From bdeaeed28c4689da7b09c381420b5fb3a7035713 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 9 Sep 2015 01:25:09 -0700 Subject: [PATCH 01/37] Use webpack to build final product This patch changes the way the `wpcom.js` library is generated and built as a library by incorporating a **webpack**-based build system. Previously, when `wpcom.js` was imported into another project, the code that was hand-written was what made it into the dependent project. Previous coding style corresponded somewhat with this paradigm: skip whitespace to save bytes. Now, webpack is used to bundle up all of the constituent code, run it through a processor, and spit out the final and single file. This opens up new possibilities for the project including but not limited to: - Significant size reduction due to the way **webpack** optimizes and minifies the output code. For example, the previous standalone code was produced with **browserify** and was still a single file, but that file was around 100 KB. The new bundle produced by **webpack** is only 17 KB. - Function stripping: As a demonstration, for the standalone product I have imported a plugin into **webpack** that strips out calls to `debug`, `console.log`, and `console.warn`. This can be helpful for making a general-release build without the development hooks. - ES6 running natively in the library! The output bundle ends up pulling in a core-js shim, but we can use any ES6 functionality that might want, including Promises, spread/rest operators, template strings, destructuring, fat-arrow functions, and more. - Version bump from 4.7.0 to 4.7.1 to reflect the fact that the development and build system are completely new. - Updated `package.json` file with all required development dependencies. - Developers no longer mess with `index.js` in the root project directory. Instead, they should work in `wpcom.js`. The reason for this is that when `wpcom.js` gets included into another project, it's the `index.js` file that loads. Therefore, I chose to load in the processed and bundled version instead of the human-formatted one. - The `webpack.config.js` and `webpack.config.dist.js` files are related. The `dist` file simply extends the base configuration to produce something like what **browserify** used to create. While the base configuration is set to create a `commonjs2` module, the `dist` bundle will still remain in the `UMD` format. Console logging has also been removed from the standalone version. Ironically, these files won't work with ES6 syntax, so I have included the **babel** transform into the `dist` config so I can use `Object.assign()`. - It's important that we explicitly tell **webpack** which imported modules are external libraries otherwise it will try to merge them in and then we lose proper naming conventions and things break. - Before committing I tried testing with both the standalone and base bundles. You can try this by editing `test/util.js` and changing the top import statement to specify the exact file you want. - Is there a good reason to remove the console warnings in either the standalone or the base build? A reason not to? I didn't think that developers would appreciate the messages in the console, but maybe they would want the `debug()` statements... Include source-maps Set the module entry point in package.json Previously in order to accomodate the combiled webpack bundle I had to rename the existing `index.js` into `wpcom.js` so that the right file would import when loading this module. I have now discovered the "main" attribute for `package.json` and have used that here instead of renaming `index.js`. Now, the build stage produces `index.min.js` which is the compiled output that other scripts will load when they `require( 'wpcom' )` Catch up to changes in master --- Makefile | 18 +- dist/wpcom.js | 4799 +--------------------------------------- dist/wpcom.js.map | 1 + index.min.js | 2 + index.min.js.map | 1 + package.json | 9 +- webpack.config.dist.js | 23 + webpack.config.js | 28 + 8 files changed, 76 insertions(+), 4805 deletions(-) create mode 100644 dist/wpcom.js.map create mode 100644 index.min.js create mode 100644 index.min.js.map create mode 100644 webpack.config.dist.js create mode 100644 webpack.config.js diff --git a/Makefile b/Makefile index 1cbc76f..c46f6dd 100644 --- a/Makefile +++ b/Makefile @@ -10,20 +10,26 @@ BIN := $(THIS_DIR)/node_modules/.bin NODE ?= node NPM ?= $(NODE) $(shell which npm) MOCHA ?= $(NODE) $(BIN)/mocha -BROWSERIFY ?= $(NODE) $(BIN)/browserify +WEBPACK ?= $(NODE) $(BIN)/webpack standalone: dist/wpcom.js -install: node_modules +install: node_modules index.js clean: - @rm -rf node_modules dist + @rm -rf dist index.js index.js.map + +distclean: clean + @rm -rf node_modules dist: @mkdir -p $@ dist/wpcom.js: node_modules *.js dist lib/*.js - @$(BROWSERIFY) -s WPCOM . > $@ + @$(WEBPACK) -p --config webpack.config.dist.js + +index.js: node_modules lib/*.js + @$(WEBPACK) -p --config webpack.config.js node_modules: package.json @NODE_ENV= $(NPM) install @@ -37,7 +43,7 @@ example-browser-cors: all cd examples/browser-cors/; $(NPM) install $(NODE) examples/browser-cors/index.js -test: node_modules +test: install @$(MOCHA) \ --compilers js:babel/register \ --timeout 120s \ @@ -46,7 +52,7 @@ test: node_modules --bail \ --reporter spec -test-all: node_modules +test-all: install @$(MOCHA) \ --compilers js:babel/register \ --timeout 120s \ diff --git a/dist/wpcom.js b/dist/wpcom.js index dffb708..7eda981 100644 --- a/dist/wpcom.js +++ b/dist/wpcom.js @@ -1,4797 +1,2 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WPCOM = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o %o', k, f[k]); - if ('file' !== k) { - param = 'attrs[' + i + '][' + k + ']'; - params.formData.push([ param, f[k] ]); - } - } - // set file path - f = f.file; - f = 'string' === typeof f ? fs.createReadStream(f) : f; - } - - params.formData.push([ 'media[]', f ]); - } - - return this.wpcom.req.post(params, query, null, fn); -}; - -/** - * Add media files from URL - * - * @param {Object} [query] - * @param {String|Array|Object} files - * @param {Function} fn - */ - -Media.prototype.addUrls = function (query, media, fn) { - if (undefined === fn) { - if (undefined === media) { - media = query; - query = {}; - } else if ('function' === typeof media) { - fn = media; - media = query; - query = {}; - } - } - - var path = '/sites/' + this._sid + '/media/new'; - var body = { media_urls: [] }; - - // process formData - var i, m, url, k; - - media = Array.isArray(media) ? media : [ media ]; - for (i = 0; i < media.length; i++) { - m = media[i]; - - if ('string' === typeof m) { - url = m; - } else { - if (!body.attrs) { - body.attrs = []; - } - - // add attributes - body.attrs[i] = {}; - for (k in m) { - if ('url' !== k) { - body.attrs[i][k] = m[k]; - } - } - url = m.url; - } - - // push url into [media_url] - body.media_urls.push(url); - } - - return this.wpcom.req.post(path, query, body, fn); -}; - -/** - * Delete media - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Media.prototype['delete'] = Media.prototype.del = function (query, fn) { - var path = '/sites/' + this._sid + '/media/' + this._id + '/delete'; - return this.wpcom.req.del(path, query, fn); -}; - -/** - * Expose `Media` module - */ - -module.exports = Media; - -},{"debug":17,"fs":16}],9:[function(require,module,exports){ - -/** - * Module dependencies. - */ - -var Like = require('./like'); -var Reblog = require('./reblog'); -var Comment = require('./comment'); -var debug = require('debug')('wpcom:post'); - -/** - * Post methods - * - * @param {String} id - * @param {String} sid site id - * @param {WPCOM} wpcom - * @api public - */ - -function Post(id, sid, wpcom) { - if (!(this instanceof Post)) { - return new Post(id, sid, wpcom); - } - - this.wpcom = wpcom; - this._sid = sid; - - // set `id` and/or `slug` properties - id = id || {}; - if ('object' !== typeof id) { - this._id = id; - } else { - this._id = id.id; - this._slug = id.slug; - } -} - -/** - * Set post `id` - * - * @param {String} id - * @api public - */ - -Post.prototype.id = function (id) { - this._id = id; -}; - -/** - * Set post `slug` - * - * @param {String} slug - * @api public - */ - -Post.prototype.slug = function (slug) { - this._slug = slug; -}; - -/** - * Get post - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Post.prototype.get = function (query, fn) { - if (!this._id && this._slug) { - return this.getBySlug(query, fn); - } - - var path = '/sites/' + this._sid + '/posts/' + this._id; - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Get post by slug - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Post.prototype.getBySlug = function (query, fn) { - var path = '/sites/' + this._sid + '/posts/slug:' + this._slug; - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Add post - * - * @param {Object} [query] - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Post.prototype.add = function (query, body, fn) { - if (undefined === fn) { - if (undefined === body) { - body = query; - query = {}; - } else if ('function' === typeof body) { - fn = body; - body = query; - query = {}; - } - } - - var path = '/sites/' + this._sid + '/posts/new'; - - return this.wpcom.req.post(path, query, body) - .then(data => { - // update POST object - this._id = data.ID; - debug('Set post _id: %s', this._id); - - this._slug = data.slug; - debug('Set post _slug: %s', this._slug); - - if ('function' === typeof fn) { - fn(null, data); - } else { - return Promise.resolve(data); - } - }) - .catch(err => { - if ('function' === typeof fn) { - fn(err); - } else { - return Promise.reject(err); - } - }); -}; - -/** - * Edit post - * - * @param {Object} [query] - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Post.prototype.update = function (query, body, fn) { - var path = '/sites/' + this._sid + '/posts/' + this._id; - return this.wpcom.req.put(path, query, body, fn); -}; - -/** - * Delete post - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Post.prototype.del = -Post.prototype['delete'] = function (query, fn) { - var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete'; - return this.wpcom.req.del(path, query, fn); -}; - -/** - * Restore post - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Post.prototype.restore = function (query, fn) { - var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore'; - return this.wpcom.req.put(path, query, null, fn); -}; - -/** - * Get post likes list - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Post.prototype.likesList = function (query, fn) { - var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes'; - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Search within a site for related posts - * - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Post.prototype.related = function (body, fn) { - var path = '/sites/' + this._sid + '/posts/' + this._id + '/related'; - return this.wpcom.req.put(path, body, null, fn); -}; - -/** - * Create a `Like` instance - * - * @api public - */ - -Post.prototype.like = function () { - return new Like(this._id, this._sid, this.wpcom); -}; - -/** - * Create a `Reblog` instance - * - * @api public - */ - -Post.prototype.reblog = function () { - return new Reblog(this._id, this._sid, this.wpcom); -}; - -/** - * Create a `Comment` instance - * - * @param {String} [cid] comment id - * @api public - */ - -Post.prototype.comment = function (cid) { - return new Comment(cid, this._id, this._sid, this.wpcom); -}; - -/** - * Return recent comments - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Post.prototype.comments = function (query, fn) { - var comment = new Comment(null, this._id, this._sid, this.wpcom); - return comment.replies(query, fn); -}; - -/** - * Expose `Post` module - */ - -module.exports = Post; - -},{"./comment":3,"./like":6,"./reblog":10,"debug":17}],10:[function(require,module,exports){ -/** - * Reblog methods - * - * @param {String} pid post id - * @param {String} sid site id - * @param {WPCOM} wpcom - * @api public - */ - -function Reblog(pid, sid, wpcom) { - if (!sid) { - throw new Error('`site id` is not correctly defined'); - } - - if (!pid) { - throw new Error('`post id` is not correctly defined'); - } - - if (!(this instanceof Reblog)) { - return new Reblog(pid, sid, wpcom); - } - - this.wpcom = wpcom; - this._pid = pid; - this._sid = sid; -} - -/** - * Get your reblog status for a Post - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Reblog.prototype.mine = -Reblog.prototype.state = function (query, fn) { - var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine'; - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Reblog a post - * - * @param {Object} [query] - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Reblog.prototype.add = function (query, body, fn) { - if ('function' === typeof body) { - fn = body; - body = query; - query = {}; - } - - if (body && !body.destination_site_id) { - return fn(new Error('destination_site_id is not defined')); - } - - var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new'; - return this.wpcom.req.put(path, query, body, fn); -}; - -/** - * Reblog a post to - * It's almost an alias of Reblogs#add - * - * @param {Number|String} dest site id destination - * @param {String} [note] - * @param {Function} fn - * @api public - */ - -Reblog.prototype.to = function (dest, note, fn) { - if (undefined === fn) { - if (undefined === note) { - note = null; - } else if ('function' === typeof note) { - fn = note; - note = null; - } - } - - return this.add({ note: note, destination_site_id: dest }, fn); -}; - -/** - * Expose `Reblog` module - */ - -module.exports = Reblog; - -},{}],11:[function(require,module,exports){ - -/** - * Module dependencies. - */ - -var Post = require('./post'); -var Category = require('./category'); -var Tag = require('./tag'); -var Media = require('./media'); -var Comment = require('./comment'); -var Follow = require('./follow'); -var debug = require('debug')('wpcom:site'); - -/** - * Resources array - * A list of endpoints with the same structure - */ - -var resources = [ - 'categories', - 'comments', - 'follows', - 'media', - 'posts', - 'shortcodes', - 'embeds', - [ 'pageTemplates', 'page-templates' ], - [ 'stats', 'stats' ], - [ 'statsClicks', 'stats/clicks' ], - [ 'statsComments', 'stats/comments' ], - [ 'statsCommentFollowers', 'stats/comment-followers' ], - [ 'statsCountryViews', 'stats/country-views' ], - [ 'statsFollowers', 'stats/followers' ], - [ 'statsPublicize', 'stats/publicize' ], - [ 'statsReferrers', 'stats/referrers' ], - [ 'statsSearchTerms', 'stats/search-terms' ], - [ 'statsStreak', 'stats/streak' ], - [ 'statsSummary', 'stats/summary' ], - [ 'statsTags', 'stats/tags' ], - [ 'statsTopAuthors', 'stats/top-authors' ], - [ 'statsTopPosts', 'stats/top-posts' ], - [ 'statsVideoPlays', 'stats/video-plays' ], - [ 'statsVisits', 'stats/visits' ], - 'tags', - 'users' -]; - -/** - * Create a Site instance - * - * @param {WPCOM} wpcom - * @api public - */ - -function Site(id, wpcom) { - if (!(this instanceof Site)) { - return new Site(id, wpcom); - } - - this.wpcom = wpcom; - - debug('set %o site id', id); - this._id = encodeURIComponent(id); -} - -/** - * Require site information - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Site.prototype.get = function (query, fn) { - return this.wpcom.req.get('/sites/' + this._id, query, fn); -}; - -/** - * List method builder - * - * @param {String} subpath - * @param {Function} - * @api private - */ - -function list(subpath) { - - /** - * Create and return the List method - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - - var listMethod = function (query, fn) { - var path = '/sites/' + this._id + '/' + subpath; - return this.wpcom.req.get(path, query, fn); - }; - listMethod._publicAPI = true; - return listMethod; -} - -// walk for each resource and create related method -var i, res, isarr, name, subpath; -for (i = 0; i < resources.length; i++) { - res = resources[i]; - isarr = Array.isArray(res); - - name = isarr ? res[0] : res + 'List'; - subpath = isarr ? res[1] : res; - - debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath); - Site.prototype[name] = list(subpath); -} - -/** - * :POST: - * Create a `Post` instance - * - * @param {String} id - * @api public - */ - -Site.prototype.post = function (id) { - return new Post(id, this._id, this.wpcom); -}; - -/** - * :POST: - * Add a new blog post - * - * @param {Object} body - * @param {Function} fn - * @return {Post} new Post instance - */ - -Site.prototype.addPost = function (body, fn) { - var post = new Post(null, this._id, this.wpcom); - return post.add(body, fn); -}; - -/** - * :POST: - * Delete a blog post - * - * @param {String} id - * @param {Function} fn - * @return {Post} remove Post instance - */ - -Site.prototype.deletePost = function (id, fn) { - var post = new Post(id, this._id, this.wpcom); - return post.delete(fn); -}; - -/** - * Create a `Media` instance - * - * @param {String} id - * @api public - */ - -Site.prototype.media = function (id) { - return new Media(id, this._id, this.wpcom); -}; - -/** - * Add a media from a file - * - * @param {Object} [query] - * @param {Array|String} files - * @param {Function} fn - * @return {Post} new Post instance - */ - -Site.prototype.addMediaFiles = function (query, files, fn) { - var media = new Media(null, this._id, this.wpcom); - return media.addFiles(query, files, fn); -}; - -/** - * Add a new media from url - * - * @param {Object} [query] - * @param {Array|String} files - * @param {Function} fn - * @return {Post} new Post instance - */ - -Site.prototype.addMediaUrls = function (query, files, fn) { - var media = new Media(null, this._id, this.wpcom); - return media.addUrls(query, files, fn); -}; - -/** - * Delete a blog media - * - * @param {String} id - * @param {Function} fn - * @return {Post} removed Media instance - */ - -Site.prototype.deleteMedia = function (id, fn) { - var media = new Media(id, this._id, this.wpcom); - return media.del(fn); -}; - -/** - * Create a `Comment` instance - * - * @param {String} id - * @api public - */ - -Site.prototype.comment = function (id) { - return new Comment(id, null, this._id, this.wpcom); -}; - -/** - * Create a `Follow` instance - * - * @api public - */ - -Site.prototype.follow = function () { - return new Follow(this._id, this.wpcom); -}; - -/** - * Create a `Category` instance - * Set `cat` alias - * - * @param {String} [slug] - * @api public - */ - -Site.prototype.cat = Site.prototype.category = function (slug) { - return new Category(slug, this._id, this.wpcom); -}; - -/** - * Create a `Tag` instance - * - * @param {String} [slug] - * @api public - */ - -Site.prototype.tag = function (slug) { - return new Tag(slug, this._id, this.wpcom); -}; - -/** - * Get a rendered shortcode for a site. - * - * Note: The current user must have publishing access. - * - * @param {String} url - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Site.prototype.renderShortcode = function (url, query, fn) { - if ('string' !== typeof url) { - throw new TypeError('expected a url String'); - } - - if ('function' === typeof query) { - fn = query; - query = {}; - } - - query = query || {}; - query.shortcode = url; - - var path = '/sites/' + this._id + '/shortcodes/render'; - - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Get a rendered embed for a site. - * - * Note: The current user must have publishing access. - * - * @param {String} url - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Site.prototype.renderEmbed = function (url, query, fn) { - if ('string' !== typeof url) { - throw new TypeError('expected an embed String'); - } - - if ('function' === typeof query) { - fn = query; - query = {}; - } - - query = query || {}; - query.embed_url = url; - - var path = '/sites/' + this._id + '/embeds/render'; - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Mark a referrering domain as spam - * - * @param {String} domain - * @param {Function} fn - * @api public - */ - -Site.prototype.statsReferrersSpamNew = function (domain, fn) { - var path = '/sites/' + this._id + '/stats/referrers/spam/new'; - var body = { domain: domain }; - - return this.wpcom.req.post(path, body, null, fn); -}; - -/** - * Remove referrering domain from spam - * - * @param {String} domain - * @param {Function} fn - * @api public - */ - -Site.prototype.statsReferrersSpamDelete = function (domain, fn) { - var path = '/sites/' + this._id + '/stats/referrers/spam/delete'; - var body = { domain: domain }; - - return this.wpcom.req.post(path, body, null, fn); -}; - -/** - * Get detailed stats about a VideoPress video - * - * @param {String} videoId - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Site.prototype.statsVideo = function (videoId, query, fn) { - var path = '/sites/' + this._id + '/stats/video/' + videoId; - - if ('function' === typeof query) { - fn = query; - query = {}; - } - - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Get detailed stats about a particular post - * - * @param {String} postId - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Site.prototype.statsPostViews = function (postId, query, fn) { - var path = '/sites/' + this._id + '/stats/post/' + postId; - - if ('function' === typeof query) { - fn = query; - query = {}; - } - - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Expose `Site` module - */ - -module.exports = Site; -},{"./category":2,"./comment":3,"./follow":5,"./media":8,"./post":9,"./tag":12,"debug":17}],12:[function(require,module,exports){ -/** - * Tag methods - * - * @param {String} [slug] - * @param {String} sid site id - * @param {WPCOM} wpcom - * @api public - */ - -function Tag(slug, sid, wpcom) { - if (!sid) { - throw new Error('`site id` is not correctly defined'); - } - - if (!(this instanceof Tag)) { - return new Tag(slug, sid, wpcom); - } - - this.wpcom = wpcom; - this._sid = sid; - this._slug = slug; -} - -/** - * Set tag `slug` - * - * @param {String} slug - * @api public - */ - -Tag.prototype.slug = function (slug) { - this._slug = slug; -}; - -/** - * Get tag - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Tag.prototype.get = function (query, fn) { - var path = '/sites/' + this._sid + '/tags/slug:' + this._slug; - return this.wpcom.req.get(path, query, fn); -}; - -/** - * Add tag - * - * @param {Object} [query] - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Tag.prototype.add = function (query, body, fn) { - var path = '/sites/' + this._sid + '/tags/new'; - return this.wpcom.req.post(path, query, body, fn); -}; - -/** - * Edit tag - * - * @param {Object} [query] - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Tag.prototype.update = function (query, body, fn) { - var path = '/sites/' + this._sid + '/tags/slug:' + this._slug; - return this.wpcom.req.put(path, query, body, fn); -}; - -/** - * Delete tag - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Tag.prototype['delete'] = Tag.prototype.del = function (query, fn) { - var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete'; - return this.wpcom.req.del(path, query, fn); -}; - -/** - * Expose `Tag` module - */ - -module.exports = Tag; -},{}],13:[function(require,module,exports){ -/** - * Create a `Users` instance - * - * @param {WPCOM} wpcom - * @api public - */ - -function Users(wpcom) { - if (!(this instanceof Users)) { - return new Users(wpcom); - } - - this.wpcom = wpcom; -} - -/** - * A list of @mention suggestions for the current user - * - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Users.prototype.suggest = function (query, fn) { - return this.wpcom.req.get('/users/suggest', query, fn); -}; - -/** - * Expose `Users` module - */ - -module.exports = Users; -},{}],14:[function(require,module,exports){ - -/** - * Module dependencies. - */ - -var sendRequest = require('./send-request'); - -/** - * Expose `Request` module - */ - - -function Req(wpcom) { - - this.wpcom = wpcom; -} - -/** - * Request methods - * - * @param {Object|String} params - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Req.prototype.get = function (params, query, fn) { - // `query` is optional - if ('function' === typeof query) { - fn = query; - query = {}; - } - - return sendRequest.call(this.wpcom, params, query, null, fn); -}; - -/** - * Make `update` request - * - * @param {Object|String} params - * @param {Object} [query] - * @param {Object} body - * @param {Function} fn - * @api public - */ - -Req.prototype.post = -Req.prototype.put = function (params, query, body, fn) { - if (undefined === fn) { - if (undefined === body) { - body = query; - query = {}; - } else if ('function' === typeof body) { - fn = body; - body = query; - query = {}; - } - } - - // params can be a string - params = 'string' === typeof params ? { path : params } : params; - - // request method - params.method = 'post'; - - return sendRequest.call(this.wpcom, params, query, body, fn); -}; - -/** - * Make a `delete` request - * - * @param {Object|String} params - * @param {Object} [query] - * @param {Function} fn - * @api public - */ - -Req.prototype.del = function (params, query, fn) { - if ('function' === typeof query) { - fn = query; - query = {}; - } - - return this.post(params, query, null, fn); -}; - -/** - * Expose module - */ - -module.exports = Req; - -},{"./send-request":15}],15:[function(require,module,exports){ - -/** - * Module dependencies - */ - -var qs = require('qs'); -var debug = require('debug')('wpcom:send-request'); -var debug_res = require('debug')('wpcom:send-request:res'); - -/** - * Request to WordPress REST API - * - * @param {String|Object} params - * @param {Object} [query] - * @param {Object} [body] - * @param {Function} fn - * @api private - */ - -module.exports = function (params, query, body, fn) { - // `params` can be just the path (String) - params = 'string' === typeof params ? { path : params } : params; - - debug('sendRequest(%o)', params.path); - - // set `method` request param - params.method = (params.method || 'get').toUpperCase(); - - // `query` is optional - if ('function' === typeof query) { - fn = query; - query = {}; - } - - // `body` is optional - if ('function' === typeof body) { - fn = body; - body = null; - } - - // query could be `null` - query = query || {}; - - // Handle special query parameters - // - `apiVersion` - if (query.apiVersion) { - params.apiVersion = query.apiVersion; - debug('apiVersion: %o', params.apiVersion); - delete query.apiVersion; - } else { - params.apiVersion = this.apiVersion; - } - - // - `proxyOrigin` - if (query.proxyOrigin) { - params.proxyOrigin = query.proxyOrigin; - debug('proxyOrigin: %o', params.proxyOrigin); - delete query.proxyOrigin; - } - - // Stringify query object before to send - query = qs.stringify(query, { arrayFormat: 'brackets' }); - - // pass `query` and/or `body` to request params - params.query = query; - - if (body) { - params.body = body; - } - debug('params: %o', params); - - // if callback is provided, behave traditionally - if ('function' === typeof fn) { - // request method - return this.request(params, function (err, res) { - debug_res(res); - fn(err, res); - }); - } - - // but if not, return a Promise - return new Promise((resolve, reject) => { - this.request(params, (err, res) => { - debug_res(res); - err ? reject(err) : resolve(res); - }); - }); -}; - -},{"debug":17,"qs":20}],16:[function(require,module,exports){ - -},{}],17:[function(require,module,exports){ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - return JSON.stringify(v); -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} - -},{"./debug":18}],18:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = debug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lowercased letter, i.e. "n". - */ - -exports.formatters = {}; - -/** - * Previously assigned color. - */ - -var prevColor = 0; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * - * @return {Number} - * @api private - */ - -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function debug(namespace) { - - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; - - // define the `enabled` version - function enabled() { - - var self = enabled; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); - - var args = Array.prototype.slice.call(arguments); - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - enabled.enabled = true; - - var fn = exports.enabled(namespace) ? enabled : disabled; - - fn.namespace = namespace; - - return fn; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":19}],19:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} - -},{}],20:[function(require,module,exports){ -// Load modules - -var Stringify = require('./stringify'); -var Parse = require('./parse'); - - -// Declare internals - -var internals = {}; - - -module.exports = { - stringify: Stringify, - parse: Parse -}; - -},{"./parse":21,"./stringify":22}],21:[function(require,module,exports){ -// Load modules - -var Utils = require('./utils'); - - -// Declare internals - -var internals = { - delimiter: '&', - depth: 5, - arrayLimit: 20, - parameterLimit: 1000, - strictNullHandling: false, - plainObjects: false, - allowPrototypes: false -}; - - -internals.parseValues = function (str, options) { - - var obj = {}; - var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); - - for (var i = 0, il = parts.length; i < il; ++i) { - var part = parts[i]; - var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; - - if (pos === -1) { - obj[Utils.decode(part)] = ''; - - if (options.strictNullHandling) { - obj[Utils.decode(part)] = null; - } - } - else { - var key = Utils.decode(part.slice(0, pos)); - var val = Utils.decode(part.slice(pos + 1)); - - if (!Object.prototype.hasOwnProperty.call(obj, key)) { - obj[key] = val; - } - else { - obj[key] = [].concat(obj[key]).concat(val); - } - } - } - - return obj; -}; - - -internals.parseObject = function (chain, val, options) { - - if (!chain.length) { - return val; - } - - var root = chain.shift(); - - var obj; - if (root === '[]') { - obj = []; - obj = obj.concat(internals.parseObject(chain, val, options)); - } - else { - obj = options.plainObjects ? Object.create(null) : {}; - var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; - var index = parseInt(cleanRoot, 10); - var indexString = '' + index; - if (!isNaN(index) && - root !== cleanRoot && - indexString === cleanRoot && - index >= 0 && - (options.parseArrays && - index <= options.arrayLimit)) { - - obj = []; - obj[index] = internals.parseObject(chain, val, options); - } - else { - obj[cleanRoot] = internals.parseObject(chain, val, options); - } - } - - return obj; -}; - - -internals.parseKeys = function (key, val, options) { - - if (!key) { - return; - } - - // Transform dot notation to bracket notation - - if (options.allowDots) { - key = key.replace(/\.([^\.\[]+)/g, '[$1]'); - } - - // The regex chunks - - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; - - // Get the parent - - var segment = parent.exec(key); - - // Stash the parent if it exists - - var keys = []; - if (segment[1]) { - // If we aren't using plain objects, optionally prefix keys - // that would overwrite object prototype properties - if (!options.plainObjects && - Object.prototype.hasOwnProperty(segment[1])) { - - if (!options.allowPrototypes) { - return; - } - } - - keys.push(segment[1]); - } - - // Loop through children appending to the array until we hit depth - - var i = 0; - while ((segment = child.exec(key)) !== null && i < options.depth) { - - ++i; - if (!options.plainObjects && - Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { - - if (!options.allowPrototypes) { - continue; - } - } - keys.push(segment[1]); - } - - // If there's a remainder, just add whatever is left - - if (segment) { - keys.push('[' + key.slice(segment.index) + ']'); - } - - return internals.parseObject(keys, val, options); -}; - - -module.exports = function (str, options) { - - options = options || {}; - options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter; - options.depth = typeof options.depth === 'number' ? options.depth : internals.depth; - options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit; - options.parseArrays = options.parseArrays !== false; - options.allowDots = options.allowDots !== false; - options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects; - options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes; - options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit; - options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; - - if (str === '' || - str === null || - typeof str === 'undefined') { - - return options.plainObjects ? Object.create(null) : {}; - } - - var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str; - var obj = options.plainObjects ? Object.create(null) : {}; - - // Iterate over the keys and setup the new object - - var keys = Object.keys(tempObj); - for (var i = 0, il = keys.length; i < il; ++i) { - var key = keys[i]; - var newObj = internals.parseKeys(key, tempObj[key], options); - obj = Utils.merge(obj, newObj, options); - } - - return Utils.compact(obj); -}; - -},{"./utils":23}],22:[function(require,module,exports){ -// Load modules - -var Utils = require('./utils'); - - -// Declare internals - -var internals = { - delimiter: '&', - arrayPrefixGenerators: { - brackets: function (prefix, key) { - - return prefix + '[]'; - }, - indices: function (prefix, key) { - - return prefix + '[' + key + ']'; - }, - repeat: function (prefix, key) { - - return prefix; - } - }, - strictNullHandling: false -}; - - -internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) { - - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } - else if (Utils.isBuffer(obj)) { - obj = obj.toString(); - } - else if (obj instanceof Date) { - obj = obj.toISOString(); - } - else if (obj === null) { - if (strictNullHandling) { - return Utils.encode(prefix); - } - - obj = ''; - } - - if (typeof obj === 'string' || - typeof obj === 'number' || - typeof obj === 'boolean') { - - return [Utils.encode(prefix) + '=' + Utils.encode(obj)]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys = Array.isArray(filter) ? filter : Object.keys(obj); - for (var i = 0, il = objKeys.length; i < il; ++i) { - var key = objKeys[i]; - - if (Array.isArray(obj)) { - values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter)); - } - else { - values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter)); - } - } - - return values; -}; - - -module.exports = function (obj, options) { - - options = options || {}; - var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter; - var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; - var objKeys; - var filter; - if (typeof options.filter === 'function') { - filter = options.filter; - obj = filter('', obj); - } - else if (Array.isArray(options.filter)) { - objKeys = filter = options.filter; - } - - var keys = []; - - if (typeof obj !== 'object' || - obj === null) { - - return ''; - } - - var arrayFormat; - if (options.arrayFormat in internals.arrayPrefixGenerators) { - arrayFormat = options.arrayFormat; - } - else if ('indices' in options) { - arrayFormat = options.indices ? 'indices' : 'repeat'; - } - else { - arrayFormat = 'indices'; - } - - var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat]; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - for (var i = 0, il = objKeys.length; i < il; ++i) { - var key = objKeys[i]; - keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter)); - } - - return keys.join(delimiter); -}; - -},{"./utils":23}],23:[function(require,module,exports){ -// Load modules - - -// Declare internals - -var internals = {}; -internals.hexTable = new Array(256); -for (var h = 0; h < 256; ++h) { - internals.hexTable[h] = '%' + ((h < 16 ? '0' : '') + h.toString(16)).toUpperCase(); -} - - -exports.arrayToObject = function (source, options) { - - var obj = options.plainObjects ? Object.create(null) : {}; - for (var i = 0, il = source.length; i < il; ++i) { - if (typeof source[i] !== 'undefined') { - - obj[i] = source[i]; - } - } - - return obj; -}; - - -exports.merge = function (target, source, options) { - - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (Array.isArray(target)) { - target.push(source); - } - else if (typeof target === 'object') { - target[source] = true; - } - else { - target = [target, source]; - } - - return target; - } - - if (typeof target !== 'object') { - target = [target].concat(source); - return target; - } - - if (Array.isArray(target) && - !Array.isArray(source)) { - - target = exports.arrayToObject(target, options); - } - - var keys = Object.keys(source); - for (var k = 0, kl = keys.length; k < kl; ++k) { - var key = keys[k]; - var value = source[key]; - - if (!Object.prototype.hasOwnProperty.call(target, key)) { - target[key] = value; - } - else { - target[key] = exports.merge(target[key], value, options); - } - } - - return target; -}; - - -exports.decode = function (str) { - - try { - return decodeURIComponent(str.replace(/\+/g, ' ')); - } catch (e) { - return str; - } -}; - -exports.encode = function (str) { - - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - if (typeof str !== 'string') { - str = '' + str; - } - - var out = ''; - for (var i = 0, il = str.length; i < il; ++i) { - var c = str.charCodeAt(i); - - if (c === 0x2D || // - - c === 0x2E || // . - c === 0x5F || // _ - c === 0x7E || // ~ - (c >= 0x30 && c <= 0x39) || // 0-9 - (c >= 0x41 && c <= 0x5A) || // a-z - (c >= 0x61 && c <= 0x7A)) { // A-Z - - out += str[i]; - continue; - } - - if (c < 0x80) { - out += internals.hexTable[c]; - continue; - } - - if (c < 0x800) { - out += internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)]; - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - out += internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)]; - continue; - } - - ++i; - c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF)); - out += internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)]; - } - - return out; -}; - -exports.compact = function (obj, refs) { - - if (typeof obj !== 'object' || - obj === null) { - - return obj; - } - - refs = refs || []; - var lookup = refs.indexOf(obj); - if (lookup !== -1) { - return refs[lookup]; - } - - refs.push(obj); - - if (Array.isArray(obj)) { - var compacted = []; - - for (var i = 0, il = obj.length; i < il; ++i) { - if (typeof obj[i] !== 'undefined') { - compacted.push(obj[i]); - } - } - - return compacted; - } - - var keys = Object.keys(obj); - for (i = 0, il = keys.length; i < il; ++i) { - var key = keys[i]; - obj[key] = exports.compact(obj[key], refs); - } - - return obj; -}; - - -exports.isRegExp = function (obj) { - - return Object.prototype.toString.call(obj) === '[object RegExp]'; -}; - - -exports.isBuffer = function (obj) { - - if (obj === null || - typeof obj === 'undefined') { - - return false; - } - - return !!(obj.constructor && - obj.constructor.isBuffer && - obj.constructor.isBuffer(obj)); -}; - -},{}],24:[function(require,module,exports){ - -/** - * Module dependencies. - */ - -var superagent = require('superagent'); -var debug = require('debug')('wpcom-xhr-request'); - -/** - * Export a single `request` function. - */ - -module.exports = request; - -/** - * WordPress.com REST API base endpoint. - */ - -var proxyOrigin = 'https://public-api.wordpress.com'; - -/** - * Default WordPress.com REST API Version. - */ - -var defaultApiVersion = '1'; - -/** - * Performs an XMLHttpRequest against the WordPress.com REST API. - * - * @param {Object|String} params - * @param {Function} fn - * @api public - */ - -function request (params, fn) { - - if ('string' == typeof params) { - params = { path: params }; - } - - var method = (params.method || 'GET').toLowerCase(); - debug('API HTTP Method: %o', method); - delete params.method; - - var apiVersion = params.apiVersion || defaultApiVersion; - delete params.apiVersion; - - proxyOrigin = params.proxyOrigin || proxyOrigin; - delete params.proxyOrigin; - - var url = proxyOrigin + '/rest/v' + apiVersion + params.path; - debug('API URL: %o', url); - delete params.path; - - // create HTTP Request object - var req = superagent[method](url); - - // Token authentication - if (params.authToken) { - req.set('Authorization', 'Bearer ' + params.authToken); - delete params.authToken; - } - - // URL querystring values - if (params.query) { - req.query(params.query); - debug('API send URL querystring: %o', params.query); - delete params.query; - } - - // POST API request body - if (params.body) { - req.send(params.body); - debug('API send POST body: ', params.body); - delete params.body; - } - - // POST FormData (for `multipart/form-data`, usually a file upload) - if (params.formData) { - for (var i = 0; i < params.formData.length; i++) { - var data = params.formData[i]; - var key = data[0]; - var value = data[1]; - debug('adding FormData field %o', key); - req.field(key, value); - } - } - - // start the request - req.end(function (err, res){ - if (err && !res) { - return fn(err); - } - - var body = res.body; - var headers = res.headers; - var statusCode = res.status; - debug('%o -> %o status code', url, statusCode); - - if (body && headers) { - body._headers = headers; - } - - if (!err) { - return fn(null, body); - } - - err = new Error(); - err.statusCode = statusCode; - for (var i in body) { - err[i] = body[i]; - } - - if (body && body.error) { - err.name = toTitle(body.error) + 'Error'; - } - - fn(err); - }); - - return req.xhr; -} - -function toTitle (str) { - if (!str || 'string' !== typeof str) return ''; - return str.replace(/((^|_)[a-z])/g, function ($1) { - return $1.toUpperCase().replace('_', ''); - }); -} - -},{"debug":25,"superagent":28}],25:[function(require,module,exports){ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; - -/** - * Use chrome.storage.local if we are in an app - */ - -var storage; - -if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined') - storage = chrome.storage.local; -else - storage = localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - return JSON.stringify(v); -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - storage.removeItem('debug'); - } else { - storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} - -},{"./debug":26}],26:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"dup":18,"ms":27}],27:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} - -},{}],28:[function(require,module,exports){ -/** - * Module dependencies. - */ - -var Emitter = require('emitter'); -var reduce = require('reduce'); - -/** - * Root reference for iframes. - */ - -var root = 'undefined' == typeof window - ? (this || self) - : window; - -/** - * Noop. - */ - -function noop(){}; - -/** - * Check if `obj` is a host object, - * we don't want to serialize these :) - * - * TODO: future proof, move to compoent land - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ - -function isHost(obj) { - var str = {}.toString.call(obj); - - switch (str) { - case '[object File]': - case '[object Blob]': - case '[object FormData]': - return true; - default: - return false; - } -} - -/** - * Determine XHR. - */ - -request.getXHR = function () { - if (root.XMLHttpRequest - && (!root.location || 'file:' != root.location.protocol - || !root.ActiveXObject)) { - return new XMLHttpRequest; - } else { - try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} - try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {} - try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {} - try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {} - } - return false; -}; - -/** - * Removes leading and trailing whitespace, added to support IE. - * - * @param {String} s - * @return {String} - * @api private - */ - -var trim = ''.trim - ? function(s) { return s.trim(); } - : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); }; - -/** - * Check if `obj` is an object. - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ - -function isObject(obj) { - return obj === Object(obj); -} - -/** - * Serialize the given `obj`. - * - * @param {Object} obj - * @return {String} - * @api private - */ - -function serialize(obj) { - if (!isObject(obj)) return obj; - var pairs = []; - for (var key in obj) { - if (null != obj[key]) { - pairs.push(encodeURIComponent(key) - + '=' + encodeURIComponent(obj[key])); - } - } - return pairs.join('&'); -} - -/** - * Expose serialization method. - */ - - request.serializeObject = serialize; - - /** - * Parse the given x-www-form-urlencoded `str`. - * - * @param {String} str - * @return {Object} - * @api private - */ - -function parseString(str) { - var obj = {}; - var pairs = str.split('&'); - var parts; - var pair; - - for (var i = 0, len = pairs.length; i < len; ++i) { - pair = pairs[i]; - parts = pair.split('='); - obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]); - } - - return obj; -} - -/** - * Expose parser. - */ - -request.parseString = parseString; - -/** - * Default MIME type map. - * - * superagent.types.xml = 'application/xml'; - * - */ - -request.types = { - html: 'text/html', - json: 'application/json', - xml: 'application/xml', - urlencoded: 'application/x-www-form-urlencoded', - 'form': 'application/x-www-form-urlencoded', - 'form-data': 'application/x-www-form-urlencoded' -}; - -/** - * Default serialization map. - * - * superagent.serialize['application/xml'] = function(obj){ - * return 'generated xml here'; - * }; - * - */ - - request.serialize = { - 'application/x-www-form-urlencoded': serialize, - 'application/json': JSON.stringify - }; - - /** - * Default parsers. - * - * superagent.parse['application/xml'] = function(str){ - * return { object parsed from str }; - * }; - * - */ - -request.parse = { - 'application/x-www-form-urlencoded': parseString, - 'application/json': JSON.parse -}; - -/** - * Parse the given header `str` into - * an object containing the mapped fields. - * - * @param {String} str - * @return {Object} - * @api private - */ - -function parseHeader(str) { - var lines = str.split(/\r?\n/); - var fields = {}; - var index; - var line; - var field; - var val; - - lines.pop(); // trailing CRLF - - for (var i = 0, len = lines.length; i < len; ++i) { - line = lines[i]; - index = line.indexOf(':'); - field = line.slice(0, index).toLowerCase(); - val = trim(line.slice(index + 1)); - fields[field] = val; - } - - return fields; -} - -/** - * Return the mime type for the given `str`. - * - * @param {String} str - * @return {String} - * @api private - */ - -function type(str){ - return str.split(/ *; */).shift(); -}; - -/** - * Return header field parameters. - * - * @param {String} str - * @return {Object} - * @api private - */ - -function params(str){ - return reduce(str.split(/ *; */), function(obj, str){ - var parts = str.split(/ *= */) - , key = parts.shift() - , val = parts.shift(); - - if (key && val) obj[key] = val; - return obj; - }, {}); -}; - -/** - * Initialize a new `Response` with the given `xhr`. - * - * - set flags (.ok, .error, etc) - * - parse header - * - * Examples: - * - * Aliasing `superagent` as `request` is nice: - * - * request = superagent; - * - * We can use the promise-like API, or pass callbacks: - * - * request.get('/').end(function(res){}); - * request.get('/', function(res){}); - * - * Sending data can be chained: - * - * request - * .post('/user') - * .send({ name: 'tj' }) - * .end(function(res){}); - * - * Or passed to `.send()`: - * - * request - * .post('/user') - * .send({ name: 'tj' }, function(res){}); - * - * Or passed to `.post()`: - * - * request - * .post('/user', { name: 'tj' }) - * .end(function(res){}); - * - * Or further reduced to a single call for simple cases: - * - * request - * .post('/user', { name: 'tj' }, function(res){}); - * - * @param {XMLHTTPRequest} xhr - * @param {Object} options - * @api private - */ - -function Response(req, options) { - options = options || {}; - this.req = req; - this.xhr = this.req.xhr; - // responseText is accessible only if responseType is '' or 'text' and on older browsers - this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined') - ? this.xhr.responseText - : null; - this.statusText = this.req.xhr.statusText; - this.setStatusProperties(this.xhr.status); - this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); - // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but - // getResponseHeader still works. so we get content-type even if getting - // other headers fails. - this.header['content-type'] = this.xhr.getResponseHeader('content-type'); - this.setHeaderProperties(this.header); - this.body = this.req.method != 'HEAD' - ? this.parseBody(this.text ? this.text : this.xhr.response) - : null; -} - -/** - * Get case-insensitive `field` value. - * - * @param {String} field - * @return {String} - * @api public - */ - -Response.prototype.get = function(field){ - return this.header[field.toLowerCase()]; -}; - -/** - * Set header related properties: - * - * - `.type` the content type without params - * - * A response of "Content-Type: text/plain; charset=utf-8" - * will provide you with a `.type` of "text/plain". - * - * @param {Object} header - * @api private - */ - -Response.prototype.setHeaderProperties = function(header){ - // content-type - var ct = this.header['content-type'] || ''; - this.type = type(ct); - - // params - var obj = params(ct); - for (var key in obj) this[key] = obj[key]; -}; - -/** - * Parse the given body `str`. - * - * Used for auto-parsing of bodies. Parsers - * are defined on the `superagent.parse` object. - * - * @param {String} str - * @return {Mixed} - * @api private - */ - -Response.prototype.parseBody = function(str){ - var parse = request.parse[this.type]; - return parse && str && (str.length || str instanceof Object) - ? parse(str) - : null; -}; - -/** - * Set flags such as `.ok` based on `status`. - * - * For example a 2xx response will give you a `.ok` of __true__ - * whereas 5xx will be __false__ and `.error` will be __true__. The - * `.clientError` and `.serverError` are also available to be more - * specific, and `.statusType` is the class of error ranging from 1..5 - * sometimes useful for mapping respond colors etc. - * - * "sugar" properties are also defined for common cases. Currently providing: - * - * - .noContent - * - .badRequest - * - .unauthorized - * - .notAcceptable - * - .notFound - * - * @param {Number} status - * @api private - */ - -Response.prototype.setStatusProperties = function(status){ - // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request - if (status === 1223) { - status = 204; - } - - var type = status / 100 | 0; - - // status / class - this.status = status; - this.statusType = type; - - // basics - this.info = 1 == type; - this.ok = 2 == type; - this.clientError = 4 == type; - this.serverError = 5 == type; - this.error = (4 == type || 5 == type) - ? this.toError() - : false; - - // sugar - this.accepted = 202 == status; - this.noContent = 204 == status; - this.badRequest = 400 == status; - this.unauthorized = 401 == status; - this.notAcceptable = 406 == status; - this.notFound = 404 == status; - this.forbidden = 403 == status; -}; - -/** - * Return an `Error` representative of this response. - * - * @return {Error} - * @api public - */ - -Response.prototype.toError = function(){ - var req = this.req; - var method = req.method; - var url = req.url; - - var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')'; - var err = new Error(msg); - err.status = this.status; - err.method = method; - err.url = url; - - return err; -}; - -/** - * Expose `Response`. - */ - -request.Response = Response; - -/** - * Initialize a new `Request` with the given `method` and `url`. - * - * @param {String} method - * @param {String} url - * @api public - */ - -function Request(method, url) { - var self = this; - Emitter.call(this); - this._query = this._query || []; - this.method = method; - this.url = url; - this.header = {}; - this._header = {}; - this.on('end', function(){ - var err = null; - var res = null; - - try { - res = new Response(self); - } catch(e) { - err = new Error('Parser is unable to parse the response'); - err.parse = true; - err.original = e; - return self.callback(err); - } - - self.emit('response', res); - - if (err) { - return self.callback(err, res); - } - - if (res.status >= 200 && res.status < 300) { - return self.callback(err, res); - } - - var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); - new_err.original = err; - new_err.response = res; - new_err.status = res.status; - - self.callback(err || new_err, res); - }); -} - -/** - * Mixin `Emitter`. - */ - -Emitter(Request.prototype); - -/** - * Allow for extension - */ - -Request.prototype.use = function(fn) { - fn(this); - return this; -} - -/** - * Set timeout to `ms`. - * - * @param {Number} ms - * @return {Request} for chaining - * @api public - */ - -Request.prototype.timeout = function(ms){ - this._timeout = ms; - return this; -}; - -/** - * Clear previous timeout. - * - * @return {Request} for chaining - * @api public - */ - -Request.prototype.clearTimeout = function(){ - this._timeout = 0; - clearTimeout(this._timer); - return this; -}; - -/** - * Abort the request, and clear potential timeout. - * - * @return {Request} - * @api public - */ - -Request.prototype.abort = function(){ - if (this.aborted) return; - this.aborted = true; - this.xhr.abort(); - this.clearTimeout(); - this.emit('abort'); - return this; -}; - -/** - * Set header `field` to `val`, or multiple fields with one object. - * - * Examples: - * - * req.get('/') - * .set('Accept', 'application/json') - * .set('X-API-Key', 'foobar') - * .end(callback); - * - * req.get('/') - * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) - * .end(callback); - * - * @param {String|Object} field - * @param {String} val - * @return {Request} for chaining - * @api public - */ - -Request.prototype.set = function(field, val){ - if (isObject(field)) { - for (var key in field) { - this.set(key, field[key]); - } - return this; - } - this._header[field.toLowerCase()] = val; - this.header[field] = val; - return this; -}; - -/** - * Remove header `field`. - * - * Example: - * - * req.get('/') - * .unset('User-Agent') - * .end(callback); - * - * @param {String} field - * @return {Request} for chaining - * @api public - */ - -Request.prototype.unset = function(field){ - delete this._header[field.toLowerCase()]; - delete this.header[field]; - return this; -}; - -/** - * Get case-insensitive header `field` value. - * - * @param {String} field - * @return {String} - * @api private - */ - -Request.prototype.getHeader = function(field){ - return this._header[field.toLowerCase()]; -}; - -/** - * Set Content-Type to `type`, mapping values from `request.types`. - * - * Examples: - * - * superagent.types.xml = 'application/xml'; - * - * request.post('/') - * .type('xml') - * .send(xmlstring) - * .end(callback); - * - * request.post('/') - * .type('application/xml') - * .send(xmlstring) - * .end(callback); - * - * @param {String} type - * @return {Request} for chaining - * @api public - */ - -Request.prototype.type = function(type){ - this.set('Content-Type', request.types[type] || type); - return this; -}; - -/** - * Set Accept to `type`, mapping values from `request.types`. - * - * Examples: - * - * superagent.types.json = 'application/json'; - * - * request.get('/agent') - * .accept('json') - * .end(callback); - * - * request.get('/agent') - * .accept('application/json') - * .end(callback); - * - * @param {String} accept - * @return {Request} for chaining - * @api public - */ - -Request.prototype.accept = function(type){ - this.set('Accept', request.types[type] || type); - return this; -}; - -/** - * Set Authorization field value with `user` and `pass`. - * - * @param {String} user - * @param {String} pass - * @return {Request} for chaining - * @api public - */ - -Request.prototype.auth = function(user, pass){ - var str = btoa(user + ':' + pass); - this.set('Authorization', 'Basic ' + str); - return this; -}; - -/** -* Add query-string `val`. -* -* Examples: -* -* request.get('/shoes') -* .query('size=10') -* .query({ color: 'blue' }) -* -* @param {Object|String} val -* @return {Request} for chaining -* @api public -*/ - -Request.prototype.query = function(val){ - if ('string' != typeof val) val = serialize(val); - if (val) this._query.push(val); - return this; -}; - -/** - * Write the field `name` and `val` for "multipart/form-data" - * request bodies. - * - * ``` js - * request.post('/upload') - * .field('foo', 'bar') - * .end(callback); - * ``` - * - * @param {String} name - * @param {String|Blob|File} val - * @return {Request} for chaining - * @api public - */ - -Request.prototype.field = function(name, val){ - if (!this._formData) this._formData = new root.FormData(); - this._formData.append(name, val); - return this; -}; - -/** - * Queue the given `file` as an attachment to the specified `field`, - * with optional `filename`. - * - * ``` js - * request.post('/upload') - * .attach(new Blob(['hey!'], { type: "text/html"})) - * .end(callback); - * ``` - * - * @param {String} field - * @param {Blob|File} file - * @param {String} filename - * @return {Request} for chaining - * @api public - */ - -Request.prototype.attach = function(field, file, filename){ - if (!this._formData) this._formData = new root.FormData(); - this._formData.append(field, file, filename); - return this; -}; - -/** - * Send `data`, defaulting the `.type()` to "json" when - * an object is given. - * - * Examples: - * - * // querystring - * request.get('/search') - * .end(callback) - * - * // multiple data "writes" - * request.get('/search') - * .send({ search: 'query' }) - * .send({ range: '1..5' }) - * .send({ order: 'desc' }) - * .end(callback) - * - * // manual json - * request.post('/user') - * .type('json') - * .send('{"name":"tj"}) - * .end(callback) - * - * // auto json - * request.post('/user') - * .send({ name: 'tj' }) - * .end(callback) - * - * // manual x-www-form-urlencoded - * request.post('/user') - * .type('form') - * .send('name=tj') - * .end(callback) - * - * // auto x-www-form-urlencoded - * request.post('/user') - * .type('form') - * .send({ name: 'tj' }) - * .end(callback) - * - * // defaults to x-www-form-urlencoded - * request.post('/user') - * .send('name=tobi') - * .send('species=ferret') - * .end(callback) - * - * @param {String|Object} data - * @return {Request} for chaining - * @api public - */ - -Request.prototype.send = function(data){ - var obj = isObject(data); - var type = this.getHeader('Content-Type'); - - // merge - if (obj && isObject(this._data)) { - for (var key in data) { - this._data[key] = data[key]; - } - } else if ('string' == typeof data) { - if (!type) this.type('form'); - type = this.getHeader('Content-Type'); - if ('application/x-www-form-urlencoded' == type) { - this._data = this._data - ? this._data + '&' + data - : data; - } else { - this._data = (this._data || '') + data; - } - } else { - this._data = data; - } - - if (!obj || isHost(data)) return this; - if (!type) this.type('json'); - return this; -}; - -/** - * Invoke the callback with `err` and `res` - * and handle arity check. - * - * @param {Error} err - * @param {Response} res - * @api private - */ - -Request.prototype.callback = function(err, res){ - var fn = this._callback; - this.clearTimeout(); - fn(err, res); -}; - -/** - * Invoke callback with x-domain error. - * - * @api private - */ - -Request.prototype.crossDomainError = function(){ - var err = new Error('Origin is not allowed by Access-Control-Allow-Origin'); - err.crossDomain = true; - this.callback(err); -}; - -/** - * Invoke callback with timeout error. - * - * @api private - */ - -Request.prototype.timeoutError = function(){ - var timeout = this._timeout; - var err = new Error('timeout of ' + timeout + 'ms exceeded'); - err.timeout = timeout; - this.callback(err); -}; - -/** - * Enable transmission of cookies with x-domain requests. - * - * Note that for this to work the origin must not be - * using "Access-Control-Allow-Origin" with a wildcard, - * and also must set "Access-Control-Allow-Credentials" - * to "true". - * - * @api public - */ - -Request.prototype.withCredentials = function(){ - this._withCredentials = true; - return this; -}; - -/** - * Initiate request, invoking callback `fn(res)` - * with an instanceof `Response`. - * - * @param {Function} fn - * @return {Request} for chaining - * @api public - */ - -Request.prototype.end = function(fn){ - var self = this; - var xhr = this.xhr = request.getXHR(); - var query = this._query.join('&'); - var timeout = this._timeout; - var data = this._formData || this._data; - - // store callback - this._callback = fn || noop; - - // state change - xhr.onreadystatechange = function(){ - if (4 != xhr.readyState) return; - - // In IE9, reads to any property (e.g. status) off of an aborted XHR will - // result in the error "Could not complete the operation due to error c00c023f" - var status; - try { status = xhr.status } catch(e) { status = 0; } - - if (0 == status) { - if (self.timedout) return self.timeoutError(); - if (self.aborted) return; - return self.crossDomainError(); - } - self.emit('end'); - }; - - // progress - var handleProgress = function(e){ - if (e.total > 0) { - e.percent = e.loaded / e.total * 100; - } - self.emit('progress', e); - }; - if (this.hasListeners('progress')) { - xhr.onprogress = handleProgress; - } - try { - if (xhr.upload && this.hasListeners('progress')) { - xhr.upload.onprogress = handleProgress; - } - } catch(e) { - // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. - // Reported here: - // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context - } - - // timeout - if (timeout && !this._timer) { - this._timer = setTimeout(function(){ - self.timedout = true; - self.abort(); - }, timeout); - } - - // querystring - if (query) { - query = request.serializeObject(query); - this.url += ~this.url.indexOf('?') - ? '&' + query - : '?' + query; - } - - // initiate request - xhr.open(this.method, this.url, true); - - // CORS - if (this._withCredentials) xhr.withCredentials = true; - - // body - if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) { - // serialize stuff - var serialize = request.serialize[this.getHeader('Content-Type')]; - if (serialize) data = serialize(data); - } - - // set header fields - for (var field in this.header) { - if (null == this.header[field]) continue; - xhr.setRequestHeader(field, this.header[field]); - } - - // send stuff - this.emit('request', this); - xhr.send(data); - return this; -}; - -/** - * Expose `Request`. - */ - -request.Request = Request; - -/** - * Issue a request: - * - * Examples: - * - * request('GET', '/users').end(callback) - * request('/users').end(callback) - * request('/users', callback) - * - * @param {String} method - * @param {String|Function} url or callback - * @return {Request} - * @api public - */ - -function request(method, url) { - // callback - if ('function' == typeof url) { - return new Request('GET', method).end(url); - } - - // url first - if (1 == arguments.length) { - return new Request('GET', method); - } - - return new Request(method, url); -} - -/** - * GET `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} data or fn - * @param {Function} fn - * @return {Request} - * @api public - */ - -request.get = function(url, data, fn){ - var req = request('GET', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.query(data); - if (fn) req.end(fn); - return req; -}; - -/** - * HEAD `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} data or fn - * @param {Function} fn - * @return {Request} - * @api public - */ - -request.head = function(url, data, fn){ - var req = request('HEAD', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * DELETE `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Function} fn - * @return {Request} - * @api public - */ - -request.del = function(url, fn){ - var req = request('DELETE', url); - if (fn) req.end(fn); - return req; -}; - -/** - * PATCH `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} data - * @param {Function} fn - * @return {Request} - * @api public - */ - -request.patch = function(url, data, fn){ - var req = request('PATCH', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * POST `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} data - * @param {Function} fn - * @return {Request} - * @api public - */ - -request.post = function(url, data, fn){ - var req = request('POST', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * PUT `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} data or fn - * @param {Function} fn - * @return {Request} - * @api public - */ - -request.put = function(url, data, fn){ - var req = request('PUT', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * Expose `request`. - */ - -module.exports = request; - -},{"emitter":29,"reduce":30}],29:[function(require,module,exports){ - -/** - * Expose `Emitter`. - */ - -module.exports = Emitter; - -/** - * Initialize a new `Emitter`. - * - * @api public - */ - -function Emitter(obj) { - if (obj) return mixin(obj); -}; - -/** - * Mixin the emitter properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - -function mixin(obj) { - for (var key in Emitter.prototype) { - obj[key] = Emitter.prototype[key]; - } - return obj; -} - -/** - * Listen on the given `event` with `fn`. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.on = -Emitter.prototype.addEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - (this._callbacks[event] = this._callbacks[event] || []) - .push(fn); - return this; -}; - -/** - * Adds an `event` listener that will be invoked a single - * time then automatically removed. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.once = function(event, fn){ - var self = this; - this._callbacks = this._callbacks || {}; - - function on() { - self.off(event, on); - fn.apply(this, arguments); - } - - on.fn = fn; - this.on(event, on); - return this; -}; - -/** - * Remove the given callback for `event` or all - * registered callbacks. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.off = -Emitter.prototype.removeListener = -Emitter.prototype.removeAllListeners = -Emitter.prototype.removeEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - - // all - if (0 == arguments.length) { - this._callbacks = {}; - return this; - } - - // specific event - var callbacks = this._callbacks[event]; - if (!callbacks) return this; - - // remove all handlers - if (1 == arguments.length) { - delete this._callbacks[event]; - return this; - } - - // remove specific handler - var cb; - for (var i = 0; i < callbacks.length; i++) { - cb = callbacks[i]; - if (cb === fn || cb.fn === fn) { - callbacks.splice(i, 1); - break; - } - } - return this; -}; - -/** - * Emit `event` with the given args. - * - * @param {String} event - * @param {Mixed} ... - * @return {Emitter} - */ - -Emitter.prototype.emit = function(event){ - this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) - , callbacks = this._callbacks[event]; - - if (callbacks) { - callbacks = callbacks.slice(0); - for (var i = 0, len = callbacks.length; i < len; ++i) { - callbacks[i].apply(this, args); - } - } - - return this; -}; - -/** - * Return array of callbacks for `event`. - * - * @param {String} event - * @return {Array} - * @api public - */ - -Emitter.prototype.listeners = function(event){ - this._callbacks = this._callbacks || {}; - return this._callbacks[event] || []; -}; - -/** - * Check if this emitter has `event` handlers. - * - * @param {String} event - * @return {Boolean} - * @api public - */ - -Emitter.prototype.hasListeners = function(event){ - return !! this.listeners(event).length; -}; - -},{}],30:[function(require,module,exports){ - -/** - * Reduce `arr` with `fn`. - * - * @param {Array} arr - * @param {Function} fn - * @param {Mixed} initial - * - * TODO: combatible error handling? - */ - -module.exports = function(arr, fn, initial){ - var idx = 0; - var len = arr.length; - var curr = arguments.length == 3 - ? initial - : arr[idx++]; - - while (idx < len) { - curr = fn.call(null, curr, arr[idx], ++idx, arr); - } - - return curr; -}; -},{}],31:[function(require,module,exports){ - - -/** - * Module dependencies. - */ - -var request_handler = require('wpcom-xhr-request'); - -/** - * Local module dependencies. - */ - -var Me = require('./lib/me'); -var Site = require('./lib/site'); -var Users = require('./lib/users'); -var Batch = require('./lib/batch'); -var Req = require('./lib/util/request'); -var sendRequest = require('./lib/util/send-request'); -var debug = require('debug')('wpcom'); - -/** - * Local module constants - */ -var DEFAULT_ASYNC_TIMEOUT = 30000; - -/** - * XMLHttpRequest (and CORS) API access method. - * - * API authentication is done via an (optional) access `token`, - * which needs to be retrieved via OAuth. - * - * Request Handler is optional and XHR is defined as default. - * - * @param {String} [token] - OAuth API access token - * @param {Function} [reqHandler] - function Request Handler - * @public - */ - -function WPCOM(token, reqHandler) { - if (!(this instanceof WPCOM)) { - return new WPCOM(token, reqHandler); - } - - // `token` is optional - if ('function' === typeof token) { - reqHandler = token; - token = null; - } - - if (token) { - debug('Token defined: %s…', token.substring(0, 6)); - this.token = token; - } - - // Set default request handler - if (!reqHandler) { - debug('No request handler. Adding default XHR request handler'); - - this.request = function (params, fn) { - params = params || {}; - - // token is optional - if (token) { - params.authToken = token; - } - - return request_handler(params, fn); - }; - } else { - this.request = reqHandler; - } - - // Add Req instance - this.req = new Req(this); - - // Default api version; - this.apiVersion = '1.1'; -} - -/** - * Get `Me` object instance - * - * @api public - */ - -WPCOM.prototype.me = function () { - return new Me(this); -}; - -/** - * Get `Site` object instance - * - * @param {String} id - * @api public - */ - -WPCOM.prototype.site = function (id) { - return new Site(id, this); -}; - -/** - * Get `Users` object instance - * - * @api public - */ - -WPCOM.prototype.users = function () { - return new Users(this); -}; - - -WPCOM.prototype.batch = function () { - return new Batch(this); -}; - -/** - * List Freshly Pressed Posts - * - * @param {Object} [query] - * @param {Function} fn callback function - * @api public - */ - -WPCOM.prototype.freshlyPressed = function (query, fn) { - return this.req.get('/freshly-pressed', query, fn); -}; - -/** - * Expose send-request - * @TODO: use `this.req` instead of this method - */ - -WPCOM.prototype.sendRequest = function (params, query, body, fn) { - var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.'; - if (console && console.warn) { //eslint-disable-line no-console - console.warn(msg); //eslint-disable-line no-console - } else { - console.log(msg); //eslint-disable-line no-console - } - - return sendRequest.call(this, params, query, body, fn); -}; - -if (!Promise.prototype.timeout) { - /** - * Returns a new promise with a deadline - * - * After the timeout interval, the promise will - * reject. If the actual promise settles before - * the deadline, the timer is cancelled. - * - * @param {number} delay how many ms to wait - * @returns {Promise} - */ - Promise.prototype.timeout = function (delay = DEFAULT_ASYNC_TIMEOUT) { - let cancelTimeout, timer, timeout; - - timeout = new Promise((resolve, reject) => { - timer = setTimeout(() => { - reject(new Error('Action timed out while waiting for response.')); - }, delay); - }); - - cancelTimeout = () => { - clearTimeout(timer); - return this; - }; - - return Promise.race([ this.then(cancelTimeout).catch(cancelTimeout), timeout ]); - }; -} - -/** - * Expose `WPCOM` module - */ - -module.exports = WPCOM; - -},{"./lib/batch":1,"./lib/me":7,"./lib/site":11,"./lib/users":13,"./lib/util/request":14,"./lib/util/send-request":15,"debug":17,"wpcom-xhr-request":24}]},{},[31])(31) -}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("debug"),require("fs"),require("qs"),require("wpcom-xhr-request")):"function"==typeof define&&define.amd?define(["debug","fs","qs","wpcom-xhr-request"],e):"object"==typeof exports?exports.WPCOM=e(require("debug"),require("fs"),require("qs"),require("wpcom-xhr-request")):t.WPCOM=e(t.debug,t.fs,t.qs,t["wpcom-xhr-request"])}(this,function(t,e,i,s){return function(t){function e(s){if(i[s])return i[s].exports;var o=i[s]={exports:{},id:s,loaded:!1};return t[s].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){function s(t,e){return this instanceof s?("function"==typeof t&&(e=t,t=null),t&&(h("Token defined: %s…",t.substring(0,6)),this.token=t),e?this.request=e:(h("No request handler. Adding default XHR request handler"),this.request=function(e,i){return e=e||{},t&&(e.authToken=t),o(e,i)}),this.req=new c(this),void(this.apiVersion="1.1")):new s(t,e)}var o=i(19),r=i(9),n=i(13),p=i(15),u=i(4),c=i(16),d=i(3),h=i(1)("wpcom"),a=3e4;s.prototype.me=function(){return new r(this)},s.prototype.site=function(t){return new n(t,this)},s.prototype.users=function(){return new p(this)},s.prototype.batch=function(){return new u(this)},s.prototype.freshlyPressed=function(t,e){return this.req.get("/freshly-pressed",t,e)},s.prototype.sendRequest=function(t,e,i,s){var o="WARN! Don use `sendRequest() anymore. Use `this.req` method.";return console&&console.warn?console.warn(o):console.log(o),d.call(this,t,e,i,s)},s.prototype.Promise=function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),s=1;e>s;s++)i[s-1]=arguments[s];return new Promise(function(e,s){t.apply(t,[].concat(i,[function(t,i){t?s(t):e(i)}]))})},Promise.prototype.timeout||(Promise.prototype.timeout=function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?a:arguments[0],i=void 0,s=void 0,o=void 0;return o=new Promise(function(t,i){s=setTimeout(function(){i(new Error("Action timed out while waiting for response."))},e)}),i=function(){return clearTimeout(s),t},Promise.race([this.then(i)["catch"](i),o])}),t.exports=s},function(e,i){e.exports=t},function(t,e,i){function s(t,e,i,o){if(!i)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=o,this._cid=t,this._pid=e,void(this._sid=i)):new s(t,e,i,o)}var o=i(6);i(1)("wpcom:comment");s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.get(i,t,e)},s.prototype.replies=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/replies/";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={})),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/posts/"+this._pid+"/replies/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.update=function(t,e,i){"function"==typeof e&&(i=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.put(s,t,e,i)},s.prototype.reply=function(t,e,i){"function"==typeof e&&(i=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/comments/"+this._cid+"/replies/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/delete";return this.wpcom.req.del(i,t,e)},s.prototype.like=function(){return o(this._cid,this._sid,this.wpcom)},s.prototype.likesList=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes";return this.wpcom.req.get(i,t,e)},t.exports=s},function(t,e,i){var s=i(18),o=i(1)("wpcom:send-request"),r=i(1)("wpcom:send-request:res");t.exports=function(t,e,i,n){var p=this;return t="string"==typeof t?{path:t}:t,o("sendRequest(%o)",t.path),t.method=(t.method||"get").toUpperCase(),"function"==typeof e&&(n=e,e={}),"function"==typeof i&&(n=i,i=null),e=e||{},e.apiVersion?(t.apiVersion=e.apiVersion,o("apiVersion: %o",t.apiVersion),delete e.apiVersion):t.apiVersion=this.apiVersion,e.proxyOrigin&&(t.proxyOrigin=e.proxyOrigin,o("proxyOrigin: %o",t.proxyOrigin),delete e.proxyOrigin),e=s.stringify(e,{arrayFormat:"brackets"}),t.query=e,i&&(t.body=i),o("params: %o",t),"function"==typeof n?this.request(t,function(t,e){r(e),n(t,e)}):new Promise(function(e,i){p.request(t,function(t,s){r(s),t?i(t):e(s)})})}},function(t,e,i){function s(t){return this instanceof s?(this.wpcom=t,void(this.urls=[])):new s(t)}i(1)("wpcom:batch");s.prototype.add=function(t){return this.urls.push(t),this},s.prototype.run=function(t,e){return void 0===t&&(t={}),"function"==typeof t&&(e=t,t={}),t.urls=this.urls,this.wpcom.req.get("/batch",t,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._sid=e,void(this._slug=t)):new s(t,e,i)}i(1)("wpcom:category");s.prototype.slug=function(t){this._slug=t},s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e,i){var s="/sites/"+this._sid+"/categories/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.update=function(t,e,i){var s="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.put(s,t,e,i)},s.prototype["delete"]=s.prototype.del=function(t,e){var i="/sites/"+this._sid+"/categories/slug:"+this._slug+"/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`comment id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._cid=t,void(this._sid=e)):new s(t,e,i)}i(1)("wpcom:commentlike");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/new";return this.wpcom.req.post(i,t,e)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t,e){if(!t)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=e,void(this._sid=t)):new s(t,e)}i(1)("wpcom:follow");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/follows/mine";return this.wpcom.req.get(i,t,e)},s.prototype.follow=s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/follows/new";return this.wpcom.req.put(i,t,null,e)},s.prototype.unfollow=s.prototype.del=function(t,e){var i="/sites/"+this._sid+"/follows/mine/delete";return this.wpcom.req.del(i,t,null,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`post id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._pid=t,void(this._sid=e)):new s(t,e,i)}i(1)("wpcom:like");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/new";return this.wpcom.req.put(i,t,null,e)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t){return this instanceof s?void(this.wpcom=t):new s(t)}i(1)("wpcom:me");s.prototype.get=function(t,e){return this.wpcom.req.get("/me",t,e)},s.prototype.sites=function(t,e){return this.wpcom.req.get("/me/sites",t,e)},s.prototype.likes=function(t,e){return this.wpcom.req.get("/me/likes",t,e)},s.prototype.groups=function(t,e){return this.wpcom.req.get("/me/groups",t,e)},s.prototype.connections=function(t,e){return this.wpcom.req.get("/me/connections",t,e)},t.exports=s},function(t,e,i){function s(t,e,i){return this instanceof s?(this.wpcom=i,this._sid=e,this._id=t,void(this._id||r("WARN: media `id` is not defined"))):new s(t,e,i)}var o=i(17),r=i(1)("wpcom:media");s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.get(i,t,e)},s.prototype.update=function(t,e,i){var s="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.put(s,t,e,i)},s.prototype.addFiles=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s={path:"/sites/"+this._sid+"/media/new",formData:[]};e=Array.isArray(e)?e:[e];var n,p,u,c,d,h;for(n=0;n %o",d,p[d]),"file"!==d&&(h="attrs["+n+"]["+d+"]",s.formData.push([h,p[d]]));p=p.file,p="string"==typeof p?o.createReadStream(p):p}s.formData.push(["media[]",p])}return this.wpcom.req.post(s,t,null,i)},s.prototype.addUrls=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s,o,r,n,p="/sites/"+this._sid+"/media/new",u={media_urls:[]};for(e=Array.isArray(e)?e:[e],s=0;s 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n\t params[_key - 1] = arguments[_key];\n\t }\n\t\n\t return new Promise(function (resolve, reject) {\n\t // The functions here take a variable number of arguments,\n\t // so pass in as many as we can but keep the callback last.\n\t callback.apply(callback, [].concat(params, [function (error, data) {\n\t error ? reject(error) : resolve(data);\n\t }]));\n\t });\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(6);\n\tvar debug = __webpack_require__(1)('wpcom:comment');\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(18);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:batch');\n\t\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:category');\n\t\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:commentlike');\n\t\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:follow');\n\t\n\t/**\n\t * Follow \n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current \n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:like');\n\t\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:me');\n\t\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's connections to third-party services\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.connections = function (query, fn) {\n\t return this.wpcom.req.get('/me/connections', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(17);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Default\n\t */\n\t\n\tvar def = {\n\t \"apiVersion\": \"1.1\"\n\t};\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m[k];\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(8);\n\tvar Reblog = __webpack_require__(12);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(error);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:reblog');\n\t\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(11);\n\tvar Category = __webpack_require__(5);\n\tvar Tag = __webpack_require__(14);\n\tvar Media = __webpack_require__(10);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(7);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:tag');\n\t\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:users');\n\t\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom:request');\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_17__;\n\n/***/ },\n/* 18 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_18__;\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_19__;\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** wpcom.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 41e2087e1f8266bcbb99\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) {\n console.warn(msg);\n } else {\n console.log(msg);\n }\n\n return sendRequest.call(this, params, query, body, fn)\n};\n\n/**\n * Wraps a library callback into a Promise\n *\n * Remember to bind the method to its parent\n * context - extracting it out otherwise removes it.\n *\n * E.g.\n * wpcom.Promise( comment.del.bind( comment ) );\n *\n * The promise rejects if the normal error return from\n * an API call is not empty. It resolves otherwise.\n *\n * @param {function} callback wpcom.js method to call\n * @param params variable list of parameters to send to callback\n * @returns {Promise}\n */\nWPCOM.prototype.Promise = ( callback, ...params ) => {\n return new Promise( ( resolve, reject ) => {\n // The functions here take a variable number of arguments,\n // so pass in as many as we can but keep the callback last.\n callback.apply( callback, [...params, ( error, data ) => {\n error ? reject( error ) : resolve( data );\n } ] );\n } );\n};\n\nif ( ! Promise.prototype.timeout ) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function( delay = DEFAULT_ASYNC_TIMEOUT ) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise( ( resolve, reject ) => {\n timer = setTimeout( () => {\n reject( new Error( 'Action timed out while waiting for response.' ) );\n }, delay );\n } );\n\n cancelTimeout = () => {\n clearTimeout( timer );\n return this;\n };\n\n return Promise.race( [ this.then( cancelTimeout ).catch( cancelTimeout ), timeout ] );\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./wpcom.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"debug\"\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\nvar debug = require('debug')('wpcom:comment');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function() {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function(err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n } );\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:batch');\n\n/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:category');\n\n/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:commentlike');\n\n/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:follow');\n\n/**\n * Follow \n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current \n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:like');\n\n/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:me');\n\n/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n/**\n * A list of the current user's connections to third-party services\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.connections = function (query, fn) {\n return this.wpcom.req.get('/me/connections', query, fn);\n};\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Default\n */\n\nvar def = {\n \"apiVersion\": \"1.1\"\n};\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if ( undefined === fn ) {\n if ( undefined === files ) {\n files = query;\n query = {};\n } else if ( 'function' === typeof files ) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [files];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([param, f[k]]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push(['media[]', f]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if ( undefined === fn ) {\n if ( undefined === media ) {\n media = query;\n query = {};\n } else if ( 'function' === typeof media ) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m[k];\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ( 'function' === typeof fn ) {\n fn(null, data);\n } else {\n return Promise.resolve( data );\n }\n })\n .catch(err => {\n if ( 'function' === typeof fn ) {\n fn(err);\n } else {\n return Promise.reject( error );\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:reblog');\n\n/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if ( undefined === fn ) {\n if ( undefined === note ) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:tag');\n\n/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:users');\n\n/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\nvar debug = require('debug')('wpcom:request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {}\n } else if ( 'function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_17__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"fs\"\n ** module id = 17\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_18__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"qs\"\n ** module id = 18\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_19__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"wpcom-xhr-request\"\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/index.min.js b/index.min.js new file mode 100644 index 0000000..a5e5590 --- /dev/null +++ b/index.min.js @@ -0,0 +1,2 @@ +module.exports=function(t){function e(s){if(i[s])return i[s].exports;var o=i[s]={exports:{},id:s,loaded:!1};return t[s].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){function s(t,e){return this instanceof s?("function"==typeof t&&(e=t,t=null),t&&(h("Token defined: %s…",t.substring(0,6)),this.token=t),e?this.request=e:(h("No request handler. Adding default XHR request handler"),this.request=function(e,i){return e=e||{},t&&(e.authToken=t),o(e,i)}),this.req=new c(this),void(this.apiVersion="1.1")):new s(t,e)}var o=i(19),r=i(9),n=i(13),p=i(15),u=i(4),c=i(16),d=i(3),h=i(1)("wpcom"),a=3e4;s.prototype.me=function(){return new r(this)},s.prototype.site=function(t){return new n(t,this)},s.prototype.users=function(){return new p(this)},s.prototype.batch=function(){return new u(this)},s.prototype.freshlyPressed=function(t,e){return this.req.get("/freshly-pressed",t,e)},s.prototype.sendRequest=function(t,e,i,s){var o="WARN! Don use `sendRequest() anymore. Use `this.req` method.";return console&&console.warn?console.warn(o):console.log(o),d.call(this,t,e,i,s)},s.prototype.Promise=function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),s=1;e>s;s++)i[s-1]=arguments[s];return new Promise(function(e,s){t.apply(t,[].concat(i,[function(t,i){t?s(t):e(i)}]))})},Promise.prototype.timeout||(Promise.prototype.timeout=function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?a:arguments[0],i=void 0,s=void 0,o=void 0;return o=new Promise(function(t,i){s=setTimeout(function(){i(new Error("Action timed out while waiting for response."))},e)}),i=function(){return clearTimeout(s),t},Promise.race([this.then(i)["catch"](i),o])}),t.exports=s},function(t,e){t.exports=require("debug")},function(t,e,i){function s(t,e,i,o){if(!i)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=o,this._cid=t,this._pid=e,void(this._sid=i)):new s(t,e,i,o)}var o=i(6);i(1)("wpcom:comment");s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.get(i,t,e)},s.prototype.replies=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/replies/";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={})),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/posts/"+this._pid+"/replies/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.update=function(t,e,i){"function"==typeof e&&(i=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.put(s,t,e,i)},s.prototype.reply=function(t,e,i){"function"==typeof e&&(i=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/comments/"+this._cid+"/replies/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/delete";return this.wpcom.req.del(i,t,e)},s.prototype.like=function(){return o(this._cid,this._sid,this.wpcom)},s.prototype.likesList=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes";return this.wpcom.req.get(i,t,e)},t.exports=s},function(t,e,i){var s=i(18),o=i(1)("wpcom:send-request"),r=i(1)("wpcom:send-request:res");t.exports=function(t,e,i,n){var p=this;return t="string"==typeof t?{path:t}:t,o("sendRequest(%o)",t.path),t.method=(t.method||"get").toUpperCase(),"function"==typeof e&&(n=e,e={}),"function"==typeof i&&(n=i,i=null),e=e||{},e.apiVersion?(t.apiVersion=e.apiVersion,o("apiVersion: %o",t.apiVersion),delete e.apiVersion):t.apiVersion=this.apiVersion,e.proxyOrigin&&(t.proxyOrigin=e.proxyOrigin,o("proxyOrigin: %o",t.proxyOrigin),delete e.proxyOrigin),e=s.stringify(e,{arrayFormat:"brackets"}),t.query=e,i&&(t.body=i),o("params: %o",t),"function"==typeof n?this.request(t,function(t,e){r(e),n(t,e)}):new Promise(function(e,i){p.request(t,function(t,s){r(s),t?i(t):e(s)})})}},function(t,e,i){function s(t){return this instanceof s?(this.wpcom=t,void(this.urls=[])):new s(t)}i(1)("wpcom:batch");s.prototype.add=function(t){return this.urls.push(t),this},s.prototype.run=function(t,e){return void 0===t&&(t={}),"function"==typeof t&&(e=t,t={}),t.urls=this.urls,this.wpcom.req.get("/batch",t,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._sid=e,void(this._slug=t)):new s(t,e,i)}i(1)("wpcom:category");s.prototype.slug=function(t){this._slug=t},s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e,i){var s="/sites/"+this._sid+"/categories/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.update=function(t,e,i){var s="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.put(s,t,e,i)},s.prototype["delete"]=s.prototype.del=function(t,e){var i="/sites/"+this._sid+"/categories/slug:"+this._slug+"/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`comment id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._cid=t,void(this._sid=e)):new s(t,e,i)}i(1)("wpcom:commentlike");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/new";return this.wpcom.req.post(i,t,e)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t,e){if(!t)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=e,void(this._sid=t)):new s(t,e)}i(1)("wpcom:follow");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/follows/mine";return this.wpcom.req.get(i,t,e)},s.prototype.follow=s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/follows/new";return this.wpcom.req.put(i,t,null,e)},s.prototype.unfollow=s.prototype.del=function(t,e){var i="/sites/"+this._sid+"/follows/mine/delete";return this.wpcom.req.del(i,t,null,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`post id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._pid=t,void(this._sid=e)):new s(t,e,i)}i(1)("wpcom:like");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/new";return this.wpcom.req.put(i,t,null,e)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t){return this instanceof s?void(this.wpcom=t):new s(t)}i(1)("wpcom:me");s.prototype.get=function(t,e){return this.wpcom.req.get("/me",t,e)},s.prototype.sites=function(t,e){return this.wpcom.req.get("/me/sites",t,e)},s.prototype.likes=function(t,e){return this.wpcom.req.get("/me/likes",t,e)},s.prototype.groups=function(t,e){return this.wpcom.req.get("/me/groups",t,e)},s.prototype.connections=function(t,e){return this.wpcom.req.get("/me/connections",t,e)},t.exports=s},function(t,e,i){function s(t,e,i){return this instanceof s?(this.wpcom=i,this._sid=e,this._id=t,void(this._id||r("WARN: media `id` is not defined"))):new s(t,e,i)}var o=i(17),r=i(1)("wpcom:media");s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.get(i,t,e)},s.prototype.update=function(t,e,i){var s="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.put(s,t,e,i)},s.prototype.addFiles=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s={path:"/sites/"+this._sid+"/media/new",formData:[]};e=Array.isArray(e)?e:[e];var n,p,u,c,d,h;for(n=0;n %o",d,p[d]),"file"!==d&&(h="attrs["+n+"]["+d+"]",s.formData.push([h,p[d]]));p=p.file,p="string"==typeof p?o.createReadStream(p):p}s.formData.push(["media[]",p])}return this.wpcom.req.post(s,t,null,i)},s.prototype.addUrls=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s,o,r,n,p="/sites/"+this._sid+"/media/new",u={media_urls:[]};for(e=Array.isArray(e)?e:[e],s=0;s 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n\t params[_key - 1] = arguments[_key];\n\t }\n\t\n\t return new Promise(function (resolve, reject) {\n\t // The functions here take a variable number of arguments,\n\t // so pass in as many as we can but keep the callback last.\n\t callback.apply(callback, [].concat(params, [function (error, data) {\n\t error ? reject(error) : resolve(data);\n\t }]));\n\t });\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"debug\");\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(6);\n\tvar debug = __webpack_require__(1)('wpcom:comment');\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(18);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:batch');\n\t\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:category');\n\t\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:commentlike');\n\t\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:follow');\n\t\n\t/**\n\t * Follow \n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current \n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:like');\n\t\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:me');\n\t\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's connections to third-party services\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.connections = function (query, fn) {\n\t return this.wpcom.req.get('/me/connections', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(17);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Default\n\t */\n\t\n\tvar def = {\n\t \"apiVersion\": \"1.1\"\n\t};\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m[k];\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(8);\n\tvar Reblog = __webpack_require__(12);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(error);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:reblog');\n\t\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(11);\n\tvar Category = __webpack_require__(5);\n\tvar Tag = __webpack_require__(14);\n\tvar Media = __webpack_require__(10);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(7);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:tag');\n\t\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:users');\n\t\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom:request');\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"fs\");\n\n/***/ },\n/* 18 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"qs\");\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"wpcom-xhr-request\");\n\n/***/ }\n/******/ ]);\n\n\n/** WEBPACK FOOTER **\n ** index.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap dbdf9a2d4526ae911efe\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) {\n console.warn(msg);\n } else {\n console.log(msg);\n }\n\n return sendRequest.call(this, params, query, body, fn)\n};\n\n/**\n * Wraps a library callback into a Promise\n *\n * Remember to bind the method to its parent\n * context - extracting it out otherwise removes it.\n *\n * E.g.\n * wpcom.Promise( comment.del.bind( comment ) );\n *\n * The promise rejects if the normal error return from\n * an API call is not empty. It resolves otherwise.\n *\n * @param {function} callback wpcom.js method to call\n * @param params variable list of parameters to send to callback\n * @returns {Promise}\n */\nWPCOM.prototype.Promise = ( callback, ...params ) => {\n return new Promise( ( resolve, reject ) => {\n // The functions here take a variable number of arguments,\n // so pass in as many as we can but keep the callback last.\n callback.apply( callback, [...params, ( error, data ) => {\n error ? reject( error ) : resolve( data );\n } ] );\n } );\n};\n\nif ( ! Promise.prototype.timeout ) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function( delay = DEFAULT_ASYNC_TIMEOUT ) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise( ( resolve, reject ) => {\n timer = setTimeout( () => {\n reject( new Error( 'Action timed out while waiting for response.' ) );\n }, delay );\n } );\n\n cancelTimeout = () => {\n clearTimeout( timer );\n return this;\n };\n\n return Promise.race( [ this.then( cancelTimeout ).catch( cancelTimeout ), timeout ] );\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","module.exports = require(\"debug\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"debug\"\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\nvar debug = require('debug')('wpcom:comment');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function() {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function(err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n } );\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:batch');\n\n/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:category');\n\n/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:commentlike');\n\n/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:follow');\n\n/**\n * Follow \n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current \n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:like');\n\n/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:me');\n\n/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n/**\n * A list of the current user's connections to third-party services\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.connections = function (query, fn) {\n return this.wpcom.req.get('/me/connections', query, fn);\n};\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Default\n */\n\nvar def = {\n \"apiVersion\": \"1.1\"\n};\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if ( undefined === fn ) {\n if ( undefined === files ) {\n files = query;\n query = {};\n } else if ( 'function' === typeof files ) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [files];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([param, f[k]]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push(['media[]', f]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if ( undefined === fn ) {\n if ( undefined === media ) {\n media = query;\n query = {};\n } else if ( 'function' === typeof media ) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m[k];\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ( 'function' === typeof fn ) {\n fn(null, data);\n } else {\n return Promise.resolve( data );\n }\n })\n .catch(err => {\n if ( 'function' === typeof fn ) {\n fn(err);\n } else {\n return Promise.reject( error );\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:reblog');\n\n/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if ( undefined === fn ) {\n if ( undefined === note ) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:tag');\n\n/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:users');\n\n/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\nvar debug = require('debug')('wpcom:request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {}\n } else if ( 'function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","module.exports = require(\"fs\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"fs\"\n ** module id = 17\n ** module chunks = 0\n **/","module.exports = require(\"qs\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"qs\"\n ** module id = 18\n ** module chunks = 0\n **/","module.exports = require(\"wpcom-xhr-request\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"wpcom-xhr-request\"\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index ecb030b..e19a6ec 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "wpcom", "description": "Official JavaScript library for the WordPress.com REST API", "version": "4.7.1", + "main": "index.min.js", "author": "Automattic, Inc.", "contributors": [ "Damian Suarez ", @@ -20,13 +21,17 @@ "license": "MIT", "dependencies": { "debug": "^2.1.3", + "fs": "0.0.2", "qs": "^4.0.0", "wpcom-xhr-request": "0.3.2" }, "devDependencies": { "babel": "^5.8.23", + "babel-core": "^5.8.23", "babel-eslint": "^4.1.3", - "browserify": "^11.0.1", - "mocha": "^2.2.5" + "babel-loader": "^5.3.2", + "mocha": "^2.2.5", + "strip-loader": "^0.1.0", + "webpack": "^1.12.1" } } diff --git a/webpack.config.dist.js b/webpack.config.dist.js new file mode 100644 index 0000000..5f767e1 --- /dev/null +++ b/webpack.config.dist.js @@ -0,0 +1,23 @@ +require("babel/register"); + +const defaultConfig = require( './webpack.config.js' ), + webpack = require( 'webpack' ), + WebpackStrip = require( 'strip-loader' ); + +module.exports = Object.assign( {}, defaultConfig, { + output: { + path: __dirname + '/dist', + filename: 'wpcom.js', + libraryTarget: 'umd', + library: 'WPCOM' + }, + loaders: [ + { + test: /\.js$/, + loader: WebpackStrip.loader('debug', 'console.log', 'console.warn') + } + ], + plugins: [ + new webpack.NormalModuleReplacementPlugin(/debug/, function() { return new Function(); }) + ] +} ); diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..fbcf79e --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,28 @@ +module.exports = { + entry: __dirname + '/index.js', + externals: [ + 'debug', + 'fs', + 'qs', + 'wpcom-xhr-request' + ], + output: { + path: __dirname, + filename: 'index.min.js', + libraryTarget: 'commonjs2', + library: 'WPCOM' + }, + module: { + loaders: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel-loader' + } + ] + }, + resolve: { + extensions: ['', '.js'] + }, + devtool: 'sourcemap' +}; From 168ed90a41d4dfbaaa6a659130040b8769307757 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Thu, 1 Oct 2015 15:39:24 -0700 Subject: [PATCH 02/37] Small updates: formatting, version, main file These changes are simply a response to feedback left in the PR. - Formatting around a babel include in the webpack config has been updated to match the rest of the file. - The version bump has been moved to a MINOR bump that introduces non-breaking updates. - The main file has been selected as the unminified file. --- package.json | 4 ++-- webpack.config.dist.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e19a6ec..b8a7432 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "wpcom", "description": "Official JavaScript library for the WordPress.com REST API", - "version": "4.7.1", - "main": "index.min.js", + "version": "4.8.0", + "main": "index.js", "author": "Automattic, Inc.", "contributors": [ "Damian Suarez ", diff --git a/webpack.config.dist.js b/webpack.config.dist.js index 5f767e1..348c957 100644 --- a/webpack.config.dist.js +++ b/webpack.config.dist.js @@ -1,4 +1,4 @@ -require("babel/register"); +require( 'babel/register' ); const defaultConfig = require( './webpack.config.js' ), webpack = require( 'webpack' ), From e687f6c6ef5a1a1595a2da8635be325751bc0677 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 2 Oct 2015 12:05:58 -0700 Subject: [PATCH 03/37] Remove 'only' that was hogging the test suites --- test/test.wpcom.promises.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.wpcom.promises.js b/test/test.wpcom.promises.js index fadd89c..7a5c199 100644 --- a/test/test.wpcom.promises.js +++ b/test/test.wpcom.promises.js @@ -26,7 +26,7 @@ function timedCallback( delay, caller = trueCallback ) { describe('wpcom', function(){ var wpcom = util.wpcom_public(); - describe.only('wpcom.promises', function(){ + describe('wpcom.promises', function(){ it('should fail when slower than timeout', done => { wpcom.site(util.site()).postsList() .timeout( 10 ) From e27b38213b041ba76e9e5afbc605ad2b691922e7 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 2 Oct 2015 12:11:02 -0700 Subject: [PATCH 04/37] Update Makefile and tests to use minified build --- Makefile | 6 +++--- test/test.fixture.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c46f6dd..0df76e1 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,10 @@ WEBPACK ?= $(NODE) $(BIN)/webpack standalone: dist/wpcom.js -install: node_modules index.js +install: node_modules index.min.js clean: - @rm -rf dist index.js index.js.map + @rm -rf dist index.min.js index.min.js.map distclean: clean @rm -rf node_modules @@ -28,7 +28,7 @@ dist: dist/wpcom.js: node_modules *.js dist lib/*.js @$(WEBPACK) -p --config webpack.config.dist.js -index.js: node_modules lib/*.js +index.min.js: node_modules lib/*.js @$(WEBPACK) -p --config webpack.config.js node_modules: package.json diff --git a/test/test.fixture.js b/test/test.fixture.js index 59baa4c..452fbf4 100644 --- a/test/test.fixture.js +++ b/test/test.fixture.js @@ -3,7 +3,7 @@ * Module dependencies */ -var WPCOM = require('../'); +var WPCOM = require('../index.min.js'); var Site = require('../lib/site'); var assert = require('assert'); From 255aa55cd05fc5b3b464baaf74dc7c55326f3364 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 2 Oct 2015 12:11:14 -0700 Subject: [PATCH 05/37] Push new distribution build of minified files. --- dist/wpcom.js.map | 1 - index.min.js | 2 +- index.min.js.map | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 dist/wpcom.js.map diff --git a/dist/wpcom.js.map b/dist/wpcom.js.map deleted file mode 100644 index fbb130f..0000000 --- a/dist/wpcom.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///wpcom.js","webpack:///webpack/bootstrap 41e2087e1f8266bcbb99","webpack:///./wpcom.js","webpack:///external \"debug\"","webpack:///./lib/comment.js","webpack:///./lib/util/send-request.js","webpack:///./lib/batch.js","webpack:///./lib/category.js","webpack:///./lib/commentlike.js","webpack:///./lib/follow.js","webpack:///./lib/like.js","webpack:///./lib/me.js","webpack:///./lib/media.js","webpack:///./lib/post.js","webpack:///./lib/reblog.js","webpack:///./lib/site.js","webpack:///./lib/tag.js","webpack:///./lib/users.js","webpack:///./lib/util/request.js","webpack:///external \"fs\"","webpack:///external \"qs\"","webpack:///external \"wpcom-xhr-request\""],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","__WEBPACK_EXTERNAL_MODULE_17__","__WEBPACK_EXTERNAL_MODULE_18__","__WEBPACK_EXTERNAL_MODULE_19__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","WPCOM","token","reqHandler","debug","substring","request","params","fn","authToken","request_handler","req","Req","apiVersion","Me","Site","Users","Batch","sendRequest","DEFAULT_ASYNC_TIMEOUT","prototype","me","site","users","batch","freshlyPressed","query","get","body","msg","console","warn","log","Promise","callback","_len","arguments","length","Array","_key","resolve","reject","apply","concat","error","data","timeout","_this","delay","undefined","cancelTimeout","timer","setTimeout","Error","clearTimeout","race","then","Comment","cid","pid","sid","wpcom","_cid","_pid","_sid","CommentLike","path","replies","add","content","post","update","put","reply","del","like","likesList","qs","debug_res","method","toUpperCase","proxyOrigin","stringify","arrayFormat","err","res","urls","url","push","run","Category","slug","_slug","mine","state","Follow","site_id","follow","unfollow","Like","sites","likes","groups","connections","Media","_id","fs","addFiles","files","formData","isArray","i","f","isStream","isFile","k","param","createReadStream","_readableState","File","file","addUrls","media","media_urls","attrs","Post","Reblog","getBySlug","ID","restore","related","reblog","comment","comments","destination_site_id","to","dest","note","encodeURIComponent","list","subpath","listMethod","_publicAPI","Tag","resources","isarr","name","addPost","deletePost","addMediaFiles","addMediaUrls","deleteMedia","cat","category","tag","renderShortcode","TypeError","shortcode","renderEmbed","embed_url","statsReferrersSpamNew","domain","statsReferrersSpamDelete","statsVideo","videoId","statsPostViews","postId","suggest"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,SAAAA,QAAA,MAAAA,QAAA,MAAAA,QAAA,sBACA,kBAAAC,gBAAAC,IACAD,QAAA,uCAAAJ,GACA,gBAAAC,SACAA,QAAA,MAAAD,EAAAG,QAAA,SAAAA,QAAA,MAAAA,QAAA,MAAAA,QAAA,sBAEAJ,EAAA,MAAAC,EAAAD,EAAA,MAAAA,EAAA,GAAAA,EAAA,GAAAA,EAAA,uBACCO,KAAA,SAAAC,EAAAC,EAAAC,EAAAC,GACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAZ,OAGA,IAAAC,GAAAY,EAAAD,IACAZ,WACAc,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAf,EAAAD,QAAAC,IAAAD,QAAAW,GAGAV,EAAAc,QAAA,EAGAd,EAAAD,QAvBA,GAAAa,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAAS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MI,UAAUmJ,QAAU,SAAU7I,EAAOlB,GACzC,MAAOtB,MAAK2E,MAAMlD,IAAIgB,IAAI,iBAAkBD,EAAOlB,IAOrD1B,EAAOD,QAAUmC,GjB4iEX,SAASlC,EAAQD,EAASW,GkBrkEhC,QAASoB,GAAIiD,GACX3E,KAAK2E,MAAQA,EATf,GAAI3C,GAAc1B,EAAQ,EACdA,GAAQ,GAAS,gBAoB7BoB,GAAIQ,UAAUO,IAAM,SAAUpB,EAAQmB,EAAOlB,GAO3C,MALI,kBAAqBkB,KACvBlB,EAAKkB,EACLA,MAGKR,EAAYrB,KAAKX,KAAK2E,MAAOtD,EAAQmB,EAAO,KAAMlB,IAa3DI,EAAIQ,UAAUkD,KACd1D,EAAIQ,UAAUoD,IAAM,SAAUjE,EAAQmB,EAAOE,EAAMpB,GAkBjD,MAjBIyC,UAAczC,IACZyC,SAAcrB,GAChBA,EAAOF,EACPA,MACU,kBAAsBE,KAChCpB,EAAKoB,EACLA,EAAOF,EACPA,OAKJnB,EAAS,gBAAoBA,IAAW2D,KAAO3D,GAAWA,EAG1DA,EAAOwE,OAAS,OAET7D,EAAYrB,KAAKX,KAAK2E,MAAOtD,EAAQmB,EAAOE,EAAMpB,IAY3DI,EAAIQ,UAAUsD,IAAM,SAAUnE,EAAQmB,EAAOlB,GAM3C,MALI,kBAAqBkB,KACvBlB,EAAKkB,EACLA,MAGKxC,KAAKoF,KAAK/D,EAAQmB,EAAO,KAAMlB,IAOxC1B,EAAOD,QAAU+B,GlBslEX,SAAS9B,EAAQD,GmBhrEvBC,EAAAD,QAAAO,GnBsrEM,SAASN,EAAQD,GoBtrEvBC,EAAAD,QAAAQ,GpB4rEM,SAASP,EAAQD,GqB5rEvBC,EAAAD,QAAAS","file":"wpcom.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"debug\"), require(\"fs\"), require(\"qs\"), require(\"wpcom-xhr-request\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"debug\", \"fs\", \"qs\", \"wpcom-xhr-request\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WPCOM\"] = factory(require(\"debug\"), require(\"fs\"), require(\"qs\"), require(\"wpcom-xhr-request\"));\n\telse\n\t\troot[\"WPCOM\"] = factory(root[\"debug\"], root[\"fs\"], root[\"qs\"], root[\"wpcom-xhr-request\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_17__, __WEBPACK_EXTERNAL_MODULE_18__, __WEBPACK_EXTERNAL_MODULE_19__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"debug\"), require(\"fs\"), require(\"qs\"), require(\"wpcom-xhr-request\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"debug\", \"fs\", \"qs\", \"wpcom-xhr-request\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WPCOM\"] = factory(require(\"debug\"), require(\"fs\"), require(\"qs\"), require(\"wpcom-xhr-request\"));\n\telse\n\t\troot[\"WPCOM\"] = factory(root[\"debug\"], root[\"fs\"], root[\"qs\"], root[\"wpcom-xhr-request\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_17__, __WEBPACK_EXTERNAL_MODULE_18__, __WEBPACK_EXTERNAL_MODULE_19__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar request_handler = __webpack_require__(19);\n\t\n\t/**\n\t * Local module dependencies.\n\t */\n\t\n\tvar Me = __webpack_require__(9);\n\tvar Site = __webpack_require__(13);\n\tvar Users = __webpack_require__(15);\n\tvar Batch = __webpack_require__(4);\n\tvar Req = __webpack_require__(16);\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom');\n\t\n\t/**\n\t * Local module constants\n\t */\n\tvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\t\n\t/**\n\t * XMLHttpRequest (and CORS) API access method.\n\t *\n\t * API authentication is done via an (optional) access `token`,\n\t * which needs to be retrieved via OAuth.\n\t *\n\t * Request Handler is optional and XHR is defined as default.\n\t *\n\t * @param {String} [token] - OAuth API access token\n\t * @param {Function} [reqHandler] - function Request Handler\n\t * @public\n\t */\n\t\n\tfunction WPCOM(token, reqHandler) {\n\t if (!(this instanceof WPCOM)) {\n\t return new WPCOM(token, reqHandler);\n\t }\n\t\n\t // `token` is optional\n\t if ('function' === typeof token) {\n\t reqHandler = token;\n\t token = null;\n\t }\n\t\n\t if (token) {\n\t debug('Token defined: %s…', token.substring(0, 6));\n\t this.token = token;\n\t }\n\t\n\t // Set default request handler\n\t if (!reqHandler) {\n\t debug('No request handler. Adding default XHR request handler');\n\t\n\t this.request = function (params, fn) {\n\t params = params || {};\n\t\n\t // token is optional\n\t if (token) {\n\t params.authToken = token;\n\t }\n\t\n\t return request_handler(params, fn);\n\t };\n\t } else {\n\t this.request = reqHandler;\n\t }\n\t\n\t // Add Req instance\n\t this.req = new Req(this);\n\t\n\t // Default api version;\n\t this.apiVersion = '1.1';\n\t}\n\t\n\t/**\n\t * Get `Me` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.me = function () {\n\t return new Me(this);\n\t};\n\t\n\t/**\n\t * Get `Site` object instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.site = function (id) {\n\t return new Site(id, this);\n\t};\n\t\n\t/**\n\t * Get `Users` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.users = function () {\n\t return new Users(this);\n\t};\n\t\n\tWPCOM.prototype.batch = function () {\n\t return new Batch(this);\n\t};\n\t\n\t/**\n\t * List Freshly Pressed Posts\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn callback function\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.freshlyPressed = function (query, fn) {\n\t return this.req.get('/freshly-pressed', query, fn);\n\t};\n\t\n\t/**\n\t * Expose send-request\n\t * @TODO: use `this.req` instead of this method\n\t */\n\t\n\tWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n\t var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n\t if (console && console.warn) {\n\t console.warn(msg);\n\t } else {\n\t console.log(msg);\n\t }\n\t\n\t return sendRequest.call(this, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Wraps a library callback into a Promise\n\t *\n\t * Remember to bind the method to its parent\n\t * context - extracting it out otherwise removes it.\n\t *\n\t * E.g.\n\t * wpcom.Promise( comment.del.bind( comment ) );\n\t *\n\t * The promise rejects if the normal error return from\n\t * an API call is not empty. It resolves otherwise.\n\t *\n\t * @param {function} callback wpcom.js method to call\n\t * @param params variable list of parameters to send to callback\n\t * @returns {Promise}\n\t */\n\tWPCOM.prototype.Promise = function (callback) {\n\t for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n\t params[_key - 1] = arguments[_key];\n\t }\n\t\n\t return new Promise(function (resolve, reject) {\n\t // The functions here take a variable number of arguments,\n\t // so pass in as many as we can but keep the callback last.\n\t callback.apply(callback, [].concat(params, [function (error, data) {\n\t error ? reject(error) : resolve(data);\n\t }]));\n\t });\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(6);\n\tvar debug = __webpack_require__(1)('wpcom:comment');\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(18);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:batch');\n\t\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:category');\n\t\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:commentlike');\n\t\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:follow');\n\t\n\t/**\n\t * Follow \n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current \n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:like');\n\t\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:me');\n\t\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's connections to third-party services\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.connections = function (query, fn) {\n\t return this.wpcom.req.get('/me/connections', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(17);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Default\n\t */\n\t\n\tvar def = {\n\t \"apiVersion\": \"1.1\"\n\t};\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m[k];\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(8);\n\tvar Reblog = __webpack_require__(12);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(error);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:reblog');\n\t\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(11);\n\tvar Category = __webpack_require__(5);\n\tvar Tag = __webpack_require__(14);\n\tvar Media = __webpack_require__(10);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(7);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:tag');\n\t\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:users');\n\t\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom:request');\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_17__;\n\n/***/ },\n/* 18 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_18__;\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_19__;\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** wpcom.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 41e2087e1f8266bcbb99\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) {\n console.warn(msg);\n } else {\n console.log(msg);\n }\n\n return sendRequest.call(this, params, query, body, fn)\n};\n\n/**\n * Wraps a library callback into a Promise\n *\n * Remember to bind the method to its parent\n * context - extracting it out otherwise removes it.\n *\n * E.g.\n * wpcom.Promise( comment.del.bind( comment ) );\n *\n * The promise rejects if the normal error return from\n * an API call is not empty. It resolves otherwise.\n *\n * @param {function} callback wpcom.js method to call\n * @param params variable list of parameters to send to callback\n * @returns {Promise}\n */\nWPCOM.prototype.Promise = ( callback, ...params ) => {\n return new Promise( ( resolve, reject ) => {\n // The functions here take a variable number of arguments,\n // so pass in as many as we can but keep the callback last.\n callback.apply( callback, [...params, ( error, data ) => {\n error ? reject( error ) : resolve( data );\n } ] );\n } );\n};\n\nif ( ! Promise.prototype.timeout ) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function( delay = DEFAULT_ASYNC_TIMEOUT ) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise( ( resolve, reject ) => {\n timer = setTimeout( () => {\n reject( new Error( 'Action timed out while waiting for response.' ) );\n }, delay );\n } );\n\n cancelTimeout = () => {\n clearTimeout( timer );\n return this;\n };\n\n return Promise.race( [ this.then( cancelTimeout ).catch( cancelTimeout ), timeout ] );\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./wpcom.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"debug\"\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\nvar debug = require('debug')('wpcom:comment');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function() {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function(err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n } );\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:batch');\n\n/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:category');\n\n/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:commentlike');\n\n/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:follow');\n\n/**\n * Follow \n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current \n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:like');\n\n/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:me');\n\n/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n/**\n * A list of the current user's connections to third-party services\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.connections = function (query, fn) {\n return this.wpcom.req.get('/me/connections', query, fn);\n};\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Default\n */\n\nvar def = {\n \"apiVersion\": \"1.1\"\n};\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if ( undefined === fn ) {\n if ( undefined === files ) {\n files = query;\n query = {};\n } else if ( 'function' === typeof files ) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [files];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([param, f[k]]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push(['media[]', f]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if ( undefined === fn ) {\n if ( undefined === media ) {\n media = query;\n query = {};\n } else if ( 'function' === typeof media ) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m[k];\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ( 'function' === typeof fn ) {\n fn(null, data);\n } else {\n return Promise.resolve( data );\n }\n })\n .catch(err => {\n if ( 'function' === typeof fn ) {\n fn(err);\n } else {\n return Promise.reject( error );\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:reblog');\n\n/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if ( undefined === fn ) {\n if ( undefined === note ) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:tag');\n\n/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:users');\n\n/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\nvar debug = require('debug')('wpcom:request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {}\n } else if ( 'function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_17__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"fs\"\n ** module id = 17\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_18__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"qs\"\n ** module id = 18\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_19__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"wpcom-xhr-request\"\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/index.min.js b/index.min.js index a5e5590..324a792 100644 --- a/index.min.js +++ b/index.min.js @@ -1,2 +1,2 @@ -module.exports=function(t){function e(s){if(i[s])return i[s].exports;var o=i[s]={exports:{},id:s,loaded:!1};return t[s].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){function s(t,e){return this instanceof s?("function"==typeof t&&(e=t,t=null),t&&(h("Token defined: %s…",t.substring(0,6)),this.token=t),e?this.request=e:(h("No request handler. Adding default XHR request handler"),this.request=function(e,i){return e=e||{},t&&(e.authToken=t),o(e,i)}),this.req=new c(this),void(this.apiVersion="1.1")):new s(t,e)}var o=i(19),r=i(9),n=i(13),p=i(15),u=i(4),c=i(16),d=i(3),h=i(1)("wpcom"),a=3e4;s.prototype.me=function(){return new r(this)},s.prototype.site=function(t){return new n(t,this)},s.prototype.users=function(){return new p(this)},s.prototype.batch=function(){return new u(this)},s.prototype.freshlyPressed=function(t,e){return this.req.get("/freshly-pressed",t,e)},s.prototype.sendRequest=function(t,e,i,s){var o="WARN! Don use `sendRequest() anymore. Use `this.req` method.";return console&&console.warn?console.warn(o):console.log(o),d.call(this,t,e,i,s)},s.prototype.Promise=function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),s=1;e>s;s++)i[s-1]=arguments[s];return new Promise(function(e,s){t.apply(t,[].concat(i,[function(t,i){t?s(t):e(i)}]))})},Promise.prototype.timeout||(Promise.prototype.timeout=function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?a:arguments[0],i=void 0,s=void 0,o=void 0;return o=new Promise(function(t,i){s=setTimeout(function(){i(new Error("Action timed out while waiting for response."))},e)}),i=function(){return clearTimeout(s),t},Promise.race([this.then(i)["catch"](i),o])}),t.exports=s},function(t,e){t.exports=require("debug")},function(t,e,i){function s(t,e,i,o){if(!i)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=o,this._cid=t,this._pid=e,void(this._sid=i)):new s(t,e,i,o)}var o=i(6);i(1)("wpcom:comment");s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.get(i,t,e)},s.prototype.replies=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/replies/";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={})),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/posts/"+this._pid+"/replies/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.update=function(t,e,i){"function"==typeof e&&(i=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.put(s,t,e,i)},s.prototype.reply=function(t,e,i){"function"==typeof e&&(i=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var s="/sites/"+this._sid+"/comments/"+this._cid+"/replies/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/delete";return this.wpcom.req.del(i,t,e)},s.prototype.like=function(){return o(this._cid,this._sid,this.wpcom)},s.prototype.likesList=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes";return this.wpcom.req.get(i,t,e)},t.exports=s},function(t,e,i){var s=i(18),o=i(1)("wpcom:send-request"),r=i(1)("wpcom:send-request:res");t.exports=function(t,e,i,n){var p=this;return t="string"==typeof t?{path:t}:t,o("sendRequest(%o)",t.path),t.method=(t.method||"get").toUpperCase(),"function"==typeof e&&(n=e,e={}),"function"==typeof i&&(n=i,i=null),e=e||{},e.apiVersion?(t.apiVersion=e.apiVersion,o("apiVersion: %o",t.apiVersion),delete e.apiVersion):t.apiVersion=this.apiVersion,e.proxyOrigin&&(t.proxyOrigin=e.proxyOrigin,o("proxyOrigin: %o",t.proxyOrigin),delete e.proxyOrigin),e=s.stringify(e,{arrayFormat:"brackets"}),t.query=e,i&&(t.body=i),o("params: %o",t),"function"==typeof n?this.request(t,function(t,e){r(e),n(t,e)}):new Promise(function(e,i){p.request(t,function(t,s){r(s),t?i(t):e(s)})})}},function(t,e,i){function s(t){return this instanceof s?(this.wpcom=t,void(this.urls=[])):new s(t)}i(1)("wpcom:batch");s.prototype.add=function(t){return this.urls.push(t),this},s.prototype.run=function(t,e){return void 0===t&&(t={}),"function"==typeof t&&(e=t,t={}),t.urls=this.urls,this.wpcom.req.get("/batch",t,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._sid=e,void(this._slug=t)):new s(t,e,i)}i(1)("wpcom:category");s.prototype.slug=function(t){this._slug=t},s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e,i){var s="/sites/"+this._sid+"/categories/new";return this.wpcom.req.post(s,t,e,i)},s.prototype.update=function(t,e,i){var s="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.put(s,t,e,i)},s.prototype["delete"]=s.prototype.del=function(t,e){var i="/sites/"+this._sid+"/categories/slug:"+this._slug+"/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`comment id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._cid=t,void(this._sid=e)):new s(t,e,i)}i(1)("wpcom:commentlike");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/new";return this.wpcom.req.post(i,t,e)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t,e){if(!t)throw new Error("`site id` is not correctly defined");return this instanceof s?(this.wpcom=e,void(this._sid=t)):new s(t,e)}i(1)("wpcom:follow");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/follows/mine";return this.wpcom.req.get(i,t,e)},s.prototype.follow=s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/follows/new";return this.wpcom.req.put(i,t,null,e)},s.prototype.unfollow=s.prototype.del=function(t,e){var i="/sites/"+this._sid+"/follows/mine/delete";return this.wpcom.req.del(i,t,null,e)},t.exports=s},function(t,e,i){function s(t,e,i){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`post id` is not correctly defined");return this instanceof s?(this.wpcom=i,this._pid=t,void(this._sid=e)):new s(t,e,i)}i(1)("wpcom:like");s.prototype.mine=s.prototype.state=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine";return this.wpcom.req.get(i,t,e)},s.prototype.add=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/new";return this.wpcom.req.put(i,t,null,e)},s.prototype.del=s.prototype["delete"]=function(t,e){var i="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine/delete";return this.wpcom.req.del(i,t,e)},t.exports=s},function(t,e,i){function s(t){return this instanceof s?void(this.wpcom=t):new s(t)}i(1)("wpcom:me");s.prototype.get=function(t,e){return this.wpcom.req.get("/me",t,e)},s.prototype.sites=function(t,e){return this.wpcom.req.get("/me/sites",t,e)},s.prototype.likes=function(t,e){return this.wpcom.req.get("/me/likes",t,e)},s.prototype.groups=function(t,e){return this.wpcom.req.get("/me/groups",t,e)},s.prototype.connections=function(t,e){return this.wpcom.req.get("/me/connections",t,e)},t.exports=s},function(t,e,i){function s(t,e,i){return this instanceof s?(this.wpcom=i,this._sid=e,this._id=t,void(this._id||r("WARN: media `id` is not defined"))):new s(t,e,i)}var o=i(17),r=i(1)("wpcom:media");s.prototype.get=function(t,e){var i="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.get(i,t,e)},s.prototype.update=function(t,e,i){var s="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.put(s,t,e,i)},s.prototype.addFiles=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s={path:"/sites/"+this._sid+"/media/new",formData:[]};e=Array.isArray(e)?e:[e];var n,p,u,c,d,h;for(n=0;n %o",d,p[d]),"file"!==d&&(h="attrs["+n+"]["+d+"]",s.formData.push([h,p[d]]));p=p.file,p="string"==typeof p?o.createReadStream(p):p}s.formData.push(["media[]",p])}return this.wpcom.req.post(s,t,null,i)},s.prototype.addUrls=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s,o,r,n,p="/sites/"+this._sid+"/media/new",u={media_urls:[]};for(e=Array.isArray(e)?e:[e],s=0;s %o",d,p[d]),"file"!==d&&(h="attrs["+n+"]["+d+"]",s.formData.push([h,p[d]]));p=p.file,p="string"==typeof p?o.createReadStream(p):p}s.formData.push(["media[]",p])}return this.wpcom.req.post(s,t,null,i)},s.prototype.addUrls=function(t,e,i){void 0===i&&(void 0===e?(e=t,t={}):"function"==typeof e&&(i=e,e=t,t={}));var s,o,r,n,p="/sites/"+this._sid+"/media/new",u={media_urls:[]};for(e=Array.isArray(e)?e:[e],s=0;s 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n\t params[_key - 1] = arguments[_key];\n\t }\n\t\n\t return new Promise(function (resolve, reject) {\n\t // The functions here take a variable number of arguments,\n\t // so pass in as many as we can but keep the callback last.\n\t callback.apply(callback, [].concat(params, [function (error, data) {\n\t error ? reject(error) : resolve(data);\n\t }]));\n\t });\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"debug\");\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(6);\n\tvar debug = __webpack_require__(1)('wpcom:comment');\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(18);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:batch');\n\t\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:category');\n\t\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:commentlike');\n\t\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:follow');\n\t\n\t/**\n\t * Follow \n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current \n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:like');\n\t\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:me');\n\t\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's connections to third-party services\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.connections = function (query, fn) {\n\t return this.wpcom.req.get('/me/connections', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(17);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Default\n\t */\n\t\n\tvar def = {\n\t \"apiVersion\": \"1.1\"\n\t};\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m[k];\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(8);\n\tvar Reblog = __webpack_require__(12);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(error);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:reblog');\n\t\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(11);\n\tvar Category = __webpack_require__(5);\n\tvar Tag = __webpack_require__(14);\n\tvar Media = __webpack_require__(10);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(7);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:tag');\n\t\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar debug = __webpack_require__(1)('wpcom:users');\n\t\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom:request');\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' == typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"fs\");\n\n/***/ },\n/* 18 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"qs\");\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"wpcom-xhr-request\");\n\n/***/ }\n/******/ ]);\n\n\n/** WEBPACK FOOTER **\n ** index.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap dbdf9a2d4526ae911efe\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) {\n console.warn(msg);\n } else {\n console.log(msg);\n }\n\n return sendRequest.call(this, params, query, body, fn)\n};\n\n/**\n * Wraps a library callback into a Promise\n *\n * Remember to bind the method to its parent\n * context - extracting it out otherwise removes it.\n *\n * E.g.\n * wpcom.Promise( comment.del.bind( comment ) );\n *\n * The promise rejects if the normal error return from\n * an API call is not empty. It resolves otherwise.\n *\n * @param {function} callback wpcom.js method to call\n * @param params variable list of parameters to send to callback\n * @returns {Promise}\n */\nWPCOM.prototype.Promise = ( callback, ...params ) => {\n return new Promise( ( resolve, reject ) => {\n // The functions here take a variable number of arguments,\n // so pass in as many as we can but keep the callback last.\n callback.apply( callback, [...params, ( error, data ) => {\n error ? reject( error ) : resolve( data );\n } ] );\n } );\n};\n\nif ( ! Promise.prototype.timeout ) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function( delay = DEFAULT_ASYNC_TIMEOUT ) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise( ( resolve, reject ) => {\n timer = setTimeout( () => {\n reject( new Error( 'Action timed out while waiting for response.' ) );\n }, delay );\n } );\n\n cancelTimeout = () => {\n clearTimeout( timer );\n return this;\n };\n\n return Promise.race( [ this.then( cancelTimeout ).catch( cancelTimeout ), timeout ] );\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","module.exports = require(\"debug\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"debug\"\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\nvar debug = require('debug')('wpcom:comment');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function() {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function(err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n } );\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:batch');\n\n/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:category');\n\n/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:commentlike');\n\n/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:follow');\n\n/**\n * Follow \n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current \n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:like');\n\n/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:me');\n\n/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n/**\n * A list of the current user's connections to third-party services\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.connections = function (query, fn) {\n return this.wpcom.req.get('/me/connections', query, fn);\n};\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Default\n */\n\nvar def = {\n \"apiVersion\": \"1.1\"\n};\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if ( undefined === fn ) {\n if ( undefined === files ) {\n files = query;\n query = {};\n } else if ( 'function' === typeof files ) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [files];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([param, f[k]]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push(['media[]', f]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if ( undefined === fn ) {\n if ( undefined === media ) {\n media = query;\n query = {};\n } else if ( 'function' === typeof media ) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m[k];\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if ( undefined === fn ) {\n if ( undefined === body ) {\n body = query;\n query = {};\n } else if ( 'function' === typeof body ) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ( 'function' === typeof fn ) {\n fn(null, data);\n } else {\n return Promise.resolve( data );\n }\n })\n .catch(err => {\n if ( 'function' === typeof fn ) {\n fn(err);\n } else {\n return Promise.reject( error );\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:reblog');\n\n/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if ( undefined === fn ) {\n if ( undefined === note ) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:tag');\n\n/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar debug = require('debug')('wpcom:users');\n\n/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\nvar debug = require('debug')('wpcom:request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {}\n } else if ( 'function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' == typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","module.exports = require(\"fs\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"fs\"\n ** module id = 17\n ** module chunks = 0\n **/","module.exports = require(\"qs\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"qs\"\n ** module id = 18\n ** module chunks = 0\n **/","module.exports = require(\"wpcom-xhr-request\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"wpcom-xhr-request\"\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///index.min.js","webpack:///webpack/bootstrap cb200ffafedebfda21d3","webpack:///./index.js","webpack:///external \"debug\"","webpack:///./lib/comment.js","webpack:///./lib/util/send-request.js","webpack:///./lib/batch.js","webpack:///./lib/category.js","webpack:///./lib/commentlike.js","webpack:///./lib/follow.js","webpack:///./lib/like.js","webpack:///./lib/me.js","webpack:///./lib/media.js","webpack:///./lib/post.js","webpack:///./lib/reblog.js","webpack:///./lib/site.js","webpack:///./lib/tag.js","webpack:///./lib/users.js","webpack:///./lib/util/request.js","webpack:///external \"fs\"","webpack:///external \"qs\"","webpack:///external \"wpcom-xhr-request\""],"names":["module","exports","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","WPCOM","token","reqHandler","this","debug","substring","request","params","fn","authToken","request_handler","req","Req","apiVersion","Me","Site","Users","Batch","sendRequest","DEFAULT_ASYNC_TIMEOUT","prototype","me","site","users","batch","freshlyPressed","query","get","body","msg","console","warn","log","Promise","timeout","_this","delay","arguments","length","undefined","cancelTimeout","timer","resolve","reject","setTimeout","Error","clearTimeout","race","then","require","Comment","cid","pid","sid","wpcom","_cid","_pid","_sid","CommentLike","path","replies","add","content","post","update","put","reply","del","like","likesList","qs","debug_res","method","toUpperCase","proxyOrigin","stringify","arrayFormat","err","res","urls","url","push","run","Category","slug","_slug","mine","state","Follow","site_id","follow","unfollow","Like","sites","likes","groups","connections","Media","_id","fs","addFiles","files","formData","Array","isArray","i","f","isStream","isFile","k","param","createReadStream","_readableState","File","file","addUrls","media","media_urls","attrs","Post","Reblog","getBySlug","data","ID","restore","related","reblog","comment","comments","destination_site_id","to","dest","note","encodeURIComponent","list","subpath","listMethod","_publicAPI","Tag","resources","isarr","name","addPost","deletePost","addMediaFiles","addMediaUrls","deleteMedia","cat","category","tag","renderShortcode","TypeError","shortcode","renderEmbed","embed_url","statsReferrersSpamNew","domain","statsReferrersSpamDelete","statsVideo","videoId","statsPostViews","postId","suggest"],"mappings":"AAAAA,OAAOC,QACE,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAH,OAGA,IAAAD,GAAAK,EAAAD,IACAH,WACAK,GAAAF,EACAG,QAAA,EAUA,OANAL,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AcX,GAChBA,EAAOF,EACPA,MACS,kBAAsBE,KAC/BpB,EAAKoB,EACLA,EAAOF,EACPA,OAKJnB,EAAS,gBAAoBA,IAAWoD,KAAOpD,GAAWA,EAG1DA,EAAOiE,OAAS,OAETtD,EAAYtB,KAAKO,KAAKmD,MAAO/C,EAAQmB,EAAOE,EAAMpB,IAY3DI,EAAIQ,UAAU+C,IAAM,SAAU5D,EAAQmB,EAAOlB,GAM3C,MALI,kBAAsBkB,KACxBlB,EAAKkB,EACLA,MAGKvB,KAAK4D,KAAKxD,EAAQmB,EAAO,KAAMlB,IAOxCpB,EAAOC,QAAUuB,GlBw+DX,SAASxB,EAAQC,GmBlkEvBD,EAAAC,QAAA4D,QAAA,OnBwkEM,SAAS7D,EAAQC,GoBxkEvBD,EAAAC,QAAA4D,QAAA,OpB8kEM,SAAS7D,EAAQC,GqB9kEvBD,EAAAC,QAAA4D,QAAA","file":"index.min.js","sourcesContent":["module.exports =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar request_handler = __webpack_require__(19);\n\t\n\t/**\n\t * Local module dependencies.\n\t */\n\t\n\tvar Me = __webpack_require__(9);\n\tvar Site = __webpack_require__(13);\n\tvar Users = __webpack_require__(15);\n\tvar Batch = __webpack_require__(4);\n\tvar Req = __webpack_require__(16);\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom');\n\t\n\t/**\n\t * Local module constants\n\t */\n\tvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\t\n\t/**\n\t * XMLHttpRequest (and CORS) API access method.\n\t *\n\t * API authentication is done via an (optional) access `token`,\n\t * which needs to be retrieved via OAuth.\n\t *\n\t * Request Handler is optional and XHR is defined as default.\n\t *\n\t * @param {String} [token] - OAuth API access token\n\t * @param {Function} [reqHandler] - function Request Handler\n\t * @public\n\t */\n\t\n\tfunction WPCOM(token, reqHandler) {\n\t if (!(this instanceof WPCOM)) {\n\t return new WPCOM(token, reqHandler);\n\t }\n\t\n\t // `token` is optional\n\t if ('function' === typeof token) {\n\t reqHandler = token;\n\t token = null;\n\t }\n\t\n\t if (token) {\n\t debug('Token defined: %s…', token.substring(0, 6));\n\t this.token = token;\n\t }\n\t\n\t // Set default request handler\n\t if (!reqHandler) {\n\t debug('No request handler. Adding default XHR request handler');\n\t\n\t this.request = function (params, fn) {\n\t params = params || {};\n\t\n\t // token is optional\n\t if (token) {\n\t params.authToken = token;\n\t }\n\t\n\t return request_handler(params, fn);\n\t };\n\t } else {\n\t this.request = reqHandler;\n\t }\n\t\n\t // Add Req instance\n\t this.req = new Req(this);\n\t\n\t // Default api version;\n\t this.apiVersion = '1.1';\n\t}\n\t\n\t/**\n\t * Get `Me` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.me = function () {\n\t return new Me(this);\n\t};\n\t\n\t/**\n\t * Get `Site` object instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.site = function (id) {\n\t return new Site(id, this);\n\t};\n\t\n\t/**\n\t * Get `Users` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.users = function () {\n\t return new Users(this);\n\t};\n\t\n\tWPCOM.prototype.batch = function () {\n\t return new Batch(this);\n\t};\n\t\n\t/**\n\t * List Freshly Pressed Posts\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn callback function\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.freshlyPressed = function (query, fn) {\n\t return this.req.get('/freshly-pressed', query, fn);\n\t};\n\t\n\t/**\n\t * Expose send-request\n\t * @TODO: use `this.req` instead of this method\n\t */\n\t\n\tWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n\t var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n\t if (console && console.warn) {\n\t //eslint-disable-line no-console\n\t console.warn(msg); //eslint-disable-line no-console\n\t } else {\n\t console.log(msg); //eslint-disable-line no-console\n\t }\n\t\n\t return sendRequest.call(this, params, query, body, fn);\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"debug\");\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(6);\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(18);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 5 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports) {\n\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Follow\n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current\n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's connections to third-party services\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.connections = function (query, fn) {\n\t return this.wpcom.req.get('/me/connections', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(17);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m[k];\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(8);\n\tvar Reblog = __webpack_require__(12);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(err);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(11);\n\tvar Category = __webpack_require__(5);\n\tvar Tag = __webpack_require__(14);\n\tvar Media = __webpack_require__(10);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(7);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"fs\");\n\n/***/ },\n/* 18 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"qs\");\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\tmodule.exports = require(\"wpcom-xhr-request\");\n\n/***/ }\n/******/ ]);\n\n\n/** WEBPACK FOOTER **\n ** index.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap cb200ffafedebfda21d3\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) { //eslint-disable-line no-console\n console.warn(msg); //eslint-disable-line no-console\n } else {\n console.log(msg); //eslint-disable-line no-console\n }\n\n return sendRequest.call(this, params, query, body, fn);\n};\n\nif (!Promise.prototype.timeout) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function (delay = DEFAULT_ASYNC_TIMEOUT) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error('Action timed out while waiting for response.'));\n }, delay);\n });\n\n cancelTimeout = () => {\n clearTimeout(timer);\n return this;\n };\n\n return Promise.race([ this.then(cancelTimeout).catch(cancelTimeout), timeout ]);\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","module.exports = require(\"debug\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"debug\"\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function () {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function (err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n });\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","/**\n * Follow\n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current\n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n/**\n * A list of the current user's connections to third-party services\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.connections = function (query, fn) {\n return this.wpcom.req.get('/me/connections', query, fn);\n};\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if (undefined === fn) {\n if (undefined === files) {\n files = query;\n query = {};\n } else if ('function' === typeof files) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [ files ];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([ param, f[k] ]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push([ 'media[]', f ]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if (undefined === fn) {\n if (undefined === media) {\n media = query;\n query = {};\n } else if ('function' === typeof media) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m[k];\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ('function' === typeof fn) {\n fn(null, data);\n } else {\n return Promise.resolve(data);\n }\n })\n .catch(err => {\n if ('function' === typeof fn) {\n fn(err);\n } else {\n return Promise.reject(err);\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if (undefined === fn) {\n if (undefined === note) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","module.exports = require(\"fs\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"fs\"\n ** module id = 17\n ** module chunks = 0\n **/","module.exports = require(\"qs\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"qs\"\n ** module id = 18\n ** module chunks = 0\n **/","module.exports = require(\"wpcom-xhr-request\");\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"wpcom-xhr-request\"\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file From da5dbb381a3880bb7c54e8c7fbeecb20e5321a2a Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 2 Oct 2015 16:00:56 -0700 Subject: [PATCH 06/37] Settle on a build layout. After lots of stewing and testing, I have decided to release this in the following manner: - All production files are built into the `dist/` directory - The node file is `index.js` - The browser file is `wpcom.js` - Both files are minified and have source-maps included. - The node version depends on the `npm` dependencies - The browser version only depends on the ES6 shims, such as Babel's polyfill or `core.js`. To test the browser version I created an HTML file just like in `Readme.md` and included the minified `wpcom.js`. First, however, I introduced a fatal error in the library and rebuilt the release files. When the Exception appeared in my browser, I was able to click on it in Chrome's DevTools and see the original source code via the source maps. I believe that this should be sufficient for our purposes here in that others are still welcome to use this without node and with the source map and without requiring a huge file. - Minified node build (no libraries included) : 16 KB - Minified browser build (with libraries) : 38 KB --- Makefile | 14 +++++++------- Readme.md | 4 +++- dist/wpcom.js | 3 ++- dist/wpcom.js.map | 1 + index.min.js | 2 -- index.min.js.map | 1 - package.json | 2 +- test/test.fixture.js | 2 +- webpack.config.js | 4 ++-- ....config.dist.js => webpack.config.standalone.js | 5 +++-- 10 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 dist/wpcom.js.map delete mode 100644 index.min.js delete mode 100644 index.min.js.map rename webpack.config.dist.js => webpack.config.standalone.js (87%) diff --git a/Makefile b/Makefile index 0df76e1..6a05dc0 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,12 @@ NPM ?= $(NODE) $(shell which npm) MOCHA ?= $(NODE) $(BIN)/mocha WEBPACK ?= $(NODE) $(BIN)/webpack -standalone: dist/wpcom.js +standalone: dist/wpcom.js dist/index.js -install: node_modules index.min.js +install: node_modules clean: - @rm -rf dist index.min.js index.min.js.map + @rm -rf dist distclean: clean @rm -rf node_modules @@ -25,12 +25,12 @@ distclean: clean dist: @mkdir -p $@ -dist/wpcom.js: node_modules *.js dist lib/*.js - @$(WEBPACK) -p --config webpack.config.dist.js - -index.min.js: node_modules lib/*.js +dist/index.js: node_modules *.js dist lib/*.js @$(WEBPACK) -p --config webpack.config.js +dist/wpcom.js: node_modules *.js dist lib/*.js + @$(WEBPACK) -p --config webpack.config.standalone.js + node_modules: package.json @NODE_ENV= $(NPM) install @touch node_modules diff --git a/Readme.md b/Readme.md index 952a92b..05aad77 100644 --- a/Readme.md +++ b/Readme.md @@ -22,9 +22,11 @@ blog.posts({ number: 8 }) ### Browser -Include `dist/wpcom.js` in a ` - - + + - + var html = '
site: ' + data.URL + '
'; + html += '' + data.description + '
'; + + document.getElementById('site').innerHTML = html; + input.removeAttribute('disabled'); + } ); + }); + + // select files on the "input" element + input.onchange = function (e) { + var files = []; + for (var i = 0; i < e.target.files.length; i++) { + files.push(e.target.files[i]); + } + + // do the API request through the iframe proxy + var req = wpcom + .site(siteId) + .addMediaFiles(files, function(err, res){ + if (err) throw err; + + console.log('response', res); + }); + + req.upload.onprogress = onprogress; + }; + + function onprogress (e) { + if (e.lengthComputable) { + var percentComplete = e.loaded / e.total * 100; + console.log('progress event! %s%', percentComplete.toFixed(2)); + } else { + // Unable to compute progress information since the total size is unknown + } + } + + From 8eba5e8f8c7e84c344dfa885e1c304f550d338e9 Mon Sep 17 00:00:00 2001 From: retrofox Date: Thu, 5 Nov 2015 11:08:59 -0300 Subject: [PATCH 34/37] dist:updated --- dist/wpcom.js | 6 +++--- dist/wpcom.js.map | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/wpcom.js b/dist/wpcom.js index b86c6f7..e4f765d 100644 --- a/dist/wpcom.js +++ b/dist/wpcom.js @@ -1,3 +1,3 @@ -var WPCOM=function(t){function e(o){if(r[o])return r[o].exports;var s=r[o]={exports:{},id:o,loaded:!1};return t[o].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function o(t,e){return this instanceof o?("function"==typeof t&&(e=t,t=null),t&&(l("Token defined: %s…",t.substring(0,6)),this.token=t),e?this.request=e:(l("No request handler. Adding default XHR request handler"),this.request=function(e,r){return e=e||{},t&&(e.authToken=t),s(e,r)}),this.req=new u(this),void(this.apiVersion="1.1")):new o(t,e)}var s=r(24),i=r(10),n=r(14),a=r(16),c=r(5),u=r(17),p=r(3),l=r(1)("wpcom"),h=3e4;o.prototype.me=function(){return new i(this)},o.prototype.site=function(t){return new n(t,this)},o.prototype.users=function(){return new a(this)},o.prototype.batch=function(){return new c(this)},o.prototype.freshlyPressed=function(t,e){return this.req.get("/freshly-pressed",t,e)},o.prototype.sendRequest=function(t,e,r,o){var s="WARN! Don use `sendRequest() anymore. Use `this.req` method.";return console&&console.warn?console.warn(s):console.log(s),p.call(this,t,e,r,o)},Promise.prototype.timeout||(Promise.prototype.timeout=function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?h:arguments[0],r=void 0,o=void 0,s=void 0;return s=new Promise(function(t,r){o=setTimeout(function(){r(new Error("Action timed out while waiting for response."))},e)}),r=function(){return clearTimeout(o),t},Promise.race([this.then(r)["catch"](r),s])}),t.exports=o},function(t,e,r){function o(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function s(){var t=arguments,r=this.useColors;if(t[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+t[0]+(r?"%c ":" ")+"+"+e.humanize(this.diff),!r)return t;var o="color: "+this.color;t=[t[0],o,"color: inherit"].concat(Array.prototype.slice.call(t,1));var s=0,i=0;return t[0].replace(/%[a-z%]/g,function(t){"%%"!==t&&(s++,"%c"===t&&(i=s))}),t.splice(i,0,o),t}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function n(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(r){}}function a(){var t;try{t=e.storage.debug}catch(r){}return t}function c(){try{return window.localStorage}catch(t){}}e=t.exports=r(18),e.log=i,e.formatArgs=s,e.save=n,e.load=a,e.useColors=o,e.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){return JSON.stringify(t)},e.enable(a())},function(t,e,r){function o(t,e,r,s){if(!r)throw new Error("`site id` is not correctly defined");return this instanceof o?(this.wpcom=s,this._cid=t,this._pid=e,void(this._sid=r)):new o(t,e,r,s)}var s=r(7);o.prototype.get=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.get(r,t,e)},o.prototype.replies=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/replies/";return this.wpcom.req.get(r,t,e)},o.prototype.add=function(t,e,r){void 0===r&&(void 0===e?(e=t,t={}):"function"==typeof e&&(r=e,e=t,t={})),e="string"==typeof e?{content:e}:e;var o="/sites/"+this._sid+"/posts/"+this._pid+"/replies/new";return this.wpcom.req.post(o,t,e,r)},o.prototype.update=function(t,e,r){"function"==typeof e&&(r=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var o="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.put(o,t,e,r)},o.prototype.reply=function(t,e,r){"function"==typeof e&&(r=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var o="/sites/"+this._sid+"/comments/"+this._cid+"/replies/new";return this.wpcom.req.post(o,t,e,r)},o.prototype.del=o.prototype["delete"]=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/delete";return this.wpcom.req.del(r,t,e)},o.prototype.like=function(){return s(this._cid,this._sid,this.wpcom)},o.prototype.likesList=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes";return this.wpcom.req.get(r,t,e)},t.exports=o},function(t,e,r){var o=r(21),s=r(1)("wpcom:send-request"),i=r(1)("wpcom:send-request:res");t.exports=function(t,e,r,n){var a=this;return t="string"==typeof t?{path:t}:t,s("sendRequest(%o)",t.path),t.method=(t.method||"get").toUpperCase(),"function"==typeof e&&(n=e,e={}),"function"==typeof r&&(n=r,r=null),e=e||{},e.apiVersion?(t.apiVersion=e.apiVersion,s("apiVersion: %o",t.apiVersion),delete e.apiVersion):t.apiVersion=this.apiVersion,e.proxyOrigin&&(t.proxyOrigin=e.proxyOrigin,s("proxyOrigin: %o",t.proxyOrigin),delete e.proxyOrigin),e=o.stringify(e,{arrayFormat:"brackets"}),t.query=e,r&&(t.body=r),s("params: %o",t),"function"==typeof n?this.request(t,function(t,e){i(e),n(t,e)}):new Promise(function(e,r){a.request(t,function(t,o){i(o),t?r(t):e(o)})})}},function(t,e){var r={};r.hexTable=new Array(256);for(var o=0;256>o;++o)r.hexTable[o]="%"+((16>o?"0":"")+o.toString(16)).toUpperCase();e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},o=0,s=t.length;s>o;++o)"undefined"!=typeof t[o]&&(r[o]=t[o]);return r},e.merge=function(t,r,o){if(!r)return t;if("object"!=typeof r)return Array.isArray(t)?t.push(r):"object"==typeof t?t[r]=!0:t=[t,r],t;if("object"!=typeof t)return t=[t].concat(r);Array.isArray(t)&&!Array.isArray(r)&&(t=e.arrayToObject(t,o));for(var s=Object.keys(r),i=0,n=s.length;n>i;++i){var a=s[i],c=r[a];Object.prototype.hasOwnProperty.call(t,a)?t[a]=e.merge(t[a],c,o):t[a]=c}return t},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;"string"!=typeof t&&(t=""+t);for(var e="",o=0,s=t.length;s>o;++o){var i=t.charCodeAt(o);45===i||46===i||95===i||126===i||i>=48&&57>=i||i>=65&&90>=i||i>=97&&122>=i?e+=t[o]:128>i?e+=r.hexTable[i]:2048>i?e+=r.hexTable[192|i>>6]+r.hexTable[128|63&i]:55296>i||i>=57344?e+=r.hexTable[224|i>>12]+r.hexTable[128|i>>6&63]+r.hexTable[128|63&i]:(++o,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),e+=r.hexTable[240|i>>18]+r.hexTable[128|i>>12&63]+r.hexTable[128|i>>6&63]+r.hexTable[128|63&i])}return e},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;r=r||[];var o=r.indexOf(t);if(-1!==o)return r[o];if(r.push(t),Array.isArray(t)){for(var s=[],i=0,n=t.length;n>i;++i)"undefined"!=typeof t[i]&&s.push(t[i]);return s}var a=Object.keys(t);for(i=0,n=a.length;n>i;++i){var c=a[i];t[c]=e.compact(t[c],r)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null===t||"undefined"==typeof t?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e){function r(t){return this instanceof r?(this.wpcom=t,void(this.urls=[])):new r(t)}r.prototype.add=function(t){return this.urls.push(t),this},r.prototype.run=function(t,e){return void 0===t&&(t={}),"function"==typeof t&&(e=t,t={}),t.urls=this.urls,this.wpcom.req.get("/batch",t,e)},t.exports=r},function(t,e){function r(t,e,o){if(!e)throw new Error("`site id` is not correctly defined");return this instanceof r?(this.wpcom=o,this._sid=e,void(this._slug=t)):new r(t,e,o)}r.prototype.slug=function(t){this._slug=t},r.prototype.get=function(t,e){var r="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.get(r,t,e)},r.prototype.add=function(t,e,r){var o="/sites/"+this._sid+"/categories/new";return this.wpcom.req.post(o,t,e,r)},r.prototype.update=function(t,e,r){var o="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.put(o,t,e,r)},r.prototype["delete"]=r.prototype.del=function(t,e){var r="/sites/"+this._sid+"/categories/slug:"+this._slug+"/delete";return this.wpcom.req.del(r,t,e)},t.exports=r},function(t,e){function r(t,e,o){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`comment id` is not correctly defined");return this instanceof r?(this.wpcom=o,this._cid=t,void(this._sid=e)):new r(t,e,o)}r.prototype.mine=r.prototype.state=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine";return this.wpcom.req.get(r,t,e)},r.prototype.add=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes/new";return this.wpcom.req.post(r,t,e)},r.prototype.del=r.prototype["delete"]=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine/delete";return this.wpcom.req.del(r,t,e)},t.exports=r},function(t,e){function r(t,e){if(!t)throw new Error("`site id` is not correctly defined");return this instanceof r?(this.wpcom=e,void(this._sid=t)):new r(t,e)}r.prototype.mine=r.prototype.state=function(t,e){var r="/sites/"+this._sid+"/follows/mine";return this.wpcom.req.get(r,t,e)},r.prototype.follow=r.prototype.add=function(t,e){var r="/sites/"+this._sid+"/follows/new";return this.wpcom.req.put(r,t,null,e)},r.prototype.unfollow=r.prototype.del=function(t,e){var r="/sites/"+this._sid+"/follows/mine/delete";return this.wpcom.req.del(r,t,null,e)},t.exports=r},function(t,e){function r(t,e,o){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`post id` is not correctly defined");return this instanceof r?(this.wpcom=o,this._pid=t,void(this._sid=e)):new r(t,e,o)}r.prototype.mine=r.prototype.state=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine";return this.wpcom.req.get(r,t,e)},r.prototype.add=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/likes/new";return this.wpcom.req.put(r,t,null,e)},r.prototype.del=r.prototype["delete"]=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine/delete";return this.wpcom.req.del(r,t,e)},t.exports=r},function(t,e){function r(t){return this instanceof r?void(this.wpcom=t):new r(t)}r.prototype.get=function(t,e){return this.wpcom.req.get("/me",t,e)},r.prototype.sites=function(t,e){return this.wpcom.req.get("/me/sites",t,e)},r.prototype.likes=function(t,e){return this.wpcom.req.get("/me/likes",t,e)},r.prototype.groups=function(t,e){return this.wpcom.req.get("/me/groups",t,e)},t.exports=r},function(t,e,r){function o(t,e,r){return this instanceof o?(this.wpcom=r,this._sid=e,this._id=t,void(this._id||i("WARN: media `id` is not defined"))):new o(t,e,r)}var s=r(20),i=r(1)("wpcom:media");o.prototype.get=function(t,e){var r="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.get(r,t,e)},o.prototype.update=function(t,e,r){var o="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.put(o,t,e,r)},o.prototype.addFiles=function(t,e,r){void 0===r&&(void 0===e?(e=t,t={}):"function"==typeof e&&(r=e,e=t,t={}));var o={path:"/sites/"+this._sid+"/media/new",formData:[]};e=Array.isArray(e)?e:[e];var n,a,c,u,p,l;for(n=0;n %o",p,a[p]),"file"!==p&&(l="attrs["+n+"]["+p+"]",o.formData.push([l,a[p]]));a=a.file,a="string"==typeof a?s.createReadStream(a):a}o.formData.push(["media[]",a])}return this.wpcom.req.post(o,t,null,r)},o.prototype.addUrls=function(t,e,r){void 0===r&&(void 0===e?(e=t,t={}):"function"==typeof e&&(r=e,e=t,t={}));var o,s,i,n,a="/sites/"+this._sid+"/media/new",c={media_urls:[]};for(e=Array.isArray(e)?e:[e],o=0;os;s++)r[s]&&(t=r[s].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function n(){e.enable("")}function a(t){var r,o;for(r=0,o=e.skips.length;o>r;r++)if(e.skips[r].test(t))return!1;for(r=0,o=e.names.length;o>r;r++)if(e.names[r].test(t))return!0;return!1}function c(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=s,e.coerce=c,e.disable=n,e.enable=i,e.enabled=a,e.humanize=r(19),e.names=[],e.skips=[],e.formatters={};var u,p=0},function(t,e){function r(t){if(t=""+t,!(t.length>1e4)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),o=(e[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*u;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function o(t){return t>=u?Math.round(t/u)+"d":t>=c?Math.round(t/c)+"h":t>=a?Math.round(t/a)+"m":t>=n?Math.round(t/n)+"s":t+"ms"}function s(t){return i(t,u,"day")||i(t,c,"hour")||i(t,a,"minute")||i(t,n,"second")||t+" ms"}function i(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var n=1e3,a=60*n,c=60*a,u=24*c,p=365.25*u;t.exports=function(t,e){return e=e||{},"string"==typeof t?r(t):e["long"]?s(t):o(t)}},function(t,e){console.log("I'm `fs` modules")},function(t,e,r){var o=r(23),s=r(22);t.exports={stringify:o,parse:s}},function(t,e,r){var o=r(4),s={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1};s.parseValues=function(t,e){for(var r={},s=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),i=0,n=s.length;n>i;++i){var a=s[i],c=-1===a.indexOf("]=")?a.indexOf("="):a.indexOf("]=")+1;if(-1===c)r[o.decode(a)]="",e.strictNullHandling&&(r[o.decode(a)]=null);else{var u=o.decode(a.slice(0,c)),p=o.decode(a.slice(c+1));Object.prototype.hasOwnProperty.call(r,u)?r[u]=[].concat(r[u]).concat(p):r[u]=p}}return r},s.parseObject=function(t,e,r){if(!t.length)return e;var o,i=t.shift();if("[]"===i)o=[],o=o.concat(s.parseObject(t,e,r));else{o=r.plainObjects?Object.create(null):{};var n="["===i[0]&&"]"===i[i.length-1]?i.slice(1,i.length-1):i,a=parseInt(n,10),c=""+a;!isNaN(a)&&i!==n&&c===n&&a>=0&&r.parseArrays&&a<=r.arrayLimit?(o=[],o[a]=s.parseObject(t,e,r)):o[n]=s.parseObject(t,e,r)}return o},s.parseKeys=function(t,e,r){if(t){r.allowDots&&(t=t.replace(/\.([^\.\[]+)/g,"[$1]"));var o=/^([^\[\]]*)/,i=/(\[[^\[\]]*\])/g,n=o.exec(t),a=[];if(n[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(n[1])&&!r.allowPrototypes)return;a.push(n[1])}for(var c=0;null!==(n=i.exec(t))&&ca;++a){var u=n[a],p=s.parseKeys(u,r[u],e);i=o.merge(i,p,e)}return o.compact(i)}},function(t,e,r){var o=r(4),s={delimiter:"&",arrayPrefixGenerators:{brackets:function(t,e){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t,e){return t}},strictNullHandling:!1};s.stringify=function(t,e,r,i,n){if("function"==typeof n)t=n(e,t);else if(o.isBuffer(t))t=t.toString();else if(t instanceof Date)t=t.toISOString();else if(null===t){if(i)return o.encode(e);t=""}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return[o.encode(e)+"="+o.encode(t)];var a=[];if("undefined"==typeof t)return a;for(var c=Array.isArray(n)?n:Object.keys(t),u=0,p=c.length;p>u;++u){var l=c[u];a=Array.isArray(t)?a.concat(s.stringify(t[l],r(e,l),r,i,n)):a.concat(s.stringify(t[l],e+"["+l+"]",r,i,n))}return a},t.exports=function(t,e){e=e||{};var r,o,i="undefined"==typeof e.delimiter?s.delimiter:e.delimiter,n="boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling;"function"==typeof e.filter?(o=e.filter,t=o("",t)):Array.isArray(e.filter)&&(r=o=e.filter);var a=[];if("object"!=typeof t||null===t)return"";var c;c=e.arrayFormat in s.arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":"indices";var u=s.arrayPrefixGenerators[c];r||(r=Object.keys(t));for(var p=0,l=r.length;l>p;++p){var h=r[p];a=a.concat(s.stringify(t[h],h,u,n,o))}return a.join(i)}},function(t,e,r){function o(t,e){"string"==typeof t&&(t={path:t});var r=(t.method||"GET").toLowerCase();n("API HTTP Method: %o",r),delete t.method;var o=t.apiVersion||c;delete t.apiVersion,a=t.proxyOrigin||a,delete t.proxyOrigin;var u=a+"/rest/v"+o+t.path;n("API URL: %o",u),delete t.path;var p=i[r](u);if(t.authToken&&(p.set("Authorization","Bearer "+t.authToken),delete t.authToken),t.query&&(p.query(t.query),n("API send URL querystring: %o",t.query),delete t.query),t.body&&(p.send(t.body),n("API send POST body: ",t.body),delete t.body),t.formData)for(var l=0;l %o status code",u,a),o&&i&&(o._headers=i),!t)return e(null,o);t=new Error,t.statusCode=a;for(var c in o)t[c]=o[c];o&&o.error&&(t.name=s(o.error)+"Error"),e(t)}),p.xhr}function s(t){return t&&"string"==typeof t?t.replace(/((^|_)[a-z])/g,function(t){return t.toUpperCase().replace("_","")}):""}var i=r(28),n=r(25)("wpcom-xhr-request");t.exports=o;var a="https://public-api.wordpress.com",c="1"},function(t,e,r){function o(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function s(){var t=arguments,r=this.useColors;if(t[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+t[0]+(r?"%c ":" ")+"+"+e.humanize(this.diff),!r)return t;var o="color: "+this.color;t=[t[0],o,"color: inherit"].concat(Array.prototype.slice.call(t,1));var s=0,i=0;return t[0].replace(/%[a-z%]/g,function(t){"%%"!==t&&(s++,"%c"===t&&(i=s))}),t.splice(i,0,o),t}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function n(t){try{null==t?u.removeItem("debug"):u.debug=t}catch(e){}}function a(){var t;try{t=u.debug}catch(e){}return t}function c(){try{return window.localStorage}catch(t){}}e=t.exports=r(26),e.log=i,e.formatArgs=s,e.save=n,e.load=a,e.useColors=o;var u;u="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){return JSON.stringify(t)},e.enable(a())},function(t,e,r){function o(){return e.colors[p++%e.colors.length]}function s(t){function r(){}function s(){var t=s,r=+new Date,i=r-(u||r);t.diff=i,t.prev=u,t.curr=r,u=r,null==t.useColors&&(t.useColors=e.useColors()),null==t.color&&t.useColors&&(t.color=o());var n=Array.prototype.slice.call(arguments);n[0]=e.coerce(n[0]),"string"!=typeof n[0]&&(n=["%o"].concat(n));var a=0;n[0]=n[0].replace(/%([a-z%])/g,function(r,o){if("%%"===r)return r;a++;var s=e.formatters[o];if("function"==typeof s){var i=n[a];r=s.call(t,i),n.splice(a,1),a--}return r}),"function"==typeof e.formatArgs&&(n=e.formatArgs.apply(t,n));var c=s.log||e.log||console.log.bind(console);c.apply(t,n)}r.enabled=!1,s.enabled=!0;var i=e.enabled(t)?s:r;return i.namespace=t,i}function i(t){e.save(t);for(var r=(t||"").split(/[\s,]+/),o=r.length,s=0;o>s;s++)r[s]&&(t=r[s].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function n(){e.enable("")}function a(t){var r,o;for(r=0,o=e.skips.length;o>r;r++)if(e.skips[r].test(t))return!1;for(r=0,o=e.names.length;o>r;r++)if(e.names[r].test(t))return!0;return!1}function c(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=s,e.coerce=c,e.disable=n,e.enable=i,e.enabled=a,e.humanize=r(27),e.names=[],e.skips=[],e.formatters={};var u,p=0},function(t,e){function r(t){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),o=(e[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*u;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}function o(t){return t>=u?Math.round(t/u)+"d":t>=c?Math.round(t/c)+"h":t>=a?Math.round(t/a)+"m":t>=n?Math.round(t/n)+"s":t+"ms"}function s(t){return i(t,u,"day")||i(t,c,"hour")||i(t,a,"minute")||i(t,n,"second")||t+" ms"}function i(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var n=1e3,a=60*n,c=60*a,u=24*c,p=365.25*u;t.exports=function(t,e){return e=e||{},"string"==typeof t?r(t):e["long"]?s(t):o(t)}},function(t,e,r){function o(){}function s(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function i(t){return t===Object(t)}function n(t){if(!i(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function a(t){for(var e,r,o={},s=t.split("&"),i=0,n=s.length;n>i;++i)r=s[i],e=r.split("="),o[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return o}function c(t){var e,r,o,s,i=t.split(/\r?\n/),n={};i.pop();for(var a=0,c=i.length;c>a;++a)r=i[a],e=r.indexOf(":"),o=r.slice(0,e).toLowerCase(),s=g(r.slice(e+1)),n[o]=s;return n}function u(t){return t.split(/ *; */).shift()}function p(t){return m(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),o=r.shift(),s=r.shift();return o&&s&&(t[o]=s),t},{})}function l(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=c(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function h(t,e){var r=this;f.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t=null,e=null;try{e=new l(r)}catch(o){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=o,r.callback(t)}if(r.emit("response",e),t)return r.callback(t,e);if(e.status>=200&&e.status<300)return r.callback(t,e); -var s=new Error(e.statusText||"Unsuccessful HTTP response");s.original=t,s.response=e,s.status=e.status,r.callback(t||s,e)})}function d(t,e){return"function"==typeof e?new h("GET",t).end(e):1==arguments.length?new h("GET",t):new h(t,e)}var f=r(29),m=r(30),y="undefined"==typeof window?this||self:window;d.getXHR=function(){if(!(!y.XMLHttpRequest||y.location&&"file:"==y.location.protocol&&y.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1};var g="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};d.serializeObject=n,d.parseString=a,d.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},d.serialize={"application/x-www-form-urlencoded":n,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":a,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype.setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=u(e);var r=p(e);for(var o in r)this[o]=r[o]},l.prototype.parseBody=function(t){var e=d.parse[this.type];return e&&t&&(t.length||t instanceof Object)?e(t):null},l.prototype.setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,o="cannot "+e+" "+r+" ("+this.status+")",s=new Error(o);return s.status=this.status,s.method=e,s.url=r,s},d.Response=l,f(h.prototype),h.prototype.use=function(t){return t(this),this},h.prototype.timeout=function(t){return this._timeout=t,this},h.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},h.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},h.prototype.set=function(t,e){if(i(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},h.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},h.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},h.prototype.type=function(t){return this.set("Content-Type",d.types[t]||t),this},h.prototype.accept=function(t){return this.set("Accept",d.types[t]||t),this},h.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},h.prototype.query=function(t){return"string"!=typeof t&&(t=n(t)),t&&this._query.push(t),this},h.prototype.field=function(t,e){return this._formData||(this._formData=new y.FormData),this._formData.append(t,e),this},h.prototype.attach=function(t,e,r){return this._formData||(this._formData=new y.FormData),this._formData.append(t,e,r),this},h.prototype.send=function(t){var e=i(t),r=this.getHeader("Content-Type");if(e&&i(this._data))for(var o in t)this._data[o]=t[o];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||s(t)?this:(r||this.type("json"),this)},h.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},h.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},h.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},h.prototype.withCredentials=function(){return this._withCredentials=!0,this},h.prototype.end=function(t){var e=this,r=this.xhr=d.getXHR(),i=this._query.join("&"),n=this._timeout,a=this._formData||this._data;this._callback=t||o,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(o){t=0}if(0==t){if(e.timedout)return e.timeoutError();if(e.aborted)return;return e.crossDomainError()}e.emit("end")}};var c=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=c);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=c)}catch(u){}if(n&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},n)),i&&(i=d.serializeObject(i),this.url+=~this.url.indexOf("?")?"&"+i:"?"+i),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!s(a)){var p=d.serialize[this.getHeader("Content-Type")];p&&(a=p(a))}for(var l in this.header)null!=this.header[l]&&r.setRequestHeader(l,this.header[l]);return this.emit("request",this),r.send(a),this},d.Request=h,d.get=function(t,e,r){var o=d("GET",t);return"function"==typeof e&&(r=e,e=null),e&&o.query(e),r&&o.end(r),o},d.head=function(t,e,r){var o=d("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},d.del=function(t,e){var r=d("DELETE",t);return e&&r.end(e),r},d.patch=function(t,e,r){var o=d("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},d.post=function(t,e,r){var o=d("POST",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},d.put=function(t,e,r){var o=d("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},t.exports=d},function(t,e){function r(t){return t?o(t):void 0}function o(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){function r(){o.off(t,r),e.apply(this,arguments)}var o=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var o,s=0;so;++o)r[o].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=function(t,e,r){for(var o=0,s=t.length,i=3==arguments.length?r:t[o++];s>o;)i=e.call(null,i,t[o],++o,t);return i}}]); -//# sourceMappingURL=wpcom.js.map +var WPCOM=function(t){function e(o){if(r[o])return r[o].exports;var s=r[o]={exports:{},id:o,loaded:!1};return t[o].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function o(t,e){return this instanceof o?("function"==typeof t&&(e=t,t=null),t&&(l("Token defined: %s…",t.substring(0,6)),this.token=t),e?this.request=e:(l("No request handler. Adding default XHR request handler"),this.request=function(e,r){return e=e||{},t&&(e.authToken=t),s(e,r)}),this.req=new u(this),void(this.apiVersion="1.1")):new o(t,e)}var s=r(24),i=r(10),n=r(14),a=r(16),c=r(5),u=r(17),p=r(3),l=r(1)("wpcom"),h=3e4;o.prototype.me=function(){return new i(this)},o.prototype.site=function(t){return new n(t,this)},o.prototype.users=function(){return new a(this)},o.prototype.batch=function(){return new c(this)},o.prototype.freshlyPressed=function(t,e){return this.req.get("/freshly-pressed",t,e)},o.prototype.sendRequest=function(t,e,r,o){var s="WARN! Don use `sendRequest() anymore. Use `this.req` method.";return console&&console.warn?console.warn(s):console.log(s),p.call(this,t,e,r,o)},Promise.prototype.timeout||(Promise.prototype.timeout=function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?h:arguments[0],r=void 0,o=void 0,s=void 0;return s=new Promise(function(t,r){o=setTimeout(function(){r(new Error("Action timed out while waiting for response."))},e)}),r=function(){return clearTimeout(o),t},Promise.race([this.then(r)["catch"](r),s])}),t.exports=o},function(t,e,r){function o(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function s(){var t=arguments,r=this.useColors;if(t[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+t[0]+(r?"%c ":" ")+"+"+e.humanize(this.diff),!r)return t;var o="color: "+this.color;t=[t[0],o,"color: inherit"].concat(Array.prototype.slice.call(t,1));var s=0,i=0;return t[0].replace(/%[a-z%]/g,function(t){"%%"!==t&&(s++,"%c"===t&&(i=s))}),t.splice(i,0,o),t}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function n(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(r){}}function a(){var t;try{t=e.storage.debug}catch(r){}return t}function c(){try{return window.localStorage}catch(t){}}e=t.exports=r(18),e.log=i,e.formatArgs=s,e.save=n,e.load=a,e.useColors=o,e.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){return JSON.stringify(t)},e.enable(a())},function(t,e,r){function o(t,e,r,s){if(!r)throw new Error("`site id` is not correctly defined");return this instanceof o?(this.wpcom=s,this._cid=t,this._pid=e,void(this._sid=r)):new o(t,e,r,s)}var s=r(7);o.prototype.get=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.get(r,t,e)},o.prototype.replies=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/replies/";return this.wpcom.req.get(r,t,e)},o.prototype.add=function(t,e,r){void 0===r&&(void 0===e?(e=t,t={}):"function"==typeof e&&(r=e,e=t,t={})),e="string"==typeof e?{content:e}:e;var o="/sites/"+this._sid+"/posts/"+this._pid+"/replies/new";return this.wpcom.req.post(o,t,e,r)},o.prototype.update=function(t,e,r){"function"==typeof e&&(r=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var o="/sites/"+this._sid+"/comments/"+this._cid;return this.wpcom.req.put(o,t,e,r)},o.prototype.reply=function(t,e,r){"function"==typeof e&&(r=e,e=t,t={}),e="string"==typeof e?{content:e}:e;var o="/sites/"+this._sid+"/comments/"+this._cid+"/replies/new";return this.wpcom.req.post(o,t,e,r)},o.prototype.del=o.prototype["delete"]=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/delete";return this.wpcom.req.del(r,t,e)},o.prototype.like=function(){return s(this._cid,this._sid,this.wpcom)},o.prototype.likesList=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes";return this.wpcom.req.get(r,t,e)},t.exports=o},function(t,e,r){var o=r(20),s=r(1)("wpcom:send-request"),i=r(1)("wpcom:send-request:res");t.exports=function(t,e,r,n){var a=this;return t="string"==typeof t?{path:t}:t,s("sendRequest(%o)",t.path),t.method=(t.method||"get").toUpperCase(),"function"==typeof e&&(n=e,e={}),"function"==typeof r&&(n=r,r=null),e=e||{},e.apiVersion?(t.apiVersion=e.apiVersion,s("apiVersion: %o",t.apiVersion),delete e.apiVersion):t.apiVersion=this.apiVersion,e.proxyOrigin&&(t.proxyOrigin=e.proxyOrigin,s("proxyOrigin: %o",t.proxyOrigin),delete e.proxyOrigin),e=o.stringify(e,{arrayFormat:"brackets"}),t.query=e,r&&(t.body=r),s("params: %o",t),"function"==typeof n?this.request(t,function(t,e){i(e),n(t,e)}):new Promise(function(e,r){a.request(t,function(t,o){i(o),t?r(t):e(o)})})}},function(t,e){var r={};r.hexTable=new Array(256);for(var o=0;256>o;++o)r.hexTable[o]="%"+((16>o?"0":"")+o.toString(16)).toUpperCase();e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},o=0,s=t.length;s>o;++o)"undefined"!=typeof t[o]&&(r[o]=t[o]);return r},e.merge=function(t,r,o){if(!r)return t;if("object"!=typeof r)return Array.isArray(t)?t.push(r):"object"==typeof t?t[r]=!0:t=[t,r],t;if("object"!=typeof t)return t=[t].concat(r);Array.isArray(t)&&!Array.isArray(r)&&(t=e.arrayToObject(t,o));for(var s=Object.keys(r),i=0,n=s.length;n>i;++i){var a=s[i],c=r[a];Object.prototype.hasOwnProperty.call(t,a)?t[a]=e.merge(t[a],c,o):t[a]=c}return t},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;"string"!=typeof t&&(t=""+t);for(var e="",o=0,s=t.length;s>o;++o){var i=t.charCodeAt(o);45===i||46===i||95===i||126===i||i>=48&&57>=i||i>=65&&90>=i||i>=97&&122>=i?e+=t[o]:128>i?e+=r.hexTable[i]:2048>i?e+=r.hexTable[192|i>>6]+r.hexTable[128|63&i]:55296>i||i>=57344?e+=r.hexTable[224|i>>12]+r.hexTable[128|i>>6&63]+r.hexTable[128|63&i]:(++o,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),e+=r.hexTable[240|i>>18]+r.hexTable[128|i>>12&63]+r.hexTable[128|i>>6&63]+r.hexTable[128|63&i])}return e},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;r=r||[];var o=r.indexOf(t);if(-1!==o)return r[o];if(r.push(t),Array.isArray(t)){for(var s=[],i=0,n=t.length;n>i;++i)"undefined"!=typeof t[i]&&s.push(t[i]);return s}var a=Object.keys(t);for(i=0,n=a.length;n>i;++i){var c=a[i];t[c]=e.compact(t[c],r)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null===t||"undefined"==typeof t?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e){function r(t){return this instanceof r?(this.wpcom=t,void(this.urls=[])):new r(t)}r.prototype.add=function(t){return this.urls.push(t),this},r.prototype.run=function(t,e){return void 0===t&&(t={}),"function"==typeof t&&(e=t,t={}),t.urls=this.urls,this.wpcom.req.get("/batch",t,e)},t.exports=r},function(t,e){function r(t,e,o){if(!e)throw new Error("`site id` is not correctly defined");return this instanceof r?(this.wpcom=o,this._sid=e,void(this._slug=t)):new r(t,e,o)}r.prototype.slug=function(t){this._slug=t},r.prototype.get=function(t,e){var r="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.get(r,t,e)},r.prototype.add=function(t,e,r){var o="/sites/"+this._sid+"/categories/new";return this.wpcom.req.post(o,t,e,r)},r.prototype.update=function(t,e,r){var o="/sites/"+this._sid+"/categories/slug:"+this._slug;return this.wpcom.req.put(o,t,e,r)},r.prototype["delete"]=r.prototype.del=function(t,e){var r="/sites/"+this._sid+"/categories/slug:"+this._slug+"/delete";return this.wpcom.req.del(r,t,e)},t.exports=r},function(t,e){function r(t,e,o){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`comment id` is not correctly defined");return this instanceof r?(this.wpcom=o,this._cid=t,void(this._sid=e)):new r(t,e,o)}r.prototype.mine=r.prototype.state=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine";return this.wpcom.req.get(r,t,e)},r.prototype.add=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes/new";return this.wpcom.req.post(r,t,e)},r.prototype.del=r.prototype["delete"]=function(t,e){var r="/sites/"+this._sid+"/comments/"+this._cid+"/likes/mine/delete";return this.wpcom.req.del(r,t,e)},t.exports=r},function(t,e){function r(t,e){if(!t)throw new Error("`site id` is not correctly defined");return this instanceof r?(this.wpcom=e,void(this._sid=t)):new r(t,e)}r.prototype.mine=r.prototype.state=function(t,e){var r="/sites/"+this._sid+"/follows/mine";return this.wpcom.req.get(r,t,e)},r.prototype.follow=r.prototype.add=function(t,e){var r="/sites/"+this._sid+"/follows/new";return this.wpcom.req.put(r,t,null,e)},r.prototype.unfollow=r.prototype.del=function(t,e){var r="/sites/"+this._sid+"/follows/mine/delete";return this.wpcom.req.del(r,t,null,e)},t.exports=r},function(t,e){function r(t,e,o){if(!e)throw new Error("`site id` is not correctly defined");if(!t)throw new Error("`post id` is not correctly defined");return this instanceof r?(this.wpcom=o,this._pid=t,void(this._sid=e)):new r(t,e,o)}r.prototype.mine=r.prototype.state=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine";return this.wpcom.req.get(r,t,e)},r.prototype.add=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/likes/new";return this.wpcom.req.put(r,t,null,e)},r.prototype.del=r.prototype["delete"]=function(t,e){var r="/sites/"+this._sid+"/posts/"+this._pid+"/likes/mine/delete";return this.wpcom.req.del(r,t,e)},t.exports=r},function(t,e){function r(t){return this instanceof r?void(this.wpcom=t):new r(t)}r.prototype.get=function(t,e){return this.wpcom.req.get("/me",t,e)},r.prototype.sites=function(t,e){return this.wpcom.req.get("/me/sites",t,e)},r.prototype.likes=function(t,e){return this.wpcom.req.get("/me/likes",t,e)},r.prototype.groups=function(t,e){return this.wpcom.req.get("/me/groups",t,e)},t.exports=r},function(t,e,r){function o(t,e,r){return this instanceof o?(this.wpcom=r,this._sid=e,this._id=t,void(this._id||i("WARN: media `id` is not defined"))):new o(t,e,r)}var s=r(23),i=r(1)("wpcom:media");o.prototype.get=function(t,e){var r="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.get(r,t,e)},o.prototype.update=function(t,e,r){var o="/sites/"+this._sid+"/media/"+this._id;return this.wpcom.req.put(o,t,e,r)},o.prototype.addFiles=function(t,e,r){void 0===r&&(void 0===e?(e=t,t={}):"function"==typeof e&&(r=e,e=t,t={}));var o={path:"/sites/"+this._sid+"/media/new",formData:[]};e=Array.isArray(e)?e:[e];var n,a,c,u,p,l;for(n=0;n %o",p,a[p]),"file"!==p&&(l="attrs["+n+"]["+p+"]",o.formData.push([l,a[p]]));a=a.file,a="string"==typeof a?s.createReadStream(a):a}o.formData.push(["media[]",a])}return this.wpcom.req.post(o,t,null,r)},o.prototype.addUrls=function(t,e,r){void 0===r&&(void 0===e?(e=t,t={}):"function"==typeof e&&(r=e,e=t,t={}));var o,s,i,n,a="/sites/"+this._sid+"/media/new",c={media_urls:[]};for(e=Array.isArray(e)?e:[e],o=0;os;s++)r[s]&&(t=r[s].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function n(){e.enable("")}function a(t){var r,o;for(r=0,o=e.skips.length;o>r;r++)if(e.skips[r].test(t))return!1;for(r=0,o=e.names.length;o>r;r++)if(e.names[r].test(t))return!0;return!1}function c(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=s,e.coerce=c,e.disable=n,e.enable=i,e.enabled=a,e.humanize=r(19),e.names=[],e.skips=[],e.formatters={};var u,p=0},function(t,e){function r(t){if(t=""+t,!(t.length>1e4)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),o=(e[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*u;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function o(t){return t>=u?Math.round(t/u)+"d":t>=c?Math.round(t/c)+"h":t>=a?Math.round(t/a)+"m":t>=n?Math.round(t/n)+"s":t+"ms"}function s(t){return i(t,u,"day")||i(t,c,"hour")||i(t,a,"minute")||i(t,n,"second")||t+" ms"}function i(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var n=1e3,a=60*n,c=60*a,u=24*c,p=365.25*u;t.exports=function(t,e){return e=e||{},"string"==typeof t?r(t):e["long"]?s(t):o(t)}},function(t,e,r){var o=r(22),s=r(21);t.exports={stringify:o,parse:s}},function(t,e,r){var o=r(4),s={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1};s.parseValues=function(t,e){for(var r={},s=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),i=0,n=s.length;n>i;++i){var a=s[i],c=-1===a.indexOf("]=")?a.indexOf("="):a.indexOf("]=")+1;if(-1===c)r[o.decode(a)]="",e.strictNullHandling&&(r[o.decode(a)]=null);else{var u=o.decode(a.slice(0,c)),p=o.decode(a.slice(c+1));Object.prototype.hasOwnProperty.call(r,u)?r[u]=[].concat(r[u]).concat(p):r[u]=p}}return r},s.parseObject=function(t,e,r){if(!t.length)return e;var o,i=t.shift();if("[]"===i)o=[],o=o.concat(s.parseObject(t,e,r));else{o=r.plainObjects?Object.create(null):{};var n="["===i[0]&&"]"===i[i.length-1]?i.slice(1,i.length-1):i,a=parseInt(n,10),c=""+a;!isNaN(a)&&i!==n&&c===n&&a>=0&&r.parseArrays&&a<=r.arrayLimit?(o=[],o[a]=s.parseObject(t,e,r)):o[n]=s.parseObject(t,e,r)}return o},s.parseKeys=function(t,e,r){if(t){r.allowDots&&(t=t.replace(/\.([^\.\[]+)/g,"[$1]"));var o=/^([^\[\]]*)/,i=/(\[[^\[\]]*\])/g,n=o.exec(t),a=[];if(n[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(n[1])&&!r.allowPrototypes)return;a.push(n[1])}for(var c=0;null!==(n=i.exec(t))&&ca;++a){var u=n[a],p=s.parseKeys(u,r[u],e);i=o.merge(i,p,e)}return o.compact(i)}},function(t,e,r){var o=r(4),s={delimiter:"&",arrayPrefixGenerators:{brackets:function(t,e){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t,e){return t}},strictNullHandling:!1};s.stringify=function(t,e,r,i,n){if("function"==typeof n)t=n(e,t);else if(o.isBuffer(t))t=t.toString();else if(t instanceof Date)t=t.toISOString();else if(null===t){if(i)return o.encode(e);t=""}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return[o.encode(e)+"="+o.encode(t)];var a=[];if("undefined"==typeof t)return a;for(var c=Array.isArray(n)?n:Object.keys(t),u=0,p=c.length;p>u;++u){var l=c[u];a=Array.isArray(t)?a.concat(s.stringify(t[l],r(e,l),r,i,n)):a.concat(s.stringify(t[l],e+"["+l+"]",r,i,n))}return a},t.exports=function(t,e){e=e||{};var r,o,i="undefined"==typeof e.delimiter?s.delimiter:e.delimiter,n="boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling;"function"==typeof e.filter?(o=e.filter,t=o("",t)):Array.isArray(e.filter)&&(r=o=e.filter);var a=[];if("object"!=typeof t||null===t)return"";var c;c=e.arrayFormat in s.arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":"indices";var u=s.arrayPrefixGenerators[c];r||(r=Object.keys(t));for(var p=0,l=r.length;l>p;++p){var h=r[p];a=a.concat(s.stringify(t[h],h,u,n,o))}return a.join(i)}},function(t,e){},function(t,e,r){function o(t,e){"string"==typeof t&&(t={path:t});var r=(t.method||"GET").toLowerCase();n("API HTTP Method: %o",r),delete t.method;var o=t.apiVersion||c;delete t.apiVersion,a=t.proxyOrigin||a,delete t.proxyOrigin;var u=a+"/rest/v"+o+t.path;n("API URL: %o",u),delete t.path;var p=i[r](u);if(t.authToken&&(p.set("Authorization","Bearer "+t.authToken),delete t.authToken),t.query&&(p.query(t.query),n("API send URL querystring: %o",t.query),delete t.query),t.body&&(p.send(t.body),n("API send POST body: ",t.body),delete t.body),t.formData)for(var l=0;l %o status code",u,a),o&&i&&(o._headers=i),!t)return e(null,o);t=new Error,t.statusCode=a;for(var c in o)t[c]=o[c];o&&o.error&&(t.name=s(o.error)+"Error"),e(t)}),p.xhr}function s(t){return t&&"string"==typeof t?t.replace(/((^|_)[a-z])/g,function(t){return t.toUpperCase().replace("_","")}):""}var i=r(28),n=r(25)("wpcom-xhr-request");t.exports=o;var a="https://public-api.wordpress.com",c="1"},function(t,e,r){function o(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function s(){var t=arguments,r=this.useColors;if(t[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+t[0]+(r?"%c ":" ")+"+"+e.humanize(this.diff),!r)return t;var o="color: "+this.color;t=[t[0],o,"color: inherit"].concat(Array.prototype.slice.call(t,1));var s=0,i=0;return t[0].replace(/%[a-z%]/g,function(t){"%%"!==t&&(s++,"%c"===t&&(i=s))}),t.splice(i,0,o),t}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function n(t){try{null==t?u.removeItem("debug"):u.debug=t}catch(e){}}function a(){var t;try{t=u.debug}catch(e){}return t}function c(){try{return window.localStorage}catch(t){}}e=t.exports=r(26),e.log=i,e.formatArgs=s,e.save=n,e.load=a,e.useColors=o;var u;u="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){return JSON.stringify(t)},e.enable(a())},function(t,e,r){function o(){return e.colors[p++%e.colors.length]}function s(t){function r(){}function s(){var t=s,r=+new Date,i=r-(u||r);t.diff=i,t.prev=u,t.curr=r,u=r,null==t.useColors&&(t.useColors=e.useColors()),null==t.color&&t.useColors&&(t.color=o());var n=Array.prototype.slice.call(arguments);n[0]=e.coerce(n[0]),"string"!=typeof n[0]&&(n=["%o"].concat(n));var a=0;n[0]=n[0].replace(/%([a-z%])/g,function(r,o){if("%%"===r)return r;a++;var s=e.formatters[o];if("function"==typeof s){var i=n[a];r=s.call(t,i),n.splice(a,1),a--}return r}),"function"==typeof e.formatArgs&&(n=e.formatArgs.apply(t,n));var c=s.log||e.log||console.log.bind(console);c.apply(t,n)}r.enabled=!1,s.enabled=!0;var i=e.enabled(t)?s:r;return i.namespace=t,i}function i(t){e.save(t);for(var r=(t||"").split(/[\s,]+/),o=r.length,s=0;o>s;s++)r[s]&&(t=r[s].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function n(){e.enable("")}function a(t){var r,o;for(r=0,o=e.skips.length;o>r;r++)if(e.skips[r].test(t))return!1;for(r=0,o=e.names.length;o>r;r++)if(e.names[r].test(t))return!0;return!1}function c(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=s,e.coerce=c,e.disable=n,e.enable=i,e.enabled=a,e.humanize=r(27),e.names=[],e.skips=[],e.formatters={};var u,p=0},function(t,e){function r(t){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),o=(e[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*u;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}function o(t){return t>=u?Math.round(t/u)+"d":t>=c?Math.round(t/c)+"h":t>=a?Math.round(t/a)+"m":t>=n?Math.round(t/n)+"s":t+"ms"}function s(t){return i(t,u,"day")||i(t,c,"hour")||i(t,a,"minute")||i(t,n,"second")||t+" ms"}function i(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var n=1e3,a=60*n,c=60*a,u=24*c,p=365.25*u;t.exports=function(t,e){return e=e||{},"string"==typeof t?r(t):e["long"]?s(t):o(t)}},function(t,e,r){function o(){}function s(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function i(t){return t===Object(t)}function n(t){if(!i(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function a(t){for(var e,r,o={},s=t.split("&"),i=0,n=s.length;n>i;++i)r=s[i],e=r.split("="),o[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return o}function c(t){var e,r,o,s,i=t.split(/\r?\n/),n={};i.pop();for(var a=0,c=i.length;c>a;++a)r=i[a],e=r.indexOf(":"),o=r.slice(0,e).toLowerCase(),s=g(r.slice(e+1)),n[o]=s;return n}function u(t){return t.split(/ *; */).shift()}function p(t){return m(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),o=r.shift(),s=r.shift();return o&&s&&(t[o]=s),t},{})}function l(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=c(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function h(t,e){var r=this;f.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t=null,e=null;try{e=new l(r)}catch(o){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=o,r.callback(t)}if(r.emit("response",e),t)return r.callback(t,e);if(e.status>=200&&e.status<300)return r.callback(t,e);var s=new Error(e.statusText||"Unsuccessful HTTP response"); +s.original=t,s.response=e,s.status=e.status,r.callback(t||s,e)})}function d(t,e){return"function"==typeof e?new h("GET",t).end(e):1==arguments.length?new h("GET",t):new h(t,e)}var f=r(29),m=r(30),y="undefined"==typeof window?this||self:window;d.getXHR=function(){if(!(!y.XMLHttpRequest||y.location&&"file:"==y.location.protocol&&y.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1};var g="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};d.serializeObject=n,d.parseString=a,d.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},d.serialize={"application/x-www-form-urlencoded":n,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":a,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype.setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=u(e);var r=p(e);for(var o in r)this[o]=r[o]},l.prototype.parseBody=function(t){var e=d.parse[this.type];return e&&t&&(t.length||t instanceof Object)?e(t):null},l.prototype.setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,o="cannot "+e+" "+r+" ("+this.status+")",s=new Error(o);return s.status=this.status,s.method=e,s.url=r,s},d.Response=l,f(h.prototype),h.prototype.use=function(t){return t(this),this},h.prototype.timeout=function(t){return this._timeout=t,this},h.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},h.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},h.prototype.set=function(t,e){if(i(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},h.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},h.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},h.prototype.type=function(t){return this.set("Content-Type",d.types[t]||t),this},h.prototype.accept=function(t){return this.set("Accept",d.types[t]||t),this},h.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},h.prototype.query=function(t){return"string"!=typeof t&&(t=n(t)),t&&this._query.push(t),this},h.prototype.field=function(t,e){return this._formData||(this._formData=new y.FormData),this._formData.append(t,e),this},h.prototype.attach=function(t,e,r){return this._formData||(this._formData=new y.FormData),this._formData.append(t,e,r),this},h.prototype.send=function(t){var e=i(t),r=this.getHeader("Content-Type");if(e&&i(this._data))for(var o in t)this._data[o]=t[o];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||s(t)?this:(r||this.type("json"),this)},h.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},h.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},h.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},h.prototype.withCredentials=function(){return this._withCredentials=!0,this},h.prototype.end=function(t){var e=this,r=this.xhr=d.getXHR(),i=this._query.join("&"),n=this._timeout,a=this._formData||this._data;this._callback=t||o,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(o){t=0}if(0==t){if(e.timedout)return e.timeoutError();if(e.aborted)return;return e.crossDomainError()}e.emit("end")}};var c=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=c);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=c)}catch(u){}if(n&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},n)),i&&(i=d.serializeObject(i),this.url+=~this.url.indexOf("?")?"&"+i:"?"+i),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!s(a)){var p=d.serialize[this.getHeader("Content-Type")];p&&(a=p(a))}for(var l in this.header)null!=this.header[l]&&r.setRequestHeader(l,this.header[l]);return this.emit("request",this),r.send(a),this},d.Request=h,d.get=function(t,e,r){var o=d("GET",t);return"function"==typeof e&&(r=e,e=null),e&&o.query(e),r&&o.end(r),o},d.head=function(t,e,r){var o=d("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},d.del=function(t,e){var r=d("DELETE",t);return e&&r.end(e),r},d.patch=function(t,e,r){var o=d("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},d.post=function(t,e,r){var o=d("POST",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},d.put=function(t,e,r){var o=d("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},t.exports=d},function(t,e){function r(t){return t?o(t):void 0}function o(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){function r(){o.off(t,r),e.apply(this,arguments)}var o=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var o,s=0;so;++o)r[o].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=function(t,e,r){for(var o=0,s=t.length,i=3==arguments.length?r:t[o++];s>o;)i=e.call(null,i,t[o],++o,t);return i}}]); +//# sourceMappingURL=wpcom.js.map \ No newline at end of file diff --git a/dist/wpcom.js.map b/dist/wpcom.js.map index af575c1..98b7a3c 100644 --- a/dist/wpcom.js.map +++ b/dist/wpcom.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///wpcom.js","webpack:///webpack/bootstrap b05cd61689205a643f6c","webpack:///./index.js","webpack:///./~/debug/browser.js","webpack:///./lib/comment.js","webpack:///./lib/util/send-request.js","webpack:///./~/qs/lib/utils.js","webpack:///./lib/batch.js","webpack:///./lib/category.js","webpack:///./lib/commentlike.js","webpack:///./lib/follow.js","webpack:///./lib/like.js","webpack:///./lib/me.js","webpack:///./lib/media.js","webpack:///./lib/post.js","webpack:///./lib/reblog.js","webpack:///./lib/site.js","webpack:///./lib/tag.js","webpack:///./lib/users.js","webpack:///./lib/util/request.js","webpack:///./~/debug/debug.js","webpack:///./~/debug/~/ms/index.js","webpack:///./~/fs/index.js","webpack:///./~/qs/lib/index.js","webpack:///./~/qs/lib/parse.js","webpack:///./~/qs/lib/stringify.js","webpack:///./~/wpcom-xhr-request/index.js","webpack:///./~/wpcom-xhr-request/~/debug/browser.js","webpack:///./~/wpcom-xhr-request/~/debug/debug.js","webpack:///./~/wpcom-xhr-request/~/debug/~/ms/index.js","webpack:///./~/wpcom-xhr-request/~/superagent/lib/client.js","webpack:///./~/wpcom-xhr-request/~/superagent/~/component-emitter/index.js","webpack:///./~/wpcom-xhr-request/~/superagent/~/reduce-component/index.js"],"names":["WPCOM","modules","__webpack_require__","moduleId","installedModules","exports","module","id","loaded","call","m","c","p","token","reqHandler","this","debug","substring","request","params","fn","authToken","request_handler","req","Req","apiVersion","Me","Site","Users","Batch","sendRequest","DEFAULT_ASYNC_TIMEOUT","prototype","me","site","users","batch","freshlyPressed","query","get","body","msg","console","warn","log","Promise","timeout","_this","delay","arguments","length","undefined","cancelTimeout","timer","resolve","reject","setTimeout","Error","clearTimeout","race","then","useColors","document","documentElement","style","window","firebug","exception","table","navigator","userAgent","toLowerCase","match","parseInt","RegExp","$1","formatArgs","args","namespace","humanize","diff","color","concat","Array","slice","index","lastC","replace","splice","Function","apply","save","namespaces","storage","removeItem","e","load","r","localstorage","localStorage","chrome","local","colors","formatters","j","v","JSON","stringify","enable","Comment","cid","pid","sid","wpcom","_cid","_pid","_sid","CommentLike","path","replies","add","content","post","update","put","reply","del","like","likesList","qs","debug_res","method","toUpperCase","proxyOrigin","arrayFormat","err","res","internals","hexTable","h","toString","arrayToObject","source","options","obj","plainObjects","Object","create","i","il","merge","target","isArray","push","keys","k","kl","key","value","hasOwnProperty","decode","str","decodeURIComponent","encode","out","charCodeAt","compact","refs","lookup","indexOf","compacted","isRegExp","isBuffer","constructor","urls","url","run","Category","slug","_slug","mine","state","Follow","site_id","follow","unfollow","Like","sites","likes","groups","Media","_id","fs","addFiles","files","formData","f","isStream","isFile","param","createReadStream","_readableState","File","file","addUrls","media","media_urls","attrs","Post","Reblog","getBySlug","data","ID","restore","related","reblog","comment","comments","destination_site_id","to","dest","note","encodeURIComponent","list","subpath","listMethod","_publicAPI","Tag","resources","isarr","name","addPost","deletePost","addMediaFiles","addMediaUrls","deleteMedia","cat","category","tag","renderShortcode","TypeError","shortcode","renderEmbed","embed_url","statsReferrersSpamNew","domain","statsReferrersSpamDelete","statsVideo","videoId","statsPostViews","postId","suggest","selectColor","prevColor","disabled","enabled","self","curr","Date","ms","prevTime","prev","coerce","format","formatter","val","logFn","bind","split","len","skips","substr","names","disable","test","stack","message","parse","exec","n","parseFloat","type","y","d","s","short","Math","round","long","plural","floor","ceil","Stringify","Parse","Utils","delimiter","depth","arrayLimit","parameterLimit","strictNullHandling","allowPrototypes","parseValues","parts","Infinity","part","pos","parseObject","chain","root","shift","cleanRoot","indexString","isNaN","parseArrays","parseKeys","allowDots","parent","child","segment","tempObj","newObj","arrayPrefixGenerators","brackets","prefix","indices","repeat","generateArrayPrefix","filter","toISOString","values","objKeys","join","defaultApiVersion","superagent","set","send","field","end","headers","statusCode","status","_headers","error","toTitle","xhr","noop","isHost","isObject","serialize","pairs","parseString","pair","parseHeader","line","lines","fields","pop","trim","reduce","Response","text","responseType","responseText","statusText","setStatusProperties","header","getAllResponseHeaders","getResponseHeader","setHeaderProperties","parseBody","response","Request","Emitter","_query","_header","on","original","callback","emit","new_err","getXHR","XMLHttpRequest","location","protocol","ActiveXObject","serializeObject","types","html","json","xml","urlencoded","form","form-data","application/x-www-form-urlencoded","application/json","ct","statusType","info","ok","clientError","serverError","toError","accepted","noContent","badRequest","unauthorized","notAcceptable","notFound","forbidden","use","_timeout","_timer","abort","aborted","unset","getHeader","accept","auth","user","pass","btoa","_formData","FormData","append","attach","filename","_data","_callback","crossDomainError","crossDomain","timeoutError","withCredentials","_withCredentials","onreadystatechange","readyState","timedout","handleProgress","total","percent","hasListeners","onprogress","upload","open","setRequestHeader","head","patch","mixin","addEventListener","event","_callbacks","once","off","removeListener","removeAllListeners","removeEventListener","callbacks","cb","listeners","arr","initial","idx"],"mappings":"AAAA,GAAIA,OACK,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAE,WACAE,GAAAJ,EACAK,QAAA,EAUA,OANAP,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,QAAA,EAGAF,EAAAD,QAvBA,GAAAD,KAqCA,OATAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,GAGAV,EAAA,KDO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AAAO,EAAA,CACAA,IAAAnX,MAAA,EACA,QAAAgE,GAAA,EAAAyH,EAAA0L,EAAArZ,OAA2C2N,EAAAzH,IAASA,EACpDmT,EAAAnT,GAAA1D,MAAA3E,KAAA8D,GAIA,MAAA9D,OAWAqW,EAAApV,UAAAya,UAAA,SAAAT,GAEA,MADAjb,MAAAkb,WAAAlb,KAAAkb,eACAlb,KAAAkb,WAAAD,QAWA5E,EAAApV,UAAAuZ,aAAA,SAAAS,GACA,QAAAjb,KAAA0b,UAAAT,GAAA9Y,S/Bo0JM,SAAS5C,EAAQD,GgC39JvBC,EAAAD,QAAA,SAAAqc,EAAAtb,EAAAub,GAOA,IANA,GAAAC,GAAA,EACA/L,EAAA6L,EAAAxZ,OACA+M,EAAA,GAAAhN,UAAAC,OACAyZ,EACAD,EAAAE,KAEA/L,EAAA+L,GACA3M,EAAA7O,EAAAX,KAAA,KAAAwP,EAAAyM,EAAAE,OAAAF,EAGA,OAAAzM","file":"wpcom.js","sourcesContent":["var WPCOM =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar request_handler = __webpack_require__(24);\n\t\n\t/**\n\t * Local module dependencies.\n\t */\n\t\n\tvar Me = __webpack_require__(10);\n\tvar Site = __webpack_require__(14);\n\tvar Users = __webpack_require__(16);\n\tvar Batch = __webpack_require__(5);\n\tvar Req = __webpack_require__(17);\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom');\n\t\n\t/**\n\t * Local module constants\n\t */\n\tvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\t\n\t/**\n\t * XMLHttpRequest (and CORS) API access method.\n\t *\n\t * API authentication is done via an (optional) access `token`,\n\t * which needs to be retrieved via OAuth.\n\t *\n\t * Request Handler is optional and XHR is defined as default.\n\t *\n\t * @param {String} [token] - OAuth API access token\n\t * @param {Function} [reqHandler] - function Request Handler\n\t * @public\n\t */\n\t\n\tfunction WPCOM(token, reqHandler) {\n\t if (!(this instanceof WPCOM)) {\n\t return new WPCOM(token, reqHandler);\n\t }\n\t\n\t // `token` is optional\n\t if ('function' === typeof token) {\n\t reqHandler = token;\n\t token = null;\n\t }\n\t\n\t if (token) {\n\t debug('Token defined: %s…', token.substring(0, 6));\n\t this.token = token;\n\t }\n\t\n\t // Set default request handler\n\t if (!reqHandler) {\n\t debug('No request handler. Adding default XHR request handler');\n\t\n\t this.request = function (params, fn) {\n\t params = params || {};\n\t\n\t // token is optional\n\t if (token) {\n\t params.authToken = token;\n\t }\n\t\n\t return request_handler(params, fn);\n\t };\n\t } else {\n\t this.request = reqHandler;\n\t }\n\t\n\t // Add Req instance\n\t this.req = new Req(this);\n\t\n\t // Default api version;\n\t this.apiVersion = '1.1';\n\t}\n\t\n\t/**\n\t * Get `Me` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.me = function () {\n\t return new Me(this);\n\t};\n\t\n\t/**\n\t * Get `Site` object instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.site = function (id) {\n\t return new Site(id, this);\n\t};\n\t\n\t/**\n\t * Get `Users` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.users = function () {\n\t return new Users(this);\n\t};\n\t\n\tWPCOM.prototype.batch = function () {\n\t return new Batch(this);\n\t};\n\t\n\t/**\n\t * List Freshly Pressed Posts\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn callback function\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.freshlyPressed = function (query, fn) {\n\t return this.req.get('/freshly-pressed', query, fn);\n\t};\n\t\n\t/**\n\t * Expose send-request\n\t * @TODO: use `this.req` instead of this method\n\t */\n\t\n\tWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n\t var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n\t if (console && console.warn) {\n\t //eslint-disable-line no-console\n\t console.warn(msg); //eslint-disable-line no-console\n\t } else {\n\t console.log(msg); //eslint-disable-line no-console\n\t }\n\t\n\t return sendRequest.call(this, params, query, body, fn);\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the web browser implementation of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = __webpack_require__(18);\n\texports.log = log;\n\texports.formatArgs = formatArgs;\n\texports.save = save;\n\texports.load = load;\n\texports.useColors = useColors;\n\texports.storage = 'undefined' != typeof chrome\n\t && 'undefined' != typeof chrome.storage\n\t ? chrome.storage.local\n\t : localstorage();\n\t\n\t/**\n\t * Colors.\n\t */\n\t\n\texports.colors = [\n\t 'lightseagreen',\n\t 'forestgreen',\n\t 'goldenrod',\n\t 'dodgerblue',\n\t 'darkorchid',\n\t 'crimson'\n\t];\n\t\n\t/**\n\t * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n\t * and the Firebug extension (any Firefox version) are known\n\t * to support \"%c\" CSS customizations.\n\t *\n\t * TODO: add a `localStorage` variable to explicitly enable/disable colors\n\t */\n\t\n\tfunction useColors() {\n\t // is webkit? http://stackoverflow.com/a/16459606/376773\n\t return ('WebkitAppearance' in document.documentElement.style) ||\n\t // is firebug? http://stackoverflow.com/a/398120/376773\n\t (window.console && (console.firebug || (console.exception && console.table))) ||\n\t // is firefox >= v31?\n\t // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n\t}\n\t\n\t/**\n\t * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n\t */\n\t\n\texports.formatters.j = function(v) {\n\t return JSON.stringify(v);\n\t};\n\t\n\t\n\t/**\n\t * Colorize log arguments if enabled.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction formatArgs() {\n\t var args = arguments;\n\t var useColors = this.useColors;\n\t\n\t args[0] = (useColors ? '%c' : '')\n\t + this.namespace\n\t + (useColors ? ' %c' : ' ')\n\t + args[0]\n\t + (useColors ? '%c ' : ' ')\n\t + '+' + exports.humanize(this.diff);\n\t\n\t if (!useColors) return args;\n\t\n\t var c = 'color: ' + this.color;\n\t args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\t\n\t // the final \"%c\" is somewhat tricky, because there could be other\n\t // arguments passed either before or after the %c, so we need to\n\t // figure out the correct index to insert the CSS into\n\t var index = 0;\n\t var lastC = 0;\n\t args[0].replace(/%[a-z%]/g, function(match) {\n\t if ('%%' === match) return;\n\t index++;\n\t if ('%c' === match) {\n\t // we only are interested in the *last* %c\n\t // (the user may have provided their own)\n\t lastC = index;\n\t }\n\t });\n\t\n\t args.splice(lastC, 0, c);\n\t return args;\n\t}\n\t\n\t/**\n\t * Invokes `console.log()` when available.\n\t * No-op when `console.log` is not a \"function\".\n\t *\n\t * @api public\n\t */\n\t\n\tfunction log() {\n\t // this hackery is required for IE8/9, where\n\t // the `console.log` function doesn't have 'apply'\n\t return 'object' === typeof console\n\t && console.log\n\t && Function.prototype.apply.call(console.log, console, arguments);\n\t}\n\t\n\t/**\n\t * Save `namespaces`.\n\t *\n\t * @param {String} namespaces\n\t * @api private\n\t */\n\t\n\tfunction save(namespaces) {\n\t try {\n\t if (null == namespaces) {\n\t exports.storage.removeItem('debug');\n\t } else {\n\t exports.storage.debug = namespaces;\n\t }\n\t } catch(e) {}\n\t}\n\t\n\t/**\n\t * Load `namespaces`.\n\t *\n\t * @return {String} returns the previously persisted debug modes\n\t * @api private\n\t */\n\t\n\tfunction load() {\n\t var r;\n\t try {\n\t r = exports.storage.debug;\n\t } catch(e) {}\n\t return r;\n\t}\n\t\n\t/**\n\t * Enable namespaces listed in `localStorage.debug` initially.\n\t */\n\t\n\texports.enable(load());\n\t\n\t/**\n\t * Localstorage attempts to return the localstorage.\n\t *\n\t * This is necessary because safari throws\n\t * when a user disables cookies/localstorage\n\t * and you attempt to access it.\n\t *\n\t * @return {LocalStorage}\n\t * @api private\n\t */\n\t\n\tfunction localstorage(){\n\t try {\n\t return window.localStorage;\n\t } catch (e) {}\n\t}\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(7);\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(21);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t// Load modules\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {};\n\tinternals.hexTable = new Array(256);\n\tfor (var h = 0; h < 256; ++h) {\n\t internals.hexTable[h] = '%' + ((h < 16 ? '0' : '') + h.toString(16)).toUpperCase();\n\t}\n\t\n\t\n\texports.arrayToObject = function (source, options) {\n\t\n\t var obj = options.plainObjects ? Object.create(null) : {};\n\t for (var i = 0, il = source.length; i < il; ++i) {\n\t if (typeof source[i] !== 'undefined') {\n\t\n\t obj[i] = source[i];\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\texports.merge = function (target, source, options) {\n\t\n\t if (!source) {\n\t return target;\n\t }\n\t\n\t if (typeof source !== 'object') {\n\t if (Array.isArray(target)) {\n\t target.push(source);\n\t }\n\t else if (typeof target === 'object') {\n\t target[source] = true;\n\t }\n\t else {\n\t target = [target, source];\n\t }\n\t\n\t return target;\n\t }\n\t\n\t if (typeof target !== 'object') {\n\t target = [target].concat(source);\n\t return target;\n\t }\n\t\n\t if (Array.isArray(target) &&\n\t !Array.isArray(source)) {\n\t\n\t target = exports.arrayToObject(target, options);\n\t }\n\t\n\t var keys = Object.keys(source);\n\t for (var k = 0, kl = keys.length; k < kl; ++k) {\n\t var key = keys[k];\n\t var value = source[key];\n\t\n\t if (!Object.prototype.hasOwnProperty.call(target, key)) {\n\t target[key] = value;\n\t }\n\t else {\n\t target[key] = exports.merge(target[key], value, options);\n\t }\n\t }\n\t\n\t return target;\n\t};\n\t\n\t\n\texports.decode = function (str) {\n\t\n\t try {\n\t return decodeURIComponent(str.replace(/\\+/g, ' '));\n\t } catch (e) {\n\t return str;\n\t }\n\t};\n\t\n\texports.encode = function (str) {\n\t\n\t // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n\t // It has been adapted here for stricter adherence to RFC 3986\n\t if (str.length === 0) {\n\t return str;\n\t }\n\t\n\t if (typeof str !== 'string') {\n\t str = '' + str;\n\t }\n\t\n\t var out = '';\n\t for (var i = 0, il = str.length; i < il; ++i) {\n\t var c = str.charCodeAt(i);\n\t\n\t if (c === 0x2D || // -\n\t c === 0x2E || // .\n\t c === 0x5F || // _\n\t c === 0x7E || // ~\n\t (c >= 0x30 && c <= 0x39) || // 0-9\n\t (c >= 0x41 && c <= 0x5A) || // a-z\n\t (c >= 0x61 && c <= 0x7A)) { // A-Z\n\t\n\t out += str[i];\n\t continue;\n\t }\n\t\n\t if (c < 0x80) {\n\t out += internals.hexTable[c];\n\t continue;\n\t }\n\t\n\t if (c < 0x800) {\n\t out += internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)];\n\t continue;\n\t }\n\t\n\t if (c < 0xD800 || c >= 0xE000) {\n\t out += internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n\t continue;\n\t }\n\t\n\t ++i;\n\t c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF));\n\t out += internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n\t }\n\t\n\t return out;\n\t};\n\t\n\texports.compact = function (obj, refs) {\n\t\n\t if (typeof obj !== 'object' ||\n\t obj === null) {\n\t\n\t return obj;\n\t }\n\t\n\t refs = refs || [];\n\t var lookup = refs.indexOf(obj);\n\t if (lookup !== -1) {\n\t return refs[lookup];\n\t }\n\t\n\t refs.push(obj);\n\t\n\t if (Array.isArray(obj)) {\n\t var compacted = [];\n\t\n\t for (var i = 0, il = obj.length; i < il; ++i) {\n\t if (typeof obj[i] !== 'undefined') {\n\t compacted.push(obj[i]);\n\t }\n\t }\n\t\n\t return compacted;\n\t }\n\t\n\t var keys = Object.keys(obj);\n\t for (i = 0, il = keys.length; i < il; ++i) {\n\t var key = keys[i];\n\t obj[key] = exports.compact(obj[key], refs);\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\texports.isRegExp = function (obj) {\n\t\n\t return Object.prototype.toString.call(obj) === '[object RegExp]';\n\t};\n\t\n\t\n\texports.isBuffer = function (obj) {\n\t\n\t if (obj === null ||\n\t typeof obj === 'undefined') {\n\t\n\t return false;\n\t }\n\t\n\t return !!(obj.constructor &&\n\t obj.constructor.isBuffer &&\n\t obj.constructor.isBuffer(obj));\n\t};\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports) {\n\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Follow\n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current\n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(20);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m.url;\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(9);\n\tvar Reblog = __webpack_require__(13);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(err);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(12);\n\tvar Category = __webpack_require__(6);\n\tvar Tag = __webpack_require__(15);\n\tvar Media = __webpack_require__(11);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(8);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 18 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the common logic for both the Node.js and web browser\n\t * implementations of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = debug;\n\texports.coerce = coerce;\n\texports.disable = disable;\n\texports.enable = enable;\n\texports.enabled = enabled;\n\texports.humanize = __webpack_require__(19);\n\t\n\t/**\n\t * The currently active debug mode names, and names to skip.\n\t */\n\t\n\texports.names = [];\n\texports.skips = [];\n\t\n\t/**\n\t * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t *\n\t * Valid key names are a single, lowercased letter, i.e. \"n\".\n\t */\n\t\n\texports.formatters = {};\n\t\n\t/**\n\t * Previously assigned color.\n\t */\n\t\n\tvar prevColor = 0;\n\t\n\t/**\n\t * Previous log timestamp.\n\t */\n\t\n\tvar prevTime;\n\t\n\t/**\n\t * Select a color.\n\t *\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction selectColor() {\n\t return exports.colors[prevColor++ % exports.colors.length];\n\t}\n\t\n\t/**\n\t * Create a debugger with the given `namespace`.\n\t *\n\t * @param {String} namespace\n\t * @return {Function}\n\t * @api public\n\t */\n\t\n\tfunction debug(namespace) {\n\t\n\t // define the `disabled` version\n\t function disabled() {\n\t }\n\t disabled.enabled = false;\n\t\n\t // define the `enabled` version\n\t function enabled() {\n\t\n\t var self = enabled;\n\t\n\t // set `diff` timestamp\n\t var curr = +new Date();\n\t var ms = curr - (prevTime || curr);\n\t self.diff = ms;\n\t self.prev = prevTime;\n\t self.curr = curr;\n\t prevTime = curr;\n\t\n\t // add the `color` if not set\n\t if (null == self.useColors) self.useColors = exports.useColors();\n\t if (null == self.color && self.useColors) self.color = selectColor();\n\t\n\t var args = Array.prototype.slice.call(arguments);\n\t\n\t args[0] = exports.coerce(args[0]);\n\t\n\t if ('string' !== typeof args[0]) {\n\t // anything else let's inspect with %o\n\t args = ['%o'].concat(args);\n\t }\n\t\n\t // apply any `formatters` transformations\n\t var index = 0;\n\t args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n\t // if we encounter an escaped % then don't increase the array index\n\t if (match === '%%') return match;\n\t index++;\n\t var formatter = exports.formatters[format];\n\t if ('function' === typeof formatter) {\n\t var val = args[index];\n\t match = formatter.call(self, val);\n\t\n\t // now we need to remove `args[index]` since it's inlined in the `format`\n\t args.splice(index, 1);\n\t index--;\n\t }\n\t return match;\n\t });\n\t\n\t if ('function' === typeof exports.formatArgs) {\n\t args = exports.formatArgs.apply(self, args);\n\t }\n\t var logFn = enabled.log || exports.log || console.log.bind(console);\n\t logFn.apply(self, args);\n\t }\n\t enabled.enabled = true;\n\t\n\t var fn = exports.enabled(namespace) ? enabled : disabled;\n\t\n\t fn.namespace = namespace;\n\t\n\t return fn;\n\t}\n\t\n\t/**\n\t * Enables a debug mode by namespaces. This can include modes\n\t * separated by a colon and wildcards.\n\t *\n\t * @param {String} namespaces\n\t * @api public\n\t */\n\t\n\tfunction enable(namespaces) {\n\t exports.save(namespaces);\n\t\n\t var split = (namespaces || '').split(/[\\s,]+/);\n\t var len = split.length;\n\t\n\t for (var i = 0; i < len; i++) {\n\t if (!split[i]) continue; // ignore empty strings\n\t namespaces = split[i].replace(/\\*/g, '.*?');\n\t if (namespaces[0] === '-') {\n\t exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t } else {\n\t exports.names.push(new RegExp('^' + namespaces + '$'));\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Disable debug output.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction disable() {\n\t exports.enable('');\n\t}\n\t\n\t/**\n\t * Returns true if the given mode name is enabled, false otherwise.\n\t *\n\t * @param {String} name\n\t * @return {Boolean}\n\t * @api public\n\t */\n\t\n\tfunction enabled(name) {\n\t var i, len;\n\t for (i = 0, len = exports.skips.length; i < len; i++) {\n\t if (exports.skips[i].test(name)) {\n\t return false;\n\t }\n\t }\n\t for (i = 0, len = exports.names.length; i < len; i++) {\n\t if (exports.names[i].test(name)) {\n\t return true;\n\t }\n\t }\n\t return false;\n\t}\n\t\n\t/**\n\t * Coerce `val`.\n\t *\n\t * @param {Mixed} val\n\t * @return {Mixed}\n\t * @api private\n\t */\n\t\n\tfunction coerce(val) {\n\t if (val instanceof Error) return val.stack || val.message;\n\t return val;\n\t}\n\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Helpers.\n\t */\n\t\n\tvar s = 1000;\n\tvar m = s * 60;\n\tvar h = m * 60;\n\tvar d = h * 24;\n\tvar y = d * 365.25;\n\t\n\t/**\n\t * Parse or format the given `val`.\n\t *\n\t * Options:\n\t *\n\t * - `long` verbose formatting [false]\n\t *\n\t * @param {String|Number} val\n\t * @param {Object} options\n\t * @return {String|Number}\n\t * @api public\n\t */\n\t\n\tmodule.exports = function(val, options){\n\t options = options || {};\n\t if ('string' == typeof val) return parse(val);\n\t return options.long\n\t ? long(val)\n\t : short(val);\n\t};\n\t\n\t/**\n\t * Parse the given `str` and return milliseconds.\n\t *\n\t * @param {String} str\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction parse(str) {\n\t str = '' + str;\n\t if (str.length > 10000) return;\n\t var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n\t if (!match) return;\n\t var n = parseFloat(match[1]);\n\t var type = (match[2] || 'ms').toLowerCase();\n\t switch (type) {\n\t case 'years':\n\t case 'year':\n\t case 'yrs':\n\t case 'yr':\n\t case 'y':\n\t return n * y;\n\t case 'days':\n\t case 'day':\n\t case 'd':\n\t return n * d;\n\t case 'hours':\n\t case 'hour':\n\t case 'hrs':\n\t case 'hr':\n\t case 'h':\n\t return n * h;\n\t case 'minutes':\n\t case 'minute':\n\t case 'mins':\n\t case 'min':\n\t case 'm':\n\t return n * m;\n\t case 'seconds':\n\t case 'second':\n\t case 'secs':\n\t case 'sec':\n\t case 's':\n\t return n * s;\n\t case 'milliseconds':\n\t case 'millisecond':\n\t case 'msecs':\n\t case 'msec':\n\t case 'ms':\n\t return n;\n\t }\n\t}\n\t\n\t/**\n\t * Short format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction short(ms) {\n\t if (ms >= d) return Math.round(ms / d) + 'd';\n\t if (ms >= h) return Math.round(ms / h) + 'h';\n\t if (ms >= m) return Math.round(ms / m) + 'm';\n\t if (ms >= s) return Math.round(ms / s) + 's';\n\t return ms + 'ms';\n\t}\n\t\n\t/**\n\t * Long format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction long(ms) {\n\t return plural(ms, d, 'day')\n\t || plural(ms, h, 'hour')\n\t || plural(ms, m, 'minute')\n\t || plural(ms, s, 'second')\n\t || ms + ' ms';\n\t}\n\t\n\t/**\n\t * Pluralization helper.\n\t */\n\t\n\tfunction plural(ms, n, name) {\n\t if (ms < n) return;\n\t if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n\t return Math.ceil(ms / n) + ' ' + name + 's';\n\t}\n\n\n/***/ },\n/* 20 */\n/***/ function(module, exports) {\n\n\tconsole.log(\"I'm `fs` modules\");\n\n\n/***/ },\n/* 21 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Load modules\n\t\n\tvar Stringify = __webpack_require__(23);\n\tvar Parse = __webpack_require__(22);\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {};\n\t\n\t\n\tmodule.exports = {\n\t stringify: Stringify,\n\t parse: Parse\n\t};\n\n\n/***/ },\n/* 22 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Load modules\n\t\n\tvar Utils = __webpack_require__(4);\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {\n\t delimiter: '&',\n\t depth: 5,\n\t arrayLimit: 20,\n\t parameterLimit: 1000,\n\t strictNullHandling: false,\n\t plainObjects: false,\n\t allowPrototypes: false\n\t};\n\t\n\t\n\tinternals.parseValues = function (str, options) {\n\t\n\t var obj = {};\n\t var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);\n\t\n\t for (var i = 0, il = parts.length; i < il; ++i) {\n\t var part = parts[i];\n\t var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;\n\t\n\t if (pos === -1) {\n\t obj[Utils.decode(part)] = '';\n\t\n\t if (options.strictNullHandling) {\n\t obj[Utils.decode(part)] = null;\n\t }\n\t }\n\t else {\n\t var key = Utils.decode(part.slice(0, pos));\n\t var val = Utils.decode(part.slice(pos + 1));\n\t\n\t if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n\t obj[key] = val;\n\t }\n\t else {\n\t obj[key] = [].concat(obj[key]).concat(val);\n\t }\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\tinternals.parseObject = function (chain, val, options) {\n\t\n\t if (!chain.length) {\n\t return val;\n\t }\n\t\n\t var root = chain.shift();\n\t\n\t var obj;\n\t if (root === '[]') {\n\t obj = [];\n\t obj = obj.concat(internals.parseObject(chain, val, options));\n\t }\n\t else {\n\t obj = options.plainObjects ? Object.create(null) : {};\n\t var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;\n\t var index = parseInt(cleanRoot, 10);\n\t var indexString = '' + index;\n\t if (!isNaN(index) &&\n\t root !== cleanRoot &&\n\t indexString === cleanRoot &&\n\t index >= 0 &&\n\t (options.parseArrays &&\n\t index <= options.arrayLimit)) {\n\t\n\t obj = [];\n\t obj[index] = internals.parseObject(chain, val, options);\n\t }\n\t else {\n\t obj[cleanRoot] = internals.parseObject(chain, val, options);\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\tinternals.parseKeys = function (key, val, options) {\n\t\n\t if (!key) {\n\t return;\n\t }\n\t\n\t // Transform dot notation to bracket notation\n\t\n\t if (options.allowDots) {\n\t key = key.replace(/\\.([^\\.\\[]+)/g, '[$1]');\n\t }\n\t\n\t // The regex chunks\n\t\n\t var parent = /^([^\\[\\]]*)/;\n\t var child = /(\\[[^\\[\\]]*\\])/g;\n\t\n\t // Get the parent\n\t\n\t var segment = parent.exec(key);\n\t\n\t // Stash the parent if it exists\n\t\n\t var keys = [];\n\t if (segment[1]) {\n\t // If we aren't using plain objects, optionally prefix keys\n\t // that would overwrite object prototype properties\n\t if (!options.plainObjects &&\n\t Object.prototype.hasOwnProperty(segment[1])) {\n\t\n\t if (!options.allowPrototypes) {\n\t return;\n\t }\n\t }\n\t\n\t keys.push(segment[1]);\n\t }\n\t\n\t // Loop through children appending to the array until we hit depth\n\t\n\t var i = 0;\n\t while ((segment = child.exec(key)) !== null && i < options.depth) {\n\t\n\t ++i;\n\t if (!options.plainObjects &&\n\t Object.prototype.hasOwnProperty(segment[1].replace(/\\[|\\]/g, ''))) {\n\t\n\t if (!options.allowPrototypes) {\n\t continue;\n\t }\n\t }\n\t keys.push(segment[1]);\n\t }\n\t\n\t // If there's a remainder, just add whatever is left\n\t\n\t if (segment) {\n\t keys.push('[' + key.slice(segment.index) + ']');\n\t }\n\t\n\t return internals.parseObject(keys, val, options);\n\t};\n\t\n\t\n\tmodule.exports = function (str, options) {\n\t\n\t options = options || {};\n\t options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;\n\t options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;\n\t options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;\n\t options.parseArrays = options.parseArrays !== false;\n\t options.allowDots = options.allowDots !== false;\n\t options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects;\n\t options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes;\n\t options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;\n\t options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n\t\n\t if (str === '' ||\n\t str === null ||\n\t typeof str === 'undefined') {\n\t\n\t return options.plainObjects ? Object.create(null) : {};\n\t }\n\t\n\t var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;\n\t var obj = options.plainObjects ? Object.create(null) : {};\n\t\n\t // Iterate over the keys and setup the new object\n\t\n\t var keys = Object.keys(tempObj);\n\t for (var i = 0, il = keys.length; i < il; ++i) {\n\t var key = keys[i];\n\t var newObj = internals.parseKeys(key, tempObj[key], options);\n\t obj = Utils.merge(obj, newObj, options);\n\t }\n\t\n\t return Utils.compact(obj);\n\t};\n\n\n/***/ },\n/* 23 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Load modules\n\t\n\tvar Utils = __webpack_require__(4);\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {\n\t delimiter: '&',\n\t arrayPrefixGenerators: {\n\t brackets: function (prefix, key) {\n\t\n\t return prefix + '[]';\n\t },\n\t indices: function (prefix, key) {\n\t\n\t return prefix + '[' + key + ']';\n\t },\n\t repeat: function (prefix, key) {\n\t\n\t return prefix;\n\t }\n\t },\n\t strictNullHandling: false\n\t};\n\t\n\t\n\tinternals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) {\n\t\n\t if (typeof filter === 'function') {\n\t obj = filter(prefix, obj);\n\t }\n\t else if (Utils.isBuffer(obj)) {\n\t obj = obj.toString();\n\t }\n\t else if (obj instanceof Date) {\n\t obj = obj.toISOString();\n\t }\n\t else if (obj === null) {\n\t if (strictNullHandling) {\n\t return Utils.encode(prefix);\n\t }\n\t\n\t obj = '';\n\t }\n\t\n\t if (typeof obj === 'string' ||\n\t typeof obj === 'number' ||\n\t typeof obj === 'boolean') {\n\t\n\t return [Utils.encode(prefix) + '=' + Utils.encode(obj)];\n\t }\n\t\n\t var values = [];\n\t\n\t if (typeof obj === 'undefined') {\n\t return values;\n\t }\n\t\n\t var objKeys = Array.isArray(filter) ? filter : Object.keys(obj);\n\t for (var i = 0, il = objKeys.length; i < il; ++i) {\n\t var key = objKeys[i];\n\t\n\t if (Array.isArray(obj)) {\n\t values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter));\n\t }\n\t else {\n\t values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter));\n\t }\n\t }\n\t\n\t return values;\n\t};\n\t\n\t\n\tmodule.exports = function (obj, options) {\n\t\n\t options = options || {};\n\t var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;\n\t var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n\t var objKeys;\n\t var filter;\n\t if (typeof options.filter === 'function') {\n\t filter = options.filter;\n\t obj = filter('', obj);\n\t }\n\t else if (Array.isArray(options.filter)) {\n\t objKeys = filter = options.filter;\n\t }\n\t\n\t var keys = [];\n\t\n\t if (typeof obj !== 'object' ||\n\t obj === null) {\n\t\n\t return '';\n\t }\n\t\n\t var arrayFormat;\n\t if (options.arrayFormat in internals.arrayPrefixGenerators) {\n\t arrayFormat = options.arrayFormat;\n\t }\n\t else if ('indices' in options) {\n\t arrayFormat = options.indices ? 'indices' : 'repeat';\n\t }\n\t else {\n\t arrayFormat = 'indices';\n\t }\n\t\n\t var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];\n\t\n\t if (!objKeys) {\n\t objKeys = Object.keys(obj);\n\t }\n\t for (var i = 0, il = objKeys.length; i < il; ++i) {\n\t var key = objKeys[i];\n\t keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter));\n\t }\n\t\n\t return keys.join(delimiter);\n\t};\n\n\n/***/ },\n/* 24 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar superagent = __webpack_require__(28);\n\tvar debug = __webpack_require__(25)('wpcom-xhr-request');\n\t\n\t/**\n\t * Export a single `request` function.\n\t */\n\t\n\tmodule.exports = request;\n\t\n\t/**\n\t * WordPress.com REST API base endpoint.\n\t */\n\t\n\tvar proxyOrigin = 'https://public-api.wordpress.com';\n\t\n\t/**\n\t * Default WordPress.com REST API Version.\n\t */\n\t\n\tvar defaultApiVersion = '1';\n\t\n\t/**\n\t * Performs an XMLHttpRequest against the WordPress.com REST API.\n\t *\n\t * @param {Object|String} params\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tfunction request (params, fn) {\n\t\n\t if ('string' == typeof params) {\n\t params = { path: params };\n\t }\n\t\n\t var method = (params.method || 'GET').toLowerCase();\n\t debug('API HTTP Method: %o', method);\n\t delete params.method;\n\t\n\t var apiVersion = params.apiVersion || defaultApiVersion;\n\t delete params.apiVersion;\n\t\n\t proxyOrigin = params.proxyOrigin || proxyOrigin;\n\t delete params.proxyOrigin;\n\t\n\t var url = proxyOrigin + '/rest/v' + apiVersion + params.path;\n\t debug('API URL: %o', url);\n\t delete params.path;\n\t\n\t // create HTTP Request object\n\t var req = superagent[method](url);\n\t\n\t // Token authentication\n\t if (params.authToken) {\n\t req.set('Authorization', 'Bearer ' + params.authToken);\n\t delete params.authToken;\n\t }\n\t\n\t // URL querystring values\n\t if (params.query) {\n\t req.query(params.query);\n\t debug('API send URL querystring: %o', params.query);\n\t delete params.query;\n\t }\n\t\n\t // POST API request body\n\t if (params.body) {\n\t req.send(params.body);\n\t debug('API send POST body: ', params.body);\n\t delete params.body;\n\t }\n\t\n\t // POST FormData (for `multipart/form-data`, usually a file upload)\n\t if (params.formData) {\n\t for (var i = 0; i < params.formData.length; i++) {\n\t var data = params.formData[i];\n\t var key = data[0];\n\t var value = data[1];\n\t debug('adding FormData field %o', key);\n\t req.field(key, value);\n\t }\n\t }\n\t\n\t // start the request\n\t req.end(function (err, res){\n\t if (err && !res) {\n\t return fn(err);\n\t }\n\t\n\t var body = res.body;\n\t var headers = res.headers;\n\t var statusCode = res.status;\n\t debug('%o -> %o status code', url, statusCode);\n\t\n\t if (body && headers) {\n\t body._headers = headers;\n\t }\n\t\n\t if (!err) {\n\t return fn(null, body);\n\t }\n\t\n\t err = new Error();\n\t err.statusCode = statusCode;\n\t for (var i in body) {\n\t err[i] = body[i];\n\t }\n\t\n\t if (body && body.error) {\n\t err.name = toTitle(body.error) + 'Error';\n\t }\n\t\n\t fn(err);\n\t });\n\t\n\t return req.xhr;\n\t}\n\t\n\tfunction toTitle (str) {\n\t if (!str || 'string' !== typeof str) return '';\n\t return str.replace(/((^|_)[a-z])/g, function ($1) {\n\t return $1.toUpperCase().replace('_', '');\n\t });\n\t}\n\n\n/***/ },\n/* 25 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the web browser implementation of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = __webpack_require__(26);\n\texports.log = log;\n\texports.formatArgs = formatArgs;\n\texports.save = save;\n\texports.load = load;\n\texports.useColors = useColors;\n\t\n\t/**\n\t * Use chrome.storage.local if we are in an app\n\t */\n\t\n\tvar storage;\n\t\n\tif (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')\n\t storage = chrome.storage.local;\n\telse\n\t storage = localstorage();\n\t\n\t/**\n\t * Colors.\n\t */\n\t\n\texports.colors = [\n\t 'lightseagreen',\n\t 'forestgreen',\n\t 'goldenrod',\n\t 'dodgerblue',\n\t 'darkorchid',\n\t 'crimson'\n\t];\n\t\n\t/**\n\t * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n\t * and the Firebug extension (any Firefox version) are known\n\t * to support \"%c\" CSS customizations.\n\t *\n\t * TODO: add a `localStorage` variable to explicitly enable/disable colors\n\t */\n\t\n\tfunction useColors() {\n\t // is webkit? http://stackoverflow.com/a/16459606/376773\n\t return ('WebkitAppearance' in document.documentElement.style) ||\n\t // is firebug? http://stackoverflow.com/a/398120/376773\n\t (window.console && (console.firebug || (console.exception && console.table))) ||\n\t // is firefox >= v31?\n\t // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n\t}\n\t\n\t/**\n\t * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n\t */\n\t\n\texports.formatters.j = function(v) {\n\t return JSON.stringify(v);\n\t};\n\t\n\t\n\t/**\n\t * Colorize log arguments if enabled.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction formatArgs() {\n\t var args = arguments;\n\t var useColors = this.useColors;\n\t\n\t args[0] = (useColors ? '%c' : '')\n\t + this.namespace\n\t + (useColors ? ' %c' : ' ')\n\t + args[0]\n\t + (useColors ? '%c ' : ' ')\n\t + '+' + exports.humanize(this.diff);\n\t\n\t if (!useColors) return args;\n\t\n\t var c = 'color: ' + this.color;\n\t args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\t\n\t // the final \"%c\" is somewhat tricky, because there could be other\n\t // arguments passed either before or after the %c, so we need to\n\t // figure out the correct index to insert the CSS into\n\t var index = 0;\n\t var lastC = 0;\n\t args[0].replace(/%[a-z%]/g, function(match) {\n\t if ('%%' === match) return;\n\t index++;\n\t if ('%c' === match) {\n\t // we only are interested in the *last* %c\n\t // (the user may have provided their own)\n\t lastC = index;\n\t }\n\t });\n\t\n\t args.splice(lastC, 0, c);\n\t return args;\n\t}\n\t\n\t/**\n\t * Invokes `console.log()` when available.\n\t * No-op when `console.log` is not a \"function\".\n\t *\n\t * @api public\n\t */\n\t\n\tfunction log() {\n\t // this hackery is required for IE8/9, where\n\t // the `console.log` function doesn't have 'apply'\n\t return 'object' === typeof console\n\t && console.log\n\t && Function.prototype.apply.call(console.log, console, arguments);\n\t}\n\t\n\t/**\n\t * Save `namespaces`.\n\t *\n\t * @param {String} namespaces\n\t * @api private\n\t */\n\t\n\tfunction save(namespaces) {\n\t try {\n\t if (null == namespaces) {\n\t storage.removeItem('debug');\n\t } else {\n\t storage.debug = namespaces;\n\t }\n\t } catch(e) {}\n\t}\n\t\n\t/**\n\t * Load `namespaces`.\n\t *\n\t * @return {String} returns the previously persisted debug modes\n\t * @api private\n\t */\n\t\n\tfunction load() {\n\t var r;\n\t try {\n\t r = storage.debug;\n\t } catch(e) {}\n\t return r;\n\t}\n\t\n\t/**\n\t * Enable namespaces listed in `localStorage.debug` initially.\n\t */\n\t\n\texports.enable(load());\n\t\n\t/**\n\t * Localstorage attempts to return the localstorage.\n\t *\n\t * This is necessary because safari throws\n\t * when a user disables cookies/localstorage\n\t * and you attempt to access it.\n\t *\n\t * @return {LocalStorage}\n\t * @api private\n\t */\n\t\n\tfunction localstorage(){\n\t try {\n\t return window.localStorage;\n\t } catch (e) {}\n\t}\n\n\n/***/ },\n/* 26 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the common logic for both the Node.js and web browser\n\t * implementations of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = debug;\n\texports.coerce = coerce;\n\texports.disable = disable;\n\texports.enable = enable;\n\texports.enabled = enabled;\n\texports.humanize = __webpack_require__(27);\n\t\n\t/**\n\t * The currently active debug mode names, and names to skip.\n\t */\n\t\n\texports.names = [];\n\texports.skips = [];\n\t\n\t/**\n\t * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t *\n\t * Valid key names are a single, lowercased letter, i.e. \"n\".\n\t */\n\t\n\texports.formatters = {};\n\t\n\t/**\n\t * Previously assigned color.\n\t */\n\t\n\tvar prevColor = 0;\n\t\n\t/**\n\t * Previous log timestamp.\n\t */\n\t\n\tvar prevTime;\n\t\n\t/**\n\t * Select a color.\n\t *\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction selectColor() {\n\t return exports.colors[prevColor++ % exports.colors.length];\n\t}\n\t\n\t/**\n\t * Create a debugger with the given `namespace`.\n\t *\n\t * @param {String} namespace\n\t * @return {Function}\n\t * @api public\n\t */\n\t\n\tfunction debug(namespace) {\n\t\n\t // define the `disabled` version\n\t function disabled() {\n\t }\n\t disabled.enabled = false;\n\t\n\t // define the `enabled` version\n\t function enabled() {\n\t\n\t var self = enabled;\n\t\n\t // set `diff` timestamp\n\t var curr = +new Date();\n\t var ms = curr - (prevTime || curr);\n\t self.diff = ms;\n\t self.prev = prevTime;\n\t self.curr = curr;\n\t prevTime = curr;\n\t\n\t // add the `color` if not set\n\t if (null == self.useColors) self.useColors = exports.useColors();\n\t if (null == self.color && self.useColors) self.color = selectColor();\n\t\n\t var args = Array.prototype.slice.call(arguments);\n\t\n\t args[0] = exports.coerce(args[0]);\n\t\n\t if ('string' !== typeof args[0]) {\n\t // anything else let's inspect with %o\n\t args = ['%o'].concat(args);\n\t }\n\t\n\t // apply any `formatters` transformations\n\t var index = 0;\n\t args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n\t // if we encounter an escaped % then don't increase the array index\n\t if (match === '%%') return match;\n\t index++;\n\t var formatter = exports.formatters[format];\n\t if ('function' === typeof formatter) {\n\t var val = args[index];\n\t match = formatter.call(self, val);\n\t\n\t // now we need to remove `args[index]` since it's inlined in the `format`\n\t args.splice(index, 1);\n\t index--;\n\t }\n\t return match;\n\t });\n\t\n\t if ('function' === typeof exports.formatArgs) {\n\t args = exports.formatArgs.apply(self, args);\n\t }\n\t var logFn = enabled.log || exports.log || console.log.bind(console);\n\t logFn.apply(self, args);\n\t }\n\t enabled.enabled = true;\n\t\n\t var fn = exports.enabled(namespace) ? enabled : disabled;\n\t\n\t fn.namespace = namespace;\n\t\n\t return fn;\n\t}\n\t\n\t/**\n\t * Enables a debug mode by namespaces. This can include modes\n\t * separated by a colon and wildcards.\n\t *\n\t * @param {String} namespaces\n\t * @api public\n\t */\n\t\n\tfunction enable(namespaces) {\n\t exports.save(namespaces);\n\t\n\t var split = (namespaces || '').split(/[\\s,]+/);\n\t var len = split.length;\n\t\n\t for (var i = 0; i < len; i++) {\n\t if (!split[i]) continue; // ignore empty strings\n\t namespaces = split[i].replace(/\\*/g, '.*?');\n\t if (namespaces[0] === '-') {\n\t exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t } else {\n\t exports.names.push(new RegExp('^' + namespaces + '$'));\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Disable debug output.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction disable() {\n\t exports.enable('');\n\t}\n\t\n\t/**\n\t * Returns true if the given mode name is enabled, false otherwise.\n\t *\n\t * @param {String} name\n\t * @return {Boolean}\n\t * @api public\n\t */\n\t\n\tfunction enabled(name) {\n\t var i, len;\n\t for (i = 0, len = exports.skips.length; i < len; i++) {\n\t if (exports.skips[i].test(name)) {\n\t return false;\n\t }\n\t }\n\t for (i = 0, len = exports.names.length; i < len; i++) {\n\t if (exports.names[i].test(name)) {\n\t return true;\n\t }\n\t }\n\t return false;\n\t}\n\t\n\t/**\n\t * Coerce `val`.\n\t *\n\t * @param {Mixed} val\n\t * @return {Mixed}\n\t * @api private\n\t */\n\t\n\tfunction coerce(val) {\n\t if (val instanceof Error) return val.stack || val.message;\n\t return val;\n\t}\n\n\n/***/ },\n/* 27 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Helpers.\n\t */\n\t\n\tvar s = 1000;\n\tvar m = s * 60;\n\tvar h = m * 60;\n\tvar d = h * 24;\n\tvar y = d * 365.25;\n\t\n\t/**\n\t * Parse or format the given `val`.\n\t *\n\t * Options:\n\t *\n\t * - `long` verbose formatting [false]\n\t *\n\t * @param {String|Number} val\n\t * @param {Object} options\n\t * @return {String|Number}\n\t * @api public\n\t */\n\t\n\tmodule.exports = function(val, options){\n\t options = options || {};\n\t if ('string' == typeof val) return parse(val);\n\t return options.long\n\t ? long(val)\n\t : short(val);\n\t};\n\t\n\t/**\n\t * Parse the given `str` and return milliseconds.\n\t *\n\t * @param {String} str\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction parse(str) {\n\t var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n\t if (!match) return;\n\t var n = parseFloat(match[1]);\n\t var type = (match[2] || 'ms').toLowerCase();\n\t switch (type) {\n\t case 'years':\n\t case 'year':\n\t case 'yrs':\n\t case 'yr':\n\t case 'y':\n\t return n * y;\n\t case 'days':\n\t case 'day':\n\t case 'd':\n\t return n * d;\n\t case 'hours':\n\t case 'hour':\n\t case 'hrs':\n\t case 'hr':\n\t case 'h':\n\t return n * h;\n\t case 'minutes':\n\t case 'minute':\n\t case 'mins':\n\t case 'min':\n\t case 'm':\n\t return n * m;\n\t case 'seconds':\n\t case 'second':\n\t case 'secs':\n\t case 'sec':\n\t case 's':\n\t return n * s;\n\t case 'milliseconds':\n\t case 'millisecond':\n\t case 'msecs':\n\t case 'msec':\n\t case 'ms':\n\t return n;\n\t }\n\t}\n\t\n\t/**\n\t * Short format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction short(ms) {\n\t if (ms >= d) return Math.round(ms / d) + 'd';\n\t if (ms >= h) return Math.round(ms / h) + 'h';\n\t if (ms >= m) return Math.round(ms / m) + 'm';\n\t if (ms >= s) return Math.round(ms / s) + 's';\n\t return ms + 'ms';\n\t}\n\t\n\t/**\n\t * Long format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction long(ms) {\n\t return plural(ms, d, 'day')\n\t || plural(ms, h, 'hour')\n\t || plural(ms, m, 'minute')\n\t || plural(ms, s, 'second')\n\t || ms + ' ms';\n\t}\n\t\n\t/**\n\t * Pluralization helper.\n\t */\n\t\n\tfunction plural(ms, n, name) {\n\t if (ms < n) return;\n\t if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n\t return Math.ceil(ms / n) + ' ' + name + 's';\n\t}\n\n\n/***/ },\n/* 28 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Emitter = __webpack_require__(29);\n\tvar reduce = __webpack_require__(30);\n\t\n\t/**\n\t * Root reference for iframes.\n\t */\n\t\n\tvar root = 'undefined' == typeof window\n\t ? (this || self)\n\t : window;\n\t\n\t/**\n\t * Noop.\n\t */\n\t\n\tfunction noop(){};\n\t\n\t/**\n\t * Check if `obj` is a host object,\n\t * we don't want to serialize these :)\n\t *\n\t * TODO: future proof, move to compoent land\n\t *\n\t * @param {Object} obj\n\t * @return {Boolean}\n\t * @api private\n\t */\n\t\n\tfunction isHost(obj) {\n\t var str = {}.toString.call(obj);\n\t\n\t switch (str) {\n\t case '[object File]':\n\t case '[object Blob]':\n\t case '[object FormData]':\n\t return true;\n\t default:\n\t return false;\n\t }\n\t}\n\t\n\t/**\n\t * Determine XHR.\n\t */\n\t\n\trequest.getXHR = function () {\n\t if (root.XMLHttpRequest\n\t && (!root.location || 'file:' != root.location.protocol\n\t || !root.ActiveXObject)) {\n\t return new XMLHttpRequest;\n\t } else {\n\t try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n\t try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n\t try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n\t try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n\t }\n\t return false;\n\t};\n\t\n\t/**\n\t * Removes leading and trailing whitespace, added to support IE.\n\t *\n\t * @param {String} s\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tvar trim = ''.trim\n\t ? function(s) { return s.trim(); }\n\t : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\t\n\t/**\n\t * Check if `obj` is an object.\n\t *\n\t * @param {Object} obj\n\t * @return {Boolean}\n\t * @api private\n\t */\n\t\n\tfunction isObject(obj) {\n\t return obj === Object(obj);\n\t}\n\t\n\t/**\n\t * Serialize the given `obj`.\n\t *\n\t * @param {Object} obj\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction serialize(obj) {\n\t if (!isObject(obj)) return obj;\n\t var pairs = [];\n\t for (var key in obj) {\n\t if (null != obj[key]) {\n\t pairs.push(encodeURIComponent(key)\n\t + '=' + encodeURIComponent(obj[key]));\n\t }\n\t }\n\t return pairs.join('&');\n\t}\n\t\n\t/**\n\t * Expose serialization method.\n\t */\n\t\n\t request.serializeObject = serialize;\n\t\n\t /**\n\t * Parse the given x-www-form-urlencoded `str`.\n\t *\n\t * @param {String} str\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction parseString(str) {\n\t var obj = {};\n\t var pairs = str.split('&');\n\t var parts;\n\t var pair;\n\t\n\t for (var i = 0, len = pairs.length; i < len; ++i) {\n\t pair = pairs[i];\n\t parts = pair.split('=');\n\t obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n\t }\n\t\n\t return obj;\n\t}\n\t\n\t/**\n\t * Expose parser.\n\t */\n\t\n\trequest.parseString = parseString;\n\t\n\t/**\n\t * Default MIME type map.\n\t *\n\t * superagent.types.xml = 'application/xml';\n\t *\n\t */\n\t\n\trequest.types = {\n\t html: 'text/html',\n\t json: 'application/json',\n\t xml: 'application/xml',\n\t urlencoded: 'application/x-www-form-urlencoded',\n\t 'form': 'application/x-www-form-urlencoded',\n\t 'form-data': 'application/x-www-form-urlencoded'\n\t};\n\t\n\t/**\n\t * Default serialization map.\n\t *\n\t * superagent.serialize['application/xml'] = function(obj){\n\t * return 'generated xml here';\n\t * };\n\t *\n\t */\n\t\n\t request.serialize = {\n\t 'application/x-www-form-urlencoded': serialize,\n\t 'application/json': JSON.stringify\n\t };\n\t\n\t /**\n\t * Default parsers.\n\t *\n\t * superagent.parse['application/xml'] = function(str){\n\t * return { object parsed from str };\n\t * };\n\t *\n\t */\n\t\n\trequest.parse = {\n\t 'application/x-www-form-urlencoded': parseString,\n\t 'application/json': JSON.parse\n\t};\n\t\n\t/**\n\t * Parse the given header `str` into\n\t * an object containing the mapped fields.\n\t *\n\t * @param {String} str\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction parseHeader(str) {\n\t var lines = str.split(/\\r?\\n/);\n\t var fields = {};\n\t var index;\n\t var line;\n\t var field;\n\t var val;\n\t\n\t lines.pop(); // trailing CRLF\n\t\n\t for (var i = 0, len = lines.length; i < len; ++i) {\n\t line = lines[i];\n\t index = line.indexOf(':');\n\t field = line.slice(0, index).toLowerCase();\n\t val = trim(line.slice(index + 1));\n\t fields[field] = val;\n\t }\n\t\n\t return fields;\n\t}\n\t\n\t/**\n\t * Return the mime type for the given `str`.\n\t *\n\t * @param {String} str\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction type(str){\n\t return str.split(/ *; */).shift();\n\t};\n\t\n\t/**\n\t * Return header field parameters.\n\t *\n\t * @param {String} str\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction params(str){\n\t return reduce(str.split(/ *; */), function(obj, str){\n\t var parts = str.split(/ *= */)\n\t , key = parts.shift()\n\t , val = parts.shift();\n\t\n\t if (key && val) obj[key] = val;\n\t return obj;\n\t }, {});\n\t};\n\t\n\t/**\n\t * Initialize a new `Response` with the given `xhr`.\n\t *\n\t * - set flags (.ok, .error, etc)\n\t * - parse header\n\t *\n\t * Examples:\n\t *\n\t * Aliasing `superagent` as `request` is nice:\n\t *\n\t * request = superagent;\n\t *\n\t * We can use the promise-like API, or pass callbacks:\n\t *\n\t * request.get('/').end(function(res){});\n\t * request.get('/', function(res){});\n\t *\n\t * Sending data can be chained:\n\t *\n\t * request\n\t * .post('/user')\n\t * .send({ name: 'tj' })\n\t * .end(function(res){});\n\t *\n\t * Or passed to `.send()`:\n\t *\n\t * request\n\t * .post('/user')\n\t * .send({ name: 'tj' }, function(res){});\n\t *\n\t * Or passed to `.post()`:\n\t *\n\t * request\n\t * .post('/user', { name: 'tj' })\n\t * .end(function(res){});\n\t *\n\t * Or further reduced to a single call for simple cases:\n\t *\n\t * request\n\t * .post('/user', { name: 'tj' }, function(res){});\n\t *\n\t * @param {XMLHTTPRequest} xhr\n\t * @param {Object} options\n\t * @api private\n\t */\n\t\n\tfunction Response(req, options) {\n\t options = options || {};\n\t this.req = req;\n\t this.xhr = this.req.xhr;\n\t // responseText is accessible only if responseType is '' or 'text' and on older browsers\n\t this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')\n\t ? this.xhr.responseText\n\t : null;\n\t this.statusText = this.req.xhr.statusText;\n\t this.setStatusProperties(this.xhr.status);\n\t this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n\t // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n\t // getResponseHeader still works. so we get content-type even if getting\n\t // other headers fails.\n\t this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n\t this.setHeaderProperties(this.header);\n\t this.body = this.req.method != 'HEAD'\n\t ? this.parseBody(this.text ? this.text : this.xhr.response)\n\t : null;\n\t}\n\t\n\t/**\n\t * Get case-insensitive `field` value.\n\t *\n\t * @param {String} field\n\t * @return {String}\n\t * @api public\n\t */\n\t\n\tResponse.prototype.get = function(field){\n\t return this.header[field.toLowerCase()];\n\t};\n\t\n\t/**\n\t * Set header related properties:\n\t *\n\t * - `.type` the content type without params\n\t *\n\t * A response of \"Content-Type: text/plain; charset=utf-8\"\n\t * will provide you with a `.type` of \"text/plain\".\n\t *\n\t * @param {Object} header\n\t * @api private\n\t */\n\t\n\tResponse.prototype.setHeaderProperties = function(header){\n\t // content-type\n\t var ct = this.header['content-type'] || '';\n\t this.type = type(ct);\n\t\n\t // params\n\t var obj = params(ct);\n\t for (var key in obj) this[key] = obj[key];\n\t};\n\t\n\t/**\n\t * Parse the given body `str`.\n\t *\n\t * Used for auto-parsing of bodies. Parsers\n\t * are defined on the `superagent.parse` object.\n\t *\n\t * @param {String} str\n\t * @return {Mixed}\n\t * @api private\n\t */\n\t\n\tResponse.prototype.parseBody = function(str){\n\t var parse = request.parse[this.type];\n\t return parse && str && (str.length || str instanceof Object)\n\t ? parse(str)\n\t : null;\n\t};\n\t\n\t/**\n\t * Set flags such as `.ok` based on `status`.\n\t *\n\t * For example a 2xx response will give you a `.ok` of __true__\n\t * whereas 5xx will be __false__ and `.error` will be __true__. The\n\t * `.clientError` and `.serverError` are also available to be more\n\t * specific, and `.statusType` is the class of error ranging from 1..5\n\t * sometimes useful for mapping respond colors etc.\n\t *\n\t * \"sugar\" properties are also defined for common cases. Currently providing:\n\t *\n\t * - .noContent\n\t * - .badRequest\n\t * - .unauthorized\n\t * - .notAcceptable\n\t * - .notFound\n\t *\n\t * @param {Number} status\n\t * @api private\n\t */\n\t\n\tResponse.prototype.setStatusProperties = function(status){\n\t // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n\t if (status === 1223) {\n\t status = 204;\n\t }\n\t\n\t var type = status / 100 | 0;\n\t\n\t // status / class\n\t this.status = status;\n\t this.statusType = type;\n\t\n\t // basics\n\t this.info = 1 == type;\n\t this.ok = 2 == type;\n\t this.clientError = 4 == type;\n\t this.serverError = 5 == type;\n\t this.error = (4 == type || 5 == type)\n\t ? this.toError()\n\t : false;\n\t\n\t // sugar\n\t this.accepted = 202 == status;\n\t this.noContent = 204 == status;\n\t this.badRequest = 400 == status;\n\t this.unauthorized = 401 == status;\n\t this.notAcceptable = 406 == status;\n\t this.notFound = 404 == status;\n\t this.forbidden = 403 == status;\n\t};\n\t\n\t/**\n\t * Return an `Error` representative of this response.\n\t *\n\t * @return {Error}\n\t * @api public\n\t */\n\t\n\tResponse.prototype.toError = function(){\n\t var req = this.req;\n\t var method = req.method;\n\t var url = req.url;\n\t\n\t var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n\t var err = new Error(msg);\n\t err.status = this.status;\n\t err.method = method;\n\t err.url = url;\n\t\n\t return err;\n\t};\n\t\n\t/**\n\t * Expose `Response`.\n\t */\n\t\n\trequest.Response = Response;\n\t\n\t/**\n\t * Initialize a new `Request` with the given `method` and `url`.\n\t *\n\t * @param {String} method\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tfunction Request(method, url) {\n\t var self = this;\n\t Emitter.call(this);\n\t this._query = this._query || [];\n\t this.method = method;\n\t this.url = url;\n\t this.header = {};\n\t this._header = {};\n\t this.on('end', function(){\n\t var err = null;\n\t var res = null;\n\t\n\t try {\n\t res = new Response(self);\n\t } catch(e) {\n\t err = new Error('Parser is unable to parse the response');\n\t err.parse = true;\n\t err.original = e;\n\t return self.callback(err);\n\t }\n\t\n\t self.emit('response', res);\n\t\n\t if (err) {\n\t return self.callback(err, res);\n\t }\n\t\n\t if (res.status >= 200 && res.status < 300) {\n\t return self.callback(err, res);\n\t }\n\t\n\t var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');\n\t new_err.original = err;\n\t new_err.response = res;\n\t new_err.status = res.status;\n\t\n\t self.callback(err || new_err, res);\n\t });\n\t}\n\t\n\t/**\n\t * Mixin `Emitter`.\n\t */\n\t\n\tEmitter(Request.prototype);\n\t\n\t/**\n\t * Allow for extension\n\t */\n\t\n\tRequest.prototype.use = function(fn) {\n\t fn(this);\n\t return this;\n\t}\n\t\n\t/**\n\t * Set timeout to `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.timeout = function(ms){\n\t this._timeout = ms;\n\t return this;\n\t};\n\t\n\t/**\n\t * Clear previous timeout.\n\t *\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.clearTimeout = function(){\n\t this._timeout = 0;\n\t clearTimeout(this._timer);\n\t return this;\n\t};\n\t\n\t/**\n\t * Abort the request, and clear potential timeout.\n\t *\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\tRequest.prototype.abort = function(){\n\t if (this.aborted) return;\n\t this.aborted = true;\n\t this.xhr.abort();\n\t this.clearTimeout();\n\t this.emit('abort');\n\t return this;\n\t};\n\t\n\t/**\n\t * Set header `field` to `val`, or multiple fields with one object.\n\t *\n\t * Examples:\n\t *\n\t * req.get('/')\n\t * .set('Accept', 'application/json')\n\t * .set('X-API-Key', 'foobar')\n\t * .end(callback);\n\t *\n\t * req.get('/')\n\t * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n\t * .end(callback);\n\t *\n\t * @param {String|Object} field\n\t * @param {String} val\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.set = function(field, val){\n\t if (isObject(field)) {\n\t for (var key in field) {\n\t this.set(key, field[key]);\n\t }\n\t return this;\n\t }\n\t this._header[field.toLowerCase()] = val;\n\t this.header[field] = val;\n\t return this;\n\t};\n\t\n\t/**\n\t * Remove header `field`.\n\t *\n\t * Example:\n\t *\n\t * req.get('/')\n\t * .unset('User-Agent')\n\t * .end(callback);\n\t *\n\t * @param {String} field\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.unset = function(field){\n\t delete this._header[field.toLowerCase()];\n\t delete this.header[field];\n\t return this;\n\t};\n\t\n\t/**\n\t * Get case-insensitive header `field` value.\n\t *\n\t * @param {String} field\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tRequest.prototype.getHeader = function(field){\n\t return this._header[field.toLowerCase()];\n\t};\n\t\n\t/**\n\t * Set Content-Type to `type`, mapping values from `request.types`.\n\t *\n\t * Examples:\n\t *\n\t * superagent.types.xml = 'application/xml';\n\t *\n\t * request.post('/')\n\t * .type('xml')\n\t * .send(xmlstring)\n\t * .end(callback);\n\t *\n\t * request.post('/')\n\t * .type('application/xml')\n\t * .send(xmlstring)\n\t * .end(callback);\n\t *\n\t * @param {String} type\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.type = function(type){\n\t this.set('Content-Type', request.types[type] || type);\n\t return this;\n\t};\n\t\n\t/**\n\t * Set Accept to `type`, mapping values from `request.types`.\n\t *\n\t * Examples:\n\t *\n\t * superagent.types.json = 'application/json';\n\t *\n\t * request.get('/agent')\n\t * .accept('json')\n\t * .end(callback);\n\t *\n\t * request.get('/agent')\n\t * .accept('application/json')\n\t * .end(callback);\n\t *\n\t * @param {String} accept\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.accept = function(type){\n\t this.set('Accept', request.types[type] || type);\n\t return this;\n\t};\n\t\n\t/**\n\t * Set Authorization field value with `user` and `pass`.\n\t *\n\t * @param {String} user\n\t * @param {String} pass\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.auth = function(user, pass){\n\t var str = btoa(user + ':' + pass);\n\t this.set('Authorization', 'Basic ' + str);\n\t return this;\n\t};\n\t\n\t/**\n\t* Add query-string `val`.\n\t*\n\t* Examples:\n\t*\n\t* request.get('/shoes')\n\t* .query('size=10')\n\t* .query({ color: 'blue' })\n\t*\n\t* @param {Object|String} val\n\t* @return {Request} for chaining\n\t* @api public\n\t*/\n\t\n\tRequest.prototype.query = function(val){\n\t if ('string' != typeof val) val = serialize(val);\n\t if (val) this._query.push(val);\n\t return this;\n\t};\n\t\n\t/**\n\t * Write the field `name` and `val` for \"multipart/form-data\"\n\t * request bodies.\n\t *\n\t * ``` js\n\t * request.post('/upload')\n\t * .field('foo', 'bar')\n\t * .end(callback);\n\t * ```\n\t *\n\t * @param {String} name\n\t * @param {String|Blob|File} val\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.field = function(name, val){\n\t if (!this._formData) this._formData = new root.FormData();\n\t this._formData.append(name, val);\n\t return this;\n\t};\n\t\n\t/**\n\t * Queue the given `file` as an attachment to the specified `field`,\n\t * with optional `filename`.\n\t *\n\t * ``` js\n\t * request.post('/upload')\n\t * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n\t * .end(callback);\n\t * ```\n\t *\n\t * @param {String} field\n\t * @param {Blob|File} file\n\t * @param {String} filename\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.attach = function(field, file, filename){\n\t if (!this._formData) this._formData = new root.FormData();\n\t this._formData.append(field, file, filename);\n\t return this;\n\t};\n\t\n\t/**\n\t * Send `data`, defaulting the `.type()` to \"json\" when\n\t * an object is given.\n\t *\n\t * Examples:\n\t *\n\t * // querystring\n\t * request.get('/search')\n\t * .end(callback)\n\t *\n\t * // multiple data \"writes\"\n\t * request.get('/search')\n\t * .send({ search: 'query' })\n\t * .send({ range: '1..5' })\n\t * .send({ order: 'desc' })\n\t * .end(callback)\n\t *\n\t * // manual json\n\t * request.post('/user')\n\t * .type('json')\n\t * .send('{\"name\":\"tj\"})\n\t * .end(callback)\n\t *\n\t * // auto json\n\t * request.post('/user')\n\t * .send({ name: 'tj' })\n\t * .end(callback)\n\t *\n\t * // manual x-www-form-urlencoded\n\t * request.post('/user')\n\t * .type('form')\n\t * .send('name=tj')\n\t * .end(callback)\n\t *\n\t * // auto x-www-form-urlencoded\n\t * request.post('/user')\n\t * .type('form')\n\t * .send({ name: 'tj' })\n\t * .end(callback)\n\t *\n\t * // defaults to x-www-form-urlencoded\n\t * request.post('/user')\n\t * .send('name=tobi')\n\t * .send('species=ferret')\n\t * .end(callback)\n\t *\n\t * @param {String|Object} data\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.send = function(data){\n\t var obj = isObject(data);\n\t var type = this.getHeader('Content-Type');\n\t\n\t // merge\n\t if (obj && isObject(this._data)) {\n\t for (var key in data) {\n\t this._data[key] = data[key];\n\t }\n\t } else if ('string' == typeof data) {\n\t if (!type) this.type('form');\n\t type = this.getHeader('Content-Type');\n\t if ('application/x-www-form-urlencoded' == type) {\n\t this._data = this._data\n\t ? this._data + '&' + data\n\t : data;\n\t } else {\n\t this._data = (this._data || '') + data;\n\t }\n\t } else {\n\t this._data = data;\n\t }\n\t\n\t if (!obj || isHost(data)) return this;\n\t if (!type) this.type('json');\n\t return this;\n\t};\n\t\n\t/**\n\t * Invoke the callback with `err` and `res`\n\t * and handle arity check.\n\t *\n\t * @param {Error} err\n\t * @param {Response} res\n\t * @api private\n\t */\n\t\n\tRequest.prototype.callback = function(err, res){\n\t var fn = this._callback;\n\t this.clearTimeout();\n\t fn(err, res);\n\t};\n\t\n\t/**\n\t * Invoke callback with x-domain error.\n\t *\n\t * @api private\n\t */\n\t\n\tRequest.prototype.crossDomainError = function(){\n\t var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n\t err.crossDomain = true;\n\t this.callback(err);\n\t};\n\t\n\t/**\n\t * Invoke callback with timeout error.\n\t *\n\t * @api private\n\t */\n\t\n\tRequest.prototype.timeoutError = function(){\n\t var timeout = this._timeout;\n\t var err = new Error('timeout of ' + timeout + 'ms exceeded');\n\t err.timeout = timeout;\n\t this.callback(err);\n\t};\n\t\n\t/**\n\t * Enable transmission of cookies with x-domain requests.\n\t *\n\t * Note that for this to work the origin must not be\n\t * using \"Access-Control-Allow-Origin\" with a wildcard,\n\t * and also must set \"Access-Control-Allow-Credentials\"\n\t * to \"true\".\n\t *\n\t * @api public\n\t */\n\t\n\tRequest.prototype.withCredentials = function(){\n\t this._withCredentials = true;\n\t return this;\n\t};\n\t\n\t/**\n\t * Initiate request, invoking callback `fn(res)`\n\t * with an instanceof `Response`.\n\t *\n\t * @param {Function} fn\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.end = function(fn){\n\t var self = this;\n\t var xhr = this.xhr = request.getXHR();\n\t var query = this._query.join('&');\n\t var timeout = this._timeout;\n\t var data = this._formData || this._data;\n\t\n\t // store callback\n\t this._callback = fn || noop;\n\t\n\t // state change\n\t xhr.onreadystatechange = function(){\n\t if (4 != xhr.readyState) return;\n\t\n\t // In IE9, reads to any property (e.g. status) off of an aborted XHR will\n\t // result in the error \"Could not complete the operation due to error c00c023f\"\n\t var status;\n\t try { status = xhr.status } catch(e) { status = 0; }\n\t\n\t if (0 == status) {\n\t if (self.timedout) return self.timeoutError();\n\t if (self.aborted) return;\n\t return self.crossDomainError();\n\t }\n\t self.emit('end');\n\t };\n\t\n\t // progress\n\t var handleProgress = function(e){\n\t if (e.total > 0) {\n\t e.percent = e.loaded / e.total * 100;\n\t }\n\t self.emit('progress', e);\n\t };\n\t if (this.hasListeners('progress')) {\n\t xhr.onprogress = handleProgress;\n\t }\n\t try {\n\t if (xhr.upload && this.hasListeners('progress')) {\n\t xhr.upload.onprogress = handleProgress;\n\t }\n\t } catch(e) {\n\t // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.\n\t // Reported here:\n\t // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context\n\t }\n\t\n\t // timeout\n\t if (timeout && !this._timer) {\n\t this._timer = setTimeout(function(){\n\t self.timedout = true;\n\t self.abort();\n\t }, timeout);\n\t }\n\t\n\t // querystring\n\t if (query) {\n\t query = request.serializeObject(query);\n\t this.url += ~this.url.indexOf('?')\n\t ? '&' + query\n\t : '?' + query;\n\t }\n\t\n\t // initiate request\n\t xhr.open(this.method, this.url, true);\n\t\n\t // CORS\n\t if (this._withCredentials) xhr.withCredentials = true;\n\t\n\t // body\n\t if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n\t // serialize stuff\n\t var serialize = request.serialize[this.getHeader('Content-Type')];\n\t if (serialize) data = serialize(data);\n\t }\n\t\n\t // set header fields\n\t for (var field in this.header) {\n\t if (null == this.header[field]) continue;\n\t xhr.setRequestHeader(field, this.header[field]);\n\t }\n\t\n\t // send stuff\n\t this.emit('request', this);\n\t xhr.send(data);\n\t return this;\n\t};\n\t\n\t/**\n\t * Expose `Request`.\n\t */\n\t\n\trequest.Request = Request;\n\t\n\t/**\n\t * Issue a request:\n\t *\n\t * Examples:\n\t *\n\t * request('GET', '/users').end(callback)\n\t * request('/users').end(callback)\n\t * request('/users', callback)\n\t *\n\t * @param {String} method\n\t * @param {String|Function} url or callback\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\tfunction request(method, url) {\n\t // callback\n\t if ('function' == typeof url) {\n\t return new Request('GET', method).end(url);\n\t }\n\t\n\t // url first\n\t if (1 == arguments.length) {\n\t return new Request('GET', method);\n\t }\n\t\n\t return new Request(method, url);\n\t}\n\t\n\t/**\n\t * GET `url` with optional callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed|Function} data or fn\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.get = function(url, data, fn){\n\t var req = request('GET', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.query(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * HEAD `url` with optional callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed|Function} data or fn\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.head = function(url, data, fn){\n\t var req = request('HEAD', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * DELETE `url` with optional callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.del = function(url, fn){\n\t var req = request('DELETE', url);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * PATCH `url` with optional `data` and callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed} data\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.patch = function(url, data, fn){\n\t var req = request('PATCH', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * POST `url` with optional `data` and callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed} data\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.post = function(url, data, fn){\n\t var req = request('POST', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * PUT `url` with optional `data` and callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed|Function} data or fn\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.put = function(url, data, fn){\n\t var req = request('PUT', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * Expose `request`.\n\t */\n\t\n\tmodule.exports = request;\n\n\n/***/ },\n/* 29 */\n/***/ function(module, exports) {\n\n\t\n\t/**\n\t * Expose `Emitter`.\n\t */\n\t\n\tmodule.exports = Emitter;\n\t\n\t/**\n\t * Initialize a new `Emitter`.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction Emitter(obj) {\n\t if (obj) return mixin(obj);\n\t};\n\t\n\t/**\n\t * Mixin the emitter properties.\n\t *\n\t * @param {Object} obj\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction mixin(obj) {\n\t for (var key in Emitter.prototype) {\n\t obj[key] = Emitter.prototype[key];\n\t }\n\t return obj;\n\t}\n\t\n\t/**\n\t * Listen on the given `event` with `fn`.\n\t *\n\t * @param {String} event\n\t * @param {Function} fn\n\t * @return {Emitter}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.on =\n\tEmitter.prototype.addEventListener = function(event, fn){\n\t this._callbacks = this._callbacks || {};\n\t (this._callbacks[event] = this._callbacks[event] || [])\n\t .push(fn);\n\t return this;\n\t};\n\t\n\t/**\n\t * Adds an `event` listener that will be invoked a single\n\t * time then automatically removed.\n\t *\n\t * @param {String} event\n\t * @param {Function} fn\n\t * @return {Emitter}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.once = function(event, fn){\n\t var self = this;\n\t this._callbacks = this._callbacks || {};\n\t\n\t function on() {\n\t self.off(event, on);\n\t fn.apply(this, arguments);\n\t }\n\t\n\t on.fn = fn;\n\t this.on(event, on);\n\t return this;\n\t};\n\t\n\t/**\n\t * Remove the given callback for `event` or all\n\t * registered callbacks.\n\t *\n\t * @param {String} event\n\t * @param {Function} fn\n\t * @return {Emitter}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.off =\n\tEmitter.prototype.removeListener =\n\tEmitter.prototype.removeAllListeners =\n\tEmitter.prototype.removeEventListener = function(event, fn){\n\t this._callbacks = this._callbacks || {};\n\t\n\t // all\n\t if (0 == arguments.length) {\n\t this._callbacks = {};\n\t return this;\n\t }\n\t\n\t // specific event\n\t var callbacks = this._callbacks[event];\n\t if (!callbacks) return this;\n\t\n\t // remove all handlers\n\t if (1 == arguments.length) {\n\t delete this._callbacks[event];\n\t return this;\n\t }\n\t\n\t // remove specific handler\n\t var cb;\n\t for (var i = 0; i < callbacks.length; i++) {\n\t cb = callbacks[i];\n\t if (cb === fn || cb.fn === fn) {\n\t callbacks.splice(i, 1);\n\t break;\n\t }\n\t }\n\t return this;\n\t};\n\t\n\t/**\n\t * Emit `event` with the given args.\n\t *\n\t * @param {String} event\n\t * @param {Mixed} ...\n\t * @return {Emitter}\n\t */\n\t\n\tEmitter.prototype.emit = function(event){\n\t this._callbacks = this._callbacks || {};\n\t var args = [].slice.call(arguments, 1)\n\t , callbacks = this._callbacks[event];\n\t\n\t if (callbacks) {\n\t callbacks = callbacks.slice(0);\n\t for (var i = 0, len = callbacks.length; i < len; ++i) {\n\t callbacks[i].apply(this, args);\n\t }\n\t }\n\t\n\t return this;\n\t};\n\t\n\t/**\n\t * Return array of callbacks for `event`.\n\t *\n\t * @param {String} event\n\t * @return {Array}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.listeners = function(event){\n\t this._callbacks = this._callbacks || {};\n\t return this._callbacks[event] || [];\n\t};\n\t\n\t/**\n\t * Check if this emitter has `event` handlers.\n\t *\n\t * @param {String} event\n\t * @return {Boolean}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.hasListeners = function(event){\n\t return !! this.listeners(event).length;\n\t};\n\n\n/***/ },\n/* 30 */\n/***/ function(module, exports) {\n\n\t\n\t/**\n\t * Reduce `arr` with `fn`.\n\t *\n\t * @param {Array} arr\n\t * @param {Function} fn\n\t * @param {Mixed} initial\n\t *\n\t * TODO: combatible error handling?\n\t */\n\t\n\tmodule.exports = function(arr, fn, initial){ \n\t var idx = 0;\n\t var len = arr.length;\n\t var curr = arguments.length == 3\n\t ? initial\n\t : arr[idx++];\n\t\n\t while (idx < len) {\n\t curr = fn.call(null, curr, arr[idx], ++idx, arr);\n\t }\n\t \n\t return curr;\n\t};\n\n/***/ }\n/******/ ]);\n\n\n/** WEBPACK FOOTER **\n ** wpcom.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap b05cd61689205a643f6c\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) { //eslint-disable-line no-console\n console.warn(msg); //eslint-disable-line no-console\n } else {\n console.log(msg); //eslint-disable-line no-console\n }\n\n return sendRequest.call(this, params, query, body, fn);\n};\n\nif (!Promise.prototype.timeout) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function (delay = DEFAULT_ASYNC_TIMEOUT) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error('Action timed out while waiting for response.'));\n }, delay);\n });\n\n cancelTimeout = () => {\n clearTimeout(timer);\n return this;\n };\n\n return Promise.race([ this.then(cancelTimeout).catch(cancelTimeout), timeout ]);\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","\n/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n && 'undefined' != typeof chrome.storage\n ? chrome.storage.local\n : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // is webkit? http://stackoverflow.com/a/16459606/376773\n return ('WebkitAppearance' in document.documentElement.style) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (window.console && (console.firebug || (console.exception && console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n return JSON.stringify(v);\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs() {\n var args = arguments;\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return args;\n\n var c = 'color: ' + this.color;\n args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n return args;\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n exports.storage.removeItem('debug');\n } else {\n exports.storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = exports.storage.debug;\n } catch(e) {}\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage(){\n try {\n return window.localStorage;\n } catch (e) {}\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/debug/browser.js\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function () {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function (err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n });\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","// Load modules\n\n\n// Declare internals\n\nvar internals = {};\ninternals.hexTable = new Array(256);\nfor (var h = 0; h < 256; ++h) {\n internals.hexTable[h] = '%' + ((h < 16 ? '0' : '') + h.toString(16)).toUpperCase();\n}\n\n\nexports.arrayToObject = function (source, options) {\n\n var obj = options.plainObjects ? Object.create(null) : {};\n for (var i = 0, il = source.length; i < il; ++i) {\n if (typeof source[i] !== 'undefined') {\n\n obj[i] = source[i];\n }\n }\n\n return obj;\n};\n\n\nexports.merge = function (target, source, options) {\n\n if (!source) {\n return target;\n }\n\n if (typeof source !== 'object') {\n if (Array.isArray(target)) {\n target.push(source);\n }\n else if (typeof target === 'object') {\n target[source] = true;\n }\n else {\n target = [target, source];\n }\n\n return target;\n }\n\n if (typeof target !== 'object') {\n target = [target].concat(source);\n return target;\n }\n\n if (Array.isArray(target) &&\n !Array.isArray(source)) {\n\n target = exports.arrayToObject(target, options);\n }\n\n var keys = Object.keys(source);\n for (var k = 0, kl = keys.length; k < kl; ++k) {\n var key = keys[k];\n var value = source[key];\n\n if (!Object.prototype.hasOwnProperty.call(target, key)) {\n target[key] = value;\n }\n else {\n target[key] = exports.merge(target[key], value, options);\n }\n }\n\n return target;\n};\n\n\nexports.decode = function (str) {\n\n try {\n return decodeURIComponent(str.replace(/\\+/g, ' '));\n } catch (e) {\n return str;\n }\n};\n\nexports.encode = function (str) {\n\n // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n // It has been adapted here for stricter adherence to RFC 3986\n if (str.length === 0) {\n return str;\n }\n\n if (typeof str !== 'string') {\n str = '' + str;\n }\n\n var out = '';\n for (var i = 0, il = str.length; i < il; ++i) {\n var c = str.charCodeAt(i);\n\n if (c === 0x2D || // -\n c === 0x2E || // .\n c === 0x5F || // _\n c === 0x7E || // ~\n (c >= 0x30 && c <= 0x39) || // 0-9\n (c >= 0x41 && c <= 0x5A) || // a-z\n (c >= 0x61 && c <= 0x7A)) { // A-Z\n\n out += str[i];\n continue;\n }\n\n if (c < 0x80) {\n out += internals.hexTable[c];\n continue;\n }\n\n if (c < 0x800) {\n out += internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)];\n continue;\n }\n\n if (c < 0xD800 || c >= 0xE000) {\n out += internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n continue;\n }\n\n ++i;\n c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF));\n out += internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n }\n\n return out;\n};\n\nexports.compact = function (obj, refs) {\n\n if (typeof obj !== 'object' ||\n obj === null) {\n\n return obj;\n }\n\n refs = refs || [];\n var lookup = refs.indexOf(obj);\n if (lookup !== -1) {\n return refs[lookup];\n }\n\n refs.push(obj);\n\n if (Array.isArray(obj)) {\n var compacted = [];\n\n for (var i = 0, il = obj.length; i < il; ++i) {\n if (typeof obj[i] !== 'undefined') {\n compacted.push(obj[i]);\n }\n }\n\n return compacted;\n }\n\n var keys = Object.keys(obj);\n for (i = 0, il = keys.length; i < il; ++i) {\n var key = keys[i];\n obj[key] = exports.compact(obj[key], refs);\n }\n\n return obj;\n};\n\n\nexports.isRegExp = function (obj) {\n\n return Object.prototype.toString.call(obj) === '[object RegExp]';\n};\n\n\nexports.isBuffer = function (obj) {\n\n if (obj === null ||\n typeof obj === 'undefined') {\n\n return false;\n }\n\n return !!(obj.constructor &&\n obj.constructor.isBuffer &&\n obj.constructor.isBuffer(obj));\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/utils.js\n ** module id = 4\n ** module chunks = 0\n **/","/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","/**\n * Follow\n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current\n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if (undefined === fn) {\n if (undefined === files) {\n files = query;\n query = {};\n } else if ('function' === typeof files) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [ files ];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([ param, f[k] ]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push([ 'media[]', f ]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if (undefined === fn) {\n if (undefined === media) {\n media = query;\n query = {};\n } else if ('function' === typeof media) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m.url;\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ('function' === typeof fn) {\n fn(null, data);\n } else {\n return Promise.resolve(data);\n }\n })\n .catch(err => {\n if ('function' === typeof fn) {\n fn(err);\n } else {\n return Promise.reject(err);\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if (undefined === fn) {\n if (undefined === note) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = debug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lowercased letter, i.e. \"n\".\n */\n\nexports.formatters = {};\n\n/**\n * Previously assigned color.\n */\n\nvar prevColor = 0;\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n *\n * @return {Number}\n * @api private\n */\n\nfunction selectColor() {\n return exports.colors[prevColor++ % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction debug(namespace) {\n\n // define the `disabled` version\n function disabled() {\n }\n disabled.enabled = false;\n\n // define the `enabled` version\n function enabled() {\n\n var self = enabled;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // add the `color` if not set\n if (null == self.useColors) self.useColors = exports.useColors();\n if (null == self.color && self.useColors) self.color = selectColor();\n\n var args = Array.prototype.slice.call(arguments);\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %o\n args = ['%o'].concat(args);\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n if ('function' === typeof exports.formatArgs) {\n args = exports.formatArgs.apply(self, args);\n }\n var logFn = enabled.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n enabled.enabled = true;\n\n var fn = exports.enabled(namespace) ? enabled : disabled;\n\n fn.namespace = namespace;\n\n return fn;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n var split = (namespaces || '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/debug/debug.js\n ** module id = 18\n ** module chunks = 0\n **/","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} options\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options){\n options = options || {};\n if ('string' == typeof val) return parse(val);\n return options.long\n ? long(val)\n : short(val);\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = '' + str;\n if (str.length > 10000) return;\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n if (!match) return;\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction short(ms) {\n if (ms >= d) return Math.round(ms / d) + 'd';\n if (ms >= h) return Math.round(ms / h) + 'h';\n if (ms >= m) return Math.round(ms / m) + 'm';\n if (ms >= s) return Math.round(ms / s) + 's';\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction long(ms) {\n return plural(ms, d, 'day')\n || plural(ms, h, 'hour')\n || plural(ms, m, 'minute')\n || plural(ms, s, 'second')\n || ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) return;\n if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/debug/~/ms/index.js\n ** module id = 19\n ** module chunks = 0\n **/","console.log(\"I'm `fs` modules\");\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/fs/index.js\n ** module id = 20\n ** module chunks = 0\n **/","// Load modules\n\nvar Stringify = require('./stringify');\nvar Parse = require('./parse');\n\n\n// Declare internals\n\nvar internals = {};\n\n\nmodule.exports = {\n stringify: Stringify,\n parse: Parse\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/index.js\n ** module id = 21\n ** module chunks = 0\n **/","// Load modules\n\nvar Utils = require('./utils');\n\n\n// Declare internals\n\nvar internals = {\n delimiter: '&',\n depth: 5,\n arrayLimit: 20,\n parameterLimit: 1000,\n strictNullHandling: false,\n plainObjects: false,\n allowPrototypes: false\n};\n\n\ninternals.parseValues = function (str, options) {\n\n var obj = {};\n var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);\n\n for (var i = 0, il = parts.length; i < il; ++i) {\n var part = parts[i];\n var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;\n\n if (pos === -1) {\n obj[Utils.decode(part)] = '';\n\n if (options.strictNullHandling) {\n obj[Utils.decode(part)] = null;\n }\n }\n else {\n var key = Utils.decode(part.slice(0, pos));\n var val = Utils.decode(part.slice(pos + 1));\n\n if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n obj[key] = val;\n }\n else {\n obj[key] = [].concat(obj[key]).concat(val);\n }\n }\n }\n\n return obj;\n};\n\n\ninternals.parseObject = function (chain, val, options) {\n\n if (!chain.length) {\n return val;\n }\n\n var root = chain.shift();\n\n var obj;\n if (root === '[]') {\n obj = [];\n obj = obj.concat(internals.parseObject(chain, val, options));\n }\n else {\n obj = options.plainObjects ? Object.create(null) : {};\n var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;\n var index = parseInt(cleanRoot, 10);\n var indexString = '' + index;\n if (!isNaN(index) &&\n root !== cleanRoot &&\n indexString === cleanRoot &&\n index >= 0 &&\n (options.parseArrays &&\n index <= options.arrayLimit)) {\n\n obj = [];\n obj[index] = internals.parseObject(chain, val, options);\n }\n else {\n obj[cleanRoot] = internals.parseObject(chain, val, options);\n }\n }\n\n return obj;\n};\n\n\ninternals.parseKeys = function (key, val, options) {\n\n if (!key) {\n return;\n }\n\n // Transform dot notation to bracket notation\n\n if (options.allowDots) {\n key = key.replace(/\\.([^\\.\\[]+)/g, '[$1]');\n }\n\n // The regex chunks\n\n var parent = /^([^\\[\\]]*)/;\n var child = /(\\[[^\\[\\]]*\\])/g;\n\n // Get the parent\n\n var segment = parent.exec(key);\n\n // Stash the parent if it exists\n\n var keys = [];\n if (segment[1]) {\n // If we aren't using plain objects, optionally prefix keys\n // that would overwrite object prototype properties\n if (!options.plainObjects &&\n Object.prototype.hasOwnProperty(segment[1])) {\n\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(segment[1]);\n }\n\n // Loop through children appending to the array until we hit depth\n\n var i = 0;\n while ((segment = child.exec(key)) !== null && i < options.depth) {\n\n ++i;\n if (!options.plainObjects &&\n Object.prototype.hasOwnProperty(segment[1].replace(/\\[|\\]/g, ''))) {\n\n if (!options.allowPrototypes) {\n continue;\n }\n }\n keys.push(segment[1]);\n }\n\n // If there's a remainder, just add whatever is left\n\n if (segment) {\n keys.push('[' + key.slice(segment.index) + ']');\n }\n\n return internals.parseObject(keys, val, options);\n};\n\n\nmodule.exports = function (str, options) {\n\n options = options || {};\n options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;\n options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;\n options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;\n options.parseArrays = options.parseArrays !== false;\n options.allowDots = options.allowDots !== false;\n options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects;\n options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes;\n options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;\n options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n\n if (str === '' ||\n str === null ||\n typeof str === 'undefined') {\n\n return options.plainObjects ? Object.create(null) : {};\n }\n\n var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;\n var obj = options.plainObjects ? Object.create(null) : {};\n\n // Iterate over the keys and setup the new object\n\n var keys = Object.keys(tempObj);\n for (var i = 0, il = keys.length; i < il; ++i) {\n var key = keys[i];\n var newObj = internals.parseKeys(key, tempObj[key], options);\n obj = Utils.merge(obj, newObj, options);\n }\n\n return Utils.compact(obj);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/parse.js\n ** module id = 22\n ** module chunks = 0\n **/","// Load modules\n\nvar Utils = require('./utils');\n\n\n// Declare internals\n\nvar internals = {\n delimiter: '&',\n arrayPrefixGenerators: {\n brackets: function (prefix, key) {\n\n return prefix + '[]';\n },\n indices: function (prefix, key) {\n\n return prefix + '[' + key + ']';\n },\n repeat: function (prefix, key) {\n\n return prefix;\n }\n },\n strictNullHandling: false\n};\n\n\ninternals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) {\n\n if (typeof filter === 'function') {\n obj = filter(prefix, obj);\n }\n else if (Utils.isBuffer(obj)) {\n obj = obj.toString();\n }\n else if (obj instanceof Date) {\n obj = obj.toISOString();\n }\n else if (obj === null) {\n if (strictNullHandling) {\n return Utils.encode(prefix);\n }\n\n obj = '';\n }\n\n if (typeof obj === 'string' ||\n typeof obj === 'number' ||\n typeof obj === 'boolean') {\n\n return [Utils.encode(prefix) + '=' + Utils.encode(obj)];\n }\n\n var values = [];\n\n if (typeof obj === 'undefined') {\n return values;\n }\n\n var objKeys = Array.isArray(filter) ? filter : Object.keys(obj);\n for (var i = 0, il = objKeys.length; i < il; ++i) {\n var key = objKeys[i];\n\n if (Array.isArray(obj)) {\n values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter));\n }\n else {\n values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter));\n }\n }\n\n return values;\n};\n\n\nmodule.exports = function (obj, options) {\n\n options = options || {};\n var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;\n var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n var objKeys;\n var filter;\n if (typeof options.filter === 'function') {\n filter = options.filter;\n obj = filter('', obj);\n }\n else if (Array.isArray(options.filter)) {\n objKeys = filter = options.filter;\n }\n\n var keys = [];\n\n if (typeof obj !== 'object' ||\n obj === null) {\n\n return '';\n }\n\n var arrayFormat;\n if (options.arrayFormat in internals.arrayPrefixGenerators) {\n arrayFormat = options.arrayFormat;\n }\n else if ('indices' in options) {\n arrayFormat = options.indices ? 'indices' : 'repeat';\n }\n else {\n arrayFormat = 'indices';\n }\n\n var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];\n\n if (!objKeys) {\n objKeys = Object.keys(obj);\n }\n for (var i = 0, il = objKeys.length; i < il; ++i) {\n var key = objKeys[i];\n keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter));\n }\n\n return keys.join(delimiter);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/stringify.js\n ** module id = 23\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar superagent = require('superagent');\nvar debug = require('debug')('wpcom-xhr-request');\n\n/**\n * Export a single `request` function.\n */\n\nmodule.exports = request;\n\n/**\n * WordPress.com REST API base endpoint.\n */\n\nvar proxyOrigin = 'https://public-api.wordpress.com';\n\n/**\n * Default WordPress.com REST API Version.\n */\n\nvar defaultApiVersion = '1';\n\n/**\n * Performs an XMLHttpRequest against the WordPress.com REST API.\n *\n * @param {Object|String} params\n * @param {Function} fn\n * @api public\n */\n\nfunction request (params, fn) {\n\n if ('string' == typeof params) {\n params = { path: params };\n }\n\n var method = (params.method || 'GET').toLowerCase();\n debug('API HTTP Method: %o', method);\n delete params.method;\n\n var apiVersion = params.apiVersion || defaultApiVersion;\n delete params.apiVersion;\n\n proxyOrigin = params.proxyOrigin || proxyOrigin;\n delete params.proxyOrigin;\n\n var url = proxyOrigin + '/rest/v' + apiVersion + params.path;\n debug('API URL: %o', url);\n delete params.path;\n\n // create HTTP Request object\n var req = superagent[method](url);\n\n // Token authentication\n if (params.authToken) {\n req.set('Authorization', 'Bearer ' + params.authToken);\n delete params.authToken;\n }\n\n // URL querystring values\n if (params.query) {\n req.query(params.query);\n debug('API send URL querystring: %o', params.query);\n delete params.query;\n }\n\n // POST API request body\n if (params.body) {\n req.send(params.body);\n debug('API send POST body: ', params.body);\n delete params.body;\n }\n\n // POST FormData (for `multipart/form-data`, usually a file upload)\n if (params.formData) {\n for (var i = 0; i < params.formData.length; i++) {\n var data = params.formData[i];\n var key = data[0];\n var value = data[1];\n debug('adding FormData field %o', key);\n req.field(key, value);\n }\n }\n\n // start the request\n req.end(function (err, res){\n if (err && !res) {\n return fn(err);\n }\n\n var body = res.body;\n var headers = res.headers;\n var statusCode = res.status;\n debug('%o -> %o status code', url, statusCode);\n\n if (body && headers) {\n body._headers = headers;\n }\n\n if (!err) {\n return fn(null, body);\n }\n\n err = new Error();\n err.statusCode = statusCode;\n for (var i in body) {\n err[i] = body[i];\n }\n\n if (body && body.error) {\n err.name = toTitle(body.error) + 'Error';\n }\n\n fn(err);\n });\n\n return req.xhr;\n}\n\nfunction toTitle (str) {\n if (!str || 'string' !== typeof str) return '';\n return str.replace(/((^|_)[a-z])/g, function ($1) {\n return $1.toUpperCase().replace('_', '');\n });\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/index.js\n ** module id = 24\n ** module chunks = 0\n **/","\n/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\n\n/**\n * Use chrome.storage.local if we are in an app\n */\n\nvar storage;\n\nif (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')\n storage = chrome.storage.local;\nelse\n storage = localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // is webkit? http://stackoverflow.com/a/16459606/376773\n return ('WebkitAppearance' in document.documentElement.style) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (window.console && (console.firebug || (console.exception && console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n return JSON.stringify(v);\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs() {\n var args = arguments;\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return args;\n\n var c = 'color: ' + this.color;\n args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n return args;\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n storage.removeItem('debug');\n } else {\n storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = storage.debug;\n } catch(e) {}\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage(){\n try {\n return window.localStorage;\n } catch (e) {}\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/debug/browser.js\n ** module id = 25\n ** module chunks = 0\n **/","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = debug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lowercased letter, i.e. \"n\".\n */\n\nexports.formatters = {};\n\n/**\n * Previously assigned color.\n */\n\nvar prevColor = 0;\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n *\n * @return {Number}\n * @api private\n */\n\nfunction selectColor() {\n return exports.colors[prevColor++ % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction debug(namespace) {\n\n // define the `disabled` version\n function disabled() {\n }\n disabled.enabled = false;\n\n // define the `enabled` version\n function enabled() {\n\n var self = enabled;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // add the `color` if not set\n if (null == self.useColors) self.useColors = exports.useColors();\n if (null == self.color && self.useColors) self.color = selectColor();\n\n var args = Array.prototype.slice.call(arguments);\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %o\n args = ['%o'].concat(args);\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n if ('function' === typeof exports.formatArgs) {\n args = exports.formatArgs.apply(self, args);\n }\n var logFn = enabled.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n enabled.enabled = true;\n\n var fn = exports.enabled(namespace) ? enabled : disabled;\n\n fn.namespace = namespace;\n\n return fn;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n var split = (namespaces || '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/debug/debug.js\n ** module id = 26\n ** module chunks = 0\n **/","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} options\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options){\n options = options || {};\n if ('string' == typeof val) return parse(val);\n return options.long\n ? long(val)\n : short(val);\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n if (!match) return;\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction short(ms) {\n if (ms >= d) return Math.round(ms / d) + 'd';\n if (ms >= h) return Math.round(ms / h) + 'h';\n if (ms >= m) return Math.round(ms / m) + 'm';\n if (ms >= s) return Math.round(ms / s) + 's';\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction long(ms) {\n return plural(ms, d, 'day')\n || plural(ms, h, 'hour')\n || plural(ms, m, 'minute')\n || plural(ms, s, 'second')\n || ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) return;\n if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/debug/~/ms/index.js\n ** module id = 27\n ** module chunks = 0\n **/","/**\n * Module dependencies.\n */\n\nvar Emitter = require('emitter');\nvar reduce = require('reduce');\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? (this || self)\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nrequest.getXHR = function () {\n if (root.XMLHttpRequest\n && (!root.location || 'file:' != root.location.protocol\n || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n};\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n // responseText is accessible only if responseType is '' or 'text' and on older browsers\n this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')\n ? this.xhr.responseText\n : null;\n this.statusText = this.req.xhr.statusText;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text ? this.text : this.xhr.response)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && (str.length || str instanceof Object)\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n if (status === 1223) {\n status = 204;\n }\n\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self);\n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n return self.callback(err);\n }\n\n self.emit('response', res);\n\n if (err) {\n return self.callback(err, res);\n }\n\n if (res.status >= 200 && res.status < 300) {\n return self.callback(err, res);\n }\n\n var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');\n new_err.original = err;\n new_err.response = res;\n new_err.status = res.status;\n\n self.callback(err || new_err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new root.FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new root.FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj || isHost(data)) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n fn(err, res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = request.getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n\n // In IE9, reads to any property (e.g. status) off of an aborted XHR will\n // result in the error \"Could not complete the operation due to error c00c023f\"\n var status;\n try { status = xhr.status } catch(e) { status = 0; }\n\n if (0 == status) {\n if (self.timedout) return self.timeoutError();\n if (self.aborted) return;\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n var handleProgress = function(e){\n if (e.total > 0) {\n e.percent = e.loaded / e.total * 100;\n }\n self.emit('progress', e);\n };\n if (this.hasListeners('progress')) {\n xhr.onprogress = handleProgress;\n }\n try {\n if (xhr.upload && this.hasListeners('progress')) {\n xhr.upload.onprogress = handleProgress;\n }\n } catch(e) {\n // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.\n // Reported here:\n // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.timedout = true;\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/superagent/lib/client.js\n ** module id = 28\n ** module chunks = 0\n **/","\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/superagent/~/component-emitter/index.js\n ** module id = 29\n ** module chunks = 0\n **/","\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/superagent/~/reduce-component/index.js\n ** module id = 30\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///wpcom.js","webpack:///webpack/bootstrap f6bf303df898521c8380","webpack:///./index.js","webpack:///./~/debug/browser.js","webpack:///./lib/comment.js","webpack:///./lib/util/send-request.js","webpack:///./~/qs/lib/utils.js","webpack:///./lib/batch.js","webpack:///./lib/category.js","webpack:///./lib/commentlike.js","webpack:///./lib/follow.js","webpack:///./lib/like.js","webpack:///./lib/me.js","webpack:///./lib/media.js","webpack:///./lib/post.js","webpack:///./lib/reblog.js","webpack:///./lib/site.js","webpack:///./lib/tag.js","webpack:///./lib/users.js","webpack:///./lib/util/request.js","webpack:///./~/debug/debug.js","webpack:///./~/debug/~/ms/index.js","webpack:///./~/qs/lib/index.js","webpack:///./~/qs/lib/parse.js","webpack:///./~/qs/lib/stringify.js","webpack:///./~/wpcom-xhr-request/index.js","webpack:///./~/wpcom-xhr-request/~/debug/browser.js","webpack:///./~/wpcom-xhr-request/~/debug/debug.js","webpack:///./~/wpcom-xhr-request/~/debug/~/ms/index.js","webpack:///./~/wpcom-xhr-request/~/superagent/lib/client.js","webpack:///./~/wpcom-xhr-request/~/superagent/~/component-emitter/index.js","webpack:///./~/wpcom-xhr-request/~/superagent/~/reduce-component/index.js"],"names":["WPCOM","modules","__webpack_require__","moduleId","installedModules","exports","module","id","loaded","call","m","c","p","token","reqHandler","this","debug","substring","request","params","fn","authToken","request_handler","req","Req","apiVersion","Me","Site","Users","Batch","sendRequest","DEFAULT_ASYNC_TIMEOUT","prototype","me","site","users","batch","freshlyPressed","query","get","body","msg","console","warn","log","Promise","timeout","_this","delay","arguments","length","undefined","cancelTimeout","timer","resolve","reject","setTimeout","Error","clearTimeout","race","then","useColors","document","documentElement","style","window","firebug","exception","table","navigator","userAgent","toLowerCase","match","parseInt","RegExp","$1","formatArgs","args","namespace","humanize","diff","color","concat","Array","slice","index","lastC","replace","splice","Function","apply","save","namespaces","storage","removeItem","e","load","r","localstorage","localStorage","chrome","local","colors","formatters","j","v","JSON","stringify","enable","Comment","cid","pid","sid","wpcom","_cid","_pid","_sid","CommentLike","path","replies","add","content","post","update","put","reply","del","like","likesList","qs","debug_res","method","toUpperCase","proxyOrigin","arrayFormat","err","res","internals","hexTable","h","toString","arrayToObject","source","options","obj","plainObjects","Object","create","i","il","merge","target","isArray","push","keys","k","kl","key","value","hasOwnProperty","decode","str","decodeURIComponent","encode","out","charCodeAt","compact","refs","lookup","indexOf","compacted","isRegExp","isBuffer","constructor","urls","url","run","Category","slug","_slug","mine","state","Follow","site_id","follow","unfollow","Like","sites","likes","groups","Media","_id","fs","addFiles","files","formData","f","isStream","isFile","param","createReadStream","_readableState","File","file","addUrls","media","media_urls","attrs","Post","Reblog","getBySlug","data","ID","restore","related","reblog","comment","comments","destination_site_id","to","dest","note","encodeURIComponent","list","subpath","listMethod","_publicAPI","Tag","resources","isarr","name","addPost","deletePost","addMediaFiles","addMediaUrls","deleteMedia","cat","category","tag","renderShortcode","TypeError","shortcode","renderEmbed","embed_url","statsReferrersSpamNew","domain","statsReferrersSpamDelete","statsVideo","videoId","statsPostViews","postId","suggest","selectColor","prevColor","disabled","enabled","self","curr","Date","ms","prevTime","prev","coerce","format","formatter","val","logFn","bind","split","len","skips","substr","names","disable","test","stack","message","parse","exec","n","parseFloat","type","y","d","s","short","Math","round","long","plural","floor","ceil","Stringify","Parse","Utils","delimiter","depth","arrayLimit","parameterLimit","strictNullHandling","allowPrototypes","parseValues","parts","Infinity","part","pos","parseObject","chain","root","shift","cleanRoot","indexString","isNaN","parseArrays","parseKeys","allowDots","parent","child","segment","tempObj","newObj","arrayPrefixGenerators","brackets","prefix","indices","repeat","generateArrayPrefix","filter","toISOString","values","objKeys","join","defaultApiVersion","superagent","set","send","field","end","headers","statusCode","status","_headers","error","toTitle","xhr","noop","isHost","isObject","serialize","pairs","parseString","pair","parseHeader","line","lines","fields","pop","trim","reduce","Response","text","responseType","responseText","statusText","setStatusProperties","header","getAllResponseHeaders","getResponseHeader","setHeaderProperties","parseBody","response","Request","Emitter","_query","_header","on","original","callback","emit","new_err","getXHR","XMLHttpRequest","location","protocol","ActiveXObject","serializeObject","types","html","json","xml","urlencoded","form","form-data","application/x-www-form-urlencoded","application/json","ct","statusType","info","ok","clientError","serverError","toError","accepted","noContent","badRequest","unauthorized","notAcceptable","notFound","forbidden","use","_timeout","_timer","abort","aborted","unset","getHeader","accept","auth","user","pass","btoa","_formData","FormData","append","attach","filename","_data","_callback","crossDomainError","crossDomain","timeoutError","withCredentials","_withCredentials","onreadystatechange","readyState","timedout","handleProgress","total","percent","hasListeners","onprogress","upload","open","setRequestHeader","head","patch","mixin","addEventListener","event","_callbacks","once","off","removeListener","removeAllListeners","removeEventListener","callbacks","cb","listeners","arr","initial","idx"],"mappings":"AAAA,GAAIA,OACK,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAE,WACAE,GAAAJ,EACAK,QAAA,EAUA,OANAP,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,QAAA,EAGAF,EAAAD,QAvBA,GAAAD,KAqCA,OATAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,GAGAV,EAAA,KDOM,SAASI,EAAQD,EAASH,GEPhC,QAASF,GAAMa,EAAOC,GACpB,MAAMC,gBAAgBf,IAKlB,kBAAsBa,KACxBC,EAAaD,EACbA,EAAQ,MAGNA,IACFG,EAAM,qBAAsBH,EAAMI,UAAU,EAAG,IAC/CF,KAAKF,MAAQA,GAIVC,EAcHC,KAAKG,QAAUJ,GAbfE,EAAM,0DAEND,KAAKG,QAAU,SAAUC,EAAQC,GAQ/B,MAPAD,GAASA,MAGLN,I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y,S9Bm0JM,SAAS5C,EAAQD,G+B19JvBC,EAAAD,QAAA,SAAAqc,EAAAtb,EAAAub,GAOA,IANA,GAAAC,GAAA,EACA/L,EAAA6L,EAAAxZ,OACA+M,EAAA,GAAAhN,UAAAC,OACAyZ,EACAD,EAAAE,KAEA/L,EAAA+L,GACA3M,EAAA7O,EAAAX,KAAA,KAAAwP,EAAAyM,EAAAE,OAAAF,EAGA,OAAAzM","file":"wpcom.js","sourcesContent":["var WPCOM =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar request_handler = __webpack_require__(24);\n\t\n\t/**\n\t * Local module dependencies.\n\t */\n\t\n\tvar Me = __webpack_require__(10);\n\tvar Site = __webpack_require__(14);\n\tvar Users = __webpack_require__(16);\n\tvar Batch = __webpack_require__(5);\n\tvar Req = __webpack_require__(17);\n\tvar sendRequest = __webpack_require__(3);\n\tvar debug = __webpack_require__(1)('wpcom');\n\t\n\t/**\n\t * Local module constants\n\t */\n\tvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\t\n\t/**\n\t * XMLHttpRequest (and CORS) API access method.\n\t *\n\t * API authentication is done via an (optional) access `token`,\n\t * which needs to be retrieved via OAuth.\n\t *\n\t * Request Handler is optional and XHR is defined as default.\n\t *\n\t * @param {String} [token] - OAuth API access token\n\t * @param {Function} [reqHandler] - function Request Handler\n\t * @public\n\t */\n\t\n\tfunction WPCOM(token, reqHandler) {\n\t if (!(this instanceof WPCOM)) {\n\t return new WPCOM(token, reqHandler);\n\t }\n\t\n\t // `token` is optional\n\t if ('function' === typeof token) {\n\t reqHandler = token;\n\t token = null;\n\t }\n\t\n\t if (token) {\n\t debug('Token defined: %s…', token.substring(0, 6));\n\t this.token = token;\n\t }\n\t\n\t // Set default request handler\n\t if (!reqHandler) {\n\t debug('No request handler. Adding default XHR request handler');\n\t\n\t this.request = function (params, fn) {\n\t params = params || {};\n\t\n\t // token is optional\n\t if (token) {\n\t params.authToken = token;\n\t }\n\t\n\t return request_handler(params, fn);\n\t };\n\t } else {\n\t this.request = reqHandler;\n\t }\n\t\n\t // Add Req instance\n\t this.req = new Req(this);\n\t\n\t // Default api version;\n\t this.apiVersion = '1.1';\n\t}\n\t\n\t/**\n\t * Get `Me` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.me = function () {\n\t return new Me(this);\n\t};\n\t\n\t/**\n\t * Get `Site` object instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.site = function (id) {\n\t return new Site(id, this);\n\t};\n\t\n\t/**\n\t * Get `Users` object instance\n\t *\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.users = function () {\n\t return new Users(this);\n\t};\n\t\n\tWPCOM.prototype.batch = function () {\n\t return new Batch(this);\n\t};\n\t\n\t/**\n\t * List Freshly Pressed Posts\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn callback function\n\t * @api public\n\t */\n\t\n\tWPCOM.prototype.freshlyPressed = function (query, fn) {\n\t return this.req.get('/freshly-pressed', query, fn);\n\t};\n\t\n\t/**\n\t * Expose send-request\n\t * @TODO: use `this.req` instead of this method\n\t */\n\t\n\tWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n\t var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n\t if (console && console.warn) {\n\t //eslint-disable-line no-console\n\t console.warn(msg); //eslint-disable-line no-console\n\t } else {\n\t console.log(msg); //eslint-disable-line no-console\n\t }\n\t\n\t return sendRequest.call(this, params, query, body, fn);\n\t};\n\t\n\tif (!Promise.prototype.timeout) {\n\t /**\n\t * Returns a new promise with a deadline\n\t *\n\t * After the timeout interval, the promise will\n\t * reject. If the actual promise settles before\n\t * the deadline, the timer is cancelled.\n\t *\n\t * @param {number} delay how many ms to wait\n\t * @returns {Promise}\n\t */\n\t Promise.prototype.timeout = function () {\n\t var _this = this;\n\t\n\t var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0];\n\t\n\t var cancelTimeout = undefined,\n\t timer = undefined,\n\t timeout = undefined;\n\t\n\t timeout = new Promise(function (resolve, reject) {\n\t timer = setTimeout(function () {\n\t reject(new Error('Action timed out while waiting for response.'));\n\t }, delay);\n\t });\n\t\n\t cancelTimeout = function () {\n\t clearTimeout(timer);\n\t return _this;\n\t };\n\t\n\t return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]);\n\t };\n\t}\n\t\n\t/**\n\t * Expose `WPCOM` module\n\t */\n\t\n\tmodule.exports = WPCOM;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the web browser implementation of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = __webpack_require__(18);\n\texports.log = log;\n\texports.formatArgs = formatArgs;\n\texports.save = save;\n\texports.load = load;\n\texports.useColors = useColors;\n\texports.storage = 'undefined' != typeof chrome\n\t && 'undefined' != typeof chrome.storage\n\t ? chrome.storage.local\n\t : localstorage();\n\t\n\t/**\n\t * Colors.\n\t */\n\t\n\texports.colors = [\n\t 'lightseagreen',\n\t 'forestgreen',\n\t 'goldenrod',\n\t 'dodgerblue',\n\t 'darkorchid',\n\t 'crimson'\n\t];\n\t\n\t/**\n\t * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n\t * and the Firebug extension (any Firefox version) are known\n\t * to support \"%c\" CSS customizations.\n\t *\n\t * TODO: add a `localStorage` variable to explicitly enable/disable colors\n\t */\n\t\n\tfunction useColors() {\n\t // is webkit? http://stackoverflow.com/a/16459606/376773\n\t return ('WebkitAppearance' in document.documentElement.style) ||\n\t // is firebug? http://stackoverflow.com/a/398120/376773\n\t (window.console && (console.firebug || (console.exception && console.table))) ||\n\t // is firefox >= v31?\n\t // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n\t}\n\t\n\t/**\n\t * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n\t */\n\t\n\texports.formatters.j = function(v) {\n\t return JSON.stringify(v);\n\t};\n\t\n\t\n\t/**\n\t * Colorize log arguments if enabled.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction formatArgs() {\n\t var args = arguments;\n\t var useColors = this.useColors;\n\t\n\t args[0] = (useColors ? '%c' : '')\n\t + this.namespace\n\t + (useColors ? ' %c' : ' ')\n\t + args[0]\n\t + (useColors ? '%c ' : ' ')\n\t + '+' + exports.humanize(this.diff);\n\t\n\t if (!useColors) return args;\n\t\n\t var c = 'color: ' + this.color;\n\t args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\t\n\t // the final \"%c\" is somewhat tricky, because there could be other\n\t // arguments passed either before or after the %c, so we need to\n\t // figure out the correct index to insert the CSS into\n\t var index = 0;\n\t var lastC = 0;\n\t args[0].replace(/%[a-z%]/g, function(match) {\n\t if ('%%' === match) return;\n\t index++;\n\t if ('%c' === match) {\n\t // we only are interested in the *last* %c\n\t // (the user may have provided their own)\n\t lastC = index;\n\t }\n\t });\n\t\n\t args.splice(lastC, 0, c);\n\t return args;\n\t}\n\t\n\t/**\n\t * Invokes `console.log()` when available.\n\t * No-op when `console.log` is not a \"function\".\n\t *\n\t * @api public\n\t */\n\t\n\tfunction log() {\n\t // this hackery is required for IE8/9, where\n\t // the `console.log` function doesn't have 'apply'\n\t return 'object' === typeof console\n\t && console.log\n\t && Function.prototype.apply.call(console.log, console, arguments);\n\t}\n\t\n\t/**\n\t * Save `namespaces`.\n\t *\n\t * @param {String} namespaces\n\t * @api private\n\t */\n\t\n\tfunction save(namespaces) {\n\t try {\n\t if (null == namespaces) {\n\t exports.storage.removeItem('debug');\n\t } else {\n\t exports.storage.debug = namespaces;\n\t }\n\t } catch(e) {}\n\t}\n\t\n\t/**\n\t * Load `namespaces`.\n\t *\n\t * @return {String} returns the previously persisted debug modes\n\t * @api private\n\t */\n\t\n\tfunction load() {\n\t var r;\n\t try {\n\t r = exports.storage.debug;\n\t } catch(e) {}\n\t return r;\n\t}\n\t\n\t/**\n\t * Enable namespaces listed in `localStorage.debug` initially.\n\t */\n\t\n\texports.enable(load());\n\t\n\t/**\n\t * Localstorage attempts to return the localstorage.\n\t *\n\t * This is necessary because safari throws\n\t * when a user disables cookies/localstorage\n\t * and you attempt to access it.\n\t *\n\t * @return {LocalStorage}\n\t * @api private\n\t */\n\t\n\tfunction localstorage(){\n\t try {\n\t return window.localStorage;\n\t } catch (e) {}\n\t}\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar CommentLike = __webpack_require__(7);\n\t\n\t/**\n\t * Comment methods\n\t *\n\t * @param {String} [cid] comment id\n\t * @param {String} [pid] post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Comment(cid, pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Comment)) {\n\t return new Comment(cid, pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Return a single Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Return recent comments for a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.replies = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a comment on a post\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.add = function (query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.update = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Create a Comment as a reply to another Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.reply = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t body = 'string' === typeof body ? { content: body } : body;\n\t\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.del = Comment.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Create a `CommentLike` instance\n\t *\n\t * @api public\n\t */\n\t\n\tComment.prototype.like = function () {\n\t return CommentLike(this._cid, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get comment likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tComment.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Comment` module\n\t */\n\t\n\tmodule.exports = Comment;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies\n\t */\n\t\n\tvar qs = __webpack_require__(20);\n\tvar debug = __webpack_require__(1)('wpcom:send-request');\n\tvar debug_res = __webpack_require__(1)('wpcom:send-request:res');\n\t\n\t/**\n\t * Request to WordPress REST API\n\t *\n\t * @param {String|Object} params\n\t * @param {Object} [query]\n\t * @param {Object} [body]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tmodule.exports = function (params, query, body, fn) {\n\t var _this = this;\n\t\n\t // `params` can be just the path (String)\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t debug('sendRequest(%o)', params.path);\n\t\n\t // set `method` request param\n\t params.method = (params.method || 'get').toUpperCase();\n\t\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // `body` is optional\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = null;\n\t }\n\t\n\t // query could be `null`\n\t query = query || {};\n\t\n\t // Handle special query parameters\n\t // - `apiVersion`\n\t if (query.apiVersion) {\n\t params.apiVersion = query.apiVersion;\n\t debug('apiVersion: %o', params.apiVersion);\n\t delete query.apiVersion;\n\t } else {\n\t params.apiVersion = this.apiVersion;\n\t }\n\t\n\t // - `proxyOrigin`\n\t if (query.proxyOrigin) {\n\t params.proxyOrigin = query.proxyOrigin;\n\t debug('proxyOrigin: %o', params.proxyOrigin);\n\t delete query.proxyOrigin;\n\t }\n\t\n\t // Stringify query object before to send\n\t query = qs.stringify(query, { arrayFormat: 'brackets' });\n\t\n\t // pass `query` and/or `body` to request params\n\t params.query = query;\n\t\n\t if (body) {\n\t params.body = body;\n\t }\n\t debug('params: %o', params);\n\t\n\t // if callback is provided, behave traditionally\n\t if ('function' === typeof fn) {\n\t // request method\n\t return this.request(params, function (err, res) {\n\t debug_res(res);\n\t fn(err, res);\n\t });\n\t }\n\t\n\t // but if not, return a Promise\n\t return new Promise(function (resolve, reject) {\n\t _this.request(params, function (err, res) {\n\t debug_res(res);\n\t err ? reject(err) : resolve(res);\n\t });\n\t });\n\t};\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t// Load modules\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {};\n\tinternals.hexTable = new Array(256);\n\tfor (var h = 0; h < 256; ++h) {\n\t internals.hexTable[h] = '%' + ((h < 16 ? '0' : '') + h.toString(16)).toUpperCase();\n\t}\n\t\n\t\n\texports.arrayToObject = function (source, options) {\n\t\n\t var obj = options.plainObjects ? Object.create(null) : {};\n\t for (var i = 0, il = source.length; i < il; ++i) {\n\t if (typeof source[i] !== 'undefined') {\n\t\n\t obj[i] = source[i];\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\texports.merge = function (target, source, options) {\n\t\n\t if (!source) {\n\t return target;\n\t }\n\t\n\t if (typeof source !== 'object') {\n\t if (Array.isArray(target)) {\n\t target.push(source);\n\t }\n\t else if (typeof target === 'object') {\n\t target[source] = true;\n\t }\n\t else {\n\t target = [target, source];\n\t }\n\t\n\t return target;\n\t }\n\t\n\t if (typeof target !== 'object') {\n\t target = [target].concat(source);\n\t return target;\n\t }\n\t\n\t if (Array.isArray(target) &&\n\t !Array.isArray(source)) {\n\t\n\t target = exports.arrayToObject(target, options);\n\t }\n\t\n\t var keys = Object.keys(source);\n\t for (var k = 0, kl = keys.length; k < kl; ++k) {\n\t var key = keys[k];\n\t var value = source[key];\n\t\n\t if (!Object.prototype.hasOwnProperty.call(target, key)) {\n\t target[key] = value;\n\t }\n\t else {\n\t target[key] = exports.merge(target[key], value, options);\n\t }\n\t }\n\t\n\t return target;\n\t};\n\t\n\t\n\texports.decode = function (str) {\n\t\n\t try {\n\t return decodeURIComponent(str.replace(/\\+/g, ' '));\n\t } catch (e) {\n\t return str;\n\t }\n\t};\n\t\n\texports.encode = function (str) {\n\t\n\t // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n\t // It has been adapted here for stricter adherence to RFC 3986\n\t if (str.length === 0) {\n\t return str;\n\t }\n\t\n\t if (typeof str !== 'string') {\n\t str = '' + str;\n\t }\n\t\n\t var out = '';\n\t for (var i = 0, il = str.length; i < il; ++i) {\n\t var c = str.charCodeAt(i);\n\t\n\t if (c === 0x2D || // -\n\t c === 0x2E || // .\n\t c === 0x5F || // _\n\t c === 0x7E || // ~\n\t (c >= 0x30 && c <= 0x39) || // 0-9\n\t (c >= 0x41 && c <= 0x5A) || // a-z\n\t (c >= 0x61 && c <= 0x7A)) { // A-Z\n\t\n\t out += str[i];\n\t continue;\n\t }\n\t\n\t if (c < 0x80) {\n\t out += internals.hexTable[c];\n\t continue;\n\t }\n\t\n\t if (c < 0x800) {\n\t out += internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)];\n\t continue;\n\t }\n\t\n\t if (c < 0xD800 || c >= 0xE000) {\n\t out += internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n\t continue;\n\t }\n\t\n\t ++i;\n\t c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF));\n\t out += internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n\t }\n\t\n\t return out;\n\t};\n\t\n\texports.compact = function (obj, refs) {\n\t\n\t if (typeof obj !== 'object' ||\n\t obj === null) {\n\t\n\t return obj;\n\t }\n\t\n\t refs = refs || [];\n\t var lookup = refs.indexOf(obj);\n\t if (lookup !== -1) {\n\t return refs[lookup];\n\t }\n\t\n\t refs.push(obj);\n\t\n\t if (Array.isArray(obj)) {\n\t var compacted = [];\n\t\n\t for (var i = 0, il = obj.length; i < il; ++i) {\n\t if (typeof obj[i] !== 'undefined') {\n\t compacted.push(obj[i]);\n\t }\n\t }\n\t\n\t return compacted;\n\t }\n\t\n\t var keys = Object.keys(obj);\n\t for (i = 0, il = keys.length; i < il; ++i) {\n\t var key = keys[i];\n\t obj[key] = exports.compact(obj[key], refs);\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\texports.isRegExp = function (obj) {\n\t\n\t return Object.prototype.toString.call(obj) === '[object RegExp]';\n\t};\n\t\n\t\n\texports.isBuffer = function (obj) {\n\t\n\t if (obj === null ||\n\t typeof obj === 'undefined') {\n\t\n\t return false;\n\t }\n\t\n\t return !!(obj.constructor &&\n\t obj.constructor.isBuffer &&\n\t obj.constructor.isBuffer(obj));\n\t};\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Batch` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Batch(wpcom) {\n\t if (!(this instanceof Batch)) {\n\t return new Batch(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t this.urls = [];\n\t}\n\t\n\t/**\n\t * Add url to batch requests\n\t *\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tBatch.prototype.add = function (url) {\n\t this.urls.push(url);\n\t return this;\n\t};\n\t\n\t/**\n\t * Run the batch request\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tBatch.prototype.run = function (query, fn) {\n\t if (query === undefined) query = {};\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t // add urls to query object\n\t query['urls'] = this.urls;\n\t\n\t return this.wpcom.req.get('/batch', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Batch` module\n\t */\n\t\n\tmodule.exports = Batch;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Category methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Category(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Category)) {\n\t return new Category(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set category `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tCategory.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit category\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete category\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Category` module\n\t */\n\t\n\tmodule.exports = Category;\n\n/***/ },\n/* 7 */\n/***/ function(module, exports) {\n\n\t/**\n\t * CommentLike methods\n\t *\n\t * @param {String} cid comment id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction CommentLike(cid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!cid) {\n\t throw new Error('`comment id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof CommentLike)) {\n\t return new CommentLike(cid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._cid = cid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.mine = CommentLike.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n\t return this.wpcom.req.post(path, query, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Comment\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tCommentLike.prototype.del = CommentLike.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `CommentLike` module\n\t */\n\t\n\tmodule.exports = CommentLike;\n\n/***/ },\n/* 8 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Follow\n\t *\n\t * @param {String} site_id - site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Follow(site_id, wpcom) {\n\t if (!site_id) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Follow)) {\n\t return new Follow(site_id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = site_id;\n\t}\n\t\n\t/**\n\t * Get the follow status for current\n\t * user on current blog sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.mine = Follow.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Follow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.follow = Follow.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Unfollow the site\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tFollow.prototype.unfollow = Follow.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/follows/mine/delete';\n\t return this.wpcom.req.del(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose `Follow` module\n\t */\n\t\n\tmodule.exports = Follow;\n\n/***/ },\n/* 9 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Like methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Like(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Like)) {\n\t return new Like(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your Like status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.mine = Like.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Like a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.add = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Remove your Like from a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tLike.prototype.del = Like.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Like` module\n\t */\n\t\n\tmodule.exports = Like;\n\n/***/ },\n/* 10 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Me` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Me(wpcom) {\n\t if (!(this instanceof Me)) {\n\t return new Me(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Meta data about auth token's User\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/me', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's sites\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api private\n\t */\n\t\n\tMe.prototype.sites = function (query, fn) {\n\t return this.wpcom.req.get('/me/sites', query, fn);\n\t};\n\t\n\t/**\n\t * List the currently authorized user's likes\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.likes = function (query, fn) {\n\t return this.wpcom.req.get('/me/likes', query, fn);\n\t};\n\t\n\t/**\n\t * A list of the current user's group\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMe.prototype.groups = function (query, fn) {\n\t return this.wpcom.req.get('/me/groups', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Me` module\n\t */\n\t\n\tmodule.exports = Me;\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar fs = __webpack_require__(23);\n\tvar debug = __webpack_require__(1)('wpcom:media');\n\t\n\t/**\n\t * Media methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Media(id, sid, wpcom) {\n\t if (!(this instanceof Media)) {\n\t return new Media(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._id = id;\n\t\n\t if (!this._id) {\n\t debug('WARN: media `id` is not defined');\n\t }\n\t}\n\t\n\t/**\n\t * Get media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Edit media\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Add media file\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Object|Array} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addFiles = function (query, files, fn) {\n\t if (undefined === fn) {\n\t if (undefined === files) {\n\t files = query;\n\t query = {};\n\t } else if ('function' === typeof files) {\n\t fn = files;\n\t files = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var params = {\n\t path: '/sites/' + this._sid + '/media/new',\n\t formData: []\n\t };\n\t\n\t // process formData\n\t files = Array.isArray(files) ? files : [files];\n\t\n\t var i, f, isStream, isFile, k, param;\n\t for (i = 0; i < files.length; i++) {\n\t f = files[i];\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t\n\t isStream = !!f._readableState;\n\t isFile = 'undefined' !== typeof File && f instanceof File;\n\t\n\t debug('is stream: %s', isStream);\n\t debug('is file: %s', isFile);\n\t\n\t if (!isFile && !isStream) {\n\t // process file attributes like as `title`, `description`, ...\n\t for (k in f) {\n\t debug('add %o => %o', k, f[k]);\n\t if ('file' !== k) {\n\t param = 'attrs[' + i + '][' + k + ']';\n\t params.formData.push([param, f[k]]);\n\t }\n\t }\n\t // set file path\n\t f = f.file;\n\t f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\t }\n\t\n\t params.formData.push(['media[]', f]);\n\t }\n\t\n\t return this.wpcom.req.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Add media files from URL\n\t *\n\t * @param {Object} [query]\n\t * @param {String|Array|Object} files\n\t * @param {Function} fn\n\t */\n\t\n\tMedia.prototype.addUrls = function (query, media, fn) {\n\t if (undefined === fn) {\n\t if (undefined === media) {\n\t media = query;\n\t query = {};\n\t } else if ('function' === typeof media) {\n\t fn = media;\n\t media = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/media/new';\n\t var body = { media_urls: [] };\n\t\n\t // process formData\n\t var i, m, url, k;\n\t\n\t media = Array.isArray(media) ? media : [media];\n\t for (i = 0; i < media.length; i++) {\n\t m = media[i];\n\t\n\t if ('string' === typeof m) {\n\t url = m;\n\t } else {\n\t if (!body.attrs) {\n\t body.attrs = [];\n\t }\n\t\n\t // add attributes\n\t body.attrs[i] = {};\n\t for (k in m) {\n\t if ('url' !== k) {\n\t body.attrs[i][k] = m[k];\n\t }\n\t }\n\t url = m.url;\n\t }\n\t\n\t // push url into [media_url]\n\t body.media_urls.push(url);\n\t }\n\t\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete media\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Media` module\n\t */\n\t\n\tmodule.exports = Media;\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Like = __webpack_require__(9);\n\tvar Reblog = __webpack_require__(13);\n\tvar Comment = __webpack_require__(2);\n\tvar debug = __webpack_require__(1)('wpcom:post');\n\t\n\t/**\n\t * Post methods\n\t *\n\t * @param {String} id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Post(id, sid, wpcom) {\n\t if (!(this instanceof Post)) {\n\t return new Post(id, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t\n\t // set `id` and/or `slug` properties\n\t id = id || {};\n\t if ('object' !== typeof id) {\n\t this._id = id;\n\t } else {\n\t this._id = id.id;\n\t this._slug = id.slug;\n\t }\n\t}\n\t\n\t/**\n\t * Set post `id`\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tPost.prototype.id = function (id) {\n\t this._id = id;\n\t};\n\t\n\t/**\n\t * Set post `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tPost.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.get = function (query, fn) {\n\t if (!this._id && this._slug) {\n\t return this.getBySlug(query, fn);\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get post by slug\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.getBySlug = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.add = function (query, body, fn) {\n\t var _this = this;\n\t\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/new';\n\t\n\t return this.wpcom.req.post(path, query, body).then(function (data) {\n\t // update POST object\n\t _this._id = data.ID;\n\t debug('Set post _id: %s', _this._id);\n\t\n\t _this._slug = data.slug;\n\t debug('Set post _slug: %s', _this._slug);\n\t\n\t if ('function' === typeof fn) {\n\t fn(null, data);\n\t } else {\n\t return Promise.resolve(data);\n\t }\n\t })['catch'](function (err) {\n\t if ('function' === typeof fn) {\n\t fn(err);\n\t } else {\n\t return Promise.reject(err);\n\t }\n\t });\n\t};\n\t\n\t/**\n\t * Edit post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.del = Post.prototype['delete'] = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Restore post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.restore = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n\t return this.wpcom.req.put(path, query, null, fn);\n\t};\n\t\n\t/**\n\t * Get post likes list\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.likesList = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Search within a site for related posts\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.related = function (body, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n\t return this.wpcom.req.put(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Create a `Like` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.like = function () {\n\t return new Like(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Reblog` instance\n\t *\n\t * @api public\n\t */\n\t\n\tPost.prototype.reblog = function () {\n\t return new Reblog(this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} [cid] comment id\n\t * @api public\n\t */\n\t\n\tPost.prototype.comment = function (cid) {\n\t return new Comment(cid, this._id, this._sid, this.wpcom);\n\t};\n\t\n\t/**\n\t * Return recent comments\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tPost.prototype.comments = function (query, fn) {\n\t var comment = new Comment(null, this._id, this._sid, this.wpcom);\n\t return comment.replies(query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Post` module\n\t */\n\t\n\tmodule.exports = Post;\n\n/***/ },\n/* 13 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Reblog methods\n\t *\n\t * @param {String} pid post id\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Reblog(pid, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!pid) {\n\t throw new Error('`post id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Reblog)) {\n\t return new Reblog(pid, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._pid = pid;\n\t this._sid = sid;\n\t}\n\t\n\t/**\n\t * Get your reblog status for a Post\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.mine = Reblog.prototype.state = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.add = function (query, body, fn) {\n\t if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t\n\t if (body && !body.destination_site_id) {\n\t return fn(new Error('destination_site_id is not defined'));\n\t }\n\t\n\t var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Reblog a post to\n\t * It's almost an alias of Reblogs#add\n\t *\n\t * @param {Number|String} dest site id destination\n\t * @param {String} [note]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReblog.prototype.to = function (dest, note, fn) {\n\t if (undefined === fn) {\n\t if (undefined === note) {\n\t note = null;\n\t } else if ('function' === typeof note) {\n\t fn = note;\n\t note = null;\n\t }\n\t }\n\t\n\t return this.add({ note: note, destination_site_id: dest }, fn);\n\t};\n\t\n\t/**\n\t * Expose `Reblog` module\n\t */\n\t\n\tmodule.exports = Reblog;\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Post = __webpack_require__(12);\n\tvar Category = __webpack_require__(6);\n\tvar Tag = __webpack_require__(15);\n\tvar Media = __webpack_require__(11);\n\tvar Comment = __webpack_require__(2);\n\tvar Follow = __webpack_require__(8);\n\tvar debug = __webpack_require__(1)('wpcom:site');\n\t\n\t/**\n\t * Resources array\n\t * A list of endpoints with the same structure\n\t */\n\t\n\tvar resources = ['categories', 'comments', 'follows', 'media', 'posts', 'shortcodes', 'embeds', ['pageTemplates', 'page-templates'], ['stats', 'stats'], ['statsClicks', 'stats/clicks'], ['statsComments', 'stats/comments'], ['statsCommentFollowers', 'stats/comment-followers'], ['statsCountryViews', 'stats/country-views'], ['statsFollowers', 'stats/followers'], ['statsPublicize', 'stats/publicize'], ['statsReferrers', 'stats/referrers'], ['statsSearchTerms', 'stats/search-terms'], ['statsStreak', 'stats/streak'], ['statsSummary', 'stats/summary'], ['statsTags', 'stats/tags'], ['statsTopAuthors', 'stats/top-authors'], ['statsTopPosts', 'stats/top-posts'], ['statsVideoPlays', 'stats/video-plays'], ['statsVisits', 'stats/visits'], 'tags', 'users'];\n\t\n\t/**\n\t * Create a Site instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Site(id, wpcom) {\n\t if (!(this instanceof Site)) {\n\t return new Site(id, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t\n\t debug('set %o site id', id);\n\t this._id = encodeURIComponent(id);\n\t}\n\t\n\t/**\n\t * Require site information\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.get = function (query, fn) {\n\t return this.wpcom.req.get('/sites/' + this._id, query, fn);\n\t};\n\t\n\t/**\n\t * List method builder\n\t *\n\t * @param {String} subpath\n\t * @param {Function}\n\t * @api private\n\t */\n\t\n\tfunction list(subpath) {\n\t\n\t /**\n\t * Create and return the List method\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\t var listMethod = function listMethod(query, fn) {\n\t var path = '/sites/' + this._id + '/' + subpath;\n\t return this.wpcom.req.get(path, query, fn);\n\t };\n\t listMethod._publicAPI = true;\n\t return listMethod;\n\t}\n\t\n\t// walk for each resource and create related method\n\tvar i, res, isarr, name, subpath;\n\tfor (i = 0; i < resources.length; i++) {\n\t res = resources[i];\n\t isarr = Array.isArray(res);\n\t\n\t name = isarr ? res[0] : res + 'List';\n\t subpath = isarr ? res[1] : res;\n\t\n\t debug('adding method: %o - sub-path: %o - version: %s', 'site.' + name + '()', subpath);\n\t Site.prototype[name] = list(subpath);\n\t}\n\t\n\t/**\n\t * :POST:\n\t * Create a `Post` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.post = function (id) {\n\t return new Post(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Add a new blog post\n\t *\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addPost = function (body, fn) {\n\t var post = new Post(null, this._id, this.wpcom);\n\t return post.add(body, fn);\n\t};\n\t\n\t/**\n\t * :POST:\n\t * Delete a blog post\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} remove Post instance\n\t */\n\t\n\tSite.prototype.deletePost = function (id, fn) {\n\t var post = new Post(id, this._id, this.wpcom);\n\t return post['delete'](fn);\n\t};\n\t\n\t/**\n\t * Create a `Media` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.media = function (id) {\n\t return new Media(id, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Add a media from a file\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaFiles = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addFiles(query, files, fn);\n\t};\n\t\n\t/**\n\t * Add a new media from url\n\t *\n\t * @param {Object} [query]\n\t * @param {Array|String} files\n\t * @param {Function} fn\n\t * @return {Post} new Post instance\n\t */\n\t\n\tSite.prototype.addMediaUrls = function (query, files, fn) {\n\t var media = new Media(null, this._id, this.wpcom);\n\t return media.addUrls(query, files, fn);\n\t};\n\t\n\t/**\n\t * Delete a blog media\n\t *\n\t * @param {String} id\n\t * @param {Function} fn\n\t * @return {Post} removed Media instance\n\t */\n\t\n\tSite.prototype.deleteMedia = function (id, fn) {\n\t var media = new Media(id, this._id, this.wpcom);\n\t return media.del(fn);\n\t};\n\t\n\t/**\n\t * Create a `Comment` instance\n\t *\n\t * @param {String} id\n\t * @api public\n\t */\n\t\n\tSite.prototype.comment = function (id) {\n\t return new Comment(id, null, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Follow` instance\n\t *\n\t * @api public\n\t */\n\t\n\tSite.prototype.follow = function () {\n\t return new Follow(this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Category` instance\n\t * Set `cat` alias\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.cat = Site.prototype.category = function (slug) {\n\t return new Category(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Create a `Tag` instance\n\t *\n\t * @param {String} [slug]\n\t * @api public\n\t */\n\t\n\tSite.prototype.tag = function (slug) {\n\t return new Tag(slug, this._id, this.wpcom);\n\t};\n\t\n\t/**\n\t * Get a rendered shortcode for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderShortcode = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected a url String');\n\t }\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.shortcode = url;\n\t\n\t var path = '/sites/' + this._id + '/shortcodes/render';\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get a rendered embed for a site.\n\t *\n\t * Note: The current user must have publishing access.\n\t *\n\t * @param {String} url\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.renderEmbed = function (url, query, fn) {\n\t if ('string' !== typeof url) {\n\t throw new TypeError('expected an embed String');\n\t }\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t query = query || {};\n\t query.embed_url = url;\n\t\n\t var path = '/sites/' + this._id + '/embeds/render';\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Mark a referrering domain as spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Remove referrering domain from spam\n\t *\n\t * @param {String} domain\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n\t var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n\t var body = { domain: domain };\n\t\n\t return this.wpcom.req.post(path, body, null, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a VideoPress video\n\t *\n\t * @param {String} videoId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsVideo = function (videoId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Get detailed stats about a particular post\n\t *\n\t * @param {String} postId\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tSite.prototype.statsPostViews = function (postId, query, fn) {\n\t var path = '/sites/' + this._id + '/stats/post/' + postId;\n\t\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Site` module\n\t */\n\t\n\tmodule.exports = Site;\n\n/***/ },\n/* 15 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Tag methods\n\t *\n\t * @param {String} [slug]\n\t * @param {String} sid site id\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Tag(slug, sid, wpcom) {\n\t if (!sid) {\n\t throw new Error('`site id` is not correctly defined');\n\t }\n\t\n\t if (!(this instanceof Tag)) {\n\t return new Tag(slug, sid, wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t this._sid = sid;\n\t this._slug = slug;\n\t}\n\t\n\t/**\n\t * Set tag `slug`\n\t *\n\t * @param {String} slug\n\t * @api public\n\t */\n\t\n\tTag.prototype.slug = function (slug) {\n\t this._slug = slug;\n\t};\n\t\n\t/**\n\t * Get tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.get = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.get(path, query, fn);\n\t};\n\t\n\t/**\n\t * Add tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.add = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/new';\n\t return this.wpcom.req.post(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Edit tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype.update = function (query, body, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n\t return this.wpcom.req.put(path, query, body, fn);\n\t};\n\t\n\t/**\n\t * Delete tag\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n\t var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n\t return this.wpcom.req.del(path, query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Tag` module\n\t */\n\t\n\tmodule.exports = Tag;\n\n/***/ },\n/* 16 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Create a `Users` instance\n\t *\n\t * @param {WPCOM} wpcom\n\t * @api public\n\t */\n\t\n\tfunction Users(wpcom) {\n\t if (!(this instanceof Users)) {\n\t return new Users(wpcom);\n\t }\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * A list of @mention suggestions for the current user\n\t *\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tUsers.prototype.suggest = function (query, fn) {\n\t return this.wpcom.req.get('/users/suggest', query, fn);\n\t};\n\t\n\t/**\n\t * Expose `Users` module\n\t */\n\t\n\tmodule.exports = Users;\n\n/***/ },\n/* 17 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar sendRequest = __webpack_require__(3);\n\t\n\t/**\n\t * Expose `Request` module\n\t */\n\t\n\tfunction Req(wpcom) {\n\t\n\t this.wpcom = wpcom;\n\t}\n\t\n\t/**\n\t * Request methods\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.get = function (params, query, fn) {\n\t // `query` is optional\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return sendRequest.call(this.wpcom, params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Make `update` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Object} body\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.post = Req.prototype.put = function (params, query, body, fn) {\n\t if (undefined === fn) {\n\t if (undefined === body) {\n\t body = query;\n\t query = {};\n\t } else if ('function' === typeof body) {\n\t fn = body;\n\t body = query;\n\t query = {};\n\t }\n\t }\n\t\n\t // params can be a string\n\t params = 'string' === typeof params ? { path: params } : params;\n\t\n\t // request method\n\t params.method = 'post';\n\t\n\t return sendRequest.call(this.wpcom, params, query, body, fn);\n\t};\n\t\n\t/**\n\t * Make a `delete` request\n\t *\n\t * @param {Object|String} params\n\t * @param {Object} [query]\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tReq.prototype.del = function (params, query, fn) {\n\t if ('function' === typeof query) {\n\t fn = query;\n\t query = {};\n\t }\n\t\n\t return this.post(params, query, null, fn);\n\t};\n\t\n\t/**\n\t * Expose module\n\t */\n\t\n\tmodule.exports = Req;\n\n/***/ },\n/* 18 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the common logic for both the Node.js and web browser\n\t * implementations of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = debug;\n\texports.coerce = coerce;\n\texports.disable = disable;\n\texports.enable = enable;\n\texports.enabled = enabled;\n\texports.humanize = __webpack_require__(19);\n\t\n\t/**\n\t * The currently active debug mode names, and names to skip.\n\t */\n\t\n\texports.names = [];\n\texports.skips = [];\n\t\n\t/**\n\t * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t *\n\t * Valid key names are a single, lowercased letter, i.e. \"n\".\n\t */\n\t\n\texports.formatters = {};\n\t\n\t/**\n\t * Previously assigned color.\n\t */\n\t\n\tvar prevColor = 0;\n\t\n\t/**\n\t * Previous log timestamp.\n\t */\n\t\n\tvar prevTime;\n\t\n\t/**\n\t * Select a color.\n\t *\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction selectColor() {\n\t return exports.colors[prevColor++ % exports.colors.length];\n\t}\n\t\n\t/**\n\t * Create a debugger with the given `namespace`.\n\t *\n\t * @param {String} namespace\n\t * @return {Function}\n\t * @api public\n\t */\n\t\n\tfunction debug(namespace) {\n\t\n\t // define the `disabled` version\n\t function disabled() {\n\t }\n\t disabled.enabled = false;\n\t\n\t // define the `enabled` version\n\t function enabled() {\n\t\n\t var self = enabled;\n\t\n\t // set `diff` timestamp\n\t var curr = +new Date();\n\t var ms = curr - (prevTime || curr);\n\t self.diff = ms;\n\t self.prev = prevTime;\n\t self.curr = curr;\n\t prevTime = curr;\n\t\n\t // add the `color` if not set\n\t if (null == self.useColors) self.useColors = exports.useColors();\n\t if (null == self.color && self.useColors) self.color = selectColor();\n\t\n\t var args = Array.prototype.slice.call(arguments);\n\t\n\t args[0] = exports.coerce(args[0]);\n\t\n\t if ('string' !== typeof args[0]) {\n\t // anything else let's inspect with %o\n\t args = ['%o'].concat(args);\n\t }\n\t\n\t // apply any `formatters` transformations\n\t var index = 0;\n\t args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n\t // if we encounter an escaped % then don't increase the array index\n\t if (match === '%%') return match;\n\t index++;\n\t var formatter = exports.formatters[format];\n\t if ('function' === typeof formatter) {\n\t var val = args[index];\n\t match = formatter.call(self, val);\n\t\n\t // now we need to remove `args[index]` since it's inlined in the `format`\n\t args.splice(index, 1);\n\t index--;\n\t }\n\t return match;\n\t });\n\t\n\t if ('function' === typeof exports.formatArgs) {\n\t args = exports.formatArgs.apply(self, args);\n\t }\n\t var logFn = enabled.log || exports.log || console.log.bind(console);\n\t logFn.apply(self, args);\n\t }\n\t enabled.enabled = true;\n\t\n\t var fn = exports.enabled(namespace) ? enabled : disabled;\n\t\n\t fn.namespace = namespace;\n\t\n\t return fn;\n\t}\n\t\n\t/**\n\t * Enables a debug mode by namespaces. This can include modes\n\t * separated by a colon and wildcards.\n\t *\n\t * @param {String} namespaces\n\t * @api public\n\t */\n\t\n\tfunction enable(namespaces) {\n\t exports.save(namespaces);\n\t\n\t var split = (namespaces || '').split(/[\\s,]+/);\n\t var len = split.length;\n\t\n\t for (var i = 0; i < len; i++) {\n\t if (!split[i]) continue; // ignore empty strings\n\t namespaces = split[i].replace(/\\*/g, '.*?');\n\t if (namespaces[0] === '-') {\n\t exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t } else {\n\t exports.names.push(new RegExp('^' + namespaces + '$'));\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Disable debug output.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction disable() {\n\t exports.enable('');\n\t}\n\t\n\t/**\n\t * Returns true if the given mode name is enabled, false otherwise.\n\t *\n\t * @param {String} name\n\t * @return {Boolean}\n\t * @api public\n\t */\n\t\n\tfunction enabled(name) {\n\t var i, len;\n\t for (i = 0, len = exports.skips.length; i < len; i++) {\n\t if (exports.skips[i].test(name)) {\n\t return false;\n\t }\n\t }\n\t for (i = 0, len = exports.names.length; i < len; i++) {\n\t if (exports.names[i].test(name)) {\n\t return true;\n\t }\n\t }\n\t return false;\n\t}\n\t\n\t/**\n\t * Coerce `val`.\n\t *\n\t * @param {Mixed} val\n\t * @return {Mixed}\n\t * @api private\n\t */\n\t\n\tfunction coerce(val) {\n\t if (val instanceof Error) return val.stack || val.message;\n\t return val;\n\t}\n\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Helpers.\n\t */\n\t\n\tvar s = 1000;\n\tvar m = s * 60;\n\tvar h = m * 60;\n\tvar d = h * 24;\n\tvar y = d * 365.25;\n\t\n\t/**\n\t * Parse or format the given `val`.\n\t *\n\t * Options:\n\t *\n\t * - `long` verbose formatting [false]\n\t *\n\t * @param {String|Number} val\n\t * @param {Object} options\n\t * @return {String|Number}\n\t * @api public\n\t */\n\t\n\tmodule.exports = function(val, options){\n\t options = options || {};\n\t if ('string' == typeof val) return parse(val);\n\t return options.long\n\t ? long(val)\n\t : short(val);\n\t};\n\t\n\t/**\n\t * Parse the given `str` and return milliseconds.\n\t *\n\t * @param {String} str\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction parse(str) {\n\t str = '' + str;\n\t if (str.length > 10000) return;\n\t var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n\t if (!match) return;\n\t var n = parseFloat(match[1]);\n\t var type = (match[2] || 'ms').toLowerCase();\n\t switch (type) {\n\t case 'years':\n\t case 'year':\n\t case 'yrs':\n\t case 'yr':\n\t case 'y':\n\t return n * y;\n\t case 'days':\n\t case 'day':\n\t case 'd':\n\t return n * d;\n\t case 'hours':\n\t case 'hour':\n\t case 'hrs':\n\t case 'hr':\n\t case 'h':\n\t return n * h;\n\t case 'minutes':\n\t case 'minute':\n\t case 'mins':\n\t case 'min':\n\t case 'm':\n\t return n * m;\n\t case 'seconds':\n\t case 'second':\n\t case 'secs':\n\t case 'sec':\n\t case 's':\n\t return n * s;\n\t case 'milliseconds':\n\t case 'millisecond':\n\t case 'msecs':\n\t case 'msec':\n\t case 'ms':\n\t return n;\n\t }\n\t}\n\t\n\t/**\n\t * Short format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction short(ms) {\n\t if (ms >= d) return Math.round(ms / d) + 'd';\n\t if (ms >= h) return Math.round(ms / h) + 'h';\n\t if (ms >= m) return Math.round(ms / m) + 'm';\n\t if (ms >= s) return Math.round(ms / s) + 's';\n\t return ms + 'ms';\n\t}\n\t\n\t/**\n\t * Long format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction long(ms) {\n\t return plural(ms, d, 'day')\n\t || plural(ms, h, 'hour')\n\t || plural(ms, m, 'minute')\n\t || plural(ms, s, 'second')\n\t || ms + ' ms';\n\t}\n\t\n\t/**\n\t * Pluralization helper.\n\t */\n\t\n\tfunction plural(ms, n, name) {\n\t if (ms < n) return;\n\t if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n\t return Math.ceil(ms / n) + ' ' + name + 's';\n\t}\n\n\n/***/ },\n/* 20 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Load modules\n\t\n\tvar Stringify = __webpack_require__(22);\n\tvar Parse = __webpack_require__(21);\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {};\n\t\n\t\n\tmodule.exports = {\n\t stringify: Stringify,\n\t parse: Parse\n\t};\n\n\n/***/ },\n/* 21 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Load modules\n\t\n\tvar Utils = __webpack_require__(4);\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {\n\t delimiter: '&',\n\t depth: 5,\n\t arrayLimit: 20,\n\t parameterLimit: 1000,\n\t strictNullHandling: false,\n\t plainObjects: false,\n\t allowPrototypes: false\n\t};\n\t\n\t\n\tinternals.parseValues = function (str, options) {\n\t\n\t var obj = {};\n\t var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);\n\t\n\t for (var i = 0, il = parts.length; i < il; ++i) {\n\t var part = parts[i];\n\t var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;\n\t\n\t if (pos === -1) {\n\t obj[Utils.decode(part)] = '';\n\t\n\t if (options.strictNullHandling) {\n\t obj[Utils.decode(part)] = null;\n\t }\n\t }\n\t else {\n\t var key = Utils.decode(part.slice(0, pos));\n\t var val = Utils.decode(part.slice(pos + 1));\n\t\n\t if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n\t obj[key] = val;\n\t }\n\t else {\n\t obj[key] = [].concat(obj[key]).concat(val);\n\t }\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\tinternals.parseObject = function (chain, val, options) {\n\t\n\t if (!chain.length) {\n\t return val;\n\t }\n\t\n\t var root = chain.shift();\n\t\n\t var obj;\n\t if (root === '[]') {\n\t obj = [];\n\t obj = obj.concat(internals.parseObject(chain, val, options));\n\t }\n\t else {\n\t obj = options.plainObjects ? Object.create(null) : {};\n\t var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;\n\t var index = parseInt(cleanRoot, 10);\n\t var indexString = '' + index;\n\t if (!isNaN(index) &&\n\t root !== cleanRoot &&\n\t indexString === cleanRoot &&\n\t index >= 0 &&\n\t (options.parseArrays &&\n\t index <= options.arrayLimit)) {\n\t\n\t obj = [];\n\t obj[index] = internals.parseObject(chain, val, options);\n\t }\n\t else {\n\t obj[cleanRoot] = internals.parseObject(chain, val, options);\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\tinternals.parseKeys = function (key, val, options) {\n\t\n\t if (!key) {\n\t return;\n\t }\n\t\n\t // Transform dot notation to bracket notation\n\t\n\t if (options.allowDots) {\n\t key = key.replace(/\\.([^\\.\\[]+)/g, '[$1]');\n\t }\n\t\n\t // The regex chunks\n\t\n\t var parent = /^([^\\[\\]]*)/;\n\t var child = /(\\[[^\\[\\]]*\\])/g;\n\t\n\t // Get the parent\n\t\n\t var segment = parent.exec(key);\n\t\n\t // Stash the parent if it exists\n\t\n\t var keys = [];\n\t if (segment[1]) {\n\t // If we aren't using plain objects, optionally prefix keys\n\t // that would overwrite object prototype properties\n\t if (!options.plainObjects &&\n\t Object.prototype.hasOwnProperty(segment[1])) {\n\t\n\t if (!options.allowPrototypes) {\n\t return;\n\t }\n\t }\n\t\n\t keys.push(segment[1]);\n\t }\n\t\n\t // Loop through children appending to the array until we hit depth\n\t\n\t var i = 0;\n\t while ((segment = child.exec(key)) !== null && i < options.depth) {\n\t\n\t ++i;\n\t if (!options.plainObjects &&\n\t Object.prototype.hasOwnProperty(segment[1].replace(/\\[|\\]/g, ''))) {\n\t\n\t if (!options.allowPrototypes) {\n\t continue;\n\t }\n\t }\n\t keys.push(segment[1]);\n\t }\n\t\n\t // If there's a remainder, just add whatever is left\n\t\n\t if (segment) {\n\t keys.push('[' + key.slice(segment.index) + ']');\n\t }\n\t\n\t return internals.parseObject(keys, val, options);\n\t};\n\t\n\t\n\tmodule.exports = function (str, options) {\n\t\n\t options = options || {};\n\t options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;\n\t options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;\n\t options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;\n\t options.parseArrays = options.parseArrays !== false;\n\t options.allowDots = options.allowDots !== false;\n\t options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects;\n\t options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes;\n\t options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;\n\t options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n\t\n\t if (str === '' ||\n\t str === null ||\n\t typeof str === 'undefined') {\n\t\n\t return options.plainObjects ? Object.create(null) : {};\n\t }\n\t\n\t var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;\n\t var obj = options.plainObjects ? Object.create(null) : {};\n\t\n\t // Iterate over the keys and setup the new object\n\t\n\t var keys = Object.keys(tempObj);\n\t for (var i = 0, il = keys.length; i < il; ++i) {\n\t var key = keys[i];\n\t var newObj = internals.parseKeys(key, tempObj[key], options);\n\t obj = Utils.merge(obj, newObj, options);\n\t }\n\t\n\t return Utils.compact(obj);\n\t};\n\n\n/***/ },\n/* 22 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Load modules\n\t\n\tvar Utils = __webpack_require__(4);\n\t\n\t\n\t// Declare internals\n\t\n\tvar internals = {\n\t delimiter: '&',\n\t arrayPrefixGenerators: {\n\t brackets: function (prefix, key) {\n\t\n\t return prefix + '[]';\n\t },\n\t indices: function (prefix, key) {\n\t\n\t return prefix + '[' + key + ']';\n\t },\n\t repeat: function (prefix, key) {\n\t\n\t return prefix;\n\t }\n\t },\n\t strictNullHandling: false\n\t};\n\t\n\t\n\tinternals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) {\n\t\n\t if (typeof filter === 'function') {\n\t obj = filter(prefix, obj);\n\t }\n\t else if (Utils.isBuffer(obj)) {\n\t obj = obj.toString();\n\t }\n\t else if (obj instanceof Date) {\n\t obj = obj.toISOString();\n\t }\n\t else if (obj === null) {\n\t if (strictNullHandling) {\n\t return Utils.encode(prefix);\n\t }\n\t\n\t obj = '';\n\t }\n\t\n\t if (typeof obj === 'string' ||\n\t typeof obj === 'number' ||\n\t typeof obj === 'boolean') {\n\t\n\t return [Utils.encode(prefix) + '=' + Utils.encode(obj)];\n\t }\n\t\n\t var values = [];\n\t\n\t if (typeof obj === 'undefined') {\n\t return values;\n\t }\n\t\n\t var objKeys = Array.isArray(filter) ? filter : Object.keys(obj);\n\t for (var i = 0, il = objKeys.length; i < il; ++i) {\n\t var key = objKeys[i];\n\t\n\t if (Array.isArray(obj)) {\n\t values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter));\n\t }\n\t else {\n\t values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter));\n\t }\n\t }\n\t\n\t return values;\n\t};\n\t\n\t\n\tmodule.exports = function (obj, options) {\n\t\n\t options = options || {};\n\t var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;\n\t var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n\t var objKeys;\n\t var filter;\n\t if (typeof options.filter === 'function') {\n\t filter = options.filter;\n\t obj = filter('', obj);\n\t }\n\t else if (Array.isArray(options.filter)) {\n\t objKeys = filter = options.filter;\n\t }\n\t\n\t var keys = [];\n\t\n\t if (typeof obj !== 'object' ||\n\t obj === null) {\n\t\n\t return '';\n\t }\n\t\n\t var arrayFormat;\n\t if (options.arrayFormat in internals.arrayPrefixGenerators) {\n\t arrayFormat = options.arrayFormat;\n\t }\n\t else if ('indices' in options) {\n\t arrayFormat = options.indices ? 'indices' : 'repeat';\n\t }\n\t else {\n\t arrayFormat = 'indices';\n\t }\n\t\n\t var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];\n\t\n\t if (!objKeys) {\n\t objKeys = Object.keys(obj);\n\t }\n\t for (var i = 0, il = objKeys.length; i < il; ++i) {\n\t var key = objKeys[i];\n\t keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter));\n\t }\n\t\n\t return keys.join(delimiter);\n\t};\n\n\n/***/ },\n/* 23 */\n/***/ function(module, exports) {\n\n\n\n/***/ },\n/* 24 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar superagent = __webpack_require__(28);\n\tvar debug = __webpack_require__(25)('wpcom-xhr-request');\n\t\n\t/**\n\t * Export a single `request` function.\n\t */\n\t\n\tmodule.exports = request;\n\t\n\t/**\n\t * WordPress.com REST API base endpoint.\n\t */\n\t\n\tvar proxyOrigin = 'https://public-api.wordpress.com';\n\t\n\t/**\n\t * Default WordPress.com REST API Version.\n\t */\n\t\n\tvar defaultApiVersion = '1';\n\t\n\t/**\n\t * Performs an XMLHttpRequest against the WordPress.com REST API.\n\t *\n\t * @param {Object|String} params\n\t * @param {Function} fn\n\t * @api public\n\t */\n\t\n\tfunction request (params, fn) {\n\t\n\t if ('string' == typeof params) {\n\t params = { path: params };\n\t }\n\t\n\t var method = (params.method || 'GET').toLowerCase();\n\t debug('API HTTP Method: %o', method);\n\t delete params.method;\n\t\n\t var apiVersion = params.apiVersion || defaultApiVersion;\n\t delete params.apiVersion;\n\t\n\t proxyOrigin = params.proxyOrigin || proxyOrigin;\n\t delete params.proxyOrigin;\n\t\n\t var url = proxyOrigin + '/rest/v' + apiVersion + params.path;\n\t debug('API URL: %o', url);\n\t delete params.path;\n\t\n\t // create HTTP Request object\n\t var req = superagent[method](url);\n\t\n\t // Token authentication\n\t if (params.authToken) {\n\t req.set('Authorization', 'Bearer ' + params.authToken);\n\t delete params.authToken;\n\t }\n\t\n\t // URL querystring values\n\t if (params.query) {\n\t req.query(params.query);\n\t debug('API send URL querystring: %o', params.query);\n\t delete params.query;\n\t }\n\t\n\t // POST API request body\n\t if (params.body) {\n\t req.send(params.body);\n\t debug('API send POST body: ', params.body);\n\t delete params.body;\n\t }\n\t\n\t // POST FormData (for `multipart/form-data`, usually a file upload)\n\t if (params.formData) {\n\t for (var i = 0; i < params.formData.length; i++) {\n\t var data = params.formData[i];\n\t var key = data[0];\n\t var value = data[1];\n\t debug('adding FormData field %o', key);\n\t req.field(key, value);\n\t }\n\t }\n\t\n\t // start the request\n\t req.end(function (err, res){\n\t if (err && !res) {\n\t return fn(err);\n\t }\n\t\n\t var body = res.body;\n\t var headers = res.headers;\n\t var statusCode = res.status;\n\t debug('%o -> %o status code', url, statusCode);\n\t\n\t if (body && headers) {\n\t body._headers = headers;\n\t }\n\t\n\t if (!err) {\n\t return fn(null, body);\n\t }\n\t\n\t err = new Error();\n\t err.statusCode = statusCode;\n\t for (var i in body) {\n\t err[i] = body[i];\n\t }\n\t\n\t if (body && body.error) {\n\t err.name = toTitle(body.error) + 'Error';\n\t }\n\t\n\t fn(err);\n\t });\n\t\n\t return req.xhr;\n\t}\n\t\n\tfunction toTitle (str) {\n\t if (!str || 'string' !== typeof str) return '';\n\t return str.replace(/((^|_)[a-z])/g, function ($1) {\n\t return $1.toUpperCase().replace('_', '');\n\t });\n\t}\n\n\n/***/ },\n/* 25 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the web browser implementation of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = __webpack_require__(26);\n\texports.log = log;\n\texports.formatArgs = formatArgs;\n\texports.save = save;\n\texports.load = load;\n\texports.useColors = useColors;\n\t\n\t/**\n\t * Use chrome.storage.local if we are in an app\n\t */\n\t\n\tvar storage;\n\t\n\tif (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')\n\t storage = chrome.storage.local;\n\telse\n\t storage = localstorage();\n\t\n\t/**\n\t * Colors.\n\t */\n\t\n\texports.colors = [\n\t 'lightseagreen',\n\t 'forestgreen',\n\t 'goldenrod',\n\t 'dodgerblue',\n\t 'darkorchid',\n\t 'crimson'\n\t];\n\t\n\t/**\n\t * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n\t * and the Firebug extension (any Firefox version) are known\n\t * to support \"%c\" CSS customizations.\n\t *\n\t * TODO: add a `localStorage` variable to explicitly enable/disable colors\n\t */\n\t\n\tfunction useColors() {\n\t // is webkit? http://stackoverflow.com/a/16459606/376773\n\t return ('WebkitAppearance' in document.documentElement.style) ||\n\t // is firebug? http://stackoverflow.com/a/398120/376773\n\t (window.console && (console.firebug || (console.exception && console.table))) ||\n\t // is firefox >= v31?\n\t // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n\t}\n\t\n\t/**\n\t * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n\t */\n\t\n\texports.formatters.j = function(v) {\n\t return JSON.stringify(v);\n\t};\n\t\n\t\n\t/**\n\t * Colorize log arguments if enabled.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction formatArgs() {\n\t var args = arguments;\n\t var useColors = this.useColors;\n\t\n\t args[0] = (useColors ? '%c' : '')\n\t + this.namespace\n\t + (useColors ? ' %c' : ' ')\n\t + args[0]\n\t + (useColors ? '%c ' : ' ')\n\t + '+' + exports.humanize(this.diff);\n\t\n\t if (!useColors) return args;\n\t\n\t var c = 'color: ' + this.color;\n\t args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\t\n\t // the final \"%c\" is somewhat tricky, because there could be other\n\t // arguments passed either before or after the %c, so we need to\n\t // figure out the correct index to insert the CSS into\n\t var index = 0;\n\t var lastC = 0;\n\t args[0].replace(/%[a-z%]/g, function(match) {\n\t if ('%%' === match) return;\n\t index++;\n\t if ('%c' === match) {\n\t // we only are interested in the *last* %c\n\t // (the user may have provided their own)\n\t lastC = index;\n\t }\n\t });\n\t\n\t args.splice(lastC, 0, c);\n\t return args;\n\t}\n\t\n\t/**\n\t * Invokes `console.log()` when available.\n\t * No-op when `console.log` is not a \"function\".\n\t *\n\t * @api public\n\t */\n\t\n\tfunction log() {\n\t // this hackery is required for IE8/9, where\n\t // the `console.log` function doesn't have 'apply'\n\t return 'object' === typeof console\n\t && console.log\n\t && Function.prototype.apply.call(console.log, console, arguments);\n\t}\n\t\n\t/**\n\t * Save `namespaces`.\n\t *\n\t * @param {String} namespaces\n\t * @api private\n\t */\n\t\n\tfunction save(namespaces) {\n\t try {\n\t if (null == namespaces) {\n\t storage.removeItem('debug');\n\t } else {\n\t storage.debug = namespaces;\n\t }\n\t } catch(e) {}\n\t}\n\t\n\t/**\n\t * Load `namespaces`.\n\t *\n\t * @return {String} returns the previously persisted debug modes\n\t * @api private\n\t */\n\t\n\tfunction load() {\n\t var r;\n\t try {\n\t r = storage.debug;\n\t } catch(e) {}\n\t return r;\n\t}\n\t\n\t/**\n\t * Enable namespaces listed in `localStorage.debug` initially.\n\t */\n\t\n\texports.enable(load());\n\t\n\t/**\n\t * Localstorage attempts to return the localstorage.\n\t *\n\t * This is necessary because safari throws\n\t * when a user disables cookies/localstorage\n\t * and you attempt to access it.\n\t *\n\t * @return {LocalStorage}\n\t * @api private\n\t */\n\t\n\tfunction localstorage(){\n\t try {\n\t return window.localStorage;\n\t } catch (e) {}\n\t}\n\n\n/***/ },\n/* 26 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\n\t/**\n\t * This is the common logic for both the Node.js and web browser\n\t * implementations of `debug()`.\n\t *\n\t * Expose `debug()` as the module.\n\t */\n\t\n\texports = module.exports = debug;\n\texports.coerce = coerce;\n\texports.disable = disable;\n\texports.enable = enable;\n\texports.enabled = enabled;\n\texports.humanize = __webpack_require__(27);\n\t\n\t/**\n\t * The currently active debug mode names, and names to skip.\n\t */\n\t\n\texports.names = [];\n\texports.skips = [];\n\t\n\t/**\n\t * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t *\n\t * Valid key names are a single, lowercased letter, i.e. \"n\".\n\t */\n\t\n\texports.formatters = {};\n\t\n\t/**\n\t * Previously assigned color.\n\t */\n\t\n\tvar prevColor = 0;\n\t\n\t/**\n\t * Previous log timestamp.\n\t */\n\t\n\tvar prevTime;\n\t\n\t/**\n\t * Select a color.\n\t *\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction selectColor() {\n\t return exports.colors[prevColor++ % exports.colors.length];\n\t}\n\t\n\t/**\n\t * Create a debugger with the given `namespace`.\n\t *\n\t * @param {String} namespace\n\t * @return {Function}\n\t * @api public\n\t */\n\t\n\tfunction debug(namespace) {\n\t\n\t // define the `disabled` version\n\t function disabled() {\n\t }\n\t disabled.enabled = false;\n\t\n\t // define the `enabled` version\n\t function enabled() {\n\t\n\t var self = enabled;\n\t\n\t // set `diff` timestamp\n\t var curr = +new Date();\n\t var ms = curr - (prevTime || curr);\n\t self.diff = ms;\n\t self.prev = prevTime;\n\t self.curr = curr;\n\t prevTime = curr;\n\t\n\t // add the `color` if not set\n\t if (null == self.useColors) self.useColors = exports.useColors();\n\t if (null == self.color && self.useColors) self.color = selectColor();\n\t\n\t var args = Array.prototype.slice.call(arguments);\n\t\n\t args[0] = exports.coerce(args[0]);\n\t\n\t if ('string' !== typeof args[0]) {\n\t // anything else let's inspect with %o\n\t args = ['%o'].concat(args);\n\t }\n\t\n\t // apply any `formatters` transformations\n\t var index = 0;\n\t args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n\t // if we encounter an escaped % then don't increase the array index\n\t if (match === '%%') return match;\n\t index++;\n\t var formatter = exports.formatters[format];\n\t if ('function' === typeof formatter) {\n\t var val = args[index];\n\t match = formatter.call(self, val);\n\t\n\t // now we need to remove `args[index]` since it's inlined in the `format`\n\t args.splice(index, 1);\n\t index--;\n\t }\n\t return match;\n\t });\n\t\n\t if ('function' === typeof exports.formatArgs) {\n\t args = exports.formatArgs.apply(self, args);\n\t }\n\t var logFn = enabled.log || exports.log || console.log.bind(console);\n\t logFn.apply(self, args);\n\t }\n\t enabled.enabled = true;\n\t\n\t var fn = exports.enabled(namespace) ? enabled : disabled;\n\t\n\t fn.namespace = namespace;\n\t\n\t return fn;\n\t}\n\t\n\t/**\n\t * Enables a debug mode by namespaces. This can include modes\n\t * separated by a colon and wildcards.\n\t *\n\t * @param {String} namespaces\n\t * @api public\n\t */\n\t\n\tfunction enable(namespaces) {\n\t exports.save(namespaces);\n\t\n\t var split = (namespaces || '').split(/[\\s,]+/);\n\t var len = split.length;\n\t\n\t for (var i = 0; i < len; i++) {\n\t if (!split[i]) continue; // ignore empty strings\n\t namespaces = split[i].replace(/\\*/g, '.*?');\n\t if (namespaces[0] === '-') {\n\t exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t } else {\n\t exports.names.push(new RegExp('^' + namespaces + '$'));\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Disable debug output.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction disable() {\n\t exports.enable('');\n\t}\n\t\n\t/**\n\t * Returns true if the given mode name is enabled, false otherwise.\n\t *\n\t * @param {String} name\n\t * @return {Boolean}\n\t * @api public\n\t */\n\t\n\tfunction enabled(name) {\n\t var i, len;\n\t for (i = 0, len = exports.skips.length; i < len; i++) {\n\t if (exports.skips[i].test(name)) {\n\t return false;\n\t }\n\t }\n\t for (i = 0, len = exports.names.length; i < len; i++) {\n\t if (exports.names[i].test(name)) {\n\t return true;\n\t }\n\t }\n\t return false;\n\t}\n\t\n\t/**\n\t * Coerce `val`.\n\t *\n\t * @param {Mixed} val\n\t * @return {Mixed}\n\t * @api private\n\t */\n\t\n\tfunction coerce(val) {\n\t if (val instanceof Error) return val.stack || val.message;\n\t return val;\n\t}\n\n\n/***/ },\n/* 27 */\n/***/ function(module, exports) {\n\n\t/**\n\t * Helpers.\n\t */\n\t\n\tvar s = 1000;\n\tvar m = s * 60;\n\tvar h = m * 60;\n\tvar d = h * 24;\n\tvar y = d * 365.25;\n\t\n\t/**\n\t * Parse or format the given `val`.\n\t *\n\t * Options:\n\t *\n\t * - `long` verbose formatting [false]\n\t *\n\t * @param {String|Number} val\n\t * @param {Object} options\n\t * @return {String|Number}\n\t * @api public\n\t */\n\t\n\tmodule.exports = function(val, options){\n\t options = options || {};\n\t if ('string' == typeof val) return parse(val);\n\t return options.long\n\t ? long(val)\n\t : short(val);\n\t};\n\t\n\t/**\n\t * Parse the given `str` and return milliseconds.\n\t *\n\t * @param {String} str\n\t * @return {Number}\n\t * @api private\n\t */\n\t\n\tfunction parse(str) {\n\t var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n\t if (!match) return;\n\t var n = parseFloat(match[1]);\n\t var type = (match[2] || 'ms').toLowerCase();\n\t switch (type) {\n\t case 'years':\n\t case 'year':\n\t case 'yrs':\n\t case 'yr':\n\t case 'y':\n\t return n * y;\n\t case 'days':\n\t case 'day':\n\t case 'd':\n\t return n * d;\n\t case 'hours':\n\t case 'hour':\n\t case 'hrs':\n\t case 'hr':\n\t case 'h':\n\t return n * h;\n\t case 'minutes':\n\t case 'minute':\n\t case 'mins':\n\t case 'min':\n\t case 'm':\n\t return n * m;\n\t case 'seconds':\n\t case 'second':\n\t case 'secs':\n\t case 'sec':\n\t case 's':\n\t return n * s;\n\t case 'milliseconds':\n\t case 'millisecond':\n\t case 'msecs':\n\t case 'msec':\n\t case 'ms':\n\t return n;\n\t }\n\t}\n\t\n\t/**\n\t * Short format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction short(ms) {\n\t if (ms >= d) return Math.round(ms / d) + 'd';\n\t if (ms >= h) return Math.round(ms / h) + 'h';\n\t if (ms >= m) return Math.round(ms / m) + 'm';\n\t if (ms >= s) return Math.round(ms / s) + 's';\n\t return ms + 'ms';\n\t}\n\t\n\t/**\n\t * Long format for `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction long(ms) {\n\t return plural(ms, d, 'day')\n\t || plural(ms, h, 'hour')\n\t || plural(ms, m, 'minute')\n\t || plural(ms, s, 'second')\n\t || ms + ' ms';\n\t}\n\t\n\t/**\n\t * Pluralization helper.\n\t */\n\t\n\tfunction plural(ms, n, name) {\n\t if (ms < n) return;\n\t if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n\t return Math.ceil(ms / n) + ' ' + name + 's';\n\t}\n\n\n/***/ },\n/* 28 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/**\n\t * Module dependencies.\n\t */\n\t\n\tvar Emitter = __webpack_require__(29);\n\tvar reduce = __webpack_require__(30);\n\t\n\t/**\n\t * Root reference for iframes.\n\t */\n\t\n\tvar root = 'undefined' == typeof window\n\t ? (this || self)\n\t : window;\n\t\n\t/**\n\t * Noop.\n\t */\n\t\n\tfunction noop(){};\n\t\n\t/**\n\t * Check if `obj` is a host object,\n\t * we don't want to serialize these :)\n\t *\n\t * TODO: future proof, move to compoent land\n\t *\n\t * @param {Object} obj\n\t * @return {Boolean}\n\t * @api private\n\t */\n\t\n\tfunction isHost(obj) {\n\t var str = {}.toString.call(obj);\n\t\n\t switch (str) {\n\t case '[object File]':\n\t case '[object Blob]':\n\t case '[object FormData]':\n\t return true;\n\t default:\n\t return false;\n\t }\n\t}\n\t\n\t/**\n\t * Determine XHR.\n\t */\n\t\n\trequest.getXHR = function () {\n\t if (root.XMLHttpRequest\n\t && (!root.location || 'file:' != root.location.protocol\n\t || !root.ActiveXObject)) {\n\t return new XMLHttpRequest;\n\t } else {\n\t try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n\t try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n\t try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n\t try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n\t }\n\t return false;\n\t};\n\t\n\t/**\n\t * Removes leading and trailing whitespace, added to support IE.\n\t *\n\t * @param {String} s\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tvar trim = ''.trim\n\t ? function(s) { return s.trim(); }\n\t : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\t\n\t/**\n\t * Check if `obj` is an object.\n\t *\n\t * @param {Object} obj\n\t * @return {Boolean}\n\t * @api private\n\t */\n\t\n\tfunction isObject(obj) {\n\t return obj === Object(obj);\n\t}\n\t\n\t/**\n\t * Serialize the given `obj`.\n\t *\n\t * @param {Object} obj\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction serialize(obj) {\n\t if (!isObject(obj)) return obj;\n\t var pairs = [];\n\t for (var key in obj) {\n\t if (null != obj[key]) {\n\t pairs.push(encodeURIComponent(key)\n\t + '=' + encodeURIComponent(obj[key]));\n\t }\n\t }\n\t return pairs.join('&');\n\t}\n\t\n\t/**\n\t * Expose serialization method.\n\t */\n\t\n\t request.serializeObject = serialize;\n\t\n\t /**\n\t * Parse the given x-www-form-urlencoded `str`.\n\t *\n\t * @param {String} str\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction parseString(str) {\n\t var obj = {};\n\t var pairs = str.split('&');\n\t var parts;\n\t var pair;\n\t\n\t for (var i = 0, len = pairs.length; i < len; ++i) {\n\t pair = pairs[i];\n\t parts = pair.split('=');\n\t obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n\t }\n\t\n\t return obj;\n\t}\n\t\n\t/**\n\t * Expose parser.\n\t */\n\t\n\trequest.parseString = parseString;\n\t\n\t/**\n\t * Default MIME type map.\n\t *\n\t * superagent.types.xml = 'application/xml';\n\t *\n\t */\n\t\n\trequest.types = {\n\t html: 'text/html',\n\t json: 'application/json',\n\t xml: 'application/xml',\n\t urlencoded: 'application/x-www-form-urlencoded',\n\t 'form': 'application/x-www-form-urlencoded',\n\t 'form-data': 'application/x-www-form-urlencoded'\n\t};\n\t\n\t/**\n\t * Default serialization map.\n\t *\n\t * superagent.serialize['application/xml'] = function(obj){\n\t * return 'generated xml here';\n\t * };\n\t *\n\t */\n\t\n\t request.serialize = {\n\t 'application/x-www-form-urlencoded': serialize,\n\t 'application/json': JSON.stringify\n\t };\n\t\n\t /**\n\t * Default parsers.\n\t *\n\t * superagent.parse['application/xml'] = function(str){\n\t * return { object parsed from str };\n\t * };\n\t *\n\t */\n\t\n\trequest.parse = {\n\t 'application/x-www-form-urlencoded': parseString,\n\t 'application/json': JSON.parse\n\t};\n\t\n\t/**\n\t * Parse the given header `str` into\n\t * an object containing the mapped fields.\n\t *\n\t * @param {String} str\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction parseHeader(str) {\n\t var lines = str.split(/\\r?\\n/);\n\t var fields = {};\n\t var index;\n\t var line;\n\t var field;\n\t var val;\n\t\n\t lines.pop(); // trailing CRLF\n\t\n\t for (var i = 0, len = lines.length; i < len; ++i) {\n\t line = lines[i];\n\t index = line.indexOf(':');\n\t field = line.slice(0, index).toLowerCase();\n\t val = trim(line.slice(index + 1));\n\t fields[field] = val;\n\t }\n\t\n\t return fields;\n\t}\n\t\n\t/**\n\t * Return the mime type for the given `str`.\n\t *\n\t * @param {String} str\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tfunction type(str){\n\t return str.split(/ *; */).shift();\n\t};\n\t\n\t/**\n\t * Return header field parameters.\n\t *\n\t * @param {String} str\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction params(str){\n\t return reduce(str.split(/ *; */), function(obj, str){\n\t var parts = str.split(/ *= */)\n\t , key = parts.shift()\n\t , val = parts.shift();\n\t\n\t if (key && val) obj[key] = val;\n\t return obj;\n\t }, {});\n\t};\n\t\n\t/**\n\t * Initialize a new `Response` with the given `xhr`.\n\t *\n\t * - set flags (.ok, .error, etc)\n\t * - parse header\n\t *\n\t * Examples:\n\t *\n\t * Aliasing `superagent` as `request` is nice:\n\t *\n\t * request = superagent;\n\t *\n\t * We can use the promise-like API, or pass callbacks:\n\t *\n\t * request.get('/').end(function(res){});\n\t * request.get('/', function(res){});\n\t *\n\t * Sending data can be chained:\n\t *\n\t * request\n\t * .post('/user')\n\t * .send({ name: 'tj' })\n\t * .end(function(res){});\n\t *\n\t * Or passed to `.send()`:\n\t *\n\t * request\n\t * .post('/user')\n\t * .send({ name: 'tj' }, function(res){});\n\t *\n\t * Or passed to `.post()`:\n\t *\n\t * request\n\t * .post('/user', { name: 'tj' })\n\t * .end(function(res){});\n\t *\n\t * Or further reduced to a single call for simple cases:\n\t *\n\t * request\n\t * .post('/user', { name: 'tj' }, function(res){});\n\t *\n\t * @param {XMLHTTPRequest} xhr\n\t * @param {Object} options\n\t * @api private\n\t */\n\t\n\tfunction Response(req, options) {\n\t options = options || {};\n\t this.req = req;\n\t this.xhr = this.req.xhr;\n\t // responseText is accessible only if responseType is '' or 'text' and on older browsers\n\t this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')\n\t ? this.xhr.responseText\n\t : null;\n\t this.statusText = this.req.xhr.statusText;\n\t this.setStatusProperties(this.xhr.status);\n\t this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n\t // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n\t // getResponseHeader still works. so we get content-type even if getting\n\t // other headers fails.\n\t this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n\t this.setHeaderProperties(this.header);\n\t this.body = this.req.method != 'HEAD'\n\t ? this.parseBody(this.text ? this.text : this.xhr.response)\n\t : null;\n\t}\n\t\n\t/**\n\t * Get case-insensitive `field` value.\n\t *\n\t * @param {String} field\n\t * @return {String}\n\t * @api public\n\t */\n\t\n\tResponse.prototype.get = function(field){\n\t return this.header[field.toLowerCase()];\n\t};\n\t\n\t/**\n\t * Set header related properties:\n\t *\n\t * - `.type` the content type without params\n\t *\n\t * A response of \"Content-Type: text/plain; charset=utf-8\"\n\t * will provide you with a `.type` of \"text/plain\".\n\t *\n\t * @param {Object} header\n\t * @api private\n\t */\n\t\n\tResponse.prototype.setHeaderProperties = function(header){\n\t // content-type\n\t var ct = this.header['content-type'] || '';\n\t this.type = type(ct);\n\t\n\t // params\n\t var obj = params(ct);\n\t for (var key in obj) this[key] = obj[key];\n\t};\n\t\n\t/**\n\t * Parse the given body `str`.\n\t *\n\t * Used for auto-parsing of bodies. Parsers\n\t * are defined on the `superagent.parse` object.\n\t *\n\t * @param {String} str\n\t * @return {Mixed}\n\t * @api private\n\t */\n\t\n\tResponse.prototype.parseBody = function(str){\n\t var parse = request.parse[this.type];\n\t return parse && str && (str.length || str instanceof Object)\n\t ? parse(str)\n\t : null;\n\t};\n\t\n\t/**\n\t * Set flags such as `.ok` based on `status`.\n\t *\n\t * For example a 2xx response will give you a `.ok` of __true__\n\t * whereas 5xx will be __false__ and `.error` will be __true__. The\n\t * `.clientError` and `.serverError` are also available to be more\n\t * specific, and `.statusType` is the class of error ranging from 1..5\n\t * sometimes useful for mapping respond colors etc.\n\t *\n\t * \"sugar\" properties are also defined for common cases. Currently providing:\n\t *\n\t * - .noContent\n\t * - .badRequest\n\t * - .unauthorized\n\t * - .notAcceptable\n\t * - .notFound\n\t *\n\t * @param {Number} status\n\t * @api private\n\t */\n\t\n\tResponse.prototype.setStatusProperties = function(status){\n\t // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n\t if (status === 1223) {\n\t status = 204;\n\t }\n\t\n\t var type = status / 100 | 0;\n\t\n\t // status / class\n\t this.status = status;\n\t this.statusType = type;\n\t\n\t // basics\n\t this.info = 1 == type;\n\t this.ok = 2 == type;\n\t this.clientError = 4 == type;\n\t this.serverError = 5 == type;\n\t this.error = (4 == type || 5 == type)\n\t ? this.toError()\n\t : false;\n\t\n\t // sugar\n\t this.accepted = 202 == status;\n\t this.noContent = 204 == status;\n\t this.badRequest = 400 == status;\n\t this.unauthorized = 401 == status;\n\t this.notAcceptable = 406 == status;\n\t this.notFound = 404 == status;\n\t this.forbidden = 403 == status;\n\t};\n\t\n\t/**\n\t * Return an `Error` representative of this response.\n\t *\n\t * @return {Error}\n\t * @api public\n\t */\n\t\n\tResponse.prototype.toError = function(){\n\t var req = this.req;\n\t var method = req.method;\n\t var url = req.url;\n\t\n\t var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n\t var err = new Error(msg);\n\t err.status = this.status;\n\t err.method = method;\n\t err.url = url;\n\t\n\t return err;\n\t};\n\t\n\t/**\n\t * Expose `Response`.\n\t */\n\t\n\trequest.Response = Response;\n\t\n\t/**\n\t * Initialize a new `Request` with the given `method` and `url`.\n\t *\n\t * @param {String} method\n\t * @param {String} url\n\t * @api public\n\t */\n\t\n\tfunction Request(method, url) {\n\t var self = this;\n\t Emitter.call(this);\n\t this._query = this._query || [];\n\t this.method = method;\n\t this.url = url;\n\t this.header = {};\n\t this._header = {};\n\t this.on('end', function(){\n\t var err = null;\n\t var res = null;\n\t\n\t try {\n\t res = new Response(self);\n\t } catch(e) {\n\t err = new Error('Parser is unable to parse the response');\n\t err.parse = true;\n\t err.original = e;\n\t return self.callback(err);\n\t }\n\t\n\t self.emit('response', res);\n\t\n\t if (err) {\n\t return self.callback(err, res);\n\t }\n\t\n\t if (res.status >= 200 && res.status < 300) {\n\t return self.callback(err, res);\n\t }\n\t\n\t var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');\n\t new_err.original = err;\n\t new_err.response = res;\n\t new_err.status = res.status;\n\t\n\t self.callback(err || new_err, res);\n\t });\n\t}\n\t\n\t/**\n\t * Mixin `Emitter`.\n\t */\n\t\n\tEmitter(Request.prototype);\n\t\n\t/**\n\t * Allow for extension\n\t */\n\t\n\tRequest.prototype.use = function(fn) {\n\t fn(this);\n\t return this;\n\t}\n\t\n\t/**\n\t * Set timeout to `ms`.\n\t *\n\t * @param {Number} ms\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.timeout = function(ms){\n\t this._timeout = ms;\n\t return this;\n\t};\n\t\n\t/**\n\t * Clear previous timeout.\n\t *\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.clearTimeout = function(){\n\t this._timeout = 0;\n\t clearTimeout(this._timer);\n\t return this;\n\t};\n\t\n\t/**\n\t * Abort the request, and clear potential timeout.\n\t *\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\tRequest.prototype.abort = function(){\n\t if (this.aborted) return;\n\t this.aborted = true;\n\t this.xhr.abort();\n\t this.clearTimeout();\n\t this.emit('abort');\n\t return this;\n\t};\n\t\n\t/**\n\t * Set header `field` to `val`, or multiple fields with one object.\n\t *\n\t * Examples:\n\t *\n\t * req.get('/')\n\t * .set('Accept', 'application/json')\n\t * .set('X-API-Key', 'foobar')\n\t * .end(callback);\n\t *\n\t * req.get('/')\n\t * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n\t * .end(callback);\n\t *\n\t * @param {String|Object} field\n\t * @param {String} val\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.set = function(field, val){\n\t if (isObject(field)) {\n\t for (var key in field) {\n\t this.set(key, field[key]);\n\t }\n\t return this;\n\t }\n\t this._header[field.toLowerCase()] = val;\n\t this.header[field] = val;\n\t return this;\n\t};\n\t\n\t/**\n\t * Remove header `field`.\n\t *\n\t * Example:\n\t *\n\t * req.get('/')\n\t * .unset('User-Agent')\n\t * .end(callback);\n\t *\n\t * @param {String} field\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.unset = function(field){\n\t delete this._header[field.toLowerCase()];\n\t delete this.header[field];\n\t return this;\n\t};\n\t\n\t/**\n\t * Get case-insensitive header `field` value.\n\t *\n\t * @param {String} field\n\t * @return {String}\n\t * @api private\n\t */\n\t\n\tRequest.prototype.getHeader = function(field){\n\t return this._header[field.toLowerCase()];\n\t};\n\t\n\t/**\n\t * Set Content-Type to `type`, mapping values from `request.types`.\n\t *\n\t * Examples:\n\t *\n\t * superagent.types.xml = 'application/xml';\n\t *\n\t * request.post('/')\n\t * .type('xml')\n\t * .send(xmlstring)\n\t * .end(callback);\n\t *\n\t * request.post('/')\n\t * .type('application/xml')\n\t * .send(xmlstring)\n\t * .end(callback);\n\t *\n\t * @param {String} type\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.type = function(type){\n\t this.set('Content-Type', request.types[type] || type);\n\t return this;\n\t};\n\t\n\t/**\n\t * Set Accept to `type`, mapping values from `request.types`.\n\t *\n\t * Examples:\n\t *\n\t * superagent.types.json = 'application/json';\n\t *\n\t * request.get('/agent')\n\t * .accept('json')\n\t * .end(callback);\n\t *\n\t * request.get('/agent')\n\t * .accept('application/json')\n\t * .end(callback);\n\t *\n\t * @param {String} accept\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.accept = function(type){\n\t this.set('Accept', request.types[type] || type);\n\t return this;\n\t};\n\t\n\t/**\n\t * Set Authorization field value with `user` and `pass`.\n\t *\n\t * @param {String} user\n\t * @param {String} pass\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.auth = function(user, pass){\n\t var str = btoa(user + ':' + pass);\n\t this.set('Authorization', 'Basic ' + str);\n\t return this;\n\t};\n\t\n\t/**\n\t* Add query-string `val`.\n\t*\n\t* Examples:\n\t*\n\t* request.get('/shoes')\n\t* .query('size=10')\n\t* .query({ color: 'blue' })\n\t*\n\t* @param {Object|String} val\n\t* @return {Request} for chaining\n\t* @api public\n\t*/\n\t\n\tRequest.prototype.query = function(val){\n\t if ('string' != typeof val) val = serialize(val);\n\t if (val) this._query.push(val);\n\t return this;\n\t};\n\t\n\t/**\n\t * Write the field `name` and `val` for \"multipart/form-data\"\n\t * request bodies.\n\t *\n\t * ``` js\n\t * request.post('/upload')\n\t * .field('foo', 'bar')\n\t * .end(callback);\n\t * ```\n\t *\n\t * @param {String} name\n\t * @param {String|Blob|File} val\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.field = function(name, val){\n\t if (!this._formData) this._formData = new root.FormData();\n\t this._formData.append(name, val);\n\t return this;\n\t};\n\t\n\t/**\n\t * Queue the given `file` as an attachment to the specified `field`,\n\t * with optional `filename`.\n\t *\n\t * ``` js\n\t * request.post('/upload')\n\t * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n\t * .end(callback);\n\t * ```\n\t *\n\t * @param {String} field\n\t * @param {Blob|File} file\n\t * @param {String} filename\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.attach = function(field, file, filename){\n\t if (!this._formData) this._formData = new root.FormData();\n\t this._formData.append(field, file, filename);\n\t return this;\n\t};\n\t\n\t/**\n\t * Send `data`, defaulting the `.type()` to \"json\" when\n\t * an object is given.\n\t *\n\t * Examples:\n\t *\n\t * // querystring\n\t * request.get('/search')\n\t * .end(callback)\n\t *\n\t * // multiple data \"writes\"\n\t * request.get('/search')\n\t * .send({ search: 'query' })\n\t * .send({ range: '1..5' })\n\t * .send({ order: 'desc' })\n\t * .end(callback)\n\t *\n\t * // manual json\n\t * request.post('/user')\n\t * .type('json')\n\t * .send('{\"name\":\"tj\"})\n\t * .end(callback)\n\t *\n\t * // auto json\n\t * request.post('/user')\n\t * .send({ name: 'tj' })\n\t * .end(callback)\n\t *\n\t * // manual x-www-form-urlencoded\n\t * request.post('/user')\n\t * .type('form')\n\t * .send('name=tj')\n\t * .end(callback)\n\t *\n\t * // auto x-www-form-urlencoded\n\t * request.post('/user')\n\t * .type('form')\n\t * .send({ name: 'tj' })\n\t * .end(callback)\n\t *\n\t * // defaults to x-www-form-urlencoded\n\t * request.post('/user')\n\t * .send('name=tobi')\n\t * .send('species=ferret')\n\t * .end(callback)\n\t *\n\t * @param {String|Object} data\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.send = function(data){\n\t var obj = isObject(data);\n\t var type = this.getHeader('Content-Type');\n\t\n\t // merge\n\t if (obj && isObject(this._data)) {\n\t for (var key in data) {\n\t this._data[key] = data[key];\n\t }\n\t } else if ('string' == typeof data) {\n\t if (!type) this.type('form');\n\t type = this.getHeader('Content-Type');\n\t if ('application/x-www-form-urlencoded' == type) {\n\t this._data = this._data\n\t ? this._data + '&' + data\n\t : data;\n\t } else {\n\t this._data = (this._data || '') + data;\n\t }\n\t } else {\n\t this._data = data;\n\t }\n\t\n\t if (!obj || isHost(data)) return this;\n\t if (!type) this.type('json');\n\t return this;\n\t};\n\t\n\t/**\n\t * Invoke the callback with `err` and `res`\n\t * and handle arity check.\n\t *\n\t * @param {Error} err\n\t * @param {Response} res\n\t * @api private\n\t */\n\t\n\tRequest.prototype.callback = function(err, res){\n\t var fn = this._callback;\n\t this.clearTimeout();\n\t fn(err, res);\n\t};\n\t\n\t/**\n\t * Invoke callback with x-domain error.\n\t *\n\t * @api private\n\t */\n\t\n\tRequest.prototype.crossDomainError = function(){\n\t var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n\t err.crossDomain = true;\n\t this.callback(err);\n\t};\n\t\n\t/**\n\t * Invoke callback with timeout error.\n\t *\n\t * @api private\n\t */\n\t\n\tRequest.prototype.timeoutError = function(){\n\t var timeout = this._timeout;\n\t var err = new Error('timeout of ' + timeout + 'ms exceeded');\n\t err.timeout = timeout;\n\t this.callback(err);\n\t};\n\t\n\t/**\n\t * Enable transmission of cookies with x-domain requests.\n\t *\n\t * Note that for this to work the origin must not be\n\t * using \"Access-Control-Allow-Origin\" with a wildcard,\n\t * and also must set \"Access-Control-Allow-Credentials\"\n\t * to \"true\".\n\t *\n\t * @api public\n\t */\n\t\n\tRequest.prototype.withCredentials = function(){\n\t this._withCredentials = true;\n\t return this;\n\t};\n\t\n\t/**\n\t * Initiate request, invoking callback `fn(res)`\n\t * with an instanceof `Response`.\n\t *\n\t * @param {Function} fn\n\t * @return {Request} for chaining\n\t * @api public\n\t */\n\t\n\tRequest.prototype.end = function(fn){\n\t var self = this;\n\t var xhr = this.xhr = request.getXHR();\n\t var query = this._query.join('&');\n\t var timeout = this._timeout;\n\t var data = this._formData || this._data;\n\t\n\t // store callback\n\t this._callback = fn || noop;\n\t\n\t // state change\n\t xhr.onreadystatechange = function(){\n\t if (4 != xhr.readyState) return;\n\t\n\t // In IE9, reads to any property (e.g. status) off of an aborted XHR will\n\t // result in the error \"Could not complete the operation due to error c00c023f\"\n\t var status;\n\t try { status = xhr.status } catch(e) { status = 0; }\n\t\n\t if (0 == status) {\n\t if (self.timedout) return self.timeoutError();\n\t if (self.aborted) return;\n\t return self.crossDomainError();\n\t }\n\t self.emit('end');\n\t };\n\t\n\t // progress\n\t var handleProgress = function(e){\n\t if (e.total > 0) {\n\t e.percent = e.loaded / e.total * 100;\n\t }\n\t self.emit('progress', e);\n\t };\n\t if (this.hasListeners('progress')) {\n\t xhr.onprogress = handleProgress;\n\t }\n\t try {\n\t if (xhr.upload && this.hasListeners('progress')) {\n\t xhr.upload.onprogress = handleProgress;\n\t }\n\t } catch(e) {\n\t // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.\n\t // Reported here:\n\t // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context\n\t }\n\t\n\t // timeout\n\t if (timeout && !this._timer) {\n\t this._timer = setTimeout(function(){\n\t self.timedout = true;\n\t self.abort();\n\t }, timeout);\n\t }\n\t\n\t // querystring\n\t if (query) {\n\t query = request.serializeObject(query);\n\t this.url += ~this.url.indexOf('?')\n\t ? '&' + query\n\t : '?' + query;\n\t }\n\t\n\t // initiate request\n\t xhr.open(this.method, this.url, true);\n\t\n\t // CORS\n\t if (this._withCredentials) xhr.withCredentials = true;\n\t\n\t // body\n\t if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n\t // serialize stuff\n\t var serialize = request.serialize[this.getHeader('Content-Type')];\n\t if (serialize) data = serialize(data);\n\t }\n\t\n\t // set header fields\n\t for (var field in this.header) {\n\t if (null == this.header[field]) continue;\n\t xhr.setRequestHeader(field, this.header[field]);\n\t }\n\t\n\t // send stuff\n\t this.emit('request', this);\n\t xhr.send(data);\n\t return this;\n\t};\n\t\n\t/**\n\t * Expose `Request`.\n\t */\n\t\n\trequest.Request = Request;\n\t\n\t/**\n\t * Issue a request:\n\t *\n\t * Examples:\n\t *\n\t * request('GET', '/users').end(callback)\n\t * request('/users').end(callback)\n\t * request('/users', callback)\n\t *\n\t * @param {String} method\n\t * @param {String|Function} url or callback\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\tfunction request(method, url) {\n\t // callback\n\t if ('function' == typeof url) {\n\t return new Request('GET', method).end(url);\n\t }\n\t\n\t // url first\n\t if (1 == arguments.length) {\n\t return new Request('GET', method);\n\t }\n\t\n\t return new Request(method, url);\n\t}\n\t\n\t/**\n\t * GET `url` with optional callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed|Function} data or fn\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.get = function(url, data, fn){\n\t var req = request('GET', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.query(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * HEAD `url` with optional callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed|Function} data or fn\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.head = function(url, data, fn){\n\t var req = request('HEAD', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * DELETE `url` with optional callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.del = function(url, fn){\n\t var req = request('DELETE', url);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * PATCH `url` with optional `data` and callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed} data\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.patch = function(url, data, fn){\n\t var req = request('PATCH', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * POST `url` with optional `data` and callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed} data\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.post = function(url, data, fn){\n\t var req = request('POST', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * PUT `url` with optional `data` and callback `fn(res)`.\n\t *\n\t * @param {String} url\n\t * @param {Mixed|Function} data or fn\n\t * @param {Function} fn\n\t * @return {Request}\n\t * @api public\n\t */\n\t\n\trequest.put = function(url, data, fn){\n\t var req = request('PUT', url);\n\t if ('function' == typeof data) fn = data, data = null;\n\t if (data) req.send(data);\n\t if (fn) req.end(fn);\n\t return req;\n\t};\n\t\n\t/**\n\t * Expose `request`.\n\t */\n\t\n\tmodule.exports = request;\n\n\n/***/ },\n/* 29 */\n/***/ function(module, exports) {\n\n\t\n\t/**\n\t * Expose `Emitter`.\n\t */\n\t\n\tmodule.exports = Emitter;\n\t\n\t/**\n\t * Initialize a new `Emitter`.\n\t *\n\t * @api public\n\t */\n\t\n\tfunction Emitter(obj) {\n\t if (obj) return mixin(obj);\n\t};\n\t\n\t/**\n\t * Mixin the emitter properties.\n\t *\n\t * @param {Object} obj\n\t * @return {Object}\n\t * @api private\n\t */\n\t\n\tfunction mixin(obj) {\n\t for (var key in Emitter.prototype) {\n\t obj[key] = Emitter.prototype[key];\n\t }\n\t return obj;\n\t}\n\t\n\t/**\n\t * Listen on the given `event` with `fn`.\n\t *\n\t * @param {String} event\n\t * @param {Function} fn\n\t * @return {Emitter}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.on =\n\tEmitter.prototype.addEventListener = function(event, fn){\n\t this._callbacks = this._callbacks || {};\n\t (this._callbacks[event] = this._callbacks[event] || [])\n\t .push(fn);\n\t return this;\n\t};\n\t\n\t/**\n\t * Adds an `event` listener that will be invoked a single\n\t * time then automatically removed.\n\t *\n\t * @param {String} event\n\t * @param {Function} fn\n\t * @return {Emitter}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.once = function(event, fn){\n\t var self = this;\n\t this._callbacks = this._callbacks || {};\n\t\n\t function on() {\n\t self.off(event, on);\n\t fn.apply(this, arguments);\n\t }\n\t\n\t on.fn = fn;\n\t this.on(event, on);\n\t return this;\n\t};\n\t\n\t/**\n\t * Remove the given callback for `event` or all\n\t * registered callbacks.\n\t *\n\t * @param {String} event\n\t * @param {Function} fn\n\t * @return {Emitter}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.off =\n\tEmitter.prototype.removeListener =\n\tEmitter.prototype.removeAllListeners =\n\tEmitter.prototype.removeEventListener = function(event, fn){\n\t this._callbacks = this._callbacks || {};\n\t\n\t // all\n\t if (0 == arguments.length) {\n\t this._callbacks = {};\n\t return this;\n\t }\n\t\n\t // specific event\n\t var callbacks = this._callbacks[event];\n\t if (!callbacks) return this;\n\t\n\t // remove all handlers\n\t if (1 == arguments.length) {\n\t delete this._callbacks[event];\n\t return this;\n\t }\n\t\n\t // remove specific handler\n\t var cb;\n\t for (var i = 0; i < callbacks.length; i++) {\n\t cb = callbacks[i];\n\t if (cb === fn || cb.fn === fn) {\n\t callbacks.splice(i, 1);\n\t break;\n\t }\n\t }\n\t return this;\n\t};\n\t\n\t/**\n\t * Emit `event` with the given args.\n\t *\n\t * @param {String} event\n\t * @param {Mixed} ...\n\t * @return {Emitter}\n\t */\n\t\n\tEmitter.prototype.emit = function(event){\n\t this._callbacks = this._callbacks || {};\n\t var args = [].slice.call(arguments, 1)\n\t , callbacks = this._callbacks[event];\n\t\n\t if (callbacks) {\n\t callbacks = callbacks.slice(0);\n\t for (var i = 0, len = callbacks.length; i < len; ++i) {\n\t callbacks[i].apply(this, args);\n\t }\n\t }\n\t\n\t return this;\n\t};\n\t\n\t/**\n\t * Return array of callbacks for `event`.\n\t *\n\t * @param {String} event\n\t * @return {Array}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.listeners = function(event){\n\t this._callbacks = this._callbacks || {};\n\t return this._callbacks[event] || [];\n\t};\n\t\n\t/**\n\t * Check if this emitter has `event` handlers.\n\t *\n\t * @param {String} event\n\t * @return {Boolean}\n\t * @api public\n\t */\n\t\n\tEmitter.prototype.hasListeners = function(event){\n\t return !! this.listeners(event).length;\n\t};\n\n\n/***/ },\n/* 30 */\n/***/ function(module, exports) {\n\n\t\n\t/**\n\t * Reduce `arr` with `fn`.\n\t *\n\t * @param {Array} arr\n\t * @param {Function} fn\n\t * @param {Mixed} initial\n\t *\n\t * TODO: combatible error handling?\n\t */\n\t\n\tmodule.exports = function(arr, fn, initial){ \n\t var idx = 0;\n\t var len = arr.length;\n\t var curr = arguments.length == 3\n\t ? initial\n\t : arr[idx++];\n\t\n\t while (idx < len) {\n\t curr = fn.call(null, curr, arr[idx], ++idx, arr);\n\t }\n\t \n\t return curr;\n\t};\n\n/***/ }\n/******/ ]);\n\n\n/** WEBPACK FOOTER **\n ** wpcom.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap f6bf303df898521c8380\n **/","\n\n/**\n * Module dependencies.\n */\n\nvar request_handler = require('wpcom-xhr-request');\n\n/**\n * Local module dependencies.\n */\n\nvar Me = require('./lib/me');\nvar Site = require('./lib/site');\nvar Users = require('./lib/users');\nvar Batch = require('./lib/batch');\nvar Req = require('./lib/util/request');\nvar sendRequest = require('./lib/util/send-request');\nvar debug = require('debug')('wpcom');\n\n/**\n * Local module constants\n */\nvar DEFAULT_ASYNC_TIMEOUT = 30000;\n\n/**\n * XMLHttpRequest (and CORS) API access method.\n *\n * API authentication is done via an (optional) access `token`,\n * which needs to be retrieved via OAuth.\n *\n * Request Handler is optional and XHR is defined as default.\n *\n * @param {String} [token] - OAuth API access token\n * @param {Function} [reqHandler] - function Request Handler\n * @public\n */\n\nfunction WPCOM(token, reqHandler) {\n if (!(this instanceof WPCOM)) {\n return new WPCOM(token, reqHandler);\n }\n\n // `token` is optional\n if ('function' === typeof token) {\n reqHandler = token;\n token = null;\n }\n\n if (token) {\n debug('Token defined: %s…', token.substring(0, 6));\n this.token = token;\n }\n\n // Set default request handler\n if (!reqHandler) {\n debug('No request handler. Adding default XHR request handler');\n\n this.request = function (params, fn) {\n params = params || {};\n\n // token is optional\n if (token) {\n params.authToken = token;\n }\n\n return request_handler(params, fn);\n };\n } else {\n this.request = reqHandler;\n }\n\n // Add Req instance\n this.req = new Req(this);\n\n // Default api version;\n this.apiVersion = '1.1';\n}\n\n/**\n * Get `Me` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.me = function () {\n return new Me(this);\n};\n\n/**\n * Get `Site` object instance\n *\n * @param {String} id\n * @api public\n */\n\nWPCOM.prototype.site = function (id) {\n return new Site(id, this);\n};\n\n/**\n * Get `Users` object instance\n *\n * @api public\n */\n\nWPCOM.prototype.users = function () {\n return new Users(this);\n};\n\n\nWPCOM.prototype.batch = function () {\n return new Batch(this);\n};\n\n/**\n * List Freshly Pressed Posts\n *\n * @param {Object} [query]\n * @param {Function} fn callback function\n * @api public\n */\n\nWPCOM.prototype.freshlyPressed = function (query, fn) {\n return this.req.get('/freshly-pressed', query, fn);\n};\n\n/**\n * Expose send-request\n * @TODO: use `this.req` instead of this method\n */\n\nWPCOM.prototype.sendRequest = function (params, query, body, fn) {\n var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.';\n if (console && console.warn) { //eslint-disable-line no-console\n console.warn(msg); //eslint-disable-line no-console\n } else {\n console.log(msg); //eslint-disable-line no-console\n }\n\n return sendRequest.call(this, params, query, body, fn);\n};\n\nif (!Promise.prototype.timeout) {\n\t/**\n * Returns a new promise with a deadline\n *\n * After the timeout interval, the promise will\n * reject. If the actual promise settles before\n * the deadline, the timer is cancelled.\n *\n * @param {number} delay how many ms to wait\n * @returns {Promise}\n */\n Promise.prototype.timeout = function (delay = DEFAULT_ASYNC_TIMEOUT) {\n let cancelTimeout, timer, timeout;\n\n timeout = new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error('Action timed out while waiting for response.'));\n }, delay);\n });\n\n cancelTimeout = () => {\n clearTimeout(timer);\n return this;\n };\n\n return Promise.race([ this.then(cancelTimeout).catch(cancelTimeout), timeout ]);\n };\n}\n\n/**\n * Expose `WPCOM` module\n */\n\nmodule.exports = WPCOM;\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","\n/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n && 'undefined' != typeof chrome.storage\n ? chrome.storage.local\n : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // is webkit? http://stackoverflow.com/a/16459606/376773\n return ('WebkitAppearance' in document.documentElement.style) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (window.console && (console.firebug || (console.exception && console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n return JSON.stringify(v);\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs() {\n var args = arguments;\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return args;\n\n var c = 'color: ' + this.color;\n args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n return args;\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n exports.storage.removeItem('debug');\n } else {\n exports.storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = exports.storage.debug;\n } catch(e) {}\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage(){\n try {\n return window.localStorage;\n } catch (e) {}\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/debug/browser.js\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar CommentLike = require('./commentlike');\n\n/**\n * Comment methods\n *\n * @param {String} [cid] comment id\n * @param {String} [pid] post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Comment(cid, pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Comment)) {\n return new Comment(cid, pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Return a single Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Return recent comments for a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.replies = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Create a comment on a post\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.add = function (query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit a comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.update = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Create a Comment as a reply to another Comment\n *\n * @param {Object} [query]\n * @param {String|Object} body\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.reply = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n body = 'string' === typeof body ? { content: body } : body;\n\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/replies/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.del =\nComment.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Create a `CommentLike` instance\n *\n * @api public\n */\n\nComment.prototype.like = function () {\n return CommentLike(this._cid, this._sid, this.wpcom);\n};\n\n/**\n * Get comment likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nComment.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Comment` module\n */\n\nmodule.exports = Comment;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/comment.js\n **/","\n/**\n * Module dependencies\n */\n\nvar qs = require('qs');\nvar debug = require('debug')('wpcom:send-request');\nvar debug_res = require('debug')('wpcom:send-request:res');\n\n/**\n * Request to WordPress REST API\n *\n * @param {String|Object} params\n * @param {Object} [query]\n * @param {Object} [body]\n * @param {Function} fn\n * @api private\n */\n\nmodule.exports = function (params, query, body, fn) {\n // `params` can be just the path (String)\n params = 'string' === typeof params ? { path : params } : params;\n\n debug('sendRequest(%o)', params.path);\n\n // set `method` request param\n params.method = (params.method || 'get').toUpperCase();\n\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // `body` is optional\n if ('function' === typeof body) {\n fn = body;\n body = null;\n }\n\n // query could be `null`\n query = query || {};\n\n // Handle special query parameters\n // - `apiVersion`\n if (query.apiVersion) {\n params.apiVersion = query.apiVersion;\n debug('apiVersion: %o', params.apiVersion);\n delete query.apiVersion;\n } else {\n params.apiVersion = this.apiVersion;\n }\n\n // - `proxyOrigin`\n if (query.proxyOrigin) {\n params.proxyOrigin = query.proxyOrigin;\n debug('proxyOrigin: %o', params.proxyOrigin);\n delete query.proxyOrigin;\n }\n\n // Stringify query object before to send\n query = qs.stringify(query, { arrayFormat: 'brackets' });\n\n // pass `query` and/or `body` to request params\n params.query = query;\n\n if (body) {\n params.body = body;\n }\n debug('params: %o', params);\n\n // if callback is provided, behave traditionally\n if ('function' === typeof fn) {\n // request method\n return this.request(params, function (err, res) {\n debug_res(res);\n fn(err, res);\n });\n }\n\n // but if not, return a Promise\n return new Promise((resolve, reject) => {\n this.request(params, (err, res) => {\n debug_res(res);\n err ? reject(err) : resolve(res);\n });\n });\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/send-request.js\n **/","// Load modules\n\n\n// Declare internals\n\nvar internals = {};\ninternals.hexTable = new Array(256);\nfor (var h = 0; h < 256; ++h) {\n internals.hexTable[h] = '%' + ((h < 16 ? '0' : '') + h.toString(16)).toUpperCase();\n}\n\n\nexports.arrayToObject = function (source, options) {\n\n var obj = options.plainObjects ? Object.create(null) : {};\n for (var i = 0, il = source.length; i < il; ++i) {\n if (typeof source[i] !== 'undefined') {\n\n obj[i] = source[i];\n }\n }\n\n return obj;\n};\n\n\nexports.merge = function (target, source, options) {\n\n if (!source) {\n return target;\n }\n\n if (typeof source !== 'object') {\n if (Array.isArray(target)) {\n target.push(source);\n }\n else if (typeof target === 'object') {\n target[source] = true;\n }\n else {\n target = [target, source];\n }\n\n return target;\n }\n\n if (typeof target !== 'object') {\n target = [target].concat(source);\n return target;\n }\n\n if (Array.isArray(target) &&\n !Array.isArray(source)) {\n\n target = exports.arrayToObject(target, options);\n }\n\n var keys = Object.keys(source);\n for (var k = 0, kl = keys.length; k < kl; ++k) {\n var key = keys[k];\n var value = source[key];\n\n if (!Object.prototype.hasOwnProperty.call(target, key)) {\n target[key] = value;\n }\n else {\n target[key] = exports.merge(target[key], value, options);\n }\n }\n\n return target;\n};\n\n\nexports.decode = function (str) {\n\n try {\n return decodeURIComponent(str.replace(/\\+/g, ' '));\n } catch (e) {\n return str;\n }\n};\n\nexports.encode = function (str) {\n\n // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n // It has been adapted here for stricter adherence to RFC 3986\n if (str.length === 0) {\n return str;\n }\n\n if (typeof str !== 'string') {\n str = '' + str;\n }\n\n var out = '';\n for (var i = 0, il = str.length; i < il; ++i) {\n var c = str.charCodeAt(i);\n\n if (c === 0x2D || // -\n c === 0x2E || // .\n c === 0x5F || // _\n c === 0x7E || // ~\n (c >= 0x30 && c <= 0x39) || // 0-9\n (c >= 0x41 && c <= 0x5A) || // a-z\n (c >= 0x61 && c <= 0x7A)) { // A-Z\n\n out += str[i];\n continue;\n }\n\n if (c < 0x80) {\n out += internals.hexTable[c];\n continue;\n }\n\n if (c < 0x800) {\n out += internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)];\n continue;\n }\n\n if (c < 0xD800 || c >= 0xE000) {\n out += internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n continue;\n }\n\n ++i;\n c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF));\n out += internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)];\n }\n\n return out;\n};\n\nexports.compact = function (obj, refs) {\n\n if (typeof obj !== 'object' ||\n obj === null) {\n\n return obj;\n }\n\n refs = refs || [];\n var lookup = refs.indexOf(obj);\n if (lookup !== -1) {\n return refs[lookup];\n }\n\n refs.push(obj);\n\n if (Array.isArray(obj)) {\n var compacted = [];\n\n for (var i = 0, il = obj.length; i < il; ++i) {\n if (typeof obj[i] !== 'undefined') {\n compacted.push(obj[i]);\n }\n }\n\n return compacted;\n }\n\n var keys = Object.keys(obj);\n for (i = 0, il = keys.length; i < il; ++i) {\n var key = keys[i];\n obj[key] = exports.compact(obj[key], refs);\n }\n\n return obj;\n};\n\n\nexports.isRegExp = function (obj) {\n\n return Object.prototype.toString.call(obj) === '[object RegExp]';\n};\n\n\nexports.isBuffer = function (obj) {\n\n if (obj === null ||\n typeof obj === 'undefined') {\n\n return false;\n }\n\n return !!(obj.constructor &&\n obj.constructor.isBuffer &&\n obj.constructor.isBuffer(obj));\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/utils.js\n ** module id = 4\n ** module chunks = 0\n **/","/**\n * Create a `Batch` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Batch(wpcom) {\n if (!(this instanceof Batch)) {\n return new Batch(wpcom);\n }\n\n this.wpcom = wpcom;\n\n this.urls = [];\n}\n\n/**\n * Add url to batch requests\n *\n * @param {String} url\n * @api public\n */\n\nBatch.prototype.add = function (url) {\n this.urls.push(url);\n return this;\n};\n\n/**\n * Run the batch request\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nBatch.prototype.run = function (query={}, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n // add urls to query object\n query['urls'] = this.urls;\n\n return this.wpcom.req.get('/batch', query, fn);\n};\n\n/**\n * Expose `Batch` module\n */\n\nmodule.exports = Batch;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/batch.js\n **/","/**\n * Category methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Category(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Category)) {\n return new Category(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set category `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nCategory.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit category\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete category\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCategory.prototype['delete'] = Category.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/categories/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Category` module\n */\n\nmodule.exports = Category;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/category.js\n **/","/**\n * CommentLike methods\n *\n * @param {String} cid comment id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction CommentLike(cid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!cid) {\n throw new Error('`comment id` is not correctly defined');\n }\n\n if (!(this instanceof CommentLike)) {\n return new CommentLike(cid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._cid = cid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.mine =\nCommentLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/new';\n return this.wpcom.req.post(path, query, fn);\n};\n\n/**\n * Remove your Like from a Comment\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nCommentLike.prototype.del =\nCommentLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/comments/' + this._cid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `CommentLike` module\n */\n\nmodule.exports = CommentLike;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/commentlike.js\n **/","/**\n * Follow\n *\n * @param {String} site_id - site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Follow(site_id, wpcom) {\n if (!site_id) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Follow)) {\n return new Follow(site_id, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = site_id;\n}\n\n/**\n * Get the follow status for current\n * user on current blog sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.mine =\nFollow.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Follow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.follow =\nFollow.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Unfollow the site\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nFollow.prototype.unfollow =\nFollow.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/follows/mine/delete';\n return this.wpcom.req.del(path, query, null, fn);\n};\n\n/**\n * Expose `Follow` module\n */\n\nmodule.exports = Follow;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/follow.js\n **/","/**\n * Like methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Like(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Like)) {\n return new Like(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your Like status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.mine =\nLike.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Like a post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.add = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/new';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Remove your Like from a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nLike.prototype.del =\nLike.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/likes/mine/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Like` module\n */\n\nmodule.exports = Like;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/like.js\n **/","/**\n * Create a `Me` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Me(wpcom) {\n if (!(this instanceof Me)) {\n return new Me(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * Meta data about auth token's User\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/me', query, fn);\n};\n\n/**\n * A list of the current user's sites\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api private\n */\n\nMe.prototype.sites = function (query, fn) {\n return this.wpcom.req.get('/me/sites', query, fn);\n};\n\n/**\n * List the currently authorized user's likes\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.likes = function (query, fn) {\n return this.wpcom.req.get('/me/likes', query, fn);\n};\n\n/**\n * A list of the current user's group\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMe.prototype.groups = function (query, fn) {\n return this.wpcom.req.get('/me/groups', query, fn);\n};\n\n\n/**\n * Expose `Me` module\n */\n\nmodule.exports = Me;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/me.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar fs = require('fs');\nvar debug = require('debug')('wpcom:media');\n\n/**\n * Media methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Media(id, sid, wpcom) {\n if (!(this instanceof Media)) {\n return new Media(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._id = id;\n\n if (!this._id) {\n debug('WARN: media `id` is not defined');\n }\n}\n\n/**\n * Get media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Edit media\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Add media file\n *\n * @param {Object} [query]\n * @param {String|Object|Array} files\n * @param {Function} fn\n */\n\nMedia.prototype.addFiles = function (query, files, fn) {\n if (undefined === fn) {\n if (undefined === files) {\n files = query;\n query = {};\n } else if ('function' === typeof files) {\n fn = files;\n files = query;\n query = {};\n }\n }\n\n var params = {\n path: '/sites/' + this._sid + '/media/new',\n formData: []\n };\n\n // process formData\n files = Array.isArray(files) ? files : [ files ];\n\n var i, f, isStream, isFile, k, param;\n for (i = 0; i < files.length; i++) {\n f = files[i];\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n\n isStream = !!f._readableState;\n isFile = 'undefined' !== typeof File && f instanceof File;\n\n debug('is stream: %s', isStream);\n debug('is file: %s', isFile);\n\n if (!isFile && !isStream) {\n // process file attributes like as `title`, `description`, ...\n for (k in f) {\n debug('add %o => %o', k, f[k]);\n if ('file' !== k) {\n param = 'attrs[' + i + '][' + k + ']';\n params.formData.push([ param, f[k] ]);\n }\n }\n // set file path\n f = f.file;\n f = 'string' === typeof f ? fs.createReadStream(f) : f;\n }\n\n params.formData.push([ 'media[]', f ]);\n }\n\n return this.wpcom.req.post(params, query, null, fn);\n};\n\n/**\n * Add media files from URL\n *\n * @param {Object} [query]\n * @param {String|Array|Object} files\n * @param {Function} fn\n */\n\nMedia.prototype.addUrls = function (query, media, fn) {\n if (undefined === fn) {\n if (undefined === media) {\n media = query;\n query = {};\n } else if ('function' === typeof media) {\n fn = media;\n media = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/media/new';\n var body = { media_urls: [] };\n\n // process formData\n var i, m, url, k;\n\n media = Array.isArray(media) ? media : [ media ];\n for (i = 0; i < media.length; i++) {\n m = media[i];\n\n if ('string' === typeof m) {\n url = m;\n } else {\n if (!body.attrs) {\n body.attrs = [];\n }\n\n // add attributes\n body.attrs[i] = {};\n for (k in m) {\n if ('url' !== k) {\n body.attrs[i][k] = m[k];\n }\n }\n url = m.url;\n }\n\n // push url into [media_url]\n body.media_urls.push(url);\n }\n\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Delete media\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nMedia.prototype['delete'] = Media.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/media/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Media` module\n */\n\nmodule.exports = Media;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/media.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Like = require('./like');\nvar Reblog = require('./reblog');\nvar Comment = require('./comment');\nvar debug = require('debug')('wpcom:post');\n\n/**\n * Post methods\n *\n * @param {String} id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Post(id, sid, wpcom) {\n if (!(this instanceof Post)) {\n return new Post(id, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n\n // set `id` and/or `slug` properties\n id = id || {};\n if ('object' !== typeof id) {\n this._id = id;\n } else {\n this._id = id.id;\n this._slug = id.slug;\n }\n}\n\n/**\n * Set post `id`\n *\n * @param {String} id\n * @api public\n */\n\nPost.prototype.id = function (id) {\n this._id = id;\n};\n\n/**\n * Set post `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nPost.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.get = function (query, fn) {\n if (!this._id && this._slug) {\n return this.getBySlug(query, fn);\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get post by slug\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.getBySlug = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.add = function (query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n var path = '/sites/' + this._sid + '/posts/new';\n\n return this.wpcom.req.post(path, query, body)\n .then(data => {\n // update POST object\n this._id = data.ID;\n debug('Set post _id: %s', this._id);\n\n this._slug = data.slug;\n debug('Set post _slug: %s', this._slug);\n\n if ('function' === typeof fn) {\n fn(null, data);\n } else {\n return Promise.resolve(data);\n }\n })\n .catch(err => {\n if ('function' === typeof fn) {\n fn(err);\n } else {\n return Promise.reject(err);\n }\n });\n};\n\n/**\n * Edit post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.del =\nPost.prototype['delete'] = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Restore post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.restore = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/restore';\n return this.wpcom.req.put(path, query, null, fn);\n};\n\n/**\n * Get post likes list\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.likesList = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/likes';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Search within a site for related posts\n *\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.related = function (body, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._id + '/related';\n return this.wpcom.req.put(path, body, null, fn);\n};\n\n/**\n * Create a `Like` instance\n *\n * @api public\n */\n\nPost.prototype.like = function () {\n return new Like(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Reblog` instance\n *\n * @api public\n */\n\nPost.prototype.reblog = function () {\n return new Reblog(this._id, this._sid, this.wpcom);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} [cid] comment id\n * @api public\n */\n\nPost.prototype.comment = function (cid) {\n return new Comment(cid, this._id, this._sid, this.wpcom);\n};\n\n/**\n * Return recent comments\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nPost.prototype.comments = function (query, fn) {\n var comment = new Comment(null, this._id, this._sid, this.wpcom);\n return comment.replies(query, fn);\n};\n\n/**\n * Expose `Post` module\n */\n\nmodule.exports = Post;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/post.js\n **/","/**\n * Reblog methods\n *\n * @param {String} pid post id\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Reblog(pid, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!pid) {\n throw new Error('`post id` is not correctly defined');\n }\n\n if (!(this instanceof Reblog)) {\n return new Reblog(pid, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._pid = pid;\n this._sid = sid;\n}\n\n/**\n * Get your reblog status for a Post\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.mine =\nReblog.prototype.state = function (query, fn) {\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Reblog a post\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.add = function (query, body, fn) {\n if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n\n if (body && !body.destination_site_id) {\n return fn(new Error('destination_site_id is not defined'));\n }\n\n var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Reblog a post to\n * It's almost an alias of Reblogs#add\n *\n * @param {Number|String} dest site id destination\n * @param {String} [note]\n * @param {Function} fn\n * @api public\n */\n\nReblog.prototype.to = function (dest, note, fn) {\n if (undefined === fn) {\n if (undefined === note) {\n note = null;\n } else if ('function' === typeof note) {\n fn = note;\n note = null;\n }\n }\n\n return this.add({ note: note, destination_site_id: dest }, fn);\n};\n\n/**\n * Expose `Reblog` module\n */\n\nmodule.exports = Reblog;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/reblog.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar Post = require('./post');\nvar Category = require('./category');\nvar Tag = require('./tag');\nvar Media = require('./media');\nvar Comment = require('./comment');\nvar Follow = require('./follow');\nvar debug = require('debug')('wpcom:site');\n\n/**\n * Resources array\n * A list of endpoints with the same structure\n */\n\nvar resources = [\n 'categories',\n 'comments',\n 'follows',\n 'media',\n 'posts',\n 'shortcodes',\n 'embeds',\n [ 'pageTemplates', 'page-templates' ],\n [ 'stats', 'stats' ],\n [ 'statsClicks', 'stats/clicks' ],\n [ 'statsComments', 'stats/comments' ],\n [ 'statsCommentFollowers', 'stats/comment-followers' ],\n [ 'statsCountryViews', 'stats/country-views' ],\n [ 'statsFollowers', 'stats/followers' ],\n [ 'statsPublicize', 'stats/publicize' ],\n [ 'statsReferrers', 'stats/referrers' ],\n [ 'statsSearchTerms', 'stats/search-terms' ],\n [ 'statsStreak', 'stats/streak' ],\n [ 'statsSummary', 'stats/summary' ],\n [ 'statsTags', 'stats/tags' ],\n [ 'statsTopAuthors', 'stats/top-authors' ],\n [ 'statsTopPosts', 'stats/top-posts' ],\n [ 'statsVideoPlays', 'stats/video-plays' ],\n [ 'statsVisits', 'stats/visits' ],\n 'tags',\n 'users'\n];\n\n/**\n * Create a Site instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Site(id, wpcom) {\n if (!(this instanceof Site)) {\n return new Site(id, wpcom);\n }\n\n this.wpcom = wpcom;\n\n debug('set %o site id', id);\n this._id = encodeURIComponent(id);\n}\n\n/**\n * Require site information\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.get = function (query, fn) {\n return this.wpcom.req.get('/sites/' + this._id, query, fn);\n};\n\n/**\n * List method builder\n *\n * @param {String} subpath\n * @param {Function}\n * @api private\n */\n\nfunction list(subpath) {\n\n /**\n * Create and return the List method\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\n var listMethod = function (query, fn) {\n var path = '/sites/' + this._id + '/' + subpath;\n return this.wpcom.req.get(path, query, fn);\n };\n listMethod._publicAPI = true;\n return listMethod;\n}\n\n// walk for each resource and create related method\nvar i, res, isarr, name, subpath;\nfor (i = 0; i < resources.length; i++) {\n res = resources[i];\n isarr = Array.isArray(res);\n\n name = isarr ? res[0] : res + 'List';\n subpath = isarr ? res[1] : res;\n\n debug('adding method: %o - sub-path: %o - version: %s', ('site.' + name + '()'), subpath);\n Site.prototype[name] = list(subpath);\n}\n\n/**\n * :POST:\n * Create a `Post` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.post = function (id) {\n return new Post(id, this._id, this.wpcom);\n};\n\n/**\n * :POST:\n * Add a new blog post\n *\n * @param {Object} body\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addPost = function (body, fn) {\n var post = new Post(null, this._id, this.wpcom);\n return post.add(body, fn);\n};\n\n/**\n * :POST:\n * Delete a blog post\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} remove Post instance\n */\n\nSite.prototype.deletePost = function (id, fn) {\n var post = new Post(id, this._id, this.wpcom);\n return post.delete(fn);\n};\n\n/**\n * Create a `Media` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.media = function (id) {\n return new Media(id, this._id, this.wpcom);\n};\n\n/**\n * Add a media from a file\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaFiles = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addFiles(query, files, fn);\n};\n\n/**\n * Add a new media from url\n *\n * @param {Object} [query]\n * @param {Array|String} files\n * @param {Function} fn\n * @return {Post} new Post instance\n */\n\nSite.prototype.addMediaUrls = function (query, files, fn) {\n var media = new Media(null, this._id, this.wpcom);\n return media.addUrls(query, files, fn);\n};\n\n/**\n * Delete a blog media\n *\n * @param {String} id\n * @param {Function} fn\n * @return {Post} removed Media instance\n */\n\nSite.prototype.deleteMedia = function (id, fn) {\n var media = new Media(id, this._id, this.wpcom);\n return media.del(fn);\n};\n\n/**\n * Create a `Comment` instance\n *\n * @param {String} id\n * @api public\n */\n\nSite.prototype.comment = function (id) {\n return new Comment(id, null, this._id, this.wpcom);\n};\n\n/**\n * Create a `Follow` instance\n *\n * @api public\n */\n\nSite.prototype.follow = function () {\n return new Follow(this._id, this.wpcom);\n};\n\n/**\n * Create a `Category` instance\n * Set `cat` alias\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.cat = Site.prototype.category = function (slug) {\n return new Category(slug, this._id, this.wpcom);\n};\n\n/**\n * Create a `Tag` instance\n *\n * @param {String} [slug]\n * @api public\n */\n\nSite.prototype.tag = function (slug) {\n return new Tag(slug, this._id, this.wpcom);\n};\n\n/**\n * Get a rendered shortcode for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderShortcode = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected a url String');\n }\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.shortcode = url;\n\n var path = '/sites/' + this._id + '/shortcodes/render';\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get a rendered embed for a site.\n *\n * Note: The current user must have publishing access.\n *\n * @param {String} url\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.renderEmbed = function (url, query, fn) {\n if ('string' !== typeof url) {\n throw new TypeError('expected an embed String');\n }\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n query = query || {};\n query.embed_url = url;\n\n var path = '/sites/' + this._id + '/embeds/render';\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Mark a referrering domain as spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamNew = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/new';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Remove referrering domain from spam\n *\n * @param {String} domain\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsReferrersSpamDelete = function (domain, fn) {\n var path = '/sites/' + this._id + '/stats/referrers/spam/delete';\n var body = { domain: domain };\n\n return this.wpcom.req.post(path, body, null, fn);\n};\n\n/**\n * Get detailed stats about a VideoPress video\n *\n * @param {String} videoId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsVideo = function (videoId, query, fn) {\n var path = '/sites/' + this._id + '/stats/video/' + videoId;\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Get detailed stats about a particular post\n *\n * @param {String} postId\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nSite.prototype.statsPostViews = function (postId, query, fn) {\n var path = '/sites/' + this._id + '/stats/post/' + postId;\n\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Expose `Site` module\n */\n\nmodule.exports = Site;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/site.js\n **/","/**\n * Tag methods\n *\n * @param {String} [slug]\n * @param {String} sid site id\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Tag(slug, sid, wpcom) {\n if (!sid) {\n throw new Error('`site id` is not correctly defined');\n }\n\n if (!(this instanceof Tag)) {\n return new Tag(slug, sid, wpcom);\n }\n\n this.wpcom = wpcom;\n this._sid = sid;\n this._slug = slug;\n}\n\n/**\n * Set tag `slug`\n *\n * @param {String} slug\n * @api public\n */\n\nTag.prototype.slug = function (slug) {\n this._slug = slug;\n};\n\n/**\n * Get tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.get = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.get(path, query, fn);\n};\n\n/**\n * Add tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.add = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/new';\n return this.wpcom.req.post(path, query, body, fn);\n};\n\n/**\n * Edit tag\n *\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype.update = function (query, body, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;\n return this.wpcom.req.put(path, query, body, fn);\n};\n\n/**\n * Delete tag\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nTag.prototype['delete'] = Tag.prototype.del = function (query, fn) {\n var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';\n return this.wpcom.req.del(path, query, fn);\n};\n\n/**\n * Expose `Tag` module\n */\n\nmodule.exports = Tag;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/tag.js\n **/","/**\n * Create a `Users` instance\n *\n * @param {WPCOM} wpcom\n * @api public\n */\n\nfunction Users(wpcom) {\n if (!(this instanceof Users)) {\n return new Users(wpcom);\n }\n\n this.wpcom = wpcom;\n}\n\n/**\n * A list of @mention suggestions for the current user\n *\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nUsers.prototype.suggest = function (query, fn) {\n return this.wpcom.req.get('/users/suggest', query, fn);\n};\n\n/**\n * Expose `Users` module\n */\n\nmodule.exports = Users;\n\n\n/** WEBPACK FOOTER **\n ** ./lib/users.js\n **/","\n/**\n * Module dependencies.\n */\n\nvar sendRequest = require('./send-request');\n\n/**\n * Expose `Request` module\n */\n\n\nfunction Req(wpcom) {\n\n this.wpcom = wpcom;\n}\n\n/**\n * Request methods\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.get = function (params, query, fn) {\n // `query` is optional\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return sendRequest.call(this.wpcom, params, query, null, fn);\n};\n\n/**\n * Make `update` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Object} body\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.post =\nReq.prototype.put = function (params, query, body, fn) {\n if (undefined === fn) {\n if (undefined === body) {\n body = query;\n query = {};\n } else if ('function' === typeof body) {\n fn = body;\n body = query;\n query = {};\n }\n }\n\n // params can be a string\n params = 'string' === typeof params ? { path : params } : params;\n\n // request method\n params.method = 'post';\n\n return sendRequest.call(this.wpcom, params, query, body, fn);\n};\n\n/**\n * Make a `delete` request\n *\n * @param {Object|String} params\n * @param {Object} [query]\n * @param {Function} fn\n * @api public\n */\n\nReq.prototype.del = function (params, query, fn) {\n if ('function' === typeof query) {\n fn = query;\n query = {};\n }\n\n return this.post(params, query, null, fn);\n};\n\n/**\n * Expose module\n */\n\nmodule.exports = Req;\n\n\n\n/** WEBPACK FOOTER **\n ** ./lib/util/request.js\n **/","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = debug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lowercased letter, i.e. \"n\".\n */\n\nexports.formatters = {};\n\n/**\n * Previously assigned color.\n */\n\nvar prevColor = 0;\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n *\n * @return {Number}\n * @api private\n */\n\nfunction selectColor() {\n return exports.colors[prevColor++ % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction debug(namespace) {\n\n // define the `disabled` version\n function disabled() {\n }\n disabled.enabled = false;\n\n // define the `enabled` version\n function enabled() {\n\n var self = enabled;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // add the `color` if not set\n if (null == self.useColors) self.useColors = exports.useColors();\n if (null == self.color && self.useColors) self.color = selectColor();\n\n var args = Array.prototype.slice.call(arguments);\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %o\n args = ['%o'].concat(args);\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n if ('function' === typeof exports.formatArgs) {\n args = exports.formatArgs.apply(self, args);\n }\n var logFn = enabled.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n enabled.enabled = true;\n\n var fn = exports.enabled(namespace) ? enabled : disabled;\n\n fn.namespace = namespace;\n\n return fn;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n var split = (namespaces || '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/debug/debug.js\n ** module id = 18\n ** module chunks = 0\n **/","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} options\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options){\n options = options || {};\n if ('string' == typeof val) return parse(val);\n return options.long\n ? long(val)\n : short(val);\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = '' + str;\n if (str.length > 10000) return;\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n if (!match) return;\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction short(ms) {\n if (ms >= d) return Math.round(ms / d) + 'd';\n if (ms >= h) return Math.round(ms / h) + 'h';\n if (ms >= m) return Math.round(ms / m) + 'm';\n if (ms >= s) return Math.round(ms / s) + 's';\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction long(ms) {\n return plural(ms, d, 'day')\n || plural(ms, h, 'hour')\n || plural(ms, m, 'minute')\n || plural(ms, s, 'second')\n || ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) return;\n if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/debug/~/ms/index.js\n ** module id = 19\n ** module chunks = 0\n **/","// Load modules\n\nvar Stringify = require('./stringify');\nvar Parse = require('./parse');\n\n\n// Declare internals\n\nvar internals = {};\n\n\nmodule.exports = {\n stringify: Stringify,\n parse: Parse\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/index.js\n ** module id = 20\n ** module chunks = 0\n **/","// Load modules\n\nvar Utils = require('./utils');\n\n\n// Declare internals\n\nvar internals = {\n delimiter: '&',\n depth: 5,\n arrayLimit: 20,\n parameterLimit: 1000,\n strictNullHandling: false,\n plainObjects: false,\n allowPrototypes: false\n};\n\n\ninternals.parseValues = function (str, options) {\n\n var obj = {};\n var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);\n\n for (var i = 0, il = parts.length; i < il; ++i) {\n var part = parts[i];\n var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;\n\n if (pos === -1) {\n obj[Utils.decode(part)] = '';\n\n if (options.strictNullHandling) {\n obj[Utils.decode(part)] = null;\n }\n }\n else {\n var key = Utils.decode(part.slice(0, pos));\n var val = Utils.decode(part.slice(pos + 1));\n\n if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n obj[key] = val;\n }\n else {\n obj[key] = [].concat(obj[key]).concat(val);\n }\n }\n }\n\n return obj;\n};\n\n\ninternals.parseObject = function (chain, val, options) {\n\n if (!chain.length) {\n return val;\n }\n\n var root = chain.shift();\n\n var obj;\n if (root === '[]') {\n obj = [];\n obj = obj.concat(internals.parseObject(chain, val, options));\n }\n else {\n obj = options.plainObjects ? Object.create(null) : {};\n var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;\n var index = parseInt(cleanRoot, 10);\n var indexString = '' + index;\n if (!isNaN(index) &&\n root !== cleanRoot &&\n indexString === cleanRoot &&\n index >= 0 &&\n (options.parseArrays &&\n index <= options.arrayLimit)) {\n\n obj = [];\n obj[index] = internals.parseObject(chain, val, options);\n }\n else {\n obj[cleanRoot] = internals.parseObject(chain, val, options);\n }\n }\n\n return obj;\n};\n\n\ninternals.parseKeys = function (key, val, options) {\n\n if (!key) {\n return;\n }\n\n // Transform dot notation to bracket notation\n\n if (options.allowDots) {\n key = key.replace(/\\.([^\\.\\[]+)/g, '[$1]');\n }\n\n // The regex chunks\n\n var parent = /^([^\\[\\]]*)/;\n var child = /(\\[[^\\[\\]]*\\])/g;\n\n // Get the parent\n\n var segment = parent.exec(key);\n\n // Stash the parent if it exists\n\n var keys = [];\n if (segment[1]) {\n // If we aren't using plain objects, optionally prefix keys\n // that would overwrite object prototype properties\n if (!options.plainObjects &&\n Object.prototype.hasOwnProperty(segment[1])) {\n\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(segment[1]);\n }\n\n // Loop through children appending to the array until we hit depth\n\n var i = 0;\n while ((segment = child.exec(key)) !== null && i < options.depth) {\n\n ++i;\n if (!options.plainObjects &&\n Object.prototype.hasOwnProperty(segment[1].replace(/\\[|\\]/g, ''))) {\n\n if (!options.allowPrototypes) {\n continue;\n }\n }\n keys.push(segment[1]);\n }\n\n // If there's a remainder, just add whatever is left\n\n if (segment) {\n keys.push('[' + key.slice(segment.index) + ']');\n }\n\n return internals.parseObject(keys, val, options);\n};\n\n\nmodule.exports = function (str, options) {\n\n options = options || {};\n options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;\n options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;\n options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;\n options.parseArrays = options.parseArrays !== false;\n options.allowDots = options.allowDots !== false;\n options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects;\n options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes;\n options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;\n options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n\n if (str === '' ||\n str === null ||\n typeof str === 'undefined') {\n\n return options.plainObjects ? Object.create(null) : {};\n }\n\n var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;\n var obj = options.plainObjects ? Object.create(null) : {};\n\n // Iterate over the keys and setup the new object\n\n var keys = Object.keys(tempObj);\n for (var i = 0, il = keys.length; i < il; ++i) {\n var key = keys[i];\n var newObj = internals.parseKeys(key, tempObj[key], options);\n obj = Utils.merge(obj, newObj, options);\n }\n\n return Utils.compact(obj);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/parse.js\n ** module id = 21\n ** module chunks = 0\n **/","// Load modules\n\nvar Utils = require('./utils');\n\n\n// Declare internals\n\nvar internals = {\n delimiter: '&',\n arrayPrefixGenerators: {\n brackets: function (prefix, key) {\n\n return prefix + '[]';\n },\n indices: function (prefix, key) {\n\n return prefix + '[' + key + ']';\n },\n repeat: function (prefix, key) {\n\n return prefix;\n }\n },\n strictNullHandling: false\n};\n\n\ninternals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) {\n\n if (typeof filter === 'function') {\n obj = filter(prefix, obj);\n }\n else if (Utils.isBuffer(obj)) {\n obj = obj.toString();\n }\n else if (obj instanceof Date) {\n obj = obj.toISOString();\n }\n else if (obj === null) {\n if (strictNullHandling) {\n return Utils.encode(prefix);\n }\n\n obj = '';\n }\n\n if (typeof obj === 'string' ||\n typeof obj === 'number' ||\n typeof obj === 'boolean') {\n\n return [Utils.encode(prefix) + '=' + Utils.encode(obj)];\n }\n\n var values = [];\n\n if (typeof obj === 'undefined') {\n return values;\n }\n\n var objKeys = Array.isArray(filter) ? filter : Object.keys(obj);\n for (var i = 0, il = objKeys.length; i < il; ++i) {\n var key = objKeys[i];\n\n if (Array.isArray(obj)) {\n values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter));\n }\n else {\n values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter));\n }\n }\n\n return values;\n};\n\n\nmodule.exports = function (obj, options) {\n\n options = options || {};\n var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;\n var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;\n var objKeys;\n var filter;\n if (typeof options.filter === 'function') {\n filter = options.filter;\n obj = filter('', obj);\n }\n else if (Array.isArray(options.filter)) {\n objKeys = filter = options.filter;\n }\n\n var keys = [];\n\n if (typeof obj !== 'object' ||\n obj === null) {\n\n return '';\n }\n\n var arrayFormat;\n if (options.arrayFormat in internals.arrayPrefixGenerators) {\n arrayFormat = options.arrayFormat;\n }\n else if ('indices' in options) {\n arrayFormat = options.indices ? 'indices' : 'repeat';\n }\n else {\n arrayFormat = 'indices';\n }\n\n var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];\n\n if (!objKeys) {\n objKeys = Object.keys(obj);\n }\n for (var i = 0, il = objKeys.length; i < il; ++i) {\n var key = objKeys[i];\n keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter));\n }\n\n return keys.join(delimiter);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/qs/lib/stringify.js\n ** module id = 22\n ** module chunks = 0\n **/","\n/**\n * Module dependencies.\n */\n\nvar superagent = require('superagent');\nvar debug = require('debug')('wpcom-xhr-request');\n\n/**\n * Export a single `request` function.\n */\n\nmodule.exports = request;\n\n/**\n * WordPress.com REST API base endpoint.\n */\n\nvar proxyOrigin = 'https://public-api.wordpress.com';\n\n/**\n * Default WordPress.com REST API Version.\n */\n\nvar defaultApiVersion = '1';\n\n/**\n * Performs an XMLHttpRequest against the WordPress.com REST API.\n *\n * @param {Object|String} params\n * @param {Function} fn\n * @api public\n */\n\nfunction request (params, fn) {\n\n if ('string' == typeof params) {\n params = { path: params };\n }\n\n var method = (params.method || 'GET').toLowerCase();\n debug('API HTTP Method: %o', method);\n delete params.method;\n\n var apiVersion = params.apiVersion || defaultApiVersion;\n delete params.apiVersion;\n\n proxyOrigin = params.proxyOrigin || proxyOrigin;\n delete params.proxyOrigin;\n\n var url = proxyOrigin + '/rest/v' + apiVersion + params.path;\n debug('API URL: %o', url);\n delete params.path;\n\n // create HTTP Request object\n var req = superagent[method](url);\n\n // Token authentication\n if (params.authToken) {\n req.set('Authorization', 'Bearer ' + params.authToken);\n delete params.authToken;\n }\n\n // URL querystring values\n if (params.query) {\n req.query(params.query);\n debug('API send URL querystring: %o', params.query);\n delete params.query;\n }\n\n // POST API request body\n if (params.body) {\n req.send(params.body);\n debug('API send POST body: ', params.body);\n delete params.body;\n }\n\n // POST FormData (for `multipart/form-data`, usually a file upload)\n if (params.formData) {\n for (var i = 0; i < params.formData.length; i++) {\n var data = params.formData[i];\n var key = data[0];\n var value = data[1];\n debug('adding FormData field %o', key);\n req.field(key, value);\n }\n }\n\n // start the request\n req.end(function (err, res){\n if (err && !res) {\n return fn(err);\n }\n\n var body = res.body;\n var headers = res.headers;\n var statusCode = res.status;\n debug('%o -> %o status code', url, statusCode);\n\n if (body && headers) {\n body._headers = headers;\n }\n\n if (!err) {\n return fn(null, body);\n }\n\n err = new Error();\n err.statusCode = statusCode;\n for (var i in body) {\n err[i] = body[i];\n }\n\n if (body && body.error) {\n err.name = toTitle(body.error) + 'Error';\n }\n\n fn(err);\n });\n\n return req.xhr;\n}\n\nfunction toTitle (str) {\n if (!str || 'string' !== typeof str) return '';\n return str.replace(/((^|_)[a-z])/g, function ($1) {\n return $1.toUpperCase().replace('_', '');\n });\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/index.js\n ** module id = 24\n ** module chunks = 0\n **/","\n/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\n\n/**\n * Use chrome.storage.local if we are in an app\n */\n\nvar storage;\n\nif (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')\n storage = chrome.storage.local;\nelse\n storage = localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // is webkit? http://stackoverflow.com/a/16459606/376773\n return ('WebkitAppearance' in document.documentElement.style) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (window.console && (console.firebug || (console.exception && console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n return JSON.stringify(v);\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs() {\n var args = arguments;\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return args;\n\n var c = 'color: ' + this.color;\n args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n return args;\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n storage.removeItem('debug');\n } else {\n storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = storage.debug;\n } catch(e) {}\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage(){\n try {\n return window.localStorage;\n } catch (e) {}\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/debug/browser.js\n ** module id = 25\n ** module chunks = 0\n **/","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = debug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lowercased letter, i.e. \"n\".\n */\n\nexports.formatters = {};\n\n/**\n * Previously assigned color.\n */\n\nvar prevColor = 0;\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n *\n * @return {Number}\n * @api private\n */\n\nfunction selectColor() {\n return exports.colors[prevColor++ % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction debug(namespace) {\n\n // define the `disabled` version\n function disabled() {\n }\n disabled.enabled = false;\n\n // define the `enabled` version\n function enabled() {\n\n var self = enabled;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // add the `color` if not set\n if (null == self.useColors) self.useColors = exports.useColors();\n if (null == self.color && self.useColors) self.color = selectColor();\n\n var args = Array.prototype.slice.call(arguments);\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %o\n args = ['%o'].concat(args);\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n if ('function' === typeof exports.formatArgs) {\n args = exports.formatArgs.apply(self, args);\n }\n var logFn = enabled.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n enabled.enabled = true;\n\n var fn = exports.enabled(namespace) ? enabled : disabled;\n\n fn.namespace = namespace;\n\n return fn;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n var split = (namespaces || '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/debug/debug.js\n ** module id = 26\n ** module chunks = 0\n **/","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} options\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options){\n options = options || {};\n if ('string' == typeof val) return parse(val);\n return options.long\n ? long(val)\n : short(val);\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n if (!match) return;\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction short(ms) {\n if (ms >= d) return Math.round(ms / d) + 'd';\n if (ms >= h) return Math.round(ms / h) + 'h';\n if (ms >= m) return Math.round(ms / m) + 'm';\n if (ms >= s) return Math.round(ms / s) + 's';\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction long(ms) {\n return plural(ms, d, 'day')\n || plural(ms, h, 'hour')\n || plural(ms, m, 'minute')\n || plural(ms, s, 'second')\n || ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) return;\n if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/debug/~/ms/index.js\n ** module id = 27\n ** module chunks = 0\n **/","/**\n * Module dependencies.\n */\n\nvar Emitter = require('emitter');\nvar reduce = require('reduce');\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? (this || self)\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nrequest.getXHR = function () {\n if (root.XMLHttpRequest\n && (!root.location || 'file:' != root.location.protocol\n || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n};\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n // responseText is accessible only if responseType is '' or 'text' and on older browsers\n this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')\n ? this.xhr.responseText\n : null;\n this.statusText = this.req.xhr.statusText;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text ? this.text : this.xhr.response)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && (str.length || str instanceof Object)\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n if (status === 1223) {\n status = 204;\n }\n\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self);\n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n return self.callback(err);\n }\n\n self.emit('response', res);\n\n if (err) {\n return self.callback(err, res);\n }\n\n if (res.status >= 200 && res.status < 300) {\n return self.callback(err, res);\n }\n\n var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');\n new_err.original = err;\n new_err.response = res;\n new_err.status = res.status;\n\n self.callback(err || new_err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new root.FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new root.FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj || isHost(data)) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n fn(err, res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = request.getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n\n // In IE9, reads to any property (e.g. status) off of an aborted XHR will\n // result in the error \"Could not complete the operation due to error c00c023f\"\n var status;\n try { status = xhr.status } catch(e) { status = 0; }\n\n if (0 == status) {\n if (self.timedout) return self.timeoutError();\n if (self.aborted) return;\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n var handleProgress = function(e){\n if (e.total > 0) {\n e.percent = e.loaded / e.total * 100;\n }\n self.emit('progress', e);\n };\n if (this.hasListeners('progress')) {\n xhr.onprogress = handleProgress;\n }\n try {\n if (xhr.upload && this.hasListeners('progress')) {\n xhr.upload.onprogress = handleProgress;\n }\n } catch(e) {\n // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.\n // Reported here:\n // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.timedout = true;\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/superagent/lib/client.js\n ** module id = 28\n ** module chunks = 0\n **/","\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/superagent/~/component-emitter/index.js\n ** module id = 29\n ** module chunks = 0\n **/","\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/wpcom-xhr-request/~/superagent/~/reduce-component/index.js\n ** module id = 30\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file From 7021e6f340cf5ef922670582ca6bc02c8bb86cd2 Mon Sep 17 00:00:00 2001 From: mattsherman Date: Thu, 5 Nov 2015 16:57:09 -0500 Subject: [PATCH 35/37] Fixed `examples/browser-cors/upload-images.html` Changed to use `wpcom-oauth-cors` to auth user. Need to put client id and site in `examples/browser-cors/upload-images.html` in order to work. --- examples/browser-cors/upload-images.html | 49 +++++++++++++----------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/examples/browser-cors/upload-images.html b/examples/browser-cors/upload-images.html index 84a5968..87f5176 100644 --- a/examples/browser-cors/upload-images.html +++ b/examples/browser-cors/upload-images.html @@ -13,42 +13,47 @@

+ - - + + - + function onprogress (e) { + if (e.lengthComputable) { + var percentComplete = e.loaded / e.total * 100; + console.log('progress event! %s%', percentComplete.toFixed(2)); + } else { + // Unable to compute progress information since the total size is unknown + } + } + + diff --git a/examples/browser-cors/wpcom.js b/examples/browser-cors/wpcom.js new file mode 120000 index 0000000..c5b7081 --- /dev/null +++ b/examples/browser-cors/wpcom.js @@ -0,0 +1 @@ +../../dist/wpcom.js \ No newline at end of file From c77b18ddac0d0e7f844281b0a8f5d64e360cbb02 Mon Sep 17 00:00:00 2001 From: retrofox Date: Fri, 6 Nov 2015 11:58:12 -0300 Subject: [PATCH 37/37] example: rename uploading testing file --- examples/browser-cors/{upload-images.html => upload.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/browser-cors/{upload-images.html => upload.html} (100%) diff --git a/examples/browser-cors/upload-images.html b/examples/browser-cors/upload.html similarity index 100% rename from examples/browser-cors/upload-images.html rename to examples/browser-cors/upload.html