inferred-types 0.54.2 → 0.54.4

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.
@@ -67,6 +67,7 @@ __export(src_exports, {
67
67
  filter: () => filter,
68
68
  find: () => find,
69
69
  fnMeta: () => fnMeta,
70
+ fromDefineObject: () => fromDefineObject,
70
71
  get: () => get,
71
72
  getDaysBetween: () => getDaysBetween,
72
73
  getEach: () => getEach,
@@ -75,6 +76,7 @@ __export(src_exports, {
75
76
  getToday: () => getToday,
76
77
  getTokenKind: () => getTokenKind,
77
78
  getTomorrow: () => getTomorrow,
79
+ getTypeSubtype: () => getTypeSubtype,
78
80
  getUrlPath: () => getUrlPath,
79
81
  getUrlPort: () => getUrlPort,
80
82
  getUrlProtocol: () => getUrlProtocol,
@@ -315,6 +317,7 @@ __export(src_exports, {
315
317
  isTupleToken: () => isTupleToken,
316
318
  isTurkishNewsUrl: () => isTurkishNewsUrl,
317
319
  isTypeOf: () => isTypeOf,
320
+ isTypeSubtype: () => isTypeSubtype,
318
321
  isTypeToken: () => isTypeToken,
319
322
  isTypeTokenKind: () => isTypeTokenKind,
320
323
  isTypeTuple: () => isTypeTuple,
@@ -2918,235 +2921,6 @@ function ensureTrailing(content, ensure) {
2918
2921
  );
2919
2922
  }
2920
2923
 
2921
- // src/literals/identity.ts
2922
- function identity(...values) {
2923
- return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
2924
- }
2925
-
2926
- // src/literals/ifLowercase.ts
2927
- function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
2928
- if (ch.length !== 1) {
2929
- throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
2930
- }
2931
- return LOWER_ALPHA_CHARS.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
2932
- }
2933
-
2934
- // src/literals/ifUppercase.ts
2935
- function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
2936
- if (ch.length !== 1) {
2937
- throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
2938
- }
2939
- return LOWER_ALPHA_CHARS.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
2940
- }
2941
-
2942
- // src/literals/infer.ts
2943
- function parseTemplate(template) {
2944
- const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
2945
- let lastIndex = 0;
2946
- let match;
2947
- const segments = [];
2948
- do {
2949
- match = pattern.exec(template);
2950
- if (match) {
2951
- const [fullMatch, varName, asType2] = match;
2952
- const staticPart = template.slice(lastIndex, match.index);
2953
- if (staticPart) {
2954
- segments.push({ dynamic: false, text: staticPart });
2955
- }
2956
- segments.push({
2957
- dynamic: true,
2958
- varName,
2959
- type: asType2 ? asType2 : "string"
2960
- });
2961
- lastIndex = match.index + fullMatch.length;
2962
- }
2963
- } while (match);
2964
- const remainder = template.slice(lastIndex);
2965
- if (remainder) {
2966
- segments.push({ dynamic: false, text: remainder });
2967
- }
2968
- return segments;
2969
- }
2970
- function escapeRegex(str) {
2971
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2972
- }
2973
- function buildRegexPattern(segments) {
2974
- let regexStr = "^";
2975
- for (const seg of segments) {
2976
- if (!seg.dynamic) {
2977
- regexStr += escapeRegex(seg.text);
2978
- } else {
2979
- switch (seg.type) {
2980
- case "string":
2981
- regexStr += `(?<${seg.varName}>.*?)`;
2982
- break;
2983
- case "number":
2984
- regexStr += `(?<${seg.varName}>\\d+)`;
2985
- break;
2986
- case "boolean":
2987
- regexStr += `(?<${seg.varName}>(?:true|false))`;
2988
- break;
2989
- }
2990
- }
2991
- }
2992
- regexStr += "$";
2993
- return new RegExp(regexStr, "s");
2994
- }
2995
- function convertValue(type, value) {
2996
- switch (type) {
2997
- case "string":
2998
- return value;
2999
- case "number":
3000
- return Number(value);
3001
- case "boolean":
3002
- return value === "true";
3003
- }
3004
- }
3005
- function matchTemplate(inference, test) {
3006
- const segments = parseTemplate(inference);
3007
- const regex = buildRegexPattern(segments);
3008
- const match = test.match(regex);
3009
- if (!match)
3010
- return false;
3011
- const result2 = {};
3012
- for (const seg of segments) {
3013
- if (seg.dynamic) {
3014
- const rawVal = match.groups?.[seg.varName];
3015
- if (rawVal === void 0)
3016
- return false;
3017
- result2[seg.varName.toLowerCase()] = convertValue(seg.type, rawVal);
3018
- }
3019
- }
3020
- return result2;
3021
- }
3022
- function infer(inference) {
3023
- return (test) => {
3024
- return matchTemplate(inference, test);
3025
- };
3026
- }
3027
-
3028
- // src/literals/literal.ts
3029
- function idLiteral(o) {
3030
- return { ...o, id: o.id };
3031
- }
3032
- function nameLiteral(o) {
3033
- return o;
3034
- }
3035
- function kindLiteral(o) {
3036
- return o;
3037
- }
3038
- function idTypeGuard(_o) {
3039
- return true;
3040
- }
3041
- function literal(obj) {
3042
- return obj;
3043
- }
3044
-
3045
- // src/literals/lowercase.ts
3046
- function lowercase(str) {
3047
- return str.toLowerCase();
3048
- }
3049
-
3050
- // src/literals/narrow.ts
3051
- function narrow(...values) {
3052
- return values.length === 1 ? values[0] : values;
3053
- }
3054
-
3055
- // src/literals/pathJoin.ts
3056
- function pathJoin(...segments) {
3057
- const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
3058
- const original_path = segments.join("/");
3059
- const pre = original_path.startsWith("/") ? "/" : "";
3060
- const post = original_path.endsWith("/") ? "/" : "";
3061
- return `${pre}${clean_path}${post}`;
3062
- }
3063
-
3064
- // src/literals/phone/asPhoneNumber.ts
3065
- var asPhoneFormat = () => `NOT IMPLEMENTED`;
3066
-
3067
- // src/literals/phone/getPhoneCountryCode.ts
3068
- function getPhoneCountryCode(phone) {
3069
- return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
3070
- stripLeading(stripLeading(phone.trim(), "+"), "00"),
3071
- ...NUMERIC_CHAR
3072
- ) : "";
3073
- }
3074
-
3075
- // src/literals/phone/removePhoneCountryCode.ts
3076
- function removePhoneCountryCode(phone) {
3077
- const countryCode = getPhoneCountryCode(phone);
3078
- return countryCode !== "" ? stripLeading(stripLeading(
3079
- phone.trim(),
3080
- "+",
3081
- "00"
3082
- ), countryCode).trim() : phone.trim();
3083
- }
3084
-
3085
- // src/literals/pluralize.ts
3086
- var isException = (word) => Object.keys(PLURAL_EXCEPTIONS).includes(word);
3087
- function endingIn(word, postfix) {
3088
- switch (postfix) {
3089
- case "is":
3090
- return word.endsWith(postfix) ? `${word}es` : void 0;
3091
- case "singular-noun":
3092
- return SINGULAR_NOUN_ENDINGS.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS].includes(i)) ? `${word}es` : void 0 : void 0;
3093
- case "f":
3094
- return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
3095
- case "y":
3096
- return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
3097
- default:
3098
- throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
3099
- }
3100
- }
3101
- function pluralize(word) {
3102
- const right = rightWhitespace(word);
3103
- const w = word.trimEnd();
3104
- const result2 = isException(w) ? PLURAL_EXCEPTIONS[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
3105
- return `${result2}${right}`;
3106
- }
3107
-
3108
- // src/literals/retainAfter.ts
3109
- function retainAfter(content, ...find2) {
3110
- const idx = Math.min(
3111
- ...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
3112
- );
3113
- const min = Math.min(...find2.map((i) => i.length));
3114
- let len = Math.max(...find2.map((i) => i.length));
3115
- if (min !== len) {
3116
- if (!find2.includes(content.slice(idx, len))) {
3117
- len = min;
3118
- }
3119
- }
3120
- return idx && idx > 0 ? content.slice(idx + len) : "";
3121
- }
3122
- function retainAfterInclusive(content, ...find2) {
3123
- const minFound = Math.min(
3124
- ...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
3125
- );
3126
- return minFound > 0 ? content.slice(minFound) : "";
3127
- }
3128
-
3129
- // src/type-conversion/asChars.ts
3130
- function asChars(str) {
3131
- return str.split("");
3132
- }
3133
-
3134
- // src/literals/retainChars.ts
3135
- function retainChars(content, ...retain2) {
3136
- const chars = asChars(content);
3137
- return chars.filter((c) => retain2.includes(c)).join("");
3138
- }
3139
-
3140
- // src/type-conversion/asRecord.ts
3141
- function asRecord(obj) {
3142
- return obj;
3143
- }
3144
-
3145
- // src/type-conversion/asString.ts
3146
- function asString(value) {
3147
- return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
3148
- }
3149
-
3150
2924
  // src/type-guards/isFunction.ts
3151
2925
  function isFunction(value) {
3152
2926
  return typeof value === "function";
@@ -3478,6 +3252,190 @@ function hasKeys(...props) {
3478
3252
  };
3479
3253
  }
3480
3254
 
3255
+ // src/type-conversion/asChars.ts
3256
+ function asChars(str) {
3257
+ return str.split("");
3258
+ }
3259
+
3260
+ // src/type-conversion/asRecord.ts
3261
+ function asRecord(obj) {
3262
+ return obj;
3263
+ }
3264
+
3265
+ // src/type-conversion/asString.ts
3266
+ function asString(value) {
3267
+ return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
3268
+ }
3269
+
3270
+ // src/type-conversion/csv.ts
3271
+ function csv(csv2, format = `string-numeric-tuple`) {
3272
+ const tuple3 = [];
3273
+ csv2.split(/,\s?/).forEach((v) => {
3274
+ tuple3.push(
3275
+ 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}` : Never
3276
+ );
3277
+ });
3278
+ return tuple3;
3279
+ }
3280
+
3281
+ // src/type-conversion/intersect.ts
3282
+ function intersect(value, _intersectedWith) {
3283
+ return value;
3284
+ }
3285
+
3286
+ // src/literals/stripTrailing.ts
3287
+ function stripTrailing(content, ...strip2) {
3288
+ let output = String(content);
3289
+ for (const s of strip2) {
3290
+ if (output.endsWith(String(s))) {
3291
+ output = output.slice(0, -1 * String(s).length);
3292
+ }
3293
+ }
3294
+ return isNumber(content) ? Number(output) : output;
3295
+ }
3296
+
3297
+ // src/type-conversion/ip6GroupExpansion.ts
3298
+ function ip6GroupExpansion(ip) {
3299
+ return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
3300
+ }
3301
+
3302
+ // src/type-conversion/json.ts
3303
+ function jsonValue(val) {
3304
+ return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
3305
+ }
3306
+ function jsonValues(...val) {
3307
+ return val.map((i) => jsonValue(i));
3308
+ }
3309
+
3310
+ // src/type-conversion/lookupCountry.ts
3311
+ function lookupAlpha2Code(code, prop) {
3312
+ const found = ISO3166_1.find((i) => i.alpha2 === code);
3313
+ return found ? found[prop] : void 0;
3314
+ }
3315
+ function lookupAlpha3Code(code, prop) {
3316
+ const found = ISO3166_1.find((i) => i.alpha3 === code);
3317
+ return found ? found[prop] : void 0;
3318
+ }
3319
+ function lookupName(name, prop) {
3320
+ const found = ISO3166_1.find((i) => i.name === name);
3321
+ return found ? found[prop] : void 0;
3322
+ }
3323
+ function lookupNumericCode(code, prop) {
3324
+ let num = isNumber(code) ? `${code}` : code;
3325
+ if (num.length === 1) {
3326
+ num = `00${num}`;
3327
+ } else if (num.length === 2) {
3328
+ num = `0${num}`;
3329
+ }
3330
+ const found = ISO3166_1.find((i) => i.countryCode === num);
3331
+ return found ? found[prop] : void 0;
3332
+ }
3333
+ function lookupCountryName(code) {
3334
+ const uc = uppercase(code);
3335
+ return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
3336
+ }
3337
+ function lookupCountryAlpha2(code) {
3338
+ const uc = uppercase(code);
3339
+ return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
3340
+ }
3341
+ function lookupCountryAlpha3(token) {
3342
+ const uc = uppercase(token);
3343
+ return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
3344
+ }
3345
+ function lookupCountryCode(token) {
3346
+ const uc = uppercase(token);
3347
+ return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
3348
+ }
3349
+
3350
+ // src/type-conversion/mergeObjects.ts
3351
+ function mergeObjects(defVal, override) {
3352
+ const intersectingKeys = sharedKeys(defVal, override);
3353
+ const defUnique = withoutKeys(defVal, ...intersectingKeys);
3354
+ const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
3355
+ const merged = {
3356
+ ...intersectingKeys.reduce(
3357
+ (acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
3358
+ {}
3359
+ ),
3360
+ ...defUnique,
3361
+ ...overrideUnique
3362
+ };
3363
+ return merged;
3364
+ }
3365
+
3366
+ // src/type-guards/isUndefined.ts
3367
+ function isUndefined(value) {
3368
+ return typeof value === "undefined";
3369
+ }
3370
+
3371
+ // src/type-conversion/mergeScalars.ts
3372
+ function mergeScalars(a, b) {
3373
+ return isUndefined(b) ? a : b;
3374
+ }
3375
+
3376
+ // src/type-conversion/mergeTuples.ts
3377
+ function mergeTuples(a, b) {
3378
+ 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]);
3379
+ }
3380
+
3381
+ // src/type-conversion/never.ts
3382
+ function never(val) {
3383
+ return val;
3384
+ }
3385
+
3386
+ // src/type-conversion/optional.ts
3387
+ function optional(value) {
3388
+ return value;
3389
+ }
3390
+ function orNull(value) {
3391
+ return value;
3392
+ }
3393
+ function optionalOrNull(value) {
3394
+ return value;
3395
+ }
3396
+
3397
+ // src/type-conversion/stripParenthesis.ts
3398
+ function stripParenthesis(val) {
3399
+ return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
3400
+ }
3401
+
3402
+ // src/type-conversion/toNumber.ts
3403
+ function convertScalar(val) {
3404
+ switch (typeof val) {
3405
+ case "number":
3406
+ return val;
3407
+ case "string":
3408
+ return Number(val);
3409
+ case "boolean":
3410
+ return val ? 1 : 0;
3411
+ default:
3412
+ throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
3413
+ }
3414
+ }
3415
+ var convertList = (val) => val.map((i) => convertScalar(i));
3416
+ function toNumber(value) {
3417
+ return Array.isArray(value) ? convertList(value) : convertScalar(value);
3418
+ }
3419
+
3420
+ // src/type-conversion/tw-conversion.ts
3421
+ var MODS = TW_MODIFIERS.map((i) => `${i}:`);
3422
+ function removeTailwindModifiers(val) {
3423
+ return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
3424
+ }
3425
+ function getTailwindModifiers(val) {
3426
+ return val.split(":").filter((i) => isTailwindModifier(i));
3427
+ }
3428
+
3429
+ // src/type-conversion/union.ts
3430
+ function union(..._options) {
3431
+ return (value) => value;
3432
+ }
3433
+
3434
+ // src/type-conversion/unionize.ts
3435
+ function unionize(value, _inUnionWith) {
3436
+ return value;
3437
+ }
3438
+
3481
3439
  // src/type-guards/hasWhitespace.ts
3482
3440
  function hasWhiteSpace(val) {
3483
3441
  return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS.includes(c));
@@ -3723,16 +3681,16 @@ function isTruthy(val) {
3723
3681
  return !FALSY_VALUES.includes(val);
3724
3682
  }
3725
3683
 
3684
+ // src/type-guards/isTypeSubtype.ts
3685
+ function isTypeSubtype(val) {
3686
+ return isString(val) && val.split("/").length === 2;
3687
+ }
3688
+
3726
3689
  // src/type-guards/isTypeTuple.ts
3727
3690
  function isTypeTuple(value) {
3728
3691
  return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
3729
3692
  }
3730
3693
 
3731
- // src/type-guards/isUndefined.ts
3732
- function isUndefined(value) {
3733
- return typeof value === "undefined";
3734
- }
3735
-
3736
3694
  // src/type-guards/isUnset.ts
3737
3695
  function isUnset(val) {
3738
3696
  return isObject(val) && val.kind === "Unset";
@@ -4382,168 +4340,230 @@ function isYouTubeVideosInPlaylist(val) {
4382
4340
  return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
4383
4341
  }
4384
4342
 
4385
- // src/type-conversion/csv.ts
4386
- function csv(csv2, format = `string-numeric-tuple`) {
4387
- const tuple3 = [];
4388
- csv2.split(/,\s?/).forEach((v) => {
4389
- tuple3.push(
4390
- 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}` : Never
4391
- );
4392
- });
4393
- return tuple3;
4343
+ // src/literals/getTypeSubtype.ts
4344
+ function getTypeSubtype(str) {
4345
+ if (isTypeSubtype(str)) {
4346
+ const [t, st] = str.split("/");
4347
+ return [t, st];
4348
+ } else {
4349
+ const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
4350
+ err.name = "InvalidTypeSubtype";
4351
+ throw err;
4352
+ }
4353
+ }
4354
+
4355
+ // src/literals/identity.ts
4356
+ function identity(...values) {
4357
+ return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
4358
+ }
4359
+
4360
+ // src/literals/ifLowercase.ts
4361
+ function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
4362
+ if (ch.length !== 1) {
4363
+ throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
4364
+ }
4365
+ return LOWER_ALPHA_CHARS.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
4366
+ }
4367
+
4368
+ // src/literals/ifUppercase.ts
4369
+ function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
4370
+ if (ch.length !== 1) {
4371
+ throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
4372
+ }
4373
+ return LOWER_ALPHA_CHARS.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
4374
+ }
4375
+
4376
+ // src/literals/infer.ts
4377
+ function parseTemplate(template) {
4378
+ const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
4379
+ let lastIndex = 0;
4380
+ let match;
4381
+ const segments = [];
4382
+ do {
4383
+ match = pattern.exec(template);
4384
+ if (match) {
4385
+ const [fullMatch, varName, asType2] = match;
4386
+ const staticPart = template.slice(lastIndex, match.index);
4387
+ if (staticPart) {
4388
+ segments.push({ dynamic: false, text: staticPart });
4389
+ }
4390
+ segments.push({
4391
+ dynamic: true,
4392
+ varName,
4393
+ type: asType2 ? asType2 : "string"
4394
+ });
4395
+ lastIndex = match.index + fullMatch.length;
4396
+ }
4397
+ } while (match);
4398
+ const remainder = template.slice(lastIndex);
4399
+ if (remainder) {
4400
+ segments.push({ dynamic: false, text: remainder });
4401
+ }
4402
+ return segments;
4394
4403
  }
4395
-
4396
- // src/type-conversion/intersect.ts
4397
- function intersect(value, _intersectedWith) {
4398
- return value;
4404
+ function escapeRegex(str) {
4405
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4399
4406
  }
4400
-
4401
- // src/literals/stripTrailing.ts
4402
- function stripTrailing(content, ...strip2) {
4403
- let output = String(content);
4404
- for (const s of strip2) {
4405
- if (output.endsWith(String(s))) {
4406
- output = output.slice(0, -1 * String(s).length);
4407
+ function buildRegexPattern(segments) {
4408
+ let regexStr = "^";
4409
+ for (const seg of segments) {
4410
+ if (!seg.dynamic) {
4411
+ regexStr += escapeRegex(seg.text);
4412
+ } else {
4413
+ switch (seg.type) {
4414
+ case "string":
4415
+ regexStr += `(?<${seg.varName}>.*?)`;
4416
+ break;
4417
+ case "number":
4418
+ regexStr += `(?<${seg.varName}>\\d+)`;
4419
+ break;
4420
+ case "boolean":
4421
+ regexStr += `(?<${seg.varName}>(?:true|false))`;
4422
+ break;
4423
+ }
4407
4424
  }
4408
4425
  }
4409
- return isNumber(content) ? Number(output) : output;
4426
+ regexStr += "$";
4427
+ return new RegExp(regexStr, "s");
4410
4428
  }
4411
-
4412
- // src/type-conversion/ip6GroupExpansion.ts
4413
- function ip6GroupExpansion(ip) {
4414
- return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
4429
+ function convertValue(type, value) {
4430
+ switch (type) {
4431
+ case "string":
4432
+ return value;
4433
+ case "number":
4434
+ return Number(value);
4435
+ case "boolean":
4436
+ return value === "true";
4437
+ }
4415
4438
  }
4416
-
4417
- // src/type-conversion/json.ts
4418
- function jsonValue(val) {
4419
- return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
4439
+ function matchTemplate(inference, test) {
4440
+ const segments = parseTemplate(inference);
4441
+ const regex = buildRegexPattern(segments);
4442
+ const match = test.match(regex);
4443
+ if (!match)
4444
+ return false;
4445
+ const result2 = {};
4446
+ for (const seg of segments) {
4447
+ if (seg.dynamic) {
4448
+ const rawVal = match.groups?.[seg.varName];
4449
+ if (rawVal === void 0)
4450
+ return false;
4451
+ result2[seg.varName.toLowerCase()] = convertValue(seg.type, rawVal);
4452
+ }
4453
+ }
4454
+ return result2;
4420
4455
  }
4421
- function jsonValues(...val) {
4422
- return val.map((i) => jsonValue(i));
4456
+ function infer(inference) {
4457
+ return (test) => {
4458
+ return matchTemplate(inference, test);
4459
+ };
4423
4460
  }
4424
4461
 
4425
- // src/type-conversion/lookupCountry.ts
4426
- function lookupAlpha2Code(code, prop) {
4427
- const found = ISO3166_1.find((i) => i.alpha2 === code);
4428
- return found ? found[prop] : void 0;
4429
- }
4430
- function lookupAlpha3Code(code, prop) {
4431
- const found = ISO3166_1.find((i) => i.alpha3 === code);
4432
- return found ? found[prop] : void 0;
4433
- }
4434
- function lookupName(name, prop) {
4435
- const found = ISO3166_1.find((i) => i.name === name);
4436
- return found ? found[prop] : void 0;
4437
- }
4438
- function lookupNumericCode(code, prop) {
4439
- let num = isNumber(code) ? `${code}` : code;
4440
- if (num.length === 1) {
4441
- num = `00${num}`;
4442
- } else if (num.length === 2) {
4443
- num = `0${num}`;
4444
- }
4445
- const found = ISO3166_1.find((i) => i.countryCode === num);
4446
- return found ? found[prop] : void 0;
4462
+ // src/literals/literal.ts
4463
+ function idLiteral(o) {
4464
+ return { ...o, id: o.id };
4447
4465
  }
4448
- function lookupCountryName(code) {
4449
- const uc = uppercase(code);
4450
- return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
4466
+ function nameLiteral(o) {
4467
+ return o;
4451
4468
  }
4452
- function lookupCountryAlpha2(code) {
4453
- const uc = uppercase(code);
4454
- return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
4469
+ function kindLiteral(o) {
4470
+ return o;
4455
4471
  }
4456
- function lookupCountryAlpha3(token) {
4457
- const uc = uppercase(token);
4458
- return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
4472
+ function idTypeGuard(_o) {
4473
+ return true;
4459
4474
  }
4460
- function lookupCountryCode(token) {
4461
- const uc = uppercase(token);
4462
- return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
4475
+ function literal(obj) {
4476
+ return obj;
4463
4477
  }
4464
4478
 
4465
- // src/type-conversion/mergeObjects.ts
4466
- function mergeObjects(defVal, override) {
4467
- const intersectingKeys = sharedKeys(defVal, override);
4468
- const defUnique = withoutKeys(defVal, ...intersectingKeys);
4469
- const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
4470
- const merged = {
4471
- ...intersectingKeys.reduce(
4472
- (acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
4473
- {}
4474
- ),
4475
- ...defUnique,
4476
- ...overrideUnique
4477
- };
4478
- return merged;
4479
+ // src/literals/lowercase.ts
4480
+ function lowercase(str) {
4481
+ return str.toLowerCase();
4479
4482
  }
4480
4483
 
4481
- // src/type-conversion/mergeScalars.ts
4482
- function mergeScalars(a, b) {
4483
- return isUndefined(b) ? a : b;
4484
+ // src/literals/narrow.ts
4485
+ function narrow(...values) {
4486
+ return values.length === 1 ? values[0] : values;
4484
4487
  }
4485
4488
 
4486
- // src/type-conversion/mergeTuples.ts
4487
- function mergeTuples(a, b) {
4488
- 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]);
4489
+ // src/literals/pathJoin.ts
4490
+ function pathJoin(...segments) {
4491
+ const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
4492
+ const original_path = segments.join("/");
4493
+ const pre = original_path.startsWith("/") ? "/" : "";
4494
+ const post = original_path.endsWith("/") ? "/" : "";
4495
+ return `${pre}${clean_path}${post}`;
4489
4496
  }
4490
4497
 
4491
- // src/type-conversion/never.ts
4492
- function never(val) {
4493
- return val;
4494
- }
4498
+ // src/literals/phone/asPhoneNumber.ts
4499
+ var asPhoneFormat = () => `NOT IMPLEMENTED`;
4495
4500
 
4496
- // src/type-conversion/optional.ts
4497
- function optional(value) {
4498
- return value;
4499
- }
4500
- function orNull(value) {
4501
- return value;
4502
- }
4503
- function optionalOrNull(value) {
4504
- return value;
4501
+ // src/literals/phone/getPhoneCountryCode.ts
4502
+ function getPhoneCountryCode(phone) {
4503
+ return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
4504
+ stripLeading(stripLeading(phone.trim(), "+"), "00"),
4505
+ ...NUMERIC_CHAR
4506
+ ) : "";
4505
4507
  }
4506
4508
 
4507
- // src/type-conversion/stripParenthesis.ts
4508
- function stripParenthesis(val) {
4509
- return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
4509
+ // src/literals/phone/removePhoneCountryCode.ts
4510
+ function removePhoneCountryCode(phone) {
4511
+ const countryCode = getPhoneCountryCode(phone);
4512
+ return countryCode !== "" ? stripLeading(stripLeading(
4513
+ phone.trim(),
4514
+ "+",
4515
+ "00"
4516
+ ), countryCode).trim() : phone.trim();
4510
4517
  }
4511
4518
 
4512
- // src/type-conversion/toNumber.ts
4513
- function convertScalar(val) {
4514
- switch (typeof val) {
4515
- case "number":
4516
- return val;
4517
- case "string":
4518
- return Number(val);
4519
- case "boolean":
4520
- return val ? 1 : 0;
4519
+ // src/literals/pluralize.ts
4520
+ var isException = (word) => Object.keys(PLURAL_EXCEPTIONS).includes(word);
4521
+ function endingIn(word, postfix) {
4522
+ switch (postfix) {
4523
+ case "is":
4524
+ return word.endsWith(postfix) ? `${word}es` : void 0;
4525
+ case "singular-noun":
4526
+ return SINGULAR_NOUN_ENDINGS.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS].includes(i)) ? `${word}es` : void 0 : void 0;
4527
+ case "f":
4528
+ return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
4529
+ case "y":
4530
+ return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
4521
4531
  default:
4522
- throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
4532
+ throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
4523
4533
  }
4524
4534
  }
4525
- var convertList = (val) => val.map((i) => convertScalar(i));
4526
- function toNumber(value) {
4527
- return Array.isArray(value) ? convertList(value) : convertScalar(value);
4535
+ function pluralize(word) {
4536
+ const right = rightWhitespace(word);
4537
+ const w = word.trimEnd();
4538
+ const result2 = isException(w) ? PLURAL_EXCEPTIONS[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
4539
+ return `${result2}${right}`;
4528
4540
  }
4529
4541
 
4530
- // src/type-conversion/tw-conversion.ts
4531
- var MODS = TW_MODIFIERS.map((i) => `${i}:`);
4532
- function removeTailwindModifiers(val) {
4533
- return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
4534
- }
4535
- function getTailwindModifiers(val) {
4536
- return val.split(":").filter((i) => isTailwindModifier(i));
4542
+ // src/literals/retainAfter.ts
4543
+ function retainAfter(content, ...find2) {
4544
+ const idx = Math.min(
4545
+ ...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
4546
+ );
4547
+ const min = Math.min(...find2.map((i) => i.length));
4548
+ let len = Math.max(...find2.map((i) => i.length));
4549
+ if (min !== len) {
4550
+ if (!find2.includes(content.slice(idx, len))) {
4551
+ len = min;
4552
+ }
4553
+ }
4554
+ return idx && idx > 0 ? content.slice(idx + len) : "";
4537
4555
  }
4538
-
4539
- // src/type-conversion/union.ts
4540
- function union(..._options) {
4541
- return (value) => value;
4556
+ function retainAfterInclusive(content, ...find2) {
4557
+ const minFound = Math.min(
4558
+ ...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
4559
+ );
4560
+ return minFound > 0 ? content.slice(minFound) : "";
4542
4561
  }
4543
4562
 
4544
- // src/type-conversion/unionize.ts
4545
- function unionize(value, _inUnionWith) {
4546
- return value;
4563
+ // src/literals/retainChars.ts
4564
+ function retainChars(content, ...retain2) {
4565
+ const chars = asChars(content);
4566
+ return chars.filter((c) => retain2.includes(c)).join("");
4547
4567
  }
4548
4568
 
4549
4569
  // src/literals/retainUntil.ts
@@ -5222,6 +5242,11 @@ function createTypeToken(kind) {
5222
5242
  return isAtomicKind(kind) ? `<<${kind}>>` : isSingletonKind(kind) ? singletonApi(kind) : isSetBasedKind(kind) ? setApi(kind) : isFnBasedKind(kind) ? handleDoneFn(fnTokenClosure(kind, unset, unset)) : "<<never>>";
5223
5243
  }
5224
5244
 
5245
+ // src/runtime-types/tokens/fromDefineObject.ts
5246
+ function fromDefineObject(defn) {
5247
+ return defn;
5248
+ }
5249
+
5225
5250
  // src/runtime-types/tokens/getTokenKind.ts
5226
5251
  function getTokenKind(token) {
5227
5252
  const bare = stripSurround("<<", ">>")(token);
@@ -5323,6 +5348,7 @@ function asVueRef(value) {
5323
5348
  filter,
5324
5349
  find,
5325
5350
  fnMeta,
5351
+ fromDefineObject,
5326
5352
  get,
5327
5353
  getDaysBetween,
5328
5354
  getEach,
@@ -5331,6 +5357,7 @@ function asVueRef(value) {
5331
5357
  getToday,
5332
5358
  getTokenKind,
5333
5359
  getTomorrow,
5360
+ getTypeSubtype,
5334
5361
  getUrlPath,
5335
5362
  getUrlPort,
5336
5363
  getUrlProtocol,
@@ -5571,6 +5598,7 @@ function asVueRef(value) {
5571
5598
  isTupleToken,
5572
5599
  isTurkishNewsUrl,
5573
5600
  isTypeOf,
5601
+ isTypeSubtype,
5574
5602
  isTypeToken,
5575
5603
  isTypeTokenKind,
5576
5604
  isTypeTuple,