@localazy/strapi-plugin
Version:
The official Strapi Plugin by Localazy.
1,506 lines (1,505 loc) • 733 kB
JavaScript
import require$$0$4 from "http";
import require$$1$4 from "fs";
import require$$1$1 from "zlib";
import require$$1 from "path";
import require$$4 from "stream";
import require$$1$2 from "querystring";
import require$$1$3 from "url";
import require$$0$2 from "crypto";
import require$$0$3 from "events";
import require$$2 from "timers";
import require$$8, { WebSocketServer } from "ws";
var objectProto$r = Object.prototype;
function isPrototype$4(value) {
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$r;
return value === proto;
}
function overArg$3(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
var nativeKeys$2 = overArg$3(Object.keys, Object);
var objectProto$q = Object.prototype;
var hasOwnProperty$m = objectProto$q.hasOwnProperty;
function baseKeys$2(object) {
if (!isPrototype$4(object)) {
return nativeKeys$2(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty$m.call(object, key) && key != "constructor") {
result.push(key);
}
}
return result;
}
var freeGlobal$2 = typeof global == "object" && global && global.Object === Object && global;
var freeSelf$1 = typeof self == "object" && self && self.Object === Object && self;
var root$9 = freeGlobal$2 || freeSelf$1 || Function("return this")();
var Symbol$5 = root$9.Symbol;
var objectProto$p = Object.prototype;
var hasOwnProperty$l = objectProto$p.hasOwnProperty;
var nativeObjectToString$3 = objectProto$p.toString;
var symToStringTag$3 = Symbol$5 ? Symbol$5.toStringTag : void 0;
function getRawTag$2(value) {
var isOwn = hasOwnProperty$l.call(value, symToStringTag$3), tag = value[symToStringTag$3];
try {
value[symToStringTag$3] = void 0;
var unmasked = true;
} catch (e3) {
}
var result = nativeObjectToString$3.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$3] = tag;
} else {
delete value[symToStringTag$3];
}
}
return result;
}
var objectProto$o = Object.prototype;
var nativeObjectToString$2 = objectProto$o.toString;
function objectToString$2(value) {
return nativeObjectToString$2.call(value);
}
var nullTag$1 = "[object Null]", undefinedTag$1 = "[object Undefined]";
var symToStringTag$2 = Symbol$5 ? Symbol$5.toStringTag : void 0;
function baseGetTag$5(value) {
if (value == null) {
return value === void 0 ? undefinedTag$1 : nullTag$1;
}
return symToStringTag$2 && symToStringTag$2 in Object(value) ? getRawTag$2(value) : objectToString$2(value);
}
function isObject$6(value) {
var type2 = typeof value;
return value != null && (type2 == "object" || type2 == "function");
}
var asyncTag$1 = "[object AsyncFunction]", funcTag$5 = "[object Function]", genTag$3 = "[object GeneratorFunction]", proxyTag$1 = "[object Proxy]";
function isFunction$3(value) {
if (!isObject$6(value)) {
return false;
}
var tag = baseGetTag$5(value);
return tag == funcTag$5 || tag == genTag$3 || tag == asyncTag$1 || tag == proxyTag$1;
}
var coreJsData$2 = root$9["__core-js_shared__"];
var maskSrcKey$1 = function() {
var uid = /[^.]+$/.exec(coreJsData$2 && coreJsData$2.keys && coreJsData$2.keys.IE_PROTO || "");
return uid ? "Symbol(src)_1." + uid : "";
}();
function isMasked$2(func) {
return !!maskSrcKey$1 && maskSrcKey$1 in func;
}
var funcProto$4 = Function.prototype;
var funcToString$4 = funcProto$4.toString;
function toSource$3(func) {
if (func != null) {
try {
return funcToString$4.call(func);
} catch (e3) {
}
try {
return func + "";
} catch (e3) {
}
}
return "";
}
var reRegExpChar$1 = /[\\^$.*+?()[\]{}|]/g;
var reIsHostCtor$1 = /^\[object .+?Constructor\]$/;
var funcProto$3 = Function.prototype, objectProto$n = Object.prototype;
var funcToString$3 = funcProto$3.toString;
var hasOwnProperty$k = objectProto$n.hasOwnProperty;
var reIsNative$1 = RegExp(
"^" + funcToString$3.call(hasOwnProperty$k).replace(reRegExpChar$1, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function baseIsNative$2(value) {
if (!isObject$6(value) || isMasked$2(value)) {
return false;
}
var pattern = isFunction$3(value) ? reIsNative$1 : reIsHostCtor$1;
return pattern.test(toSource$3(value));
}
function getValue$2(object, key) {
return object == null ? void 0 : object[key];
}
function getNative$8(object, key) {
var value = getValue$2(object, key);
return baseIsNative$2(value) ? value : void 0;
}
var DataView$3 = getNative$8(root$9, "DataView");
var Map$5 = getNative$8(root$9, "Map");
var Promise$3 = getNative$8(root$9, "Promise");
var Set$3 = getNative$8(root$9, "Set");
var WeakMap$2 = getNative$8(root$9, "WeakMap");
var mapTag$a = "[object Map]", objectTag$6 = "[object Object]", promiseTag$1 = "[object Promise]", setTag$a = "[object Set]", weakMapTag$5 = "[object WeakMap]";
var dataViewTag$7 = "[object DataView]";
var dataViewCtorString$1 = toSource$3(DataView$3), mapCtorString$1 = toSource$3(Map$5), promiseCtorString$1 = toSource$3(Promise$3), setCtorString$1 = toSource$3(Set$3), weakMapCtorString$1 = toSource$3(WeakMap$2);
var getTag$4 = baseGetTag$5;
if (DataView$3 && getTag$4(new DataView$3(new ArrayBuffer(1))) != dataViewTag$7 || Map$5 && getTag$4(new Map$5()) != mapTag$a || Promise$3 && getTag$4(Promise$3.resolve()) != promiseTag$1 || Set$3 && getTag$4(new Set$3()) != setTag$a || WeakMap$2 && getTag$4(new WeakMap$2()) != weakMapTag$5) {
getTag$4 = function(value) {
var result = baseGetTag$5(value), Ctor = result == objectTag$6 ? value.constructor : void 0, ctorString = Ctor ? toSource$3(Ctor) : "";
if (ctorString) {
switch (ctorString) {
case dataViewCtorString$1:
return dataViewTag$7;
case mapCtorString$1:
return mapTag$a;
case promiseCtorString$1:
return promiseTag$1;
case setCtorString$1:
return setTag$a;
case weakMapCtorString$1:
return weakMapTag$5;
}
}
return result;
};
}
function isObjectLike$6(value) {
return value != null && typeof value == "object";
}
var argsTag$5 = "[object Arguments]";
function baseIsArguments$2(value) {
return isObjectLike$6(value) && baseGetTag$5(value) == argsTag$5;
}
var objectProto$m = Object.prototype;
var hasOwnProperty$j = objectProto$m.hasOwnProperty;
var propertyIsEnumerable$3 = objectProto$m.propertyIsEnumerable;
var isArguments$2 = baseIsArguments$2(/* @__PURE__ */ function() {
return arguments;
}()) ? baseIsArguments$2 : function(value) {
return isObjectLike$6(value) && hasOwnProperty$j.call(value, "callee") && !propertyIsEnumerable$3.call(value, "callee");
};
var isArray$4 = Array.isArray;
var MAX_SAFE_INTEGER$3 = 9007199254740991;
function isLength$3(value) {
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$3;
}
function isArrayLike$3(value) {
return value != null && isLength$3(value.length) && !isFunction$3(value);
}
function stubFalse$1() {
return false;
}
var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
var Buffer$2 = moduleExports$2 ? root$9.Buffer : void 0;
var nativeIsBuffer = Buffer$2 ? Buffer$2.isBuffer : void 0;
var isBuffer$3 = nativeIsBuffer || stubFalse$1;
var argsTag$4 = "[object Arguments]", arrayTag$3 = "[object Array]", boolTag$5 = "[object Boolean]", dateTag$5 = "[object Date]", errorTag$3 = "[object Error]", funcTag$4 = "[object Function]", mapTag$9 = "[object Map]", numberTag$5 = "[object Number]", objectTag$5 = "[object Object]", regexpTag$5 = "[object RegExp]", setTag$9 = "[object Set]", stringTag$5 = "[object String]", weakMapTag$4 = "[object WeakMap]";
var arrayBufferTag$5 = "[object ArrayBuffer]", dataViewTag$6 = "[object DataView]", float32Tag$5 = "[object Float32Array]", float64Tag$5 = "[object Float64Array]", int8Tag$5 = "[object Int8Array]", int16Tag$5 = "[object Int16Array]", int32Tag$5 = "[object Int32Array]", uint8Tag$5 = "[object Uint8Array]", uint8ClampedTag$5 = "[object Uint8ClampedArray]", uint16Tag$5 = "[object Uint16Array]", uint32Tag$5 = "[object Uint32Array]";
var typedArrayTags$1 = {};
typedArrayTags$1[float32Tag$5] = typedArrayTags$1[float64Tag$5] = typedArrayTags$1[int8Tag$5] = typedArrayTags$1[int16Tag$5] = typedArrayTags$1[int32Tag$5] = typedArrayTags$1[uint8Tag$5] = typedArrayTags$1[uint8ClampedTag$5] = typedArrayTags$1[uint16Tag$5] = typedArrayTags$1[uint32Tag$5] = true;
typedArrayTags$1[argsTag$4] = typedArrayTags$1[arrayTag$3] = typedArrayTags$1[arrayBufferTag$5] = typedArrayTags$1[boolTag$5] = typedArrayTags$1[dataViewTag$6] = typedArrayTags$1[dateTag$5] = typedArrayTags$1[errorTag$3] = typedArrayTags$1[funcTag$4] = typedArrayTags$1[mapTag$9] = typedArrayTags$1[numberTag$5] = typedArrayTags$1[objectTag$5] = typedArrayTags$1[regexpTag$5] = typedArrayTags$1[setTag$9] = typedArrayTags$1[stringTag$5] = typedArrayTags$1[weakMapTag$4] = false;
function baseIsTypedArray$2(value) {
return isObjectLike$6(value) && isLength$3(value.length) && !!typedArrayTags$1[baseGetTag$5(value)];
}
function baseUnary$4(func) {
return function(value) {
return func(value);
};
}
var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
var freeProcess = moduleExports$1 && freeGlobal$2.process;
var nodeUtil$3 = function() {
try {
var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
if (types) {
return types;
}
return freeProcess && freeProcess.binding && freeProcess.binding("util");
} catch (e3) {
}
}();
var nodeIsTypedArray$1 = nodeUtil$3 && nodeUtil$3.isTypedArray;
var isTypedArray$2 = nodeIsTypedArray$1 ? baseUnary$4(nodeIsTypedArray$1) : baseIsTypedArray$2;
var mapTag$8 = "[object Map]", setTag$8 = "[object Set]";
var objectProto$l = Object.prototype;
var hasOwnProperty$i = objectProto$l.hasOwnProperty;
function isEmpty(value) {
if (value == null) {
return true;
}
if (isArrayLike$3(value) && (isArray$4(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer$3(value) || isTypedArray$2(value) || isArguments$2(value))) {
return !value.length;
}
var tag = getTag$4(value);
if (tag == mapTag$8 || tag == setTag$8) {
return !value.size;
}
if (isPrototype$4(value)) {
return !baseKeys$2(value).length;
}
for (var key in value) {
if (hasOwnProperty$i.call(value, key)) {
return false;
}
}
return true;
}
function listCacheClear$2() {
this.__data__ = [];
this.size = 0;
}
function eq$3(value, other) {
return value === other || value !== value && other !== other;
}
function assocIndexOf$5(array, key) {
var length2 = array.length;
while (length2--) {
if (eq$3(array[length2][0], key)) {
return length2;
}
}
return -1;
}
var arrayProto$1 = Array.prototype;
var splice$1 = arrayProto$1.splice;
function listCacheDelete$2(key) {
var data = this.__data__, index2 = assocIndexOf$5(data, key);
if (index2 < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index2 == lastIndex) {
data.pop();
} else {
splice$1.call(data, index2, 1);
}
--this.size;
return true;
}
function listCacheGet$2(key) {
var data = this.__data__, index2 = assocIndexOf$5(data, key);
return index2 < 0 ? void 0 : data[index2][1];
}
function listCacheHas$2(key) {
return assocIndexOf$5(this.__data__, key) > -1;
}
function listCacheSet$2(key, value) {
var data = this.__data__, index2 = assocIndexOf$5(data, key);
if (index2 < 0) {
++this.size;
data.push([key, value]);
} else {
data[index2][1] = value;
}
return this;
}
function ListCache$5(entries) {
var index2 = -1, length2 = entries == null ? 0 : entries.length;
this.clear();
while (++index2 < length2) {
var entry = entries[index2];
this.set(entry[0], entry[1]);
}
}
ListCache$5.prototype.clear = listCacheClear$2;
ListCache$5.prototype["delete"] = listCacheDelete$2;
ListCache$5.prototype.get = listCacheGet$2;
ListCache$5.prototype.has = listCacheHas$2;
ListCache$5.prototype.set = listCacheSet$2;
function stackClear$2() {
this.__data__ = new ListCache$5();
this.size = 0;
}
function stackDelete$2(key) {
var data = this.__data__, result = data["delete"](key);
this.size = data.size;
return result;
}
function stackGet$2(key) {
return this.__data__.get(key);
}
function stackHas$2(key) {
return this.__data__.has(key);
}
var nativeCreate$5 = getNative$8(Object, "create");
function hashClear$2() {
this.__data__ = nativeCreate$5 ? nativeCreate$5(null) : {};
this.size = 0;
}
function hashDelete$2(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
var HASH_UNDEFINED$3 = "__lodash_hash_undefined__";
var objectProto$k = Object.prototype;
var hasOwnProperty$h = objectProto$k.hasOwnProperty;
function hashGet$2(key) {
var data = this.__data__;
if (nativeCreate$5) {
var result = data[key];
return result === HASH_UNDEFINED$3 ? void 0 : result;
}
return hasOwnProperty$h.call(data, key) ? data[key] : void 0;
}
var objectProto$j = Object.prototype;
var hasOwnProperty$g = objectProto$j.hasOwnProperty;
function hashHas$2(key) {
var data = this.__data__;
return nativeCreate$5 ? data[key] !== void 0 : hasOwnProperty$g.call(data, key);
}
var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
function hashSet$2(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = nativeCreate$5 && value === void 0 ? HASH_UNDEFINED$2 : value;
return this;
}
function Hash$2(entries) {
var index2 = -1, length2 = entries == null ? 0 : entries.length;
this.clear();
while (++index2 < length2) {
var entry = entries[index2];
this.set(entry[0], entry[1]);
}
}
Hash$2.prototype.clear = hashClear$2;
Hash$2.prototype["delete"] = hashDelete$2;
Hash$2.prototype.get = hashGet$2;
Hash$2.prototype.has = hashHas$2;
Hash$2.prototype.set = hashSet$2;
function mapCacheClear$2() {
this.size = 0;
this.__data__ = {
"hash": new Hash$2(),
"map": new (Map$5 || ListCache$5)(),
"string": new Hash$2()
};
}
function isKeyable$2(value) {
var type2 = typeof value;
return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
}
function getMapData$5(map2, key) {
var data = map2.__data__;
return isKeyable$2(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
}
function mapCacheDelete$2(key) {
var result = getMapData$5(this, key)["delete"](key);
this.size -= result ? 1 : 0;
return result;
}
function mapCacheGet$2(key) {
return getMapData$5(this, key).get(key);
}
function mapCacheHas$2(key) {
return getMapData$5(this, key).has(key);
}
function mapCacheSet$2(key, value) {
var data = getMapData$5(this, key), size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
function MapCache$2(entries) {
var index2 = -1, length2 = entries == null ? 0 : entries.length;
this.clear();
while (++index2 < length2) {
var entry = entries[index2];
this.set(entry[0], entry[1]);
}
}
MapCache$2.prototype.clear = mapCacheClear$2;
MapCache$2.prototype["delete"] = mapCacheDelete$2;
MapCache$2.prototype.get = mapCacheGet$2;
MapCache$2.prototype.has = mapCacheHas$2;
MapCache$2.prototype.set = mapCacheSet$2;
var LARGE_ARRAY_SIZE$1 = 200;
function stackSet$2(key, value) {
var data = this.__data__;
if (data instanceof ListCache$5) {
var pairs = data.__data__;
if (!Map$5 || pairs.length < LARGE_ARRAY_SIZE$1 - 1) {
pairs.push([key, value]);
this.size = ++data.size;
return this;
}
data = this.__data__ = new MapCache$2(pairs);
}
data.set(key, value);
this.size = data.size;
return this;
}
function Stack$2(entries) {
var data = this.__data__ = new ListCache$5(entries);
this.size = data.size;
}
Stack$2.prototype.clear = stackClear$2;
Stack$2.prototype["delete"] = stackDelete$2;
Stack$2.prototype.get = stackGet$2;
Stack$2.prototype.has = stackHas$2;
Stack$2.prototype.set = stackSet$2;
var defineProperty$2 = function() {
try {
var func = getNative$8(Object, "defineProperty");
func({}, "", {});
return func;
} catch (e3) {
}
}();
function baseAssignValue$3(object, key, value) {
if (key == "__proto__" && defineProperty$2) {
defineProperty$2(object, key, {
"configurable": true,
"enumerable": true,
"value": value,
"writable": true
});
} else {
object[key] = value;
}
}
function assignMergeValue(object, key, value) {
if (value !== void 0 && !eq$3(object[key], value) || value === void 0 && !(key in object)) {
baseAssignValue$3(object, key, value);
}
}
function createBaseFor(fromRight) {
return function(object, iteratee, keysFunc) {
var index2 = -1, iterable = Object(object), props = keysFunc(object), length2 = props.length;
while (length2--) {
var key = props[++index2];
if (iteratee(iterable[key], key, iterable) === false) {
break;
}
}
return object;
};
}
var baseFor = createBaseFor();
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
var moduleExports = freeModule && freeModule.exports === freeExports;
var Buffer$1 = moduleExports ? root$9.Buffer : void 0, allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : void 0;
function cloneBuffer$1(buffer, isDeep) {
if (isDeep) {
return buffer.slice();
}
var length2 = buffer.length, result = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2);
buffer.copy(result);
return result;
}
var Uint8Array$3 = root$9.Uint8Array;
function cloneArrayBuffer$4(arrayBuffer) {
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
new Uint8Array$3(result).set(new Uint8Array$3(arrayBuffer));
return result;
}
function cloneTypedArray$2(typedArray, isDeep) {
var buffer = isDeep ? cloneArrayBuffer$4(typedArray.buffer) : typedArray.buffer;
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
}
function copyArray$2(source, array) {
var index2 = -1, length2 = source.length;
array || (array = Array(length2));
while (++index2 < length2) {
array[index2] = source[index2];
}
return array;
}
var objectCreate$1 = Object.create;
var baseCreate$2 = /* @__PURE__ */ function() {
function object() {
}
return function(proto) {
if (!isObject$6(proto)) {
return {};
}
if (objectCreate$1) {
return objectCreate$1(proto);
}
object.prototype = proto;
var result = new object();
object.prototype = void 0;
return result;
};
}();
var getPrototype$3 = overArg$3(Object.getPrototypeOf, Object);
function initCloneObject$2(object) {
return typeof object.constructor == "function" && !isPrototype$4(object) ? baseCreate$2(getPrototype$3(object)) : {};
}
function isArrayLikeObject(value) {
return isObjectLike$6(value) && isArrayLike$3(value);
}
var objectTag$4 = "[object Object]";
var funcProto$2 = Function.prototype, objectProto$i = Object.prototype;
var funcToString$2 = funcProto$2.toString;
var hasOwnProperty$f = objectProto$i.hasOwnProperty;
var objectCtorString = funcToString$2.call(Object);
function isPlainObject(value) {
if (!isObjectLike$6(value) || baseGetTag$5(value) != objectTag$4) {
return false;
}
var proto = getPrototype$3(value);
if (proto === null) {
return true;
}
var Ctor = hasOwnProperty$f.call(proto, "constructor") && proto.constructor;
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString$2.call(Ctor) == objectCtorString;
}
function safeGet(object, key) {
if (key === "constructor" && typeof object[key] === "function") {
return;
}
if (key == "__proto__") {
return;
}
return object[key];
}
var objectProto$h = Object.prototype;
var hasOwnProperty$e = objectProto$h.hasOwnProperty;
function assignValue$3(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty$e.call(object, key) && eq$3(objValue, value)) || value === void 0 && !(key in object)) {
baseAssignValue$3(object, key, value);
}
}
function copyObject$5(source, props, object, customizer) {
var isNew = !object;
object || (object = {});
var index2 = -1, length2 = props.length;
while (++index2 < length2) {
var key = props[index2];
var newValue = void 0;
if (newValue === void 0) {
newValue = source[key];
}
if (isNew) {
baseAssignValue$3(object, key, newValue);
} else {
assignValue$3(object, key, newValue);
}
}
return object;
}
function baseTimes$2(n2, iteratee) {
var index2 = -1, result = Array(n2);
while (++index2 < n2) {
result[index2] = iteratee(index2);
}
return result;
}
var MAX_SAFE_INTEGER$2 = 9007199254740991;
var reIsUint$1 = /^(?:0|[1-9]\d*)$/;
function isIndex$2(value, length2) {
var type2 = typeof value;
length2 = length2 == null ? MAX_SAFE_INTEGER$2 : length2;
return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint$1.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
}
var objectProto$g = Object.prototype;
var hasOwnProperty$d = objectProto$g.hasOwnProperty;
function arrayLikeKeys$3(value, inherited) {
var isArr = isArray$4(value), isArg = !isArr && isArguments$2(value), isBuff = !isArr && !isArg && isBuffer$3(value), isType = !isArr && !isArg && !isBuff && isTypedArray$2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes$2(value.length, String) : [], length2 = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty$d.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
isIndex$2(key, length2)))) {
result.push(key);
}
}
return result;
}
function nativeKeysIn$2(object) {
var result = [];
if (object != null) {
for (var key in Object(object)) {
result.push(key);
}
}
return result;
}
var objectProto$f = Object.prototype;
var hasOwnProperty$c = objectProto$f.hasOwnProperty;
function baseKeysIn$2(object) {
if (!isObject$6(object)) {
return nativeKeysIn$2(object);
}
var isProto = isPrototype$4(object), result = [];
for (var key in object) {
if (!(key == "constructor" && (isProto || !hasOwnProperty$c.call(object, key)))) {
result.push(key);
}
}
return result;
}
function keysIn$4(object) {
return isArrayLike$3(object) ? arrayLikeKeys$3(object, true) : baseKeysIn$2(object);
}
function toPlainObject(value) {
return copyObject$5(value, keysIn$4(value));
}
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
if (stacked) {
assignMergeValue(object, key, stacked);
return;
}
var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0;
var isCommon = newValue === void 0;
if (isCommon) {
var isArr = isArray$4(srcValue), isBuff = !isArr && isBuffer$3(srcValue), isTyped = !isArr && !isBuff && isTypedArray$2(srcValue);
newValue = srcValue;
if (isArr || isBuff || isTyped) {
if (isArray$4(objValue)) {
newValue = objValue;
} else if (isArrayLikeObject(objValue)) {
newValue = copyArray$2(objValue);
} else if (isBuff) {
isCommon = false;
newValue = cloneBuffer$1(srcValue, true);
} else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray$2(srcValue, true);
} else {
newValue = [];
}
} else if (isPlainObject(srcValue) || isArguments$2(srcValue)) {
newValue = objValue;
if (isArguments$2(objValue)) {
newValue = toPlainObject(objValue);
} else if (!isObject$6(objValue) || isFunction$3(objValue)) {
newValue = initCloneObject$2(srcValue);
}
} else {
isCommon = false;
}
}
if (isCommon) {
stack.set(srcValue, newValue);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
stack["delete"](srcValue);
}
assignMergeValue(object, key, newValue);
}
function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) {
return;
}
baseFor(source, function(srcValue, key) {
stack || (stack = new Stack$2());
if (isObject$6(srcValue)) {
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
} else {
var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : void 0;
if (newValue === void 0) {
newValue = srcValue;
}
assignMergeValue(object, key, newValue);
}
}, keysIn$4);
}
function identity(value) {
return value;
}
function apply(func, thisArg, args) {
switch (args.length) {
case 0:
return func.call(thisArg);
case 1:
return func.call(thisArg, args[0]);
case 2:
return func.call(thisArg, args[0], args[1]);
case 3:
return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
var nativeMax = Math.max;
function overRest(func, start, transform) {
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
return function() {
var args = arguments, index2 = -1, length2 = nativeMax(args.length - start, 0), array = Array(length2);
while (++index2 < length2) {
array[index2] = args[start + index2];
}
index2 = -1;
var otherArgs = Array(start + 1);
while (++index2 < start) {
otherArgs[index2] = args[index2];
}
otherArgs[start] = transform(array);
return apply(func, this, otherArgs);
};
}
function constant(value) {
return function() {
return value;
};
}
var baseSetToString = !defineProperty$2 ? identity : function(func, string) {
return defineProperty$2(func, "toString", {
"configurable": true,
"enumerable": false,
"value": constant(string),
"writable": true
});
};
var HOT_COUNT = 800, HOT_SPAN = 16;
var nativeNow = Date.now;
function shortOut(func) {
var count = 0, lastCalled = 0;
return function() {
var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count = 0;
}
return func.apply(void 0, arguments);
};
}
var setToString = shortOut(baseSetToString);
function baseRest(func, start) {
return setToString(overRest(func, start, identity), func + "");
}
function isIterateeCall(value, index2, object) {
if (!isObject$6(object)) {
return false;
}
var type2 = typeof index2;
if (type2 == "number" ? isArrayLike$3(object) && isIndex$2(index2, object.length) : type2 == "string" && index2 in object) {
return eq$3(object[index2], value);
}
return false;
}
function createAssigner(assigner) {
return baseRest(function(object, sources) {
var index2 = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : void 0, guard = length2 > 2 ? sources[2] : void 0;
customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : void 0;
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length2 < 3 ? void 0 : customizer;
length2 = 1;
}
object = Object(object);
while (++index2 < length2) {
var source = sources[index2];
if (source) {
assigner(object, source, index2, customizer);
}
}
return object;
});
}
var merge = createAssigner(function(object, source, srcIndex) {
baseMerge(object, source, srcIndex);
});
const name = "@localazy/strapi-plugin";
const version$1 = "1.0.3";
const description = "The official Strapi Plugin by Localazy.";
const keywords = [
"strapi",
"plugin",
"localazy",
"javascript",
"internationalization",
"i18n",
"headless",
"cms",
"l10n"
];
const repository = {
type: "git",
url: "git+https://github.com/localazy/strapi-plugin"
};
const bugs = {
url: "https://github.com/localazy/strapi-plugin/issues"
};
const homepage = "https://github.com/localazy/strapi-plugin#readme";
const license = "MIT";
const author = {
name: "Localazy",
email: "team@localazy.com",
url: "https://localazy.com"
};
const type = "commonjs";
const exports$1 = {
"./package.json": "./package.json",
"./strapi-admin": {
types: "./dist/admin/src/index.d.ts",
source: "./admin/src/index.ts",
"import": "./dist/admin/index.mjs",
require: "./dist/admin/index.js",
"default": "./dist/admin/index.js"
},
"./strapi-server": {
types: "./dist/server/src/index.d.ts",
source: "./server/src/index.ts",
"import": "./dist/server/index.mjs",
require: "./dist/server/index.js",
"default": "./dist/server/index.js"
}
};
const bin = {
"strapi-plugin": "install/index.mjs"
};
const files = [
"dist",
"install"
];
const scripts = {
build: "strapi-plugin build",
format: "prettier --write .",
"format:check": "prettier --check .",
lint: "eslint .",
"lint:fix": "eslint --fix .",
"test:server": "jest --config server/jest.config.ts",
"test:server:coverage": "jest --config server/jest.config.ts --coverage",
"test:server:watch": "jest --config server/jest.config.ts --watch",
"test:ts:back": "run -T tsc -p server/tsconfig.json",
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
verify: "strapi-plugin verify",
watch: "strapi-plugin watch",
"watch:link": "strapi-plugin watch:link"
};
const dependencies = {
shelljs: "^0.8.5",
ws: "^8.18.0"
};
const devDependencies = {
"@david-vaclavek/deep-keys": "^0.5.0",
"@localazy/api-client": "^2.1.6",
"@localazy/conventional-changelog-preset": "^1.2.10",
"@localazy/generic-connector-client": "^0.3.0",
"@strapi/design-system": "^2.0.0-rc.14",
"@strapi/icons": "^2.0.0-rc.14",
"@strapi/typescript-utils": "^5.6.0",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
axios: "^1.7.9",
chalk: "^5.4.1",
"conventional-changelog": "^5.1.0",
"conventional-changelog-cli": "^4.1.0",
"conventional-changelog-writer": "github:localazy/conventional-changelog-writer",
"conventional-recommended-bump": "^9.0.0",
eslint: "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.1.0",
"fs-extra": "^11.3.0",
history: "^5.3.0",
husky: "^9.1.7",
i18next: "^24.2.1",
jest: "^29.7.0",
"lint-staged": "^15.4.1",
lodash: "^4.17.21",
"lodash-es": "^4.17.21",
ora: "^8.2.0",
prettier: "^3.4.2",
"react-hooks-global-state": "^2.1.0",
"react-i18next": "^15.4.0",
"react-intl": "^7.1.0",
"socket.io": "^4.8.1",
"socket.io-client": "^4.8.1",
strapio: "^3.0.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
typescript: "^5.7.2"
};
const peerDependencies = {
"@strapi/sdk-plugin": "^5.2.8",
"@strapi/strapi": "^5.6.0",
react: "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.1",
"styled-components": "^6.1.14"
};
const strapi$1 = {
kind: "plugin",
name: "localazy",
displayName: "Localazy Strapi Plugin",
description: "The official Strapi Plugin by Localazy"
};
const _package = {
name,
version: version$1,
description,
keywords,
repository,
bugs,
homepage,
license,
author,
type,
exports: exports$1,
bin,
files,
scripts,
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
]
},
dependencies,
devDependencies,
peerDependencies,
strapi: strapi$1
};
const _package$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
author,
bin,
bugs,
default: _package,
dependencies,
description,
devDependencies,
exports: exports$1,
files,
homepage,
keywords,
license,
name,
peerDependencies,
repository,
scripts,
strapi: strapi$1,
type,
version: version$1
}, Symbol.toStringTag, { value: "Module" }));
const PLUGIN_NAME = strapi$1.name;
const DEFAULT_MAX_POPULATE_DEPTH = 10;
const DEFAULT_POPULATE_DEPTH$1 = 5;
const getModelPopulationAttributes$2 = (model) => {
if (model.uid === "plugin::upload.file") {
const { related, ...attributes } = model.attributes;
return attributes;
}
return model.attributes;
};
const getFullPopulateObject = (modelUid, maxDepth = DEFAULT_POPULATE_DEPTH$1, ignore = []) => {
const skipCreatorFields = strapi.plugin(PLUGIN_NAME)?.config("skipCreatorFields");
let localDepth = maxDepth;
if (localDepth <= 1) {
return true;
}
if (modelUid === "admin::user" && skipCreatorFields) {
return void 0;
}
const populate = {};
const model = strapi.getModel(modelUid);
if (model === void 0) {
return void 0;
}
if (ignore && !ignore.includes(model.collectionName)) ignore.push(model.collectionName);
for (const [key, value] of Object.entries(getModelPopulationAttributes$2(model))) {
if (ignore?.includes(key)) continue;
if (value) {
if (value.type === "component") {
populate[key] = getFullPopulateObject(value.component, maxDepth - 1);
} else if (value.type === "dynamiczone") {
const dynamicPopulate = value.components.reduce((prev2, cur) => {
const curPopulate = getFullPopulateObject(cur, maxDepth - 1);
return merge(prev2, { [cur]: curPopulate });
}, {});
populate[key] = isEmpty(dynamicPopulate) ? true : { on: dynamicPopulate };
} else if (value.type === "relation") {
const relationPopulate = getFullPopulateObject(
value.target,
key === "localizations" && maxDepth > 2 ? 1 : maxDepth - 1,
ignore
);
if (relationPopulate) {
populate[key] = relationPopulate;
}
} else if (value.type === "media") {
populate[key] = true;
}
}
}
return isEmpty(populate) ? true : { populate };
};
const getModelPopulationAttributes$1 = (model) => {
if (model.uid === "plugin::upload.file") {
const { related, ...attributes } = model.attributes;
return attributes;
}
return model.attributes;
};
const getFullPopulateLocalazyUploadObject = (modelUid, maxDepth = DEFAULT_POPULATE_DEPTH$1, ignore = ["locale", "localizations", "createdAt", "createdBy", "updatedAt", "updatedBy", "publishedAt"]) => {
let localDepth = maxDepth;
if (localDepth <= 1) {
return true;
}
if (["admin::user", "plugin::upload.file"].includes(modelUid)) {
return void 0;
}
const populate = {};
const model = strapi.getModel(modelUid);
if (model === void 0) {
return void 0;
}
if (ignore && !ignore.includes(model.collectionName)) ignore.push(model.collectionName);
for (const [key, value] of Object.entries(getModelPopulationAttributes$1(model))) {
if (ignore?.includes(key)) continue;
if (value) {
if (value.type === "component") {
populate[key] = getFullPopulateLocalazyUploadObject(value.component, maxDepth - 1);
} else if (value.type === "dynamiczone") {
const dynamicPopulate = value.components.reduce((prev2, cur) => {
const curPopulate = getFullPopulateLocalazyUploadObject(cur, maxDepth - 1);
return merge(prev2, { [cur]: curPopulate });
}, {});
populate[key] = isEmpty(dynamicPopulate) ? true : { on: dynamicPopulate };
}
}
}
return isEmpty(populate) ? true : { populate };
};
const DEFAULT_POPULATE_DEPTH = 5;
const getModelPopulationAttributes = (model) => {
if (model.uid === "plugin::upload.file") {
const { related, ...attributes } = model.attributes;
return attributes;
}
return model.attributes;
};
const getFullPopulateLocalazyDownloadObject = (modelUid, maxDepth = DEFAULT_POPULATE_DEPTH, ignore = ["localizations", "createdAt", "updatedAt", "publishedAt"]) => {
let localDepth = maxDepth;
if (localDepth <= 1) {
return true;
}
if (modelUid === "admin::user") {
return true;
}
const populate = {};
const model = strapi.getModel(modelUid);
if (model === void 0) {
return void 0;
}
if (ignore && !ignore.includes(model.collectionName)) ignore.push(model.collectionName);
for (const [key, value] of Object.entries(getModelPopulationAttributes(model))) {
if (ignore?.includes(key)) continue;
if (value) {
if (value.type === "component") {
populate[key] = getFullPopulateLocalazyDownloadObject(value.component, maxDepth - 1);
} else if (value.type === "dynamiczone") {
const dynamicPopulate = value.components.reduce((prev2, cur) => {
const curPopulate = getFullPopulateLocalazyDownloadObject(cur, maxDepth - 1);
return merge(prev2, { [cur]: curPopulate });
}, {});
populate[key] = isEmpty(dynamicPopulate) ? true : { on: dynamicPopulate };
} else if (value.type === "relation") {
const relationPopulate = getFullPopulateLocalazyDownloadObject(value.target, 1, ignore);
if (relationPopulate) {
populate[key] = relationPopulate;
}
} else if (value.type === "media") {
populate[key] = true;
}
}
}
return isEmpty(populate) ? true : { populate };
};
const deepPopulateHook = (event) => {
const locUploadPLevel = event.params?.locUploadPLevel;
const locDownloadPLevel = event.params?.locDownloadPLevel;
let chosen = "pLevel";
if (locUploadPLevel) {
chosen = "locUploadPLevel";
} else if (locDownloadPLevel) {
chosen = "locDownloadPLevel";
}
const eventDepth = event.params[chosen];
if (typeof eventDepth === "undefined") {
return;
}
const populateDefaultDepth = strapi.plugin(PLUGIN_NAME)?.config("populateDefaultDepth") ?? DEFAULT_POPULATE_DEPTH$1;
let depth = Math.max(eventDepth, populateDefaultDepth, 1);
const maxDepth = strapi.plugin(PLUGIN_NAME)?.config("populateMaxDepth") ?? DEFAULT_MAX_POPULATE_DEPTH;
if (depth > maxDepth) {
depth = maxDepth;
}
let modelObject;
switch (chosen) {
case "locUploadPLevel": {
modelObject = getFullPopulateLocalazyUploadObject(event.model.uid, depth);
break;
}
case "pLevel": {
modelObject = getFullPopulateObject(event.model.uid, depth);
break;
}
case "locDownloadPLevel": {
modelObject = getFullPopulateLocalazyDownloadObject(event.model.uid, depth);
break;
}
}
if (typeof modelObject !== "boolean" && modelObject !== void 0) {
event.params.populate = modelObject.populate;
}
};
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
function getDefaultExportFromCjs(x2) {
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
}
function getAugmentedNamespace(n2) {
if (n2.__esModule) return n2;
var f2 = n2.default;
if (typeof f2 == "function") {
var a2 = function a3() {
if (this instanceof a3) {
return Reflect.construct(f2, arguments, this.constructor);
}
return f2.apply(this, arguments);
};
a2.prototype = f2.prototype;
} else a2 = {};
Object.defineProperty(a2, "__esModule", { value: true });
Object.keys(n2).forEach(function(k2) {
var d2 = Object.getOwnPropertyDescriptor(n2, k2);
Object.defineProperty(a2, k2, d2.get ? d2 : {
enumerable: true,
get: function() {
return n2[k2];
}
});
});
return a2;
}
var dist$1 = { exports: {} };
var negotiator = { exports: {} };
var charset = { exports: {} };
charset.exports = preferredCharsets$1;
charset.exports.preferredCharsets = preferredCharsets$1;
var simpleCharsetRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
function parseAcceptCharset(accept) {
var accepts2 = accept.split(",");
for (var i2 = 0, j2 = 0; i2 < accepts2.length; i2++) {
var charset3 = parseCharset(accepts2[i2].trim(), i2);
if (charset3) {
accepts2[j2++] = charset3;
}
}
accepts2.length = j2;
return accepts2;
}
function parseCharset(str, i2) {
var match = simpleCharsetRegExp.exec(str);
if (!match) return null;
var charset3 = match[1];
var q2 = 1;
if (match[2]) {
var params = match[2].split(";");
for (var j2 = 0; j2 < params.length; j2++) {
var p2 = params[j2].trim().split("=");
if (p2[0] === "q") {
q2 = parseFloat(p2[1]);
break;
}
}
}
return {
charset: charset3,
q: q2,
i: i2
};
}
function getCharsetPriority(charset3, accepted, index2) {
var priority = { o: -1, q: 0, s: 0 };
for (var i2 = 0; i2 < accepted.length; i2++) {
var spec = specify$3(charset3, accepted[i2], index2);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
}
return priority;
}
function specify$3(charset3, spec, index2) {
var s2 = 0;
if (spec.charset.toLowerCase() === charset3.toLowerCase()) {
s2 |= 1;
} else if (spec.charset !== "*") {
return null;
}
return {
i: index2,
o: spec.i,
q: spec.q,
s: s2
};
}
function preferredCharsets$1(accept, provided) {
var accepts2 = parseAcceptCharset(accept === void 0 ? "*" : accept || "");
if (!provided) {
return accepts2.filter(isQuality$3).sort(compareSpecs$3).map(getFullCharset);
}
var priorities = provided.map(function getPriority(type2, index2) {
return getCharsetPriority(type2, accepts2, index2);
});
return priorities.filter(isQuality$3).sort(compareSpecs$3).map(function getCharset(priority) {
return provided[priorities.indexOf(priority)];
});
}
function compareSpecs$3(a2, b2) {
return b2.q - a2.q || b2.s - a2.s || a2.o - b2.o || a2.i - b2.i || 0;
}
function getFullCharset(spec) {
return spec.charset;
}
function isQuality$3(spec) {
return spec.q > 0;
}
var charsetExports = charset.exports;
var encoding = { exports: {} };
encoding.exports = preferredEncodings$1;
encoding.exports.preferredEncodings = preferredEncodings$1;
var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
function parseAcceptEncoding(accept) {
var accepts2 = accept.split(",");
var hasIdentity = false;
var minQuality = 1;
for (var i2 = 0, j2 = 0; i2 < accepts2.length; i2++) {
var encoding3 = parseEncoding(accepts2[i2].trim(), i2);
if (encoding3) {
accepts2[j2++] = encoding3;
hasIdentity = hasIdentity || specify$2("identity", encoding3);
minQuality = Math.min(minQuality, encoding3.q || 1);
}
}
if (!hasIdentity) {
accepts2[j2++] = {
encoding: "identity",
q: minQuality,
i: i2
};
}
accepts2.length = j2;
return accepts2;
}
function parseEncoding(str, i2) {
var match = simpleEncodingRegExp.exec(str);
if (!match) return null;
var encoding3 = match[1];
var q2 = 1;
if (match[2]) {
var params = match[2].split(";");
for (var j2 = 0; j2 < params.length; j2++) {
var p2 = params[j2].trim().split("=");
if (p2[0] === "q") {
q2 = parseFloat(p2[1]);
break;
}
}
}
return {
encoding: encoding3,
q: q2,
i: i2
};
}
function getEncodingPriority(encoding3, accepted, index2) {
var priority = { o: -1, q: 0, s: 0 };
for (var i2 = 0; i2 < accepted.length; i2++) {
var spec = specify$2(encoding3, accepted[i2], index2);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
}
return priority;
}
function specify$2(encoding3, spec, index2) {
var s2 = 0;
if (spec.encoding.toLowerCase() === encoding3.toLowerCase()) {
s2 |= 1;
} else if (spec.encoding !== "*") {
return null;
}
return {
i: index2,
o: spec.i,
q: spec.q,
s: s2
};
}
function preferredEncodings$1(accept, provided) {
var accepts2 = parseAcceptEncoding(accept || "");
if (!provided) {
return accepts2.filter(isQuality$2).sort(compareSpecs$2).map(getFullEncoding);
}
var priorities = provided.map(function getPriority(type2, index2) {
return getEncodingPriority(type2, accepts2, index2);
});
return priorities.filter(isQuality$2).sort(compareSpecs$2).map(function getEncoding(priority) {
return provided[priorities.indexOf(priority)];
});
}
function compareSpecs$2(a2, b2) {
return b2.q - a2.q || b2.s - a2.s || a2.o - b2.o || a2.i - b2.i || 0;
}
function getFullEncoding(spec) {
return spec.encoding;
}
function isQuality$2(spec) {
return spec.q > 0;
}
var encodingExports = encoding.exports;
var language = { exports: {} };
language.exports = preferredLanguages$1;
language.exports.preferredLanguages = preferredLanguages$1;
var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
function parseAcceptLanguage(accept) {
var accepts2 = accept.split(",");
for (var i2 = 0, j2 = 0; i2 < accepts2.length; i2++) {
var language3 = parseLanguage(accepts2[i2].trim(), i2);
if (language3) {
accepts2[j2++] = language3;
}
}
accepts2.length = j2;
return accepts2;
}
function parseLanguage(str, i2) {
var match = simpleLanguageRegExp.exec(str);
if (!match) return null;
var prefix = match[1];
var suffix = match[2];
var full = prefix;
if (suffix) full += "-" + suffix;
var q2 = 1;
if (match[3]) {
var params = match[3].split(";");
for (var j2 = 0; j2 < params.length; j2++) {
var p2 = params[j2].split("=");
if (p2[0] === "q") q2 = parseFloat(p2[1]);
}
}
return {
prefix,
suffix,
q: q2,
i: i2,
full
};
}
function getLanguagePriority(language3, accepted, index2) {
var priority = { o: -1, q: 0, s: 0 };
for (var i2 = 0; i2 < accepted.length; i2++) {
var spec = specify$1(language3, accepted[i2], index2);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
}
return priority;
}
function specify$1(language3, spec, index2) {
var p2 = parseLanguage(language3);
if (!p2) return null;
var s2 = 0;
if (spec.full.toLowerCase() === p2.full.toLowerCase()) {
s2 |= 4;
} else if (spec.prefix.toLowerCase() === p2.full.toLowerCase()) {
s2 |= 2;
} else if (spec.full.toLowerCase() === p2.prefix.toLowerCase()) {
s2 |= 1;
} else if (spec.full !== "*") {
return null;
}
return {
i: index2,
o: spec.i,
q: spec.q,
s: s2
};
}
function preferredLanguages$1(accept, provided) {
var accepts2 = parseAcceptLanguage(accept === void 0 ? "*" : accept || "");
if (!provided) {
return accepts2.filter(isQuality$1).sort(compareSpecs$1).map(getFullLanguage);
}
var priorities = provided.map(function getPriority(type2, index2) {
return getLanguagePriority(type2, accepts2, index2);
});
return priorities.filter(isQuality$1).sort(compareSpecs$1).map(function getLanguage(priority) {
return provided[priorities.indexOf(priority)];
});
}
function compareSpecs$1(a2, b2) {
return b2.q - a2.q || b2.s - a2.s || a2.o - b2.o || a2.i - b2.i || 0;
}
function getFullLanguage(spec) {
return spec.full;
}
function isQuality$1(spec) {
return spec.q > 0;
}
var languageExports = language.exports;
var mediaType = { exports: {} };
mediaType.exports = preferredMediaTypes$1;
mediaType.exports.preferredMediaTypes = preferredMediaTypes$1;
var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
function parseAccept(accept) {
var accepts2 = splitMediaTypes(accept);
for (var i2 = 0, j2 = 0; i2 < accepts2.length; i2++) {
var mediaType3 = parseMediaType(accepts2[i2].trim(), i2);
if (mediaType3) {
accepts2[j2++] = mediaType3;
}
}
accepts2.length = j2;
return accepts2;
}
function parseMediaType(str, i2) {
var match = simpleMediaTypeRegExp.exec(str);
if (!match) return null;
var params = /* @__PURE__ */ Object.create(null);
var q2 = 1;
var subtype = match[2];
var type2 = match[1];
if (match[3]) {
var kvps = splitParameters(match[3]).map(splitKeyValuePair);
for (var j2 = 0; j2 < kvps.length; j2++) {
var pair = kvps[j2];
var key = pair[0].toLowerCase();
var val = pair[1];
var value = val && val[0] === '"' && val[val.length - 1] === '"' ? val.substr(1, val.length - 2) : val;
if (key === "q") {
q2 = parseFloat(value);
break;
}
params[key] = value;
}
}
return {
type: type2,
subtype,
params,
q: q2,
i: i2
};
}
function getMediaTypePriority(type2, accepted, index2) {
var priority = { o: -1, q: 0, s: 0 };
for (var i2 = 0; i2 < accepted.length; i2++) {
var spec = specify(type2, accepted[i2], index2);
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
priority = spec;
}
}
return priority;
}
function specify(type2, spec, index2) {
var p2 = parseMediaType(type2);
var s2 = 0;