@bicharts/shape-core 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2LR73DNS.mjs +2 -0
- package/dist/chunk-3UOCZ2D6.mjs +2 -0
- package/dist/chunk-FVSPBUW2.mjs +2 -0
- package/dist/chunk-GY54KQLP.mjs +2 -0
- package/dist/chunk-NWDPA7DG.mjs +2 -0
- package/dist/chunk-QEH7WTLB.mjs +2 -0
- package/dist/chunk-WBEROMBG.mjs +2 -0
- package/dist/formatDetector.mjs +1 -7
- package/dist/geoDetector.mjs +1 -14
- package/dist/geoPoint.mjs +1 -23
- package/dist/index.mjs +1 -250
- package/dist/indexedText.mjs +1 -23
- package/dist/models.mjs +0 -1
- package/dist/monthNames.mjs +1 -9
- package/dist/ordinalDetector.mjs +1 -11
- package/dist/types/models.d.ts +1 -0
- package/dist/util.mjs +1 -11
- package/package.json +2 -2
- package/dist/chunk-ICDJLWEM.mjs +0 -83
- package/dist/chunk-ICDJLWEM.mjs.map +0 -7
- package/dist/chunk-NGV56PGT.mjs +0 -787
- package/dist/chunk-NGV56PGT.mjs.map +0 -7
- package/dist/chunk-QTEE53OQ.mjs +0 -205
- package/dist/chunk-QTEE53OQ.mjs.map +0 -7
- package/dist/chunk-RZAZ7PZK.mjs +0 -31
- package/dist/chunk-RZAZ7PZK.mjs.map +0 -7
- package/dist/chunk-VHWC3THS.mjs +0 -572
- package/dist/chunk-VHWC3THS.mjs.map +0 -7
- package/dist/chunk-VLMGGCN4.mjs +0 -36
- package/dist/chunk-VLMGGCN4.mjs.map +0 -7
- package/dist/chunk-YJVU7G63.mjs +0 -559
- package/dist/chunk-YJVU7G63.mjs.map +0 -7
- package/dist/formatDetector.mjs.map +0 -7
- package/dist/geoDetector.mjs.map +0 -7
- package/dist/geoPoint.mjs.map +0 -7
- package/dist/index.mjs.map +0 -7
- package/dist/indexedText.mjs.map +0 -7
- package/dist/models.mjs.map +0 -7
- package/dist/monthNames.mjs.map +0 -7
- package/dist/ordinalDetector.mjs.map +0 -7
- package/dist/util.mjs.map +0 -7
package/dist/chunk-VHWC3THS.mjs
DELETED
|
@@ -1,572 +0,0 @@
|
|
|
1
|
-
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
|
|
3
|
-
// src/ordinalDetector.ts
|
|
4
|
-
var PATTERNS = [
|
|
5
|
-
// Likert agreement — the case that motivated this whole feature
|
|
6
|
-
{
|
|
7
|
-
name: "likert7_agreement",
|
|
8
|
-
minMatches: 5,
|
|
9
|
-
canonical: ["strongly disagree", "disagree", "slightly disagree", "neutral", "slightly agree", "agree", "strongly agree"]
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: "likert5_agreement",
|
|
13
|
-
minMatches: 3,
|
|
14
|
-
canonical: ["strongly disagree", "disagree", "neutral", "agree", "strongly agree"]
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: "likert3_agreement",
|
|
18
|
-
minMatches: 2,
|
|
19
|
-
canonical: ["disagree", "neutral", "agree"]
|
|
20
|
-
},
|
|
21
|
-
// Satisfaction
|
|
22
|
-
{
|
|
23
|
-
name: "likert5_satisfaction",
|
|
24
|
-
minMatches: 3,
|
|
25
|
-
canonical: ["very dissatisfied", "dissatisfied", "neutral", "satisfied", "very satisfied"]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "likert3_satisfaction",
|
|
29
|
-
minMatches: 2,
|
|
30
|
-
canonical: ["dissatisfied", "neutral", "satisfied"]
|
|
31
|
-
},
|
|
32
|
-
// Quality
|
|
33
|
-
{
|
|
34
|
-
name: "likert5_quality",
|
|
35
|
-
minMatches: 3,
|
|
36
|
-
canonical: ["poor", "fair", "good", "very good", "excellent"]
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "likert3_quality",
|
|
40
|
-
minMatches: 2,
|
|
41
|
-
canonical: ["poor", "fair", "good"]
|
|
42
|
-
},
|
|
43
|
-
// Frequency
|
|
44
|
-
{
|
|
45
|
-
name: "frequency5",
|
|
46
|
-
minMatches: 3,
|
|
47
|
-
canonical: ["never", "rarely", "sometimes", "often", "always"]
|
|
48
|
-
},
|
|
49
|
-
// Intensity — common in psychology / wellness surveys
|
|
50
|
-
{
|
|
51
|
-
name: "intensity5",
|
|
52
|
-
minMatches: 3,
|
|
53
|
-
canonical: ["not at all", "slightly", "moderately", "very", "extremely"]
|
|
54
|
-
},
|
|
55
|
-
// Importance
|
|
56
|
-
{
|
|
57
|
-
name: "importance5",
|
|
58
|
-
minMatches: 3,
|
|
59
|
-
canonical: ["not important", "slightly important", "moderately important", "very important", "extremely important"]
|
|
60
|
-
},
|
|
61
|
-
// Severity / priority / urgency — common in IT / clinical / ops data
|
|
62
|
-
{
|
|
63
|
-
name: "severity_low_critical",
|
|
64
|
-
minMatches: 3,
|
|
65
|
-
canonical: ["low", "medium", "high", "critical"]
|
|
66
|
-
},
|
|
67
|
-
// Support/ops priority where the top band is "Urgent" (not "Critical").
|
|
68
|
-
// Distinct catalog entry so the subset check passes for {Low,Medium,High,
|
|
69
|
-
// Urgent} (the city_311 case where the LLM otherwise invented a generic
|
|
70
|
-
// Critical/High/Normal/Low taxonomy because no orderedDomain shipped).
|
|
71
|
-
{
|
|
72
|
-
name: "severity_low_urgent",
|
|
73
|
-
minMatches: 3,
|
|
74
|
-
canonical: ["low", "medium", "high", "urgent"]
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "severity_none_critical",
|
|
78
|
-
minMatches: 3,
|
|
79
|
-
canonical: ["none", "mild", "moderate", "severe", "critical"]
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "priority_p4_p1",
|
|
83
|
-
minMatches: 3,
|
|
84
|
-
canonical: ["p4", "p3", "p2", "p1", "p0"]
|
|
85
|
-
},
|
|
86
|
-
// Jira-style issue priority (Blocker highest).
|
|
87
|
-
{
|
|
88
|
-
name: "severity_trivial_blocker",
|
|
89
|
-
minMatches: 3,
|
|
90
|
-
canonical: ["trivial", "minor", "major", "critical", "blocker"]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "severity_minor_severe",
|
|
94
|
-
minMatches: 3,
|
|
95
|
-
canonical: ["minor", "moderate", "major", "severe"]
|
|
96
|
-
},
|
|
97
|
-
// Generic magnitude / confidence bands (two spellings of the mid value:
|
|
98
|
-
// 'medium' vs 'moderate' — separate patterns so the subset check is exact).
|
|
99
|
-
{
|
|
100
|
-
name: "magnitude5_medium",
|
|
101
|
-
minMatches: 3,
|
|
102
|
-
canonical: ["very low", "low", "medium", "high", "very high"]
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "magnitude5_moderate",
|
|
106
|
-
minMatches: 3,
|
|
107
|
-
canonical: ["very low", "low", "moderate", "high", "very high"]
|
|
108
|
-
},
|
|
109
|
-
// Speed
|
|
110
|
-
{
|
|
111
|
-
name: "speed5",
|
|
112
|
-
minMatches: 3,
|
|
113
|
-
canonical: ["very slow", "slow", "moderate", "fast", "very fast"]
|
|
114
|
-
},
|
|
115
|
-
// Temperature (qualitative)
|
|
116
|
-
{
|
|
117
|
-
name: "temperature6",
|
|
118
|
-
minMatches: 3,
|
|
119
|
-
canonical: ["freezing", "cold", "cool", "mild", "warm", "hot"]
|
|
120
|
-
},
|
|
121
|
-
// Skill / experience ladder
|
|
122
|
-
{
|
|
123
|
-
name: "experience6",
|
|
124
|
-
minMatches: 3,
|
|
125
|
-
canonical: ["novice", "beginner", "intermediate", "advanced", "expert", "master"]
|
|
126
|
-
},
|
|
127
|
-
// Membership / loyalty tiers (metal ladder)
|
|
128
|
-
{
|
|
129
|
-
name: "tier_metal",
|
|
130
|
-
minMatches: 3,
|
|
131
|
-
canonical: ["bronze", "silver", "gold", "platinum", "diamond"]
|
|
132
|
-
},
|
|
133
|
-
// T-shirt sizes — letter form. Single letters are short/ambiguous, so
|
|
134
|
-
// require 4 anchors to fire (keeps {M,F} gender / {A,B} groups from
|
|
135
|
-
// tripping it).
|
|
136
|
-
{
|
|
137
|
-
name: "tshirt_letter_sizes",
|
|
138
|
-
minMatches: 4,
|
|
139
|
-
canonical: ["xxs", "xs", "s", "m", "l", "xl", "xxl", "xxxl"]
|
|
140
|
-
},
|
|
141
|
-
// T-shirt sizes — word form.
|
|
142
|
-
{
|
|
143
|
-
name: "tshirt_word_sizes",
|
|
144
|
-
minMatches: 3,
|
|
145
|
-
canonical: ["extra small", "small", "medium", "large", "extra large"]
|
|
146
|
-
},
|
|
147
|
-
// NPS respondent bands
|
|
148
|
-
{
|
|
149
|
-
name: "nps_bands",
|
|
150
|
-
minMatches: 2,
|
|
151
|
-
canonical: ["detractor", "passive", "promoter"]
|
|
152
|
-
},
|
|
153
|
-
// Likelihood / probability bands
|
|
154
|
-
{
|
|
155
|
-
name: "likelihood5",
|
|
156
|
-
minMatches: 3,
|
|
157
|
-
canonical: ["very unlikely", "unlikely", "neutral", "likely", "very likely"]
|
|
158
|
-
},
|
|
159
|
-
// Educational levels (one common ladder)
|
|
160
|
-
{
|
|
161
|
-
name: "education",
|
|
162
|
-
minMatches: 3,
|
|
163
|
-
canonical: ["none", "primary", "secondary", "bachelors", "masters", "doctoral"]
|
|
164
|
-
},
|
|
165
|
-
// Grade letters — A best → F worst. Single letters are short; we require
|
|
166
|
-
// 3 of 5 to fire to keep false-positive risk low.
|
|
167
|
-
{
|
|
168
|
-
name: "grades_a_to_f",
|
|
169
|
-
minMatches: 3,
|
|
170
|
-
canonical: ["a", "b", "c", "d", "f"]
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: "grades_a_to_f_plusminus",
|
|
174
|
-
minMatches: 4,
|
|
175
|
-
canonical: ["a+", "a", "a-", "b+", "b", "b-", "c+", "c", "c-", "d+", "d", "d-", "f"]
|
|
176
|
-
}
|
|
177
|
-
];
|
|
178
|
-
var SYNONYMS = {
|
|
179
|
-
// frequency5: never / rarely / sometimes / often / always
|
|
180
|
-
"seldom": "rarely",
|
|
181
|
-
"infrequently": "rarely",
|
|
182
|
-
"hardly ever": "rarely",
|
|
183
|
-
"occasionally": "sometimes",
|
|
184
|
-
"periodically": "sometimes",
|
|
185
|
-
"now and then": "sometimes",
|
|
186
|
-
"frequently": "often",
|
|
187
|
-
"frequent": "often",
|
|
188
|
-
"regularly": "often",
|
|
189
|
-
"commonly": "often",
|
|
190
|
-
"usually": "often",
|
|
191
|
-
"constantly": "always",
|
|
192
|
-
"every time": "always",
|
|
193
|
-
"all the time": "always",
|
|
194
|
-
"consistently": "always",
|
|
195
|
-
"continually": "always",
|
|
196
|
-
// likert5_quality: poor / fair / good / very good / excellent
|
|
197
|
-
"bad": "poor",
|
|
198
|
-
"weak": "poor",
|
|
199
|
-
"subpar": "poor",
|
|
200
|
-
"mediocre": "fair",
|
|
201
|
-
"passable": "fair",
|
|
202
|
-
"so so": "fair",
|
|
203
|
-
"decent": "good",
|
|
204
|
-
"solid": "good",
|
|
205
|
-
"outstanding": "excellent",
|
|
206
|
-
"superb": "excellent",
|
|
207
|
-
"exceptional": "excellent",
|
|
208
|
-
"stellar": "excellent",
|
|
209
|
-
// likert5_satisfaction
|
|
210
|
-
"unsatisfied": "dissatisfied",
|
|
211
|
-
"unhappy": "dissatisfied",
|
|
212
|
-
"displeased": "dissatisfied",
|
|
213
|
-
"happy": "satisfied",
|
|
214
|
-
"content": "satisfied",
|
|
215
|
-
"pleased": "satisfied",
|
|
216
|
-
"delighted": "very satisfied",
|
|
217
|
-
"highly satisfied": "very satisfied",
|
|
218
|
-
"extremely satisfied": "very satisfied",
|
|
219
|
-
"highly dissatisfied": "very dissatisfied",
|
|
220
|
-
"extremely dissatisfied": "very dissatisfied",
|
|
221
|
-
// agreement
|
|
222
|
-
"neither": "neutral",
|
|
223
|
-
"undecided": "neutral",
|
|
224
|
-
"no opinion": "neutral",
|
|
225
|
-
"neither agree nor disagree": "neutral",
|
|
226
|
-
"completely agree": "strongly agree",
|
|
227
|
-
"totally agree": "strongly agree",
|
|
228
|
-
"completely disagree": "strongly disagree",
|
|
229
|
-
"totally disagree": "strongly disagree",
|
|
230
|
-
// likelihood5
|
|
231
|
-
"highly unlikely": "very unlikely",
|
|
232
|
-
"extremely unlikely": "very unlikely",
|
|
233
|
-
"highly likely": "very likely",
|
|
234
|
-
"extremely likely": "very likely",
|
|
235
|
-
"almost certain": "very likely",
|
|
236
|
-
// education ladder
|
|
237
|
-
"bachelor": "bachelors",
|
|
238
|
-
"bachelor's": "bachelors",
|
|
239
|
-
"undergraduate": "bachelors",
|
|
240
|
-
"bachelor degree": "bachelors",
|
|
241
|
-
// bare "master" is intentionally OMITTED — it is the experience6 canonical
|
|
242
|
-
// (skill level), so it must not be remapped to the education "masters".
|
|
243
|
-
"master's": "masters",
|
|
244
|
-
"graduate": "masters",
|
|
245
|
-
"master degree": "masters",
|
|
246
|
-
"doctorate": "doctoral",
|
|
247
|
-
"phd": "doctoral"
|
|
248
|
-
};
|
|
249
|
-
var CANONICAL_SET = (() => {
|
|
250
|
-
const s = /* @__PURE__ */ new Set();
|
|
251
|
-
for (const p of PATTERNS) for (const c of p.canonical) s.add(normalize(c));
|
|
252
|
-
return s;
|
|
253
|
-
})();
|
|
254
|
-
var SYNONYM_TO_CANON = (() => {
|
|
255
|
-
const m = /* @__PURE__ */ new Map();
|
|
256
|
-
for (const [syn, canon] of Object.entries(SYNONYMS)) {
|
|
257
|
-
const ns = normalize(syn);
|
|
258
|
-
if (CANONICAL_SET.has(ns) || m.has(ns)) continue;
|
|
259
|
-
m.set(ns, normalize(canon));
|
|
260
|
-
}
|
|
261
|
-
return m;
|
|
262
|
-
})();
|
|
263
|
-
function resolveCanon(norm) {
|
|
264
|
-
return SYNONYM_TO_CANON.get(norm) ?? norm;
|
|
265
|
-
}
|
|
266
|
-
var ORDINAL_NAME_TOKENS = /* @__PURE__ */ new Set([
|
|
267
|
-
// temporal
|
|
268
|
-
"hour",
|
|
269
|
-
"hr",
|
|
270
|
-
"day",
|
|
271
|
-
"dow",
|
|
272
|
-
"dom",
|
|
273
|
-
"weekday",
|
|
274
|
-
"week",
|
|
275
|
-
"wk",
|
|
276
|
-
"woy",
|
|
277
|
-
"month",
|
|
278
|
-
"mth",
|
|
279
|
-
"quarter",
|
|
280
|
-
"qtr",
|
|
281
|
-
"year",
|
|
282
|
-
"yr",
|
|
283
|
-
"semester",
|
|
284
|
-
"trimester",
|
|
285
|
-
"decade",
|
|
286
|
-
"period",
|
|
287
|
-
"fiscal",
|
|
288
|
-
"fy",
|
|
289
|
-
// rank / level / scale
|
|
290
|
-
"rank",
|
|
291
|
-
"level",
|
|
292
|
-
"lvl",
|
|
293
|
-
"tier",
|
|
294
|
-
"grade",
|
|
295
|
-
"band",
|
|
296
|
-
"decile",
|
|
297
|
-
"percentile",
|
|
298
|
-
"quartile",
|
|
299
|
-
"quintile",
|
|
300
|
-
"score",
|
|
301
|
-
"rating",
|
|
302
|
-
"stars",
|
|
303
|
-
"step",
|
|
304
|
-
"stage",
|
|
305
|
-
"phase",
|
|
306
|
-
"round",
|
|
307
|
-
"wave",
|
|
308
|
-
"episode",
|
|
309
|
-
"chapter",
|
|
310
|
-
"age",
|
|
311
|
-
"cohort",
|
|
312
|
-
"generation",
|
|
313
|
-
"seniority",
|
|
314
|
-
"position",
|
|
315
|
-
"sequence",
|
|
316
|
-
"seq",
|
|
317
|
-
"priority"
|
|
318
|
-
]);
|
|
319
|
-
function tokenizeName(name) {
|
|
320
|
-
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-./]+/g, " ").toLowerCase().split(/\s+/).filter((t) => t.length > 0);
|
|
321
|
-
}
|
|
322
|
-
function isOrdinalFriendlyName(name) {
|
|
323
|
-
if (!name) return false;
|
|
324
|
-
for (const tok of tokenizeName(name)) {
|
|
325
|
-
if (ORDINAL_NAME_TOKENS.has(tok)) return true;
|
|
326
|
-
}
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
function normalize(s) {
|
|
330
|
-
return s.toLowerCase().replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
|
|
331
|
-
}
|
|
332
|
-
function buildCalendarDict(entries) {
|
|
333
|
-
const m = /* @__PURE__ */ new Map();
|
|
334
|
-
for (const [forms, pos] of entries) {
|
|
335
|
-
for (const f of forms) m.set(normalize(f), pos);
|
|
336
|
-
}
|
|
337
|
-
return m;
|
|
338
|
-
}
|
|
339
|
-
var CALENDAR_FAMILIES = [
|
|
340
|
-
// Weekday, Mon→Sun (ISO order, matches the server's DataShapeAdvisor R9).
|
|
341
|
-
{ name: "weekday_mon_sun", minMatches: 4, dict: buildCalendarDict([
|
|
342
|
-
[["monday", "mon"], 0],
|
|
343
|
-
[["tuesday", "tue", "tues"], 1],
|
|
344
|
-
[["wednesday", "wed", "weds"], 2],
|
|
345
|
-
[["thursday", "thu", "thur", "thurs", "thr"], 3],
|
|
346
|
-
[["friday", "fri"], 4],
|
|
347
|
-
[["saturday", "sat"], 5],
|
|
348
|
-
[["sunday", "sun"], 6]
|
|
349
|
-
]) },
|
|
350
|
-
// Month, Jan→Dec.
|
|
351
|
-
{ name: "month_jan_dec", minMatches: 4, dict: buildCalendarDict([
|
|
352
|
-
[["january", "jan"], 0],
|
|
353
|
-
[["february", "feb"], 1],
|
|
354
|
-
[["march", "mar"], 2],
|
|
355
|
-
[["april", "apr"], 3],
|
|
356
|
-
[["may"], 4],
|
|
357
|
-
[["june", "jun"], 5],
|
|
358
|
-
[["july", "jul"], 6],
|
|
359
|
-
[["august", "aug"], 7],
|
|
360
|
-
[["september", "sep", "sept"], 8],
|
|
361
|
-
[["october", "oct"], 9],
|
|
362
|
-
[["november", "nov"], 10],
|
|
363
|
-
[["december", "dec"], 11]
|
|
364
|
-
]) },
|
|
365
|
-
// Quarter, Q1→Q4. Power BI emits 'Qtr 1'/'Qtr 2'/... (the Marimekko genesis).
|
|
366
|
-
{ name: "quarter_q1_q4", minMatches: 3, dict: buildCalendarDict([
|
|
367
|
-
[["q1", "qtr 1", "qtr1", "quarter 1", "q 1"], 0],
|
|
368
|
-
[["q2", "qtr 2", "qtr2", "quarter 2", "q 2"], 1],
|
|
369
|
-
[["q3", "qtr 3", "qtr3", "quarter 3", "q 3"], 2],
|
|
370
|
-
[["q4", "qtr 4", "qtr4", "quarter 4", "q 4"], 3]
|
|
371
|
-
]) }
|
|
372
|
-
];
|
|
373
|
-
var _localeCalCache = {};
|
|
374
|
-
function localeCalendarDicts(locale) {
|
|
375
|
-
const key = locale || "";
|
|
376
|
-
if (!key) return { weekday: /* @__PURE__ */ new Map(), month: /* @__PURE__ */ new Map() };
|
|
377
|
-
const cached = _localeCalCache[key];
|
|
378
|
-
if (cached) return cached;
|
|
379
|
-
const weekday = /* @__PURE__ */ new Map();
|
|
380
|
-
const month = /* @__PURE__ */ new Map();
|
|
381
|
-
const add = (map, s, pos) => {
|
|
382
|
-
const n = normalize(s);
|
|
383
|
-
if (n) map.set(n, pos);
|
|
384
|
-
const nd = normalize(s.replace(/\./g, ""));
|
|
385
|
-
if (nd && nd !== n) map.set(nd, pos);
|
|
386
|
-
};
|
|
387
|
-
try {
|
|
388
|
-
const wLong = new Intl.DateTimeFormat(key, { weekday: "long" });
|
|
389
|
-
const wShort = new Intl.DateTimeFormat(key, { weekday: "short" });
|
|
390
|
-
for (let i = 0; i < 7; ++i) {
|
|
391
|
-
const d = new Date(Date.UTC(2024, 0, 1 + i));
|
|
392
|
-
add(weekday, wLong.format(d), i);
|
|
393
|
-
add(weekday, wShort.format(d), i);
|
|
394
|
-
}
|
|
395
|
-
const mLong = new Intl.DateTimeFormat(key, { month: "long" });
|
|
396
|
-
const mShort = new Intl.DateTimeFormat(key, { month: "short" });
|
|
397
|
-
for (let m = 0; m < 12; ++m) {
|
|
398
|
-
const d = new Date(Date.UTC(2020, m, 15));
|
|
399
|
-
add(month, mLong.format(d), m);
|
|
400
|
-
add(month, mShort.format(d), m);
|
|
401
|
-
}
|
|
402
|
-
} catch {
|
|
403
|
-
}
|
|
404
|
-
const result = { weekday, month };
|
|
405
|
-
_localeCalCache[key] = result;
|
|
406
|
-
return result;
|
|
407
|
-
}
|
|
408
|
-
function mergeDicts(base, extra) {
|
|
409
|
-
if (extra.size === 0) return base;
|
|
410
|
-
const m = new Map(base);
|
|
411
|
-
for (const [k, v] of extra) if (!m.has(k)) m.set(k, v);
|
|
412
|
-
return m;
|
|
413
|
-
}
|
|
414
|
-
function detectCalendarOrdinal(normIndex, locale) {
|
|
415
|
-
const loc = localeCalendarDicts(locale);
|
|
416
|
-
for (const fam of CALENDAR_FAMILIES) {
|
|
417
|
-
const dict = fam.name === "weekday_mon_sun" ? mergeDicts(fam.dict, loc.weekday) : fam.name === "month_jan_dec" ? mergeDicts(fam.dict, loc.month) : fam.dict;
|
|
418
|
-
let allInDict = true;
|
|
419
|
-
const byPos = /* @__PURE__ */ new Map();
|
|
420
|
-
for (const [norm, original] of normIndex) {
|
|
421
|
-
const pos = dict.get(norm);
|
|
422
|
-
if (pos === void 0) {
|
|
423
|
-
allInDict = false;
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
if (!byPos.has(pos)) byPos.set(pos, original);
|
|
427
|
-
}
|
|
428
|
-
if (!allInDict) continue;
|
|
429
|
-
if (byPos.size < fam.minMatches) continue;
|
|
430
|
-
const orderedDomain = [...byPos.entries()].sort((a, b) => a[0] - b[0]).map((e) => e[1]);
|
|
431
|
-
return { pattern: fam.name, orderedDomain };
|
|
432
|
-
}
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
function buildNormalizedIndex(rawValues) {
|
|
436
|
-
const out = /* @__PURE__ */ new Map();
|
|
437
|
-
for (const v of rawValues) {
|
|
438
|
-
if (v === null || v === void 0) continue;
|
|
439
|
-
const s = String(v);
|
|
440
|
-
if (s.length === 0) continue;
|
|
441
|
-
const n = normalize(s);
|
|
442
|
-
if (!out.has(n)) out.set(n, s);
|
|
443
|
-
}
|
|
444
|
-
return out;
|
|
445
|
-
}
|
|
446
|
-
var MAX_SAFE_DISTINCT = 15;
|
|
447
|
-
var MAX_CODE_LEN = 10;
|
|
448
|
-
var ALWAYS_SAFE_TOKENS = (() => {
|
|
449
|
-
const literal = [
|
|
450
|
-
// sizes
|
|
451
|
-
"xxs",
|
|
452
|
-
"xs",
|
|
453
|
-
"s",
|
|
454
|
-
"sm",
|
|
455
|
-
"small",
|
|
456
|
-
"m",
|
|
457
|
-
"med",
|
|
458
|
-
"medium",
|
|
459
|
-
"l",
|
|
460
|
-
"lg",
|
|
461
|
-
"large",
|
|
462
|
-
"xl",
|
|
463
|
-
"xlarge",
|
|
464
|
-
"xxl",
|
|
465
|
-
"xxxl",
|
|
466
|
-
"2xl",
|
|
467
|
-
"3xl",
|
|
468
|
-
"4xl",
|
|
469
|
-
// boolean / flags / fillers
|
|
470
|
-
"y",
|
|
471
|
-
"n",
|
|
472
|
-
"yes",
|
|
473
|
-
"no",
|
|
474
|
-
"t",
|
|
475
|
-
"f",
|
|
476
|
-
"true",
|
|
477
|
-
"false",
|
|
478
|
-
"na",
|
|
479
|
-
"n/a",
|
|
480
|
-
"n a",
|
|
481
|
-
"none",
|
|
482
|
-
"null",
|
|
483
|
-
"unknown",
|
|
484
|
-
"other",
|
|
485
|
-
"all",
|
|
486
|
-
"both",
|
|
487
|
-
// magnitude / severity words (safe standalone even when Tier A doesn't fire)
|
|
488
|
-
"low",
|
|
489
|
-
"medium",
|
|
490
|
-
"med",
|
|
491
|
-
"high",
|
|
492
|
-
"very low",
|
|
493
|
-
"very high",
|
|
494
|
-
"minimal",
|
|
495
|
-
"critical",
|
|
496
|
-
"urgent"
|
|
497
|
-
];
|
|
498
|
-
const set = new Set(literal.map(normalize));
|
|
499
|
-
for (const fam of CALENDAR_FAMILIES) {
|
|
500
|
-
for (const k of fam.dict.keys()) set.add(k);
|
|
501
|
-
}
|
|
502
|
-
return set;
|
|
503
|
-
})();
|
|
504
|
-
function isCodeStructured(raw) {
|
|
505
|
-
const s = raw.trim();
|
|
506
|
-
if (s.length === 0 || s.length > MAX_CODE_LEN) return false;
|
|
507
|
-
const letters = (s.match(/\p{L}/gu) || []).length;
|
|
508
|
-
if (letters > 1) return false;
|
|
509
|
-
return /\p{Nd}/u.test(s);
|
|
510
|
-
}
|
|
511
|
-
function safeDistinctValuesToShip(rawDistinct) {
|
|
512
|
-
if (!rawDistinct || rawDistinct.length === 0) return null;
|
|
513
|
-
const seen = /* @__PURE__ */ new Set();
|
|
514
|
-
const out = [];
|
|
515
|
-
for (const v of rawDistinct) {
|
|
516
|
-
if (v === null || v === void 0) continue;
|
|
517
|
-
const s = String(v);
|
|
518
|
-
if (seen.has(s)) continue;
|
|
519
|
-
const norm = normalize(s);
|
|
520
|
-
const safe = norm === "" || ALWAYS_SAFE_TOKENS.has(norm) || isCodeStructured(s);
|
|
521
|
-
if (!safe) return null;
|
|
522
|
-
seen.add(s);
|
|
523
|
-
out.push(s);
|
|
524
|
-
if (out.length > MAX_SAFE_DISTINCT) return null;
|
|
525
|
-
}
|
|
526
|
-
return out.length > 0 ? out : null;
|
|
527
|
-
}
|
|
528
|
-
function detectOrdinalDomain(rawValues, locale) {
|
|
529
|
-
if (!rawValues || rawValues.length < 2) return null;
|
|
530
|
-
const normIndex = buildNormalizedIndex(rawValues);
|
|
531
|
-
if (normIndex.size < 2) return null;
|
|
532
|
-
const canonIndex = /* @__PURE__ */ new Map();
|
|
533
|
-
for (const [norm, original] of normIndex) {
|
|
534
|
-
const canon = resolveCanon(norm);
|
|
535
|
-
if (!canonIndex.has(canon)) canonIndex.set(canon, original);
|
|
536
|
-
}
|
|
537
|
-
let best = null;
|
|
538
|
-
for (const pattern of PATTERNS) {
|
|
539
|
-
const orderedDomain = [];
|
|
540
|
-
for (const canonForm of pattern.canonical) {
|
|
541
|
-
const raw = canonIndex.get(canonForm);
|
|
542
|
-
if (raw !== void 0) orderedDomain.push(raw);
|
|
543
|
-
}
|
|
544
|
-
if (orderedDomain.length < pattern.minMatches) continue;
|
|
545
|
-
const patternSet = new Set(pattern.canonical);
|
|
546
|
-
let allUserValuesInPattern = true;
|
|
547
|
-
for (const normUserValue of normIndex.keys()) {
|
|
548
|
-
if (!patternSet.has(resolveCanon(normUserValue))) {
|
|
549
|
-
allUserValuesInPattern = false;
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
if (!allUserValuesInPattern) continue;
|
|
554
|
-
let isBetter;
|
|
555
|
-
if (best === null) isBetter = true;
|
|
556
|
-
else if (orderedDomain.length > best.matched) isBetter = true;
|
|
557
|
-
else if (orderedDomain.length === best.matched && pattern.canonical.length < best.pattern.canonical.length) isBetter = true;
|
|
558
|
-
else isBetter = false;
|
|
559
|
-
if (isBetter) {
|
|
560
|
-
best = { pattern, matched: orderedDomain.length, orderedDomain };
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
if (best) return { pattern: best.pattern.name, orderedDomain: best.orderedDomain };
|
|
564
|
-
return detectCalendarOrdinal(normIndex, locale);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
export {
|
|
568
|
-
isOrdinalFriendlyName,
|
|
569
|
-
safeDistinctValuesToShip,
|
|
570
|
-
detectOrdinalDomain
|
|
571
|
-
};
|
|
572
|
-
//# sourceMappingURL=chunk-VHWC3THS.mjs.map
|