api-fetch.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681
  1. this["wp"] = this["wp"] || {}; this["wp"]["apiFetch"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 353);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 1:
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = this["wp"]["i18n"]; }());
  92. /***/ }),
  93. /***/ 10:
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
  97. function _defineProperty(obj, key, value) {
  98. if (key in obj) {
  99. Object.defineProperty(obj, key, {
  100. value: value,
  101. enumerable: true,
  102. configurable: true,
  103. writable: true
  104. });
  105. } else {
  106. obj[key] = value;
  107. }
  108. return obj;
  109. }
  110. /***/ }),
  111. /***/ 20:
  112. /***/ (function(module, exports, __webpack_require__) {
  113. module.exports = __webpack_require__(47);
  114. /***/ }),
  115. /***/ 21:
  116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117. "use strict";
  118. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
  119. function _objectWithoutPropertiesLoose(source, excluded) {
  120. if (source == null) return {};
  121. var target = {};
  122. var sourceKeys = Object.keys(source);
  123. var key, i;
  124. for (i = 0; i < sourceKeys.length; i++) {
  125. key = sourceKeys[i];
  126. if (excluded.indexOf(key) >= 0) continue;
  127. target[key] = source[key];
  128. }
  129. return target;
  130. }
  131. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
  132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; });
  133. function _objectWithoutProperties(source, excluded) {
  134. if (source == null) return {};
  135. var target = _objectWithoutPropertiesLoose(source, excluded);
  136. var key, i;
  137. if (Object.getOwnPropertySymbols) {
  138. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  139. for (i = 0; i < sourceSymbolKeys.length; i++) {
  140. key = sourceSymbolKeys[i];
  141. if (excluded.indexOf(key) >= 0) continue;
  142. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  143. target[key] = source[key];
  144. }
  145. }
  146. return target;
  147. }
  148. /***/ }),
  149. /***/ 26:
  150. /***/ (function(module, exports) {
  151. (function() { module.exports = this["wp"]["url"]; }());
  152. /***/ }),
  153. /***/ 353:
  154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  155. "use strict";
  156. __webpack_require__.r(__webpack_exports__);
  157. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js
  158. var objectSpread = __webpack_require__(7);
  159. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js + 1 modules
  160. var objectWithoutProperties = __webpack_require__(21);
  161. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js
  162. function createNonceMiddleware(nonce) {
  163. function middleware(options, next) {
  164. var _options$headers = options.headers,
  165. headers = _options$headers === void 0 ? {} : _options$headers; // If an 'X-WP-Nonce' header (or any case-insensitive variation
  166. // thereof) was specified, no need to add a nonce header.
  167. for (var headerName in headers) {
  168. if (headerName.toLowerCase() === 'x-wp-nonce') {
  169. return next(options);
  170. }
  171. }
  172. return next(Object(objectSpread["a" /* default */])({}, options, {
  173. headers: Object(objectSpread["a" /* default */])({}, headers, {
  174. 'X-WP-Nonce': middleware.nonce
  175. })
  176. }));
  177. }
  178. middleware.nonce = nonce;
  179. return middleware;
  180. }
  181. /* harmony default export */ var middlewares_nonce = (createNonceMiddleware);
  182. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js
  183. var namespace_endpoint_namespaceAndEndpointMiddleware = function namespaceAndEndpointMiddleware(options, next) {
  184. var path = options.path;
  185. var namespaceTrimmed, endpointTrimmed;
  186. if (typeof options.namespace === 'string' && typeof options.endpoint === 'string') {
  187. namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, '');
  188. endpointTrimmed = options.endpoint.replace(/^\//, '');
  189. if (endpointTrimmed) {
  190. path = namespaceTrimmed + '/' + endpointTrimmed;
  191. } else {
  192. path = namespaceTrimmed;
  193. }
  194. }
  195. delete options.namespace;
  196. delete options.endpoint;
  197. return next(Object(objectSpread["a" /* default */])({}, options, {
  198. path: path
  199. }));
  200. };
  201. /* harmony default export */ var namespace_endpoint = (namespace_endpoint_namespaceAndEndpointMiddleware);
  202. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js
  203. /**
  204. * Internal dependencies
  205. */
  206. var root_url_createRootURLMiddleware = function createRootURLMiddleware(rootURL) {
  207. return function (options, next) {
  208. return namespace_endpoint(options, function (optionsWithPath) {
  209. var url = optionsWithPath.url;
  210. var path = optionsWithPath.path;
  211. var apiRoot;
  212. if (typeof path === 'string') {
  213. apiRoot = rootURL;
  214. if (-1 !== rootURL.indexOf('?')) {
  215. path = path.replace('?', '&');
  216. }
  217. path = path.replace(/^\//, ''); // API root may already include query parameter prefix if site is
  218. // configured to use plain permalinks.
  219. if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) {
  220. path = path.replace('?', '&');
  221. }
  222. url = apiRoot + path;
  223. }
  224. return next(Object(objectSpread["a" /* default */])({}, optionsWithPath, {
  225. url: url
  226. }));
  227. });
  228. };
  229. };
  230. /* harmony default export */ var root_url = (root_url_createRootURLMiddleware);
  231. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js
  232. var createPreloadingMiddleware = function createPreloadingMiddleware(preloadedData) {
  233. return function (options, next) {
  234. function getStablePath(path) {
  235. var splitted = path.split('?');
  236. var query = splitted[1];
  237. var base = splitted[0];
  238. if (!query) {
  239. return base;
  240. } // 'b=1&c=2&a=5'
  241. return base + '?' + query // [ 'b=1', 'c=2', 'a=5' ]
  242. .split('&') // [ [ 'b, '1' ], [ 'c', '2' ], [ 'a', '5' ] ]
  243. .map(function (entry) {
  244. return entry.split('=');
  245. }) // [ [ 'a', '5' ], [ 'b, '1' ], [ 'c', '2' ] ]
  246. .sort(function (a, b) {
  247. return a[0].localeCompare(b[0]);
  248. }) // [ 'a=5', 'b=1', 'c=2' ]
  249. .map(function (pair) {
  250. return pair.join('=');
  251. }) // 'a=5&b=1&c=2'
  252. .join('&');
  253. }
  254. var _options$parse = options.parse,
  255. parse = _options$parse === void 0 ? true : _options$parse;
  256. if (typeof options.path === 'string') {
  257. var method = options.method || 'GET';
  258. var path = getStablePath(options.path);
  259. if (parse && 'GET' === method && preloadedData[path]) {
  260. return Promise.resolve(preloadedData[path].body);
  261. } else if ('OPTIONS' === method && preloadedData[method] && preloadedData[method][path]) {
  262. return Promise.resolve(preloadedData[method][path]);
  263. }
  264. }
  265. return next(options);
  266. };
  267. };
  268. /* harmony default export */ var preloading = (createPreloadingMiddleware);
  269. // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
  270. var regenerator = __webpack_require__(20);
  271. var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
  272. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
  273. var asyncToGenerator = __webpack_require__(43);
  274. // EXTERNAL MODULE: external {"this":["wp","url"]}
  275. var external_this_wp_url_ = __webpack_require__(26);
  276. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/fetch-all-middleware.js
  277. /**
  278. * WordPress dependencies
  279. */
  280. // Apply query arguments to both URL and Path, whichever is present.
  281. var fetch_all_middleware_modifyQuery = function modifyQuery(_ref, queryArgs) {
  282. var path = _ref.path,
  283. url = _ref.url,
  284. options = Object(objectWithoutProperties["a" /* default */])(_ref, ["path", "url"]);
  285. return Object(objectSpread["a" /* default */])({}, options, {
  286. url: url && Object(external_this_wp_url_["addQueryArgs"])(url, queryArgs),
  287. path: path && Object(external_this_wp_url_["addQueryArgs"])(path, queryArgs)
  288. });
  289. }; // Duplicates parsing functionality from apiFetch.
  290. var parseResponse = function parseResponse(response) {
  291. return response.json ? response.json() : Promise.reject(response);
  292. };
  293. var parseLinkHeader = function parseLinkHeader(linkHeader) {
  294. if (!linkHeader) {
  295. return {};
  296. }
  297. var match = linkHeader.match(/<([^>]+)>; rel="next"/);
  298. return match ? {
  299. next: match[1]
  300. } : {};
  301. };
  302. var getNextPageUrl = function getNextPageUrl(response) {
  303. var _parseLinkHeader = parseLinkHeader(response.headers.get('link')),
  304. next = _parseLinkHeader.next;
  305. return next;
  306. };
  307. var requestContainsUnboundedQuery = function requestContainsUnboundedQuery(options) {
  308. var pathIsUnbounded = options.path && options.path.indexOf('per_page=-1') !== -1;
  309. var urlIsUnbounded = options.url && options.url.indexOf('per_page=-1') !== -1;
  310. return pathIsUnbounded || urlIsUnbounded;
  311. }; // The REST API enforces an upper limit on the per_page option. To handle large
  312. // collections, apiFetch consumers can pass `per_page=-1`; this middleware will
  313. // then recursively assemble a full response array from all available pages.
  314. var fetchAllMiddleware =
  315. /*#__PURE__*/
  316. function () {
  317. var _ref2 = Object(asyncToGenerator["a" /* default */])(
  318. /*#__PURE__*/
  319. regenerator_default.a.mark(function _callee(options, next) {
  320. var response, results, nextPage, mergedResults, nextResponse, nextResults;
  321. return regenerator_default.a.wrap(function _callee$(_context) {
  322. while (1) {
  323. switch (_context.prev = _context.next) {
  324. case 0:
  325. if (!(options.parse === false)) {
  326. _context.next = 2;
  327. break;
  328. }
  329. return _context.abrupt("return", next(options));
  330. case 2:
  331. if (requestContainsUnboundedQuery(options)) {
  332. _context.next = 4;
  333. break;
  334. }
  335. return _context.abrupt("return", next(options));
  336. case 4:
  337. _context.next = 6;
  338. return next(Object(objectSpread["a" /* default */])({}, fetch_all_middleware_modifyQuery(options, {
  339. per_page: 100
  340. }), {
  341. // Ensure headers are returned for page 1.
  342. parse: false
  343. }));
  344. case 6:
  345. response = _context.sent;
  346. _context.next = 9;
  347. return parseResponse(response);
  348. case 9:
  349. results = _context.sent;
  350. if (Array.isArray(results)) {
  351. _context.next = 12;
  352. break;
  353. }
  354. return _context.abrupt("return", results);
  355. case 12:
  356. nextPage = getNextPageUrl(response);
  357. if (nextPage) {
  358. _context.next = 15;
  359. break;
  360. }
  361. return _context.abrupt("return", results);
  362. case 15:
  363. // Iteratively fetch all remaining pages until no "next" header is found.
  364. mergedResults = [].concat(results);
  365. case 16:
  366. if (!nextPage) {
  367. _context.next = 27;
  368. break;
  369. }
  370. _context.next = 19;
  371. return next(Object(objectSpread["a" /* default */])({}, options, {
  372. // Ensure the URL for the next page is used instead of any provided path.
  373. path: undefined,
  374. url: nextPage,
  375. // Ensure we still get headers so we can identify the next page.
  376. parse: false
  377. }));
  378. case 19:
  379. nextResponse = _context.sent;
  380. _context.next = 22;
  381. return parseResponse(nextResponse);
  382. case 22:
  383. nextResults = _context.sent;
  384. mergedResults = mergedResults.concat(nextResults);
  385. nextPage = getNextPageUrl(nextResponse);
  386. _context.next = 16;
  387. break;
  388. case 27:
  389. return _context.abrupt("return", mergedResults);
  390. case 28:
  391. case "end":
  392. return _context.stop();
  393. }
  394. }
  395. }, _callee);
  396. }));
  397. return function fetchAllMiddleware(_x, _x2) {
  398. return _ref2.apply(this, arguments);
  399. };
  400. }();
  401. /* harmony default export */ var fetch_all_middleware = (fetchAllMiddleware);
  402. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js
  403. /**
  404. * Set of HTTP methods which are eligible to be overridden.
  405. *
  406. * @type {Set}
  407. */
  408. var OVERRIDE_METHODS = new Set(['PATCH', 'PUT', 'DELETE']);
  409. /**
  410. * Default request method.
  411. *
  412. * "A request has an associated method (a method). Unless stated otherwise it
  413. * is `GET`."
  414. *
  415. * @see https://fetch.spec.whatwg.org/#requests
  416. *
  417. * @type {string}
  418. */
  419. var DEFAULT_METHOD = 'GET';
  420. /**
  421. * API Fetch middleware which overrides the request method for HTTP v1
  422. * compatibility leveraging the REST API X-HTTP-Method-Override header.
  423. *
  424. * @param {Object} options Fetch options.
  425. * @param {Function} next [description]
  426. *
  427. * @return {*} The evaluated result of the remaining middleware chain.
  428. */
  429. function httpV1Middleware(options, next) {
  430. var _options = options,
  431. _options$method = _options.method,
  432. method = _options$method === void 0 ? DEFAULT_METHOD : _options$method;
  433. if (OVERRIDE_METHODS.has(method.toUpperCase())) {
  434. options = Object(objectSpread["a" /* default */])({}, options, {
  435. headers: Object(objectSpread["a" /* default */])({}, options.headers, {
  436. 'X-HTTP-Method-Override': method,
  437. 'Content-Type': 'application/json'
  438. }),
  439. method: 'POST'
  440. });
  441. }
  442. return next(options, next);
  443. }
  444. /* harmony default export */ var http_v1 = (httpV1Middleware);
  445. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/user-locale.js
  446. /**
  447. * WordPress dependencies
  448. */
  449. function userLocaleMiddleware(options, next) {
  450. if (typeof options.url === 'string' && !Object(external_this_wp_url_["hasQueryArg"])(options.url, '_locale')) {
  451. options.url = Object(external_this_wp_url_["addQueryArgs"])(options.url, {
  452. _locale: 'user'
  453. });
  454. }
  455. if (typeof options.path === 'string' && !Object(external_this_wp_url_["hasQueryArg"])(options.path, '_locale')) {
  456. options.path = Object(external_this_wp_url_["addQueryArgs"])(options.path, {
  457. _locale: 'user'
  458. });
  459. }
  460. return next(options, next);
  461. }
  462. /* harmony default export */ var user_locale = (userLocaleMiddleware);
  463. // EXTERNAL MODULE: external {"this":["wp","i18n"]}
  464. var external_this_wp_i18n_ = __webpack_require__(1);
  465. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/utils/response.js
  466. /**
  467. * WordPress dependencies
  468. */
  469. /**
  470. * Parses the apiFetch response.
  471. *
  472. * @param {Response} response
  473. * @param {boolean} shouldParseResponse
  474. *
  475. * @return {Promise} Parsed response
  476. */
  477. var response_parseResponse = function parseResponse(response) {
  478. var shouldParseResponse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  479. if (shouldParseResponse) {
  480. if (response.status === 204) {
  481. return null;
  482. }
  483. return response.json ? response.json() : Promise.reject(response);
  484. }
  485. return response;
  486. };
  487. var response_parseJsonAndNormalizeError = function parseJsonAndNormalizeError(response) {
  488. var invalidJsonError = {
  489. code: 'invalid_json',
  490. message: Object(external_this_wp_i18n_["__"])('The response is not a valid JSON response.')
  491. };
  492. if (!response || !response.json) {
  493. throw invalidJsonError;
  494. }
  495. return response.json().catch(function () {
  496. throw invalidJsonError;
  497. });
  498. };
  499. /**
  500. * Parses the apiFetch response properly and normalize response errors.
  501. *
  502. * @param {Response} response
  503. * @param {boolean} shouldParseResponse
  504. *
  505. * @return {Promise} Parsed response.
  506. */
  507. var parseResponseAndNormalizeError = function parseResponseAndNormalizeError(response) {
  508. var shouldParseResponse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  509. return Promise.resolve(response_parseResponse(response, shouldParseResponse)).catch(function (res) {
  510. return parseAndThrowError(res, shouldParseResponse);
  511. });
  512. };
  513. function parseAndThrowError(response) {
  514. var shouldParseResponse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  515. if (!shouldParseResponse) {
  516. throw response;
  517. }
  518. return response_parseJsonAndNormalizeError(response).then(function (error) {
  519. var unknownError = {
  520. code: 'unknown_error',
  521. message: Object(external_this_wp_i18n_["__"])('An unknown error occurred.')
  522. };
  523. throw error || unknownError;
  524. });
  525. }
  526. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/media-upload.js
  527. /**
  528. * WordPress dependencies
  529. */
  530. /**
  531. * Internal dependencies
  532. */
  533. /**
  534. * Middleware handling media upload failures and retries.
  535. *
  536. * @param {Object} options Fetch options.
  537. * @param {Function} next [description]
  538. *
  539. * @return {*} The evaluated result of the remaining middleware chain.
  540. */
  541. function mediaUploadMiddleware(options, next) {
  542. var isMediaUploadRequest = options.path && options.path.indexOf('/wp/v2/media') !== -1 || options.url && options.url.indexOf('/wp/v2/media') !== -1;
  543. if (!isMediaUploadRequest) {
  544. return next(options, next);
  545. }
  546. var retries = 0;
  547. var maxRetries = 5;
  548. var postProcess = function postProcess(attachmentId) {
  549. retries++;
  550. return next({
  551. path: "/wp/v2/media/".concat(attachmentId, "/post-process"),
  552. method: 'POST',
  553. data: {
  554. action: 'create-image-subsizes'
  555. },
  556. parse: false
  557. }).catch(function () {
  558. if (retries < maxRetries) {
  559. return postProcess(attachmentId);
  560. }
  561. next({
  562. path: "/wp/v2/media/".concat(attachmentId, "?force=true"),
  563. method: 'DELETE'
  564. });
  565. return Promise.reject();
  566. });
  567. };
  568. return next(Object(objectSpread["a" /* default */])({}, options, {
  569. parse: false
  570. })).catch(function (response) {
  571. var attachmentId = response.headers.get('x-wp-upload-attachment-id');
  572. if (response.status >= 500 && response.status < 600 && attachmentId) {
  573. return postProcess(attachmentId).catch(function () {
  574. if (options.parse !== false) {
  575. return Promise.reject({
  576. code: 'post_process',
  577. message: Object(external_this_wp_i18n_["__"])('Media upload failed. If this is a photo or a large image, please scale it down and try again.')
  578. });
  579. }
  580. return Promise.reject(response);
  581. });
  582. }
  583. return parseAndThrowError(response, options.parse);
  584. }).then(function (response) {
  585. return parseResponseAndNormalizeError(response, options.parse);
  586. });
  587. }
  588. /* harmony default export */ var media_upload = (mediaUploadMiddleware);
  589. // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/index.js
  590. /**
  591. * Internal dependencies
  592. */
  593. /**
  594. * Default set of header values which should be sent with every request unless
  595. * explicitly provided through apiFetch options.
  596. *
  597. * @type {Object}
  598. */
  599. var DEFAULT_HEADERS = {
  600. // The backend uses the Accept header as a condition for considering an
  601. // incoming request as a REST request.
  602. //
  603. // See: https://core.trac.wordpress.org/ticket/44534
  604. Accept: 'application/json, */*;q=0.1'
  605. };
  606. /**
  607. * Default set of fetch option values which should be sent with every request
  608. * unless explicitly provided through apiFetch options.
  609. *
  610. * @type {Object}
  611. */
  612. var DEFAULT_OPTIONS = {
  613. credentials: 'include'
  614. };
  615. var middlewares = [user_locale, namespace_endpoint, http_v1, fetch_all_middleware];
  616. function registerMiddleware(middleware) {
  617. middlewares.unshift(middleware);
  618. }
  619. var checkStatus = function checkStatus(response) {
  620. if (response.status >= 200 && response.status < 300) {
  621. return response;
  622. }
  623. throw response;
  624. };
  625. var build_module_defaultFetchHandler = function defaultFetchHandler(nextOptions) {
  626. var url = nextOptions.url,
  627. path = nextOptions.path,
  628. data = nextOptions.data,
  629. _nextOptions$parse = nextOptions.parse,
  630. parse = _nextOptions$parse === void 0 ? true : _nextOptions$parse,
  631. remainingOptions = Object(objectWithoutProperties["a" /* default */])(nextOptions, ["url", "path", "data", "parse"]);
  632. var body = nextOptions.body,
  633. headers = nextOptions.headers; // Merge explicitly-provided headers with default values.
  634. headers = Object(objectSpread["a" /* default */])({}, DEFAULT_HEADERS, headers); // The `data` property is a shorthand for sending a JSON body.
  635. if (data) {
  636. body = JSON.stringify(data);
  637. headers['Content-Type'] = 'application/json';
  638. }
  639. var responsePromise = window.fetch(url || path, Object(objectSpread["a" /* default */])({}, DEFAULT_OPTIONS, remainingOptions, {
  640. body: body,
  641. headers: headers
  642. }));
  643. return responsePromise.then(checkStatus).catch(function (response) {
  644. return parseAndThrowError(response, parse);
  645. }).then(function (response) {
  646. return parseResponseAndNormalizeError(response, parse);
  647. });
  648. };
  649. var fetchHandler = build_module_defaultFetchHandler;
  650. /**
  651. * Defines a custom fetch handler for making the requests that will override
  652. * the default one using window.fetch
  653. *
  654. * @param {Function} newFetchHandler The new fetch handler
  655. */
  656. function setFetchHandler(newFetchHandler) {
  657. fetchHandler = newFetchHandler;
  658. }
  659. function apiFetch(options) {
  660. var steps = [].concat(middlewares, [fetchHandler]);
  661. var createRunStep = function createRunStep(index) {
  662. return function (workingOptions) {
  663. var step = steps[index];
  664. if (index === steps.length - 1) {
  665. return step(workingOptions);
  666. }
  667. var next = createRunStep(index + 1);
  668. return step(workingOptions, next);
  669. };
  670. };
  671. return new Promise(function (resolve, reject) {
  672. createRunStep(0)(options).then(resolve).catch(function (error) {
  673. if (error.code !== 'rest_cookie_invalid_nonce') {
  674. return reject(error);
  675. } // If the nonce is invalid, refresh it and try again.
  676. window.fetch(apiFetch.nonceEndpoint).then(checkStatus).then(function (data) {
  677. return data.text();
  678. }).then(function (text) {
  679. apiFetch.nonceMiddleware.nonce = text;
  680. apiFetch(options).then(resolve).catch(reject);
  681. }).catch(reject);
  682. });
  683. });
  684. }
  685. apiFetch.use = registerMiddleware;
  686. apiFetch.setFetchHandler = setFetchHandler;
  687. apiFetch.createNonceMiddleware = middlewares_nonce;
  688. apiFetch.createPreloadingMiddleware = preloading;
  689. apiFetch.createRootURLMiddleware = root_url;
  690. apiFetch.fetchAllMiddleware = fetch_all_middleware;
  691. apiFetch.mediaUploadMiddleware = media_upload;
  692. /* harmony default export */ var build_module = __webpack_exports__["default"] = (apiFetch);
  693. /***/ }),
  694. /***/ 43:
  695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  696. "use strict";
  697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
  698. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  699. try {
  700. var info = gen[key](arg);
  701. var value = info.value;
  702. } catch (error) {
  703. reject(error);
  704. return;
  705. }
  706. if (info.done) {
  707. resolve(value);
  708. } else {
  709. Promise.resolve(value).then(_next, _throw);
  710. }
  711. }
  712. function _asyncToGenerator(fn) {
  713. return function () {
  714. var self = this,
  715. args = arguments;
  716. return new Promise(function (resolve, reject) {
  717. var gen = fn.apply(self, args);
  718. function _next(value) {
  719. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  720. }
  721. function _throw(err) {
  722. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  723. }
  724. _next(undefined);
  725. });
  726. };
  727. }
  728. /***/ }),
  729. /***/ 47:
  730. /***/ (function(module, exports, __webpack_require__) {
  731. /**
  732. * Copyright (c) 2014-present, Facebook, Inc.
  733. *
  734. * This source code is licensed under the MIT license found in the
  735. * LICENSE file in the root directory of this source tree.
  736. */
  737. var runtime = (function (exports) {
  738. "use strict";
  739. var Op = Object.prototype;
  740. var hasOwn = Op.hasOwnProperty;
  741. var undefined; // More compressible than void 0.
  742. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  743. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  744. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  745. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  746. function wrap(innerFn, outerFn, self, tryLocsList) {
  747. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  748. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  749. var generator = Object.create(protoGenerator.prototype);
  750. var context = new Context(tryLocsList || []);
  751. // The ._invoke method unifies the implementations of the .next,
  752. // .throw, and .return methods.
  753. generator._invoke = makeInvokeMethod(innerFn, self, context);
  754. return generator;
  755. }
  756. exports.wrap = wrap;
  757. // Try/catch helper to minimize deoptimizations. Returns a completion
  758. // record like context.tryEntries[i].completion. This interface could
  759. // have been (and was previously) designed to take a closure to be
  760. // invoked without arguments, but in all the cases we care about we
  761. // already have an existing method we want to call, so there's no need
  762. // to create a new function object. We can even get away with assuming
  763. // the method takes exactly one argument, since that happens to be true
  764. // in every case, so we don't have to touch the arguments object. The
  765. // only additional allocation required is the completion record, which
  766. // has a stable shape and so hopefully should be cheap to allocate.
  767. function tryCatch(fn, obj, arg) {
  768. try {
  769. return { type: "normal", arg: fn.call(obj, arg) };
  770. } catch (err) {
  771. return { type: "throw", arg: err };
  772. }
  773. }
  774. var GenStateSuspendedStart = "suspendedStart";
  775. var GenStateSuspendedYield = "suspendedYield";
  776. var GenStateExecuting = "executing";
  777. var GenStateCompleted = "completed";
  778. // Returning this object from the innerFn has the same effect as
  779. // breaking out of the dispatch switch statement.
  780. var ContinueSentinel = {};
  781. // Dummy constructor functions that we use as the .constructor and
  782. // .constructor.prototype properties for functions that return Generator
  783. // objects. For full spec compliance, you may wish to configure your
  784. // minifier not to mangle the names of these two functions.
  785. function Generator() {}
  786. function GeneratorFunction() {}
  787. function GeneratorFunctionPrototype() {}
  788. // This is a polyfill for %IteratorPrototype% for environments that
  789. // don't natively support it.
  790. var IteratorPrototype = {};
  791. IteratorPrototype[iteratorSymbol] = function () {
  792. return this;
  793. };
  794. var getProto = Object.getPrototypeOf;
  795. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  796. if (NativeIteratorPrototype &&
  797. NativeIteratorPrototype !== Op &&
  798. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  799. // This environment has a native %IteratorPrototype%; use it instead
  800. // of the polyfill.
  801. IteratorPrototype = NativeIteratorPrototype;
  802. }
  803. var Gp = GeneratorFunctionPrototype.prototype =
  804. Generator.prototype = Object.create(IteratorPrototype);
  805. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  806. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  807. GeneratorFunctionPrototype[toStringTagSymbol] =
  808. GeneratorFunction.displayName = "GeneratorFunction";
  809. // Helper for defining the .next, .throw, and .return methods of the
  810. // Iterator interface in terms of a single ._invoke method.
  811. function defineIteratorMethods(prototype) {
  812. ["next", "throw", "return"].forEach(function(method) {
  813. prototype[method] = function(arg) {
  814. return this._invoke(method, arg);
  815. };
  816. });
  817. }
  818. exports.isGeneratorFunction = function(genFun) {
  819. var ctor = typeof genFun === "function" && genFun.constructor;
  820. return ctor
  821. ? ctor === GeneratorFunction ||
  822. // For the native GeneratorFunction constructor, the best we can
  823. // do is to check its .name property.
  824. (ctor.displayName || ctor.name) === "GeneratorFunction"
  825. : false;
  826. };
  827. exports.mark = function(genFun) {
  828. if (Object.setPrototypeOf) {
  829. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  830. } else {
  831. genFun.__proto__ = GeneratorFunctionPrototype;
  832. if (!(toStringTagSymbol in genFun)) {
  833. genFun[toStringTagSymbol] = "GeneratorFunction";
  834. }
  835. }
  836. genFun.prototype = Object.create(Gp);
  837. return genFun;
  838. };
  839. // Within the body of any async function, `await x` is transformed to
  840. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  841. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  842. // meant to be awaited.
  843. exports.awrap = function(arg) {
  844. return { __await: arg };
  845. };
  846. function AsyncIterator(generator) {
  847. function invoke(method, arg, resolve, reject) {
  848. var record = tryCatch(generator[method], generator, arg);
  849. if (record.type === "throw") {
  850. reject(record.arg);
  851. } else {
  852. var result = record.arg;
  853. var value = result.value;
  854. if (value &&
  855. typeof value === "object" &&
  856. hasOwn.call(value, "__await")) {
  857. return Promise.resolve(value.__await).then(function(value) {
  858. invoke("next", value, resolve, reject);
  859. }, function(err) {
  860. invoke("throw", err, resolve, reject);
  861. });
  862. }
  863. return Promise.resolve(value).then(function(unwrapped) {
  864. // When a yielded Promise is resolved, its final value becomes
  865. // the .value of the Promise<{value,done}> result for the
  866. // current iteration.
  867. result.value = unwrapped;
  868. resolve(result);
  869. }, function(error) {
  870. // If a rejected Promise was yielded, throw the rejection back
  871. // into the async generator function so it can be handled there.
  872. return invoke("throw", error, resolve, reject);
  873. });
  874. }
  875. }
  876. var previousPromise;
  877. function enqueue(method, arg) {
  878. function callInvokeWithMethodAndArg() {
  879. return new Promise(function(resolve, reject) {
  880. invoke(method, arg, resolve, reject);
  881. });
  882. }
  883. return previousPromise =
  884. // If enqueue has been called before, then we want to wait until
  885. // all previous Promises have been resolved before calling invoke,
  886. // so that results are always delivered in the correct order. If
  887. // enqueue has not been called before, then it is important to
  888. // call invoke immediately, without waiting on a callback to fire,
  889. // so that the async generator function has the opportunity to do
  890. // any necessary setup in a predictable way. This predictability
  891. // is why the Promise constructor synchronously invokes its
  892. // executor callback, and why async functions synchronously
  893. // execute code before the first await. Since we implement simple
  894. // async functions in terms of async generators, it is especially
  895. // important to get this right, even though it requires care.
  896. previousPromise ? previousPromise.then(
  897. callInvokeWithMethodAndArg,
  898. // Avoid propagating failures to Promises returned by later
  899. // invocations of the iterator.
  900. callInvokeWithMethodAndArg
  901. ) : callInvokeWithMethodAndArg();
  902. }
  903. // Define the unified helper method that is used to implement .next,
  904. // .throw, and .return (see defineIteratorMethods).
  905. this._invoke = enqueue;
  906. }
  907. defineIteratorMethods(AsyncIterator.prototype);
  908. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  909. return this;
  910. };
  911. exports.AsyncIterator = AsyncIterator;
  912. // Note that simple async functions are implemented on top of
  913. // AsyncIterator objects; they just return a Promise for the value of
  914. // the final result produced by the iterator.
  915. exports.async = function(innerFn, outerFn, self, tryLocsList) {
  916. var iter = new AsyncIterator(
  917. wrap(innerFn, outerFn, self, tryLocsList)
  918. );
  919. return exports.isGeneratorFunction(outerFn)
  920. ? iter // If outerFn is a generator, return the full iterator.
  921. : iter.next().then(function(result) {
  922. return result.done ? result.value : iter.next();
  923. });
  924. };
  925. function makeInvokeMethod(innerFn, self, context) {
  926. var state = GenStateSuspendedStart;
  927. return function invoke(method, arg) {
  928. if (state === GenStateExecuting) {
  929. throw new Error("Generator is already running");
  930. }
  931. if (state === GenStateCompleted) {
  932. if (method === "throw") {
  933. throw arg;
  934. }
  935. // Be forgiving, per 25.3.3.3.3 of the spec:
  936. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  937. return doneResult();
  938. }
  939. context.method = method;
  940. context.arg = arg;
  941. while (true) {
  942. var delegate = context.delegate;
  943. if (delegate) {
  944. var delegateResult = maybeInvokeDelegate(delegate, context);
  945. if (delegateResult) {
  946. if (delegateResult === ContinueSentinel) continue;
  947. return delegateResult;
  948. }
  949. }
  950. if (context.method === "next") {
  951. // Setting context._sent for legacy support of Babel's
  952. // function.sent implementation.
  953. context.sent = context._sent = context.arg;
  954. } else if (context.method === "throw") {
  955. if (state === GenStateSuspendedStart) {
  956. state = GenStateCompleted;
  957. throw context.arg;
  958. }
  959. context.dispatchException(context.arg);
  960. } else if (context.method === "return") {
  961. context.abrupt("return", context.arg);
  962. }
  963. state = GenStateExecuting;
  964. var record = tryCatch(innerFn, self, context);
  965. if (record.type === "normal") {
  966. // If an exception is thrown from innerFn, we leave state ===
  967. // GenStateExecuting and loop back for another invocation.
  968. state = context.done
  969. ? GenStateCompleted
  970. : GenStateSuspendedYield;
  971. if (record.arg === ContinueSentinel) {
  972. continue;
  973. }
  974. return {
  975. value: record.arg,
  976. done: context.done
  977. };
  978. } else if (record.type === "throw") {
  979. state = GenStateCompleted;
  980. // Dispatch the exception by looping back around to the
  981. // context.dispatchException(context.arg) call above.
  982. context.method = "throw";
  983. context.arg = record.arg;
  984. }
  985. }
  986. };
  987. }
  988. // Call delegate.iterator[context.method](context.arg) and handle the
  989. // result, either by returning a { value, done } result from the
  990. // delegate iterator, or by modifying context.method and context.arg,
  991. // setting context.delegate to null, and returning the ContinueSentinel.
  992. function maybeInvokeDelegate(delegate, context) {
  993. var method = delegate.iterator[context.method];
  994. if (method === undefined) {
  995. // A .throw or .return when the delegate iterator has no .throw
  996. // method always terminates the yield* loop.
  997. context.delegate = null;
  998. if (context.method === "throw") {
  999. // Note: ["return"] must be used for ES3 parsing compatibility.
  1000. if (delegate.iterator["return"]) {
  1001. // If the delegate iterator has a return method, give it a
  1002. // chance to clean up.
  1003. context.method = "return";
  1004. context.arg = undefined;
  1005. maybeInvokeDelegate(delegate, context);
  1006. if (context.method === "throw") {
  1007. // If maybeInvokeDelegate(context) changed context.method from
  1008. // "return" to "throw", let that override the TypeError below.
  1009. return ContinueSentinel;
  1010. }
  1011. }
  1012. context.method = "throw";
  1013. context.arg = new TypeError(
  1014. "The iterator does not provide a 'throw' method");
  1015. }
  1016. return ContinueSentinel;
  1017. }
  1018. var record = tryCatch(method, delegate.iterator, context.arg);
  1019. if (record.type === "throw") {
  1020. context.method = "throw";
  1021. context.arg = record.arg;
  1022. context.delegate = null;
  1023. return ContinueSentinel;
  1024. }
  1025. var info = record.arg;
  1026. if (! info) {
  1027. context.method = "throw";
  1028. context.arg = new TypeError("iterator result is not an object");
  1029. context.delegate = null;
  1030. return ContinueSentinel;
  1031. }
  1032. if (info.done) {
  1033. // Assign the result of the finished delegate to the temporary
  1034. // variable specified by delegate.resultName (see delegateYield).
  1035. context[delegate.resultName] = info.value;
  1036. // Resume execution at the desired location (see delegateYield).
  1037. context.next = delegate.nextLoc;
  1038. // If context.method was "throw" but the delegate handled the
  1039. // exception, let the outer generator proceed normally. If
  1040. // context.method was "next", forget context.arg since it has been
  1041. // "consumed" by the delegate iterator. If context.method was
  1042. // "return", allow the original .return call to continue in the
  1043. // outer generator.
  1044. if (context.method !== "return") {
  1045. context.method = "next";
  1046. context.arg = undefined;
  1047. }
  1048. } else {
  1049. // Re-yield the result returned by the delegate method.
  1050. return info;
  1051. }
  1052. // The delegate iterator is finished, so forget it and continue with
  1053. // the outer generator.
  1054. context.delegate = null;
  1055. return ContinueSentinel;
  1056. }
  1057. // Define Generator.prototype.{next,throw,return} in terms of the
  1058. // unified ._invoke helper method.
  1059. defineIteratorMethods(Gp);
  1060. Gp[toStringTagSymbol] = "Generator";
  1061. // A Generator should always return itself as the iterator object when the
  1062. // @@iterator function is called on it. Some browsers' implementations of the
  1063. // iterator prototype chain incorrectly implement this, causing the Generator
  1064. // object to not be returned from this call. This ensures that doesn't happen.
  1065. // See https://github.com/facebook/regenerator/issues/274 for more details.
  1066. Gp[iteratorSymbol] = function() {
  1067. return this;
  1068. };
  1069. Gp.toString = function() {
  1070. return "[object Generator]";
  1071. };
  1072. function pushTryEntry(locs) {
  1073. var entry = { tryLoc: locs[0] };
  1074. if (1 in locs) {
  1075. entry.catchLoc = locs[1];
  1076. }
  1077. if (2 in locs) {
  1078. entry.finallyLoc = locs[2];
  1079. entry.afterLoc = locs[3];
  1080. }
  1081. this.tryEntries.push(entry);
  1082. }
  1083. function resetTryEntry(entry) {
  1084. var record = entry.completion || {};
  1085. record.type = "normal";
  1086. delete record.arg;
  1087. entry.completion = record;
  1088. }
  1089. function Context(tryLocsList) {
  1090. // The root entry object (effectively a try statement without a catch
  1091. // or a finally block) gives us a place to store values thrown from
  1092. // locations where there is no enclosing try statement.
  1093. this.tryEntries = [{ tryLoc: "root" }];
  1094. tryLocsList.forEach(pushTryEntry, this);
  1095. this.reset(true);
  1096. }
  1097. exports.keys = function(object) {
  1098. var keys = [];
  1099. for (var key in object) {
  1100. keys.push(key);
  1101. }
  1102. keys.reverse();
  1103. // Rather than returning an object with a next method, we keep
  1104. // things simple and return the next function itself.
  1105. return function next() {
  1106. while (keys.length) {
  1107. var key = keys.pop();
  1108. if (key in object) {
  1109. next.value = key;
  1110. next.done = false;
  1111. return next;
  1112. }
  1113. }
  1114. // To avoid creating an additional object, we just hang the .value
  1115. // and .done properties off the next function object itself. This
  1116. // also ensures that the minifier will not anonymize the function.
  1117. next.done = true;
  1118. return next;
  1119. };
  1120. };
  1121. function values(iterable) {
  1122. if (iterable) {
  1123. var iteratorMethod = iterable[iteratorSymbol];
  1124. if (iteratorMethod) {
  1125. return iteratorMethod.call(iterable);
  1126. }
  1127. if (typeof iterable.next === "function") {
  1128. return iterable;
  1129. }
  1130. if (!isNaN(iterable.length)) {
  1131. var i = -1, next = function next() {
  1132. while (++i < iterable.length) {
  1133. if (hasOwn.call(iterable, i)) {
  1134. next.value = iterable[i];
  1135. next.done = false;
  1136. return next;
  1137. }
  1138. }
  1139. next.value = undefined;
  1140. next.done = true;
  1141. return next;
  1142. };
  1143. return next.next = next;
  1144. }
  1145. }
  1146. // Return an iterator with no values.
  1147. return { next: doneResult };
  1148. }
  1149. exports.values = values;
  1150. function doneResult() {
  1151. return { value: undefined, done: true };
  1152. }
  1153. Context.prototype = {
  1154. constructor: Context,
  1155. reset: function(skipTempReset) {
  1156. this.prev = 0;
  1157. this.next = 0;
  1158. // Resetting context._sent for legacy support of Babel's
  1159. // function.sent implementation.
  1160. this.sent = this._sent = undefined;
  1161. this.done = false;
  1162. this.delegate = null;
  1163. this.method = "next";
  1164. this.arg = undefined;
  1165. this.tryEntries.forEach(resetTryEntry);
  1166. if (!skipTempReset) {
  1167. for (var name in this) {
  1168. // Not sure about the optimal order of these conditions:
  1169. if (name.charAt(0) === "t" &&
  1170. hasOwn.call(this, name) &&
  1171. !isNaN(+name.slice(1))) {
  1172. this[name] = undefined;
  1173. }
  1174. }
  1175. }
  1176. },
  1177. stop: function() {
  1178. this.done = true;
  1179. var rootEntry = this.tryEntries[0];
  1180. var rootRecord = rootEntry.completion;
  1181. if (rootRecord.type === "throw") {
  1182. throw rootRecord.arg;
  1183. }
  1184. return this.rval;
  1185. },
  1186. dispatchException: function(exception) {
  1187. if (this.done) {
  1188. throw exception;
  1189. }
  1190. var context = this;
  1191. function handle(loc, caught) {
  1192. record.type = "throw";
  1193. record.arg = exception;
  1194. context.next = loc;
  1195. if (caught) {
  1196. // If the dispatched exception was caught by a catch block,
  1197. // then let that catch block handle the exception normally.
  1198. context.method = "next";
  1199. context.arg = undefined;
  1200. }
  1201. return !! caught;
  1202. }
  1203. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1204. var entry = this.tryEntries[i];
  1205. var record = entry.completion;
  1206. if (entry.tryLoc === "root") {
  1207. // Exception thrown outside of any try block that could handle
  1208. // it, so set the completion value of the entire function to
  1209. // throw the exception.
  1210. return handle("end");
  1211. }
  1212. if (entry.tryLoc <= this.prev) {
  1213. var hasCatch = hasOwn.call(entry, "catchLoc");
  1214. var hasFinally = hasOwn.call(entry, "finallyLoc");
  1215. if (hasCatch && hasFinally) {
  1216. if (this.prev < entry.catchLoc) {
  1217. return handle(entry.catchLoc, true);
  1218. } else if (this.prev < entry.finallyLoc) {
  1219. return handle(entry.finallyLoc);
  1220. }
  1221. } else if (hasCatch) {
  1222. if (this.prev < entry.catchLoc) {
  1223. return handle(entry.catchLoc, true);
  1224. }
  1225. } else if (hasFinally) {
  1226. if (this.prev < entry.finallyLoc) {
  1227. return handle(entry.finallyLoc);
  1228. }
  1229. } else {
  1230. throw new Error("try statement without catch or finally");
  1231. }
  1232. }
  1233. }
  1234. },
  1235. abrupt: function(type, arg) {
  1236. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1237. var entry = this.tryEntries[i];
  1238. if (entry.tryLoc <= this.prev &&
  1239. hasOwn.call(entry, "finallyLoc") &&
  1240. this.prev < entry.finallyLoc) {
  1241. var finallyEntry = entry;
  1242. break;
  1243. }
  1244. }
  1245. if (finallyEntry &&
  1246. (type === "break" ||
  1247. type === "continue") &&
  1248. finallyEntry.tryLoc <= arg &&
  1249. arg <= finallyEntry.finallyLoc) {
  1250. // Ignore the finally entry if control is not jumping to a
  1251. // location outside the try/catch block.
  1252. finallyEntry = null;
  1253. }
  1254. var record = finallyEntry ? finallyEntry.completion : {};
  1255. record.type = type;
  1256. record.arg = arg;
  1257. if (finallyEntry) {
  1258. this.method = "next";
  1259. this.next = finallyEntry.finallyLoc;
  1260. return ContinueSentinel;
  1261. }
  1262. return this.complete(record);
  1263. },
  1264. complete: function(record, afterLoc) {
  1265. if (record.type === "throw") {
  1266. throw record.arg;
  1267. }
  1268. if (record.type === "break" ||
  1269. record.type === "continue") {
  1270. this.next = record.arg;
  1271. } else if (record.type === "return") {
  1272. this.rval = this.arg = record.arg;
  1273. this.method = "return";
  1274. this.next = "end";
  1275. } else if (record.type === "normal" && afterLoc) {
  1276. this.next = afterLoc;
  1277. }
  1278. return ContinueSentinel;
  1279. },
  1280. finish: function(finallyLoc) {
  1281. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1282. var entry = this.tryEntries[i];
  1283. if (entry.finallyLoc === finallyLoc) {
  1284. this.complete(entry.completion, entry.afterLoc);
  1285. resetTryEntry(entry);
  1286. return ContinueSentinel;
  1287. }
  1288. }
  1289. },
  1290. "catch": function(tryLoc) {
  1291. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1292. var entry = this.tryEntries[i];
  1293. if (entry.tryLoc === tryLoc) {
  1294. var record = entry.completion;
  1295. if (record.type === "throw") {
  1296. var thrown = record.arg;
  1297. resetTryEntry(entry);
  1298. }
  1299. return thrown;
  1300. }
  1301. }
  1302. // The context.catch method must only be called with a location
  1303. // argument that corresponds to a known catch block.
  1304. throw new Error("illegal catch attempt");
  1305. },
  1306. delegateYield: function(iterable, resultName, nextLoc) {
  1307. this.delegate = {
  1308. iterator: values(iterable),
  1309. resultName: resultName,
  1310. nextLoc: nextLoc
  1311. };
  1312. if (this.method === "next") {
  1313. // Deliberately forget the last sent value so that we don't
  1314. // accidentally pass it on to the delegate.
  1315. this.arg = undefined;
  1316. }
  1317. return ContinueSentinel;
  1318. }
  1319. };
  1320. // Regardless of whether this script is executing as a CommonJS module
  1321. // or not, return the runtime object so that we can declare the variable
  1322. // regeneratorRuntime in the outer scope, which allows this module to be
  1323. // injected easily by `bin/regenerator --include-runtime script.js`.
  1324. return exports;
  1325. }(
  1326. // If this script is executing as a CommonJS module, use module.exports
  1327. // as the regeneratorRuntime namespace. Otherwise create a new empty
  1328. // object. Either way, the resulting object will be used to initialize
  1329. // the regeneratorRuntime variable at the top of this file.
  1330. true ? module.exports : undefined
  1331. ));
  1332. try {
  1333. regeneratorRuntime = runtime;
  1334. } catch (accidentalStrictMode) {
  1335. // This module should not be running in strict mode, so the above
  1336. // assignment should always work unless something is misconfigured. Just
  1337. // in case runtime.js accidentally runs in strict mode, we can escape
  1338. // strict mode using a global Function call. This could conceivably fail
  1339. // if a Content Security Policy forbids using Function, but in that case
  1340. // the proper solution is to fix the accidental strict mode problem. If
  1341. // you've misconfigured your bundler to force strict mode and applied a
  1342. // CSP to forbid Function, and you're not willing to fix either of those
  1343. // problems, please detail your unique predicament in a GitHub issue.
  1344. Function("r", "regeneratorRuntime = r")(runtime);
  1345. }
  1346. /***/ }),
  1347. /***/ 7:
  1348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1349. "use strict";
  1350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; });
  1351. /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
  1352. function _objectSpread(target) {
  1353. for (var i = 1; i < arguments.length; i++) {
  1354. var source = arguments[i] != null ? arguments[i] : {};
  1355. var ownKeys = Object.keys(source);
  1356. if (typeof Object.getOwnPropertySymbols === 'function') {
  1357. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  1358. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  1359. }));
  1360. }
  1361. ownKeys.forEach(function (key) {
  1362. Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]);
  1363. });
  1364. }
  1365. return target;
  1366. }
  1367. /***/ })
  1368. /******/ })["default"];