inferred-types 0.55.12 → 0.55.14
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/modules/inferred-types/dist/index.cjs +2083 -2067
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +13 -3
- package/modules/inferred-types/dist/index.js +2082 -2067
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +2419 -2401
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +13 -3
- package/modules/runtime/dist/index.js +2418 -2401
- package/modules/runtime/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -274,6 +274,7 @@ __export(index_exports, {
|
|
|
274
274
|
errCondition: () => errCondition,
|
|
275
275
|
filter: () => filter,
|
|
276
276
|
filterEmpty: () => filterEmpty,
|
|
277
|
+
filterUndefined: () => filterUndefined,
|
|
277
278
|
find: () => find,
|
|
278
279
|
fnMeta: () => fnMeta,
|
|
279
280
|
fromDefineObject: () => fromDefineObject,
|
|
@@ -680,7 +681,7 @@ __export(index_exports, {
|
|
|
680
681
|
twColor: () => twColor,
|
|
681
682
|
unbox: () => unbox,
|
|
682
683
|
uncapitalize: () => uncapitalize,
|
|
683
|
-
union: () =>
|
|
684
|
+
union: () => union,
|
|
684
685
|
unionize: () => unionize,
|
|
685
686
|
unique: () => unique,
|
|
686
687
|
uniqueKeys: () => uniqueKeys,
|
|
@@ -5446,10 +5447,21 @@ ${frameToCss(frames)}
|
|
|
5446
5447
|
};
|
|
5447
5448
|
}
|
|
5448
5449
|
function cssFromDefinition(defn, opt) {
|
|
5450
|
+
if (isUndefined(defn)) {
|
|
5451
|
+
return "";
|
|
5452
|
+
}
|
|
5449
5453
|
const inline = isDefined(opt?.inline) ? opt.inline : true;
|
|
5450
5454
|
const indent = isString(opt?.indent) ? opt.indent : "";
|
|
5451
5455
|
const nextDefn = inline ? " " : "\n";
|
|
5452
|
-
return Object.keys(defn).map(
|
|
5456
|
+
return Object.keys(defn).map(
|
|
5457
|
+
(key) => {
|
|
5458
|
+
const val = ensureTrailing(
|
|
5459
|
+
defn[key],
|
|
5460
|
+
";"
|
|
5461
|
+
);
|
|
5462
|
+
return `${indent}${key}: ${val}`;
|
|
5463
|
+
}
|
|
5464
|
+
).join(nextDefn);
|
|
5453
5465
|
}
|
|
5454
5466
|
function defineCss(defn) {
|
|
5455
5467
|
const fn2 = (selector) => {
|
|
@@ -5824,2526 +5836,2529 @@ var filter = "NOT READY";
|
|
|
5824
5836
|
function filterEmpty(...val) {
|
|
5825
5837
|
return val.filter((i) => isNotEmpty(i));
|
|
5826
5838
|
}
|
|
5827
|
-
function
|
|
5828
|
-
return
|
|
5829
|
-
return list2.find((i) => {
|
|
5830
|
-
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
5831
|
-
return val === comparator;
|
|
5832
|
-
});
|
|
5833
|
-
};
|
|
5834
|
-
}
|
|
5835
|
-
function getEach(list2, dotPath) {
|
|
5836
|
-
const result2 = list2.map(
|
|
5837
|
-
(i) => isNull(dotPath) ? i : isContainer(i) ? get(i, dotPath) : Never2
|
|
5838
|
-
).filter((i) => !isErrorCondition(i));
|
|
5839
|
-
return result2;
|
|
5840
|
-
}
|
|
5841
|
-
function indexOf(val, index) {
|
|
5842
|
-
const isNegative = isNumber(index) && index < 0;
|
|
5843
|
-
if (isNegative && !Array.isArray(val)) {
|
|
5844
|
-
throw new Error(`The indexOf(val,idx) utility received a negative index value [${index}] but the value being de-references is not an array [${typeof val}]!`);
|
|
5845
|
-
}
|
|
5846
|
-
if (isNegative && Array.isArray(val) && val.length < Math.abs(index)) {
|
|
5847
|
-
throw new Error(`The indexOf(val,idx) utility received a negative index of ${index} but the length of the array passed in is only ${val.length}! This is not allowed.`);
|
|
5848
|
-
}
|
|
5849
|
-
const idx = isNegative && Array.isArray(val) ? val.length + 1 - Math.abs(index) : index;
|
|
5850
|
-
return index === null ? val : isNull(idx) ? val : isArray(val) ? Number(idx) in val ? val[Number(idx)] : errCondition("invalid-index", `attempt to index a numeric array with an invalid index: ${Number(idx)}`) : isObject(val) ? String(idx) in val ? val[String(idx)] : errCondition("invalid-index", `attempt to index a dictionary object with an invalid index: ${String(idx)}`) : errCondition("invalid-container-type", `Attempt to use indexOf() on an invalid container type: ${typeof val}`);
|
|
5839
|
+
function isFunction(value) {
|
|
5840
|
+
return typeof value === "function";
|
|
5851
5841
|
}
|
|
5852
|
-
function
|
|
5853
|
-
|
|
5854
|
-
const bIndexable = b.every((i) => isIndexable(i));
|
|
5855
|
-
if (!aIndexable || !bIndexable) {
|
|
5856
|
-
if (!aIndexable) {
|
|
5857
|
-
throw new Error(`The "a" array passed into intersect(a,b) was not fully composed of indexable properties: ${a.map((i) => typeof i).join(", ")}`);
|
|
5858
|
-
} else {
|
|
5859
|
-
throw new Error(`The "b" array passed into intersect(a,b) was not fully composed of indexable properties: ${b.map((i) => typeof i).join(", ")}`);
|
|
5860
|
-
}
|
|
5861
|
-
}
|
|
5862
|
-
const aMatches = getEach(a, deref);
|
|
5863
|
-
const bMatches = getEach(b, deref);
|
|
5864
|
-
const sharedKeys2 = ifNotNull(
|
|
5865
|
-
deref,
|
|
5866
|
-
(v) => [
|
|
5867
|
-
a.filter((i) => Array.from(bMatches).includes(get(i, v))),
|
|
5868
|
-
b.filter((i) => Array.from(aMatches).includes(get(i, v)))
|
|
5869
|
-
],
|
|
5870
|
-
() => a.filter((k) => b.includes(k))
|
|
5871
|
-
);
|
|
5872
|
-
return sharedKeys2;
|
|
5842
|
+
function isObject(value) {
|
|
5843
|
+
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
5873
5844
|
}
|
|
5874
|
-
function
|
|
5875
|
-
return
|
|
5845
|
+
function isNarrowableObject(value) {
|
|
5846
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
5876
5847
|
}
|
|
5877
|
-
function
|
|
5878
|
-
return
|
|
5848
|
+
function isEscapeFunction(val) {
|
|
5849
|
+
return isFunction(val) && "escape" in val && val.escape === true;
|
|
5879
5850
|
}
|
|
5880
|
-
function
|
|
5881
|
-
return (
|
|
5882
|
-
const tup = tuple3;
|
|
5883
|
-
return tup.join(joinWith2);
|
|
5884
|
-
};
|
|
5851
|
+
function isOptionalParamFunction(val) {
|
|
5852
|
+
return isFunction(val) && "optionalParams" in val && val.optionalParams === true;
|
|
5885
5853
|
}
|
|
5886
|
-
function
|
|
5887
|
-
return
|
|
5854
|
+
function isApi(api2) {
|
|
5855
|
+
return isObject(api2) && "surface" in api2 && "_kind" in api2 && api2._kind === "api";
|
|
5888
5856
|
}
|
|
5889
|
-
function
|
|
5890
|
-
return
|
|
5891
|
-
(c) => isBoolean(c) ? c : isFunction(c) ? c() : Never2
|
|
5892
|
-
);
|
|
5857
|
+
function isApiSurface(val) {
|
|
5858
|
+
return isObject(val) && Object.keys(val).some((k) => isEscapeFunction(val[k]));
|
|
5893
5859
|
}
|
|
5894
|
-
function
|
|
5895
|
-
return
|
|
5860
|
+
function isDate(val) {
|
|
5861
|
+
return val instanceof Date;
|
|
5896
5862
|
}
|
|
5897
|
-
function
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
rtn = list2.length === 0 ? void 0 : list2[0];
|
|
5901
|
-
try {
|
|
5902
|
-
list2 = list2.slice(1);
|
|
5903
|
-
} catch {
|
|
5904
|
-
}
|
|
5905
|
-
} else {
|
|
5906
|
-
rtn = void 0;
|
|
5863
|
+
function isIsoDateTime(val) {
|
|
5864
|
+
if (!isString(val)) {
|
|
5865
|
+
return false;
|
|
5907
5866
|
}
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
return list2.slice(start2, end);
|
|
5912
|
-
}
|
|
5913
|
-
function unique(...values) {
|
|
5914
|
-
const u = [];
|
|
5915
|
-
for (const i of values.flat()) {
|
|
5916
|
-
if (!u.includes(i)) {
|
|
5917
|
-
u.push(i);
|
|
5918
|
-
}
|
|
5867
|
+
const ISO_DATETIME_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
5868
|
+
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
5869
|
+
return false;
|
|
5919
5870
|
}
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5871
|
+
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
5872
|
+
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
5873
|
+
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
5874
|
+
return false;
|
|
5875
|
+
}
|
|
5876
|
+
if (month < 1 || month > 12) {
|
|
5877
|
+
return false;
|
|
5878
|
+
}
|
|
5879
|
+
;
|
|
5880
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
5881
|
+
if (day < 1 || day > daysInMonth) {
|
|
5882
|
+
return false;
|
|
5883
|
+
}
|
|
5884
|
+
;
|
|
5885
|
+
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
5886
|
+
if (tzMatch) {
|
|
5887
|
+
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
5888
|
+
const numHours = Number.parseInt(tzHours, 10);
|
|
5889
|
+
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
5890
|
+
if (numHours > 14 || numMinutes > 59) {
|
|
5891
|
+
return false;
|
|
5928
5892
|
}
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
}
|
|
5932
|
-
|
|
5933
|
-
return
|
|
5893
|
+
if (numHours === 14 && numMinutes > 0) {
|
|
5894
|
+
return false;
|
|
5895
|
+
}
|
|
5896
|
+
}
|
|
5897
|
+
return true;
|
|
5934
5898
|
}
|
|
5935
|
-
function
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
(
|
|
5939
|
-
|
|
5940
|
-
|
|
5899
|
+
function isIsoExplicitDate(val) {
|
|
5900
|
+
if (isString(val)) {
|
|
5901
|
+
const parts = val.split("-").map((i) => Number(i));
|
|
5902
|
+
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
5903
|
+
} else {
|
|
5904
|
+
return false;
|
|
5905
|
+
}
|
|
5941
5906
|
}
|
|
5942
|
-
function
|
|
5943
|
-
|
|
5907
|
+
function isIsoImplicitDate(val) {
|
|
5908
|
+
if (isString(val) && val.length === 8 && isNumberLike(val)) {
|
|
5909
|
+
const year = Number(val.slice(0, 4));
|
|
5910
|
+
const month = Number(val.slice(4, 6));
|
|
5911
|
+
const date = Number(val.slice(6, 8));
|
|
5912
|
+
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
5913
|
+
} else {
|
|
5914
|
+
return false;
|
|
5915
|
+
}
|
|
5944
5916
|
}
|
|
5945
|
-
function
|
|
5946
|
-
|
|
5917
|
+
function isIsoDate(val) {
|
|
5918
|
+
if (isString(val)) {
|
|
5919
|
+
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
5920
|
+
} else {
|
|
5921
|
+
return false;
|
|
5922
|
+
}
|
|
5947
5923
|
}
|
|
5948
|
-
function
|
|
5949
|
-
|
|
5924
|
+
function isIsoExplicitTime(val) {
|
|
5925
|
+
if (isString(val)) {
|
|
5926
|
+
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
5927
|
+
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5928
|
+
} else {
|
|
5929
|
+
return false;
|
|
5930
|
+
}
|
|
5950
5931
|
}
|
|
5951
|
-
function
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5932
|
+
function isIsoImplicitTime(val) {
|
|
5933
|
+
if (isString(val)) {
|
|
5934
|
+
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
5935
|
+
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5936
|
+
} else {
|
|
5937
|
+
return false;
|
|
5938
|
+
}
|
|
5956
5939
|
}
|
|
5957
|
-
function
|
|
5958
|
-
|
|
5959
|
-
return output.startsWith(String(ensure)) ? content : isString(content) ? `${ensure}${content}` : Number(`${ensure}${content}`);
|
|
5940
|
+
function isIsoTime(val) {
|
|
5941
|
+
return isIsoExplicitTime(val) || isIsoImplicitTime(val);
|
|
5960
5942
|
}
|
|
5961
|
-
function
|
|
5962
|
-
|
|
5963
|
-
let result2 = input;
|
|
5964
|
-
result2 = ensureLeading(result2, prefix);
|
|
5965
|
-
result2 = ensureTrailing(result2, postfix);
|
|
5966
|
-
return result2;
|
|
5967
|
-
};
|
|
5968
|
-
return fn2;
|
|
5943
|
+
function isIsoYear(val) {
|
|
5944
|
+
return !!(isString(val) && val.length === 4 && isNumber(Number(val)) && Number(val) >= 0 && Number(val) <= 9999);
|
|
5969
5945
|
}
|
|
5970
|
-
function
|
|
5971
|
-
return (
|
|
5972
|
-
//
|
|
5973
|
-
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
5974
|
-
);
|
|
5946
|
+
function isLuxonDateTime(val) {
|
|
5947
|
+
return isObject(val) && typeof val === "object" && val !== null && "isValid" in val && "invalidReason" in val && "invalidExplanation" in val && "toISO" in val && "toFormat" in val && "toMillis" in val && "year" in val && "month" in val && "day" in val && "hour" in val && "minute" in val && "second" in val && "millisecond" in val && typeof val.isValid === "boolean" && typeof val.toISO === "function";
|
|
5975
5948
|
}
|
|
5976
|
-
function
|
|
5977
|
-
if (
|
|
5978
|
-
|
|
5979
|
-
return [t, st];
|
|
5980
|
-
} else {
|
|
5981
|
-
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
5982
|
-
err.name = "InvalidTypeSubtype";
|
|
5983
|
-
throw err;
|
|
5949
|
+
function isMoment(val) {
|
|
5950
|
+
if (val instanceof Date) {
|
|
5951
|
+
return false;
|
|
5984
5952
|
}
|
|
5953
|
+
return isObject(val) && typeof val.format === "function" && typeof val.year === "function" && typeof val.month === "function" && typeof val.date === "function" && "_isAMomentObject" in val && "_isValid" in val && typeof val.add === "function" && typeof val.subtract === "function" && typeof val.toISOString === "function" && typeof val.isValid === "function";
|
|
5985
5954
|
}
|
|
5986
|
-
function
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
if (
|
|
5991
|
-
|
|
5955
|
+
function isThisMonth(val) {
|
|
5956
|
+
const now = /* @__PURE__ */ new Date();
|
|
5957
|
+
const currentYear = now.getFullYear();
|
|
5958
|
+
const currentMonth = now.getMonth() + 1;
|
|
5959
|
+
if (val instanceof Date) {
|
|
5960
|
+
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
5992
5961
|
}
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
if (ch.length !== 1) {
|
|
5997
|
-
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
5962
|
+
if (isMoment(val)) {
|
|
5963
|
+
const monthValue = val.month();
|
|
5964
|
+
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
5998
5965
|
}
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
function parseTemplate(template) {
|
|
6002
|
-
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
6003
|
-
let lastIndex = 0;
|
|
6004
|
-
let match;
|
|
6005
|
-
const segments = [];
|
|
6006
|
-
while (match = pattern.exec(template)) {
|
|
6007
|
-
const [fullMatch, varName, asType2] = match;
|
|
6008
|
-
const staticPart = template.slice(lastIndex, match.index);
|
|
6009
|
-
if (staticPart) {
|
|
6010
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
6011
|
-
}
|
|
6012
|
-
segments.push({
|
|
6013
|
-
dynamic: true,
|
|
6014
|
-
varName,
|
|
6015
|
-
type: asType2 ? asType2 : "string"
|
|
6016
|
-
});
|
|
6017
|
-
lastIndex = match.index + fullMatch.length;
|
|
5966
|
+
if (isLuxonDateTime(val)) {
|
|
5967
|
+
return val.year === currentYear && val.month === currentMonth;
|
|
6018
5968
|
}
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
5969
|
+
if (typeof val === "string") {
|
|
5970
|
+
const isoDateRegex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(?:T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[-+][01]\d:[0-5]\d))?$/;
|
|
5971
|
+
if (!isoDateRegex.test(val)) {
|
|
5972
|
+
return false;
|
|
5973
|
+
}
|
|
5974
|
+
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
5975
|
+
if (dateMatch) {
|
|
5976
|
+
const year = Number.parseInt(dateMatch[1], 10);
|
|
5977
|
+
const month = Number.parseInt(dateMatch[2], 10);
|
|
5978
|
+
return year === currentYear && month === currentMonth;
|
|
5979
|
+
}
|
|
6022
5980
|
}
|
|
6023
|
-
return
|
|
5981
|
+
return false;
|
|
6024
5982
|
}
|
|
6025
|
-
function
|
|
6026
|
-
|
|
5983
|
+
function isThisWeek(date) {
|
|
5984
|
+
const targetDate = asDate(date);
|
|
5985
|
+
if (!targetDate) {
|
|
5986
|
+
return false;
|
|
5987
|
+
}
|
|
5988
|
+
const currentWeek = getWeekNumber();
|
|
5989
|
+
const targetWeek = getWeekNumber(targetDate);
|
|
5990
|
+
return currentWeek === targetWeek;
|
|
6027
5991
|
}
|
|
6028
|
-
function
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
5992
|
+
function isThisYear(val) {
|
|
5993
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
5994
|
+
if (isObject(val) || isNumber(val) || isString(val)) {
|
|
5995
|
+
const date = asDate(val);
|
|
5996
|
+
if (date) {
|
|
5997
|
+
return date.getFullYear() === currentYear;
|
|
6033
5998
|
} else {
|
|
6034
|
-
|
|
6035
|
-
case "string":
|
|
6036
|
-
regexStr += "(.*?)";
|
|
6037
|
-
break;
|
|
6038
|
-
case "number":
|
|
6039
|
-
regexStr += "(\\d+)";
|
|
6040
|
-
break;
|
|
6041
|
-
case "boolean":
|
|
6042
|
-
regexStr += "(true|false)";
|
|
6043
|
-
break;
|
|
6044
|
-
}
|
|
5999
|
+
return false;
|
|
6045
6000
|
}
|
|
6046
6001
|
}
|
|
6047
|
-
|
|
6048
|
-
return new RegExp(regexStr);
|
|
6002
|
+
return false;
|
|
6049
6003
|
}
|
|
6050
|
-
function
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6004
|
+
function isToday(test) {
|
|
6005
|
+
if (isString(test)) {
|
|
6006
|
+
const justDate = stripAfter(test, "T");
|
|
6007
|
+
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
6008
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6009
|
+
return stripAfter(test.toISOString(), "T") === getToday();
|
|
6010
|
+
} else if (isLuxonDateTime(test)) {
|
|
6011
|
+
return stripAfter(test.toISO(), "T") === getToday();
|
|
6058
6012
|
}
|
|
6013
|
+
return false;
|
|
6059
6014
|
}
|
|
6060
|
-
function
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
if (
|
|
6065
|
-
return
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
for (const seg of segments) {
|
|
6069
|
-
if (seg.dynamic) {
|
|
6070
|
-
const rawVal = match[captureIndex++];
|
|
6071
|
-
if (rawVal === void 0)
|
|
6072
|
-
return false;
|
|
6073
|
-
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
6074
|
-
}
|
|
6015
|
+
function isTomorrow(test) {
|
|
6016
|
+
if (isString(test)) {
|
|
6017
|
+
const justDate = stripAfter(test, "T");
|
|
6018
|
+
return isIsoExplicitDate(justDate) && justDate === getTomorrow();
|
|
6019
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6020
|
+
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
6021
|
+
} else if (isLuxonDateTime(test)) {
|
|
6022
|
+
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
6075
6023
|
}
|
|
6076
|
-
return
|
|
6024
|
+
return false;
|
|
6077
6025
|
}
|
|
6078
|
-
function
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6026
|
+
function isYesterday(test) {
|
|
6027
|
+
if (isString(test)) {
|
|
6028
|
+
const justDate = stripAfter(test, "T");
|
|
6029
|
+
return isIsoExplicitDate(justDate) && justDate === getYesterday();
|
|
6030
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6031
|
+
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
6032
|
+
} else if (isLuxonDateTime(test)) {
|
|
6033
|
+
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
6034
|
+
}
|
|
6035
|
+
return false;
|
|
6082
6036
|
}
|
|
6083
|
-
function
|
|
6084
|
-
|
|
6037
|
+
function isVisa(val) {
|
|
6038
|
+
if (isString(val) && val.startsWith("4")) {
|
|
6039
|
+
const parts = val.split(" ");
|
|
6040
|
+
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
|
|
6041
|
+
}
|
|
6042
|
+
return false;
|
|
6085
6043
|
}
|
|
6086
|
-
function
|
|
6087
|
-
|
|
6044
|
+
function isMastercard(val) {
|
|
6045
|
+
if (isString(val) && val.startsWith("4")) {
|
|
6046
|
+
const parts = val.split(" ");
|
|
6047
|
+
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4) && ["51", "55", "22", "23", "24", "25", "26", "27"].some((i) => val.startsWith(i));
|
|
6048
|
+
}
|
|
6049
|
+
return false;
|
|
6088
6050
|
}
|
|
6089
|
-
function
|
|
6090
|
-
return
|
|
6051
|
+
function isVisaMastercard(val) {
|
|
6052
|
+
return isVisa(val) || isMastercard(val);
|
|
6091
6053
|
}
|
|
6092
|
-
function
|
|
6093
|
-
|
|
6054
|
+
function isAmericanExpress(val) {
|
|
6055
|
+
if (isString(val)) {
|
|
6056
|
+
const parts = val.split(" ");
|
|
6057
|
+
return parts.length === 3 && parts.every(
|
|
6058
|
+
(i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
|
|
6059
|
+
);
|
|
6060
|
+
}
|
|
6061
|
+
return false;
|
|
6094
6062
|
}
|
|
6095
|
-
function
|
|
6096
|
-
return
|
|
6063
|
+
function isCreditCard(val) {
|
|
6064
|
+
return isVisaMastercard(val) || isAmericanExpress(val);
|
|
6097
6065
|
}
|
|
6098
|
-
function
|
|
6099
|
-
|
|
6066
|
+
function cardType(cardNumber) {
|
|
6067
|
+
const cleanedNumber = String(cardNumber).replace(/\D/g, "");
|
|
6068
|
+
const length = cleanedNumber.length;
|
|
6069
|
+
if (!isValidLength(length)) {
|
|
6070
|
+
return "invalid";
|
|
6071
|
+
}
|
|
6072
|
+
if (!luhnCheck(cleanedNumber)) {
|
|
6073
|
+
return "invalid";
|
|
6074
|
+
}
|
|
6075
|
+
const cardTypes = [
|
|
6076
|
+
{ name: "Visa", lengths: [16], prefixes: [/^4/] },
|
|
6077
|
+
{ name: "Mastercard", lengths: [16], prefixes: [/^(51|52|53|54|55|222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)/] },
|
|
6078
|
+
{ name: "American Express", lengths: [15], prefixes: [/^3[47]/] },
|
|
6079
|
+
{ name: "Discover", lengths: [16], prefixes: [/^(6011|622(12[6-9]|1[3-9]\d|2[0-4]\d|25\d|6[4-9]|7[0-4]|8[0-4]|9\d)|64[4-9]|65)/] },
|
|
6080
|
+
{ name: "JCB", lengths: [16], prefixes: [/^(35|2131|1800)/] },
|
|
6081
|
+
{ name: "Diners Club", lengths: [14, 16], prefixes: [/^(30[0-5]|36|38)/] },
|
|
6082
|
+
{ name: "China UnionPay", lengths: [16, 17, 18, 19], prefixes: [/^(62|88)/] },
|
|
6083
|
+
{ name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
|
|
6084
|
+
{ name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
|
|
6085
|
+
];
|
|
6086
|
+
for (const type of cardTypes) {
|
|
6087
|
+
if (type.lengths.includes(length)) {
|
|
6088
|
+
for (const prefix of type.prefixes) {
|
|
6089
|
+
if (prefix.test(cleanedNumber)) {
|
|
6090
|
+
return type.name;
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6095
|
+
return "invalid";
|
|
6100
6096
|
}
|
|
6101
|
-
function
|
|
6102
|
-
|
|
6097
|
+
function isValidLength(length) {
|
|
6098
|
+
const validLengths = [13, 14, 15, 16, 17, 18, 19];
|
|
6099
|
+
return validLengths.includes(length);
|
|
6103
6100
|
}
|
|
6104
|
-
function
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6101
|
+
function luhnCheck(num) {
|
|
6102
|
+
let sum = 0;
|
|
6103
|
+
let double = false;
|
|
6104
|
+
for (let i = num.length - 1; i >= 0; i--) {
|
|
6105
|
+
let n = Number.parseInt(num.charAt(i), 10);
|
|
6106
|
+
if (double) {
|
|
6107
|
+
n *= 2;
|
|
6108
|
+
if (n > 9) {
|
|
6109
|
+
n -= 9;
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
sum += n;
|
|
6113
|
+
double = !double;
|
|
6114
|
+
}
|
|
6115
|
+
return sum % 10 === 0;
|
|
6110
6116
|
}
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
6114
|
-
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
6115
|
-
...NUMERIC_CHAR2
|
|
6116
|
-
) : "";
|
|
6117
|
+
function isString(value) {
|
|
6118
|
+
return typeof value === "string";
|
|
6117
6119
|
}
|
|
6118
|
-
function
|
|
6119
|
-
const
|
|
6120
|
-
return
|
|
6121
|
-
phone.trim(),
|
|
6122
|
-
"+",
|
|
6123
|
-
"00"
|
|
6124
|
-
), countryCode).trim() : phone.trim();
|
|
6120
|
+
function isIso3166Alpha2(val) {
|
|
6121
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
6122
|
+
return isString(val) && codes.includes(val);
|
|
6125
6123
|
}
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
case "is":
|
|
6130
|
-
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
6131
|
-
case "singular-noun":
|
|
6132
|
-
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
6133
|
-
case "f":
|
|
6134
|
-
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
6135
|
-
case "y":
|
|
6136
|
-
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
6137
|
-
default:
|
|
6138
|
-
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
6139
|
-
}
|
|
6124
|
+
function isCountryCode2(val) {
|
|
6125
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
6126
|
+
return isString(val) && codes.includes(val);
|
|
6140
6127
|
}
|
|
6141
|
-
function
|
|
6142
|
-
const
|
|
6143
|
-
|
|
6144
|
-
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
6145
|
-
return `${result2}${right}`;
|
|
6146
|
-
}
|
|
6147
|
-
function retainAfter(content, ...find2) {
|
|
6148
|
-
const idx = Math.min(
|
|
6149
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6150
|
-
);
|
|
6151
|
-
const min = Math.min(...find2.map((i) => i.length));
|
|
6152
|
-
let len = Math.max(...find2.map((i) => i.length));
|
|
6153
|
-
if (min !== len) {
|
|
6154
|
-
if (!find2.includes(content.slice(idx, len))) {
|
|
6155
|
-
len = min;
|
|
6156
|
-
}
|
|
6157
|
-
}
|
|
6158
|
-
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
6128
|
+
function isIso3166Alpha3(val) {
|
|
6129
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
6130
|
+
return isString(val) && codes.includes(val);
|
|
6159
6131
|
}
|
|
6160
|
-
function
|
|
6161
|
-
const
|
|
6162
|
-
|
|
6163
|
-
);
|
|
6164
|
-
return minFound > 0 ? content.slice(minFound) : "";
|
|
6132
|
+
function isCountryCode3(val) {
|
|
6133
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
6134
|
+
return isString(val) && codes.includes(val);
|
|
6165
6135
|
}
|
|
6166
|
-
function
|
|
6167
|
-
const
|
|
6168
|
-
return
|
|
6136
|
+
function isIso3166CountryCode(val) {
|
|
6137
|
+
const codes = ISO3166_12.map((i) => i.countryCode);
|
|
6138
|
+
return isString(val) && codes.includes(val);
|
|
6169
6139
|
}
|
|
6170
|
-
function
|
|
6171
|
-
|
|
6172
|
-
let idx = 0;
|
|
6173
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6174
|
-
idx = idx + 1;
|
|
6175
|
-
}
|
|
6176
|
-
return idx === 0 ? "" : content.slice(0, idx);
|
|
6140
|
+
function isCountryAbbrev(val) {
|
|
6141
|
+
return isCountryCode2(val) || isCountryCode3(val);
|
|
6177
6142
|
}
|
|
6178
|
-
function
|
|
6179
|
-
const
|
|
6180
|
-
|
|
6181
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6182
|
-
idx = idx + 1;
|
|
6183
|
-
}
|
|
6184
|
-
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
6143
|
+
function isIso3166CountryName(val) {
|
|
6144
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
6145
|
+
return isString(val) && codes.includes(val);
|
|
6185
6146
|
}
|
|
6186
|
-
function
|
|
6187
|
-
const
|
|
6188
|
-
return
|
|
6147
|
+
function isCountryName(val) {
|
|
6148
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
6149
|
+
return isString(val) && codes.includes(val);
|
|
6189
6150
|
}
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
...WHITESPACE_CHARS2
|
|
6195
|
-
);
|
|
6151
|
+
var ABBREV = US_STATE_LOOKUP2.map((i) => i.abbrev);
|
|
6152
|
+
var NAME = US_STATE_LOOKUP2.map((i) => i.name);
|
|
6153
|
+
function isUsStateAbbreviation(val) {
|
|
6154
|
+
return isString(val) && ABBREV.includes(val);
|
|
6196
6155
|
}
|
|
6197
|
-
function
|
|
6198
|
-
return
|
|
6156
|
+
function isUsStateName(val) {
|
|
6157
|
+
return isString(val) && NAME.includes(val);
|
|
6199
6158
|
}
|
|
6200
|
-
function
|
|
6201
|
-
|
|
6159
|
+
function isNumericString(value) {
|
|
6160
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
6161
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
6202
6162
|
}
|
|
6203
|
-
function
|
|
6204
|
-
|
|
6163
|
+
function isNumberLike(value) {
|
|
6164
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
6165
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i)) ? true : typeof value === "number";
|
|
6205
6166
|
}
|
|
6206
|
-
function
|
|
6207
|
-
|
|
6208
|
-
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
6167
|
+
function isNumber(value) {
|
|
6168
|
+
return typeof value === "number";
|
|
6209
6169
|
}
|
|
6210
|
-
function
|
|
6211
|
-
if (
|
|
6212
|
-
return
|
|
6213
|
-
}
|
|
6214
|
-
let output = String(content);
|
|
6215
|
-
for (const s of strip2) {
|
|
6216
|
-
if (output.startsWith(String(s))) {
|
|
6217
|
-
output = output.slice(String(s).length);
|
|
6218
|
-
}
|
|
6170
|
+
function isZipCode5(val) {
|
|
6171
|
+
if (isNumber(val)) {
|
|
6172
|
+
return isZipCode5(`${val}`);
|
|
6219
6173
|
}
|
|
6220
|
-
return
|
|
6221
|
-
}
|
|
6222
|
-
function stripSurround(...chars) {
|
|
6223
|
-
return (input) => {
|
|
6224
|
-
let output = String(input);
|
|
6225
|
-
for (const s of chars) {
|
|
6226
|
-
if (output.startsWith(String(s))) {
|
|
6227
|
-
output = output.slice(String(s).length);
|
|
6228
|
-
}
|
|
6229
|
-
if (output.endsWith(String(s))) {
|
|
6230
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6231
|
-
}
|
|
6232
|
-
}
|
|
6233
|
-
return isNumber(input) ? Number(output) : output;
|
|
6234
|
-
};
|
|
6174
|
+
return isString(val) && val.trim().length === 5 && isNumberLike(val.trim());
|
|
6235
6175
|
}
|
|
6236
|
-
function
|
|
6237
|
-
if (
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
for (const s of strip2) {
|
|
6242
|
-
if (output.endsWith(String(s))) {
|
|
6243
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6244
|
-
}
|
|
6176
|
+
function isZipPlus4(val) {
|
|
6177
|
+
if (isString(val)) {
|
|
6178
|
+
const first = retainWhile(val.trim(), ...NUMERIC_CHAR2);
|
|
6179
|
+
const next = stripChars(val.trim().replace(first, "").trim(), "-");
|
|
6180
|
+
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
6245
6181
|
}
|
|
6246
|
-
return
|
|
6182
|
+
return false;
|
|
6247
6183
|
}
|
|
6248
|
-
function
|
|
6249
|
-
|
|
6250
|
-
return content.slice(stopIdx);
|
|
6184
|
+
function isZipCode(val) {
|
|
6185
|
+
return isZipCode5(val) || isZipPlus4(val);
|
|
6251
6186
|
}
|
|
6252
|
-
function
|
|
6253
|
-
|
|
6254
|
-
|
|
6187
|
+
function isSpecificConstant(kind) {
|
|
6188
|
+
return (value) => {
|
|
6189
|
+
return !!(isConstant(value) && value.kind === kind);
|
|
6190
|
+
};
|
|
6255
6191
|
}
|
|
6256
|
-
function
|
|
6257
|
-
|
|
6192
|
+
function hasDefaultValue(value) {
|
|
6193
|
+
const noDefault = isSpecificConstant("no-default-value");
|
|
6194
|
+
return !noDefault(value);
|
|
6258
6195
|
}
|
|
6259
|
-
function
|
|
6260
|
-
const
|
|
6261
|
-
return
|
|
6196
|
+
function hasIndexOf(value, idx) {
|
|
6197
|
+
const result2 = isObject(value) ? String(idx) in value : Array.isArray(value) ? Number(idx) in value : false;
|
|
6198
|
+
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
6262
6199
|
}
|
|
6263
|
-
function
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
6269
|
-
return camel;
|
|
6200
|
+
function hasKeys(...props) {
|
|
6201
|
+
return (val) => {
|
|
6202
|
+
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
6203
|
+
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
6204
|
+
};
|
|
6270
6205
|
}
|
|
6271
|
-
function
|
|
6272
|
-
|
|
6273
|
-
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
6274
|
-
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
6275
|
-
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
6276
|
-
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
6277
|
-
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
6278
|
-
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
6279
|
-
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
6280
|
-
replaceTrailingDash(
|
|
6281
|
-
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
6282
|
-
)
|
|
6283
|
-
)}${postWhite}`);
|
|
6206
|
+
function asChars(str) {
|
|
6207
|
+
return str.split("");
|
|
6284
6208
|
}
|
|
6285
|
-
function
|
|
6286
|
-
return
|
|
6209
|
+
function asRecord(obj) {
|
|
6210
|
+
return obj;
|
|
6287
6211
|
}
|
|
6288
|
-
function
|
|
6289
|
-
|
|
6290
|
-
input
|
|
6291
|
-
);
|
|
6292
|
-
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
6293
|
-
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
6294
|
-
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
6295
|
-
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
6296
|
-
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
6297
|
-
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
6298
|
-
)}${preserveWhitespace ? postWhite : ""}`;
|
|
6299
|
-
return pascal;
|
|
6212
|
+
function asString(value) {
|
|
6213
|
+
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
6300
6214
|
}
|
|
6301
|
-
function
|
|
6302
|
-
const
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
6215
|
+
function csv(csv2, format = `string-numeric-tuple`) {
|
|
6216
|
+
const tuple3 = [];
|
|
6217
|
+
csv2.split(/,\s?/).forEach((v) => {
|
|
6218
|
+
tuple3.push(
|
|
6219
|
+
format === "string-numeric-tuple" ? isNumberLike(v) ? Number(v) : v : format === "json-tuple" ? isNumberLike(v) ? Number(v) : v === "true" ? true : v === "false" ? false : `"${v}"` : format === "string-tuple" ? `${v}` : Never2
|
|
6220
|
+
);
|
|
6221
|
+
});
|
|
6222
|
+
return tuple3;
|
|
6310
6223
|
}
|
|
6311
|
-
function
|
|
6312
|
-
|
|
6224
|
+
function fromKeyValue(kvs) {
|
|
6225
|
+
const obj = {};
|
|
6226
|
+
for (const kv of kvs) {
|
|
6227
|
+
obj[kv.key] = kv.value;
|
|
6228
|
+
}
|
|
6229
|
+
return obj;
|
|
6313
6230
|
}
|
|
6314
|
-
function
|
|
6315
|
-
return
|
|
6231
|
+
function intersect(value, _intersectedWith) {
|
|
6232
|
+
return value;
|
|
6316
6233
|
}
|
|
6317
|
-
function
|
|
6318
|
-
return
|
|
6234
|
+
function ip6GroupExpansion(ip) {
|
|
6235
|
+
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
6319
6236
|
}
|
|
6320
|
-
function
|
|
6321
|
-
return
|
|
6237
|
+
function jsonValue(val) {
|
|
6238
|
+
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
6322
6239
|
}
|
|
6323
|
-
function
|
|
6324
|
-
return
|
|
6240
|
+
function jsonValues(...val) {
|
|
6241
|
+
return val.map((i) => jsonValue(i));
|
|
6325
6242
|
}
|
|
6326
|
-
function
|
|
6327
|
-
|
|
6243
|
+
function lookupAlpha2Code(code, prop) {
|
|
6244
|
+
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
6245
|
+
return found ? found[prop] : void 0;
|
|
6328
6246
|
}
|
|
6329
|
-
function
|
|
6330
|
-
|
|
6247
|
+
function lookupAlpha3Code(code, prop) {
|
|
6248
|
+
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
6249
|
+
return found ? found[prop] : void 0;
|
|
6331
6250
|
}
|
|
6332
|
-
function
|
|
6333
|
-
const
|
|
6334
|
-
return
|
|
6251
|
+
function lookupName(name, prop) {
|
|
6252
|
+
const found = ISO3166_12.find((i) => i.name === name);
|
|
6253
|
+
return found ? found[prop] : void 0;
|
|
6335
6254
|
}
|
|
6336
|
-
function
|
|
6337
|
-
|
|
6338
|
-
|
|
6255
|
+
function lookupNumericCode(code, prop) {
|
|
6256
|
+
let num = isNumber(code) ? `${code}` : code;
|
|
6257
|
+
if (num.length === 1) {
|
|
6258
|
+
num = `00${num}`;
|
|
6259
|
+
} else if (num.length === 2) {
|
|
6260
|
+
num = `0${num}`;
|
|
6261
|
+
}
|
|
6262
|
+
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
6263
|
+
return found ? found[prop] : void 0;
|
|
6339
6264
|
}
|
|
6340
|
-
function
|
|
6341
|
-
|
|
6265
|
+
function lookupCountryName(code) {
|
|
6266
|
+
const uc = uppercase(code);
|
|
6267
|
+
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
6342
6268
|
}
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
return
|
|
6269
|
+
function lookupCountryAlpha2(code) {
|
|
6270
|
+
const uc = uppercase(code);
|
|
6271
|
+
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
6346
6272
|
}
|
|
6347
|
-
function
|
|
6348
|
-
|
|
6273
|
+
function lookupCountryAlpha3(token) {
|
|
6274
|
+
const uc = uppercase(token);
|
|
6275
|
+
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
6349
6276
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
return proto;
|
|
6277
|
+
function lookupCountryCode(token) {
|
|
6278
|
+
const uc = uppercase(token);
|
|
6279
|
+
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
6354
6280
|
}
|
|
6355
|
-
function
|
|
6356
|
-
|
|
6281
|
+
function asMapper(fn2) {
|
|
6282
|
+
const props = {
|
|
6283
|
+
kind: "Mapper",
|
|
6284
|
+
map: (from) => {
|
|
6285
|
+
return from.map(fn2);
|
|
6286
|
+
}
|
|
6287
|
+
};
|
|
6288
|
+
return createFnWithPropsExplicit(fn2, props);
|
|
6357
6289
|
}
|
|
6358
|
-
function
|
|
6359
|
-
|
|
6360
|
-
|
|
6290
|
+
function createObjectMap() {
|
|
6291
|
+
return (map2) => {
|
|
6292
|
+
const fn2 = (input) => {
|
|
6293
|
+
return Object.keys(map2).reduce(
|
|
6294
|
+
(acc, key) => {
|
|
6295
|
+
const val = map2[key];
|
|
6296
|
+
return {
|
|
6297
|
+
...acc,
|
|
6298
|
+
[key]: isFunction(val) ? val(input) : val
|
|
6299
|
+
};
|
|
6300
|
+
},
|
|
6301
|
+
{}
|
|
6302
|
+
);
|
|
6303
|
+
};
|
|
6304
|
+
return fn2;
|
|
6305
|
+
};
|
|
6361
6306
|
}
|
|
6362
|
-
function
|
|
6363
|
-
return
|
|
6364
|
-
|
|
6365
|
-
|
|
6307
|
+
function createMapper() {
|
|
6308
|
+
return (fn2) => {
|
|
6309
|
+
return asMapper(fn2);
|
|
6310
|
+
};
|
|
6366
6311
|
}
|
|
6367
|
-
function
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
stripBefore(qp, `${specific}=`),
|
|
6373
|
-
"&"
|
|
6374
|
-
).replace(/\+/g, "%20")
|
|
6375
|
-
) : void 0;
|
|
6376
|
-
}
|
|
6377
|
-
return qp === "" ? qp : `?${qp}`;
|
|
6312
|
+
function mergeObjects(defVal, override) {
|
|
6313
|
+
return {
|
|
6314
|
+
...defVal,
|
|
6315
|
+
...override
|
|
6316
|
+
};
|
|
6378
6317
|
}
|
|
6379
|
-
function
|
|
6380
|
-
|
|
6381
|
-
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
6318
|
+
function isUndefined(value) {
|
|
6319
|
+
return typeof value === "undefined";
|
|
6382
6320
|
}
|
|
6383
|
-
function
|
|
6384
|
-
|
|
6385
|
-
const match = url.match(re);
|
|
6386
|
-
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
6321
|
+
function mergeScalars(a, b) {
|
|
6322
|
+
return isUndefined(b) ? a : b;
|
|
6387
6323
|
}
|
|
6388
|
-
function
|
|
6389
|
-
|
|
6390
|
-
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
6324
|
+
function mergeTuples(a, b) {
|
|
6325
|
+
return b.length > a.length ? b.map((v, idx) => v !== void 0 ? v : a[idx]) : [...b, ...a.slice(b.length)].map((v, idx) => v !== void 0 ? v : a[idx]);
|
|
6391
6326
|
}
|
|
6392
|
-
function
|
|
6393
|
-
|
|
6394
|
-
const remaining = stripAfter(url, path);
|
|
6395
|
-
return remaining;
|
|
6327
|
+
function never(val) {
|
|
6328
|
+
return val;
|
|
6396
6329
|
}
|
|
6397
|
-
function
|
|
6398
|
-
|
|
6399
|
-
const qp = getUrlQueryParams(url);
|
|
6400
|
-
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
6401
|
-
const segmentTypes = [
|
|
6402
|
-
"string",
|
|
6403
|
-
"number",
|
|
6404
|
-
"boolean",
|
|
6405
|
-
"Opt<string>",
|
|
6406
|
-
"Opt<number>",
|
|
6407
|
-
"Opt<boolean>"
|
|
6408
|
-
];
|
|
6409
|
-
const pathVars = {};
|
|
6410
|
-
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
6411
|
-
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
6412
|
-
const findPathNamed = infer(`<{{infer name}}>`);
|
|
6413
|
-
for (const part of pathParts) {
|
|
6414
|
-
const union4 = findPathUnion(part);
|
|
6415
|
-
const typed = findPathTyped(part);
|
|
6416
|
-
const named = findPathNamed(part);
|
|
6417
|
-
if (union4) {
|
|
6418
|
-
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
6419
|
-
pathVars[union4.name] = `string(${union4.union})`;
|
|
6420
|
-
}
|
|
6421
|
-
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
6422
|
-
pathVars[typed.name] = typed.type;
|
|
6423
|
-
} else if (named && isVariable(named.name)) {
|
|
6424
|
-
pathVars[named.name] = "string";
|
|
6425
|
-
}
|
|
6426
|
-
}
|
|
6427
|
-
const qpVars = {};
|
|
6428
|
-
const qpParts = stripLeading(qp, "?").split("&");
|
|
6429
|
-
for (const p of qpParts) {
|
|
6430
|
-
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
6431
|
-
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
6432
|
-
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
6433
|
-
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
6434
|
-
qpVars[union4.var] = `string(${union4.params})`;
|
|
6435
|
-
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
6436
|
-
qpVars[dynamic.var] = dynamic.val;
|
|
6437
|
-
} else if (fixed && isVariable(fixed.var)) {
|
|
6438
|
-
qpVars[fixed.var] = fixed.val;
|
|
6439
|
-
}
|
|
6440
|
-
}
|
|
6441
|
-
return {
|
|
6442
|
-
pathVars,
|
|
6443
|
-
qpVars,
|
|
6444
|
-
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
6445
|
-
...pathVars,
|
|
6446
|
-
...qpVars
|
|
6447
|
-
}
|
|
6448
|
-
};
|
|
6330
|
+
function optional(value) {
|
|
6331
|
+
return value;
|
|
6449
6332
|
}
|
|
6450
|
-
function
|
|
6333
|
+
function orNull(value) {
|
|
6334
|
+
return value;
|
|
6335
|
+
}
|
|
6336
|
+
function optionalOrNull(value) {
|
|
6337
|
+
return value;
|
|
6338
|
+
}
|
|
6339
|
+
function stripParenthesis(val) {
|
|
6340
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
6341
|
+
}
|
|
6342
|
+
function sortKeyApi(order) {
|
|
6451
6343
|
return {
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6344
|
+
order,
|
|
6345
|
+
toTop: (...keys) => sortKeyApi(
|
|
6346
|
+
[
|
|
6347
|
+
...keys,
|
|
6348
|
+
...order.filter((i) => !keys.includes(i))
|
|
6349
|
+
]
|
|
6350
|
+
),
|
|
6351
|
+
toBottom: (...keys) => sortKeyApi(
|
|
6352
|
+
[
|
|
6353
|
+
...order.filter((i) => !keys.includes(i)),
|
|
6354
|
+
...keys
|
|
6355
|
+
]
|
|
6356
|
+
),
|
|
6357
|
+
done: () => order
|
|
6463
6358
|
};
|
|
6464
6359
|
}
|
|
6465
|
-
function
|
|
6466
|
-
|
|
6360
|
+
function toKeyValue(obj, sort) {
|
|
6361
|
+
let keys = keysOf(obj);
|
|
6362
|
+
const tuple3 = [];
|
|
6363
|
+
if (sort) {
|
|
6364
|
+
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
6365
|
+
}
|
|
6366
|
+
for (const k of keys) {
|
|
6367
|
+
tuple3.push({ key: k, value: obj[k] });
|
|
6368
|
+
}
|
|
6369
|
+
return tuple3;
|
|
6467
6370
|
}
|
|
6468
|
-
function
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
return
|
|
6476
|
-
|
|
6477
|
-
throw new Error(
|
|
6478
|
-
}
|
|
6479
|
-
} else {
|
|
6480
|
-
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
6371
|
+
function convertScalar(val) {
|
|
6372
|
+
switch (typeof val) {
|
|
6373
|
+
case "number":
|
|
6374
|
+
return val;
|
|
6375
|
+
case "string":
|
|
6376
|
+
return Number(val);
|
|
6377
|
+
case "boolean":
|
|
6378
|
+
return val ? 1 : 0;
|
|
6379
|
+
default:
|
|
6380
|
+
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
6481
6381
|
}
|
|
6482
6382
|
}
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
isYouTubeUrl: true,
|
|
6487
|
-
isShareUrl: isYouTubeShareUrl(url),
|
|
6488
|
-
pageType: getYouTubePageType(url)
|
|
6489
|
-
} : {
|
|
6490
|
-
url,
|
|
6491
|
-
isYouTubeUrl: false
|
|
6492
|
-
};
|
|
6383
|
+
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
6384
|
+
function toNumber(value) {
|
|
6385
|
+
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
6493
6386
|
}
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
size: state.length,
|
|
6498
|
-
isEmpty() {
|
|
6499
|
-
return state.length === 0;
|
|
6500
|
-
},
|
|
6501
|
-
clear() {
|
|
6502
|
-
state.slice(0, 0);
|
|
6503
|
-
},
|
|
6504
|
-
drain() {
|
|
6505
|
-
const old_state = [...state];
|
|
6506
|
-
state.slice(0, 0);
|
|
6507
|
-
return old_state;
|
|
6508
|
-
},
|
|
6509
|
-
push(...add) {
|
|
6510
|
-
state.push(...add);
|
|
6511
|
-
},
|
|
6512
|
-
drop(quantity) {
|
|
6513
|
-
if (quantity && quantity > state.length) {
|
|
6514
|
-
throw new Error("Cannot drop more elements than present in the queue");
|
|
6515
|
-
}
|
|
6516
|
-
state.splice(0, quantity || 1);
|
|
6517
|
-
},
|
|
6518
|
-
take(quantity) {
|
|
6519
|
-
if (quantity && quantity > state.length) {
|
|
6520
|
-
throw new Error("Cannot take more elements than present in the queue");
|
|
6521
|
-
}
|
|
6522
|
-
const result2 = state.slice(0, quantity || 1);
|
|
6523
|
-
state.splice(0, quantity || 1);
|
|
6524
|
-
return result2;
|
|
6525
|
-
},
|
|
6526
|
-
*[Symbol.iterator]() {
|
|
6527
|
-
for (let i = 0; i < state.length; i++) {
|
|
6528
|
-
yield state[i];
|
|
6529
|
-
}
|
|
6530
|
-
}
|
|
6531
|
-
};
|
|
6387
|
+
var MODS = TW_MODIFIERS2.map((i) => `${i}:`);
|
|
6388
|
+
function removeTailwindModifiers(val) {
|
|
6389
|
+
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
6532
6390
|
}
|
|
6533
|
-
function
|
|
6534
|
-
return
|
|
6391
|
+
function getTailwindModifiers(val) {
|
|
6392
|
+
return val.split(":").filter((i) => isTailwindModifier(i));
|
|
6535
6393
|
}
|
|
6536
|
-
function
|
|
6537
|
-
return
|
|
6538
|
-
queue: state,
|
|
6539
|
-
size: state.length,
|
|
6540
|
-
isEmpty() {
|
|
6541
|
-
return state.length === 0;
|
|
6542
|
-
},
|
|
6543
|
-
push(...add) {
|
|
6544
|
-
state.push(...add);
|
|
6545
|
-
},
|
|
6546
|
-
drop(quantity) {
|
|
6547
|
-
state.splice(-quantity);
|
|
6548
|
-
},
|
|
6549
|
-
clear() {
|
|
6550
|
-
state.slice(0, 0);
|
|
6551
|
-
},
|
|
6552
|
-
drain() {
|
|
6553
|
-
const old_state = [...state];
|
|
6554
|
-
state.slice(0, 0);
|
|
6555
|
-
return old_state;
|
|
6556
|
-
},
|
|
6557
|
-
take(quantity) {
|
|
6558
|
-
const result2 = state.slice(-quantity);
|
|
6559
|
-
state.splice(-quantity);
|
|
6560
|
-
return result2;
|
|
6561
|
-
},
|
|
6562
|
-
*[Symbol.iterator]() {
|
|
6563
|
-
for (let i = state.length - 1; i >= 0; i--) {
|
|
6564
|
-
yield state[i];
|
|
6565
|
-
}
|
|
6566
|
-
}
|
|
6567
|
-
};
|
|
6394
|
+
function union(..._options) {
|
|
6395
|
+
return (value) => value;
|
|
6568
6396
|
}
|
|
6569
|
-
function
|
|
6570
|
-
return
|
|
6397
|
+
function unionize(value, _inUnionWith) {
|
|
6398
|
+
return value;
|
|
6571
6399
|
}
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
number: "<<number>>",
|
|
6575
|
-
boolean: "<<boolean>>",
|
|
6576
|
-
true: "<<true>>",
|
|
6577
|
-
false: "<<false>>",
|
|
6578
|
-
null: "<<null>>",
|
|
6579
|
-
undefined: "<<undefined>>",
|
|
6580
|
-
unknown: "<<unknown>>",
|
|
6581
|
-
any: "<<any>>",
|
|
6582
|
-
never: "<<never>>"
|
|
6583
|
-
});
|
|
6584
|
-
function stringLiteral(str) {
|
|
6585
|
-
return stripAfter(stripBefore(str, "string("), ")");
|
|
6400
|
+
function hasWhiteSpace(val) {
|
|
6401
|
+
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS2.includes(c));
|
|
6586
6402
|
}
|
|
6587
|
-
function
|
|
6588
|
-
return
|
|
6403
|
+
function endsWith(endingIn2) {
|
|
6404
|
+
return (val) => {
|
|
6405
|
+
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
6406
|
+
};
|
|
6589
6407
|
}
|
|
6590
|
-
function
|
|
6591
|
-
|
|
6592
|
-
return bare.startsWith("string") ? `<<union::[ <<string>>, <<undefined>> ]>>` : bare.startsWith("number") ? `<<union::[ <<number>>, <<undefined>> ]>>` : bare.startsWith("boolean") ? `<<union::[ <<boolean>>, <<undefined>> ]>>` : bare.startsWith("unknown") ? `<<union::[ <<unknown>>, <<undefined>> ]>>` : `<<never>>`;
|
|
6408
|
+
function isEqual(base) {
|
|
6409
|
+
return (value) => isSameTypeOf(base)(value) ? value === base : false;
|
|
6593
6410
|
}
|
|
6594
|
-
function
|
|
6595
|
-
return
|
|
6411
|
+
function isLength(value, len) {
|
|
6412
|
+
return isArray(value) ? !!isEqual(value.length)(len) : isString(value) ? !!isEqual(value.length)(len) : isObject(value) ? !!isEqual(keysOf(value))(len) : false;
|
|
6596
6413
|
}
|
|
6597
|
-
function
|
|
6598
|
-
return
|
|
6414
|
+
function isSameTypeOf(base) {
|
|
6415
|
+
return (compare) => {
|
|
6416
|
+
return typeof base === typeof compare;
|
|
6417
|
+
};
|
|
6599
6418
|
}
|
|
6600
|
-
function
|
|
6601
|
-
|
|
6419
|
+
function isTuple(...tuple3) {
|
|
6420
|
+
const results = tuple3.map((i) => i(ShapeApiImplementation)).map((i) => isDoneFn(i) ? i.done() : i);
|
|
6421
|
+
return (v) => {
|
|
6422
|
+
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
6423
|
+
};
|
|
6602
6424
|
}
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6425
|
+
function isTypeOf(type) {
|
|
6426
|
+
return (value) => {
|
|
6427
|
+
return typeof value === type;
|
|
6428
|
+
};
|
|
6606
6429
|
}
|
|
6607
|
-
function
|
|
6430
|
+
function startsWith(startingWith) {
|
|
6431
|
+
return (val) => {
|
|
6432
|
+
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
6433
|
+
};
|
|
6608
6434
|
}
|
|
6609
|
-
function
|
|
6610
|
-
return "
|
|
6435
|
+
function isHtmlElement(val) {
|
|
6436
|
+
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
6611
6437
|
}
|
|
6612
|
-
function
|
|
6613
|
-
return
|
|
6438
|
+
function isAlpha(value) {
|
|
6439
|
+
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
6614
6440
|
}
|
|
6615
|
-
function
|
|
6616
|
-
return
|
|
6441
|
+
function isArray(value) {
|
|
6442
|
+
return Array.isArray(value) === true;
|
|
6617
6443
|
}
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
var nullType = () => "<<null>>";
|
|
6621
|
-
function fn(..._args) {
|
|
6622
|
-
return {
|
|
6623
|
-
returns: (_rtn) => ({
|
|
6624
|
-
addProperties: (_kv) => {
|
|
6625
|
-
return null;
|
|
6626
|
-
},
|
|
6627
|
-
done: () => {
|
|
6628
|
-
return null;
|
|
6629
|
-
}
|
|
6630
|
-
}),
|
|
6631
|
-
done: () => {
|
|
6632
|
-
const result2 = null;
|
|
6633
|
-
return result2;
|
|
6634
|
-
}
|
|
6635
|
-
};
|
|
6444
|
+
function isBoolean(value) {
|
|
6445
|
+
return typeof value === "boolean";
|
|
6636
6446
|
}
|
|
6637
|
-
function
|
|
6638
|
-
return
|
|
6447
|
+
function isBooleanLike(val) {
|
|
6448
|
+
return isBoolean(val) || isString(val) && ["true", "false", "boolean"].includes(val);
|
|
6639
6449
|
}
|
|
6640
|
-
function
|
|
6641
|
-
return
|
|
6450
|
+
function isConstant(value) {
|
|
6451
|
+
return !!(isObject(value) && "_type" in value && "kind" in value && value._type === "Constant");
|
|
6642
6452
|
}
|
|
6643
|
-
function
|
|
6644
|
-
|
|
6645
|
-
if (isString(re)) {
|
|
6646
|
-
try {
|
|
6647
|
-
const test = new RegExp(re);
|
|
6648
|
-
if (!isRegExp(test)) {
|
|
6649
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
6650
|
-
err.name = "InvalidRegEx";
|
|
6651
|
-
throw err;
|
|
6652
|
-
} else {
|
|
6653
|
-
exp = re;
|
|
6654
|
-
}
|
|
6655
|
-
} catch {
|
|
6656
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
6657
|
-
err.name = "InvalidRegEx";
|
|
6658
|
-
throw err;
|
|
6659
|
-
}
|
|
6660
|
-
} else if (isRegExp(re)) {
|
|
6661
|
-
exp = re.toString();
|
|
6662
|
-
}
|
|
6663
|
-
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
6664
|
-
return token;
|
|
6453
|
+
function isContainer(value) {
|
|
6454
|
+
return !!(Array.isArray(value) || isObject(value));
|
|
6665
6455
|
}
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6456
|
+
var tokens = [
|
|
6457
|
+
"1",
|
|
6458
|
+
"inherit",
|
|
6459
|
+
"initial",
|
|
6460
|
+
"revert",
|
|
6461
|
+
"revert-layer",
|
|
6462
|
+
"unset",
|
|
6463
|
+
"auto"
|
|
6464
|
+
];
|
|
6465
|
+
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
6466
|
+
function isCssAspectRatio(val) {
|
|
6467
|
+
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6673
6468
|
}
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
6677
|
-
zip: () => addToken("string-set", "Zip5"),
|
|
6678
|
-
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
6679
|
-
zipCode: () => addToken("string-set", "ZipCode"),
|
|
6680
|
-
militaryTime: (resolution) => {
|
|
6681
|
-
return addToken(
|
|
6682
|
-
"string-set",
|
|
6683
|
-
"militaryTime",
|
|
6684
|
-
resolution || "HH:MM"
|
|
6685
|
-
);
|
|
6686
|
-
},
|
|
6687
|
-
civilianTime: (resolution) => {
|
|
6688
|
-
return addToken(
|
|
6689
|
-
"string-set",
|
|
6690
|
-
"militaryTime",
|
|
6691
|
-
resolution || "HH:MM"
|
|
6692
|
-
);
|
|
6693
|
-
},
|
|
6694
|
-
numericString: () => addToken("string-set", "numeric"),
|
|
6695
|
-
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
6696
|
-
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
6697
|
-
regex: (exp, ...literalRepresentation) => {
|
|
6698
|
-
const token = regexToken(exp, ...literalRepresentation);
|
|
6699
|
-
return token;
|
|
6700
|
-
},
|
|
6701
|
-
done: () => addToken("string")
|
|
6702
|
-
};
|
|
6703
|
-
var string22 = addSingleton("string", stringApi);
|
|
6704
|
-
var number = addSingleton("number");
|
|
6705
|
-
function union2(...elements) {
|
|
6706
|
-
const result2 = elements.map((_el) => {
|
|
6707
|
-
});
|
|
6708
|
-
return result2;
|
|
6469
|
+
function isCsv(val) {
|
|
6470
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
6709
6471
|
}
|
|
6710
|
-
function
|
|
6711
|
-
return
|
|
6472
|
+
function isDefined(value) {
|
|
6473
|
+
return value !== void 0;
|
|
6712
6474
|
}
|
|
6713
|
-
function
|
|
6714
|
-
return
|
|
6475
|
+
function isDoneFn(val) {
|
|
6476
|
+
return hasKeys("done")(val) && typeof val.done === "function";
|
|
6715
6477
|
}
|
|
6716
|
-
function
|
|
6717
|
-
|
|
6478
|
+
function isEmail(val) {
|
|
6479
|
+
if (!isString(val)) {
|
|
6480
|
+
return false;
|
|
6481
|
+
}
|
|
6482
|
+
const parts = val?.split("@");
|
|
6483
|
+
const domain = parts[1]?.split(".");
|
|
6484
|
+
const tld = domain ? domain.pop() : "";
|
|
6485
|
+
const firstChar = val[0].toLowerCase();
|
|
6486
|
+
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
6718
6487
|
}
|
|
6719
|
-
function
|
|
6720
|
-
return
|
|
6488
|
+
function isEmpty(val) {
|
|
6489
|
+
return isUndefined(val) || isNull(val) || isString(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isArray(val) && val.length === 0;
|
|
6721
6490
|
}
|
|
6722
|
-
function
|
|
6723
|
-
return
|
|
6491
|
+
function isNotEmpty(val) {
|
|
6492
|
+
return !(isUndefined(val) || isNull(val) || isString(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isArray(val) && (val?.length === 0 || val?.length === void 0));
|
|
6724
6493
|
}
|
|
6725
|
-
function
|
|
6726
|
-
return isObject(
|
|
6494
|
+
function isErrorCondition(value, kind = null) {
|
|
6495
|
+
return isObject(value) && "__kind" in value && value.__kind === "ErrorCondition" && "kind" in value ? kind !== null ? value.kind === kind : true : false;
|
|
6727
6496
|
}
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
number,
|
|
6731
|
-
boolean,
|
|
6732
|
-
unknown,
|
|
6733
|
-
undefined: undefinedType,
|
|
6734
|
-
null: nullType,
|
|
6735
|
-
union: union2,
|
|
6736
|
-
fn,
|
|
6737
|
-
record,
|
|
6738
|
-
array,
|
|
6739
|
-
set,
|
|
6740
|
-
map,
|
|
6741
|
-
weakMap,
|
|
6742
|
-
dictionary,
|
|
6743
|
-
tuple: tuple2
|
|
6744
|
-
};
|
|
6745
|
-
function shape(cb) {
|
|
6746
|
-
const rtn = cb(ShapeApiImplementation);
|
|
6747
|
-
return handleDoneFn(
|
|
6748
|
-
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
6749
|
-
);
|
|
6497
|
+
function isFalse(i) {
|
|
6498
|
+
return typeof i === "boolean" && !i;
|
|
6750
6499
|
}
|
|
6751
|
-
function
|
|
6752
|
-
return
|
|
6500
|
+
function isFalsy(val) {
|
|
6501
|
+
return FALSY_VALUES2.includes(val);
|
|
6753
6502
|
}
|
|
6754
|
-
function
|
|
6755
|
-
|
|
6756
|
-
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
6757
|
-
...acc,
|
|
6758
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
6759
|
-
} : isFunction(defn[i]) ? {
|
|
6760
|
-
...acc,
|
|
6761
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
6762
|
-
} : Never2,
|
|
6763
|
-
{}
|
|
6764
|
-
);
|
|
6765
|
-
return result2;
|
|
6503
|
+
function isFnWithParams(input, ...params) {
|
|
6504
|
+
return params.length === 0 ? typeof input === "function" && input?.length > 0 : typeof input === "function" && input?.length === params.length;
|
|
6766
6505
|
}
|
|
6767
|
-
function
|
|
6768
|
-
return
|
|
6506
|
+
function isHexadecimal(val) {
|
|
6507
|
+
return isString(val) && asChars(val).every((i) => isNumericString(i) || ["a", "b", "c", "d", "e", "f"].includes(i.toLowerCase()));
|
|
6769
6508
|
}
|
|
6770
|
-
function
|
|
6771
|
-
return
|
|
6509
|
+
function isIndexable(value) {
|
|
6510
|
+
return !!(Array.isArray(value) || typeof value === "object" && keysOf(value).length > 0);
|
|
6772
6511
|
}
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
}
|
|
6834
|
-
}
|
|
6835
|
-
if (isArray(val)) {
|
|
6836
|
-
if (type === "Array" || type === "Array<unknown>") {
|
|
6837
|
-
return true;
|
|
6838
|
-
}
|
|
6839
|
-
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
6840
|
-
response = true;
|
|
6841
|
-
}
|
|
6842
|
-
}
|
|
6843
|
-
if (isMap(val)) {
|
|
6844
|
-
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
6845
|
-
response = true;
|
|
6846
|
-
}
|
|
6847
|
-
}
|
|
6848
|
-
if (isSetContainer(val)) {
|
|
6849
|
-
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
6850
|
-
response = true;
|
|
6851
|
-
}
|
|
6512
|
+
function isInlineSvg(v) {
|
|
6513
|
+
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
6514
|
+
}
|
|
6515
|
+
function isMap(val) {
|
|
6516
|
+
return val instanceof Map;
|
|
6517
|
+
}
|
|
6518
|
+
function isNever(val) {
|
|
6519
|
+
return isConstant(val) && val.kind === "never";
|
|
6520
|
+
}
|
|
6521
|
+
function isNothing(val) {
|
|
6522
|
+
return !!(val === null || val === void 0);
|
|
6523
|
+
}
|
|
6524
|
+
function isNotNull(value) {
|
|
6525
|
+
return value === null;
|
|
6526
|
+
}
|
|
6527
|
+
function isNull(value) {
|
|
6528
|
+
return value === null;
|
|
6529
|
+
}
|
|
6530
|
+
function maybePhoneNumber(val) {
|
|
6531
|
+
const svelte = String(val).trim();
|
|
6532
|
+
const chars = svelte.split("");
|
|
6533
|
+
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
6534
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
6535
|
+
const nothing = stripChars(svelte, ...[
|
|
6536
|
+
...NUMERIC_CHAR2,
|
|
6537
|
+
...WHITESPACE_CHARS2,
|
|
6538
|
+
"(",
|
|
6539
|
+
")",
|
|
6540
|
+
"+",
|
|
6541
|
+
".",
|
|
6542
|
+
"-"
|
|
6543
|
+
]);
|
|
6544
|
+
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
6545
|
+
}
|
|
6546
|
+
var start = PHONE_COUNTRY_CODES2.map((i) => `+${i[0]} `);
|
|
6547
|
+
function hasCountryCode(val) {
|
|
6548
|
+
if (isString(val)) {
|
|
6549
|
+
return start.some((i) => val.trimStart().startsWith(i));
|
|
6550
|
+
}
|
|
6551
|
+
return false;
|
|
6552
|
+
}
|
|
6553
|
+
function isUsPhoneNumber(val) {
|
|
6554
|
+
if (isString(val)) {
|
|
6555
|
+
return maybePhoneNumber(val) && val.trimStart().startsWith(`+1 `);
|
|
6556
|
+
}
|
|
6557
|
+
return false;
|
|
6558
|
+
}
|
|
6559
|
+
function isPhoneNumber(val) {
|
|
6560
|
+
if (isString(val) && maybePhoneNumber(val) && [" ", "-", "."].some((i) => val.includes(i))) {
|
|
6561
|
+
const cc = getPhoneCountryCode(val);
|
|
6562
|
+
const without = cc === "" ? retainChars(val, ...NUMERIC_CHAR2) : retainChars(val.trimStart().replace(`+${cc} `, ""), ...NUMERIC_CHAR2);
|
|
6563
|
+
switch (cc) {
|
|
6564
|
+
case "1":
|
|
6565
|
+
return without.length === 10;
|
|
6566
|
+
case "44":
|
|
6567
|
+
return !![10, 11].includes(without.length);
|
|
6568
|
+
case "":
|
|
6569
|
+
return without.length <= 10;
|
|
6570
|
+
default:
|
|
6571
|
+
return without.length <= 11;
|
|
6852
6572
|
}
|
|
6853
|
-
|
|
6854
|
-
|
|
6573
|
+
}
|
|
6574
|
+
return false;
|
|
6855
6575
|
}
|
|
6856
|
-
function
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6576
|
+
function isReadonlyArray(value) {
|
|
6577
|
+
return Array.isArray(value) === true;
|
|
6578
|
+
}
|
|
6579
|
+
function isRef(value) {
|
|
6580
|
+
return isObject(value) && "value" in value && Array.from(Object.keys(value)).includes("_value");
|
|
6581
|
+
}
|
|
6582
|
+
function isRegExp(val) {
|
|
6583
|
+
return val instanceof RegExp;
|
|
6584
|
+
}
|
|
6585
|
+
function isLikeRegExp(val) {
|
|
6586
|
+
if (isRegExp(val)) {
|
|
6587
|
+
return true;
|
|
6862
6588
|
}
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6589
|
+
if (isString(val)) {
|
|
6590
|
+
try {
|
|
6591
|
+
const _re = new RegExp(val);
|
|
6592
|
+
return true;
|
|
6593
|
+
} catch {
|
|
6594
|
+
return false;
|
|
6595
|
+
}
|
|
6596
|
+
}
|
|
6597
|
+
return false;
|
|
6598
|
+
}
|
|
6599
|
+
function isSymbol(value) {
|
|
6600
|
+
return typeof value === "symbol";
|
|
6601
|
+
}
|
|
6602
|
+
function isScalar(value) {
|
|
6603
|
+
return isString(value) || isNumber(value) || isSymbol(value) || isNull(value);
|
|
6604
|
+
}
|
|
6605
|
+
function isSet(val) {
|
|
6606
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
6607
|
+
}
|
|
6608
|
+
function isSetContainer(val) {
|
|
6609
|
+
return val instanceof Set;
|
|
6610
|
+
}
|
|
6611
|
+
function isStringArray(val) {
|
|
6612
|
+
return Array.isArray(val) && val.every((i) => isString(i));
|
|
6613
|
+
}
|
|
6614
|
+
function isThenable(val) {
|
|
6615
|
+
return isObject(val) && "then" in val && "catch" in val && typeof val.then === "function";
|
|
6616
|
+
}
|
|
6617
|
+
function isTrimable(val) {
|
|
6618
|
+
return isString(val) && val !== val.trim();
|
|
6619
|
+
}
|
|
6620
|
+
function isTrue(value) {
|
|
6621
|
+
return value === true;
|
|
6622
|
+
}
|
|
6623
|
+
function isTruthy(val) {
|
|
6624
|
+
return !FALSY_VALUES2.includes(val);
|
|
6625
|
+
}
|
|
6626
|
+
function isTypeSubtype(val) {
|
|
6627
|
+
return isString(val) && val.split("/").length === 2;
|
|
6628
|
+
}
|
|
6629
|
+
function isTypeTuple(value) {
|
|
6630
|
+
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
6631
|
+
}
|
|
6632
|
+
function isUnset(val) {
|
|
6633
|
+
return isObject(val) && val.kind === "Unset";
|
|
6871
6634
|
}
|
|
6872
|
-
function
|
|
6873
|
-
const
|
|
6874
|
-
|
|
6875
|
-
const proxy = new Proxy(state, {});
|
|
6876
|
-
Object.defineProperty(proxy, "id", {
|
|
6877
|
-
enumerable: false
|
|
6878
|
-
});
|
|
6879
|
-
return proxy;
|
|
6635
|
+
function isUri(val, ...protocols) {
|
|
6636
|
+
const p = protocols.length === 0 ? valuesOf(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i) : protocols;
|
|
6637
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6880
6638
|
}
|
|
6881
|
-
function
|
|
6882
|
-
|
|
6639
|
+
function isUrl(val, ...protocols) {
|
|
6640
|
+
const p = protocols.length === 0 ? ["http", "https"] : protocols;
|
|
6641
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6883
6642
|
}
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6643
|
+
var VALID = [
|
|
6644
|
+
...ALPHA_CHARS2,
|
|
6645
|
+
...NUMERIC_CHAR2,
|
|
6646
|
+
"_",
|
|
6647
|
+
"."
|
|
6648
|
+
];
|
|
6649
|
+
var alpha = null;
|
|
6650
|
+
function valid(chars) {
|
|
6651
|
+
return chars.every((i) => VALID.includes(i));
|
|
6889
6652
|
}
|
|
6890
|
-
function
|
|
6891
|
-
return
|
|
6653
|
+
function isVariable(val) {
|
|
6654
|
+
return isString(val) && startsWith(alpha)(val) && valid(asChars(val));
|
|
6892
6655
|
}
|
|
6893
|
-
function
|
|
6894
|
-
return
|
|
6895
|
-
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
6896
|
-
};
|
|
6656
|
+
function separate(s) {
|
|
6657
|
+
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR2).trim();
|
|
6897
6658
|
}
|
|
6898
|
-
function
|
|
6899
|
-
return
|
|
6900
|
-
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
6901
|
-
};
|
|
6659
|
+
function isAreaMetric(val) {
|
|
6660
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6902
6661
|
}
|
|
6903
|
-
function
|
|
6904
|
-
return
|
|
6662
|
+
function isLuminosityMetric(val) {
|
|
6663
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6905
6664
|
}
|
|
6906
|
-
function
|
|
6907
|
-
return
|
|
6908
|
-
done: fnDoneApi(kind, params, returns),
|
|
6909
|
-
params: fnParamsApi(kind, params, returns),
|
|
6910
|
-
returns: fnReturnsApi(kind, params, returns)
|
|
6911
|
-
};
|
|
6665
|
+
function isResistance(val) {
|
|
6666
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6912
6667
|
}
|
|
6913
|
-
function
|
|
6914
|
-
return
|
|
6668
|
+
function isCurrentMetric(val) {
|
|
6669
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6915
6670
|
}
|
|
6916
|
-
function
|
|
6917
|
-
return
|
|
6671
|
+
function isVoltageMetric(val) {
|
|
6672
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6918
6673
|
}
|
|
6919
|
-
function
|
|
6920
|
-
|
|
6921
|
-
const parts = bare.split("::");
|
|
6922
|
-
const kind = parts.pop();
|
|
6923
|
-
return kind;
|
|
6674
|
+
function isFrequencyMetric(val) {
|
|
6675
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6924
6676
|
}
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
var simpleContainerToken = (token) => token;
|
|
6928
|
-
function simpleScalarType(token) {
|
|
6929
|
-
const value = simpleScalarToken(token);
|
|
6930
|
-
return value;
|
|
6677
|
+
function isPowerMetric(val) {
|
|
6678
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6931
6679
|
}
|
|
6932
|
-
function
|
|
6933
|
-
|
|
6934
|
-
return value;
|
|
6680
|
+
function isTimeMetric(val) {
|
|
6681
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6935
6682
|
}
|
|
6936
|
-
function
|
|
6937
|
-
|
|
6938
|
-
return value;
|
|
6683
|
+
function isEnergyMetric(val) {
|
|
6684
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6939
6685
|
}
|
|
6940
|
-
function
|
|
6941
|
-
|
|
6942
|
-
for (const k of keys) {
|
|
6943
|
-
if (k in b) {
|
|
6944
|
-
return true;
|
|
6945
|
-
}
|
|
6946
|
-
}
|
|
6947
|
-
return false;
|
|
6686
|
+
function isPressureMetric(val) {
|
|
6687
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6948
6688
|
}
|
|
6949
|
-
function
|
|
6950
|
-
|
|
6951
|
-
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
6952
|
-
throw new Error("uniqueKeys(l,r) given invalid comparison; both left and right values should be an object or an array but not one of each!");
|
|
6953
|
-
}
|
|
6954
|
-
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
6955
|
-
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
6956
|
-
if (isNumeric) {
|
|
6957
|
-
throw new Error("uniqueKeys does not yet work with tuples");
|
|
6958
|
-
}
|
|
6959
|
-
const leftKeys = l.filter((i) => !r.includes(i));
|
|
6960
|
-
const rightKeys = r.filter((i) => !l.includes(i));
|
|
6961
|
-
return [
|
|
6962
|
-
"LeftRight",
|
|
6963
|
-
leftKeys,
|
|
6964
|
-
rightKeys
|
|
6965
|
-
];
|
|
6689
|
+
function isTemperatureMetric(val) {
|
|
6690
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6966
6691
|
}
|
|
6967
|
-
function
|
|
6968
|
-
return
|
|
6692
|
+
function isVolumeMetric(val) {
|
|
6693
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6969
6694
|
}
|
|
6970
|
-
function
|
|
6971
|
-
return
|
|
6695
|
+
function isAccelerationMetric(val) {
|
|
6696
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6972
6697
|
}
|
|
6973
|
-
function
|
|
6974
|
-
|
|
6698
|
+
function isSpeedMetric(val) {
|
|
6699
|
+
const speed = SPEED_METRICS_LOOKUP2.map((i) => i.abbrev);
|
|
6700
|
+
return isString(val) && speed.includes(separate(val));
|
|
6975
6701
|
}
|
|
6976
|
-
function
|
|
6977
|
-
return
|
|
6702
|
+
function isMassMetric(val) {
|
|
6703
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6978
6704
|
}
|
|
6979
|
-
function
|
|
6980
|
-
return
|
|
6705
|
+
function isDistanceMetric(val) {
|
|
6706
|
+
return isString(val) && DISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6981
6707
|
}
|
|
6982
|
-
function
|
|
6983
|
-
return
|
|
6708
|
+
function isMetric(val) {
|
|
6709
|
+
return isDistanceMetric(val) || isMassMetric(val) || isSpeedMetric(val) || isAccelerationMetric(val) || isVoltageMetric(val) || isTemperatureMetric(val) || isPressureMetric(val) || isEnergyMetric(val) || isTimeMetric(val) || isPowerMetric(val) || isFrequencyMetric(val) || isVoltageMetric(val) || isCurrentMetric(val) || isLuminosityMetric(val) || isAreaMetric(val);
|
|
6984
6710
|
}
|
|
6985
|
-
function
|
|
6986
|
-
return
|
|
6711
|
+
function isAreaUom(val) {
|
|
6712
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6987
6713
|
}
|
|
6988
|
-
function
|
|
6989
|
-
return
|
|
6714
|
+
function isLuminosityUom(val) {
|
|
6715
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6990
6716
|
}
|
|
6991
|
-
function
|
|
6992
|
-
return
|
|
6717
|
+
function isResistanceUom(val) {
|
|
6718
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6993
6719
|
}
|
|
6994
|
-
function
|
|
6995
|
-
return
|
|
6720
|
+
function isCurrentUom(val) {
|
|
6721
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6996
6722
|
}
|
|
6997
|
-
function
|
|
6998
|
-
return val
|
|
6723
|
+
function isVoltageUom(val) {
|
|
6724
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6999
6725
|
}
|
|
7000
|
-
function
|
|
7001
|
-
|
|
7002
|
-
return false;
|
|
7003
|
-
}
|
|
7004
|
-
const ISO_DATETIME_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
7005
|
-
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
7006
|
-
return false;
|
|
7007
|
-
}
|
|
7008
|
-
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
7009
|
-
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
7010
|
-
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
7011
|
-
return false;
|
|
7012
|
-
}
|
|
7013
|
-
if (month < 1 || month > 12) {
|
|
7014
|
-
return false;
|
|
7015
|
-
}
|
|
7016
|
-
;
|
|
7017
|
-
const daysInMonth = new Date(year, month, 0).getDate();
|
|
7018
|
-
if (day < 1 || day > daysInMonth) {
|
|
7019
|
-
return false;
|
|
7020
|
-
}
|
|
7021
|
-
;
|
|
7022
|
-
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
7023
|
-
if (tzMatch) {
|
|
7024
|
-
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
7025
|
-
const numHours = Number.parseInt(tzHours, 10);
|
|
7026
|
-
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
7027
|
-
if (numHours > 14 || numMinutes > 59) {
|
|
7028
|
-
return false;
|
|
7029
|
-
}
|
|
7030
|
-
if (numHours === 14 && numMinutes > 0) {
|
|
7031
|
-
return false;
|
|
7032
|
-
}
|
|
7033
|
-
}
|
|
7034
|
-
return true;
|
|
6726
|
+
function isFrequencyUom(val) {
|
|
6727
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7035
6728
|
}
|
|
7036
|
-
function
|
|
7037
|
-
|
|
7038
|
-
const parts = val.split("-").map((i) => Number(i));
|
|
7039
|
-
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
7040
|
-
} else {
|
|
7041
|
-
return false;
|
|
7042
|
-
}
|
|
6729
|
+
function isPowerUom(val) {
|
|
6730
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7043
6731
|
}
|
|
7044
|
-
function
|
|
7045
|
-
|
|
7046
|
-
const year = Number(val.slice(0, 4));
|
|
7047
|
-
const month = Number(val.slice(4, 6));
|
|
7048
|
-
const date = Number(val.slice(6, 8));
|
|
7049
|
-
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
7050
|
-
} else {
|
|
7051
|
-
return false;
|
|
7052
|
-
}
|
|
6732
|
+
function isTimeUom(val) {
|
|
6733
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7053
6734
|
}
|
|
7054
|
-
function
|
|
7055
|
-
|
|
7056
|
-
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
7057
|
-
} else {
|
|
7058
|
-
return false;
|
|
7059
|
-
}
|
|
6735
|
+
function isEnergyUom(val) {
|
|
6736
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7060
6737
|
}
|
|
7061
|
-
function
|
|
7062
|
-
|
|
7063
|
-
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
7064
|
-
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
7065
|
-
} else {
|
|
7066
|
-
return false;
|
|
7067
|
-
}
|
|
6738
|
+
function isPressureUom(val) {
|
|
6739
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7068
6740
|
}
|
|
7069
|
-
function
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
6741
|
+
function isTemperatureUom(val) {
|
|
6742
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6743
|
+
}
|
|
6744
|
+
function isVolumeUom(val) {
|
|
6745
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6746
|
+
}
|
|
6747
|
+
function isAccelerationUom(val) {
|
|
6748
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7076
6749
|
}
|
|
7077
|
-
function
|
|
7078
|
-
return
|
|
6750
|
+
function isSpeedUom(val) {
|
|
6751
|
+
return isString(val) && SPEED_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7079
6752
|
}
|
|
7080
|
-
function
|
|
7081
|
-
return
|
|
6753
|
+
function isMassUom(val) {
|
|
6754
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7082
6755
|
}
|
|
7083
|
-
function
|
|
7084
|
-
return
|
|
6756
|
+
function isDistanceUom(val) {
|
|
6757
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7085
6758
|
}
|
|
7086
|
-
function
|
|
7087
|
-
|
|
7088
|
-
return false;
|
|
7089
|
-
}
|
|
7090
|
-
return isObject(val) && typeof val.format === "function" && typeof val.year === "function" && typeof val.month === "function" && typeof val.date === "function" && "_isAMomentObject" in val && "_isValid" in val && typeof val.add === "function" && typeof val.subtract === "function" && typeof val.toISOString === "function" && typeof val.isValid === "function";
|
|
6759
|
+
function isUom(val) {
|
|
6760
|
+
return isDistanceUom(val) || isMassUom(val) || isSpeedUom(val) || isAccelerationUom(val) || isVoltageUom(val) || isTemperatureUom(val) || isPressureUom(val) || isEnergyUom(val) || isTimeUom(val) || isPowerUom(val) || isFrequencyUom(val) || isVoltageUom(val) || isCurrentUom(val) || isLuminosityUom(val) || isAreaUom(val);
|
|
7091
6761
|
}
|
|
7092
|
-
function
|
|
7093
|
-
|
|
7094
|
-
const currentYear = now.getFullYear();
|
|
7095
|
-
const currentMonth = now.getMonth() + 1;
|
|
7096
|
-
if (val instanceof Date) {
|
|
7097
|
-
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
7098
|
-
}
|
|
7099
|
-
if (isMoment(val)) {
|
|
7100
|
-
const monthValue = val.month();
|
|
7101
|
-
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
7102
|
-
}
|
|
7103
|
-
if (isLuxonDateTime(val)) {
|
|
7104
|
-
return val.year === currentYear && val.month === currentMonth;
|
|
7105
|
-
}
|
|
7106
|
-
if (typeof val === "string") {
|
|
7107
|
-
const isoDateRegex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(?:T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[-+][01]\d:[0-5]\d))?$/;
|
|
7108
|
-
if (!isoDateRegex.test(val)) {
|
|
7109
|
-
return false;
|
|
7110
|
-
}
|
|
7111
|
-
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
7112
|
-
if (dateMatch) {
|
|
7113
|
-
const year = Number.parseInt(dateMatch[1], 10);
|
|
7114
|
-
const month = Number.parseInt(dateMatch[2], 10);
|
|
7115
|
-
return year === currentYear && month === currentMonth;
|
|
7116
|
-
}
|
|
7117
|
-
}
|
|
7118
|
-
return false;
|
|
6762
|
+
function isIp4Address(val) {
|
|
6763
|
+
return isString(val) && val.split(".").length === 4 && val.split(".").every((i) => isNumberLike(i)) && val.split(".").every((i) => Number(i) >= 0 && Number(i) <= 255);
|
|
7119
6764
|
}
|
|
7120
|
-
function
|
|
7121
|
-
const
|
|
7122
|
-
|
|
7123
|
-
return false;
|
|
7124
|
-
}
|
|
7125
|
-
const currentWeek = getWeekNumber();
|
|
7126
|
-
const targetWeek = getWeekNumber(targetDate);
|
|
7127
|
-
return currentWeek === targetWeek;
|
|
6765
|
+
function isIp6Address(val) {
|
|
6766
|
+
const expanded = isString(val) ? ip6GroupExpansion(val) : "";
|
|
6767
|
+
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
7128
6768
|
}
|
|
7129
|
-
function
|
|
7130
|
-
|
|
7131
|
-
if (isObject(val) || isNumber(val) || isString(val)) {
|
|
7132
|
-
const date = asDate(val);
|
|
7133
|
-
if (date) {
|
|
7134
|
-
return date.getFullYear() === currentYear;
|
|
7135
|
-
} else {
|
|
7136
|
-
return false;
|
|
7137
|
-
}
|
|
7138
|
-
}
|
|
7139
|
-
return false;
|
|
6769
|
+
function isIpAddress(val) {
|
|
6770
|
+
return isIp4Address(val) || isIp6Address(val);
|
|
7140
6771
|
}
|
|
7141
|
-
function
|
|
7142
|
-
|
|
7143
|
-
const justDate = stripAfter(test, "T");
|
|
7144
|
-
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
7145
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
7146
|
-
return stripAfter(test.toISOString(), "T") === getToday();
|
|
7147
|
-
} else if (isLuxonDateTime(test)) {
|
|
7148
|
-
return stripAfter(test.toISO(), "T") === getToday();
|
|
7149
|
-
}
|
|
7150
|
-
return false;
|
|
6772
|
+
function hasUrlPort(val) {
|
|
6773
|
+
return isString(val) && asChars(removeUrlProtocol(val)).includes(":");
|
|
7151
6774
|
}
|
|
7152
|
-
function
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
7157
|
-
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
7158
|
-
} else if (isLuxonDateTime(test)) {
|
|
7159
|
-
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
7160
|
-
}
|
|
7161
|
-
return false;
|
|
6775
|
+
function isUrlPath(val) {
|
|
6776
|
+
return isString(val) && (val === "" || val.startsWith("/")) && asChars(val).every(
|
|
6777
|
+
(c) => isAlpha(c) || isNumberLike(c) || c === "_" || c === "@" || c === "." || c === "-"
|
|
6778
|
+
);
|
|
7162
6779
|
}
|
|
7163
|
-
function
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
7168
|
-
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
7169
|
-
} else if (isLuxonDateTime(test)) {
|
|
7170
|
-
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
7171
|
-
}
|
|
7172
|
-
return false;
|
|
6780
|
+
function isDomainName(val) {
|
|
6781
|
+
return isString(val) && val.split(".").filter((i) => i).length > 1 && isString(val.split(".").filter((i) => i).pop()) && asChars(val.split(".").filter((i) => i).pop()).length > 1 && val.split(".").filter((i) => i).every(
|
|
6782
|
+
(i) => isAlpha(i) || isNumberLike(i) || i === "-" || i === "_"
|
|
6783
|
+
);
|
|
7173
6784
|
}
|
|
7174
|
-
function
|
|
7175
|
-
|
|
7176
|
-
const parts = val.split(" ");
|
|
7177
|
-
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
|
|
7178
|
-
}
|
|
7179
|
-
return false;
|
|
6785
|
+
function isUrlSource(val) {
|
|
6786
|
+
return isDomainName(val) || isIpAddress(val);
|
|
7180
6787
|
}
|
|
7181
|
-
function
|
|
7182
|
-
|
|
7183
|
-
const parts = val.split(" ");
|
|
7184
|
-
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4) && ["51", "55", "22", "23", "24", "25", "26", "27"].some((i) => val.startsWith(i));
|
|
7185
|
-
}
|
|
7186
|
-
return false;
|
|
6788
|
+
function hasUrlQueryParameter(val, prop) {
|
|
6789
|
+
return isString(getUrlQueryParams(val, prop));
|
|
7187
6790
|
}
|
|
7188
|
-
function
|
|
7189
|
-
return
|
|
6791
|
+
function isNumericArray(val) {
|
|
6792
|
+
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
7190
6793
|
}
|
|
7191
|
-
function
|
|
7192
|
-
|
|
7193
|
-
const parts = val.split(" ");
|
|
7194
|
-
return parts.length === 3 && parts.every(
|
|
7195
|
-
(i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
|
|
7196
|
-
);
|
|
7197
|
-
}
|
|
7198
|
-
return false;
|
|
6794
|
+
function hasProtocol(val, ...protocols) {
|
|
6795
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.some((i) => val.startsWith(i)) : protocols.some((i) => val.startsWith(i));
|
|
7199
6796
|
}
|
|
7200
|
-
function
|
|
7201
|
-
return
|
|
6797
|
+
function isProtocol(val, ...protocols) {
|
|
6798
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.includes(val) : protocols.includes(val);
|
|
7202
6799
|
}
|
|
7203
|
-
function
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
{ name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
|
|
7221
|
-
{ name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
|
|
7222
|
-
];
|
|
7223
|
-
for (const type of cardTypes) {
|
|
7224
|
-
if (type.lengths.includes(length)) {
|
|
7225
|
-
for (const prefix of type.prefixes) {
|
|
7226
|
-
if (prefix.test(cleanedNumber)) {
|
|
7227
|
-
return type.name;
|
|
6800
|
+
function hasProtocolPrefix(val, ...protocols) {
|
|
6801
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).some((i) => val.startsWith(i)) : protocols.map((i) => `${i}://`).some((i) => val.startsWith(i));
|
|
6802
|
+
}
|
|
6803
|
+
function isProtocolPrefix(val, ...protocols) {
|
|
6804
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).includes(val) : protocols.map((i) => `${i}://`).includes(val);
|
|
6805
|
+
}
|
|
6806
|
+
function isTypeToken(val, kind) {
|
|
6807
|
+
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
6808
|
+
const stripped = stripSurround("<<", ">>")(val);
|
|
6809
|
+
if (TT_KIND_VARIANTS2.some((k) => stripped.startsWith(k))) {
|
|
6810
|
+
if (kind) {
|
|
6811
|
+
if (isAtomicKind(kind)) {
|
|
6812
|
+
return val === `<<${kind}>>`;
|
|
6813
|
+
} else if (isSetBasedKind(kind)) {
|
|
6814
|
+
return val.startsWith(`<<${kind}::`);
|
|
6815
|
+
} else {
|
|
6816
|
+
return val === `<<${kind}>>` || val.startsWith(`<<${kind}::`);
|
|
7228
6817
|
}
|
|
6818
|
+
} else {
|
|
6819
|
+
return true;
|
|
7229
6820
|
}
|
|
7230
6821
|
}
|
|
6822
|
+
return false;
|
|
7231
6823
|
}
|
|
7232
|
-
return
|
|
6824
|
+
return false;
|
|
7233
6825
|
}
|
|
7234
|
-
function
|
|
7235
|
-
|
|
7236
|
-
return validLengths.includes(length);
|
|
6826
|
+
function isTypeTokenKind(val) {
|
|
6827
|
+
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
7237
6828
|
}
|
|
7238
|
-
function
|
|
7239
|
-
|
|
7240
|
-
let double = false;
|
|
7241
|
-
for (let i = num.length - 1; i >= 0; i--) {
|
|
7242
|
-
let n = Number.parseInt(num.charAt(i), 10);
|
|
7243
|
-
if (double) {
|
|
7244
|
-
n *= 2;
|
|
7245
|
-
if (n > 9) {
|
|
7246
|
-
n -= 9;
|
|
7247
|
-
}
|
|
7248
|
-
}
|
|
7249
|
-
sum += n;
|
|
7250
|
-
double = !double;
|
|
7251
|
-
}
|
|
7252
|
-
return sum % 10 === 0;
|
|
6829
|
+
function isAtomicToken(val) {
|
|
6830
|
+
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
7253
6831
|
}
|
|
7254
|
-
function
|
|
7255
|
-
return
|
|
6832
|
+
function isAtomicKind(val) {
|
|
6833
|
+
return isString(val) && TT_ATOMICS2.includes(val);
|
|
7256
6834
|
}
|
|
7257
|
-
function
|
|
7258
|
-
|
|
7259
|
-
return isString(val) && codes.includes(val);
|
|
6835
|
+
function isObjectToken(val) {
|
|
6836
|
+
return isTypeToken(val, "obj");
|
|
7260
6837
|
}
|
|
7261
|
-
function
|
|
7262
|
-
|
|
7263
|
-
return isString(val) && codes.includes(val);
|
|
6838
|
+
function isRecordToken(val) {
|
|
6839
|
+
return isTypeToken(val, "rec");
|
|
7264
6840
|
}
|
|
7265
|
-
function
|
|
7266
|
-
|
|
7267
|
-
return isString(val) && codes.includes(val);
|
|
6841
|
+
function isTupleToken(val) {
|
|
6842
|
+
return isTypeToken(val, "tuple");
|
|
7268
6843
|
}
|
|
7269
|
-
function
|
|
7270
|
-
|
|
7271
|
-
return isString(val) && codes.includes(val);
|
|
6844
|
+
function isArrayToken(val) {
|
|
6845
|
+
return isTypeToken(val, "arr");
|
|
7272
6846
|
}
|
|
7273
|
-
function
|
|
7274
|
-
|
|
7275
|
-
|
|
6847
|
+
function isMapToken(val) {
|
|
6848
|
+
return isTypeToken(val, "map");
|
|
6849
|
+
}
|
|
6850
|
+
function isSetToken(val) {
|
|
6851
|
+
return isTypeToken(val, "set");
|
|
6852
|
+
}
|
|
6853
|
+
function isContainerToken(val) {
|
|
6854
|
+
return isObjectToken(val) || isRecordToken(val) || isTupleToken(val) || isArrayToken(val) || isMapToken(val) || isSetToken(val);
|
|
6855
|
+
}
|
|
6856
|
+
function isShapeCallback(val) {
|
|
6857
|
+
return isFunction(val) && val.kind === "shape";
|
|
6858
|
+
}
|
|
6859
|
+
var token_types = [
|
|
6860
|
+
...TT_ATOMICS2,
|
|
6861
|
+
...TT_CONTAINERS2,
|
|
6862
|
+
...TT_FUNCTIONS2,
|
|
6863
|
+
...TT_SETS2,
|
|
6864
|
+
...TT_SINGLETONS2
|
|
6865
|
+
];
|
|
6866
|
+
function isShapeToken(val) {
|
|
6867
|
+
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
7276
6868
|
}
|
|
7277
|
-
|
|
7278
|
-
|
|
6869
|
+
var split_tokens = SIMPLE_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6870
|
+
var scalar_split_tokens = SIMPLE_SCALAR_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6871
|
+
function isSimpleToken(val) {
|
|
6872
|
+
return isString(val) && split_tokens.some(
|
|
6873
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6874
|
+
);
|
|
7279
6875
|
}
|
|
7280
|
-
function
|
|
7281
|
-
|
|
7282
|
-
|
|
6876
|
+
function isSimpleScalarToken(val) {
|
|
6877
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6878
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6879
|
+
);
|
|
7283
6880
|
}
|
|
7284
|
-
function
|
|
7285
|
-
|
|
7286
|
-
|
|
6881
|
+
function isSimpleContainerToken(val) {
|
|
6882
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6883
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6884
|
+
);
|
|
7287
6885
|
}
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
function isUsStateAbbreviation(val) {
|
|
7291
|
-
return isString(val) && ABBREV.includes(val);
|
|
6886
|
+
function isSimpleTokenTuple(val) {
|
|
6887
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleToken);
|
|
7292
6888
|
}
|
|
7293
|
-
function
|
|
7294
|
-
return
|
|
6889
|
+
function isSimpleScalarTokenTuple(val) {
|
|
6890
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleScalarToken);
|
|
7295
6891
|
}
|
|
7296
|
-
function
|
|
7297
|
-
|
|
7298
|
-
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
6892
|
+
function isSimpleContainerTokenTuple(val) {
|
|
6893
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleContainerToken);
|
|
7299
6894
|
}
|
|
7300
|
-
function
|
|
7301
|
-
|
|
7302
|
-
|
|
6895
|
+
function isDefineObject(val) {
|
|
6896
|
+
return isObject(val) && Object.keys(val).some(
|
|
6897
|
+
(key) => isSimpleToken(val[key]) || isShapeToken(val) || isShapeCallback(val)
|
|
6898
|
+
);
|
|
7303
6899
|
}
|
|
7304
|
-
function
|
|
7305
|
-
|
|
6900
|
+
function isFnBasedToken(val) {
|
|
6901
|
+
if (isString(val) && val.startsWith(TT_START2) && val.endsWith(TT_STOP2)) {
|
|
6902
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6903
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6904
|
+
}
|
|
7306
6905
|
}
|
|
7307
|
-
function
|
|
7308
|
-
if (
|
|
7309
|
-
|
|
6906
|
+
function isFnBasedKind(val) {
|
|
6907
|
+
if (isString(val) && isTypeTokenKind(val)) {
|
|
6908
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6909
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
7310
6910
|
}
|
|
7311
|
-
return
|
|
6911
|
+
return false;
|
|
7312
6912
|
}
|
|
7313
|
-
function
|
|
7314
|
-
if (
|
|
7315
|
-
const
|
|
7316
|
-
|
|
7317
|
-
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
6913
|
+
function isSetBasedToken(val) {
|
|
6914
|
+
if (isTypeToken(val)) {
|
|
6915
|
+
const kind = getTokenKind(val);
|
|
6916
|
+
return kind.endsWith(`-set`);
|
|
7318
6917
|
}
|
|
7319
6918
|
return false;
|
|
7320
6919
|
}
|
|
7321
|
-
function
|
|
7322
|
-
return
|
|
6920
|
+
function isSetBasedKind(val) {
|
|
6921
|
+
return isString(val) && val.endsWith(`-set`);
|
|
7323
6922
|
}
|
|
7324
|
-
function
|
|
7325
|
-
return (
|
|
7326
|
-
return !!(isConstant(value) && value.kind === kind);
|
|
7327
|
-
};
|
|
6923
|
+
function isSingletonKind(val) {
|
|
6924
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7328
6925
|
}
|
|
7329
|
-
function
|
|
7330
|
-
|
|
7331
|
-
return !noDefault(value);
|
|
6926
|
+
function isSingletonToken(val) {
|
|
6927
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7332
6928
|
}
|
|
7333
|
-
function
|
|
7334
|
-
|
|
7335
|
-
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
6929
|
+
function isTailwindColorName(val) {
|
|
6930
|
+
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
7336
6931
|
}
|
|
7337
|
-
function
|
|
7338
|
-
return (val)
|
|
7339
|
-
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
7340
|
-
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
7341
|
-
};
|
|
6932
|
+
function isTailwindColorWithLuminosity(val) {
|
|
6933
|
+
return isString(val) && isTailwindColorName(val.split("-")[0]) && (!["white", "black"].includes(val.split("-")[0]) || val.split("-").length === 1) && (!val.includes("-") || Object.keys(TW_LUMINOSITY2).includes(retainAfter(val, "-")));
|
|
7342
6934
|
}
|
|
7343
|
-
function
|
|
7344
|
-
return isString(val) &&
|
|
6935
|
+
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
6936
|
+
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
7345
6937
|
}
|
|
7346
|
-
function
|
|
7347
|
-
return (val)
|
|
7348
|
-
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
7349
|
-
};
|
|
6938
|
+
function isTailwindColor(val) {
|
|
6939
|
+
return isTailwindColorWithLuminosity(val) || isTailwindColorWithLuminosityAndOpacity(val);
|
|
7350
6940
|
}
|
|
7351
|
-
function
|
|
7352
|
-
return (
|
|
6941
|
+
function isTailwindModifier(val) {
|
|
6942
|
+
return isString(val) && TW_MODIFIERS2.includes(val);
|
|
7353
6943
|
}
|
|
7354
|
-
function
|
|
7355
|
-
return
|
|
6944
|
+
function isTailwindColorTarget(val) {
|
|
6945
|
+
return isString(val) && TW_COLOR_TARGETS2.includes(val);
|
|
7356
6946
|
}
|
|
7357
|
-
function
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
6947
|
+
function isTailwindColorClass(val, ...allowedModifiers) {
|
|
6948
|
+
if (isString(val)) {
|
|
6949
|
+
const mods = getTailwindModifiers(val);
|
|
6950
|
+
const targetted = removeTailwindModifiers(val);
|
|
6951
|
+
const target = targetted.split("-")[0];
|
|
6952
|
+
const color = targetted.split("-").slice(1).join("-");
|
|
6953
|
+
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
6954
|
+
}
|
|
6955
|
+
return false;
|
|
7361
6956
|
}
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
return (
|
|
7365
|
-
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
7366
|
-
};
|
|
6957
|
+
var URL = AUSTRALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6958
|
+
function isAustralianNewsUrl(val) {
|
|
6959
|
+
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
7367
6960
|
}
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
};
|
|
6961
|
+
var URL2 = BELGIUM_NEWS2.flatMap((i) => i.baseUrls);
|
|
6962
|
+
function isBelgiumNewsUrl(val) {
|
|
6963
|
+
return isString(val) && val.startsWith("https://") && (URL2.includes(val) || URL2.some((i) => i.startsWith(`${i}/`)));
|
|
7372
6964
|
}
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
};
|
|
6965
|
+
var URL3 = CANADIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6966
|
+
function isCanadianNewsUrl(val) {
|
|
6967
|
+
return isString(val) && val.startsWith("https://") && (URL3.includes(val) || URL3.some((i) => i.startsWith(`${i}/`)));
|
|
7377
6968
|
}
|
|
7378
|
-
|
|
7379
|
-
|
|
6969
|
+
var URL4 = DANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6970
|
+
function isDanishNewsUrl(val) {
|
|
6971
|
+
return isString(val) && val.startsWith("https://") && (URL4.includes(val) || URL4.some((i) => i.startsWith(`${i}/`)));
|
|
7380
6972
|
}
|
|
7381
|
-
|
|
7382
|
-
|
|
6973
|
+
var URL5 = DUTCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6974
|
+
function isDutchNewsUrl(val) {
|
|
6975
|
+
return isString(val) && val.startsWith("https://") && (URL5.includes(val) || URL5.some((i) => i.startsWith(`${i}/`)));
|
|
7383
6976
|
}
|
|
7384
|
-
|
|
7385
|
-
|
|
6977
|
+
var URL6 = FRENCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6978
|
+
function isFrenchNewsUrl(val) {
|
|
6979
|
+
return isString(val) && val.startsWith("https://") && (URL6.includes(val) || URL6.some((i) => i.startsWith(`${i}/`)));
|
|
7386
6980
|
}
|
|
7387
|
-
|
|
7388
|
-
|
|
6981
|
+
var URL7 = GERMAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6982
|
+
function isGermanNewsUrl(val) {
|
|
6983
|
+
return isString(val) && val.startsWith("https://") && (URL7.includes(val) || URL7.some((i) => i.startsWith(`${i}/`)));
|
|
7389
6984
|
}
|
|
7390
|
-
|
|
7391
|
-
|
|
6985
|
+
var URL8 = INDIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6986
|
+
function isIndianNewsUrl(val) {
|
|
6987
|
+
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
7392
6988
|
}
|
|
7393
|
-
|
|
7394
|
-
|
|
6989
|
+
var URL9 = ITALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6990
|
+
function isItalianNewsUrl(val) {
|
|
6991
|
+
return isString(val) && val.startsWith("https://") && (URL9.includes(val) || URL9.some((i) => i.startsWith(`${i}/`)));
|
|
7395
6992
|
}
|
|
7396
|
-
|
|
7397
|
-
|
|
6993
|
+
var URL10 = JAPANESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
6994
|
+
function isJapaneseNewsUrl(val) {
|
|
6995
|
+
return isString(val) && val.startsWith("https://") && (URL10.includes(val) || URL10.some((i) => i.startsWith(`${i}/`)));
|
|
7398
6996
|
}
|
|
7399
|
-
var
|
|
7400
|
-
|
|
7401
|
-
"
|
|
7402
|
-
"initial",
|
|
7403
|
-
"revert",
|
|
7404
|
-
"revert-layer",
|
|
7405
|
-
"unset",
|
|
7406
|
-
"auto"
|
|
7407
|
-
];
|
|
7408
|
-
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
7409
|
-
function isCssAspectRatio(val) {
|
|
7410
|
-
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6997
|
+
var URL11 = MEXICAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6998
|
+
function isMexicanNewsUrl(val) {
|
|
6999
|
+
return isString(val) && val.startsWith("https://") && (URL11.includes(val) || URL11.some((i) => i.startsWith(`${i}/`)));
|
|
7411
7000
|
}
|
|
7412
|
-
|
|
7413
|
-
|
|
7001
|
+
var URL12 = NORWEGIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
7002
|
+
function isNorwegianNewsUrl(val) {
|
|
7003
|
+
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
7414
7004
|
}
|
|
7415
|
-
|
|
7416
|
-
|
|
7005
|
+
var URL13 = SOUTH_KOREAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
7006
|
+
function isSouthKoreanNewsUrl(val) {
|
|
7007
|
+
return isString(val) && val.startsWith("https://") && (URL13.includes(val) || URL13.some((i) => i.startsWith(`${i}/`)));
|
|
7417
7008
|
}
|
|
7418
|
-
|
|
7419
|
-
|
|
7009
|
+
var URL14 = SPANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
7010
|
+
function isSpanishNewsUrl(val) {
|
|
7011
|
+
return isString(val) && val.startsWith("https://") && (URL14.includes(val) || URL14.some((i) => i.startsWith(`${i}/`)));
|
|
7420
7012
|
}
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
}
|
|
7425
|
-
const parts = val?.split("@");
|
|
7426
|
-
const domain = parts[1]?.split(".");
|
|
7427
|
-
const tld = domain ? domain.pop() : "";
|
|
7428
|
-
const firstChar = val[0].toLowerCase();
|
|
7429
|
-
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
7013
|
+
var URL15 = SWISS_NEWS2.flatMap((i) => i.baseUrls);
|
|
7014
|
+
function isSwissNewsUrl(val) {
|
|
7015
|
+
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
7430
7016
|
}
|
|
7431
|
-
|
|
7432
|
-
|
|
7017
|
+
var URL16 = TURKISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
7018
|
+
function isTurkishNewsUrl(val) {
|
|
7019
|
+
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
7433
7020
|
}
|
|
7434
|
-
|
|
7435
|
-
|
|
7021
|
+
var URL17 = UK_NEWS2.flatMap((i) => i.baseUrls);
|
|
7022
|
+
function isUkNewsUrl(val) {
|
|
7023
|
+
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
7436
7024
|
}
|
|
7437
|
-
|
|
7438
|
-
|
|
7025
|
+
var URL18 = US_NEWS2.flatMap((i) => i.baseUrls);
|
|
7026
|
+
function isUsNewsUrl(val) {
|
|
7027
|
+
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
7028
|
+
}
|
|
7029
|
+
var URL19 = CHINESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
7030
|
+
function isChineseNewsUrl(val) {
|
|
7031
|
+
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
7032
|
+
}
|
|
7033
|
+
function isNewsUrl(val) {
|
|
7034
|
+
return isAustralianNewsUrl(val) || isBelgiumNewsUrl(val) || isCanadianNewsUrl(val) || isDanishNewsUrl(val) || isDutchNewsUrl(val) || isFrenchNewsUrl(val) || isGermanNewsUrl(val) || isIndianNewsUrl(val) || isItalianNewsUrl(val) || isJapaneseNewsUrl(val) || isMexicanNewsUrl(val) || isNorwegianNewsUrl(val) || isSouthKoreanNewsUrl(val) || isSpanishNewsUrl(val) || isSwissNewsUrl(val) || isTurkishNewsUrl(val) || isUkNewsUrl(val) || isUsNewsUrl(val);
|
|
7035
|
+
}
|
|
7036
|
+
function isBitbucketUrl(val) {
|
|
7037
|
+
const valid2 = REPO_SOURCE_LOOKUP2.bitbucket;
|
|
7038
|
+
return isString(val) && valid2.some(
|
|
7039
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7040
|
+
);
|
|
7439
7041
|
}
|
|
7440
|
-
function
|
|
7441
|
-
|
|
7042
|
+
function isCodeCommitUrl(val) {
|
|
7043
|
+
const valid2 = REPO_SOURCE_LOOKUP2.codecommit;
|
|
7044
|
+
return isString(val) && valid2.some(
|
|
7045
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7046
|
+
);
|
|
7442
7047
|
}
|
|
7443
|
-
function
|
|
7444
|
-
|
|
7048
|
+
function isGithubUrl(val) {
|
|
7049
|
+
const valid2 = [
|
|
7050
|
+
"https://github.com",
|
|
7051
|
+
"https://www.github.com",
|
|
7052
|
+
"https://github.io"
|
|
7053
|
+
];
|
|
7054
|
+
return isString(val) && valid2.some(
|
|
7055
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7056
|
+
);
|
|
7445
7057
|
}
|
|
7446
|
-
function
|
|
7447
|
-
return
|
|
7058
|
+
function isGithubOrgUrl(val) {
|
|
7059
|
+
return isString(val) && (val.startsWith("https://github.com/") && stripper(val).length === 2);
|
|
7448
7060
|
}
|
|
7449
|
-
function
|
|
7450
|
-
return
|
|
7061
|
+
function stripper(s) {
|
|
7062
|
+
return stripTrailing(
|
|
7063
|
+
stripLeading(s, "https://github.com/"),
|
|
7064
|
+
"/"
|
|
7065
|
+
);
|
|
7451
7066
|
}
|
|
7452
|
-
function
|
|
7453
|
-
return !!(
|
|
7067
|
+
function isGithubRepoUrl(val) {
|
|
7068
|
+
return !!(isString(val) && (val.startsWith("https://github.com/") && stripper(val).split("/").length === 2));
|
|
7454
7069
|
}
|
|
7455
|
-
function
|
|
7456
|
-
return isString(
|
|
7070
|
+
function isGithubRepoReleasesUrl(val) {
|
|
7071
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases") && stripper(val).split("/").length === 3);
|
|
7457
7072
|
}
|
|
7458
|
-
function
|
|
7459
|
-
return val
|
|
7073
|
+
function isGithubRepoReleaseTagUrl(val) {
|
|
7074
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).length === 4);
|
|
7460
7075
|
}
|
|
7461
|
-
function
|
|
7462
|
-
return
|
|
7076
|
+
function isGithubIssuesListUrl(val) {
|
|
7077
|
+
return isString(val) && val.startsWith("https://github.com/") && val.includes("/issues");
|
|
7463
7078
|
}
|
|
7464
|
-
function
|
|
7465
|
-
return
|
|
7079
|
+
function isGithubIssueUrl(val) {
|
|
7080
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/issues/"));
|
|
7466
7081
|
}
|
|
7467
|
-
function
|
|
7468
|
-
return
|
|
7082
|
+
function isGithubProjectsListUrl(val) {
|
|
7083
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/projects?") || val.trim().endsWith("/projects")) && stripper(val).split("/").length === 3);
|
|
7469
7084
|
}
|
|
7470
|
-
function
|
|
7471
|
-
return
|
|
7085
|
+
function isGithubProjectUrl(val) {
|
|
7086
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/projects/") && stripper(val).split("/").length === 4);
|
|
7472
7087
|
}
|
|
7473
|
-
function
|
|
7474
|
-
|
|
7475
|
-
const chars = svelte.split("");
|
|
7476
|
-
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
7477
|
-
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
7478
|
-
const nothing = stripChars(svelte, ...[
|
|
7479
|
-
...NUMERIC_CHAR2,
|
|
7480
|
-
...WHITESPACE_CHARS2,
|
|
7481
|
-
"(",
|
|
7482
|
-
")",
|
|
7483
|
-
"+",
|
|
7484
|
-
".",
|
|
7485
|
-
"-"
|
|
7486
|
-
]);
|
|
7487
|
-
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
7088
|
+
function isGithubReleasesListUrl(val) {
|
|
7089
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/releases?") || val.trim().endsWith("/releases")) && stripper(val).split("/").length === 3);
|
|
7488
7090
|
}
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
if (isString(val)) {
|
|
7492
|
-
return start.some((i) => val.trimStart().startsWith(i));
|
|
7493
|
-
}
|
|
7494
|
-
return false;
|
|
7091
|
+
function isGithubReleaseTagUrl(val) {
|
|
7092
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).split("/").length === 5);
|
|
7495
7093
|
}
|
|
7496
|
-
function
|
|
7497
|
-
|
|
7498
|
-
return maybePhoneNumber(val) && val.trimStart().startsWith(`+1 `);
|
|
7499
|
-
}
|
|
7500
|
-
return false;
|
|
7094
|
+
function isRepoSource(v) {
|
|
7095
|
+
return isString(v) && REPO_SOURCES2.includes(v);
|
|
7501
7096
|
}
|
|
7502
|
-
function
|
|
7503
|
-
|
|
7504
|
-
const cc = getPhoneCountryCode(val);
|
|
7505
|
-
const without = cc === "" ? retainChars(val, ...NUMERIC_CHAR2) : retainChars(val.trimStart().replace(`+${cc} `, ""), ...NUMERIC_CHAR2);
|
|
7506
|
-
switch (cc) {
|
|
7507
|
-
case "1":
|
|
7508
|
-
return without.length === 10;
|
|
7509
|
-
case "44":
|
|
7510
|
-
return !![10, 11].includes(without.length);
|
|
7511
|
-
case "":
|
|
7512
|
-
return without.length <= 10;
|
|
7513
|
-
default:
|
|
7514
|
-
return without.length <= 11;
|
|
7515
|
-
}
|
|
7516
|
-
}
|
|
7517
|
-
return false;
|
|
7097
|
+
function isSemanticVersion(v, allowPrefix = false) {
|
|
7098
|
+
return isString(v) && v.split(".").length === 3 && !Number.isNaN(Number(v.split(".")[1])) && !Number.isNaN(Number(v.split(".")[2])) && (!Number.isNaN(Number(v.split(".")[0])) || allowPrefix && !Number.isNaN(Number(stripLeading(v.split(".")[0], "v").trim())));
|
|
7518
7099
|
}
|
|
7519
|
-
function
|
|
7520
|
-
return
|
|
7100
|
+
function isRepoUrl(val) {
|
|
7101
|
+
return isGithubUrl(val) || isBitbucketUrl(val) || isCodeCommitUrl(val);
|
|
7521
7102
|
}
|
|
7522
|
-
function
|
|
7523
|
-
return
|
|
7103
|
+
function isWholeFoodsUrl(val) {
|
|
7104
|
+
return isString(val) && WHOLE_FOODS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7524
7105
|
}
|
|
7525
|
-
function
|
|
7526
|
-
return val
|
|
7106
|
+
function isCvsUrl(val) {
|
|
7107
|
+
return isString(val) && CVS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7527
7108
|
}
|
|
7528
|
-
function
|
|
7529
|
-
|
|
7530
|
-
return true;
|
|
7531
|
-
}
|
|
7532
|
-
if (isString(val)) {
|
|
7533
|
-
try {
|
|
7534
|
-
const _re = new RegExp(val);
|
|
7535
|
-
return true;
|
|
7536
|
-
} catch {
|
|
7537
|
-
return false;
|
|
7538
|
-
}
|
|
7539
|
-
}
|
|
7540
|
-
return false;
|
|
7109
|
+
function isWalgreensUrl(val) {
|
|
7110
|
+
return isString(val) && WALGREENS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7541
7111
|
}
|
|
7542
|
-
function
|
|
7543
|
-
return
|
|
7112
|
+
function isKrogersUrl(val) {
|
|
7113
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7544
7114
|
}
|
|
7545
|
-
function
|
|
7546
|
-
return isString(
|
|
7115
|
+
function isZaraUrl(val) {
|
|
7116
|
+
return isString(val) && ZARA_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7547
7117
|
}
|
|
7548
|
-
function
|
|
7549
|
-
return
|
|
7118
|
+
function isHmUrl(val) {
|
|
7119
|
+
return isString(val) && HM_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7550
7120
|
}
|
|
7551
|
-
function
|
|
7552
|
-
return val
|
|
7121
|
+
function isDellUrl(val) {
|
|
7122
|
+
return isString(val) && DELL_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7553
7123
|
}
|
|
7554
|
-
function
|
|
7555
|
-
return
|
|
7124
|
+
function isIkeaUrl(val) {
|
|
7125
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7556
7126
|
}
|
|
7557
|
-
function
|
|
7558
|
-
return
|
|
7127
|
+
function isLowesUrl(val) {
|
|
7128
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7559
7129
|
}
|
|
7560
|
-
function
|
|
7561
|
-
return isString(val) &&
|
|
7130
|
+
function isNikeUrl(val) {
|
|
7131
|
+
return isString(val) && NIKE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7562
7132
|
}
|
|
7563
|
-
function
|
|
7564
|
-
return
|
|
7133
|
+
function isWayfairUrl(val) {
|
|
7134
|
+
return isString(val) && WAYFAIR_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7565
7135
|
}
|
|
7566
|
-
function
|
|
7567
|
-
return
|
|
7136
|
+
function isBestBuyUrl(val) {
|
|
7137
|
+
return isString(val) && BEST_BUY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7568
7138
|
}
|
|
7569
|
-
function
|
|
7570
|
-
return isString(val) &&
|
|
7139
|
+
function isCostCoUrl(val) {
|
|
7140
|
+
return isString(val) && COSTCO_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7571
7141
|
}
|
|
7572
|
-
function
|
|
7573
|
-
return
|
|
7142
|
+
function isEtsyUrl(val) {
|
|
7143
|
+
return isString(val) && ETSY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7574
7144
|
}
|
|
7575
|
-
function
|
|
7576
|
-
return
|
|
7145
|
+
function isTargetUrl(val) {
|
|
7146
|
+
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7577
7147
|
}
|
|
7578
|
-
function
|
|
7579
|
-
return
|
|
7148
|
+
function isEbayUrl(val) {
|
|
7149
|
+
return isString(val) && EBAY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7580
7150
|
}
|
|
7581
|
-
function
|
|
7582
|
-
|
|
7583
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
7151
|
+
function isHomeDepotUrl(val) {
|
|
7152
|
+
return isString(val) && HOME_DEPOT_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7584
7153
|
}
|
|
7585
|
-
function
|
|
7586
|
-
|
|
7587
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
7154
|
+
function isMacysUrl(val) {
|
|
7155
|
+
return isString(val) && MACYS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7588
7156
|
}
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
...NUMERIC_CHAR2,
|
|
7592
|
-
"_",
|
|
7593
|
-
"."
|
|
7594
|
-
];
|
|
7595
|
-
var alpha = null;
|
|
7596
|
-
function valid(chars) {
|
|
7597
|
-
return chars.every((i) => VALID.includes(i));
|
|
7157
|
+
function isAppleUrl(val) {
|
|
7158
|
+
return isString(val) && APPLE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7598
7159
|
}
|
|
7599
|
-
function
|
|
7600
|
-
return isString(val) &&
|
|
7160
|
+
function isWalmartUrl(val) {
|
|
7161
|
+
return isString(val) && WALMART_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7601
7162
|
}
|
|
7602
|
-
function
|
|
7603
|
-
return
|
|
7163
|
+
function isAmazonUrl(val) {
|
|
7164
|
+
return isString(val) && AMAZON_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7604
7165
|
}
|
|
7605
|
-
function
|
|
7606
|
-
return
|
|
7166
|
+
function isRetailUrl(val) {
|
|
7167
|
+
return isAmazonUrl(val) || isWalgreensUrl(val) || isAppleUrl(val) || isMacysUrl(val) || isEbayUrl(val) || isHomeDepotUrl(val) || isTargetUrl(val) || isEtsyUrl(val) || isCostCoUrl(val) || isBestBuyUrl(val) || isWayfairUrl(val) || isNikeUrl(val) || isLowesUrl(val) || isIkeaUrl(val) || isDellUrl(val) || isHmUrl(val) || isZaraUrl(val) || isKrogersUrl(val) || isWalgreensUrl(val) || isCvsUrl(val) || isWholeFoodsUrl(val);
|
|
7607
7168
|
}
|
|
7608
|
-
|
|
7609
|
-
|
|
7169
|
+
var URL20 = SOCIAL_MEDIA2.flatMap((i) => i.baseUrls);
|
|
7170
|
+
var PROFILE = SOCIAL_MEDIA2.map((i) => i.profileUrl);
|
|
7171
|
+
function isSocialMediaUrl(val) {
|
|
7172
|
+
return isString(val) && URL20.some((i) => val.startsWith(i));
|
|
7610
7173
|
}
|
|
7611
|
-
function
|
|
7612
|
-
return isString(val) &&
|
|
7174
|
+
function isSocialMediaProfileUrl(val) {
|
|
7175
|
+
return isString(val) && PROFILE.some((i) => i.startsWith(`${i}`));
|
|
7613
7176
|
}
|
|
7614
|
-
function
|
|
7615
|
-
return isString(val) &&
|
|
7177
|
+
function isYouTubeUrl(val) {
|
|
7178
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
7616
7179
|
}
|
|
7617
|
-
function
|
|
7618
|
-
return isString(val) &&
|
|
7180
|
+
function isYouTubeShareUrl(val) {
|
|
7181
|
+
return isString(val) && val.startsWith(`https://youtu.be`);
|
|
7619
7182
|
}
|
|
7620
|
-
function
|
|
7621
|
-
return isString(val) &&
|
|
7183
|
+
function isYouTubeVideoUrl(val) {
|
|
7184
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
7622
7185
|
}
|
|
7623
|
-
function
|
|
7624
|
-
return isString(val) &&
|
|
7186
|
+
function isYouTubePlaylistUrl(val) {
|
|
7187
|
+
return isString(val) && (val === `https://www.youtube.com/feed/playlists` || val === `https://youtube.com/feed/playlists` || val === `https://www.youtube.com/channel/playlists` || val === `https://youtube.com/channel/playlists` || val.startsWith(`https://www.youtube.com/@`) && val.endsWith(`/playlists`) || val.startsWith(`https://youtube.com/@`) && val.endsWith(`/playlists`));
|
|
7625
7188
|
}
|
|
7626
|
-
function
|
|
7627
|
-
return
|
|
7189
|
+
function feed_map(type) {
|
|
7190
|
+
return isUndefined(type) ? `/feed` : type === "liked" ? `/playlist?list=LL` : ["history", "playlists", "trending", "subscriptions"].includes(type) ? `/feed/${type}` : `/feed/`;
|
|
7628
7191
|
}
|
|
7629
|
-
function
|
|
7630
|
-
return isString(val) &&
|
|
7192
|
+
function isYouTubeFeedUrl(val, type) {
|
|
7193
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com${feed_map(type)}`) || val.startsWith(`https://youtube.com${feed_map(type)}`));
|
|
7631
7194
|
}
|
|
7632
|
-
function
|
|
7633
|
-
return isString(val) &&
|
|
7195
|
+
function isYouTubeFeedHistoryUrl(val) {
|
|
7196
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/history`) || val.startsWith(`https://youtube.com/feed/history`));
|
|
7634
7197
|
}
|
|
7635
|
-
function
|
|
7636
|
-
return isString(val) &&
|
|
7198
|
+
function isYouTubePlaylistsUrl(val) {
|
|
7199
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/playlists`) || val.startsWith(`https://youtube.com/feed/playlists`));
|
|
7637
7200
|
}
|
|
7638
|
-
function
|
|
7639
|
-
return isString(val) &&
|
|
7201
|
+
function isYouTubeTrendingUrl(val) {
|
|
7202
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/trending`) || val.startsWith(`https://youtube.com/feed/trending`));
|
|
7640
7203
|
}
|
|
7641
|
-
function
|
|
7642
|
-
return isString(val) &&
|
|
7204
|
+
function isYouTubeSubscriptionsUrl(val) {
|
|
7205
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/subscriptions`) || val.startsWith(`https://youtube.com/feed/subscriptions`));
|
|
7643
7206
|
}
|
|
7644
|
-
function
|
|
7645
|
-
|
|
7646
|
-
return isString(val) && speed.includes(separate(val));
|
|
7207
|
+
function isYouTubeCreatorUrl(url) {
|
|
7208
|
+
return isString(url) && (url.startsWith(`https://www.youtube.com/@`) || url.startsWith(`https://youtube.com/@`) || url.startsWith(`https://www.youtube.com/channel/`));
|
|
7647
7209
|
}
|
|
7648
|
-
function
|
|
7649
|
-
return isString(val) &&
|
|
7210
|
+
function isYouTubeVideosInPlaylist(val) {
|
|
7211
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
|
|
7650
7212
|
}
|
|
7651
|
-
function
|
|
7652
|
-
|
|
7213
|
+
function isVueRef(val) {
|
|
7214
|
+
if (isObject(val)) {
|
|
7215
|
+
const keys = Object.keys(val);
|
|
7216
|
+
return !!["dep", "__v_isRef"].every((i) => keys.includes(i));
|
|
7217
|
+
}
|
|
7218
|
+
return false;
|
|
7653
7219
|
}
|
|
7654
|
-
function
|
|
7655
|
-
return
|
|
7220
|
+
function filterUndefined(...val) {
|
|
7221
|
+
return val.filter((i) => isDefined(i));
|
|
7656
7222
|
}
|
|
7657
|
-
function
|
|
7658
|
-
return
|
|
7223
|
+
function find(list2, deref = null) {
|
|
7224
|
+
return (comparator) => {
|
|
7225
|
+
return list2.find((i) => {
|
|
7226
|
+
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
7227
|
+
return val === comparator;
|
|
7228
|
+
});
|
|
7229
|
+
};
|
|
7659
7230
|
}
|
|
7660
|
-
function
|
|
7661
|
-
|
|
7231
|
+
function getEach(list2, dotPath) {
|
|
7232
|
+
const result2 = list2.map(
|
|
7233
|
+
(i) => isNull(dotPath) ? i : isContainer(i) ? get(i, dotPath) : Never2
|
|
7234
|
+
).filter((i) => !isErrorCondition(i));
|
|
7235
|
+
return result2;
|
|
7662
7236
|
}
|
|
7663
|
-
function
|
|
7664
|
-
|
|
7237
|
+
function indexOf(val, index) {
|
|
7238
|
+
const isNegative = isNumber(index) && index < 0;
|
|
7239
|
+
if (isNegative && !Array.isArray(val)) {
|
|
7240
|
+
throw new Error(`The indexOf(val,idx) utility received a negative index value [${index}] but the value being de-references is not an array [${typeof val}]!`);
|
|
7241
|
+
}
|
|
7242
|
+
if (isNegative && Array.isArray(val) && val.length < Math.abs(index)) {
|
|
7243
|
+
throw new Error(`The indexOf(val,idx) utility received a negative index of ${index} but the length of the array passed in is only ${val.length}! This is not allowed.`);
|
|
7244
|
+
}
|
|
7245
|
+
const idx = isNegative && Array.isArray(val) ? val.length + 1 - Math.abs(index) : index;
|
|
7246
|
+
return index === null ? val : isNull(idx) ? val : isArray(val) ? Number(idx) in val ? val[Number(idx)] : errCondition("invalid-index", `attempt to index a numeric array with an invalid index: ${Number(idx)}`) : isObject(val) ? String(idx) in val ? val[String(idx)] : errCondition("invalid-index", `attempt to index a dictionary object with an invalid index: ${String(idx)}`) : errCondition("invalid-container-type", `Attempt to use indexOf() on an invalid container type: ${typeof val}`);
|
|
7665
7247
|
}
|
|
7666
|
-
function
|
|
7667
|
-
|
|
7248
|
+
function intersectWithOffset(a, b, deref) {
|
|
7249
|
+
const aIndexable = a.every((i) => isIndexable(i));
|
|
7250
|
+
const bIndexable = b.every((i) => isIndexable(i));
|
|
7251
|
+
if (!aIndexable || !bIndexable) {
|
|
7252
|
+
if (!aIndexable) {
|
|
7253
|
+
throw new Error(`The "a" array passed into intersect(a,b) was not fully composed of indexable properties: ${a.map((i) => typeof i).join(", ")}`);
|
|
7254
|
+
} else {
|
|
7255
|
+
throw new Error(`The "b" array passed into intersect(a,b) was not fully composed of indexable properties: ${b.map((i) => typeof i).join(", ")}`);
|
|
7256
|
+
}
|
|
7257
|
+
}
|
|
7258
|
+
const aMatches = getEach(a, deref);
|
|
7259
|
+
const bMatches = getEach(b, deref);
|
|
7260
|
+
const sharedKeys2 = ifNotNull(
|
|
7261
|
+
deref,
|
|
7262
|
+
(v) => [
|
|
7263
|
+
a.filter((i) => Array.from(bMatches).includes(get(i, v))),
|
|
7264
|
+
b.filter((i) => Array.from(aMatches).includes(get(i, v)))
|
|
7265
|
+
],
|
|
7266
|
+
() => a.filter((k) => b.includes(k))
|
|
7267
|
+
);
|
|
7268
|
+
return sharedKeys2;
|
|
7668
7269
|
}
|
|
7669
|
-
function
|
|
7670
|
-
return
|
|
7270
|
+
function intersectNoOffset(a, b) {
|
|
7271
|
+
return a.length < b.length ? a.filter((val) => b.includes(val)) : b.filter((val) => a.includes(val));
|
|
7671
7272
|
}
|
|
7672
|
-
function
|
|
7673
|
-
return
|
|
7273
|
+
function intersection(a, b, deref = null) {
|
|
7274
|
+
return deref === null ? intersectNoOffset(a, b) : intersectWithOffset(a, b, deref);
|
|
7674
7275
|
}
|
|
7675
|
-
function
|
|
7676
|
-
return
|
|
7276
|
+
function joinWith(joinWith2) {
|
|
7277
|
+
return (...tuple3) => {
|
|
7278
|
+
const tup = tuple3;
|
|
7279
|
+
return tup.join(joinWith2);
|
|
7280
|
+
};
|
|
7677
7281
|
}
|
|
7678
|
-
function
|
|
7679
|
-
return
|
|
7282
|
+
function last(list2) {
|
|
7283
|
+
return [...list2].pop();
|
|
7680
7284
|
}
|
|
7681
|
-
function
|
|
7682
|
-
return
|
|
7285
|
+
function logicalReturns(conditions) {
|
|
7286
|
+
return conditions.map(
|
|
7287
|
+
(c) => isBoolean(c) ? c : isFunction(c) ? c() : Never2
|
|
7288
|
+
);
|
|
7683
7289
|
}
|
|
7684
|
-
function
|
|
7685
|
-
return
|
|
7290
|
+
function reverse(list2) {
|
|
7291
|
+
return [...list2].reverse();
|
|
7686
7292
|
}
|
|
7687
|
-
function
|
|
7688
|
-
|
|
7293
|
+
function shift(list2) {
|
|
7294
|
+
let rtn;
|
|
7295
|
+
if (isDefined(list2)) {
|
|
7296
|
+
rtn = list2.length === 0 ? void 0 : list2[0];
|
|
7297
|
+
try {
|
|
7298
|
+
list2 = list2.slice(1);
|
|
7299
|
+
} catch {
|
|
7300
|
+
}
|
|
7301
|
+
} else {
|
|
7302
|
+
rtn = void 0;
|
|
7303
|
+
}
|
|
7304
|
+
return rtn;
|
|
7689
7305
|
}
|
|
7690
|
-
function
|
|
7691
|
-
return
|
|
7306
|
+
function slice(list2, start2, end) {
|
|
7307
|
+
return list2.slice(start2, end);
|
|
7692
7308
|
}
|
|
7693
|
-
function
|
|
7694
|
-
|
|
7309
|
+
function unique(...values) {
|
|
7310
|
+
const u = [];
|
|
7311
|
+
for (const i of values.flat()) {
|
|
7312
|
+
if (!u.includes(i)) {
|
|
7313
|
+
u.push(i);
|
|
7314
|
+
}
|
|
7315
|
+
}
|
|
7316
|
+
return u;
|
|
7695
7317
|
}
|
|
7696
|
-
function
|
|
7697
|
-
|
|
7318
|
+
function box(value) {
|
|
7319
|
+
const rtn = {
|
|
7320
|
+
__type: "box",
|
|
7321
|
+
value,
|
|
7322
|
+
unbox: (...p) => {
|
|
7323
|
+
return typeof value === "function" ? value(...p) : value;
|
|
7324
|
+
}
|
|
7325
|
+
};
|
|
7326
|
+
return rtn;
|
|
7698
7327
|
}
|
|
7699
|
-
function
|
|
7700
|
-
return
|
|
7328
|
+
function isBox(thing) {
|
|
7329
|
+
return typeof thing === "object" && "__type" in thing && thing.__type === "box";
|
|
7701
7330
|
}
|
|
7702
|
-
function
|
|
7703
|
-
|
|
7331
|
+
function boxDictionaryValues(dict) {
|
|
7332
|
+
const keys = Object.keys(dict);
|
|
7333
|
+
return keys.reduce(
|
|
7334
|
+
(acc, key) => ({ ...acc, [key]: box(dict[key]) }),
|
|
7335
|
+
{}
|
|
7336
|
+
);
|
|
7704
7337
|
}
|
|
7705
|
-
function
|
|
7706
|
-
return
|
|
7338
|
+
function unbox(val) {
|
|
7339
|
+
return isBox(val) ? val.value : val;
|
|
7707
7340
|
}
|
|
7708
|
-
function
|
|
7709
|
-
return
|
|
7341
|
+
function capitalize(str) {
|
|
7342
|
+
return `${str?.slice(0, 1).toUpperCase()}${str?.slice(1)}`;
|
|
7710
7343
|
}
|
|
7711
|
-
function
|
|
7712
|
-
|
|
7713
|
-
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
7344
|
+
function cssColor(color, v1, v2, v3, opacity) {
|
|
7345
|
+
return `color(${color} ${v1} ${v2} ${v3}${opacity ? ` / ${opacity}` : ""}`;
|
|
7714
7346
|
}
|
|
7715
|
-
function
|
|
7716
|
-
|
|
7347
|
+
function twColor(color, luminosity) {
|
|
7348
|
+
const lum = luminosity in TW_LUMINOSITY2 ? TW_LUMINOSITY2[luminosity] : 0;
|
|
7349
|
+
const chroma = luminosity in TW_CHROMA2 ? TW_CHROMA2[luminosity] : 0;
|
|
7350
|
+
const hue = TW_HUE2[color];
|
|
7351
|
+
return `oklch(${lum} ${chroma} ${hue})`;
|
|
7717
7352
|
}
|
|
7718
|
-
function
|
|
7719
|
-
|
|
7353
|
+
function ensureLeading(content, ensure) {
|
|
7354
|
+
const output = String(content);
|
|
7355
|
+
return output.startsWith(String(ensure)) ? content : isString(content) ? `${ensure}${content}` : Number(`${ensure}${content}`);
|
|
7720
7356
|
}
|
|
7721
|
-
function
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7357
|
+
function ensureSurround(prefix, postfix) {
|
|
7358
|
+
const fn2 = (input) => {
|
|
7359
|
+
let result2 = input;
|
|
7360
|
+
result2 = ensureLeading(result2, prefix);
|
|
7361
|
+
result2 = ensureTrailing(result2, postfix);
|
|
7362
|
+
return result2;
|
|
7363
|
+
};
|
|
7364
|
+
return fn2;
|
|
7725
7365
|
}
|
|
7726
|
-
function
|
|
7727
|
-
return
|
|
7728
|
-
|
|
7366
|
+
function ensureTrailing(content, ensure) {
|
|
7367
|
+
return (
|
|
7368
|
+
//
|
|
7369
|
+
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
7729
7370
|
);
|
|
7730
7371
|
}
|
|
7731
|
-
function
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7372
|
+
function getTypeSubtype(str) {
|
|
7373
|
+
if (isTypeSubtype(str)) {
|
|
7374
|
+
const [t, st] = str.split("/");
|
|
7375
|
+
return [t, st];
|
|
7376
|
+
} else {
|
|
7377
|
+
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
7378
|
+
err.name = "InvalidTypeSubtype";
|
|
7379
|
+
throw err;
|
|
7380
|
+
}
|
|
7736
7381
|
}
|
|
7737
|
-
function
|
|
7738
|
-
return
|
|
7382
|
+
function identity(...values) {
|
|
7383
|
+
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
7739
7384
|
}
|
|
7740
|
-
function
|
|
7741
|
-
|
|
7385
|
+
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
7386
|
+
if (ch.length !== 1) {
|
|
7387
|
+
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
7388
|
+
}
|
|
7389
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
7742
7390
|
}
|
|
7743
|
-
function
|
|
7744
|
-
|
|
7391
|
+
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
7392
|
+
if (ch.length !== 1) {
|
|
7393
|
+
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
7394
|
+
}
|
|
7395
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
7745
7396
|
}
|
|
7746
|
-
function
|
|
7747
|
-
|
|
7397
|
+
function parseTemplate(template) {
|
|
7398
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
7399
|
+
let lastIndex = 0;
|
|
7400
|
+
let match;
|
|
7401
|
+
const segments = [];
|
|
7402
|
+
while (match = pattern.exec(template)) {
|
|
7403
|
+
const [fullMatch, varName, asType2] = match;
|
|
7404
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
7405
|
+
if (staticPart) {
|
|
7406
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
7407
|
+
}
|
|
7408
|
+
segments.push({
|
|
7409
|
+
dynamic: true,
|
|
7410
|
+
varName,
|
|
7411
|
+
type: asType2 ? asType2 : "string"
|
|
7412
|
+
});
|
|
7413
|
+
lastIndex = match.index + fullMatch.length;
|
|
7414
|
+
}
|
|
7415
|
+
const remainder = template.slice(lastIndex);
|
|
7416
|
+
if (remainder) {
|
|
7417
|
+
segments.push({ dynamic: false, text: remainder });
|
|
7418
|
+
}
|
|
7419
|
+
return segments;
|
|
7748
7420
|
}
|
|
7749
|
-
function
|
|
7750
|
-
return
|
|
7421
|
+
function escapeRegex(str) {
|
|
7422
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7751
7423
|
}
|
|
7752
|
-
function
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
if (
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7424
|
+
function buildRegexPattern(segments) {
|
|
7425
|
+
let regexStr = "^";
|
|
7426
|
+
for (const seg of segments) {
|
|
7427
|
+
if (!seg.dynamic) {
|
|
7428
|
+
regexStr += escapeRegex(seg.text);
|
|
7429
|
+
} else {
|
|
7430
|
+
switch (seg.type) {
|
|
7431
|
+
case "string":
|
|
7432
|
+
regexStr += "(.*?)";
|
|
7433
|
+
break;
|
|
7434
|
+
case "number":
|
|
7435
|
+
regexStr += "(\\d+)";
|
|
7436
|
+
break;
|
|
7437
|
+
case "boolean":
|
|
7438
|
+
regexStr += "(true|false)";
|
|
7439
|
+
break;
|
|
7766
7440
|
}
|
|
7767
7441
|
}
|
|
7768
|
-
return false;
|
|
7769
7442
|
}
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
function isTypeTokenKind(val) {
|
|
7773
|
-
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
7774
|
-
}
|
|
7775
|
-
function isAtomicToken(val) {
|
|
7776
|
-
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
7443
|
+
regexStr += "$";
|
|
7444
|
+
return new RegExp(regexStr);
|
|
7777
7445
|
}
|
|
7778
|
-
function
|
|
7779
|
-
|
|
7446
|
+
function convertValue(type, value) {
|
|
7447
|
+
switch (type) {
|
|
7448
|
+
case "string":
|
|
7449
|
+
return value;
|
|
7450
|
+
case "number":
|
|
7451
|
+
return Number(value);
|
|
7452
|
+
case "boolean":
|
|
7453
|
+
return value === "true";
|
|
7454
|
+
}
|
|
7780
7455
|
}
|
|
7781
|
-
function
|
|
7782
|
-
|
|
7456
|
+
function matchTemplate(template, test) {
|
|
7457
|
+
const segments = parseTemplate(template);
|
|
7458
|
+
const regex = buildRegexPattern(segments);
|
|
7459
|
+
const match = regex.exec(test);
|
|
7460
|
+
if (!match)
|
|
7461
|
+
return false;
|
|
7462
|
+
let captureIndex = 1;
|
|
7463
|
+
const result2 = {};
|
|
7464
|
+
for (const seg of segments) {
|
|
7465
|
+
if (seg.dynamic) {
|
|
7466
|
+
const rawVal = match[captureIndex++];
|
|
7467
|
+
if (rawVal === void 0)
|
|
7468
|
+
return false;
|
|
7469
|
+
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
7470
|
+
}
|
|
7471
|
+
}
|
|
7472
|
+
return result2;
|
|
7783
7473
|
}
|
|
7784
|
-
function
|
|
7785
|
-
return
|
|
7474
|
+
function infer(inference) {
|
|
7475
|
+
return (test) => {
|
|
7476
|
+
return matchTemplate(inference, test);
|
|
7477
|
+
};
|
|
7786
7478
|
}
|
|
7787
|
-
function
|
|
7788
|
-
return
|
|
7479
|
+
function idLiteral(o) {
|
|
7480
|
+
return { ...o, id: o.id };
|
|
7789
7481
|
}
|
|
7790
|
-
function
|
|
7791
|
-
return
|
|
7482
|
+
function nameLiteral(o) {
|
|
7483
|
+
return o;
|
|
7792
7484
|
}
|
|
7793
|
-
function
|
|
7794
|
-
return
|
|
7485
|
+
function kindLiteral(o) {
|
|
7486
|
+
return o;
|
|
7795
7487
|
}
|
|
7796
|
-
function
|
|
7797
|
-
return
|
|
7488
|
+
function idTypeGuard(_o) {
|
|
7489
|
+
return true;
|
|
7798
7490
|
}
|
|
7799
|
-
function
|
|
7800
|
-
return
|
|
7491
|
+
function literal(obj) {
|
|
7492
|
+
return obj;
|
|
7801
7493
|
}
|
|
7802
|
-
function
|
|
7803
|
-
return
|
|
7494
|
+
function lowercase(str) {
|
|
7495
|
+
return str.toLowerCase();
|
|
7804
7496
|
}
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
...TT_CONTAINERS2,
|
|
7808
|
-
...TT_FUNCTIONS2,
|
|
7809
|
-
...TT_SETS2,
|
|
7810
|
-
...TT_SINGLETONS2
|
|
7811
|
-
];
|
|
7812
|
-
function isShapeToken(val) {
|
|
7813
|
-
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
7497
|
+
function narrow(...values) {
|
|
7498
|
+
return values.length === 1 ? values[0] : values;
|
|
7814
7499
|
}
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7500
|
+
function pathJoin(...segments) {
|
|
7501
|
+
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
7502
|
+
const original_path = segments.join("/");
|
|
7503
|
+
const pre = original_path.startsWith("/") ? "/" : "";
|
|
7504
|
+
const post = original_path.endsWith("/") ? "/" : "";
|
|
7505
|
+
return `${pre}${clean_path}${post}`;
|
|
7821
7506
|
}
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7507
|
+
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
7508
|
+
function getPhoneCountryCode(phone) {
|
|
7509
|
+
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
7510
|
+
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
7511
|
+
...NUMERIC_CHAR2
|
|
7512
|
+
) : "";
|
|
7826
7513
|
}
|
|
7827
|
-
function
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7514
|
+
function removePhoneCountryCode(phone) {
|
|
7515
|
+
const countryCode = getPhoneCountryCode(phone);
|
|
7516
|
+
return countryCode !== "" ? stripLeading(stripLeading(
|
|
7517
|
+
phone.trim(),
|
|
7518
|
+
"+",
|
|
7519
|
+
"00"
|
|
7520
|
+
), countryCode).trim() : phone.trim();
|
|
7831
7521
|
}
|
|
7832
|
-
|
|
7833
|
-
|
|
7522
|
+
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
7523
|
+
function endingIn(word, postfix) {
|
|
7524
|
+
switch (postfix) {
|
|
7525
|
+
case "is":
|
|
7526
|
+
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
7527
|
+
case "singular-noun":
|
|
7528
|
+
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
7529
|
+
case "f":
|
|
7530
|
+
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
7531
|
+
case "y":
|
|
7532
|
+
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
7533
|
+
default:
|
|
7534
|
+
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
7535
|
+
}
|
|
7834
7536
|
}
|
|
7835
|
-
function
|
|
7836
|
-
|
|
7537
|
+
function pluralize(word) {
|
|
7538
|
+
const right = rightWhitespace(word);
|
|
7539
|
+
const w = word.trimEnd();
|
|
7540
|
+
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
7541
|
+
return `${result2}${right}`;
|
|
7837
7542
|
}
|
|
7838
|
-
function
|
|
7839
|
-
|
|
7543
|
+
function retainAfter(content, ...find2) {
|
|
7544
|
+
const idx = Math.min(
|
|
7545
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
7546
|
+
);
|
|
7547
|
+
const min = Math.min(...find2.map((i) => i.length));
|
|
7548
|
+
let len = Math.max(...find2.map((i) => i.length));
|
|
7549
|
+
if (min !== len) {
|
|
7550
|
+
if (!find2.includes(content.slice(idx, len))) {
|
|
7551
|
+
len = min;
|
|
7552
|
+
}
|
|
7553
|
+
}
|
|
7554
|
+
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
7840
7555
|
}
|
|
7841
|
-
function
|
|
7842
|
-
|
|
7843
|
-
(
|
|
7556
|
+
function retainAfterInclusive(content, ...find2) {
|
|
7557
|
+
const minFound = Math.min(
|
|
7558
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
7844
7559
|
);
|
|
7560
|
+
return minFound > 0 ? content.slice(minFound) : "";
|
|
7845
7561
|
}
|
|
7846
|
-
function
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
7850
|
-
}
|
|
7562
|
+
function retainChars(content, ...retain2) {
|
|
7563
|
+
const chars = asChars(content);
|
|
7564
|
+
return chars.filter((c) => retain2.includes(c)).join("");
|
|
7851
7565
|
}
|
|
7852
|
-
function
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7566
|
+
function retainUntil(content, ...find2) {
|
|
7567
|
+
const chars = asChars(content);
|
|
7568
|
+
let idx = 0;
|
|
7569
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
7570
|
+
idx = idx + 1;
|
|
7856
7571
|
}
|
|
7857
|
-
return
|
|
7572
|
+
return idx === 0 ? "" : content.slice(0, idx);
|
|
7858
7573
|
}
|
|
7859
|
-
function
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7574
|
+
function retainUntilInclusive(content, ...find2) {
|
|
7575
|
+
const chars = asChars(content);
|
|
7576
|
+
let idx = 0;
|
|
7577
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
7578
|
+
idx = idx + 1;
|
|
7863
7579
|
}
|
|
7864
|
-
return
|
|
7865
|
-
}
|
|
7866
|
-
function isSetBasedKind(val) {
|
|
7867
|
-
return isString(val) && val.endsWith(`-set`);
|
|
7868
|
-
}
|
|
7869
|
-
function isSingletonKind(val) {
|
|
7870
|
-
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7871
|
-
}
|
|
7872
|
-
function isSingletonToken(val) {
|
|
7873
|
-
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7874
|
-
}
|
|
7875
|
-
function isTailwindColorName(val) {
|
|
7876
|
-
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
7877
|
-
}
|
|
7878
|
-
function isTailwindColorWithLuminosity(val) {
|
|
7879
|
-
return isString(val) && isTailwindColorName(val.split("-")[0]) && (!["white", "black"].includes(val.split("-")[0]) || val.split("-").length === 1) && (!val.includes("-") || Object.keys(TW_LUMINOSITY2).includes(retainAfter(val, "-")));
|
|
7880
|
-
}
|
|
7881
|
-
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
7882
|
-
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
7580
|
+
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
7883
7581
|
}
|
|
7884
|
-
function
|
|
7885
|
-
|
|
7582
|
+
function retainWhile(content, ...retain2) {
|
|
7583
|
+
const stopIdx = asChars(content).findIndex((c) => !retain2.includes(c));
|
|
7584
|
+
return content.slice(0, stopIdx);
|
|
7886
7585
|
}
|
|
7887
|
-
function
|
|
7888
|
-
|
|
7586
|
+
function rightWhitespace(content) {
|
|
7587
|
+
const trimmed = content.trimStart();
|
|
7588
|
+
return retainAfterInclusive(
|
|
7589
|
+
trimmed,
|
|
7590
|
+
...WHITESPACE_CHARS2
|
|
7591
|
+
);
|
|
7889
7592
|
}
|
|
7890
|
-
function
|
|
7891
|
-
return
|
|
7593
|
+
function split(str, sep = "") {
|
|
7594
|
+
return str.split(sep);
|
|
7892
7595
|
}
|
|
7893
|
-
function
|
|
7894
|
-
|
|
7895
|
-
const mods = getTailwindModifiers(val);
|
|
7896
|
-
const targetted = removeTailwindModifiers(val);
|
|
7897
|
-
const target = targetted.split("-")[0];
|
|
7898
|
-
const color = targetted.split("-").slice(1).join("-");
|
|
7899
|
-
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
7900
|
-
}
|
|
7901
|
-
return false;
|
|
7596
|
+
function stripAfter(content, find2) {
|
|
7597
|
+
return content.split(find2).shift();
|
|
7902
7598
|
}
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
7599
|
+
function stripBefore(content, find2) {
|
|
7600
|
+
return content.split(find2).slice(1).join(find2);
|
|
7906
7601
|
}
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
return
|
|
7602
|
+
function stripChars(content, ...strip2) {
|
|
7603
|
+
const chars = asChars(content);
|
|
7604
|
+
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
7910
7605
|
}
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7606
|
+
function stripLeading(content, ...strip2) {
|
|
7607
|
+
if (isUndefined(content)) {
|
|
7608
|
+
return void 0;
|
|
7609
|
+
}
|
|
7610
|
+
let output = String(content);
|
|
7611
|
+
for (const s of strip2) {
|
|
7612
|
+
if (output.startsWith(String(s))) {
|
|
7613
|
+
output = output.slice(String(s).length);
|
|
7614
|
+
}
|
|
7615
|
+
}
|
|
7616
|
+
return isNumber(content) ? Number(output) : output;
|
|
7914
7617
|
}
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7618
|
+
function stripSurround(...chars) {
|
|
7619
|
+
return (input) => {
|
|
7620
|
+
let output = String(input);
|
|
7621
|
+
for (const s of chars) {
|
|
7622
|
+
if (output.startsWith(String(s))) {
|
|
7623
|
+
output = output.slice(String(s).length);
|
|
7624
|
+
}
|
|
7625
|
+
if (output.endsWith(String(s))) {
|
|
7626
|
+
output = output.slice(0, -1 * String(s).length);
|
|
7627
|
+
}
|
|
7628
|
+
}
|
|
7629
|
+
return isNumber(input) ? Number(output) : output;
|
|
7630
|
+
};
|
|
7918
7631
|
}
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7632
|
+
function stripTrailing(content, ...strip2) {
|
|
7633
|
+
if (isUndefined(content)) {
|
|
7634
|
+
return void 0;
|
|
7635
|
+
}
|
|
7636
|
+
let output = String(content);
|
|
7637
|
+
for (const s of strip2) {
|
|
7638
|
+
if (output.endsWith(String(s))) {
|
|
7639
|
+
output = output.slice(0, -1 * String(s).length);
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
return isNumber(content) ? Number(output) : output;
|
|
7922
7643
|
}
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
return
|
|
7644
|
+
function stripUntil(content, ...until) {
|
|
7645
|
+
const stopIdx = asChars(content).findIndex((c) => until.includes(c));
|
|
7646
|
+
return content.slice(stopIdx);
|
|
7926
7647
|
}
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
return
|
|
7648
|
+
function stripWhile(content, ...match) {
|
|
7649
|
+
const stopIdx = asChars(content).findIndex((c) => !match.includes(c));
|
|
7650
|
+
return content.slice(stopIdx);
|
|
7930
7651
|
}
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
7652
|
+
function surround(prefix, postfix) {
|
|
7653
|
+
return (input) => `${prefix}${input}${postfix}`;
|
|
7934
7654
|
}
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
return
|
|
7655
|
+
function takeNumericCharacters(content) {
|
|
7656
|
+
const nonNumericIdx = asChars(content).findIndex((i) => !NUMERIC_CHAR2.includes(i));
|
|
7657
|
+
return content.slice(0, nonNumericIdx);
|
|
7938
7658
|
}
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7659
|
+
function toCamelCase(input, preserveWhitespace) {
|
|
7660
|
+
const pascal = preserveWhitespace ? toPascalCase(input, preserveWhitespace) : toPascalCase(input);
|
|
7661
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
7662
|
+
pascal
|
|
7663
|
+
);
|
|
7664
|
+
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
7665
|
+
return camel;
|
|
7942
7666
|
}
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7667
|
+
function toKebabCase(input, _preserveWhitespace = false) {
|
|
7668
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
7669
|
+
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
7670
|
+
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
7671
|
+
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
7672
|
+
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
7673
|
+
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
7674
|
+
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
7675
|
+
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
7676
|
+
replaceTrailingDash(
|
|
7677
|
+
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
7678
|
+
)
|
|
7679
|
+
)}${postWhite}`);
|
|
7946
7680
|
}
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
7681
|
+
function toNumericArray(arr) {
|
|
7682
|
+
return arr.map((i) => Number(i));
|
|
7950
7683
|
}
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7684
|
+
function toPascalCase(input, preserveWhitespace = void 0) {
|
|
7685
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
7686
|
+
input
|
|
7687
|
+
);
|
|
7688
|
+
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
7689
|
+
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
7690
|
+
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
7691
|
+
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
7692
|
+
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
7693
|
+
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
7694
|
+
)}${preserveWhitespace ? postWhite : ""}`;
|
|
7695
|
+
return pascal;
|
|
7954
7696
|
}
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7697
|
+
function toSnakeCase(input, preserveWhitespace = false) {
|
|
7698
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
7699
|
+
const convertInteriorSpace = (input2) => input2.replace(/\s+/g, "_");
|
|
7700
|
+
const convertDashes = (input2) => input2.replace(/-/g, "_");
|
|
7701
|
+
const injectUnderscoreBeforeCaps = (input2) => input2.replace(/([A-Z])/g, "_$1");
|
|
7702
|
+
const removeLeadingUnderscore = (input2) => input2.startsWith("_") ? input2.slice(1) : input2;
|
|
7703
|
+
return ((preserveWhitespace ? preWhite : "") + removeLeadingUnderscore(
|
|
7704
|
+
injectUnderscoreBeforeCaps(convertDashes(convertInteriorSpace(focus)))
|
|
7705
|
+
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
7958
7706
|
}
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
7707
|
+
function toString(val) {
|
|
7708
|
+
return String(val);
|
|
7962
7709
|
}
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
7710
|
+
function toUppercase(str) {
|
|
7711
|
+
return str.split("").map((i) => ifLowercaseChar(i, (v) => capitalize(v), (v) => v)).join("");
|
|
7966
7712
|
}
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
7713
|
+
function trim(input) {
|
|
7714
|
+
return input.trim();
|
|
7970
7715
|
}
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
7716
|
+
function trimLeft(input) {
|
|
7717
|
+
return input.trimStart();
|
|
7974
7718
|
}
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
7719
|
+
function trimStart(input) {
|
|
7720
|
+
return input.trimStart();
|
|
7978
7721
|
}
|
|
7979
|
-
function
|
|
7980
|
-
return
|
|
7722
|
+
function trimRight(input) {
|
|
7723
|
+
return input.trimEnd();
|
|
7981
7724
|
}
|
|
7982
|
-
function
|
|
7983
|
-
|
|
7984
|
-
return isString(val) && valid2.some(
|
|
7985
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7986
|
-
);
|
|
7725
|
+
function trimEnd(input) {
|
|
7726
|
+
return input.trimEnd();
|
|
7987
7727
|
}
|
|
7988
|
-
function
|
|
7989
|
-
const
|
|
7990
|
-
return
|
|
7991
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7992
|
-
);
|
|
7728
|
+
function truncate(content, maxLength, ellipsis = false) {
|
|
7729
|
+
const overLimit = content.length > maxLength;
|
|
7730
|
+
return overLimit ? ellipsis ? `${content.slice(0, maxLength)}${typeof ellipsis === "string" ? ellipsis : "..."}` : content.slice(0, maxLength) : content;
|
|
7993
7731
|
}
|
|
7994
|
-
function
|
|
7995
|
-
const
|
|
7996
|
-
|
|
7997
|
-
"https://www.github.com",
|
|
7998
|
-
"https://github.io"
|
|
7999
|
-
];
|
|
8000
|
-
return isString(val) && valid2.some(
|
|
8001
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
8002
|
-
);
|
|
7732
|
+
function tuple(...values) {
|
|
7733
|
+
const arr = values.length === 1 ? values[0] : values;
|
|
7734
|
+
return asArray(arr);
|
|
8003
7735
|
}
|
|
8004
|
-
function
|
|
8005
|
-
return
|
|
7736
|
+
function uncapitalize(str) {
|
|
7737
|
+
return `${str?.slice(0, 1).toLowerCase()}${str?.slice(1)}`;
|
|
8006
7738
|
}
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
"/"
|
|
8011
|
-
);
|
|
7739
|
+
var unset = "<<unset>>";
|
|
7740
|
+
function uppercase(str) {
|
|
7741
|
+
return str.toUpperCase();
|
|
8012
7742
|
}
|
|
8013
|
-
function
|
|
8014
|
-
return
|
|
7743
|
+
function widen(value) {
|
|
7744
|
+
return value;
|
|
8015
7745
|
}
|
|
8016
|
-
|
|
8017
|
-
|
|
7746
|
+
var PROTOCOLS = Object.values(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i !== "");
|
|
7747
|
+
function getUrlProtocol(url) {
|
|
7748
|
+
const proto = PROTOCOLS.find((p) => url.startsWith(`${p}://`));
|
|
7749
|
+
return proto;
|
|
8018
7750
|
}
|
|
8019
|
-
function
|
|
8020
|
-
return
|
|
7751
|
+
function removeUrlProtocol(url) {
|
|
7752
|
+
return stripBefore(url, "://");
|
|
8021
7753
|
}
|
|
8022
|
-
function
|
|
8023
|
-
|
|
7754
|
+
function ensurePath(val) {
|
|
7755
|
+
const val2 = ensureLeading(val, "/");
|
|
7756
|
+
return val === "" ? "" : stripTrailing(val2, "/");
|
|
8024
7757
|
}
|
|
8025
|
-
function
|
|
8026
|
-
return
|
|
7758
|
+
function getUrlPath(url) {
|
|
7759
|
+
return isUrl(url) ? ensurePath(
|
|
7760
|
+
stripAfter(stripBefore(removeUrlProtocol(url), "/"), "?")
|
|
7761
|
+
) : Never2;
|
|
8027
7762
|
}
|
|
8028
|
-
function
|
|
8029
|
-
|
|
7763
|
+
function getUrlQueryParams(url, specific = void 0) {
|
|
7764
|
+
const qp = stripBefore(url, "?");
|
|
7765
|
+
if (specific) {
|
|
7766
|
+
return qp.includes(`${specific}=`) ? decodeURIComponent(
|
|
7767
|
+
stripAfter(
|
|
7768
|
+
stripBefore(qp, `${specific}=`),
|
|
7769
|
+
"&"
|
|
7770
|
+
).replace(/\+/g, "%20")
|
|
7771
|
+
) : void 0;
|
|
7772
|
+
}
|
|
7773
|
+
return qp === "" ? qp : `?${qp}`;
|
|
8030
7774
|
}
|
|
8031
|
-
function
|
|
8032
|
-
|
|
7775
|
+
function getUrlDefaultPort(url) {
|
|
7776
|
+
const proto = getUrlProtocol(url);
|
|
7777
|
+
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
8033
7778
|
}
|
|
8034
|
-
function
|
|
8035
|
-
|
|
7779
|
+
function getUrlPort(url, resolve = false) {
|
|
7780
|
+
const re = /.*:(\d{2,3})/;
|
|
7781
|
+
const match = url.match(re);
|
|
7782
|
+
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
8036
7783
|
}
|
|
8037
|
-
function
|
|
8038
|
-
|
|
7784
|
+
function getUrlSource(url) {
|
|
7785
|
+
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
7786
|
+
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
8039
7787
|
}
|
|
8040
|
-
function
|
|
8041
|
-
|
|
7788
|
+
function getUrlBase(url) {
|
|
7789
|
+
const path = getUrlPath(url);
|
|
7790
|
+
const remaining = stripAfter(url, path);
|
|
7791
|
+
return remaining;
|
|
8042
7792
|
}
|
|
8043
|
-
function
|
|
8044
|
-
|
|
7793
|
+
function getUrlDynamics(url) {
|
|
7794
|
+
const path = getUrlPath(url);
|
|
7795
|
+
const qp = getUrlQueryParams(url);
|
|
7796
|
+
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
7797
|
+
const segmentTypes = [
|
|
7798
|
+
"string",
|
|
7799
|
+
"number",
|
|
7800
|
+
"boolean",
|
|
7801
|
+
"Opt<string>",
|
|
7802
|
+
"Opt<number>",
|
|
7803
|
+
"Opt<boolean>"
|
|
7804
|
+
];
|
|
7805
|
+
const pathVars = {};
|
|
7806
|
+
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
7807
|
+
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
7808
|
+
const findPathNamed = infer(`<{{infer name}}>`);
|
|
7809
|
+
for (const part of pathParts) {
|
|
7810
|
+
const union4 = findPathUnion(part);
|
|
7811
|
+
const typed = findPathTyped(part);
|
|
7812
|
+
const named = findPathNamed(part);
|
|
7813
|
+
if (union4) {
|
|
7814
|
+
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
7815
|
+
pathVars[union4.name] = `string(${union4.union})`;
|
|
7816
|
+
}
|
|
7817
|
+
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
7818
|
+
pathVars[typed.name] = typed.type;
|
|
7819
|
+
} else if (named && isVariable(named.name)) {
|
|
7820
|
+
pathVars[named.name] = "string";
|
|
7821
|
+
}
|
|
7822
|
+
}
|
|
7823
|
+
const qpVars = {};
|
|
7824
|
+
const qpParts = stripLeading(qp, "?").split("&");
|
|
7825
|
+
for (const p of qpParts) {
|
|
7826
|
+
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
7827
|
+
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
7828
|
+
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
7829
|
+
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
7830
|
+
qpVars[union4.var] = `string(${union4.params})`;
|
|
7831
|
+
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
7832
|
+
qpVars[dynamic.var] = dynamic.val;
|
|
7833
|
+
} else if (fixed && isVariable(fixed.var)) {
|
|
7834
|
+
qpVars[fixed.var] = fixed.val;
|
|
7835
|
+
}
|
|
7836
|
+
}
|
|
7837
|
+
return {
|
|
7838
|
+
pathVars,
|
|
7839
|
+
qpVars,
|
|
7840
|
+
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
7841
|
+
...pathVars,
|
|
7842
|
+
...qpVars
|
|
7843
|
+
}
|
|
7844
|
+
};
|
|
8045
7845
|
}
|
|
8046
|
-
function
|
|
8047
|
-
return
|
|
7846
|
+
function urlMeta(url) {
|
|
7847
|
+
return {
|
|
7848
|
+
url,
|
|
7849
|
+
isUrl: isUrl(url),
|
|
7850
|
+
protocol: getUrlProtocol(url),
|
|
7851
|
+
path: getUrlPath(url),
|
|
7852
|
+
queryParameters: getUrlQueryParams(url),
|
|
7853
|
+
params: getUrlDynamics,
|
|
7854
|
+
port: getUrlPort(url),
|
|
7855
|
+
source: getUrlSource(url),
|
|
7856
|
+
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
7857
|
+
isIp4Address: isIp4Address(getUrlSource(url)),
|
|
7858
|
+
isIp6Address: isIp6Address(getUrlSource(url))
|
|
7859
|
+
};
|
|
8048
7860
|
}
|
|
8049
|
-
function
|
|
8050
|
-
return
|
|
7861
|
+
function getYouTubePageType(url) {
|
|
7862
|
+
return isYouTubeUrl(url) ? isYouTubeVideoUrl(url) && (hasUrlQueryParameter(url, "v") || isYouTubeShareUrl(url)) ? hasUrlQueryParameter(url, "list") ? isYouTubeShareUrl(url) ? hasUrlQueryParameter(url, "t") ? `play::video::in-list::share-link::with-timestamp` : `play::video::in-list::share-link` : `play::video::in-list` : isYouTubeShareUrl(url) ? hasUrlQueryParameter(url, "t") ? `play::video::solo::share-link::with-timestamp` : `play::video::solo::share-link` : `play::video::solo` : isYouTubeCreatorUrl(url) ? getUrlPath(url).includes("/videos") ? "creator::videos" : getUrlPath(url).includes("/playlists") ? "creator::playlists" : last(getUrlPath(url).split("/")).startsWith("@") || getUrlPath(url).includes("/featured") ? "creator::featured" : "creator::other" : isYouTubeFeedUrl(url) ? isYouTubeFeedUrl(url, "history") ? "feed::history" : isYouTubeFeedUrl(url, "playlists") ? "feed::playlists" : isYouTubeFeedUrl(url, "liked") ? "feed::liked" : isYouTubeFeedUrl(url, "subscriptions") ? "feed::subscriptions" : isYouTubeFeedUrl(url, "trending") ? "feed::trending" : "feed::other" : isYouTubeVideosInPlaylist(url) ? "playlist::show" : "other" : Never2;
|
|
8051
7863
|
}
|
|
8052
|
-
function
|
|
8053
|
-
|
|
7864
|
+
function youtubeEmbed(url) {
|
|
7865
|
+
if (hasUrlQueryParameter(url, "v")) {
|
|
7866
|
+
const id = getUrlQueryParams(url, "v");
|
|
7867
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
7868
|
+
} else if (isYouTubeShareUrl(url)) {
|
|
7869
|
+
const id = url.split("/").pop();
|
|
7870
|
+
if (id) {
|
|
7871
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
7872
|
+
} else {
|
|
7873
|
+
throw new Error(`Unexpected problem parsing share URL -- "${url}" -- into a YouTube embed URL`);
|
|
7874
|
+
}
|
|
7875
|
+
} else {
|
|
7876
|
+
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
7877
|
+
}
|
|
8054
7878
|
}
|
|
8055
|
-
function
|
|
8056
|
-
return
|
|
7879
|
+
function youtubeMeta(url) {
|
|
7880
|
+
return isYouTubeUrl(url) ? {
|
|
7881
|
+
url,
|
|
7882
|
+
isYouTubeUrl: true,
|
|
7883
|
+
isShareUrl: isYouTubeShareUrl(url),
|
|
7884
|
+
pageType: getYouTubePageType(url)
|
|
7885
|
+
} : {
|
|
7886
|
+
url,
|
|
7887
|
+
isYouTubeUrl: false
|
|
7888
|
+
};
|
|
8057
7889
|
}
|
|
8058
|
-
function
|
|
8059
|
-
return
|
|
7890
|
+
function queue(state) {
|
|
7891
|
+
return {
|
|
7892
|
+
queue: state,
|
|
7893
|
+
size: state.length,
|
|
7894
|
+
isEmpty() {
|
|
7895
|
+
return state.length === 0;
|
|
7896
|
+
},
|
|
7897
|
+
clear() {
|
|
7898
|
+
state.slice(0, 0);
|
|
7899
|
+
},
|
|
7900
|
+
drain() {
|
|
7901
|
+
const old_state = [...state];
|
|
7902
|
+
state.slice(0, 0);
|
|
7903
|
+
return old_state;
|
|
7904
|
+
},
|
|
7905
|
+
push(...add) {
|
|
7906
|
+
state.push(...add);
|
|
7907
|
+
},
|
|
7908
|
+
drop(quantity) {
|
|
7909
|
+
if (quantity && quantity > state.length) {
|
|
7910
|
+
throw new Error("Cannot drop more elements than present in the queue");
|
|
7911
|
+
}
|
|
7912
|
+
state.splice(0, quantity || 1);
|
|
7913
|
+
},
|
|
7914
|
+
take(quantity) {
|
|
7915
|
+
if (quantity && quantity > state.length) {
|
|
7916
|
+
throw new Error("Cannot take more elements than present in the queue");
|
|
7917
|
+
}
|
|
7918
|
+
const result2 = state.slice(0, quantity || 1);
|
|
7919
|
+
state.splice(0, quantity || 1);
|
|
7920
|
+
return result2;
|
|
7921
|
+
},
|
|
7922
|
+
*[Symbol.iterator]() {
|
|
7923
|
+
for (let i = 0; i < state.length; i++) {
|
|
7924
|
+
yield state[i];
|
|
7925
|
+
}
|
|
7926
|
+
}
|
|
7927
|
+
};
|
|
8060
7928
|
}
|
|
8061
|
-
function
|
|
8062
|
-
return
|
|
7929
|
+
function createFifoQueue(...list2) {
|
|
7930
|
+
return queue([...list2]);
|
|
8063
7931
|
}
|
|
8064
|
-
function
|
|
8065
|
-
return
|
|
7932
|
+
function queue2(state) {
|
|
7933
|
+
return {
|
|
7934
|
+
queue: state,
|
|
7935
|
+
size: state.length,
|
|
7936
|
+
isEmpty() {
|
|
7937
|
+
return state.length === 0;
|
|
7938
|
+
},
|
|
7939
|
+
push(...add) {
|
|
7940
|
+
state.push(...add);
|
|
7941
|
+
},
|
|
7942
|
+
drop(quantity) {
|
|
7943
|
+
state.splice(-quantity);
|
|
7944
|
+
},
|
|
7945
|
+
clear() {
|
|
7946
|
+
state.slice(0, 0);
|
|
7947
|
+
},
|
|
7948
|
+
drain() {
|
|
7949
|
+
const old_state = [...state];
|
|
7950
|
+
state.slice(0, 0);
|
|
7951
|
+
return old_state;
|
|
7952
|
+
},
|
|
7953
|
+
take(quantity) {
|
|
7954
|
+
const result2 = state.slice(-quantity);
|
|
7955
|
+
state.splice(-quantity);
|
|
7956
|
+
return result2;
|
|
7957
|
+
},
|
|
7958
|
+
*[Symbol.iterator]() {
|
|
7959
|
+
for (let i = state.length - 1; i >= 0; i--) {
|
|
7960
|
+
yield state[i];
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
};
|
|
8066
7964
|
}
|
|
8067
|
-
function
|
|
8068
|
-
return
|
|
7965
|
+
function createLifoQueue(...list2) {
|
|
7966
|
+
return queue2([...list2]);
|
|
8069
7967
|
}
|
|
8070
|
-
|
|
8071
|
-
|
|
7968
|
+
var scalarToToken = identity({
|
|
7969
|
+
string: "<<string>>",
|
|
7970
|
+
number: "<<number>>",
|
|
7971
|
+
boolean: "<<boolean>>",
|
|
7972
|
+
true: "<<true>>",
|
|
7973
|
+
false: "<<false>>",
|
|
7974
|
+
null: "<<null>>",
|
|
7975
|
+
undefined: "<<undefined>>",
|
|
7976
|
+
unknown: "<<unknown>>",
|
|
7977
|
+
any: "<<any>>",
|
|
7978
|
+
never: "<<never>>"
|
|
7979
|
+
});
|
|
7980
|
+
function stringLiteral(str) {
|
|
7981
|
+
return stripAfter(stripBefore(str, "string("), ")");
|
|
8072
7982
|
}
|
|
8073
|
-
function
|
|
8074
|
-
return
|
|
7983
|
+
function numericLiteral(str) {
|
|
7984
|
+
return stripAfter(stripBefore(str, "number("), ")");
|
|
8075
7985
|
}
|
|
8076
|
-
function
|
|
8077
|
-
|
|
7986
|
+
function handleOptional(token) {
|
|
7987
|
+
const bare = stripTrailing(stripLeading(token, "Opt<"), ">");
|
|
7988
|
+
return bare.startsWith("string") ? `<<union::[ <<string>>, <<undefined>> ]>>` : bare.startsWith("number") ? `<<union::[ <<number>>, <<undefined>> ]>>` : bare.startsWith("boolean") ? `<<union::[ <<boolean>>, <<undefined>> ]>>` : bare.startsWith("unknown") ? `<<union::[ <<unknown>>, <<undefined>> ]>>` : `<<never>>`;
|
|
8078
7989
|
}
|
|
8079
|
-
function
|
|
8080
|
-
return
|
|
7990
|
+
function simpleScalarTokenToTypeToken(val) {
|
|
7991
|
+
return val in scalarToToken ? scalarToToken[val] : val.startsWith("string(") ? stringLiteral(val).includes(",") ? `<<union::[ ${stringLiteral(val).split(/,\s?/).map((i) => `"${i}"`).join(", ")} ]>>` : `<<string::${stringLiteral(val)}>>` : val.startsWith("number(") ? numericLiteral(val).includes(",") ? `<<union::[ ${numericLiteral(val).split(/,\s?/).join(", ")} ]>>` : `<<number::${numericLiteral(val)}>>` : val.startsWith("Opt<") ? handleOptional(val) : `<<never>>`;
|
|
8081
7992
|
}
|
|
8082
|
-
function
|
|
8083
|
-
return
|
|
7993
|
+
function unionNode(node) {
|
|
7994
|
+
return isNumberLike(node) ? `<<number::${node}>>` : isBooleanLike(node) ? `<<${node}>>` : isSimpleContainerToken(node) ? simpleContainerTokenToTypeToken(node) : isSimpleScalarToken(node) ? simpleScalarToken(node) : `<<string::${node}>>`;
|
|
8084
7995
|
}
|
|
8085
|
-
function
|
|
8086
|
-
return
|
|
7996
|
+
function union2(nodes) {
|
|
7997
|
+
return Array.isArray(nodes) ? nodes.map((n) => unionNode(n)) : nodes.includes(",") ? nodes.split(/,\s?/).map((n) => unionNode(n)).join(", ") : unionNode(nodes);
|
|
8087
7998
|
}
|
|
8088
|
-
|
|
8089
|
-
|
|
7999
|
+
var stripUnion = stripSurround("Union(", ")");
|
|
8000
|
+
function simpleUnionTokenToTypeToken(val) {
|
|
8001
|
+
return val.startsWith(`Union(`) && val.endsWith(`)`) ? `<<union::[ ${union2(stripUnion(val))} ]>>` : Never2;
|
|
8090
8002
|
}
|
|
8091
|
-
function
|
|
8092
|
-
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
8003
|
+
function simpleContainerTokenToTypeToken(_val) {
|
|
8093
8004
|
}
|
|
8094
|
-
function
|
|
8095
|
-
return
|
|
8005
|
+
function asTypeToken(_val) {
|
|
8006
|
+
return "not ready";
|
|
8096
8007
|
}
|
|
8097
|
-
function
|
|
8098
|
-
return
|
|
8008
|
+
function addToken(token, ...params) {
|
|
8009
|
+
return `<<${token}${params.length > 0 ? `::${params.join("::")}` : ""}>>`;
|
|
8099
8010
|
}
|
|
8100
|
-
function
|
|
8101
|
-
return
|
|
8011
|
+
function boolean(literal2) {
|
|
8012
|
+
return isDefined(literal2) ? isTrue(literal2) ? addToken("true") : isFalse(literal2) ? addToken("false") : addToken("boolean") : addToken("boolean");
|
|
8102
8013
|
}
|
|
8103
|
-
|
|
8104
|
-
|
|
8014
|
+
var unknown = () => "<<unknown>>";
|
|
8015
|
+
var undefinedType = () => "<<undefined>>";
|
|
8016
|
+
var nullType = () => "<<null>>";
|
|
8017
|
+
function fn(..._args) {
|
|
8018
|
+
return {
|
|
8019
|
+
returns: (_rtn) => ({
|
|
8020
|
+
addProperties: (_kv) => {
|
|
8021
|
+
return null;
|
|
8022
|
+
},
|
|
8023
|
+
done: () => {
|
|
8024
|
+
return null;
|
|
8025
|
+
}
|
|
8026
|
+
}),
|
|
8027
|
+
done: () => {
|
|
8028
|
+
const result2 = null;
|
|
8029
|
+
return result2;
|
|
8030
|
+
}
|
|
8031
|
+
};
|
|
8105
8032
|
}
|
|
8106
|
-
function
|
|
8107
|
-
return
|
|
8033
|
+
function dictionary(_obj) {
|
|
8034
|
+
return null;
|
|
8108
8035
|
}
|
|
8109
|
-
function
|
|
8110
|
-
return
|
|
8036
|
+
function tuple2(..._elements) {
|
|
8037
|
+
return null;
|
|
8111
8038
|
}
|
|
8112
|
-
function
|
|
8113
|
-
|
|
8039
|
+
function regexToken(re, ...rep) {
|
|
8040
|
+
let exp = "";
|
|
8041
|
+
if (isString(re)) {
|
|
8042
|
+
try {
|
|
8043
|
+
const test = new RegExp(re);
|
|
8044
|
+
if (!isRegExp(test)) {
|
|
8045
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
8046
|
+
err.name = "InvalidRegEx";
|
|
8047
|
+
throw err;
|
|
8048
|
+
} else {
|
|
8049
|
+
exp = re;
|
|
8050
|
+
}
|
|
8051
|
+
} catch {
|
|
8052
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
8053
|
+
err.name = "InvalidRegEx";
|
|
8054
|
+
throw err;
|
|
8055
|
+
}
|
|
8056
|
+
} else if (isRegExp(re)) {
|
|
8057
|
+
exp = re.toString();
|
|
8058
|
+
}
|
|
8059
|
+
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
8060
|
+
return token;
|
|
8114
8061
|
}
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8062
|
+
function addSingleton(token, api2) {
|
|
8063
|
+
return (...literals) => {
|
|
8064
|
+
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
8065
|
+
"union",
|
|
8066
|
+
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
8067
|
+
);
|
|
8068
|
+
};
|
|
8119
8069
|
}
|
|
8120
|
-
|
|
8121
|
-
|
|
8070
|
+
var stringApi = {
|
|
8071
|
+
startsWith: (startsWith2) => addToken(`string-set`, `startsWith::${startsWith2}`),
|
|
8072
|
+
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
8073
|
+
zip: () => addToken("string-set", "Zip5"),
|
|
8074
|
+
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
8075
|
+
zipCode: () => addToken("string-set", "ZipCode"),
|
|
8076
|
+
militaryTime: (resolution) => {
|
|
8077
|
+
return addToken(
|
|
8078
|
+
"string-set",
|
|
8079
|
+
"militaryTime",
|
|
8080
|
+
resolution || "HH:MM"
|
|
8081
|
+
);
|
|
8082
|
+
},
|
|
8083
|
+
civilianTime: (resolution) => {
|
|
8084
|
+
return addToken(
|
|
8085
|
+
"string-set",
|
|
8086
|
+
"militaryTime",
|
|
8087
|
+
resolution || "HH:MM"
|
|
8088
|
+
);
|
|
8089
|
+
},
|
|
8090
|
+
numericString: () => addToken("string-set", "numeric"),
|
|
8091
|
+
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
8092
|
+
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
8093
|
+
regex: (exp, ...literalRepresentation) => {
|
|
8094
|
+
const token = regexToken(exp, ...literalRepresentation);
|
|
8095
|
+
return token;
|
|
8096
|
+
},
|
|
8097
|
+
done: () => addToken("string")
|
|
8098
|
+
};
|
|
8099
|
+
var string22 = addSingleton("string", stringApi);
|
|
8100
|
+
var number = addSingleton("number");
|
|
8101
|
+
function union3(...elements) {
|
|
8102
|
+
const result2 = elements.map((_el) => {
|
|
8103
|
+
});
|
|
8104
|
+
return result2;
|
|
8122
8105
|
}
|
|
8123
|
-
function
|
|
8124
|
-
return
|
|
8106
|
+
function record(_key, _value) {
|
|
8107
|
+
return null;
|
|
8125
8108
|
}
|
|
8126
|
-
function
|
|
8127
|
-
return
|
|
8109
|
+
function array(_type) {
|
|
8110
|
+
return null;
|
|
8128
8111
|
}
|
|
8129
|
-
function
|
|
8130
|
-
return
|
|
8112
|
+
function set(_type) {
|
|
8113
|
+
return null;
|
|
8131
8114
|
}
|
|
8132
|
-
function
|
|
8133
|
-
return
|
|
8115
|
+
function map(_key, _value) {
|
|
8116
|
+
return null;
|
|
8134
8117
|
}
|
|
8135
|
-
function
|
|
8136
|
-
return
|
|
8118
|
+
function weakMap(_key, _value) {
|
|
8119
|
+
return null;
|
|
8137
8120
|
}
|
|
8138
|
-
function
|
|
8139
|
-
return
|
|
8121
|
+
function isAddOrDone(val) {
|
|
8122
|
+
return isObject(val) && hasKeys("add", "done") && typeof val.done === "function" && typeof val.add === "function";
|
|
8140
8123
|
}
|
|
8141
|
-
|
|
8142
|
-
|
|
8124
|
+
var ShapeApiImplementation = {
|
|
8125
|
+
string: string22,
|
|
8126
|
+
number,
|
|
8127
|
+
boolean,
|
|
8128
|
+
unknown,
|
|
8129
|
+
undefined: undefinedType,
|
|
8130
|
+
null: nullType,
|
|
8131
|
+
union: union3,
|
|
8132
|
+
fn,
|
|
8133
|
+
record,
|
|
8134
|
+
array,
|
|
8135
|
+
set,
|
|
8136
|
+
map,
|
|
8137
|
+
weakMap,
|
|
8138
|
+
dictionary,
|
|
8139
|
+
tuple: tuple2
|
|
8140
|
+
};
|
|
8141
|
+
function shape(cb) {
|
|
8142
|
+
const rtn = cb(ShapeApiImplementation);
|
|
8143
|
+
return handleDoneFn(
|
|
8144
|
+
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
8145
|
+
);
|
|
8143
8146
|
}
|
|
8144
|
-
function
|
|
8145
|
-
return isString(
|
|
8147
|
+
function isShape(v) {
|
|
8148
|
+
return !!(isString(v) && v.startsWith("<<") && v.endsWith(">>") && SHAPE_PREFIXES2.some((i) => v.startsWith(`<<${i}`)));
|
|
8146
8149
|
}
|
|
8147
|
-
function
|
|
8148
|
-
|
|
8150
|
+
function asDefineObject(defn) {
|
|
8151
|
+
const result2 = Object.keys(defn).reduce(
|
|
8152
|
+
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
8153
|
+
...acc,
|
|
8154
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
8155
|
+
} : isFunction(defn[i]) ? {
|
|
8156
|
+
...acc,
|
|
8157
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
8158
|
+
} : Never2,
|
|
8159
|
+
{}
|
|
8160
|
+
);
|
|
8161
|
+
return result2;
|
|
8149
8162
|
}
|
|
8150
|
-
function
|
|
8151
|
-
return
|
|
8163
|
+
function asType(...token) {
|
|
8164
|
+
return isFunction(token) ? token(ShapeApiImplementation) : token.length === 1 ? isFunction(token[0]) ? handleDoneFn(token[0](ShapeApiImplementation)) : isDefineObject(token[0]) ? asDefineObject(token[0]) : token[0] : token.map((i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i);
|
|
8152
8165
|
}
|
|
8153
|
-
function
|
|
8154
|
-
return
|
|
8166
|
+
function asStringLiteral(...values) {
|
|
8167
|
+
return values.map((i) => i);
|
|
8155
8168
|
}
|
|
8156
|
-
|
|
8157
|
-
|
|
8169
|
+
var choices = "NOT READY";
|
|
8170
|
+
function doesExtend(type) {
|
|
8171
|
+
return (val) => {
|
|
8172
|
+
let response = false;
|
|
8173
|
+
if (isString(val)) {
|
|
8174
|
+
if (type === "string") {
|
|
8175
|
+
response = true;
|
|
8176
|
+
}
|
|
8177
|
+
if (type.startsWith("string(")) {
|
|
8178
|
+
const literals = stripAfter(
|
|
8179
|
+
stripBefore(type, "string("),
|
|
8180
|
+
")"
|
|
8181
|
+
).split(/,\s*/);
|
|
8182
|
+
if (literals.includes(val)) {
|
|
8183
|
+
response = true;
|
|
8184
|
+
}
|
|
8185
|
+
}
|
|
8186
|
+
}
|
|
8187
|
+
if (isNumber(val)) {
|
|
8188
|
+
if (type === "number") {
|
|
8189
|
+
response = true;
|
|
8190
|
+
}
|
|
8191
|
+
if (type.startsWith("number(")) {
|
|
8192
|
+
const literals = stripAfter(
|
|
8193
|
+
stripBefore(type, "number("),
|
|
8194
|
+
")"
|
|
8195
|
+
).split(/,\s*/).map(Number);
|
|
8196
|
+
if (literals.includes(val)) {
|
|
8197
|
+
response = true;
|
|
8198
|
+
}
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
8202
|
+
response = true;
|
|
8203
|
+
}
|
|
8204
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
8205
|
+
response = true;
|
|
8206
|
+
}
|
|
8207
|
+
if (isBoolean(val)) {
|
|
8208
|
+
if (type === "boolean") {
|
|
8209
|
+
response = true;
|
|
8210
|
+
}
|
|
8211
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
8212
|
+
response = true;
|
|
8213
|
+
}
|
|
8214
|
+
}
|
|
8215
|
+
if (isNarrowableObject(val)) {
|
|
8216
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
8217
|
+
response = true;
|
|
8218
|
+
}
|
|
8219
|
+
if (startsWith("Dict<")(type)) {
|
|
8220
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
8221
|
+
if (match) {
|
|
8222
|
+
const { value } = match;
|
|
8223
|
+
const isOpt = value.includes(`Opt<`);
|
|
8224
|
+
const values = objectValues(val);
|
|
8225
|
+
if (values.every((i) => isOpt ? isString(i) || isUndefined(i) : isString(i)) && type === "Dict<string, string>" || values.every((i) => isOpt ? isUndefined(i) || isNumber(i) : isNumber(i)) && type === "Dict<string, number>" || values.every((i) => isOpt ? isUndefined(i) || isBoolean(i) : isBoolean(i)) && type === "Dict<string, boolean>") {
|
|
8226
|
+
response = true;
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8229
|
+
}
|
|
8230
|
+
}
|
|
8231
|
+
if (isArray(val)) {
|
|
8232
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
8233
|
+
return true;
|
|
8234
|
+
}
|
|
8235
|
+
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
8236
|
+
response = true;
|
|
8237
|
+
}
|
|
8238
|
+
}
|
|
8239
|
+
if (isMap(val)) {
|
|
8240
|
+
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
8241
|
+
response = true;
|
|
8242
|
+
}
|
|
8243
|
+
}
|
|
8244
|
+
if (isSetContainer(val)) {
|
|
8245
|
+
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
8246
|
+
response = true;
|
|
8247
|
+
}
|
|
8248
|
+
}
|
|
8249
|
+
return response;
|
|
8250
|
+
};
|
|
8158
8251
|
}
|
|
8159
|
-
function
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8252
|
+
function ip6Prefix(...groups) {
|
|
8253
|
+
const empty = addToken("string");
|
|
8254
|
+
const count = 4 - groups.length;
|
|
8255
|
+
const fillIn = [];
|
|
8256
|
+
for (let index = 0; index < count; index++) {
|
|
8257
|
+
fillIn.push(empty);
|
|
8163
8258
|
}
|
|
8164
|
-
return
|
|
8259
|
+
return [
|
|
8260
|
+
"<<string::",
|
|
8261
|
+
[
|
|
8262
|
+
groups.join(":"),
|
|
8263
|
+
fillIn.join(":")
|
|
8264
|
+
].join(":"),
|
|
8265
|
+
">>"
|
|
8266
|
+
].join("");
|
|
8165
8267
|
}
|
|
8166
|
-
function
|
|
8167
|
-
const
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8268
|
+
function createProxy(...initialize) {
|
|
8269
|
+
const state = initialize;
|
|
8270
|
+
state.id = null;
|
|
8271
|
+
const proxy = new Proxy(state, {});
|
|
8272
|
+
Object.defineProperty(proxy, "id", {
|
|
8273
|
+
enumerable: false
|
|
8172
8274
|
});
|
|
8173
|
-
return
|
|
8174
|
-
}
|
|
8175
|
-
function fromKeyValue(kvs) {
|
|
8176
|
-
const obj = {};
|
|
8177
|
-
for (const kv of kvs) {
|
|
8178
|
-
obj[kv.key] = kv.value;
|
|
8179
|
-
}
|
|
8180
|
-
return obj;
|
|
8181
|
-
}
|
|
8182
|
-
function intersect(value, _intersectedWith) {
|
|
8183
|
-
return value;
|
|
8184
|
-
}
|
|
8185
|
-
function ip6GroupExpansion(ip) {
|
|
8186
|
-
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
8187
|
-
}
|
|
8188
|
-
function jsonValue(val) {
|
|
8189
|
-
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
8190
|
-
}
|
|
8191
|
-
function jsonValues(...val) {
|
|
8192
|
-
return val.map((i) => jsonValue(i));
|
|
8193
|
-
}
|
|
8194
|
-
function lookupAlpha2Code(code, prop) {
|
|
8195
|
-
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
8196
|
-
return found ? found[prop] : void 0;
|
|
8197
|
-
}
|
|
8198
|
-
function lookupAlpha3Code(code, prop) {
|
|
8199
|
-
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
8200
|
-
return found ? found[prop] : void 0;
|
|
8201
|
-
}
|
|
8202
|
-
function lookupName(name, prop) {
|
|
8203
|
-
const found = ISO3166_12.find((i) => i.name === name);
|
|
8204
|
-
return found ? found[prop] : void 0;
|
|
8205
|
-
}
|
|
8206
|
-
function lookupNumericCode(code, prop) {
|
|
8207
|
-
let num = isNumber(code) ? `${code}` : code;
|
|
8208
|
-
if (num.length === 1) {
|
|
8209
|
-
num = `00${num}`;
|
|
8210
|
-
} else if (num.length === 2) {
|
|
8211
|
-
num = `0${num}`;
|
|
8212
|
-
}
|
|
8213
|
-
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
8214
|
-
return found ? found[prop] : void 0;
|
|
8215
|
-
}
|
|
8216
|
-
function lookupCountryName(code) {
|
|
8217
|
-
const uc = uppercase(code);
|
|
8218
|
-
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
8275
|
+
return proxy;
|
|
8219
8276
|
}
|
|
8220
|
-
function
|
|
8221
|
-
|
|
8222
|
-
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
8277
|
+
function list(...init) {
|
|
8278
|
+
return init.length === 1 && isArray(init[0]) ? createProxy(...init[0]) : createProxy(...init);
|
|
8223
8279
|
}
|
|
8224
|
-
function
|
|
8225
|
-
|
|
8226
|
-
|
|
8280
|
+
function singletonApi(kind) {
|
|
8281
|
+
return {
|
|
8282
|
+
wide: () => `<<${kind}>>`,
|
|
8283
|
+
literal: (val) => `<<${kind}::${val}>>`
|
|
8284
|
+
};
|
|
8227
8285
|
}
|
|
8228
|
-
function
|
|
8229
|
-
|
|
8230
|
-
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
8286
|
+
function setApi(_variant) {
|
|
8287
|
+
return null;
|
|
8231
8288
|
}
|
|
8232
|
-
function
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
map: (from) => {
|
|
8236
|
-
return from.map(fn2);
|
|
8237
|
-
}
|
|
8289
|
+
function fnReturnsApi(variant, _params, returns) {
|
|
8290
|
+
return isSet(returns) ? null : (_rtn) => {
|
|
8291
|
+
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
8238
8292
|
};
|
|
8239
|
-
return createFnWithPropsExplicit(fn2, props);
|
|
8240
8293
|
}
|
|
8241
|
-
function
|
|
8242
|
-
return (
|
|
8243
|
-
|
|
8244
|
-
return Object.keys(map2).reduce(
|
|
8245
|
-
(acc, key) => {
|
|
8246
|
-
const val = map2[key];
|
|
8247
|
-
return {
|
|
8248
|
-
...acc,
|
|
8249
|
-
[key]: isFunction(val) ? val(input) : val
|
|
8250
|
-
};
|
|
8251
|
-
},
|
|
8252
|
-
{}
|
|
8253
|
-
);
|
|
8254
|
-
};
|
|
8255
|
-
return fn2;
|
|
8294
|
+
function fnParamsApi(variant, params, _returns) {
|
|
8295
|
+
return isSet(params) ? null : (params2) => {
|
|
8296
|
+
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
8256
8297
|
};
|
|
8257
8298
|
}
|
|
8258
|
-
function
|
|
8259
|
-
return (
|
|
8260
|
-
return asMapper(fn2);
|
|
8261
|
-
};
|
|
8299
|
+
function fnDoneApi(variant, params, returns) {
|
|
8300
|
+
return isUnset(params) && isUnset(returns) ? `<<` : ``;
|
|
8262
8301
|
}
|
|
8263
|
-
function
|
|
8302
|
+
function fnTokenClosure(kind, params, returns) {
|
|
8264
8303
|
return {
|
|
8265
|
-
|
|
8266
|
-
|
|
8304
|
+
done: fnDoneApi(kind, params, returns),
|
|
8305
|
+
params: fnParamsApi(kind, params, returns),
|
|
8306
|
+
returns: fnReturnsApi(kind, params, returns)
|
|
8267
8307
|
};
|
|
8268
8308
|
}
|
|
8269
|
-
function
|
|
8270
|
-
return
|
|
8309
|
+
function createTypeToken(kind) {
|
|
8310
|
+
return isAtomicKind(kind) ? `<<${kind}>>` : isSingletonKind(kind) ? singletonApi(kind) : isSetBasedKind(kind) ? setApi(kind) : isFnBasedKind(kind) ? handleDoneFn(fnTokenClosure(kind, unset, unset)) : "<<never>>";
|
|
8271
8311
|
}
|
|
8272
|
-
function
|
|
8273
|
-
return
|
|
8312
|
+
function fromDefineObject(defn) {
|
|
8313
|
+
return defn;
|
|
8274
8314
|
}
|
|
8275
|
-
function
|
|
8276
|
-
|
|
8315
|
+
function getTokenKind(token) {
|
|
8316
|
+
const bare = stripSurround("<<", ">>")(token);
|
|
8317
|
+
const parts = bare.split("::");
|
|
8318
|
+
const kind = parts.pop();
|
|
8319
|
+
return kind;
|
|
8277
8320
|
}
|
|
8278
|
-
|
|
8321
|
+
var simpleToken = (token) => token;
|
|
8322
|
+
var simpleScalarToken = (token) => token;
|
|
8323
|
+
var simpleContainerToken = (token) => token;
|
|
8324
|
+
function simpleScalarType(token) {
|
|
8325
|
+
const value = simpleScalarToken(token);
|
|
8279
8326
|
return value;
|
|
8280
8327
|
}
|
|
8281
|
-
function
|
|
8328
|
+
function simpleContainerType(token) {
|
|
8329
|
+
const value = simpleContainerToken(token);
|
|
8282
8330
|
return value;
|
|
8283
8331
|
}
|
|
8284
|
-
function
|
|
8332
|
+
function simpleType(token) {
|
|
8333
|
+
const value = isSimpleScalarToken(token) ? simpleScalarType(token) : isSimpleContainerToken(token) ? simpleContainerToken(token) : Never2;
|
|
8285
8334
|
return value;
|
|
8286
8335
|
}
|
|
8287
|
-
function
|
|
8288
|
-
|
|
8289
|
-
}
|
|
8290
|
-
function sortKeyApi(order) {
|
|
8291
|
-
return {
|
|
8292
|
-
order,
|
|
8293
|
-
toTop: (...keys) => sortKeyApi(
|
|
8294
|
-
[
|
|
8295
|
-
...keys,
|
|
8296
|
-
...order.filter((i) => !keys.includes(i))
|
|
8297
|
-
]
|
|
8298
|
-
),
|
|
8299
|
-
toBottom: (...keys) => sortKeyApi(
|
|
8300
|
-
[
|
|
8301
|
-
...order.filter((i) => !keys.includes(i)),
|
|
8302
|
-
...keys
|
|
8303
|
-
]
|
|
8304
|
-
),
|
|
8305
|
-
done: () => order
|
|
8306
|
-
};
|
|
8307
|
-
}
|
|
8308
|
-
function toKeyValue(obj, sort) {
|
|
8309
|
-
let keys = keysOf(obj);
|
|
8310
|
-
const tuple3 = [];
|
|
8311
|
-
if (sort) {
|
|
8312
|
-
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
8313
|
-
}
|
|
8336
|
+
function hasOverlappingKeys(a, b) {
|
|
8337
|
+
const keys = Object.keys(a);
|
|
8314
8338
|
for (const k of keys) {
|
|
8315
|
-
|
|
8339
|
+
if (k in b) {
|
|
8340
|
+
return true;
|
|
8341
|
+
}
|
|
8316
8342
|
}
|
|
8317
|
-
return
|
|
8343
|
+
return false;
|
|
8318
8344
|
}
|
|
8319
|
-
function
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
case "string":
|
|
8324
|
-
return Number(val);
|
|
8325
|
-
case "boolean":
|
|
8326
|
-
return val ? 1 : 0;
|
|
8327
|
-
default:
|
|
8328
|
-
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
8345
|
+
function uniqueKeys(left, right) {
|
|
8346
|
+
const isNumeric = !!(isArray(left) && isArray(right));
|
|
8347
|
+
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
8348
|
+
throw new Error("uniqueKeys(l,r) given invalid comparison; both left and right values should be an object or an array but not one of each!");
|
|
8329
8349
|
}
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
}
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
return
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
function union3(..._options) {
|
|
8343
|
-
return (value) => value;
|
|
8344
|
-
}
|
|
8345
|
-
function unionize(value, _inUnionWith) {
|
|
8346
|
-
return value;
|
|
8350
|
+
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
8351
|
+
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
8352
|
+
if (isNumeric) {
|
|
8353
|
+
throw new Error("uniqueKeys does not yet work with tuples");
|
|
8354
|
+
}
|
|
8355
|
+
const leftKeys = l.filter((i) => !r.includes(i));
|
|
8356
|
+
const rightKeys = r.filter((i) => !l.includes(i));
|
|
8357
|
+
return [
|
|
8358
|
+
"LeftRight",
|
|
8359
|
+
leftKeys,
|
|
8360
|
+
rightKeys
|
|
8361
|
+
];
|
|
8347
8362
|
}
|
|
8348
8363
|
function asVueRef(value) {
|
|
8349
8364
|
return {
|
|
@@ -8796,6 +8811,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
|
|
|
8796
8811
|
errCondition,
|
|
8797
8812
|
filter,
|
|
8798
8813
|
filterEmpty,
|
|
8814
|
+
filterUndefined,
|
|
8799
8815
|
find,
|
|
8800
8816
|
fnMeta,
|
|
8801
8817
|
fromDefineObject,
|