microcms-js-sdk 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,6 +106,49 @@ client
106
106
  .catch((err) => console.error(err));
107
107
  ```
108
108
 
109
+ #### Get all content ids
110
+
111
+ This function can be used to retrieve all content IDs only.
112
+ Since `filters` and `draftKey` can also be specified, it is possible to retrieve only the content IDs for a specific category, or to include content from a specific draft. \
113
+ The `alternateField` property can also be used to address cases where the value of a field other than content ID is used in a URL, etc.
114
+
115
+ ```javascript
116
+ client
117
+ .getAllContentIds({
118
+ endpoint: 'endpoint',
119
+ })
120
+ .then((res) => console.log(res))
121
+ .catch((err) => console.error(err));
122
+
123
+ // Get all content ids with filters
124
+ client
125
+ .getAllContentIds({
126
+ endpoint: 'endpoint',
127
+ filters: 'category[equals]uN28Folyn',
128
+ })
129
+ .then((res) => console.log(res))
130
+ .catch((err) => console.error(err));
131
+
132
+ // Get all content ids with draftKey
133
+ client
134
+ .getAllContentIds({
135
+ endpoint: 'endpoint',
136
+ draftKey: 'draftKey',
137
+ })
138
+ .then((res) => console.log(res))
139
+ .catch((err) => console.error(err));
140
+
141
+ // Get all content ids with alternateField
142
+ client
143
+ .getAllContentIds({
144
+ endpoint: 'endpoint',
145
+ alternateField: 'url',
146
+ })
147
+ .then((res) => console.log(res))
148
+ .catch((err) => console.error(err));
149
+ ```
150
+ ```
151
+
109
152
  #### CREATE API
110
153
 
111
154
  The following is how to use the write system when making a request to the write system API.
@@ -219,7 +262,7 @@ type Content = {
219
262
  /**
220
263
  * // getList response type
221
264
  * {
222
- * contents: Content; // This is Content type
265
+ * contents: Content[]; // This is array type of Content
223
266
  * totalCount: number;
224
267
  * limit: number;
225
268
  * offset: number;
@@ -253,6 +296,16 @@ client.getListDetail<Content>({ //other })
253
296
  client.getObject<Content>({ //other })
254
297
  ```
255
298
 
299
+ The type of `getAllContentIds` is as follows.
300
+
301
+ ```typescript
302
+ /**
303
+ * // getAllContentIds response type
304
+ * string[] // This is array type of string
305
+ */
306
+ client.getAllContentIds({ //other })
307
+ ```
308
+
256
309
  Write functions can also be performed type-safely.
257
310
 
258
311
  ```typescript
@@ -279,6 +332,44 @@ client.update<Content>({
279
332
  })
280
333
  ```
281
334
 
335
+ ## CustomRequestInit
336
+
337
+ ### Next.js App Router
338
+
339
+ You can now use the fetch option of the Next.js App Router as CustomRequestInit.
340
+ Please refer to the official Next.js documentation as the available options depend on the Next.js Type file.
341
+
342
+ [Functions: fetch \| Next\.js](https://nextjs.org/docs/app/api-reference/functions/fetch)
343
+
344
+ ```ts
345
+ const response = await client.getList({
346
+ customRequestInit: {
347
+ next: {
348
+ revalidate: 60,
349
+ },
350
+ },
351
+ endpoint: "endpoint",
352
+ });
353
+ ```
354
+
355
+ ### AbortController: abort() method
356
+
357
+ You can abort fetch requests.
358
+
359
+ ```ts
360
+ const controller = new AbortController()
361
+ const response = await client.getObject({
362
+ customRequestInit: {
363
+ signal: controller.signal
364
+ },
365
+ endpoint: "config",
366
+ });
367
+
368
+ setTimeout(() => {
369
+ controller.abort()
370
+ }, 1000)
371
+ ```
372
+
282
373
  ## Tips
283
374
 
284
375
  ### Separate API keys for read and write
@@ -294,6 +385,7 @@ const writeClient = createClient({
294
385
  })
295
386
  ```
296
387
 
388
+
297
389
  # LICENSE
298
390
 
299
391
  Apache-2.0
@@ -1,2 +1 @@
1
- import e from"qs";import t,{Headers as n}from"cross-fetch";import r from"async-retry";var o=function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function i(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}u((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return c.label++,{value:s[1],done:!1};case 5:c.label++,r=s[1],s=[0];continue;case 7:s=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){c=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){c.label=s[1];break}if(6===s[0]&&c.label<o[1]){c.label=o[1],o=s;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(s);break}o[2]&&c.ops.pop(),c.trys.pop();continue}s=t.call(e,c)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var s=function(e){return"string"==typeof e},u=function(e){var n;return n=e||("undefined"==typeof fetch?t:fetch),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(void 0,e)}},a=function(e,t){var r=u(t),s="undefined"==typeof Headers?n:Headers;return function(t,n){return i(void 0,void 0,void 0,(function(){var i;return c(this,(function(c){return(i=new s(null==n?void 0:n.headers)).has("X-MICROCMS-API-KEY")||i.set("X-MICROCMS-API-KEY",e),[2,r(t,o(o({},n),{headers:i}))]}))}))}},d=function(t){var n=t.serviceDomain,o=t.apiKey,u=t.customFetch,d=t.retry;if(!n||!o)throw new Error("parameter is required (check serviceDomain and apiKey)");if(!s(n)||!s(o))throw new Error("parameter is not string");var f="https://".concat(n,".").concat("microcms.io","/api/").concat("v1"),l=function(t){var n=t.endpoint,s=t.contentId,l=t.queries,v=void 0===l?{}:l,p=t.method,h=t.customHeaders,m=t.customBody;return i(void 0,void 0,void 0,(function(){var t,l,y,w;return c(this,(function(b){switch(b.label){case 0:return t=a(o,u),l=function(t){if(null===(n=t)||"object"!=typeof n)throw new Error("queries is not object");var n;return e.stringify(t,{arrayFormat:"comma"})}(v),y="".concat(f,"/").concat(n).concat(s?"/".concat(s):"").concat(l?"?".concat(l):""),w=function(e){return i(void 0,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e.json()];case 1:return[2,null!=(t=n.sent().message)?t:null];case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},[4,r((function(e){return i(void 0,void 0,void 0,(function(){var n,r,o,i;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,6,,7]),[4,t(y,{method:p||"GET",headers:h,body:m})];case 1:return 429!==(n=c.sent()).status&&n.status>=400&&n.status<500?[4,w(n)]:[3,3];case 2:return r=c.sent(),[2,e(new Error("fetch API response status: ".concat(n.status).concat(r?"\n message is `".concat(r,"`"):"")))];case 3:return n.ok?[3,5]:[4,w(n)];case 4:return r=c.sent(),[2,Promise.reject(new Error("fetch API response status: ".concat(n.status).concat(r?"\n message is `".concat(r,"`"):"")))];case 5:return"DELETE"===p?[2]:[2,n.json()];case 6:if((o=c.sent()).data)throw o.data;if(null===(i=o.response)||void 0===i?void 0:i.data)throw o.response.data;return[2,Promise.reject(new Error("Network Error.\n Details: ".concat(o)))];case 7:return[2]}}))}))}),{retries:d?2:0,onRetry:function(e,t){console.log(e),console.log("Waiting for retry (".concat(t,"/").concat(2,")"))},minTimeout:5e3})];case 1:return[2,b.sent()]}}))}))};return{get:function(e){var t=e.endpoint,n=e.contentId,r=e.queries,o=void 0===r?{}:r;return i(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return t?[4,l({endpoint:t,contentId:n,queries:o})]:[2,Promise.reject(new Error("endpoint is required"))];case 1:return[2,e.sent()]}}))}))},getList:function(e){var t=e.endpoint,n=e.queries,r=void 0===n?{}:n;return i(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return t?[4,l({endpoint:t,queries:r})]:[2,Promise.reject(new Error("endpoint is required"))];case 1:return[2,e.sent()]}}))}))},getListDetail:function(e){var t=e.endpoint,n=e.contentId,r=e.queries,o=void 0===r?{}:r;return i(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return t?[4,l({endpoint:t,contentId:n,queries:o})]:[2,Promise.reject(new Error("endpoint is required"))];case 1:return[2,e.sent()]}}))}))},getObject:function(e){var t=e.endpoint,n=e.queries,r=void 0===n?{}:n;return i(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return t?[4,l({endpoint:t,queries:r})]:[2,Promise.reject(new Error("endpoint is required"))];case 1:return[2,e.sent()]}}))}))},create:function(e){var t=e.endpoint,n=e.contentId,r=e.content,o=e.isDraft,s=void 0!==o&&o;return i(void 0,void 0,void 0,(function(){var e,o,i,u;return c(this,(function(c){return t?(e=s?{status:"draft"}:{},o=n?"PUT":"POST",i={"Content-Type":"application/json"},u=JSON.stringify(r),[2,l({endpoint:t,contentId:n,queries:e,method:o,customHeaders:i,customBody:u})]):[2,Promise.reject(new Error("endpoint is required"))]}))}))},update:function(e){var t=e.endpoint,n=e.contentId,r=e.content;return i(void 0,void 0,void 0,(function(){var e,o;return c(this,(function(i){return t?("PATCH",e={"Content-Type":"application/json"},o=JSON.stringify(r),[2,l({endpoint:t,contentId:n,method:"PATCH",customHeaders:e,customBody:o})]):[2,Promise.reject(new Error("endpoint is required"))]}))}))},delete:function(e){var t=e.endpoint,n=e.contentId;return i(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return t?n?("DELETE",[4,l({endpoint:t,contentId:n,method:"DELETE"})]):[2,Promise.reject(new Error("contentId is required"))]:[2,Promise.reject(new Error("endpoint is required"))];case 1:return e.sent(),[2]}}))}))}}};export{d as createClient};
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWljcm9jbXMtanMtc2RrLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
1
+ function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(t){if(Array.isArray(t))return e(t)}function r(e,t,r,n,i,o,u){try{var c=e[o](u);var s=c.value}catch(e){r(e);return}if(c.done){t(s)}else{Promise.resolve(s).then(n,i)}}function n(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var u=e.apply(t,n);function c(e){r(u,i,o,c,s,"next",e)}function s(e){r(u,i,o,c,s,"throw",e)}c(undefined)})}}function i(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function o(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){i(e,t,r[t])})}return e}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function a(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{s(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function f(e){return t(e)||o(e)||d(e)||u()}function l(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function d(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function p(e,t){var r,n,i,o,u={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return(o={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o);function c(e){return function(t){return s([e,t])}}function s(o){if(r)throw new TypeError("Generator is already executing.");while(u)try{if(r=1,n&&(i=o[0]&2?n["return"]:o[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;if(n=0,i)o=[o[0]&2,i.value];switch(o[0]){case 0:case 1:i=o;break;case 4:u.label++;return{value:o[1],done:false};case 5:u.label++;n=o[1];o=[0];continue;case 7:o=u.ops.pop();u.trys.pop();continue;default:if(!(i=u.trys,i=i.length>0&&i[i.length-1])&&(o[0]===6||o[0]===2)){u=0;continue}if(o[0]===3&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(o[0]===6&&u.label<i[1]){u.label=i[1];i=o;break}if(i&&u.label<i[2]){u.label=i[2];u.ops.push(o);break}if(i[2])u.ops.pop();u.trys.pop();continue}o=t.call(e,u)}catch(e){o=[6,e];n=0}finally{r=i=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}import h from"qs";var y=function(e){return e!==null&&typeof e=="object"},v=function(e){return typeof e=="string"};var m=function(e){if(!y(e))throw new Error("queries is not object");return h.stringify(e,{arrayFormat:"comma"})};var b="microcms.io",w="v1";import q,{Headers as g}from"cross-fetch";var I=function(e){var t;return e?t=e:(typeof fetch==="undefined"?"undefined":l(fetch))>"u"?t=q:t=fetch,function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(void 0,f(r))}},j=function(){return(typeof Headers==="undefined"?"undefined":l(Headers))>"u"?g:Headers},O=function(e,t){var r=I(t),i=j();return function(){var t=n(function(t,n){var o,u;return p(this,function(s){u=new i((o=n)===null||o===void 0?void 0:o.headers);return[2,(u.has("X-MICROCMS-API-KEY")||u.set("X-MICROCMS-API-KEY",e),r(t,a(c({},n),{headers:u})))]})});return function(e,r){return t.apply(this,arguments)}}()};import P from"async-retry";var E=function(e){var t=e.serviceDomain,r=e.apiKey,i=e.customFetch,o=e.retry;if(!t||!r)throw new Error("parameter is required (check serviceDomain and apiKey)");if(!v(t)||!v(r))throw new Error("parameter is not string");var u="https://".concat(t,".").concat(b,"/api/").concat(w),s=function(){var e=n(function(e){var t,s,f,l,d,h,y,v,b;return p(this,function(w){switch(w.label){case 0:t=e.endpoint,s=e.contentId,f=e.queries,l=f===void 0?{}:f,d=e.requestInit;h=O(r,i),y=m(l),v="".concat(u,"/").concat(t).concat(s?"/".concat(s):"").concat(y?"?".concat(y):""),b=function(){var e=n(function(e){var t,r,n;return p(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,e.json()];case 1:t=i.sent(),r=t.message;return[2,r!==null&&r!==void 0?r:null];case 2:n=i.sent();return[2,null];case 3:return[2]}})});return function t(t){return e.apply(this,arguments)}}();return[4,P(function(){var e=n(function(e){var t,r,n,i,o,u,s,f;return p(this,function(l){switch(l.label){case 0:l.trys.push([0,6,,7]);return[4,h(v,a(c({},d),{method:(n=(t=d)===null||t===void 0?void 0:t.method)!==null&&n!==void 0?n:"GET"}))];case 1:i=l.sent();if(!(i.status!==429&&i.status>=400&&i.status<500))return[3,3];return[4,b(i)];case 2:o=l.sent();return[2,e(new Error("fetch API response status: ".concat(i.status).concat(o?"\n message is `".concat(o,"`"):"")))];case 3:if(!!i.ok)return[3,5];return[4,b(i)];case 4:u=l.sent();return[2,Promise.reject(new Error("fetch API response status: ".concat(i.status).concat(u?"\n message is `".concat(u,"`"):"")))];case 5:return[2,((r=d)===null||r===void 0?void 0:r.method)==="DELETE"?void 0:i.json()];case 6:s=l.sent();if(s.data)throw s.data;if((f=s.response)===null||f===void 0?void 0:f.data)throw s.response.data;return[2,Promise.reject(new Error("Network Error.\n Details: ".concat(s)))];case 7:return[2]}})});return function(t){return e.apply(this,arguments)}}(),{retries:o?2:0,onRetry:function(e,t){console.log(e),console.log("Waiting for retry (".concat(t,"/",2,")"))},minTimeout:5e3})];case 1:return[2,w.sent()]}})});return function t(t){return e.apply(this,arguments)}}();return{get:function(){var e=n(function(e){var t,r,n,i,o,u;return p(this,function(c){switch(c.label){case 0:t=e.endpoint,r=e.contentId,n=e.queries,i=n===void 0?{}:n,o=e.customRequestInit;if(!t)return[3,2];return[4,s({endpoint:t,contentId:r,queries:i,requestInit:o})];case 1:u=c.sent();return[3,3];case 2:u=Promise.reject(new Error("endpoint is required"));c.label=3;case 3:return[2,u]}})});return function(t){return e.apply(this,arguments)}}(),getList:function(){var e=n(function(e){var t,r,n,i,o;return p(this,function(u){switch(u.label){case 0:t=e.endpoint,r=e.queries,n=r===void 0?{}:r,i=e.customRequestInit;if(!t)return[3,2];return[4,s({endpoint:t,queries:n,requestInit:i})];case 1:o=u.sent();return[3,3];case 2:o=Promise.reject(new Error("endpoint is required"));u.label=3;case 3:return[2,o]}})});return function(t){return e.apply(this,arguments)}}(),getListDetail:function(){var e=n(function(e){var t,r,n,i,o,u;return p(this,function(c){switch(c.label){case 0:t=e.endpoint,r=e.contentId,n=e.queries,i=n===void 0?{}:n,o=e.customRequestInit;if(!t)return[3,2];return[4,s({endpoint:t,contentId:r,queries:i,requestInit:o})];case 1:u=c.sent();return[3,3];case 2:u=Promise.reject(new Error("endpoint is required"));c.label=3;case 3:return[2,u]}})});return function(t){return e.apply(this,arguments)}}(),getObject:function(){var e=n(function(e){var t,r,n,i,o;return p(this,function(u){switch(u.label){case 0:t=e.endpoint,r=e.queries,n=r===void 0?{}:r,i=e.customRequestInit;if(!t)return[3,2];return[4,s({endpoint:t,queries:n,requestInit:i})];case 1:o=u.sent();return[3,3];case 2:o=Promise.reject(new Error("endpoint is required"));u.label=3;case 3:return[2,o]}})});return function(t){return e.apply(this,arguments)}}(),getAllContentIds:function(){var e=n(function(e){var t,r,n,i,o,u,l,d,h,y,v,m,b,w,q,g,I;return p(this,function(p){switch(p.label){case 0:t=e.endpoint,r=e.alternateField,n=e.draftKey,i=e.filters,o=e.orders,u=e.customRequestInit;l={draftKey:n,filters:i,orders:o,limit:100,fields:r!==null&&r!==void 0?r:"id",depth:0};return[4,s({endpoint:t,queries:a(c({},l),{limit:0}),requestInit:u})];case 1:d=p.sent(),h=d.totalCount,y=[],v=0,m=function(e){return new Promise(function(t){return setTimeout(t,e)})},b=function(e){return e.every(function(e){return typeof e=="string"})};p.label=2;case 2:if(!(y.length<h))return[3,7];return[4,s({endpoint:t,queries:a(c({},l),{offset:v}),requestInit:u})];case 3:w=p.sent(),q=w.contents,g=q.map(function(e){return e[r!==null&&r!==void 0?r:"id"]});if(!b(g))throw new Error("The value of the field specified by `alternateField` is not a string.");y=f(y).concat(f(g)),v+=100;I=y.length<h;if(!I)return[3,5];return[4,m(1e3)];case 4:I=p.sent();p.label=5;case 5:I;p.label=6;case 6:return[3,2];case 7:return[2,y]}})});return function(t){return e.apply(this,arguments)}}(),create:function(){var e=n(function(e){var t,r,n,i,o,u,f,l;return p(this,function(d){t=e.endpoint,r=e.contentId,n=e.content,i=e.isDraft,o=i===void 0?!1:i,u=e.customRequestInit;if(!t)return[2,Promise.reject(new Error("endpoint is required"))];f=o?{status:"draft"}:{},l=a(c({},u),{method:r?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return[2,s({endpoint:t,contentId:r,queries:f,requestInit:l})]})});return function(t){return e.apply(this,arguments)}}(),update:function(){var e=n(function(e){var t,r,n,i,o;return p(this,function(u){t=e.endpoint,r=e.contentId,n=e.content,i=e.customRequestInit;if(!t)return[2,Promise.reject(new Error("endpoint is required"))];o=a(c({},i),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return[2,s({endpoint:t,contentId:r,requestInit:o})]})});return function(t){return e.apply(this,arguments)}}(),delete:function(){var e=n(function(e){var t,r,n,i;return p(this,function(o){switch(o.label){case 0:t=e.endpoint,r=e.contentId,n=e.customRequestInit;if(!t)return[2,Promise.reject(new Error("endpoint is required"))];if(!r)return[2,Promise.reject(new Error("contentId is required"))];i=a(c({},n),{method:"DELETE",headers:{},body:void 0});return[4,s({endpoint:t,contentId:r,requestInit:i})];case 1:o.sent();return[2]}})});return function(t){return e.apply(this,arguments)}}()}};export{E as createClient};//# sourceMappingURL=microcms-js-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/parseQuery.ts","../../src/utils/isCheckValue.ts","../../src/utils/constants.ts","../../src/lib/fetch.ts","../../src/createClient.ts"],"names":["qs","isObject","value","isString","parseQuery","queries","BASE_DOMAIN","API_VERSION","crossFetch","CrossFetchHeaders","resolveFetch","customFetch","_fetch","args","resolveHeadersConstructor","generateFetchClient","apiKey","fetch","HeadersConstructor","req","init","headers","retry","createClient","serviceDomain","retryOption","baseUrl","makeRequest","endpoint","contentId","requestInit","fetchClient","queryString","url","getMessageFromResponse","response","message","bail","error","err","num","customRequestInit","alternateField","draftKey","filters","orders","defaultQueries","totalCount","contentIds","offset","sleep","ms","resolve","isStringArray","arr","item","contents","ids","content","isDraft"],"mappings":"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","sourcesContent":["/**\n * Parse query.\n *\n * @param {object} queries\n * @return {string} queryString\n */\nimport qs from 'qs';\nimport { isObject } from './isCheckValue';\nimport { MicroCMSQueries } from '../types';\n\nexport const parseQuery = (queries: MicroCMSQueries): string => {\n if (!isObject(queries)) {\n throw new Error('queries is not object');\n }\n const queryString = qs.stringify(queries, { arrayFormat: 'comma' });\n\n return queryString;\n};\n","/**\n * Check object\n *\n * @param {unknown} value\n * @returns {boolean}\n */\nexport const isObject = (value: unknown): value is Record<string, unknown> => {\n return value !== null && typeof value === 'object';\n};\n\n/**\n * Check string\n *\n * @param {unknown} value\n * @returns {boolean}\n */\nexport const isString = (value: unknown): value is string => {\n return typeof value === 'string';\n};\n","export const BASE_DOMAIN = 'microcms.io';\nexport const API_VERSION = 'v1';\nexport const MAX_RETRY_COUNT = 2;\nexport const MIN_TIMEOUT_MS = 5000;\n","import crossFetch, { Headers as CrossFetchHeaders } from 'cross-fetch';\nimport { Fetch } from 'src/types';\n\nexport const resolveFetch = (customFetch?: Fetch): Fetch => {\n let _fetch: Fetch;\n if (customFetch) {\n _fetch = customFetch;\n } else if (typeof fetch === 'undefined') {\n _fetch = (crossFetch as unknown) as Fetch;\n } else {\n _fetch = fetch;\n }\n return (...args) => _fetch(...args);\n};\n\nexport const resolveHeadersConstructor = () => {\n if (typeof Headers === 'undefined') {\n return CrossFetchHeaders;\n }\n\n return Headers;\n};\n\nexport const generateFetchClient = (\n apiKey: string,\n customFetch?: Fetch\n): Fetch => {\n const fetch = resolveFetch(customFetch);\n const HeadersConstructor = resolveHeadersConstructor();\n\n return async (req, init) => {\n const headers = new HeadersConstructor(init?.headers);\n\n if (!headers.has('X-MICROCMS-API-KEY')) {\n headers.set('X-MICROCMS-API-KEY', apiKey);\n }\n\n return fetch(req, { ...init, headers });\n };\n};\n","/**\n * microCMS API SDK\n * https://github.com/microcmsio/microcms-js-sdk\n */\nimport { parseQuery } from './utils/parseQuery';\nimport { isString } from './utils/isCheckValue';\nimport {\n MicroCMSClient,\n MakeRequest,\n GetRequest,\n GetListRequest,\n GetListDetailRequest,\n GetObjectRequest,\n WriteApiRequestResult,\n CreateRequest,\n MicroCMSListResponse,\n MicroCMSListContent,\n MicroCMSObjectContent,\n UpdateRequest,\n DeleteRequest,\n GetAllContentIdsRequest,\n MicroCMSQueries,\n} from './types';\nimport {\n API_VERSION,\n BASE_DOMAIN,\n MAX_RETRY_COUNT,\n MIN_TIMEOUT_MS,\n} from './utils/constants';\nimport { generateFetchClient } from './lib/fetch';\nimport retry from 'async-retry';\n\n/**\n * Initialize SDK Client\n */\nexport const createClient = ({\n serviceDomain,\n apiKey,\n customFetch,\n retry: retryOption,\n}: MicroCMSClient) => {\n if (!serviceDomain || !apiKey) {\n throw new Error('parameter is required (check serviceDomain and apiKey)');\n }\n\n if (!isString(serviceDomain) || !isString(apiKey)) {\n throw new Error('parameter is not string');\n }\n\n /**\n * Defined microCMS base URL\n */\n const baseUrl = `https://${serviceDomain}.${BASE_DOMAIN}/api/${API_VERSION}`;\n\n /**\n * Make request\n */\n const makeRequest = async ({\n endpoint,\n contentId,\n queries = {},\n requestInit,\n }: MakeRequest) => {\n const fetchClient = generateFetchClient(apiKey, customFetch);\n const queryString = parseQuery(queries);\n const url = `${baseUrl}/${endpoint}${contentId ? `/${contentId}` : ''}${\n queryString ? `?${queryString}` : ''\n }`;\n\n const getMessageFromResponse = async (response: Response) => {\n // Enclose `response.json()` in a try since it may throw an error\n // Only return the `message` if there is a `message`\n try {\n const { message } = await response.json();\n return message ?? null;\n } catch (_) {\n return null;\n }\n };\n\n return await retry(\n async (bail) => {\n try {\n const response = await fetchClient(url, {\n ...requestInit,\n method: requestInit?.method ?? 'GET',\n });\n\n // If a status code in the 400 range other than 429 is returned, do not retry.\n if (\n response.status !== 429 &&\n response.status >= 400 &&\n response.status < 500\n ) {\n const message = await getMessageFromResponse(response);\n\n return bail(\n new Error(\n `fetch API response status: ${response.status}${\n message ? `\\n message is \\`${message}\\`` : ''\n }`,\n ),\n );\n }\n\n // If the response fails with any other status code, retry until the set number of attempts is reached.\n if (!response.ok) {\n const message = await getMessageFromResponse(response);\n\n return Promise.reject(\n new Error(\n `fetch API response status: ${response.status}${\n message ? `\\n message is \\`${message}\\`` : ''\n }`,\n ),\n );\n }\n\n if (requestInit?.method === 'DELETE') return;\n\n return response.json();\n } catch (error) {\n if (error.data) {\n throw error.data;\n }\n\n if (error.response?.data) {\n throw error.response.data;\n }\n\n return Promise.reject(\n new Error(`Network Error.\\n Details: ${error}`),\n );\n }\n },\n {\n retries: retryOption ? MAX_RETRY_COUNT : 0,\n onRetry: (err, num) => {\n console.log(err);\n console.log(`Waiting for retry (${num}/${MAX_RETRY_COUNT})`);\n },\n minTimeout: MIN_TIMEOUT_MS,\n },\n );\n };\n\n /**\n * Get list and object API data for microCMS\n */\n const get = async <T = any>({\n endpoint,\n contentId,\n queries = {},\n customRequestInit,\n }: GetRequest): Promise<T> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n return await makeRequest({\n endpoint,\n contentId,\n queries,\n requestInit: customRequestInit,\n });\n };\n\n /**\n * Get list API data for microCMS\n */\n const getList = async <T = any>({\n endpoint,\n queries = {},\n customRequestInit,\n }: GetListRequest): Promise<MicroCMSListResponse<T>> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n return await makeRequest({\n endpoint,\n queries,\n requestInit: customRequestInit,\n });\n };\n\n /**\n * Get list API detail data for microCMS\n */\n const getListDetail = async <T = any>({\n endpoint,\n contentId,\n queries = {},\n customRequestInit,\n }: GetListDetailRequest): Promise<T & MicroCMSListContent> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n return await makeRequest({\n endpoint,\n contentId,\n queries,\n requestInit: customRequestInit,\n });\n };\n\n /**\n * Get object API data for microCMS\n */\n const getObject = async <T = any>({\n endpoint,\n queries = {},\n customRequestInit,\n }: GetObjectRequest): Promise<T & MicroCMSObjectContent> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n return await makeRequest({\n endpoint,\n queries,\n requestInit: customRequestInit,\n });\n };\n\n const getAllContentIds = async ({\n endpoint,\n alternateField,\n draftKey,\n filters,\n orders,\n customRequestInit,\n }: GetAllContentIdsRequest): Promise<string[]> => {\n const limit = 100;\n const defaultQueries: MicroCMSQueries = {\n draftKey,\n filters,\n orders,\n limit,\n fields: alternateField ?? 'id',\n depth: 0,\n };\n\n const { totalCount } = await makeRequest({\n endpoint,\n queries: { ...defaultQueries, limit: 0 },\n requestInit: customRequestInit,\n });\n\n let contentIds: string[] = [];\n let offset = 0;\n\n const sleep = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n const isStringArray = (arr: unknown[]): arr is string[] =>\n arr.every((item) => typeof item === 'string');\n\n while (contentIds.length < totalCount) {\n const { contents } = (await makeRequest({\n endpoint,\n queries: { ...defaultQueries, offset },\n requestInit: customRequestInit,\n })) as MicroCMSListResponse<Record<string, unknown>>;\n\n const ids = contents.map((content) => content[alternateField ?? 'id']);\n\n if (!isStringArray(ids)) {\n throw new Error(\n 'The value of the field specified by `alternateField` is not a string.',\n );\n }\n\n contentIds = [...contentIds, ...ids];\n\n offset += limit;\n if (contentIds.length < totalCount) {\n await sleep(1000); // sleep for 1 second before the next request\n }\n }\n\n return contentIds;\n };\n\n /**\n * Create new content in the microCMS list API data\n */\n const create = async <T extends Record<string | number, any>>({\n endpoint,\n contentId,\n content,\n isDraft = false,\n customRequestInit,\n }: CreateRequest<T>): Promise<WriteApiRequestResult> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n\n const queries: MakeRequest['queries'] = isDraft ? { status: 'draft' } : {};\n const requestInit: MakeRequest['requestInit'] = {\n ...customRequestInit,\n method: contentId ? 'PUT' : 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(content),\n };\n\n return makeRequest({\n endpoint,\n contentId,\n queries,\n requestInit,\n });\n };\n\n /**\n * Update content in their microCMS list and object API data\n */\n const update = async <T extends Record<string | number, any>>({\n endpoint,\n contentId,\n content,\n customRequestInit,\n }: UpdateRequest<T>): Promise<WriteApiRequestResult> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n\n const requestInit: MakeRequest['requestInit'] = {\n ...customRequestInit,\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(content),\n };\n\n return makeRequest({\n endpoint,\n contentId,\n requestInit,\n });\n };\n\n /**\n * Delete content in their microCMS list and object API data\n */\n const _delete = async ({\n endpoint,\n contentId,\n customRequestInit,\n }: DeleteRequest): Promise<void> => {\n if (!endpoint) {\n return Promise.reject(new Error('endpoint is required'));\n }\n\n if (!contentId) {\n return Promise.reject(new Error('contentId is required'));\n }\n\n const requestInit: MakeRequest['requestInit'] = {\n ...customRequestInit,\n method: 'DELETE',\n headers: {},\n body: undefined,\n };\n\n await makeRequest({ endpoint, contentId, requestInit });\n };\n\n return {\n get,\n getList,\n getListDetail,\n getObject,\n getAllContentIds,\n create,\n update,\n delete: _delete,\n };\n};\n"]}
@@ -0,0 +1 @@
1
+ "use strict";function t(t,e){if(e==null||e>t.length)e=t.length;for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function e(e){if(Array.isArray(e))return t(e)}function r(t,e,r,n,o,i,a){try{var u=t[i](a);var s=u.value}catch(t){r(t);return}if(u.done){e(s)}else{Promise.resolve(s).then(n,o)}}function n(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var a=t.apply(e,n);function u(t){r(a,o,i,u,s,"next",t)}function s(t){r(a,o,i,u,s,"throw",t)}u(undefined)})}}function o(t,e,r){if(e in t){Object.defineProperty(t,e,{value:r,enumerable:true,configurable:true,writable:true})}else{t[e]=r}return t}function i(t,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](t)}else{return t instanceof e}}function a(t){if(typeof Symbol!=="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))}n.forEach(function(e){o(t,e,r[e])})}return t}function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);if(e){n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})}r.push.apply(r,n)}return r}function f(t,e){e=e!=null?e:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(t,Object.getOwnPropertyDescriptors(e))}else{c(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function p(t){return e(t)||a(t)||y(t)||u()}function l(t){"@swc/helpers - typeof";return t&&typeof Symbol!=="undefined"&&t.constructor===Symbol?"symbol":typeof t}function y(e,r){if(!e)return;if(typeof e==="string")return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}function d(t,e){var r,n,o,i,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return(i={next:u(0),"throw":u(1),"return":u(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i);function u(t){return function(e){return s([t,e])}}function s(i){if(r)throw new TypeError("Generator is already executing.");while(a)try{if(r=1,n&&(o=i[0]&2?n["return"]:i[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;if(n=0,o)i=[i[0]&2,o.value];switch(i[0]){case 0:case 1:o=i;break;case 4:a.label++;return{value:i[1],done:false};case 5:a.label++;n=i[1];i=[0];continue;case 7:i=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){a=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(i[0]===6&&a.label<o[1]){a.label=o[1];o=i;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(i);break}if(o[2])a.ops.pop();a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t];n=0}finally{r=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var microcms=function(){var t=Object.create;var e=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var c=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}},y=function(t,r){for(var n in r)e(t,n,{get:r[n],enumerable:!0})},h=function(t,n,i,a){var s=true,c=false,f=undefined;if(n&&typeof n=="object"||typeof n=="function")try{var p=function(){var o=y.value;!u.call(t,o)&&o!==i&&e(t,o,{get:function(){return n[o]},enumerable:!(a=r(n,o))||a.enumerable})};for(var l=o(n)[Symbol.iterator](),y;!(s=(y=l.next()).done);s=true)p()}catch(t){c=true;f=t}finally{try{if(!s&&l.return!=null){l.return()}}finally{if(c){throw f}}}return t};var m=function(r,n,o){return o=r!=null?t(a(r)):{},h(n||!r||!r.__esModule?e(o,"default",{value:r,enumerable:!0}):o,r)},b=function(t){return h(e({},"__esModule",{value:!0}),t)};var v=c(function(t,e){"use strict";e.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(l(Symbol.iterator)=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var n=42;t[e]=n;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var i=Object.getOwnPropertyDescriptor(t,e);if(i.value!==n||i.enumerable!==!0)return!1}return!0}});var g=c(function(t,e){"use strict";var r=(typeof Symbol==="undefined"?"undefined":l(Symbol))<"u"&&Symbol,n=v();e.exports=function(){return typeof r!="function"||typeof Symbol!="function"||l(r("foo"))!="symbol"||l(Symbol("bar"))!="symbol"?!1:n()}});var w=c(function(t,e){"use strict";var r={foo:{}},n=Object;e.exports=function(){return({__proto__:r}).foo===r.foo&&!i({__proto__:null},n)}});var A=c(function(t,e){"use strict";var r="Function.prototype.bind called on incompatible ",n=Array.prototype.slice,o=Object.prototype.toString,a="[object Function]";e.exports=function(t){var e=this;if(typeof e!="function"||o.call(e)!==a)throw new TypeError(r+e);for(var u=n.call(arguments,1),s,c=function r(){if(i(this,s)){var r=e.apply(this,u.concat(n.call(arguments)));return Object(r)===r?r:this}else return e.apply(t,u.concat(n.call(arguments)))},f=Math.max(0,e.length-u.length),p=[],l=0;l<f;l++)p.push("$"+l);if(s=Function("binder","return function ("+p.join(",")+"){ return binder.apply(this,arguments); }")(c),e.prototype){var y=function t(){};y.prototype=e.prototype,s.prototype=new y,y.prototype=null}return s}});var O=c(function(t,e){"use strict";var r=A();e.exports=Function.prototype.bind||r});var j=c(function(t,e){"use strict";var r=O();e.exports=r.call(Function.call,Object.prototype.hasOwnProperty)});var S=c(function(t,e){"use strict";var r,n=SyntaxError,o=Function,i=TypeError,a=function t(t){try{return o('"use strict"; return ('+t+").constructor;")()}catch(t){}},u=Object.getOwnPropertyDescriptor;if(u)try{u({},"")}catch(t){u=null}var s=function t(){throw new i},c=u?function(){try{return arguments.callee,s}catch(t){try{return u(arguments,"callee").get}catch(t){return s}}}():s,f=g()(),p=w()(),y=Object.getPrototypeOf||(p?function(t){return t.__proto__}:null),d={},h=(typeof Uint8Array==="undefined"?"undefined":l(Uint8Array))>"u"||!y?r:y(Uint8Array),m={"%AggregateError%":(typeof AggregateError==="undefined"?"undefined":l(AggregateError))>"u"?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":(typeof ArrayBuffer==="undefined"?"undefined":l(ArrayBuffer))>"u"?r:ArrayBuffer,"%ArrayIteratorPrototype%":f&&y?y([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":d,"%AsyncGenerator%":d,"%AsyncGeneratorFunction%":d,"%AsyncIteratorPrototype%":d,"%Atomics%":(typeof Atomics==="undefined"?"undefined":l(Atomics))>"u"?r:Atomics,"%BigInt%":(typeof BigInt==="undefined"?"undefined":l(BigInt))>"u"?r:BigInt,"%BigInt64Array%":(typeof BigInt64Array==="undefined"?"undefined":l(BigInt64Array))>"u"?r:BigInt64Array,"%BigUint64Array%":(typeof BigUint64Array==="undefined"?"undefined":l(BigUint64Array))>"u"?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":(typeof DataView==="undefined"?"undefined":l(DataView))>"u"?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":(typeof Float32Array==="undefined"?"undefined":l(Float32Array))>"u"?r:Float32Array,"%Float64Array%":(typeof Float64Array==="undefined"?"undefined":l(Float64Array))>"u"?r:Float64Array,"%FinalizationRegistry%":(typeof FinalizationRegistry==="undefined"?"undefined":l(FinalizationRegistry))>"u"?r:FinalizationRegistry,"%Function%":o,"%GeneratorFunction%":d,"%Int8Array%":(typeof Int8Array==="undefined"?"undefined":l(Int8Array))>"u"?r:Int8Array,"%Int16Array%":(typeof Int16Array==="undefined"?"undefined":l(Int16Array))>"u"?r:Int16Array,"%Int32Array%":(typeof Int32Array==="undefined"?"undefined":l(Int32Array))>"u"?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":f&&y?y(y([][Symbol.iterator]())):r,"%JSON%":typeof JSON=="object"?JSON:r,"%Map%":(typeof Map==="undefined"?"undefined":l(Map))>"u"?r:Map,"%MapIteratorPrototype%":(typeof Map==="undefined"?"undefined":l(Map))>"u"||!f||!y?r:y(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":(typeof Promise==="undefined"?"undefined":l(Promise))>"u"?r:Promise,"%Proxy%":(typeof Proxy==="undefined"?"undefined":l(Proxy))>"u"?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":(typeof Reflect==="undefined"?"undefined":l(Reflect))>"u"?r:Reflect,"%RegExp%":RegExp,"%Set%":(typeof Set==="undefined"?"undefined":l(Set))>"u"?r:Set,"%SetIteratorPrototype%":(typeof Set==="undefined"?"undefined":l(Set))>"u"||!f||!y?r:y(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":(typeof SharedArrayBuffer==="undefined"?"undefined":l(SharedArrayBuffer))>"u"?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":f&&y?y(""[Symbol.iterator]()):r,"%Symbol%":f?Symbol:r,"%SyntaxError%":n,"%ThrowTypeError%":c,"%TypedArray%":h,"%TypeError%":i,"%Uint8Array%":(typeof Uint8Array==="undefined"?"undefined":l(Uint8Array))>"u"?r:Uint8Array,"%Uint8ClampedArray%":(typeof Uint8ClampedArray==="undefined"?"undefined":l(Uint8ClampedArray))>"u"?r:Uint8ClampedArray,"%Uint16Array%":(typeof Uint16Array==="undefined"?"undefined":l(Uint16Array))>"u"?r:Uint16Array,"%Uint32Array%":(typeof Uint32Array==="undefined"?"undefined":l(Uint32Array))>"u"?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":(typeof WeakMap==="undefined"?"undefined":l(WeakMap))>"u"?r:WeakMap,"%WeakRef%":(typeof WeakRef==="undefined"?"undefined":l(WeakRef))>"u"?r:WeakRef,"%WeakSet%":(typeof WeakSet==="undefined"?"undefined":l(WeakSet))>"u"?r:WeakSet};if(y)try{null.error}catch(t){b=y(y(t)),m["%Error.prototype%"]=b}var b,v=function t(e){var r;if(e==="%AsyncFunction%")r=a("async function () {}");else if(e==="%GeneratorFunction%")r=a("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=a("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&y&&(r=y(o.prototype))}return m[e]=r,r},A={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},S=O(),P=j(),E=S.call(Function.call,Array.prototype.concat),x=S.call(Function.apply,Array.prototype.splice),_=S.call(Function.call,String.prototype.replace),I=S.call(Function.call,String.prototype.slice),T=S.call(Function.call,RegExp.prototype.exec),R=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,F=/\\(\\)?/g,D=function t(t){var e=I(t,0,1),r=I(t,-1);if(e==="%"&&r!=="%")throw new n("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new n("invalid intrinsic syntax, expected opening `%`");var o=[];return _(t,R,function(t,e,r,n){o[o.length]=r?_(n,F,"$1"):e||t}),o},k=function t(t,e){var r=t,o;if(P(A,r)&&(o=A[r],r="%"+o[0]+"%"),P(m,r)){var a=m[r];if(a===d&&(a=v(r)),(typeof a==="undefined"?"undefined":l(a))>"u"&&!e)throw new i("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:o,name:r,value:a}}throw new n("intrinsic "+t+" does not exist!")};e.exports=function(t,e){if(typeof t!="string"||t.length===0)throw new i("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new i('"allowMissing" argument must be a boolean');if(T(/^%?[^%]*%?$/,t)===null)throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=D(t),o=r.length>0?r[0]:"",a=k("%"+o+"%",e),s=a.name,c=a.value,f=!1,p=a.alias;p&&(o=p[0],x(r,E([0,1],p)));for(var l=1,y=!0;l<r.length;l+=1){var d=r[l],h=I(d,0,1),b=I(d,-1);if((h==='"'||h==="'"||h==="`"||b==='"'||b==="'"||b==="`")&&h!==b)throw new n("property names with quotes must have matching quotes");if((d==="constructor"||!y)&&(f=!0),o+="."+d,s="%"+o+"%",P(m,s))c=m[s];else if(c!=null){if(!(d in c)){if(!e)throw new i("base intrinsic for "+t+" exists, but the property is not available.");return}if(u&&l+1>=r.length){var v=u(c,d);y=!!v,y&&"get"in v&&!("originalValue"in v.get)?c=v.get:c=c[d]}else y=P(c,d),c=c[d];y&&!f&&(m[s]=c)}}return c}});var P=c(function(t,e){"use strict";var r=O(),n=S(),o=n("%Function.prototype.apply%"),i=n("%Function.prototype.call%"),a=n("%Reflect.apply%",!0)||r.call(i,o),u=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),c=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(t){s=null}e.exports=function(t){var e=a(r,i,arguments);if(u&&s){var n=u(e,"length");n.configurable&&s(e,"length",{value:1+c(0,t.length-(arguments.length-1))})}return e};var f=function t(){return a(r,o,arguments)};s?s(e.exports,"apply",{value:f}):e.exports.apply=f});var E=c(function(t,e){"use strict";var r=S(),n=P(),o=n(r("String.prototype.indexOf"));e.exports=function(t,e){var i=r(t,!!e);return typeof i=="function"&&o(t,".prototype.")>-1?n(i):i}});var x=c(function(){"use strict"});var _=c(function(t,e){"use strict";var r=function t(t,e,r){var n=(r.quoteStyle||e)==="double"?'"':"'";return n+t+n};var n=function t(t){return String(t).replace(/"/g,"&quot;")};var o=function t(t){return m(t)==="[object Array]"&&(!ti||!(typeof t=="object"&&ti in t))};var a=function t(t){return m(t)==="[object Date]"&&(!ti||!(typeof t=="object"&&ti in t))};var u=function t(t){return m(t)==="[object RegExp]"&&(!ti||!(typeof t=="object"&&ti in t))};var s=function t(t){return m(t)==="[object Error]"&&(!ti||!(typeof t=="object"&&ti in t))};var c=function t(t){return m(t)==="[object String]"&&(!ti||!(typeof t=="object"&&ti in t))};var f=function t(t){return m(t)==="[object Number]"&&(!ti||!(typeof t=="object"&&ti in t))};var p=function t(t){return m(t)==="[object Boolean]"&&(!ti||!(typeof t=="object"&&ti in t))};var y=function t(t){if((typeof t==="undefined"?"undefined":l(t))=="symbol")return!0;if(!t||typeof t!="object"||!tt)return!1;try{return tt.call(t),!0}catch(t){}return!1};var d=function t(t){if(!t||typeof t!="object"||!Y)return!1;try{return Y.call(t),!0}catch(t){}return!1};var h=function t(t,e){return ta.call(t,e)};var m=function t(t){return $.call(t)};var b=function t(t){if(t.name)return t.name;var e=X.call(K.call(t),/^function\s*([\w$]+)/);return e?e[1]:null};var v=function t(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1};var g=function t(t){if(!U||!t||typeof t!="object")return!1;try{U.call(t);try{q.call(t)}catch(t){return!0}return i(t,Map)}catch(t){}return!1};var w=function t(t){if(!H||!t||typeof t!="object")return!1;try{H.call(t,H);try{z.call(t,z)}catch(t){return!0}return i(t,WeakMap)}catch(t){}return!1};var A=function t(t){if(!J||!t||typeof t!="object")return!1;try{return J.call(t),!0}catch(t){}return!1};var O=function t(t){if(!q||!t||typeof t!="object")return!1;try{q.call(t);try{U.call(t)}catch(t){return!0}return i(t,Set)}catch(t){}return!1};var j=function t(t){if(!z||!t||typeof t!="object")return!1;try{z.call(t,z);try{H.call(t,H)}catch(t){return!0}return i(t,WeakSet)}catch(t){}return!1};var S=function t(t){return!t||typeof t!="object"?!1:(typeof HTMLElement==="undefined"?"undefined":l(HTMLElement))<"u"&&i(t,HTMLElement)?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"};var P=function t(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+e.toString(16).toUpperCase()};var E=function t(t){return"Object("+t+")"};var _=function t(t){return t+" { ? }"};var I=function t(t,e,r,n){var o=n?F(r,n):r.join(", ");return t+" ("+e+") {"+o+"}"};var T=function t(t){for(var e=0;e<t.length;e++)if(v(t[e],"\n")>=0)return!1;return!0};var R=function t(t,e){var r;if(t.indent===" ")r=" ";else if(typeof t.indent=="number"&&t.indent>0)r=Array(t.indent+1).join(" ");else return null;return{base:r,prev:Array(e+1).join(r)}};var F=function t(t,e){if(t.length===0)return"";var r="\n"+e.prev+e.base;return r+t.join(","+r)+"\n"+e.prev};var D=function t(t,e){var r=o(t),n=[];if(r){n.length=t.length;for(var i=0;i<t.length;i++)n[i]=h(t,i)?e(t[i],t):""}for(var a in t)h(t,a)&&(r&&String(Number(a))===a&&a<t.length||(/[^\w$]/.test(a)?n.push(e(a,t)+": "+e(t[a],t)):n.push(a+": "+e(t[a],t))));if(typeof Z=="function")for(var u=Z(t),s=0;s<u.length;s++)te.call(t,u[s])&&n.push("["+e(u[s])+"]: "+e(t[u[s]],t));return n};var k=typeof Map=="function"&&Map.prototype,B=Object.getOwnPropertyDescriptor&&k?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=k&&B&&typeof B.get=="function"?B.get:null,M=k&&Map.prototype.forEach,N=typeof Set=="function"&&Set.prototype,C=Object.getOwnPropertyDescriptor&&N?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,q=N&&C&&typeof C.get=="function"?C.get:null,L=N&&Set.prototype.forEach,W=typeof WeakMap=="function"&&WeakMap.prototype,H=W?WeakMap.prototype.has:null,G=typeof WeakSet=="function"&&WeakSet.prototype,z=G?WeakSet.prototype.has:null,V=typeof WeakRef=="function"&&WeakRef.prototype,J=V?WeakRef.prototype.deref:null,Q=Boolean.prototype.valueOf,$=Object.prototype.toString,K=Function.prototype.toString,X=String.prototype.match,Y=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Z=Object.getOwnPropertySymbols,tt=typeof Symbol=="function"&&l(Symbol.iterator)=="symbol"?Symbol.prototype.toString:null,te=Object.prototype.propertyIsEnumerable,tr=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null),tn=x().custom,to=tn&&y(tn)?tn:null,ti=typeof Symbol=="function"&&l(Symbol.toStringTag)=="symbol"?Symbol.toStringTag:null;e.exports=function t(e,P,x,k){var B=function e(e,r,n){if(r&&(k=k.slice(),k.push(r)),n){var o={depth:N.depth};return h(N,"quoteStyle")&&(o.quoteStyle=N.quoteStyle),t(e,o,x+1,k)}return t(e,N,x+1,k)};var N=P||{};if(h(N,"quoteStyle")&&N.quoteStyle!=="single"&&N.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(h(N,"maxStringLength")&&(typeof N.maxStringLength=="number"?N.maxStringLength<0&&N.maxStringLength!==1/0:N.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var C=h(N,"customInspect")?N.customInspect:!0;if(typeof C!="boolean")throw new TypeError('option "customInspect", if provided, must be `true` or `false`');if(h(N,"indent")&&N.indent!==null&&N.indent!==" "&&!(parseInt(N.indent,10)===N.indent&&N.indent>0))throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');if((typeof e==="undefined"?"undefined":l(e))>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return tu(e,N);if(typeof e=="number")return e===0?1/0/e>0?"0":"-0":String(e);if((typeof e==="undefined"?"undefined":l(e))=="bigint")return String(e)+"n";var W=l(N.depth)>"u"?5:N.depth;if((typeof x==="undefined"?"undefined":l(x))>"u"&&(x=0),x>=W&&W>0&&typeof e=="object")return o(e)?"[Array]":"[Object]";var H=R(N,x);if((typeof k==="undefined"?"undefined":l(k))>"u")k=[];else if(v(k,e)>=0)return"[Circular]";if(typeof e=="function"){var G=b(e),z=D(e,B);return"[Function"+(G?": "+G:" (anonymous)")+"]"+(z.length>0?" { "+z.join(", ")+" }":"")}if(y(e)){var V=tt.call(e);return typeof e=="object"?E(V):V}if(S(e)){for(var J="<"+String(e.nodeName).toLowerCase(),$=e.attributes||[],K=0;K<$.length;K++)J+=" "+$[K].name+"="+r(n($[K].value),"double",N);return J+=">",e.childNodes&&e.childNodes.length&&(J+="..."),J+="</"+String(e.nodeName).toLowerCase()+">",J}if(o(e)){if(e.length===0)return"[]";var X=D(e,B);return H&&!T(X)?"["+F(X,H)+"]":"[ "+X.join(", ")+" ]"}if(s(e)){var Z=D(e,B);return Z.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+Z.join(", ")+" }"}if(typeof e=="object"&&C){if(to&&typeof e[to]=="function")return e[to]();if(typeof e.inspect=="function")return e.inspect()}if(g(e)){var te=[];return M.call(e,function(t,r){te.push(B(r,e,!0)+" => "+B(t,e))}),I("Map",U.call(e),te,H)}if(O(e)){var tn=[];return L.call(e,function(t){tn.push(B(t,e))}),I("Set",q.call(e),tn,H)}if(w(e))return _("WeakMap");if(j(e))return _("WeakSet");if(A(e))return _("WeakRef");if(f(e))return E(B(Number(e)));if(d(e))return E(B(Y.call(e)));if(p(e))return E(Q.call(e));if(c(e))return E(B(String(e)));if(!a(e)&&!u(e)){var ta=D(e,B),ts=tr?tr(e)===Object.prototype:i(e,Object)||e.constructor===Object,tc=i(e,Object)?"":"null prototype",tf=!ts&&ti&&Object(e)===e&&ti in e?m(e).slice(8,-1):tc?"Object":"",tp=ts||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",tl=tp+(tf||tc?"["+[].concat(tf||[],tc||[]).join(": ")+"] ":"");return ta.length===0?tl+"{}":H?tl+"{"+F(ta,H)+"}":tl+"{ "+ta.join(", ")+" }"}return String(e)};var ta=Object.prototype.hasOwnProperty||function(t){return t in this};function tu(t,e){if(t.length>e.maxStringLength){var n=t.length-e.maxStringLength,o="... "+n+" more character"+(n>1?"s":"");return tu(t.slice(0,e.maxStringLength),e)+o}var i=t.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,P);return r(i,"single",e)}});var I=c(function(t,e){"use strict";var r=S(),n=E(),o=_(),i=r("%TypeError%"),a=r("%WeakMap%",!0),u=r("%Map%",!0),s=n("WeakMap.prototype.get",!0),c=n("WeakMap.prototype.set",!0),f=n("WeakMap.prototype.has",!0),p=n("Map.prototype.get",!0),l=n("Map.prototype.set",!0),y=n("Map.prototype.has",!0),d=function t(t,e){for(var r=t,n;(n=r.next)!==null;r=n)if(n.key===e)return r.next=n.next,n.next=t.next,t.next=n,n},h=function t(t,e){var r=d(t,e);return r&&r.value},m=function t(t,e,r){var n=d(t,e);n?n.value=r:t.next={key:e,next:t.next,value:r}},b=function t(t,e){return!!d(t,e)};e.exports=function(){var t,e,r,n={assert:function t(t){if(!n.has(t))throw new i("Side channel does not contain "+o(t))},get:function n(n){if(a&&n&&(typeof n=="object"||typeof n=="function")){if(t)return s(t,n)}else if(u){if(e)return p(e,n)}else if(r)return h(r,n)},has:function n(n){if(a&&n&&(typeof n=="object"||typeof n=="function")){if(t)return f(t,n)}else if(u){if(e)return y(e,n)}else if(r)return b(r,n);return!1},set:function n(n,o){a&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new a),c(t,n,o)):u?(e||(e=new u),l(e,n,o)):(r||(r={key:{},next:null}),m(r,n,o))}};return n}});var T=c(function(t,e){"use strict";var r=String.prototype.replace,n=/%20/g,o={RFC1738:"RFC1738",RFC3986:"RFC3986"};e.exports={default:o.RFC3986,formatters:{RFC1738:function t(t){return r.call(t,n,"+")},RFC3986:function t(t){return String(t)}},RFC1738:o.RFC1738,RFC3986:o.RFC3986}});var R=c(function(t,e){"use strict";var r=T(),n=Object.prototype.hasOwnProperty,o=Array.isArray,i=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),a=function t(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(o(r)){for(var n=[],i=0;i<r.length;++i)l(r[i])<"u"&&n.push(r[i]);e.obj[e.prop]=n}}},u=function t(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},n=0;n<t.length;++n)l(t[n])<"u"&&(r[n]=t[n]);return r},s=function t(e,r,i){if(!r)return e;if(typeof r!="object"){if(o(e))e.push(r);else if(e&&typeof e=="object")(i&&(i.plainObjects||i.allowPrototypes)||!n.call(Object.prototype,r))&&(e[r]=!0);else return[e,r];return e}if(!e||typeof e!="object")return[e].concat(r);var a=e;return o(e)&&!o(r)&&(a=u(e,i)),o(e)&&o(r)?(r.forEach(function(r,o){if(n.call(e,o)){var a=e[o];a&&typeof a=="object"&&r&&typeof r=="object"?e[o]=t(a,r,i):e.push(r)}else e[o]=r}),e):Object.keys(r).reduce(function(e,o){var a=r[o];return n.call(e,o)?e[o]=t(e[o],a,i):e[o]=a,e},a)},c=function t(t,e){return Object.keys(e).reduce(function(t,r){return t[r]=e[r],t},t)},f=function t(t,e,r){var n=t.replace(/\+/g," ");if(r==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(t){return n}},p=function t(t,e,n,o,a){if(t.length===0)return t;var u=t;if((typeof t==="undefined"?"undefined":l(t))=="symbol"?u=Symbol.prototype.toString.call(t):typeof t!="string"&&(u=String(t)),n==="iso-8859-1")return escape(u).replace(/%u[0-9a-f]{4}/gi,function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"});for(var s="",c=0;c<u.length;++c){var f=u.charCodeAt(c);if(f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||a===r.RFC1738&&(f===40||f===41)){s+=u.charAt(c);continue}if(f<128){s=s+i[f];continue}if(f<2048){s=s+(i[192|f>>6]+i[128|f&63]);continue}if(f<55296||f>=57344){s=s+(i[224|f>>12]+i[128|f>>6&63]+i[128|f&63]);continue}c+=1,f=65536+((f&1023)<<10|u.charCodeAt(c)&1023),s+=i[240|f>>18]+i[128|f>>12&63]+i[128|f>>6&63]+i[128|f&63]}return s},y=function t(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],n=0;n<e.length;++n)for(var o=e[n],i=o.obj[o.prop],u=Object.keys(i),s=0;s<u.length;++s){var c=u[s],f=i[c];typeof f=="object"&&f!==null&&r.indexOf(f)===-1&&(e.push({obj:i,prop:c}),r.push(f))}return a(e),t},d=function t(t){return Object.prototype.toString.call(t)==="[object RegExp]"},h=function t(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},m=function t(t,e){return[].concat(t,e)},b=function t(t,e){if(o(t)){for(var r=[],n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)};e.exports={arrayToObject:u,assign:c,combine:m,compact:y,decode:f,encode:p,isBuffer:h,isRegExp:d,maybeMap:b,merge:s}});var F=c(function(t,e){"use strict";var r=I(),n=R(),o=T(),a=Object.prototype.hasOwnProperty,u={brackets:function t(t){return t+"[]"},comma:"comma",indices:function t(t,e){return t+"["+e+"]"},repeat:function t(t){return t}},s=Array.isArray,c=Array.prototype.push,f=function t(t,e){c.apply(t,s(e)?e:[e])},p=Date.prototype.toISOString,y=o.default,d={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:n.encode,encodeValuesOnly:!1,format:y,formatter:o.formatters[y],indices:!1,serializeDate:function t(t){return p.call(t)},skipNulls:!1,strictNullHandling:!1},h=function t(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||(typeof t==="undefined"?"undefined":l(t))=="symbol"||(typeof t==="undefined"?"undefined":l(t))=="bigint"},m=function t(e,o,a,u,c,p,y,m,b,v,g,w,A,O,j){var S=e;if(j.has(e))throw new RangeError("Cyclic object value");if(typeof y=="function"?S=y(o,S):i(S,Date)?S=v(S):a==="comma"&&s(S)&&(S=n.maybeMap(S,function(t){return i(t,Date)?v(t):t})),S===null){if(u)return p&&!A?p(o,d.encoder,O,"key",g):o;S=""}if(h(S)||n.isBuffer(S)){if(p){var P=A?o:p(o,d.encoder,O,"key",g);return[w(P)+"="+w(p(S,d.encoder,O,"value",g))]}return[w(o)+"="+w(String(S))]}var E=[];if((typeof S==="undefined"?"undefined":l(S))>"u")return E;var x;if(a==="comma"&&s(S))x=[{value:S.length>0?S.join(",")||null:void 0}];else if(s(y))x=y;else{var _=Object.keys(S);x=m?_.sort(m):_}for(var I=0;I<x.length;++I){var T=x[I],R=typeof T=="object"&&T.value!==void 0?T.value:S[T];if(!(c&&R===null)){var F=s(S)?typeof a=="function"?a(o,T):o:o+(b?"."+T:"["+T+"]");j.set(e,!0);var D=r();f(E,t(R,F,a,u,c,p,y,m,b,v,g,w,A,O,D))}}return E},b=function t(t){if(!t)return d;if(t.encoder!==null&&t.encoder!==void 0&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||d.charset;if(l(t.charset)<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=o.default;if(l(t.format)<"u"){if(!a.call(o.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var n=o.formatters[r],i=d.filter;return(typeof t.filter=="function"||s(t.filter))&&(i=t.filter),{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:d.addQueryPrefix,allowDots:l(t.allowDots)>"u"?d.allowDots:!!t.allowDots,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:d.charsetSentinel,delimiter:l(t.delimiter)>"u"?d.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:d.encode,encoder:typeof t.encoder=="function"?t.encoder:d.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:d.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:d.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:d.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:d.strictNullHandling}};e.exports=function(t,e){var n=t,o=b(e),i,a;typeof o.filter=="function"?(a=o.filter,n=a("",n)):s(o.filter)&&(a=o.filter,i=a);var c=[];if(typeof n!="object"||n===null)return"";var p;e&&e.arrayFormat in u?p=e.arrayFormat:e&&"indices"in e?p=e.indices?"indices":"repeat":p="indices";var l=u[p];i||(i=Object.keys(n)),o.sort&&i.sort(o.sort);for(var y=r(),d=0;d<i.length;++d){var h=i[d];o.skipNulls&&n[h]===null||f(c,m(n[h],h,l,o.strictNullHandling,o.skipNulls,o.encode?o.encoder:null,o.filter,o.sort,o.allowDots,o.serializeDate,o.format,o.formatter,o.encodeValuesOnly,o.charset,y))}var v=c.join(o.delimiter),g=o.addQueryPrefix===!0?"?":"";return o.charsetSentinel&&(o.charset==="iso-8859-1"?g+="utf8=%26%2310003%3B&":g+="utf8=%E2%9C%93&"),v.length>0?g+v:""}});var D=c(function(t,e){"use strict";var r=R(),n=Object.prototype.hasOwnProperty,o=Array.isArray,i={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},a=function t(t){return t.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},u=function t(t,e){return t&&typeof t=="string"&&e.comma&&t.indexOf(",")>-1?t.split(","):t},s="utf8=%26%2310003%3B",c="utf8=%E2%9C%93",f=function t(t,e){var f={},p=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,l=e.parameterLimit===1/0?void 0:e.parameterLimit,y=p.split(e.delimiter,l),d=-1,h,m=e.charset;if(e.charsetSentinel)for(h=0;h<y.length;++h)y[h].indexOf("utf8=")===0&&(y[h]===c?m="utf-8":y[h]===s&&(m="iso-8859-1"),d=h,h=y.length);for(h=0;h<y.length;++h)if(h!==d){var b=y[h],v=b.indexOf("]="),g=v===-1?b.indexOf("="):v+1,w,A;g===-1?(w=e.decoder(b,i.decoder,m,"key"),A=e.strictNullHandling?null:""):(w=e.decoder(b.slice(0,g),i.decoder,m,"key"),A=r.maybeMap(u(b.slice(g+1),e),function(t){return e.decoder(t,i.decoder,m,"value")})),A&&e.interpretNumericEntities&&m==="iso-8859-1"&&(A=a(A)),b.indexOf("[]=")>-1&&(A=o(A)?[A]:A),n.call(f,w)?f[w]=r.combine(f[w],A):f[w]=A}return f},p=function t(t,e,r,n){for(var o=n?e:u(e,r),i=t.length-1;i>=0;--i){var a,s=t[i];if(s==="[]"&&r.parseArrays)a=[].concat(o);else{a=r.plainObjects?Object.create(null):{};var c=s.charAt(0)==="["&&s.charAt(s.length-1)==="]"?s.slice(1,-1):s,f=parseInt(c,10);!r.parseArrays&&c===""?a={0:o}:!isNaN(f)&&s!==c&&String(f)===c&&f>=0&&r.parseArrays&&f<=r.arrayLimit?(a=[],a[f]=o):a[c]=o}o=a}return o},y=function t(t,e,r,o){if(t){var i=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/,u=/(\[[^[\]]*])/g,s=r.depth>0&&a.exec(i),c=s?i.slice(0,s.index):i,f=[];if(c){if(!r.plainObjects&&n.call(Object.prototype,c)&&!r.allowPrototypes)return;f.push(c)}for(var l=0;r.depth>0&&(s=u.exec(i))!==null&&l<r.depth;){if(l+=1,!r.plainObjects&&n.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;f.push(s[1])}return s&&f.push("["+i.slice(s.index)+"]"),p(f,e,r,o)}},d=function t(t){if(!t)return i;if(t.decoder!==null&&t.decoder!==void 0&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(l(t.charset)<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=l(t.charset)>"u"?i.charset:t.charset;return{allowDots:l(t.allowDots)>"u"?i.allowDots:!!t.allowDots,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:i.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:i.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:i.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:i.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:i.comma,decoder:typeof t.decoder=="function"?t.decoder:i.decoder,delimiter:typeof t.delimiter=="string"||r.isRegExp(t.delimiter)?t.delimiter:i.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:i.depth,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:i.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:i.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:i.strictNullHandling}};e.exports=function(t,e){var n=d(e);if(t===""||t===null||(typeof t==="undefined"?"undefined":l(t))>"u")return n.plainObjects?Object.create(null):{};for(var o=typeof t=="string"?f(t,n):t,i=n.plainObjects?Object.create(null):{},a=Object.keys(o),u=0;u<a.length;++u){var s=a[u],c=y(s,o[s],n,typeof t=="string");i=r.merge(i,c,n)}return n.allowSparse===!0?i:r.compact(i)}});var k=c(function(t,e){"use strict";var r=F(),n=D(),o=T();e.exports={formats:o,parse:n,stringify:r}});var B=c(function(t,e){"use strict";var r=(typeof self==="undefined"?"undefined":l(self))<"u"?self:t,n=function(){var t=function t(){this.fetch=!1,this.DOMException=r.DOMException};return t.prototype=r,new t}();(function(t){var e=function(e){var r=function t(t){return t&&DataView.prototype.isPrototypeOf(t)};var n=function t(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()};var o=function t(t){return typeof t!="string"&&(t=String(t)),t};var a=function t(t){var e={next:function e(){var e=t.shift();return{done:e===void 0,value:e}}};return w.iterable&&(e[Symbol.iterator]=function(){return e}),e};var u=function t(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0};var s=function t(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})};var c=function t(t){var e=new FileReader,r=s(e);return e.readAsArrayBuffer(t),r};var f=function t(t){var e=new FileReader,r=s(e);return e.readAsText(t),r};var p=function t(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")};var y=function t(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer};var d=function t(){return this.bodyUsed=!1,this._initBody=function(t){this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:w.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:w.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:w.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():w.arrayBuffer&&w.blob&&r(t)?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):w.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||O(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):w.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},w.blob&&(this.blob=function(){var t=u(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(c)}),this.text=function(){var t=u(this);if(t)return t;if(this._bodyBlob)return f(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(p(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},w.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this};var h=function t(t){var e=t.toUpperCase();return S.indexOf(e)>-1?e:t};var m=function t(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e};var b=function t(t){var e=new j,r=t.replace(/\r?\n[\t ]+/g," ");return r.split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e};var v=function t(t,e){e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new j(e.headers),this.url=e.url||"",this._initBody(t)};var g=function t(t,r){return new Promise(function(n,o){var i=new P(t,r);if(i.signal&&i.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t={status:a.status,statusText:a.statusText,headers:b(a.getAllResponseHeaders()||"")};t.url="responseURL"in a?a.responseURL:t.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;n(new v(e,t))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(i.method,i.url,!0),i.credentials==="include"?a.withCredentials=!0:i.credentials==="omit"&&(a.withCredentials=!1),"responseType"in a&&w.blob&&(a.responseType="blob"),i.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),i.signal&&(i.signal.addEventListener("abort",u),a.onreadystatechange=function(){a.readyState===4&&i.signal.removeEventListener("abort",u)}),a.send(l(i._bodyInit)>"u"?null:i._bodyInit)})};var w={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(w.arrayBuffer)var A=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],O=ArrayBuffer.isView||function(t){return t&&A.indexOf(Object.prototype.toString.call(t))>-1};function j(t){this.map={},i(t,j)?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}j.prototype.append=function(t,e){t=n(t),e=o(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},j.prototype.delete=function(t){delete this.map[n(t)]},j.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},j.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},j.prototype.set=function(t,e){this.map[n(t)]=o(e)},j.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},j.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),a(t)},j.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),a(t)},j.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),a(t)},w.iterable&&(j.prototype[Symbol.iterator]=j.prototype.entries);var S=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function P(t,e){e=e||{};var r=e.body;if(i(t,P)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new j(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new j(e.headers)),this.method=h(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}P.prototype.clone=function(){return new P(this,{body:this._bodyInit})};d.call(P.prototype);d.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new j(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var E=[301,302,303,307,308];v.redirect=function(t,e){if(E.indexOf(e)===-1)throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}return g.polyfill=!0,t.fetch||(t.fetch=g,t.Headers=j,t.Request=P,t.Response=v),e.Headers=j,e.Request=P,e.Response=v,e.fetch=g,Object.defineProperty(e,"__esModule",{value:!0}),e}({})})(n);n.fetch.ponyfill=!0;delete n.fetch.polyfill;var o=n;t=o.fetch;t.default=o.fetch;t.fetch=o.fetch;t.Headers=o.Headers;t.Request=o.Request;t.Response=o.Response;e.exports=t});var U=c(function(t,e){"use strict";var r=function t(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))};e.exports=r;r.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};r.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};r.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0};r.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};r.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};r.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};r.prototype.start=r.prototype.try;r.prototype.errors=function(){return this._errors};r.prototype.attempts=function(){return this._attempts};r.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,r=0,n=0;n<this._errors.length;n++){var o=this._errors[n],i=o.message,a=(t[i]||0)+1;t[i]=a,a>=r&&(e=o,r=a)}return e}});var M=c(function(t){"use strict";var e=U();t.operation=function(r){var n=t.timeouts(r);return new e(n,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})};t.timeouts=function(t){if(i(t,Array))return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in t)e[r]=t[r];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],o=0;o<e.retries;o++)n.push(this.createTimeout(o,e));return t&&t.forever&&!n.length&&n.push(this.createTimeout(o,e)),n.sort(function(t,e){return t-e}),n};t.createTimeout=function(t,e){var r=e.randomize?Math.random()+1:1,n=Math.round(r*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return n=Math.min(n,e.maxTimeout),n};t.wrap=function(e,r,n){if(i(r,Array)&&(n=r,r=null),!n){n=[];for(var o in e)typeof e[o]=="function"&&n.push(o)}for(var a=0;a<n.length;a++){var u=n[a],s=e[u];e[u]=(function(n){var o=t.operation(r),i=Array.prototype.slice.call(arguments,1),a=i.pop();i.push(function(t){o.retry(t)||(t&&(arguments[0]=o.mainError()),a.apply(this,arguments))}),o.attempt(function(){n.apply(e,i)})}).bind(e,s),e[u].options=r}}});var N=c(function(t,e){"use strict";e.exports=M()});var C=c(function(t,e){"use strict";var r=function t(t,e){function r(r,o){var i=e||{},a;"randomize"in i||(i.randomize=!0),a=n.operation(i);function u(t){o(t||new Error("Aborted"))}function s(t,e){if(t.bail){u(t);return}a.retry(t)?i.onRetry&&i.onRetry(t,e):o(a.mainError())}function c(e){var n;try{n=t(u,e)}catch(t){s(t,e);return}Promise.resolve(n).then(r).catch(function(t){s(t,e)})}a.attempt(c)}return new Promise(r)};var n=N();e.exports=r});var q={};y(q,{createClient:function(){return Y}});var L=m(k());var W=function(t){return t!==null&&typeof t=="object"},H=function(t){return typeof t=="string"};var G=function(t){if(!W(t))throw new Error("queries is not object");return L.default.stringify(t,{arrayFormat:"comma"})};var z="microcms.io",V="v1";var J=m(B()),Q=function(t){var e;return t?e=t:(typeof fetch==="undefined"?"undefined":l(fetch))>"u"?e=J.default:e=fetch,function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}return e.apply(void 0,p(r))}},$=function(){return(typeof Headers==="undefined"?"undefined":l(Headers))>"u"?J.Headers:Headers},K=function(t,e){var r=Q(e),o=$();return function(){var e=n(function(e,n){var i,a;return d(this,function(u){a=new o((i=n)===null||i===void 0?void 0:i.headers);return[2,(a.has("X-MICROCMS-API-KEY")||a.set("X-MICROCMS-API-KEY",t),r(e,f(s({},n),{headers:a})))]})});return function(t,r){return e.apply(this,arguments)}}()};var X=m(C()),Y=function(t){var e=t.serviceDomain,r=t.apiKey,o=t.customFetch,i=t.retry;if(!e||!r)throw new Error("parameter is required (check serviceDomain and apiKey)");if(!H(e)||!H(r))throw new Error("parameter is not string");var a="https://".concat(e,".").concat(z,"/api/").concat(V),u=function(){var t=n(function(t){var e,u,c,p,l,y,h,m,b;return d(this,function(v){switch(v.label){case 0:e=t.endpoint,u=t.contentId,c=t.queries,p=c===void 0?{}:c,l=t.requestInit;y=K(r,o),h=G(p),m="".concat(a,"/").concat(e).concat(u?"/".concat(u):"").concat(h?"?".concat(h):""),b=function(){var t=n(function(t){var e,r,n;return d(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,t.json()];case 1:e=o.sent(),r=e.message;return[2,r!==null&&r!==void 0?r:null];case 2:n=o.sent();return[2,null];case 3:return[2]}})});return function e(e){return t.apply(this,arguments)}}();return[4,(0,X.default)(function(){var t=n(function(t){var e,r,n,o,i,a,u,c;return d(this,function(p){switch(p.label){case 0:p.trys.push([0,6,,7]);return[4,y(m,f(s({},l),{method:(n=(e=l)===null||e===void 0?void 0:e.method)!==null&&n!==void 0?n:"GET"}))];case 1:o=p.sent();if(!(o.status!==429&&o.status>=400&&o.status<500))return[3,3];return[4,b(o)];case 2:i=p.sent();return[2,t(new Error("fetch API response status: ".concat(o.status).concat(i?"\n message is `".concat(i,"`"):"")))];case 3:if(!!o.ok)return[3,5];return[4,b(o)];case 4:a=p.sent();return[2,Promise.reject(new Error("fetch API response status: ".concat(o.status).concat(a?"\n message is `".concat(a,"`"):"")))];case 5:return[2,((r=l)===null||r===void 0?void 0:r.method)==="DELETE"?void 0:o.json()];case 6:u=p.sent();if(u.data)throw u.data;if((c=u.response)===null||c===void 0?void 0:c.data)throw u.response.data;return[2,Promise.reject(new Error("Network Error.\n Details: ".concat(u)))];case 7:return[2]}})});return function(e){return t.apply(this,arguments)}}(),{retries:i?2:0,onRetry:function(t,e){console.log(t),console.log("Waiting for retry (".concat(e,"/",2,")"))},minTimeout:5e3})];case 1:return[2,v.sent()]}})});return function e(e){return t.apply(this,arguments)}}();return{get:function(){var t=n(function(t){var e,r,n,o,i,a;return d(this,function(s){switch(s.label){case 0:e=t.endpoint,r=t.contentId,n=t.queries,o=n===void 0?{}:n,i=t.customRequestInit;if(!e)return[3,2];return[4,u({endpoint:e,contentId:r,queries:o,requestInit:i})];case 1:a=s.sent();return[3,3];case 2:a=Promise.reject(new Error("endpoint is required"));s.label=3;case 3:return[2,a]}})});return function(e){return t.apply(this,arguments)}}(),getList:function(){var t=n(function(t){var e,r,n,o,i;return d(this,function(a){switch(a.label){case 0:e=t.endpoint,r=t.queries,n=r===void 0?{}:r,o=t.customRequestInit;if(!e)return[3,2];return[4,u({endpoint:e,queries:n,requestInit:o})];case 1:i=a.sent();return[3,3];case 2:i=Promise.reject(new Error("endpoint is required"));a.label=3;case 3:return[2,i]}})});return function(e){return t.apply(this,arguments)}}(),getListDetail:function(){var t=n(function(t){var e,r,n,o,i,a;return d(this,function(s){switch(s.label){case 0:e=t.endpoint,r=t.contentId,n=t.queries,o=n===void 0?{}:n,i=t.customRequestInit;if(!e)return[3,2];return[4,u({endpoint:e,contentId:r,queries:o,requestInit:i})];case 1:a=s.sent();return[3,3];case 2:a=Promise.reject(new Error("endpoint is required"));s.label=3;case 3:return[2,a]}})});return function(e){return t.apply(this,arguments)}}(),getObject:function(){var t=n(function(t){var e,r,n,o,i;return d(this,function(a){switch(a.label){case 0:e=t.endpoint,r=t.queries,n=r===void 0?{}:r,o=t.customRequestInit;if(!e)return[3,2];return[4,u({endpoint:e,queries:n,requestInit:o})];case 1:i=a.sent();return[3,3];case 2:i=Promise.reject(new Error("endpoint is required"));a.label=3;case 3:return[2,i]}})});return function(e){return t.apply(this,arguments)}}(),getAllContentIds:function(){var t=n(function(t){var e,r,n,o,i,a,c,l,y,h,m,b,v,g,w,A,O;return d(this,function(d){switch(d.label){case 0:e=t.endpoint,r=t.alternateField,n=t.draftKey,o=t.filters,i=t.orders,a=t.customRequestInit;c={draftKey:n,filters:o,orders:i,limit:100,fields:r!==null&&r!==void 0?r:"id",depth:0};return[4,u({endpoint:e,queries:f(s({},c),{limit:0}),requestInit:a})];case 1:l=d.sent(),y=l.totalCount,h=[],m=0,b=function(t){return new Promise(function(e){return setTimeout(e,t)})},v=function(t){return t.every(function(t){return typeof t=="string"})};d.label=2;case 2:if(!(h.length<y))return[3,7];return[4,u({endpoint:e,queries:f(s({},c),{offset:m}),requestInit:a})];case 3:g=d.sent(),w=g.contents,A=w.map(function(t){return t[r!==null&&r!==void 0?r:"id"]});if(!v(A))throw new Error("The value of the field specified by `alternateField` is not a string.");h=p(h).concat(p(A)),m+=100;O=h.length<y;if(!O)return[3,5];return[4,b(1e3)];case 4:O=d.sent();d.label=5;case 5:O;d.label=6;case 6:return[3,2];case 7:return[2,h]}})});return function(e){return t.apply(this,arguments)}}(),create:function(){var t=n(function(t){var e,r,n,o,i,a,c,p;return d(this,function(l){e=t.endpoint,r=t.contentId,n=t.content,o=t.isDraft,i=o===void 0?!1:o,a=t.customRequestInit;if(!e)return[2,Promise.reject(new Error("endpoint is required"))];c=i?{status:"draft"}:{},p=f(s({},a),{method:r?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return[2,u({endpoint:e,contentId:r,queries:c,requestInit:p})]})});return function(e){return t.apply(this,arguments)}}(),update:function(){var t=n(function(t){var e,r,n,o,i;return d(this,function(a){e=t.endpoint,r=t.contentId,n=t.content,o=t.customRequestInit;if(!e)return[2,Promise.reject(new Error("endpoint is required"))];i=f(s({},o),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return[2,u({endpoint:e,contentId:r,requestInit:i})]})});return function(e){return t.apply(this,arguments)}}(),delete:function(){var t=n(function(t){var e,r,n,o;return d(this,function(i){switch(i.label){case 0:e=t.endpoint,r=t.contentId,n=t.customRequestInit;if(!e)return[2,Promise.reject(new Error("endpoint is required"))];if(!r)return[2,Promise.reject(new Error("contentId is required"))];o=f(s({},n),{method:"DELETE",headers:{},body:void 0});return[4,u({endpoint:e,contentId:r,requestInit:o})];case 1:i.sent();return[2]}})});return function(e){return t.apply(this,arguments)}}()}};return b(q)}();//# sourceMappingURL=microcms-js-sdk.js.map