@posty5/social-publisher-post 4.1.0 → 4.2.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/dist/index.js CHANGED
@@ -12080,22 +12080,82 @@ var { toString } = Object.prototype;
12080
12080
  var { getPrototypeOf } = Object;
12081
12081
  var { iterator, toStringTag } = Symbol;
12082
12082
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
12083
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
12084
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
12085
+ var isSafeAndFullyMutable = (obj) => {
12086
+ if (!Object.isExtensible(obj)) {
12087
+ return false;
12088
+ }
12089
+ const props = Object.getOwnPropertyNames(obj);
12090
+ if (Object.getOwnPropertySymbols) {
12091
+ props.push(...Object.getOwnPropertySymbols(obj));
12092
+ }
12093
+ return props.every((prop) => {
12094
+ if (isUnsafeObjectKey(prop)) {
12095
+ return false;
12096
+ }
12097
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
12098
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
12099
+ });
12100
+ };
12083
12101
  var hasOwnInPrototypeChain = (thing, prop) => {
12084
12102
  let obj = thing;
12085
12103
  const seen = [];
12086
- while (obj != null && obj !== Object.prototype) {
12104
+ while (obj != null) {
12087
12105
  if (seen.indexOf(obj) !== -1) {
12088
12106
  return false;
12089
12107
  }
12090
12108
  seen.push(obj);
12109
+ const prototype2 = getPrototypeOf(obj);
12110
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
12111
+ return false;
12112
+ }
12091
12113
  if (hasOwnProperty(obj, prop)) {
12092
12114
  return true;
12093
12115
  }
12094
- obj = getPrototypeOf(obj);
12116
+ obj = prototype2;
12095
12117
  }
12096
12118
  return false;
12097
12119
  };
12098
12120
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
12121
+ var toSafeFlatObject = (thing) => {
12122
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
12123
+ return thing;
12124
+ }
12125
+ const sourcePrototype = getPrototypeOf(thing);
12126
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
12127
+ return thing;
12128
+ }
12129
+ const result = /* @__PURE__ */ Object.create(null);
12130
+ const merged = /* @__PURE__ */ Object.create(null);
12131
+ const seen = [];
12132
+ let current = thing;
12133
+ while (current != null) {
12134
+ if (seen.indexOf(current) !== -1) {
12135
+ break;
12136
+ }
12137
+ seen.push(current);
12138
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
12139
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
12140
+ break;
12141
+ }
12142
+ const props = Object.getOwnPropertyNames(current);
12143
+ if (Object.getOwnPropertySymbols) {
12144
+ props.push(...Object.getOwnPropertySymbols(current));
12145
+ }
12146
+ for (const prop of props) {
12147
+ if (isUnsafeObjectKey(prop)) {
12148
+ continue;
12149
+ }
12150
+ if (!hasOwnProperty(merged, prop)) {
12151
+ result[prop] = thing[prop];
12152
+ merged[prop] = true;
12153
+ }
12154
+ }
12155
+ current = prototype2;
12156
+ }
12157
+ return result;
12158
+ };
12099
12159
  var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
12100
12160
  const str = toString.call(thing);
12101
12161
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -12130,9 +12190,9 @@ var isPlainObject = (val) => {
12130
12190
  return false;
12131
12191
  }
12132
12192
  const prototype2 = getPrototypeOf(val);
12133
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
12134
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
12135
- // than a plain object, while ignoring keys injected onto Object.prototype.
12193
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
12194
+ // evidence the value is tagged/iterable, while ignoring members reachable
12195
+ // only through shared or terminal prototype boundaries.
12136
12196
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
12137
12197
  };
12138
12198
  var isEmptyObject = (val) => {
@@ -12153,6 +12213,7 @@ var isReactNativeBlob = (value) => {
12153
12213
  var isReactNative = (formData) => formData && typeof formData.getParts !== "undefined";
12154
12214
  var isBlob = kindOfTest("Blob");
12155
12215
  var isFileList = kindOfTest("FileList");
12216
+ var isSet = kindOfTest("Set");
12156
12217
  var isStream = (val) => isObject(val) && isFunction(val.pipe);
12157
12218
  function getGlobal() {
12158
12219
  if (typeof globalThis !== "undefined") return globalThis;
@@ -12448,11 +12509,20 @@ var toJSONObject = (obj) => {
12448
12509
  }
12449
12510
  if (!("toJSON" in source)) {
12450
12511
  visited.add(source);
12451
- const target = isArray(source) ? [] : {};
12452
- forEach(source, (value, key) => {
12453
- const reducedValue = visit(value);
12454
- !isUndefined(reducedValue) && (target[key] = reducedValue);
12455
- });
12512
+ let target;
12513
+ if (isSet(source)) {
12514
+ target = [];
12515
+ for (const value of source) {
12516
+ const reducedValue = visit(value);
12517
+ !isUndefined(reducedValue) && target.push(reducedValue);
12518
+ }
12519
+ } else {
12520
+ target = isArray(source) ? [] : {};
12521
+ forEach(source, (value, key) => {
12522
+ const reducedValue = visit(value);
12523
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
12524
+ });
12525
+ }
12456
12526
  visited.delete(source);
12457
12527
  return target;
12458
12528
  }
@@ -12533,6 +12603,7 @@ var utils_default = {
12533
12603
  // an alias to avoid ESLint no-prototype-builtins detection
12534
12604
  hasOwnInPrototypeChain,
12535
12605
  getSafeProp,
12606
+ toSafeFlatObject,
12536
12607
  reduceDescriptors,
12537
12608
  freezeMethods,
12538
12609
  toObjectSet,
@@ -12581,17 +12652,18 @@ var parseHeaders_default = (rawHeaders) => {
12581
12652
  i = line.indexOf(":");
12582
12653
  key = line.substring(0, i).trim().toLowerCase();
12583
12654
  val = line.substring(i + 1).trim();
12584
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
12655
+ const hasKey = utils_default.hasOwnProp(parsed, key);
12656
+ if (!key || hasKey && utils_default.hasOwnProp(ignoreDuplicateOf, key)) {
12585
12657
  return;
12586
12658
  }
12587
12659
  if (key === "set-cookie") {
12588
- if (parsed[key]) {
12660
+ if (hasKey) {
12589
12661
  parsed[key].push(val);
12590
12662
  } else {
12591
12663
  parsed[key] = [val];
12592
12664
  }
12593
12665
  } else {
12594
- parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
12666
+ parsed[key] = hasKey ? parsed[key] + ", " + val : val;
12595
12667
  }
12596
12668
  });
12597
12669
  return parsed;
@@ -12655,6 +12727,90 @@ function parseTokens(str) {
12655
12727
  }
12656
12728
  return tokens;
12657
12729
  }
12730
+ var parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
12731
+ function trimOWS(value) {
12732
+ let start = 0;
12733
+ let end = value.length;
12734
+ while (start < end) {
12735
+ const code = value.charCodeAt(start);
12736
+ if (code !== 9 && code !== 32) {
12737
+ break;
12738
+ }
12739
+ start += 1;
12740
+ }
12741
+ while (end > start) {
12742
+ const code = value.charCodeAt(end - 1);
12743
+ if (code !== 9 && code !== 32) {
12744
+ break;
12745
+ }
12746
+ end -= 1;
12747
+ }
12748
+ return start === 0 && end === value.length ? value : value.slice(start, end);
12749
+ }
12750
+ function decodeQuotedString(value) {
12751
+ const last = value.length - 1;
12752
+ if (last < 1 || value.charCodeAt(0) !== 34 || value.charCodeAt(last) !== 34) {
12753
+ return value;
12754
+ }
12755
+ let decoded = "";
12756
+ for (let i = 1; i < last; i++) {
12757
+ const code = value.charCodeAt(i);
12758
+ if (code === 34) {
12759
+ return value;
12760
+ }
12761
+ if (code === 92) {
12762
+ i += 1;
12763
+ if (i >= last) {
12764
+ return value;
12765
+ }
12766
+ }
12767
+ decoded += value[i];
12768
+ }
12769
+ return decoded;
12770
+ }
12771
+ function parseParameters(value) {
12772
+ const parameters = /* @__PURE__ */ Object.create(null);
12773
+ const str = String(value);
12774
+ let start = 0;
12775
+ let quoted = false;
12776
+ let escaped = false;
12777
+ function parseParameter(end) {
12778
+ const part = trimOWS(str.slice(start, end));
12779
+ const equals = part.indexOf("=");
12780
+ if (equals < 1) {
12781
+ return;
12782
+ }
12783
+ const name = trimOWS(part.slice(0, equals));
12784
+ if (!parameterNameRE.test(name)) {
12785
+ return;
12786
+ }
12787
+ const normalizedName = name.toLowerCase();
12788
+ if (normalizedName === "__proto__" || normalizedName === "constructor" || normalizedName === "prototype") {
12789
+ return;
12790
+ }
12791
+ const parameterValue = trimOWS(part.slice(equals + 1));
12792
+ parameters[normalizedName] = decodeQuotedString(parameterValue);
12793
+ }
12794
+ for (let i = 0; i < str.length; i++) {
12795
+ const code = str.charCodeAt(i);
12796
+ if (quoted) {
12797
+ if (escaped) {
12798
+ escaped = false;
12799
+ } else if (code === 92) {
12800
+ escaped = true;
12801
+ } else if (code === 34) {
12802
+ quoted = false;
12803
+ }
12804
+ } else if (code === 34) {
12805
+ quoted = true;
12806
+ } else if (code === 44 || code === 59) {
12807
+ parseParameter(i);
12808
+ start = i + 1;
12809
+ }
12810
+ }
12811
+ parseParameter(str.length);
12812
+ return parameters;
12813
+ }
12658
12814
  var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
12659
12815
  function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
12660
12816
  if (utils_default.isFunction(filter2)) {
@@ -12830,7 +12986,8 @@ var AxiosHeaders = class {
12830
12986
  return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
12831
12987
  }
12832
12988
  getSetCookie() {
12833
- return this.get("set-cookie") || [];
12989
+ const value = this.get("set-cookie");
12990
+ return utils_default.isArray(value) ? value : value == null || value === false ? [] : [value];
12834
12991
  }
12835
12992
  get [Symbol.toStringTag]() {
12836
12993
  return "AxiosHeaders";
@@ -12838,6 +12995,9 @@ var AxiosHeaders = class {
12838
12995
  static from(thing) {
12839
12996
  return thing instanceof this ? thing : new this(thing);
12840
12997
  }
12998
+ static parseParameters(value) {
12999
+ return parseParameters(value);
13000
+ }
12841
13001
  static concat(first, ...targets) {
12842
13002
  const computed = new this(first);
12843
13003
  targets.forEach((target) => computed.set(target));
@@ -12933,9 +13093,30 @@ function redactConfig(config, redactKeys) {
12933
13093
  };
12934
13094
  return visit(config);
12935
13095
  }
13096
+ function stringifySafely(value) {
13097
+ try {
13098
+ return String(value);
13099
+ } catch (err) {
13100
+ return "";
13101
+ }
13102
+ }
13103
+ function aggregateErrorMessage(error) {
13104
+ const message = error.errors.map((entry) => {
13105
+ try {
13106
+ return entry && entry.message ? stringifySafely(entry.message) : stringifySafely(entry);
13107
+ } catch (err) {
13108
+ return "";
13109
+ }
13110
+ }).filter(Boolean).join("; ");
13111
+ return message || error.name || "AggregateError";
13112
+ }
12936
13113
  var AxiosError = class _AxiosError extends Error {
12937
13114
  static from(error, code, config, request, response, customProps) {
12938
- const axiosError = new _AxiosError(error.message, code || error.code, config, request, response);
13115
+ let message = error.message;
13116
+ if (!message && utils_default.isArray(error.errors) && error.errors.length) {
13117
+ message = aggregateErrorMessage(error);
13118
+ }
13119
+ const axiosError = new _AxiosError(message, code || error.code, config, request, response);
12939
13120
  Object.defineProperty(axiosError, "cause", {
12940
13121
  __proto__: null,
12941
13122
  value: error,
@@ -13025,6 +13206,16 @@ var AxiosError_default = AxiosError;
13025
13206
  var import_form_data = __toESM(require_form_data());
13026
13207
  var FormData_default = import_form_data.default;
13027
13208
 
13209
+ // ../node_modules/axios/lib/platform/node/classes/Buffer.js
13210
+ var Buffer_default = {
13211
+ isBufferAvailable() {
13212
+ return typeof Buffer !== "undefined";
13213
+ },
13214
+ from(value) {
13215
+ return Buffer.from(value);
13216
+ }
13217
+ };
13218
+
13028
13219
  // ../node_modules/axios/lib/helpers/toFormData.js
13029
13220
  var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
13030
13221
  function isVisitable(thing) {
@@ -13051,24 +13242,16 @@ function toFormData(obj, formData, options) {
13051
13242
  throw new TypeError("target must be an object");
13052
13243
  }
13053
13244
  formData = formData || new (FormData_default || FormData)();
13054
- options = utils_default.toFlatObject(
13055
- options,
13056
- {
13057
- metaTokens: true,
13058
- dots: false,
13059
- indexes: false
13060
- },
13061
- false,
13062
- function defined(option, source) {
13063
- return !utils_default.isUndefined(source[option]);
13064
- }
13065
- );
13066
- const metaTokens = options.metaTokens;
13067
- const visitor = options.visitor || defaultVisitor;
13068
- const dots = options.dots;
13069
- const indexes = options.indexes;
13070
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
13071
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
13245
+ const option = (name, fallback) => {
13246
+ const value = utils_default.getSafeProp(options, name);
13247
+ return utils_default.isUndefined(value) ? fallback : value;
13248
+ };
13249
+ const metaTokens = option("metaTokens", true);
13250
+ const visitor = option("visitor") || defaultVisitor;
13251
+ const dots = option("dots", false);
13252
+ const indexes = option("indexes", false);
13253
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
13254
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
13072
13255
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
13073
13256
  const stack = [];
13074
13257
  if (!utils_default.isFunction(visitor)) {
@@ -13089,10 +13272,13 @@ function toFormData(obj, formData, options) {
13089
13272
  if (useBlob && typeof _Blob === "function") {
13090
13273
  return new _Blob([value]);
13091
13274
  }
13092
- if (typeof Buffer !== "undefined") {
13093
- return Buffer.from(value);
13275
+ if (Buffer_default && Buffer_default.isBufferAvailable()) {
13276
+ return Buffer_default.from(value);
13094
13277
  }
13095
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
13278
+ throw new AxiosError_default(
13279
+ "Blob is not supported. Use a Buffer instead.",
13280
+ AxiosError_default.ERR_NOT_SUPPORT
13281
+ );
13096
13282
  }
13097
13283
  return value;
13098
13284
  }
@@ -13238,9 +13424,47 @@ function buildURL(url2, params, options) {
13238
13424
  }
13239
13425
 
13240
13426
  // ../node_modules/axios/lib/core/InterceptorManager.js
13427
+ var $internals2 = /* @__PURE__ */ Symbol("internals");
13428
+ function countHandlers(handlers) {
13429
+ return handlers ? handlers.length : 0;
13430
+ }
13431
+ function trimHandlers(handlers) {
13432
+ if (!handlers) {
13433
+ return;
13434
+ }
13435
+ while (handlers.length && handlers[handlers.length - 1] === null) {
13436
+ handlers.pop();
13437
+ }
13438
+ }
13439
+ function syncHandlerEntries(manager, internals) {
13440
+ const handlers = manager.handlers;
13441
+ const length = countHandlers(handlers);
13442
+ if (handlers !== internals.handlersRef) {
13443
+ internals.handlersRef = handlers;
13444
+ internals.handlerEntries.clear();
13445
+ } else if (length !== internals.handlersLength) {
13446
+ if (!length) {
13447
+ internals.handlerEntries.clear();
13448
+ } else {
13449
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
13450
+ if (handlers[entry.index] !== entry.handler) {
13451
+ internals.handlerEntries.delete(id);
13452
+ }
13453
+ });
13454
+ }
13455
+ }
13456
+ internals.handlersLength = length;
13457
+ }
13241
13458
  var InterceptorManager = class {
13242
13459
  constructor() {
13243
13460
  this.handlers = [];
13461
+ this[$internals2] = {
13462
+ handlersRef: this.handlers,
13463
+ handlersLength: this.handlers.length,
13464
+ handlerEntries: /* @__PURE__ */ new Map(),
13465
+ iterationDepth: 0,
13466
+ nextId: 0
13467
+ };
13244
13468
  }
13245
13469
  /**
13246
13470
  * Add a new interceptor to the stack
@@ -13252,13 +13476,25 @@ var InterceptorManager = class {
13252
13476
  * @return {Number} An ID used to remove interceptor later
13253
13477
  */
13254
13478
  use(fulfilled, rejected, options) {
13255
- this.handlers.push({
13479
+ const handler = {
13256
13480
  fulfilled,
13257
13481
  rejected,
13258
13482
  synchronous: options ? options.synchronous : false,
13259
13483
  runWhen: options ? options.runWhen : null
13484
+ };
13485
+ const internals = this[$internals2];
13486
+ if (this.handlers == null) {
13487
+ this.handlers = [];
13488
+ }
13489
+ syncHandlerEntries(this, internals);
13490
+ const id = internals.nextId++;
13491
+ this.handlers.push(handler);
13492
+ internals.handlerEntries.set(id, {
13493
+ handler,
13494
+ index: this.handlers.length - 1
13260
13495
  });
13261
- return this.handlers.length - 1;
13496
+ internals.handlersLength = this.handlers.length;
13497
+ return id;
13262
13498
  }
13263
13499
  /**
13264
13500
  * Remove an interceptor from the stack
@@ -13268,8 +13504,19 @@ var InterceptorManager = class {
13268
13504
  * @returns {void}
13269
13505
  */
13270
13506
  eject(id) {
13271
- if (this.handlers[id]) {
13272
- this.handlers[id] = null;
13507
+ const internals = this[$internals2];
13508
+ syncHandlerEntries(this, internals);
13509
+ const entry = internals.handlerEntries.get(id);
13510
+ if (entry) {
13511
+ internals.handlerEntries.delete(id);
13512
+ if (this.handlers[entry.index] !== entry.handler) {
13513
+ return;
13514
+ }
13515
+ this.handlers[entry.index] = null;
13516
+ if (!internals.iterationDepth) {
13517
+ trimHandlers(this.handlers);
13518
+ internals.handlersLength = this.handlers.length;
13519
+ }
13273
13520
  }
13274
13521
  }
13275
13522
  /**
@@ -13280,6 +13527,7 @@ var InterceptorManager = class {
13280
13527
  clear() {
13281
13528
  if (this.handlers) {
13282
13529
  this.handlers = [];
13530
+ syncHandlerEntries(this, this[$internals2]);
13283
13531
  }
13284
13532
  }
13285
13533
  /**
@@ -13293,11 +13541,22 @@ var InterceptorManager = class {
13293
13541
  * @returns {void}
13294
13542
  */
13295
13543
  forEach(fn) {
13296
- utils_default.forEach(this.handlers, function forEachHandler(h) {
13297
- if (h !== null) {
13298
- fn(h);
13544
+ const internals = this[$internals2];
13545
+ syncHandlerEntries(this, internals);
13546
+ internals.iterationDepth++;
13547
+ try {
13548
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
13549
+ if (h !== null) {
13550
+ fn(h);
13551
+ }
13552
+ });
13553
+ } finally {
13554
+ if (!--internals.iterationDepth) {
13555
+ syncHandlerEntries(this, internals);
13556
+ trimHandlers(this.handlers);
13557
+ internals.handlersLength = countHandlers(this.handlers);
13299
13558
  }
13300
- });
13559
+ }
13301
13560
  }
13302
13561
  };
13303
13562
  var InterceptorManager_default = InterceptorManager;
@@ -13393,7 +13652,7 @@ function throwIfDepthExceeded(index) {
13393
13652
  }
13394
13653
  function parsePropPath(name) {
13395
13654
  const path = [];
13396
- const pattern = /\w+|\[(\w*)]/g;
13655
+ const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
13397
13656
  let match;
13398
13657
  while ((match = pattern.exec(name)) !== null) {
13399
13658
  throwIfDepthExceeded(path.length);
@@ -13449,9 +13708,25 @@ function formDataToJSON(formData) {
13449
13708
  }
13450
13709
  var formDataToJSON_default = formDataToJSON;
13451
13710
 
13711
+ // ../node_modules/axios/lib/core/methodList.js
13712
+ var methodList = Object.freeze([
13713
+ "get",
13714
+ "delete",
13715
+ "head",
13716
+ "options",
13717
+ "post",
13718
+ "put",
13719
+ "patch",
13720
+ "purge",
13721
+ "link",
13722
+ "unlink",
13723
+ "query"
13724
+ ]);
13725
+ var methodList_default = methodList;
13726
+
13452
13727
  // ../node_modules/axios/lib/defaults/index.js
13453
13728
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
13454
- function stringifySafely(rawValue, parser, encoder) {
13729
+ function stringifySafely2(rawValue, parser, encoder) {
13455
13730
  if (utils_default.isString(rawValue)) {
13456
13731
  try {
13457
13732
  (parser || JSON.parse)(rawValue);
@@ -13507,7 +13782,7 @@ var defaults = {
13507
13782
  }
13508
13783
  if (isObjectPayload || hasJSONContentType) {
13509
13784
  headers.setContentType("application/json", false);
13510
- return stringifySafely(data);
13785
+ return stringifySafely2(data);
13511
13786
  }
13512
13787
  return data;
13513
13788
  }
@@ -13561,7 +13836,7 @@ var defaults = {
13561
13836
  }
13562
13837
  }
13563
13838
  };
13564
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
13839
+ utils_default.forEach(methodList_default, (method) => {
13565
13840
  defaults.headers[method] = {};
13566
13841
  });
13567
13842
  var defaults_default = defaults;
@@ -13629,29 +13904,62 @@ function isAbsoluteURL(url2) {
13629
13904
 
13630
13905
  // ../node_modules/axios/lib/helpers/combineURLs.js
13631
13906
  function combineURLs(baseURL, relativeURL) {
13632
- return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
13907
+ if (!relativeURL) {
13908
+ return baseURL;
13909
+ }
13910
+ let end = baseURL.length;
13911
+ while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
13912
+ end--;
13913
+ }
13914
+ return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
13915
+ }
13916
+
13917
+ // ../node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
13918
+ var urlParserControlCharacters = /[\t\n\r]/g;
13919
+ function normalizeURLForProtocolCheck(url2) {
13920
+ if (typeof url2 !== "string") {
13921
+ return url2;
13922
+ }
13923
+ let start = 0;
13924
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
13925
+ start++;
13926
+ }
13927
+ return url2.slice(start).replace(urlParserControlCharacters, "");
13633
13928
  }
13634
13929
 
13635
13930
  // ../node_modules/axios/lib/core/buildFullPath.js
13636
13931
  var malformedHttpProtocol = /^https?:(?!\/\/)/i;
13637
- var httpProtocolControlCharacters = /[\t\n\r]/g;
13638
- function stripLeadingC0ControlOrSpace(url2) {
13639
- let i = 0;
13640
- while (i < url2.length && url2.charCodeAt(i) <= 32) {
13641
- i++;
13932
+ function redactFragment(fragment) {
13933
+ if (!fragment) {
13934
+ return fragment;
13642
13935
  }
13643
- return url2.slice(i);
13936
+ return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = "") => {
13937
+ return `${separator}${parameterName}${REDACTED}`;
13938
+ });
13644
13939
  }
13645
- function normalizeURLForProtocolCheck(url2) {
13646
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
13940
+ function redactSensitiveURLParts(url2) {
13941
+ const redactedURL = url2.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
13942
+ const fragmentIndex = redactedURL.indexOf("#");
13943
+ const urlWithoutFragment = fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
13944
+ const redactedURLWithoutFragment = urlWithoutFragment.replace(
13945
+ /([?&][^=&#]*=)[^&#]*/g,
13946
+ `$1${REDACTED}`
13947
+ );
13948
+ if (fragmentIndex === -1) {
13949
+ return redactedURLWithoutFragment;
13950
+ }
13951
+ return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
13647
13952
  }
13648
13953
  function assertValidHttpProtocolURL(url2, config) {
13649
- if (typeof url2 === "string" && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url2))) {
13650
- throw new AxiosError_default(
13651
- 'Invalid URL: missing "//" after protocol',
13652
- AxiosError_default.ERR_INVALID_URL,
13653
- config
13654
- );
13954
+ if (typeof url2 === "string") {
13955
+ const normalizedURL = normalizeURLForProtocolCheck(url2);
13956
+ if (malformedHttpProtocol.test(normalizedURL)) {
13957
+ throw new AxiosError_default(
13958
+ `Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
13959
+ AxiosError_default.ERR_INVALID_URL,
13960
+ config
13961
+ );
13962
+ }
13655
13963
  }
13656
13964
  }
13657
13965
  function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
@@ -13736,7 +14044,7 @@ var import_https_proxy_agent = __toESM(require_dist());
13736
14044
  var import_follow_redirects = __toESM(require_follow_redirects());
13737
14045
 
13738
14046
  // ../node_modules/axios/lib/env/data.js
13739
- var VERSION = "1.18.1";
14047
+ var VERSION = "1.20.0";
13740
14048
 
13741
14049
  // ../node_modules/axios/lib/helpers/parseProtocol.js
13742
14050
  function parseProtocol(url2) {
@@ -13745,7 +14053,7 @@ function parseProtocol(url2) {
13745
14053
  }
13746
14054
 
13747
14055
  // ../node_modules/axios/lib/helpers/fromDataURI.js
13748
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
14056
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
13749
14057
  function fromDataURI(uri, asBlob, options) {
13750
14058
  const _Blob = options && options.Blob || platform_default.classes.Blob;
13751
14059
  const protocol = parseProtocol(uri);
@@ -13779,6 +14087,20 @@ function fromDataURI(uri, asBlob, options) {
13779
14087
  }
13780
14088
  throw new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_NOT_SUPPORT);
13781
14089
  }
14090
+
14091
+ // ../node_modules/axios/lib/core/setFormDataHeaders.js
14092
+ var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
14093
+ function setFormDataHeaders(headers, formHeaders, policy) {
14094
+ if (policy !== "content-only") {
14095
+ headers.set(formHeaders);
14096
+ return;
14097
+ }
14098
+ Object.entries(formHeaders || {}).forEach(([key, val]) => {
14099
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
14100
+ headers.set(key, val);
14101
+ }
14102
+ });
14103
+ }
13782
14104
  var kInternals = /* @__PURE__ */ Symbol("internals");
13783
14105
  var AxiosTransformStream = class extends stream3__default.default.Transform {
13784
14106
  constructor(options) {
@@ -14024,6 +14346,7 @@ var Http2Sessions = class {
14024
14346
  }
14025
14347
  getSession(authority, options) {
14026
14348
  options = Object.assign(
14349
+ /* @__PURE__ */ Object.create(null),
14027
14350
  {
14028
14351
  sessionTimeout: 1e3
14029
14352
  },
@@ -14089,6 +14412,7 @@ var Http2Sessions = class {
14089
14412
  };
14090
14413
  }
14091
14414
  session.once("close", removeSession);
14415
+ session.once("error", removeSession);
14092
14416
  let entry = [session, options];
14093
14417
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
14094
14418
  return session;
@@ -14113,12 +14437,73 @@ var callbackify_default = callbackify;
14113
14437
 
14114
14438
  // ../node_modules/axios/lib/helpers/shouldBypassProxy.js
14115
14439
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
14440
+ var trimTrailingDots = (value) => {
14441
+ let end = value.length;
14442
+ while (end && value.charCodeAt(end - 1) === 46) {
14443
+ end--;
14444
+ }
14445
+ return end === value.length ? value : value.slice(0, end);
14446
+ };
14116
14447
  var isIPv4Loopback = (host) => {
14117
14448
  const parts = host.split(".");
14118
14449
  if (parts.length !== 4) return false;
14119
14450
  if (parts[0] !== "127") return false;
14120
14451
  return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
14121
14452
  };
14453
+ var parseIPv4Octet = (text) => {
14454
+ if (/^0[xX][0-9a-fA-F]+$/.test(text)) {
14455
+ const n = parseInt(text.slice(2), 16);
14456
+ return Number.isFinite(n) ? n : null;
14457
+ }
14458
+ if (text.length > 1 && /^0[0-7]+$/.test(text)) {
14459
+ const n = parseInt(text, 8);
14460
+ return Number.isFinite(n) ? n : null;
14461
+ }
14462
+ if (text.length > 1 && /^0[0-9]+$/.test(text)) {
14463
+ return null;
14464
+ }
14465
+ if (/^[0-9]+$/.test(text)) {
14466
+ const n = parseInt(text, 10);
14467
+ return Number.isFinite(n) ? n : null;
14468
+ }
14469
+ return null;
14470
+ };
14471
+ var normalizeIPAddress = (host) => {
14472
+ if (typeof host !== "string" || !host || host.indexOf(":") !== -1) {
14473
+ return host;
14474
+ }
14475
+ let h = host;
14476
+ if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
14477
+ h = h.slice(1, -1);
14478
+ }
14479
+ h = trimTrailingDots(h);
14480
+ if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
14481
+ const parts = h.split(".");
14482
+ if (parts.some((p) => p === "")) return host;
14483
+ if (parts.length === 4) {
14484
+ const octets = parts.map(parseIPv4Octet);
14485
+ if (octets.some((n) => n === null || n < 0 || n > 255)) return host;
14486
+ return octets.join(".");
14487
+ }
14488
+ if (parts.length > 4) {
14489
+ return host;
14490
+ }
14491
+ if (parts.length === 1) return host;
14492
+ const literalOctets = parts.slice(0, -1);
14493
+ const tail = parts[parts.length - 1];
14494
+ const tailSlots = 4 - literalOctets.length;
14495
+ const tailValue = parseIPv4Octet(tail);
14496
+ if (tailValue === null) return host;
14497
+ const maxTail = (1 << 8 * tailSlots) - 1;
14498
+ if (tailValue < 0 || tailValue > maxTail) return host;
14499
+ const tailOctets = new Array(tailSlots).fill(0);
14500
+ for (let i = tailSlots - 1, v = tailValue; i >= 0; i--, v >>= 8) {
14501
+ tailOctets[i] = v & 255;
14502
+ }
14503
+ const literal = literalOctets.map(parseIPv4Octet);
14504
+ if (literal.some((n) => n === null || n < 0 || n > 255)) return host;
14505
+ return [...literal, ...tailOctets].join(".");
14506
+ };
14122
14507
  var isIPv6ZeroGroup = (group) => /^0{1,4}$/.test(group);
14123
14508
  var isIPv6Unspecified = (host) => {
14124
14509
  if (host === "::") return true;
@@ -14203,6 +14588,40 @@ var unmapIPv4MappedIPv6 = (host) => {
14203
14588
  }
14204
14589
  return host;
14205
14590
  };
14591
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
14592
+ var ipv4ToBytes = (host) => {
14593
+ const parts = host.split(".");
14594
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
14595
+ };
14596
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
14597
+ var ipv6ToBytes = (host) => {
14598
+ const halves = host.split("::");
14599
+ if (halves.length > 2) {
14600
+ return null;
14601
+ }
14602
+ const groups = halves[0] ? halves[0].split(":") : [];
14603
+ if (halves.length === 2) {
14604
+ const rear = halves[1] ? halves[1].split(":") : [];
14605
+ const missing = 8 - groups.length - rear.length;
14606
+ if (missing < 1) {
14607
+ return null;
14608
+ }
14609
+ groups.push(...new Array(missing).fill("0"), ...rear);
14610
+ }
14611
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
14612
+ return null;
14613
+ }
14614
+ return groups.flatMap((group) => {
14615
+ const value = Number.parseInt(group, 16);
14616
+ return [value >> 8 & 255, value & 255];
14617
+ });
14618
+ };
14619
+ var ipToBytes = (host) => {
14620
+ if (typeof host !== "string" || !host) {
14621
+ return null;
14622
+ }
14623
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
14624
+ };
14206
14625
  var normalizeNoProxyHost = (hostname) => {
14207
14626
  if (!hostname) {
14208
14627
  return hostname;
@@ -14210,7 +14629,89 @@ var normalizeNoProxyHost = (hostname) => {
14210
14629
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
14211
14630
  hostname = hostname.slice(1, -1);
14212
14631
  }
14213
- return unmapIPv4MappedIPv6(hostname.replace(/\.+$/, ""));
14632
+ const trimmed = trimTrailingDots(hostname);
14633
+ const ipv4 = normalizeIPAddress(trimmed);
14634
+ if (ipv4 !== trimmed) {
14635
+ return ipv4;
14636
+ }
14637
+ return unmapIPv4MappedIPv6(trimmed);
14638
+ };
14639
+ var normalizeCidrBase = (input) => {
14640
+ let base = input;
14641
+ const startsBracket = base.charAt(0) === "[";
14642
+ const endsBracket = base.charAt(base.length - 1) === "]";
14643
+ const hasBracket = base.includes("[") || base.includes("]");
14644
+ if (startsBracket || endsBracket) {
14645
+ if (!startsBracket || !endsBracket) {
14646
+ return null;
14647
+ }
14648
+ base = base.slice(1, -1);
14649
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
14650
+ return null;
14651
+ }
14652
+ } else if (hasBracket) {
14653
+ return null;
14654
+ }
14655
+ if (!base || base.charAt(base.length - 1) === ".") {
14656
+ return null;
14657
+ }
14658
+ const wasIPv6 = base.indexOf(":") !== -1;
14659
+ if (wasIPv6) {
14660
+ try {
14661
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
14662
+ } catch (_err) {
14663
+ return null;
14664
+ }
14665
+ } else {
14666
+ base = normalizeIPAddress(base);
14667
+ if (!ipv4ToBytes(base)) {
14668
+ return null;
14669
+ }
14670
+ }
14671
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
14672
+ };
14673
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
14674
+ var parseCidrEntry = (entry) => {
14675
+ if (entry.indexOf("/") === -1) {
14676
+ return void 0;
14677
+ }
14678
+ const match = CIDR_ENTRY_RE.exec(entry);
14679
+ if (!match) {
14680
+ return null;
14681
+ }
14682
+ let prefix = Number(match[2]);
14683
+ const parsedBase = normalizeCidrBase(match[1]);
14684
+ if (!parsedBase) {
14685
+ return null;
14686
+ }
14687
+ const { normalized, wasIPv6 } = parsedBase;
14688
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
14689
+ if (prefix < 96) {
14690
+ return null;
14691
+ }
14692
+ prefix -= 96;
14693
+ }
14694
+ const bytes = ipToBytes(normalized);
14695
+ if (!bytes || prefix > bytes.length * 8) {
14696
+ return null;
14697
+ }
14698
+ return { bytes, prefix };
14699
+ };
14700
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
14701
+ const fullBytes = prefix >> 3;
14702
+ for (let i = 0; i < fullBytes; i++) {
14703
+ if (addressBytes[i] !== networkBytes[i]) {
14704
+ return false;
14705
+ }
14706
+ }
14707
+ const remainingBits = prefix & 7;
14708
+ if (remainingBits) {
14709
+ const mask = 255 << 8 - remainingBits & 255;
14710
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
14711
+ return false;
14712
+ }
14713
+ }
14714
+ return true;
14214
14715
  };
14215
14716
  function shouldBypassProxy(location) {
14216
14717
  let parsed;
@@ -14228,10 +14729,18 @@ function shouldBypassProxy(location) {
14228
14729
  }
14229
14730
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
14230
14731
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
14732
+ const hostnameBytes = ipToBytes(hostname);
14231
14733
  return noProxy.split(/[\s,]+/).some((entry) => {
14232
14734
  if (!entry) {
14233
14735
  return false;
14234
14736
  }
14737
+ if (entry === "*") {
14738
+ return true;
14739
+ }
14740
+ const cidr = parseCidrEntry(entry);
14741
+ if (cidr !== void 0) {
14742
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
14743
+ }
14235
14744
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
14236
14745
  entryHost = normalizeNoProxyHost(entryHost);
14237
14746
  if (!entryHost) {
@@ -14317,7 +14826,8 @@ function throttle(fn, freq) {
14317
14826
  }
14318
14827
  };
14319
14828
  const flush = () => lastArgs && invoke(lastArgs);
14320
- return [throttled, flush];
14829
+ const flushWith = (...args) => invoke(args);
14830
+ return [throttled, flush, flushWith];
14321
14831
  }
14322
14832
  var throttle_default = throttle;
14323
14833
 
@@ -14326,12 +14836,12 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
14326
14836
  let bytesNotified = 0;
14327
14837
  const _speedometer = speedometer_default(50, 250);
14328
14838
  return throttle_default((e) => {
14329
- if (!e || typeof e.loaded !== "number") {
14839
+ if (!e || !utils_default.isNumber(e.loaded)) {
14330
14840
  return;
14331
14841
  }
14332
14842
  const rawLoaded = e.loaded;
14333
14843
  const total = e.lengthComputable ? e.total : void 0;
14334
- const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
14844
+ const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
14335
14845
  const progressBytes = Math.max(0, loaded - bytesNotified);
14336
14846
  const rate = _speedometer(progressBytes);
14337
14847
  bytesNotified = Math.max(bytesNotified, loaded);
@@ -14360,12 +14870,66 @@ var progressEventDecorator = (total, throttled) => {
14360
14870
  throttled[1]
14361
14871
  ];
14362
14872
  };
14363
- var asyncDecorator = (fn) => (...args) => utils_default.asap(() => fn(...args));
14873
+ var asyncDecorator = (fn, scheduler = utils_default.asap) => (...args) => scheduler(() => fn(...args));
14364
14874
 
14365
14875
  // ../node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js
14366
14876
  var isHexDigit = (charCode) => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
14367
14877
  var isPercentEncodedByte = (str, i, len) => i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
14368
- function estimateDataURLDecodedBytes(url2) {
14878
+ var hexValue = (charCode) => charCode <= 57 ? charCode - 48 : (charCode & 223) - 55;
14879
+ var isBase64Char = (charCode) => charCode >= 65 && charCode <= 90 || // A-Z
14880
+ charCode >= 97 && charCode <= 122 || // a-z
14881
+ charCode >= 48 && charCode <= 57 || // 0-9
14882
+ charCode === 43 || // +
14883
+ charCode === 47 || // /
14884
+ charCode === 45 || // - (base64url)
14885
+ charCode === 95;
14886
+ var isBase64Whitespace = (charCode) => charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
14887
+ var base64Bytes = (significant) => {
14888
+ const groups = Math.floor(significant / 4);
14889
+ const remainder = significant % 4;
14890
+ return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
14891
+ };
14892
+ var estimateBase64BufferAllocation = (body) => {
14893
+ const len = body.length;
14894
+ let padding = 0;
14895
+ if (len > 0 && body.charCodeAt(len - 1) === 61) {
14896
+ padding++;
14897
+ if (len > 1 && body.charCodeAt(len - 2) === 61) {
14898
+ padding++;
14899
+ }
14900
+ }
14901
+ return Math.floor((len - padding) * 3 / 4);
14902
+ };
14903
+ var estimatePercentDecodedBase64Bytes = (body) => {
14904
+ const len = body.length;
14905
+ let significant = 0;
14906
+ let padding = 0;
14907
+ let invalid = false;
14908
+ for (let i = 0; i < len; i++) {
14909
+ let code = body.charCodeAt(i);
14910
+ if (code === 37 && isPercentEncodedByte(body, i, len)) {
14911
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
14912
+ i += 2;
14913
+ }
14914
+ if (isBase64Whitespace(code)) {
14915
+ continue;
14916
+ }
14917
+ if (code === 61) {
14918
+ padding++;
14919
+ continue;
14920
+ }
14921
+ if (!isBase64Char(code) || padding > 0) {
14922
+ invalid = true;
14923
+ continue;
14924
+ }
14925
+ significant++;
14926
+ }
14927
+ if (invalid || padding > 2 || padding > 0 && (significant + padding) % 4 !== 0 || significant % 4 === 1) {
14928
+ return estimateBase64BufferAllocation(body);
14929
+ }
14930
+ return base64Bytes(significant);
14931
+ };
14932
+ var estimateDataURLBytes = (url2, estimateBase64) => {
14369
14933
  if (!url2 || typeof url2 !== "string") return 0;
14370
14934
  if (!url2.startsWith("data:")) return 0;
14371
14935
  const comma = url2.indexOf(",");
@@ -14374,43 +14938,7 @@ function estimateDataURLDecodedBytes(url2) {
14374
14938
  const body = url2.slice(comma + 1);
14375
14939
  const isBase64 = /;base64/i.test(meta);
14376
14940
  if (isBase64) {
14377
- let effectiveLen = body.length;
14378
- const len = body.length;
14379
- for (let i = 0; i < len; i++) {
14380
- if (body.charCodeAt(i) === 37 && i + 2 < len) {
14381
- const a = body.charCodeAt(i + 1);
14382
- const b = body.charCodeAt(i + 2);
14383
- const isHex = isHexDigit(a) && isHexDigit(b);
14384
- if (isHex) {
14385
- effectiveLen -= 2;
14386
- i += 2;
14387
- }
14388
- }
14389
- }
14390
- let pad = 0;
14391
- let idx = len - 1;
14392
- const tailIsPct3D = (j) => j >= 2 && body.charCodeAt(j - 2) === 37 && // '%'
14393
- body.charCodeAt(j - 1) === 51 && // '3'
14394
- (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
14395
- if (idx >= 0) {
14396
- if (body.charCodeAt(idx) === 61) {
14397
- pad++;
14398
- idx--;
14399
- } else if (tailIsPct3D(idx)) {
14400
- pad++;
14401
- idx -= 3;
14402
- }
14403
- }
14404
- if (pad === 1 && idx >= 0) {
14405
- if (body.charCodeAt(idx) === 61) {
14406
- pad++;
14407
- } else if (tailIsPct3D(idx)) {
14408
- pad++;
14409
- }
14410
- }
14411
- const groups = Math.floor(effectiveLen / 4);
14412
- const bytes2 = groups * 3 - (pad || 0);
14413
- return bytes2 > 0 ? bytes2 : 0;
14941
+ return estimateBase64(body);
14414
14942
  }
14415
14943
  let bytes = 0;
14416
14944
  for (let i = 0, len = body.length; i < len; i++) {
@@ -14435,6 +14963,16 @@ function estimateDataURLDecodedBytes(url2) {
14435
14963
  }
14436
14964
  }
14437
14965
  return bytes;
14966
+ };
14967
+ function estimateDataURLDecodedBytes(url2) {
14968
+ const fragmentIndex = typeof url2 === "string" ? url2.indexOf("#") : -1;
14969
+ return estimateDataURLBytes(
14970
+ fragmentIndex === -1 ? url2 : url2.slice(0, fragmentIndex),
14971
+ estimatePercentDecodedBase64Bytes
14972
+ );
14973
+ }
14974
+ function estimateDataURLBufferAllocation(url2) {
14975
+ return estimateDataURLBytes(url2, estimateBase64BufferAllocation);
14438
14976
  }
14439
14977
 
14440
14978
  // ../node_modules/axios/lib/adapters/http.js
@@ -14454,22 +14992,17 @@ var isBrotliSupported = utils_default.isFunction(zlib__default.default.createBro
14454
14992
  var isZstdSupported = utils_default.isFunction(zlib__default.default.createZstdDecompress);
14455
14993
  var ACCEPT_ENCODING = "gzip, compress, deflate" + (isBrotliSupported ? ", br" : "");
14456
14994
  var ACCEPT_ENCODING_WITH_ZSTD = ACCEPT_ENCODING + (isZstdSupported ? ", zstd" : "");
14995
+ var scheduleProgress = typeof process !== "undefined" && process.nextTick ? process.nextTick.bind(process) : utils_default.asap;
14457
14996
  var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
14458
14997
  var isHttps = /https:?/;
14459
- var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
14460
- function setFormDataHeaders(headers, formHeaders, policy) {
14461
- if (policy !== "content-only") {
14462
- headers.set(formHeaders);
14463
- return;
14464
- }
14465
- Object.entries(formHeaders).forEach(([key, val]) => {
14466
- if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
14467
- headers.set(key, val);
14468
- }
14469
- });
14470
- }
14471
14998
  var kAxiosSocketListener = /* @__PURE__ */ Symbol("axios.http.socketListener");
14472
14999
  var kAxiosCurrentReq = /* @__PURE__ */ Symbol("axios.http.currentReq");
15000
+ function handleSocketError(err) {
15001
+ const current = this[kAxiosCurrentReq];
15002
+ if (current && !current.destroyed) {
15003
+ current.destroy(err);
15004
+ }
15005
+ }
14473
15006
  var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
14474
15007
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
14475
15008
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -14572,10 +15105,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
14572
15105
  return false;
14573
15106
  }
14574
15107
  }
14575
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
15108
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
14576
15109
  let proxy = configProxy;
14577
15110
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
14578
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
15111
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
14579
15112
  const proxyUrl = getProxyForUrl(location);
14580
15113
  if (proxyUrl) {
14581
15114
  if (!shouldBypassProxy(location)) {
@@ -14672,9 +15205,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
14672
15205
  redirectOptions.href,
14673
15206
  true,
14674
15207
  configHttpsAgent,
14675
- configHttpAgent
15208
+ configHttpAgent,
15209
+ allowEnvProxy
14676
15210
  );
14677
15211
  };
15212
+ return Boolean(
15213
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
15214
+ );
14678
15215
  }
14679
15216
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
14680
15217
  var wrapAsync = (asyncExecutor) => {
@@ -14699,7 +15236,7 @@ var wrapAsync = (asyncExecutor) => {
14699
15236
  };
14700
15237
  var resolveFamily = ({ address, family }) => {
14701
15238
  if (!utils_default.isString(address)) {
14702
- throw TypeError("address must be a string");
15239
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
14703
15240
  }
14704
15241
  return {
14705
15242
  address,
@@ -14707,6 +15244,30 @@ var resolveFamily = ({ address, family }) => {
14707
15244
  };
14708
15245
  };
14709
15246
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
15247
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
15248
+ var normalizeLookup = (lookup) => {
15249
+ let normalized = normalizedLookupCache.get(lookup);
15250
+ if (normalized) {
15251
+ return normalized;
15252
+ }
15253
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
15254
+ normalized = (hostname, opt, cb) => {
15255
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
15256
+ if (err) {
15257
+ return cb(err);
15258
+ }
15259
+ let addresses;
15260
+ try {
15261
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
15262
+ } catch (error) {
15263
+ return cb(error);
15264
+ }
15265
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
15266
+ });
15267
+ };
15268
+ normalizedLookupCache.set(lookup, normalized);
15269
+ return normalized;
15270
+ };
14710
15271
  var http2Transport = {
14711
15272
  request(options, cb) {
14712
15273
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -14743,6 +15304,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
14743
15304
  let family = own2("family");
14744
15305
  let httpVersion = own2("httpVersion");
14745
15306
  if (httpVersion === void 0) httpVersion = 1;
15307
+ const rawHttpVersion = httpVersion;
14746
15308
  let http2Options = own2("http2Options");
14747
15309
  const httpAgent = own2("httpAgent");
14748
15310
  const httpsAgent = own2("httpsAgent");
@@ -14759,25 +15321,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
14759
15321
  let rejected = false;
14760
15322
  let req;
14761
15323
  let connectPhaseTimer;
14762
- httpVersion = +httpVersion;
15324
+ try {
15325
+ httpVersion = +httpVersion;
15326
+ } catch (err) {
15327
+ throw new AxiosError_default(
15328
+ "Invalid protocol version: value is not a number",
15329
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
15330
+ config
15331
+ );
15332
+ }
14763
15333
  if (Number.isNaN(httpVersion)) {
14764
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
15334
+ throw new AxiosError_default(
15335
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
15336
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
15337
+ config
15338
+ );
14765
15339
  }
14766
15340
  if (httpVersion !== 1 && httpVersion !== 2) {
14767
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
15341
+ throw new AxiosError_default(
15342
+ `Unsupported protocol version '${httpVersion}'`,
15343
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
15344
+ config
15345
+ );
14768
15346
  }
14769
15347
  const isHttp2 = httpVersion === 2;
14770
15348
  if (lookup) {
14771
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
14772
- lookup = (hostname, opt, cb) => {
14773
- _lookup(hostname, opt, (err, arg0, arg1) => {
14774
- if (err) {
14775
- return cb(err);
14776
- }
14777
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
14778
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
14779
- });
14780
- };
15349
+ lookup = normalizeLookup(lookup);
14781
15350
  }
14782
15351
  const abortEmitter = new events.EventEmitter();
14783
15352
  function abort(reason) {
@@ -14851,7 +15420,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
14851
15420
  if (protocol === "data:") {
14852
15421
  if (maxContentLength > -1) {
14853
15422
  const dataUrl = String(own2("url") || fullPath || "");
14854
- const estimated = estimateDataURLDecodedBytes(dataUrl);
15423
+ const estimated = estimateDataURLBufferAllocation(dataUrl);
14855
15424
  if (estimated > maxContentLength) {
14856
15425
  return reject(
14857
15426
  new AxiosError_default(
@@ -14981,7 +15550,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
14981
15550
  data,
14982
15551
  progressEventDecorator(
14983
15552
  contentLength,
14984
- progressEventReducer(asyncDecorator(onUploadProgress), false, 3)
15553
+ progressEventReducer(asyncDecorator(onUploadProgress, scheduleProgress), false, 3)
14985
15554
  )
14986
15555
  )
14987
15556
  );
@@ -15019,6 +15588,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15019
15588
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
15020
15589
  false
15021
15590
  );
15591
+ if (isHttp2 && lookup) {
15592
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
15593
+ }
15022
15594
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
15023
15595
  path: path$1,
15024
15596
  method,
@@ -15029,9 +15601,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15029
15601
  family,
15030
15602
  beforeRedirect: dispatchBeforeRedirect,
15031
15603
  beforeRedirects: /* @__PURE__ */ Object.create(null),
15032
- http2Options
15604
+ http2Options,
15605
+ createConnection: void 0
15033
15606
  });
15034
15607
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
15608
+ let proxyApplied = false;
15035
15609
  if (socketPath) {
15036
15610
  if (typeof socketPath !== "string") {
15037
15611
  return reject(
@@ -15059,13 +15633,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15059
15633
  } else {
15060
15634
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
15061
15635
  options.port = parsed.port;
15062
- setProxy(
15636
+ proxyApplied = setProxy(
15063
15637
  options,
15064
15638
  configProxy,
15065
15639
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
15066
15640
  false,
15067
15641
  httpsAgent,
15068
- httpAgent
15642
+ httpAgent,
15643
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
15644
+ // cannot apply either axios-resolved or agent-local environment proxies.
15645
+ // Explicit proxy config is still processed and rejected below.
15646
+ !isHttp2
15069
15647
  );
15070
15648
  }
15071
15649
  let transport;
@@ -15076,6 +15654,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15076
15654
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
15077
15655
  }
15078
15656
  if (isHttp2) {
15657
+ if (proxyApplied) {
15658
+ return reject(
15659
+ new AxiosError_default(
15660
+ "HTTP/2 requests with a proxy are not supported",
15661
+ AxiosError_default.ERR_NOT_SUPPORT,
15662
+ config
15663
+ )
15664
+ );
15665
+ }
15079
15666
  transport = http2Transport;
15080
15667
  } else {
15081
15668
  const configTransport = own2("transport");
@@ -15163,7 +15750,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15163
15750
  transformStream,
15164
15751
  progressEventDecorator(
15165
15752
  responseLength,
15166
- progressEventReducer(asyncDecorator(onDownloadProgress), true, 3)
15753
+ progressEventReducer(
15754
+ asyncDecorator(onDownloadProgress, scheduleProgress),
15755
+ true,
15756
+ 3
15757
+ )
15167
15758
  )
15168
15759
  )
15169
15760
  );
@@ -15312,12 +15903,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15312
15903
  socket.setKeepAlive(true, 1e3 * 60);
15313
15904
  }
15314
15905
  if (!socket[kAxiosSocketListener]) {
15315
- socket.on("error", function handleSocketError(err) {
15316
- const current = socket[kAxiosCurrentReq];
15317
- if (current && !current.destroyed) {
15318
- current.destroy(err);
15319
- }
15320
- });
15906
+ socket.on("error", handleSocketError);
15321
15907
  socket[kAxiosSocketListener] = true;
15322
15908
  }
15323
15909
  socket[kAxiosCurrentReq] = req;
@@ -15477,6 +16063,16 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
15477
16063
 
15478
16064
  // ../node_modules/axios/lib/core/mergeConfig.js
15479
16065
  var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
16066
+ var ownEnumerableKeys = (thing) => {
16067
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
16068
+ return Object.keys(thing).concat(
16069
+ Object.getOwnPropertySymbols(thing).filter(
16070
+ (symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
16071
+ )
16072
+ );
16073
+ }
16074
+ return Object.keys(thing);
16075
+ };
15480
16076
  function mergeConfig(config1, config2) {
15481
16077
  config1 = config1 || {};
15482
16078
  config2 = config2 || {};
@@ -15552,7 +16148,7 @@ function mergeConfig(config1, config2) {
15552
16148
  transformResponse: defaultToConfig2,
15553
16149
  paramsSerializer: defaultToConfig2,
15554
16150
  timeout: defaultToConfig2,
15555
- timeoutMessage: defaultToConfig2,
16151
+ timeoutErrorMessage: defaultToConfig2,
15556
16152
  withCredentials: defaultToConfig2,
15557
16153
  withXSRFToken: defaultToConfig2,
15558
16154
  adapter: defaultToConfig2,
@@ -15575,7 +16171,7 @@ function mergeConfig(config1, config2) {
15575
16171
  validateStatus: mergeDirectKeys,
15576
16172
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
15577
16173
  };
15578
- utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
16174
+ utils_default.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
15579
16175
  if (prop === "__proto__" || prop === "constructor" || prop === "prototype") return;
15580
16176
  const merge2 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
15581
16177
  const a = utils_default.hasOwnProp(config1, prop) ? config1[prop] : void 0;
@@ -15594,18 +16190,6 @@ function mergeConfig(config1, config2) {
15594
16190
  }
15595
16191
 
15596
16192
  // ../node_modules/axios/lib/helpers/resolveConfig.js
15597
- var FORM_DATA_CONTENT_HEADERS2 = ["content-type", "content-length"];
15598
- function setFormDataHeaders2(headers, formHeaders, policy) {
15599
- if (policy !== "content-only") {
15600
- headers.set(formHeaders);
15601
- return;
15602
- }
15603
- Object.entries(formHeaders || {}).forEach(([key, val]) => {
15604
- if (FORM_DATA_CONTENT_HEADERS2.includes(key.toLowerCase())) {
15605
- headers.set(key, val);
15606
- }
15607
- });
15608
- }
15609
16193
  var encodeUTF8 = (str) => encodeURIComponent(str).replace(
15610
16194
  /%([0-9A-F]{2})/gi,
15611
16195
  (_, hex) => String.fromCharCode(parseInt(hex, 16))
@@ -15641,10 +16225,11 @@ function resolveConfig(config) {
15641
16225
  }
15642
16226
  }
15643
16227
  if (utils_default.isFormData(data)) {
16228
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
15644
16229
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
15645
16230
  headers.setContentType(void 0);
15646
- } else if (utils_default.isFunction(data.getHeaders)) {
15647
- setFormDataHeaders2(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
16231
+ } else if (utils_default.isFunction(getHeaders)) {
16232
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
15648
16233
  }
15649
16234
  }
15650
16235
  if (platform_default.hasStandardBrowserEnv) {
@@ -15673,7 +16258,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
15673
16258
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
15674
16259
  let onCanceled;
15675
16260
  let uploadThrottled, downloadThrottled;
15676
- let flushUpload, flushDownload;
16261
+ let flushUpload, flushDownload, flushDownloadWithEvent;
15677
16262
  function done() {
15678
16263
  flushUpload && flushUpload();
15679
16264
  flushDownload && flushDownload();
@@ -15683,7 +16268,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
15683
16268
  let request = new XMLHttpRequest();
15684
16269
  request.open(_config.method.toUpperCase(), _config.url, true);
15685
16270
  request.timeout = _config.timeout;
15686
- function onloadend() {
16271
+ function onloadend(event) {
16272
+ if (!request) {
16273
+ return;
16274
+ }
16275
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
16276
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
16277
+ done();
16278
+ request = null;
16279
+ return;
16280
+ }
16281
+ try {
16282
+ if (event) {
16283
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
16284
+ } else {
16285
+ flushDownload && flushDownload();
16286
+ }
16287
+ } catch (err) {
16288
+ setTimeout(() => {
16289
+ throw err;
16290
+ });
16291
+ }
15687
16292
  if (!request) {
15688
16293
  return;
15689
16294
  }
@@ -15771,7 +16376,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
15771
16376
  request.responseType = _config.responseType;
15772
16377
  }
15773
16378
  if (onDownloadProgress) {
15774
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
16379
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
16380
+ onDownloadProgress,
16381
+ true
16382
+ );
15775
16383
  request.addEventListener("progress", downloadThrottled);
15776
16384
  }
15777
16385
  if (onUploadProgress && request.upload) {
@@ -15843,7 +16451,16 @@ var composeSignals = (signals, timeout) => {
15843
16451
  });
15844
16452
  signals = null;
15845
16453
  };
15846
- signals.forEach((signal2) => signal2.addEventListener("abort", onabort, { once: true }));
16454
+ signals.forEach((signal2) => {
16455
+ if (aborted) {
16456
+ return;
16457
+ }
16458
+ if (signal2.aborted) {
16459
+ onabort.call(signal2);
16460
+ return;
16461
+ }
16462
+ signal2.addEventListener("abort", onabort, { once: true });
16463
+ });
15847
16464
  const { signal } = controller;
15848
16465
  signal.unsubscribe = () => utils_default.asap(unsubscribe);
15849
16466
  return signal;
@@ -15932,6 +16549,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
15932
16549
 
15933
16550
  // ../node_modules/axios/lib/adapters/fetch.js
15934
16551
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
16552
+ var DEFAULT_REQUEST_OPTIONS = {
16553
+ cache: "default",
16554
+ redirect: "follow",
16555
+ referrer: "about:client",
16556
+ referrerPolicy: "",
16557
+ mode: "cors",
16558
+ integrity: "",
16559
+ keepalive: false,
16560
+ priority: "auto",
16561
+ window: null
16562
+ };
15935
16563
  var { isFunction: isFunction2 } = utils_default;
15936
16564
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
15937
16565
  /%([0-9A-F]{2})/gi,
@@ -16062,7 +16690,8 @@ var factory = (env) => {
16062
16690
  withCredentials = "same-origin",
16063
16691
  fetchOptions,
16064
16692
  maxContentLength,
16065
- maxBodyLength
16693
+ maxBodyLength,
16694
+ maxRedirects
16066
16695
  } = resolveConfig_default(config);
16067
16696
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
16068
16697
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -16192,17 +16821,44 @@ var factory = (env) => {
16192
16821
  }
16193
16822
  }
16194
16823
  headers.set("User-Agent", "axios/" + VERSION, false);
16195
- const resolvedOptions = {
16196
- ...fetchOptions,
16824
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
16825
+ if (safeFetchOptions) {
16826
+ delete safeFetchOptions.body;
16827
+ delete safeFetchOptions.headers;
16828
+ delete safeFetchOptions.method;
16829
+ delete safeFetchOptions.signal;
16830
+ delete safeFetchOptions.duplex;
16831
+ delete safeFetchOptions.credentials;
16832
+ }
16833
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
16197
16834
  signal: composedSignal,
16198
16835
  method: method.toUpperCase(),
16199
16836
  headers: toByteStringHeaderObject(headers.normalize()),
16200
16837
  body: data,
16201
16838
  duplex: "half",
16202
16839
  credentials: isCredentialsSupported ? withCredentials : void 0
16203
- };
16840
+ });
16841
+ if (isRequestSupported) {
16842
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
16843
+ if (resolvedOptions[key] === void 0) {
16844
+ resolvedOptions[key] = value;
16845
+ }
16846
+ });
16847
+ if (resolvedOptions.signal === void 0) {
16848
+ resolvedOptions.signal = null;
16849
+ }
16850
+ if (resolvedOptions.body === void 0) {
16851
+ resolvedOptions.body = null;
16852
+ }
16853
+ }
16854
+ if (maxRedirects === 0) {
16855
+ resolvedOptions.redirect = "manual";
16856
+ if (safeFetchOptions) {
16857
+ safeFetchOptions.redirect = "manual";
16858
+ }
16859
+ }
16204
16860
  request = isRequestSupported && new Request(url2, resolvedOptions);
16205
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
16861
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
16206
16862
  const responseHeaders = AxiosHeaders_default.from(response.headers);
16207
16863
  if (hasMaxContentLength) {
16208
16864
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -16421,9 +17077,10 @@ function throwIfCancellationRequested(config) {
16421
17077
  throw new CanceledError_default(null, config);
16422
17078
  }
16423
17079
  }
16424
- function dispatchRequest(config) {
17080
+ function dispatchRequest(_config) {
17081
+ const config = utils_default.toSafeFlatObject(_config);
16425
17082
  throwIfCancellationRequested(config);
16426
- config.headers = AxiosHeaders_default.from(config.headers);
17083
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
16427
17084
  config.data = transformData.call(config, config.transformRequest);
16428
17085
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
16429
17086
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -16553,16 +17210,15 @@ var Axios = class {
16553
17210
  return await this._request(configOrUrl, config);
16554
17211
  } catch (err) {
16555
17212
  if (err instanceof Error) {
16556
- let dummy = {};
16557
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
16558
- const stack = (() => {
16559
- if (!dummy.stack) {
16560
- return "";
16561
- }
16562
- const firstNewlineIndex = dummy.stack.indexOf("\n");
16563
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
16564
- })();
16565
17213
  try {
17214
+ let dummy = {};
17215
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
17216
+ const dummyStack = dummy.stack;
17217
+ let stack = "";
17218
+ if (typeof dummyStack === "string") {
17219
+ const firstNewlineIndex = dummyStack.indexOf("\n");
17220
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
17221
+ }
16566
17222
  if (!err.stack) {
16567
17223
  err.stack = stack;
16568
17224
  } else if (stack) {
@@ -16631,9 +17287,9 @@ var Axios = class {
16631
17287
  },
16632
17288
  true
16633
17289
  );
16634
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
17290
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
16635
17291
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
16636
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
17292
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
16637
17293
  delete headers[method];
16638
17294
  });
16639
17295
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -16676,16 +17332,31 @@ var Axios = class {
16676
17332
  const onFulfilled = requestInterceptorChain[i++];
16677
17333
  const onRejected = requestInterceptorChain[i++];
16678
17334
  try {
16679
- newConfig = onFulfilled(newConfig);
17335
+ newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
16680
17336
  } catch (error) {
16681
- onRejected.call(this, error);
17337
+ if (!onRejected) {
17338
+ promise = Promise.reject(error);
17339
+ break;
17340
+ }
17341
+ try {
17342
+ const rejectedResult = onRejected.call(this, error);
17343
+ if (utils_default.isThenable(rejectedResult)) {
17344
+ promise = Promise.resolve(rejectedResult).then(
17345
+ () => dispatchRequest.call(this, newConfig)
17346
+ );
17347
+ }
17348
+ } catch (rejectedError) {
17349
+ promise = Promise.reject(rejectedError);
17350
+ }
16682
17351
  break;
16683
17352
  }
16684
17353
  }
16685
- try {
16686
- promise = dispatchRequest.call(this, newConfig);
16687
- } catch (error) {
16688
- return Promise.reject(error);
17354
+ if (!promise) {
17355
+ try {
17356
+ promise = dispatchRequest.call(this, newConfig);
17357
+ } catch (error) {
17358
+ promise = Promise.reject(error);
17359
+ }
16689
17360
  }
16690
17361
  i = 0;
16691
17362
  len = responseInterceptorChain.length;
@@ -16881,14 +17552,22 @@ var HttpStatusCode = {
16881
17552
  Gone: 410,
16882
17553
  LengthRequired: 411,
16883
17554
  PreconditionFailed: 412,
17555
+ /**
17556
+ * @deprecated Use `ContentTooLarge` instead.
17557
+ */
16884
17558
  PayloadTooLarge: 413,
17559
+ ContentTooLarge: 413,
16885
17560
  UriTooLong: 414,
16886
17561
  UnsupportedMediaType: 415,
16887
17562
  RangeNotSatisfiable: 416,
16888
17563
  ExpectationFailed: 417,
16889
17564
  ImATeapot: 418,
16890
17565
  MisdirectedRequest: 421,
17566
+ /**
17567
+ * @deprecated Use `UnprocessableContent` instead.
17568
+ */
16891
17569
  UnprocessableEntity: 422,
17570
+ UnprocessableContent: 422,
16892
17571
  Locked: 423,
16893
17572
  FailedDependency: 424,
16894
17573
  TooEarly: 425,
@@ -16908,6 +17587,7 @@ var HttpStatusCode = {
16908
17587
  LoopDetected: 508,
16909
17588
  NotExtended: 510,
16910
17589
  NetworkAuthenticationRequired: 511,
17590
+ WebServerReturnsAnUnknownError: 520,
16911
17591
  WebServerIsDown: 521,
16912
17592
  ConnectionTimedOut: 522,
16913
17593
  OriginIsUnreachable: 523,
@@ -16916,7 +17596,9 @@ var HttpStatusCode = {
16916
17596
  InvalidSslCertificate: 526
16917
17597
  };
16918
17598
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
16919
- HttpStatusCode[value] = key;
17599
+ if (HttpStatusCode[value] === void 0) {
17600
+ HttpStatusCode[value] = key;
17601
+ }
16920
17602
  });
16921
17603
  var HttpStatusCode_default = HttpStatusCode;
16922
17604
 
@@ -17257,6 +17939,16 @@ function transformError(error) {
17257
17939
  }
17258
17940
  return new Posty5Error("An unknown error occurred", void 0, void 0, { originalError: error });
17259
17941
  }
17942
+ function parseFileName(disposition) {
17943
+ if (!disposition) return void 0;
17944
+ const match = /filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(disposition);
17945
+ if (!match) return void 0;
17946
+ try {
17947
+ return decodeURIComponent(match[1]);
17948
+ } catch {
17949
+ return match[1];
17950
+ }
17951
+ }
17260
17952
  var HttpClient = class {
17261
17953
  constructor(config = {}) {
17262
17954
  this.config = {
@@ -17399,6 +18091,28 @@ var HttpClient = class {
17399
18091
  throw transformError(error);
17400
18092
  }
17401
18093
  }
18094
+ /**
18095
+ * Make a GET request for a file download.
18096
+ *
18097
+ * Separate from `get` rather than a flag on it: a download answers with the
18098
+ * file itself, not with the `{ message, result }` envelope every other
18099
+ * endpoint uses, so it cannot share the return type.
18100
+ */
18101
+ async getBinary(url2, config) {
18102
+ try {
18103
+ const response = await this.axiosInstance.get(url2, {
18104
+ ...this.buildConfig(config),
18105
+ responseType: "arraybuffer"
18106
+ });
18107
+ return {
18108
+ data: response.data,
18109
+ contentType: String(response.headers?.["content-type"] || "application/octet-stream"),
18110
+ fileName: parseFileName(response.headers?.["content-disposition"])
18111
+ };
18112
+ } catch (error) {
18113
+ throw transformError(error);
18114
+ }
18115
+ }
17402
18116
  /**
17403
18117
  * Build axios config from request config
17404
18118
  */
@@ -17473,6 +18187,169 @@ async function uploadToR2(presignedUrl, fileOrBlob, options = {}) {
17473
18187
  }
17474
18188
  }
17475
18189
 
18190
+ // src/resumable-upload.ts
18191
+ var TUS_VERSION = "1.0.0";
18192
+ var DEFAULT_CHUNK_SIZE2 = 8 * 1024 * 1024;
18193
+ var RETRY_DELAYS = [0, 1e3, 3e3, 5e3, 1e4];
18194
+ var MAX_CONSECUTIVE_STALLS = 3;
18195
+ function encodeMetadata(pairs) {
18196
+ return Object.entries(pairs).filter(([, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key} ${toBase64(value)}`).join(",");
18197
+ }
18198
+ function toBase64(value) {
18199
+ if (typeof btoa === "function") {
18200
+ return btoa(String.fromCharCode(...new TextEncoder().encode(value)));
18201
+ }
18202
+ return Buffer.from(value, "utf8").toString("base64");
18203
+ }
18204
+ var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18205
+ function isAborted(signal) {
18206
+ return !!signal?.aborted;
18207
+ }
18208
+ function abortError() {
18209
+ const error = new Error("Upload aborted");
18210
+ error.name = "AbortError";
18211
+ return error;
18212
+ }
18213
+ function supportsResumableUpload(target) {
18214
+ return !!target.tusEndpoint && !!target.ticket;
18215
+ }
18216
+ async function createUpload(target, size, filename, filetype, signal) {
18217
+ const response = await fetch(target.tusEndpoint, {
18218
+ method: "POST",
18219
+ headers: {
18220
+ "Tus-Resumable": TUS_VERSION,
18221
+ "Upload-Length": String(size),
18222
+ "Upload-Metadata": encodeMetadata({ ticket: target.ticket, filename, filetype })
18223
+ },
18224
+ signal
18225
+ });
18226
+ if (response.status !== 201) {
18227
+ throw new Error(`Could not start the upload (${response.status}): ${await safeText(response)}`);
18228
+ }
18229
+ const location = response.headers.get("Location");
18230
+ if (!location) {
18231
+ throw new Error("Upload was created but the server returned no Location header.");
18232
+ }
18233
+ return new URL(location, target.tusEndpoint).toString();
18234
+ }
18235
+ async function getOffset(uploadUrl, signal) {
18236
+ const response = await fetch(uploadUrl, {
18237
+ method: "HEAD",
18238
+ headers: { "Tus-Resumable": TUS_VERSION },
18239
+ signal
18240
+ });
18241
+ if (response.status === 404 || response.status === 410) {
18242
+ throw new Error("This upload has expired on the server and cannot be resumed.");
18243
+ }
18244
+ if (!response.ok) {
18245
+ throw new Error(`Could not read the upload's progress (${response.status}).`);
18246
+ }
18247
+ return Number(response.headers.get("Upload-Offset") ?? 0);
18248
+ }
18249
+ async function terminateUpload(uploadUrl) {
18250
+ try {
18251
+ const response = await fetch(uploadUrl, {
18252
+ method: "DELETE",
18253
+ headers: { "Tus-Resumable": TUS_VERSION }
18254
+ });
18255
+ return response.status === 204 || response.status === 404 || response.status === 410;
18256
+ } catch {
18257
+ return false;
18258
+ }
18259
+ }
18260
+ async function safeText(response) {
18261
+ try {
18262
+ return (await response.text()).slice(0, 300);
18263
+ } catch {
18264
+ return "";
18265
+ }
18266
+ }
18267
+ async function patchChunk(uploadUrl, chunk, offset, signal) {
18268
+ let lastError;
18269
+ for (let attempt = 0; attempt < RETRY_DELAYS.length; attempt++) {
18270
+ if (isAborted(signal)) throw abortError();
18271
+ if (RETRY_DELAYS[attempt]) await wait(RETRY_DELAYS[attempt]);
18272
+ try {
18273
+ const response = await fetch(uploadUrl, {
18274
+ method: "PATCH",
18275
+ headers: {
18276
+ "Tus-Resumable": TUS_VERSION,
18277
+ "Upload-Offset": String(offset),
18278
+ "Content-Type": "application/offset+octet-stream"
18279
+ },
18280
+ body: chunk,
18281
+ signal
18282
+ });
18283
+ if (response.status === 204) {
18284
+ return Number(response.headers.get("Upload-Offset") ?? offset + chunk.size);
18285
+ }
18286
+ if (response.status === 409) {
18287
+ return await getOffset(uploadUrl, signal);
18288
+ }
18289
+ if (response.status >= 400 && response.status < 500) {
18290
+ throw new Error(`Upload rejected (${response.status}): ${await safeText(response)}`);
18291
+ }
18292
+ lastError = new Error(`Upload failed (${response.status})`);
18293
+ } catch (error) {
18294
+ if (error?.name === "AbortError") throw error;
18295
+ if (/^Upload rejected/.test(error?.message || "")) throw error;
18296
+ lastError = error;
18297
+ }
18298
+ }
18299
+ throw lastError instanceof Error ? lastError : new Error("Upload failed");
18300
+ }
18301
+ async function uploadResumable(target, file, options = {}) {
18302
+ const { onProgress, onUploadUrl, chunkSize = DEFAULT_CHUNK_SIZE2, signal, fallbackType = "application/octet-stream", terminateOnAbort = false } = options;
18303
+ if (!supportsResumableUpload(target)) {
18304
+ throw new Error("This upload target does not support resumable uploads.");
18305
+ }
18306
+ if (target.maxSize && file.size > target.maxSize) {
18307
+ const limitMb = Math.round(target.maxSize / (1024 * 1024));
18308
+ throw new Error(`This file is larger than the ${limitMb}MB limit.`);
18309
+ }
18310
+ if (isAborted(signal)) throw abortError();
18311
+ const filename = file.name || "upload";
18312
+ const filetype = file.type || fallbackType;
18313
+ let uploadUrl = options.uploadUrl;
18314
+ let offset = 0;
18315
+ if (uploadUrl) {
18316
+ offset = await getOffset(uploadUrl, signal);
18317
+ } else {
18318
+ uploadUrl = await createUpload(target, file.size, filename, filetype, signal);
18319
+ onUploadUrl?.(uploadUrl);
18320
+ }
18321
+ const discardIfAsked = async () => {
18322
+ if (terminateOnAbort && uploadUrl) await terminateUpload(uploadUrl);
18323
+ };
18324
+ onProgress?.(file.size ? Math.round(offset / file.size * 100) : 0);
18325
+ let consecutiveStalls = 0;
18326
+ while (offset < file.size) {
18327
+ if (isAborted(signal)) {
18328
+ await discardIfAsked();
18329
+ throw abortError();
18330
+ }
18331
+ const end = Math.min(offset + chunkSize, file.size);
18332
+ let next;
18333
+ try {
18334
+ next = await patchChunk(uploadUrl, file.slice(offset, end), offset, signal);
18335
+ } catch (error) {
18336
+ if (error?.name === "AbortError") await discardIfAsked();
18337
+ throw error;
18338
+ }
18339
+ if (next <= offset) {
18340
+ if (++consecutiveStalls >= MAX_CONSECUTIVE_STALLS) {
18341
+ throw new Error("The upload stopped making progress and was abandoned.");
18342
+ }
18343
+ continue;
18344
+ }
18345
+ consecutiveStalls = 0;
18346
+ offset = next;
18347
+ onProgress?.(Math.round(offset / file.size * 100));
18348
+ }
18349
+ onProgress?.(100);
18350
+ return target.fileURL;
18351
+ }
18352
+
17476
18353
  // src/social-publisher-post.client.ts
17477
18354
  var SocialPublisherPostClient = class {
17478
18355
  constructor(http3) {
@@ -17518,6 +18395,29 @@ var SocialPublisherPostClient = class {
17518
18395
  const response = await this.http.post(`${this.basePath}/generate-upload-urls`, data);
17519
18396
  return response.result;
17520
18397
  }
18398
+ /**
18399
+ * Remove (delete) a post's published media directly from the connected
18400
+ * platform pages. Runs synchronously on the server — the media is deleted
18401
+ * from the platform immediately, not via a background job.
18402
+ *
18403
+ * Cost: 50 credits, charged ONLY when the removal succeeds (at least one
18404
+ * platform cleared and no delete-capable platform failed). Instagram and
18405
+ * TikTok expose no delete API, so a post published only to those platforms
18406
+ * cannot be removed programmatically and no credits are charged.
18407
+ *
18408
+ * @param id - Post ID
18409
+ * @returns Per-platform removal results
18410
+ *
18411
+ * @example
18412
+ * ```ts
18413
+ * const { results } = await client.removePost("post_123");
18414
+ * // results.youtube?.success === true
18415
+ * ```
18416
+ */
18417
+ async removePost(id) {
18418
+ const response = await this.http.post(`${this.basePath}/${id}/remove`, {});
18419
+ return response.result;
18420
+ }
17521
18421
  /**
17522
18422
  * Get next and previous post IDs
17523
18423
  * @param id - Current Post ID
@@ -17863,6 +18763,260 @@ var SocialPublisherPostClient = class {
17863
18763
  async publishShortVideo(options) {
17864
18764
  return this.publishShortVideoToWorkspace(options);
17865
18765
  }
18766
+ // ─── Long video (up to 60 minutes) ───────────────────────────────────────
18767
+ /**
18768
+ * Price a long video before publishing it. Neither creates nor charges
18769
+ * anything.
18770
+ *
18771
+ * The server reads the video, measures its duration, and returns the exact
18772
+ * cost plus what each platform would do with a video that long. Show this
18773
+ * before the user commits — the units come from the same function the create
18774
+ * call charges with, so the quote and the bill cannot disagree.
18775
+ *
18776
+ * @param videoURL - URL of an uploaded or externally hosted video
18777
+ *
18778
+ * @example
18779
+ * ```ts
18780
+ * const quote = await client.getLongVideoQuote(fileURL);
18781
+ * if (!quote.withinLimit) throw new Error(quote.reason);
18782
+ * console.log(`${quote.durationSeconds}s costs ${quote.credits} credits`);
18783
+ * const blocked = quote.platforms.filter((p) => !p.accepted);
18784
+ * ```
18785
+ */
18786
+ async getLongVideoQuote(videoURL) {
18787
+ if (!videoURL) {
18788
+ throw new Error("videoURL is required");
18789
+ }
18790
+ const response = await this.http.post(`${this.basePath}/long-video/quote`, { videoURL });
18791
+ return response.result;
18792
+ }
18793
+ /**
18794
+ * Publish a video of up to 60 minutes to every account connected to a
18795
+ * workspace.
18796
+ *
18797
+ * Handles the whole sequence for an uploaded file: request an upload
18798
+ * destination, push the bytes, then create the post. Pass a URL instead of a
18799
+ * `File` to publish something already hosted elsewhere.
18800
+ *
18801
+ * Cost is duration-based — 50 credits per started 5 minutes — so a 12-minute
18802
+ * video costs 150. Call {@link getLongVideoQuote} first if you need to show
18803
+ * the price. The duration is measured server-side; there is no duration
18804
+ * option here because a client-supplied one would be a client-supplied price.
18805
+ *
18806
+ * Platforms differ on what they accept: a 40-minute video publishes to
18807
+ * YouTube and Facebook but is refused by Instagram, whose Reels cap at 15
18808
+ * minutes. Those targets come back in `refusedTargets` — the post still
18809
+ * publishes to the rest.
18810
+ *
18811
+ * @example
18812
+ * ```ts
18813
+ * const result = await client.publishLongVideoToWorkspace({
18814
+ * workspaceId: "ws_123",
18815
+ * video: recordingFile,
18816
+ * youtube: { title: "Full session", description: "...", tags: ["workshop"] },
18817
+ * onProgress: (p) => console.log(`${p}%`),
18818
+ * });
18819
+ * console.log(`Charged ${result.credits} credits for ${result.durationSeconds}s`);
18820
+ * for (const t of result.refusedTargets) console.warn(t.reason);
18821
+ * ```
18822
+ */
18823
+ async publishLongVideoToWorkspace(options) {
18824
+ if (!options.workspaceId) {
18825
+ throw new Error("workspaceId is required");
18826
+ }
18827
+ if (!options.video) {
18828
+ throw new Error("video is required");
18829
+ }
18830
+ if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
18831
+ throw new Error("Provide at least one platform configuration (youtube / tiktok / facebook / instagram)");
18832
+ }
18833
+ const isFile2 = this.detectVideoSource(options.video) === "file";
18834
+ const upload = isFile2 ? await this.uploadLongVideo(
18835
+ options.video,
18836
+ options.thumbnail,
18837
+ {
18838
+ onProgress: options.onProgress,
18839
+ onUploadUrl: options.onUploadUrl,
18840
+ resumeFrom: options.resumeFrom,
18841
+ signal: options.signal,
18842
+ terminateOnAbort: options.terminateOnAbort
18843
+ }
18844
+ ) : void 0;
18845
+ const videoURL = upload ? upload.videoURL : options.video;
18846
+ const postId = upload?.postId;
18847
+ const thumb = await this.handleThumbnailUpload(options.thumbnail, upload?.uploadUrls);
18848
+ const body = {
18849
+ workspaceId: options.workspaceId,
18850
+ youtube: options.youtube,
18851
+ tiktok: options.tiktok,
18852
+ facebook: options.facebook,
18853
+ instagram: options.instagram,
18854
+ schedule: this.buildSchedule(options.schedule),
18855
+ source: isFile2 ? "video-file" : "video-url",
18856
+ videoURL,
18857
+ thumbURL: thumb?.thumbFileURL,
18858
+ tag: options.tag,
18859
+ refId: options.refId,
18860
+ comment: options.comment
18861
+ };
18862
+ const target = isFile2 ? "by-file" : "by-url";
18863
+ const id = postId ?? thumb?.postId;
18864
+ const url2 = id ? `${this.basePath}/long-video/workspace/${target}/${id}` : `${this.basePath}/long-video/workspace/${target}`;
18865
+ const response = await this.http.post(url2, { ...body, createdFrom: "npmPackage" });
18866
+ return this.normaliseLongVideoResult(response.result);
18867
+ }
18868
+ /**
18869
+ * Publish a video of up to 60 minutes to a single connected account.
18870
+ *
18871
+ * With one target there is no partial success: if that platform will not take
18872
+ * a video this long, the whole call is refused and nothing is charged. See
18873
+ * {@link publishLongVideoToWorkspace} for the cost model.
18874
+ */
18875
+ async publishLongVideoToAccount(options) {
18876
+ if (!options.accountId) {
18877
+ throw new Error("accountId is required");
18878
+ }
18879
+ if (!options.video) {
18880
+ throw new Error("video is required");
18881
+ }
18882
+ if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
18883
+ throw new Error("Provide the platform configuration matching the account (youtube / tiktok / facebook / instagram)");
18884
+ }
18885
+ const isFile2 = this.detectVideoSource(options.video) === "file";
18886
+ const upload = isFile2 ? await this.uploadLongVideo(
18887
+ options.video,
18888
+ options.thumbnail,
18889
+ {
18890
+ onProgress: options.onProgress,
18891
+ onUploadUrl: options.onUploadUrl,
18892
+ resumeFrom: options.resumeFrom,
18893
+ signal: options.signal,
18894
+ terminateOnAbort: options.terminateOnAbort
18895
+ }
18896
+ ) : void 0;
18897
+ const videoURL = upload ? upload.videoURL : options.video;
18898
+ const postId = upload?.postId;
18899
+ const thumb = await this.handleThumbnailUpload(options.thumbnail, upload?.uploadUrls);
18900
+ const body = {
18901
+ accountId: options.accountId,
18902
+ youtube: options.youtube,
18903
+ tiktok: options.tiktok,
18904
+ facebook: options.facebook,
18905
+ instagram: options.instagram,
18906
+ schedule: this.buildSchedule(options.schedule),
18907
+ source: isFile2 ? "video-file" : "video-url",
18908
+ videoURL,
18909
+ thumbURL: thumb?.thumbFileURL,
18910
+ tag: options.tag,
18911
+ refId: options.refId,
18912
+ comment: options.comment
18913
+ };
18914
+ const target = isFile2 ? "by-file" : "by-url";
18915
+ const id = postId ?? thumb?.postId;
18916
+ const url2 = id ? `${this.basePath}/long-video/account/${target}/${id}` : `${this.basePath}/long-video/account/${target}`;
18917
+ const response = await this.http.post(url2, { ...body, createdFrom: "npmPackage" });
18918
+ return this.normaliseLongVideoResult(response.result);
18919
+ }
18920
+ /**
18921
+ * Re-schedule a post that has not published yet, or send it out now.
18922
+ *
18923
+ * Free — this costs no credits. Only posts still pending with a future
18924
+ * publish time are eligible; anything that has started publishing is refused
18925
+ * by the server with a reason.
18926
+ *
18927
+ * @example
18928
+ * ```ts
18929
+ * await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") });
18930
+ * await client.reschedulePost("post_123", { schedule: "now" });
18931
+ * ```
18932
+ */
18933
+ async reschedulePost(id, data) {
18934
+ if (!id) {
18935
+ throw new Error("id is required");
18936
+ }
18937
+ await this.http.put(`${this.basePath}/${id}`, {
18938
+ schedule: this.buildSchedule(data.schedule),
18939
+ ...data.caption !== void 0 ? { caption: data.caption } : {}
18940
+ });
18941
+ }
18942
+ /**
18943
+ * Delete a post that has not published yet, releasing its uploaded media in
18944
+ * the same request.
18945
+ *
18946
+ * Free, and nothing is refunded — nothing was charged for a post that never
18947
+ * went out. A post that HAS published is refused; use {@link removePost} to
18948
+ * take down media that is already live.
18949
+ *
18950
+ * @example
18951
+ * ```ts
18952
+ * await client.deletePost("post_123");
18953
+ * ```
18954
+ */
18955
+ async deletePost(id) {
18956
+ if (!id) {
18957
+ throw new Error("id is required");
18958
+ }
18959
+ await this.http.delete(`${this.basePath}/${id}`);
18960
+ }
18961
+ /**
18962
+ * Upload a long video and return the URL to publish from.
18963
+ *
18964
+ * Declares `postType: "longVideo"` so the server refuses now — on plan gating
18965
+ * or an empty balance — rather than after an hour of transfer.
18966
+ */
18967
+ async uploadLongVideo(video, thumb, controls = {}) {
18968
+ const { onProgress, onUploadUrl, resumeFrom, signal, terminateOnAbort } = controls;
18969
+ if (video.size > this.maxVideoUploadSizeBytes) {
18970
+ throw new Error(`Video file size (${video.size} bytes) exceeds maximum allowed size (${this.maxVideoUploadSizeBytes} bytes)`);
18971
+ }
18972
+ const allowedVideoTypes = [".mp4", ".mov", ".avi", ".mkv", ".webm"];
18973
+ const videoExtension = "." + video.name.split(".").pop()?.toLowerCase();
18974
+ if (!allowedVideoTypes.includes(videoExtension)) {
18975
+ throw new Error(`Invalid video file type. Allowed types: ${allowedVideoTypes.join(", ")}`);
18976
+ }
18977
+ const uploadUrls = await this.generateUploadUrls({
18978
+ videoFileType: video.type,
18979
+ thumbFileType: thumb instanceof File ? thumb.type : void 0,
18980
+ postType: "longVideo"
18981
+ });
18982
+ if (supportsResumableUpload(uploadUrls.video)) {
18983
+ await uploadResumable(uploadUrls.video, video, {
18984
+ onProgress,
18985
+ onUploadUrl,
18986
+ uploadUrl: resumeFrom,
18987
+ signal,
18988
+ terminateOnAbort
18989
+ });
18990
+ } else {
18991
+ await uploadToR2(uploadUrls.video.uploadFileURL, video, {
18992
+ contentType: video.type,
18993
+ onProgress
18994
+ });
18995
+ }
18996
+ return { videoURL: uploadUrls.video.fileURL, postId: uploadUrls.postId, uploadUrls };
18997
+ }
18998
+ /** Translate the friendly `"now" | Date` form into the wire shape. */
18999
+ buildSchedule(schedule) {
19000
+ if (!schedule) return void 0;
19001
+ return {
19002
+ type: schedule === "now" ? "now" : "schedule",
19003
+ scheduledAt: schedule instanceof Date ? schedule : void 0
19004
+ };
19005
+ }
19006
+ /**
19007
+ * Guarantee the shape callers destructure. An older server that does not yet
19008
+ * return the duration fields would otherwise hand back `undefined` where the
19009
+ * types promise numbers.
19010
+ */
19011
+ normaliseLongVideoResult(result) {
19012
+ return {
19013
+ _id: result?._id,
19014
+ durationSeconds: result?.durationSeconds ?? 0,
19015
+ creditUnits: result?.creditUnits ?? 0,
19016
+ credits: result?.credits ?? 0,
19017
+ refusedTargets: result?.refusedTargets ?? []
19018
+ };
19019
+ }
17866
19020
  /**
17867
19021
  * Auto-detect video source type.
17868
19022
  *
@@ -17879,6 +19033,13 @@ var SocialPublisherPostClient = class {
17879
19033
  throw new Error("Invalid video type. Must be File or string URL");
17880
19034
  }
17881
19035
  };
19036
+
19037
+ // src/interfaces/requests/index.ts
19038
+ var MAX_POST_COMMENTS = 5;
19039
+ var MAX_COMMENT_LENGTH = 2200;
19040
+ var MAX_COMMENT_DELAY_MINUTES = 24 * 60;
19041
+ var LONG_VIDEO_MAX_DURATION_SECONDS = 3600;
19042
+ var LONG_VIDEO_CREDIT_UNIT_SECONDS = 300;
17882
19043
  /*! Bundled license information:
17883
19044
 
17884
19045
  mime-db/index.js:
@@ -17898,8 +19059,17 @@ mime-types/index.js:
17898
19059
  *)
17899
19060
  */
17900
19061
 
19062
+ exports.DEFAULT_CHUNK_SIZE = DEFAULT_CHUNK_SIZE2;
17901
19063
  exports.HttpClient = HttpClient;
19064
+ exports.LONG_VIDEO_CREDIT_UNIT_SECONDS = LONG_VIDEO_CREDIT_UNIT_SECONDS;
19065
+ exports.LONG_VIDEO_MAX_DURATION_SECONDS = LONG_VIDEO_MAX_DURATION_SECONDS;
19066
+ exports.MAX_COMMENT_DELAY_MINUTES = MAX_COMMENT_DELAY_MINUTES;
19067
+ exports.MAX_COMMENT_LENGTH = MAX_COMMENT_LENGTH;
19068
+ exports.MAX_POST_COMMENTS = MAX_POST_COMMENTS;
17902
19069
  exports.SocialPublisherPostClient = SocialPublisherPostClient;
19070
+ exports.supportsResumableUpload = supportsResumableUpload;
19071
+ exports.terminateUpload = terminateUpload;
19072
+ exports.uploadResumable = uploadResumable;
17903
19073
  exports.uploadToR2 = uploadToR2;
17904
19074
  //# sourceMappingURL=index.js.map
17905
19075
  //# sourceMappingURL=index.js.map