@arc-js/config-manager 0.0.92 → 0.0.95

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/config.js CHANGED
@@ -1,7 +1,904 @@
1
- const DEFAULT_CONFIG = 'base';
2
- let configManagerConfig = null;
3
- const setConfigManagerConfig = (config) => {
4
- configManagerConfig = config;
1
+ var cooks = {};
2
+
3
+ var timez = {};
4
+
5
+ var hasRequiredTimez;
6
+
7
+ function requireTimez () {
8
+ if (hasRequiredTimez) return timez;
9
+ hasRequiredTimez = 1;
10
+
11
+ Object.defineProperty(timez, '__esModule', { value: true });
12
+
13
+ class Timez {
14
+ constructor(input, enableException = false) {
15
+ if (this.dateChecker(input) === false) {
16
+ this._date = undefined;
17
+ }
18
+ else {
19
+ if (input instanceof Timez && !!input && !!(input === null || input === void 0 ? void 0 : input._date)) {
20
+ this._date = new Date(input === null || input === void 0 ? void 0 : input._date);
21
+ }
22
+ else if (input instanceof Date) {
23
+ this._date = new Date(input);
24
+ }
25
+ else if (typeof input === 'string') {
26
+ this._date = Timez.parseString(input, enableException);
27
+ }
28
+ else if (typeof input === 'number') {
29
+ this._date = new Date(input);
30
+ }
31
+ else if (input === undefined ||
32
+ input === null ||
33
+ (typeof input === 'number' && isNaN(input))) {
34
+ this._date = new Date();
35
+ }
36
+ else {
37
+ this._date = undefined;
38
+ }
39
+ }
40
+ }
41
+ static now() {
42
+ return new Timez();
43
+ }
44
+ static parse(dateString, format) {
45
+ if (typeof format === 'string' &&
46
+ format.length > 0 && ((dateString instanceof Timez &&
47
+ !!dateString &&
48
+ !!(dateString === null || dateString === void 0 ? void 0 : dateString._date)) ||
49
+ dateString instanceof Date ||
50
+ typeof dateString === 'string' ||
51
+ typeof dateString === 'number' || (dateString === undefined ||
52
+ dateString === null ||
53
+ (typeof dateString === 'number' && isNaN(dateString))))) {
54
+ return Timez.parseWithFormat(dateString, format) || new Timez(dateString);
55
+ }
56
+ return new Timez(dateString);
57
+ }
58
+ static unix(timestamp) {
59
+ return new Timez(timestamp * 1000);
60
+ }
61
+ static utc() {
62
+ const now = new Date();
63
+ return new Timez(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
64
+ }
65
+ year() {
66
+ var _a;
67
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getFullYear();
68
+ }
69
+ month() {
70
+ return !!this._date ? this._date.getMonth() + 1 : undefined;
71
+ }
72
+ date() {
73
+ var _a;
74
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getDate();
75
+ }
76
+ hour() {
77
+ var _a;
78
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getHours();
79
+ }
80
+ minute() {
81
+ var _a;
82
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getMinutes();
83
+ }
84
+ second() {
85
+ var _a;
86
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getSeconds();
87
+ }
88
+ millisecond() {
89
+ var _a;
90
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getMilliseconds();
91
+ }
92
+ day() {
93
+ var _a;
94
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getDay();
95
+ }
96
+ add(amount, unit) {
97
+ if (!this._date) {
98
+ return new Timez(undefined);
99
+ }
100
+ const newDate = new Date(this._date);
101
+ switch (unit) {
102
+ case 'years':
103
+ newDate.setFullYear(newDate.getFullYear() + amount);
104
+ break;
105
+ case 'months':
106
+ newDate.setMonth(newDate.getMonth() + amount);
107
+ break;
108
+ case 'days':
109
+ newDate.setDate(newDate.getDate() + amount);
110
+ break;
111
+ case 'hours':
112
+ newDate.setHours(newDate.getHours() + amount);
113
+ break;
114
+ case 'minutes':
115
+ newDate.setMinutes(newDate.getMinutes() + amount);
116
+ break;
117
+ case 'seconds':
118
+ newDate.setSeconds(newDate.getSeconds() + amount);
119
+ break;
120
+ case 'milliseconds':
121
+ newDate.setMilliseconds(newDate.getMilliseconds() + amount);
122
+ break;
123
+ }
124
+ return new Timez(newDate);
125
+ }
126
+ subtract(amount, unit) {
127
+ return this.add(-amount, unit);
128
+ }
129
+ startOf(unit) {
130
+ if (!this._date) {
131
+ return new Timez(undefined);
132
+ }
133
+ const newDate = new Date(this._date);
134
+ switch (unit) {
135
+ case 'year':
136
+ newDate.setMonth(0, 1);
137
+ newDate.setHours(0, 0, 0, 0);
138
+ break;
139
+ case 'month':
140
+ newDate.setDate(1);
141
+ newDate.setHours(0, 0, 0, 0);
142
+ break;
143
+ case 'day':
144
+ newDate.setHours(0, 0, 0, 0);
145
+ break;
146
+ case 'hour':
147
+ newDate.setMinutes(0, 0, 0);
148
+ break;
149
+ case 'minute':
150
+ newDate.setSeconds(0, 0);
151
+ break;
152
+ case 'second':
153
+ newDate.setMilliseconds(0);
154
+ break;
155
+ }
156
+ return new Timez(newDate);
157
+ }
158
+ endOf(unit) {
159
+ const start = this.startOf(unit);
160
+ switch (unit) {
161
+ case 'year':
162
+ return start.add(1, 'years').subtract(1, 'milliseconds');
163
+ case 'month':
164
+ return start.add(1, 'months').subtract(1, 'milliseconds');
165
+ case 'day':
166
+ return start.add(1, 'days').subtract(1, 'milliseconds');
167
+ case 'hour':
168
+ return start.add(1, 'hours').subtract(1, 'milliseconds');
169
+ case 'minute':
170
+ return start.add(1, 'minutes').subtract(1, 'milliseconds');
171
+ case 'second':
172
+ return start.add(1, 'seconds').subtract(1, 'milliseconds');
173
+ default:
174
+ return start;
175
+ }
176
+ }
177
+ isBefore(other, inclusivity = '()') {
178
+ const isIncluded = inclusivity[1] === ']';
179
+ const otherTimez = other instanceof Timez ? other : new Timez(other);
180
+ if (!this._date || !otherTimez._date) {
181
+ return false;
182
+ }
183
+ return ((!isIncluded &&
184
+ this._date < otherTimez._date) ||
185
+ (!!isIncluded &&
186
+ this._date <= otherTimez._date));
187
+ }
188
+ isAfter(other, inclusivity = '()') {
189
+ const isIncluded = inclusivity[0] === '[';
190
+ const otherTimez = other instanceof Timez ? other : new Timez(other);
191
+ if (!this._date || !otherTimez._date) {
192
+ return false;
193
+ }
194
+ return ((!isIncluded &&
195
+ this._date > otherTimez._date) ||
196
+ (!!isIncluded &&
197
+ this._date >= otherTimez._date));
198
+ }
199
+ isSame(other, unit) {
200
+ const otherTimez = other instanceof Timez ? other : new Timez(other);
201
+ if (!unit && this._date && otherTimez._date) {
202
+ return this._date.getTime() === otherTimez._date.getTime();
203
+ }
204
+ const thisStart = !!unit ? this.startOf(unit) : undefined;
205
+ const otherStart = !!unit ? otherTimez.startOf(unit) : undefined;
206
+ if (!thisStart || !(thisStart === null || thisStart === void 0 ? void 0 : thisStart._date) || !otherStart || !(otherStart === null || otherStart === void 0 ? void 0 : otherStart._date)) {
207
+ return false;
208
+ }
209
+ return thisStart._date.getTime() === otherStart._date.getTime();
210
+ }
211
+ isBetween(start, end, inclusivity = '()') {
212
+ const startTimez = start instanceof Timez ? start : new Timez(start);
213
+ const endTimez = end instanceof Timez ? end : new Timez(end);
214
+ const startIncluded = inclusivity[0] === '[';
215
+ const endIncluded = inclusivity[1] === ']';
216
+ const afterStart = startIncluded ?
217
+ this.isSame(startTimez) || this.isAfter(startTimez) :
218
+ this.isAfter(startTimez);
219
+ const beforeEnd = endIncluded ?
220
+ this.isSame(endTimez) || this.isBefore(endTimez) :
221
+ this.isBefore(endTimez);
222
+ return afterStart && beforeEnd;
223
+ }
224
+ format(formatString) {
225
+ if (!formatString) {
226
+ return this.toISOString();
227
+ }
228
+ const predefinedFormat = Timez.PREDEFINED_FORMATS[formatString];
229
+ if (predefinedFormat) {
230
+ return this.format(predefinedFormat);
231
+ }
232
+ let result = '';
233
+ let i = 0;
234
+ while (i < formatString.length) {
235
+ if (formatString[i] === '[') {
236
+ const endIndex = formatString.indexOf(']', i);
237
+ if (endIndex === -1) {
238
+ result += formatString[i];
239
+ i++;
240
+ continue;
241
+ }
242
+ const literal = formatString.substring(i + 1, endIndex);
243
+ result += literal;
244
+ i = endIndex + 1;
245
+ }
246
+ else if (formatString[i] === '%' && i + 1 < formatString.length) {
247
+ const token = `%${formatString[i + 1]}`;
248
+ const formatter = Timez.FORMAT_TOKENS[token];
249
+ if (formatter) {
250
+ result += formatter(this);
251
+ }
252
+ else {
253
+ result += token;
254
+ }
255
+ i += 2;
256
+ }
257
+ else {
258
+ result += formatString[i];
259
+ i++;
260
+ }
261
+ }
262
+ return result;
263
+ }
264
+ setTimezone(timezone) {
265
+ if (!this._date) {
266
+ return new Timez(undefined);
267
+ }
268
+ const currentOffset = this._date.getTimezoneOffset();
269
+ const targetOffset = this.parseTimezoneOffset(timezone);
270
+ const adjustedDate = new Date(this._date.getTime() + (targetOffset - currentOffset) * 60000);
271
+ return new Timez(adjustedDate);
272
+ }
273
+ utc() {
274
+ if (!this._date) {
275
+ return new Timez(undefined);
276
+ }
277
+ return new Timez(new Date(Date.UTC(this._date.getUTCFullYear(), this._date.getUTCMonth(), this._date.getUTCDate(), this._date.getUTCHours(), this._date.getUTCMinutes(), this._date.getUTCSeconds(), this._date.getUTCMilliseconds())));
278
+ }
279
+ local() {
280
+ if (!this._date) {
281
+ return new Timez(undefined);
282
+ }
283
+ return new Timez(new Date(this._date.getFullYear(), this._date.getMonth(), this._date.getDate(), this._date.getHours(), this._date.getMinutes(), this._date.getSeconds(), this._date.getMilliseconds()));
284
+ }
285
+ toString() {
286
+ var _a;
287
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.toString();
288
+ }
289
+ toISOString() {
290
+ var _a;
291
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.toISOString();
292
+ }
293
+ toDate() {
294
+ return !!this._date ? new Date(this._date) : undefined;
295
+ }
296
+ valueOf() {
297
+ var _a;
298
+ return (_a = this._date) === null || _a === void 0 ? void 0 : _a.getTime();
299
+ }
300
+ unix() {
301
+ return !!this._date ? Math.floor(this._date.getTime() / 1000) : undefined;
302
+ }
303
+ utcOffset() {
304
+ return this._date ? -this._date.getTimezoneOffset() : undefined;
305
+ }
306
+ isCorrect() {
307
+ return !!this._date && !isNaN(this._date.getTime());
308
+ }
309
+ timezone() {
310
+ if (!this._date)
311
+ return undefined;
312
+ try {
313
+ const formatter = new Intl.DateTimeFormat();
314
+ const timezone = formatter.resolvedOptions().timeZone;
315
+ return timezone || undefined;
316
+ }
317
+ catch (error) {
318
+ return this.timezoneFromOffset();
319
+ }
320
+ }
321
+ timezoneAbbr() {
322
+ if (!this._date)
323
+ return undefined;
324
+ try {
325
+ const formatter = new Intl.DateTimeFormat('en', {
326
+ timeZoneName: 'short'
327
+ });
328
+ const parts = formatter.formatToParts(this._date);
329
+ const timezonePart = parts.find(part => part.type === 'timeZoneName');
330
+ return (timezonePart === null || timezonePart === void 0 ? void 0 : timezonePart.value) || undefined;
331
+ }
332
+ catch (error) {
333
+ return this.timezoneAbbrFromOffset();
334
+ }
335
+ }
336
+ timezoneName() {
337
+ if (!this._date)
338
+ return undefined;
339
+ try {
340
+ const formatter = new Intl.DateTimeFormat('en', {
341
+ timeZoneName: 'long'
342
+ });
343
+ const parts = formatter.formatToParts(this._date);
344
+ const timezonePart = parts.find(part => part.type === 'timeZoneName');
345
+ return (timezonePart === null || timezonePart === void 0 ? void 0 : timezonePart.value) || undefined;
346
+ }
347
+ catch (error) {
348
+ return this.timezoneNameFromOffset();
349
+ }
350
+ }
351
+ timezoneOffsetString() {
352
+ const offset = this.utcOffset();
353
+ if (offset === undefined)
354
+ return undefined;
355
+ const sign = offset >= 0 ? '+' : '-';
356
+ const hours = Math.floor(Math.abs(offset) / 60).toString().padStart(2, '0');
357
+ const minutes = (Math.abs(offset) % 60).toString().padStart(2, '0');
358
+ return `${sign}${hours}:${minutes}`;
359
+ }
360
+ dateChecker(input) {
361
+ return ((input instanceof Timez &&
362
+ !!input &&
363
+ !!(input === null || input === void 0 ? void 0 : input._date)) ||
364
+ input instanceof Date ||
365
+ typeof input === 'string' ||
366
+ typeof input === 'number' || (input === undefined ||
367
+ input === null ||
368
+ (typeof input === 'number' && isNaN(input))));
369
+ }
370
+ timezoneFromOffset() {
371
+ const offset = this.utcOffset();
372
+ if (offset === undefined)
373
+ return undefined;
374
+ const offsetToTimezone = {
375
+ 0: 'Etc/UTC',
376
+ 60: 'Europe/Paris',
377
+ 120: 'Europe/Athens',
378
+ 180: 'Europe/Moscow',
379
+ 240: 'Asia/Dubai',
380
+ 270: 'Asia/Tehran',
381
+ 300: 'Asia/Karachi',
382
+ 330: 'Asia/Kolkata',
383
+ 345: 'Asia/Rangoon',
384
+ 360: 'Asia/Dhaka',
385
+ 390: 'Asia/Yangon',
386
+ 420: 'Asia/Bangkok',
387
+ 480: 'Asia/Shanghai',
388
+ 525: 'Asia/Kathmandu',
389
+ 540: 'Asia/Tokyo',
390
+ 570: 'Australia/Adelaide',
391
+ 600: 'Australia/Sydney',
392
+ 630: 'Australia/Lord_Howe',
393
+ 660: 'Pacific/Noumea',
394
+ 675: 'Australia/Eucla',
395
+ 720: 'Pacific/Auckland',
396
+ 780: 'Pacific/Chatham',
397
+ [-60]: 'Atlantic/Azores',
398
+ [-120]: 'America/Noronha',
399
+ [-180]: 'America/Argentina/Buenos_Aires',
400
+ [-210]: 'America/St_Johns',
401
+ [-240]: 'America/Halifax',
402
+ [-270]: 'America/Caracas',
403
+ [-300]: 'America/New_York',
404
+ [-360]: 'America/Chicago',
405
+ [-420]: 'America/Denver',
406
+ [-480]: 'America/Los_Angeles',
407
+ [-540]: 'America/Anchorage',
408
+ [-600]: 'Pacific/Honolulu',
409
+ [-660]: 'Pacific/Pago_Pago',
410
+ [-720]: 'Pacific/Kiritimati',
411
+ };
412
+ return offsetToTimezone[offset] || `Etc/GMT${offset >= 0 ? '-' : '+'}${Math.abs(offset) / 60}`;
413
+ }
414
+ timezoneAbbrFromOffset() {
415
+ const offset = this.utcOffset();
416
+ if (offset === undefined)
417
+ return undefined;
418
+ const offsetToAbbr = {
419
+ 0: 'GMT',
420
+ 60: 'CET',
421
+ [-300]: 'EST',
422
+ [-360]: 'CST',
423
+ [-420]: 'MST',
424
+ [-480]: 'PST',
425
+ };
426
+ return offsetToAbbr[offset] || `GMT${offset >= 0 ? '+' : ''}${offset / 60}`;
427
+ }
428
+ timezoneNameFromOffset() {
429
+ const offset = this.utcOffset();
430
+ if (offset === undefined)
431
+ return undefined;
432
+ const offsetToName = {
433
+ 0: 'Greenwich Mean Time',
434
+ 60: 'Central European Time',
435
+ [-300]: 'Eastern Standard Time',
436
+ [-360]: 'Central Standard Time',
437
+ [-420]: 'Mountain Standard Time',
438
+ [-480]: 'Pacific Standard Time',
439
+ };
440
+ return offsetToName[offset] || `GMT${offset >= 0 ? '+' : ''}${offset / 60}`;
441
+ }
442
+ isDST() {
443
+ if (!this._date)
444
+ return undefined;
445
+ try {
446
+ const jan = new Date(this._date.getFullYear(), 0, 1);
447
+ const jul = new Date(this._date.getFullYear(), 6, 1);
448
+ const stdOffset = Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
449
+ return this._date.getTimezoneOffset() < stdOffset;
450
+ }
451
+ catch (error) {
452
+ return undefined;
453
+ }
454
+ }
455
+ static parseString(dateString, enableException = false) {
456
+ const isoDate = new Date(dateString);
457
+ if (!isNaN(isoDate.getTime())) {
458
+ return isoDate;
459
+ }
460
+ const formats = [
461
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d{3})Z$/,
462
+ /^(\d{4})-(\d{2})-(\d{2})$/,
463
+ /^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,
464
+ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
465
+ ];
466
+ for (const regex of formats) {
467
+ const match = dateString.match(regex);
468
+ if (match) {
469
+ const components = match.slice(1).map(Number);
470
+ if (regex === formats[0]) {
471
+ return new Date(Date.UTC(components[0], components[1] - 1, components[2], components[3], components[4], components[5], components[6]));
472
+ }
473
+ else if (regex === formats[1]) {
474
+ return new Date(components[0], components[1] - 1, components[2]);
475
+ }
476
+ else if (regex === formats[2]) {
477
+ return new Date(components[0], components[1] - 1, components[2], components[3], components[4], components[5]);
478
+ }
479
+ else if (regex === formats[3]) {
480
+ return new Date(components[0], components[1] - 1, components[2], components[3], components[4], components[5]);
481
+ }
482
+ }
483
+ }
484
+ const fallback = new Date(dateString);
485
+ if (!isNaN(fallback.getTime())) {
486
+ return fallback;
487
+ }
488
+ if (!!enableException) {
489
+ throw new Error(`Unable to parse date string: ${dateString}`);
490
+ }
491
+ }
492
+ static parseWithFormat(value, format) {
493
+ if (!value || !format)
494
+ return undefined;
495
+ const valueStr = String(value).trim();
496
+ if (!valueStr)
497
+ return undefined;
498
+ const tokenHandlers = {
499
+ 'Y': {
500
+ regex: /\d{4}/,
501
+ extract: (match) => parseInt(match, 10)
502
+ },
503
+ 'y': {
504
+ regex: /\d{2}/,
505
+ extract: (match) => {
506
+ const year = parseInt(match, 10);
507
+ return year >= 70 ? 1900 + year : 2000 + year;
508
+ }
509
+ },
510
+ 'm': {
511
+ regex: /\d{1,2}/,
512
+ extract: (match) => parseInt(match, 10)
513
+ },
514
+ 'd': {
515
+ regex: /\d{1,2}/,
516
+ extract: (match) => parseInt(match, 10)
517
+ },
518
+ 'H': {
519
+ regex: /\d{1,2}/,
520
+ extract: (match) => parseInt(match, 10)
521
+ },
522
+ 'M': {
523
+ regex: /\d{1,2}/,
524
+ extract: (match) => parseInt(match, 10)
525
+ },
526
+ 'S': {
527
+ regex: /\d{1,2}/,
528
+ extract: (match) => parseInt(match, 10)
529
+ },
530
+ 'f': {
531
+ regex: /\d{1,3}/,
532
+ extract: (match) => parseInt(match, 10)
533
+ }
534
+ };
535
+ const result = {
536
+ year: new Date().getFullYear(),
537
+ month: 1,
538
+ day: 1,
539
+ hour: 0,
540
+ minute: 0,
541
+ second: 0,
542
+ millisecond: 0
543
+ };
544
+ let valueIndex = 0;
545
+ let formatIndex = 0;
546
+ let inLiteral = false;
547
+ let currentLiteral = '';
548
+ while (formatIndex < format.length && valueIndex < valueStr.length) {
549
+ const formatChar = format[formatIndex];
550
+ if (formatChar === '[') {
551
+ inLiteral = true;
552
+ currentLiteral = '';
553
+ formatIndex++;
554
+ }
555
+ else if (formatChar === ']' && inLiteral) {
556
+ if (valueStr.substring(valueIndex, valueIndex + currentLiteral.length) === currentLiteral) {
557
+ valueIndex += currentLiteral.length;
558
+ }
559
+ else {
560
+ return undefined;
561
+ }
562
+ inLiteral = false;
563
+ currentLiteral = '';
564
+ formatIndex++;
565
+ }
566
+ else if (inLiteral) {
567
+ currentLiteral += formatChar;
568
+ formatIndex++;
569
+ }
570
+ else if (formatChar === '%' && formatIndex + 1 < format.length) {
571
+ const token = format[formatIndex + 1];
572
+ const handler = tokenHandlers[token];
573
+ if (handler) {
574
+ const remainingValue = valueStr.substring(valueIndex);
575
+ const match = remainingValue.match(handler.regex);
576
+ if (match && match.index === 0) {
577
+ const matchedValue = match[0];
578
+ const numericValue = handler.extract(matchedValue);
579
+ switch (token) {
580
+ case 'Y':
581
+ case 'y':
582
+ result.year = numericValue;
583
+ break;
584
+ case 'm':
585
+ result.month = numericValue;
586
+ break;
587
+ case 'd':
588
+ result.day = numericValue;
589
+ break;
590
+ case 'H':
591
+ result.hour = numericValue;
592
+ break;
593
+ case 'M':
594
+ result.minute = numericValue;
595
+ break;
596
+ case 'S':
597
+ result.second = numericValue;
598
+ break;
599
+ case 'f':
600
+ result.millisecond = numericValue;
601
+ break;
602
+ }
603
+ valueIndex += matchedValue.length;
604
+ }
605
+ else {
606
+ return undefined;
607
+ }
608
+ }
609
+ else {
610
+ valueIndex++;
611
+ }
612
+ formatIndex += 2;
613
+ }
614
+ else {
615
+ if (formatChar === valueStr[valueIndex]) {
616
+ valueIndex++;
617
+ formatIndex++;
618
+ }
619
+ else {
620
+ return undefined;
621
+ }
622
+ }
623
+ }
624
+ if (result.month < 1 || result.month > 12)
625
+ return undefined;
626
+ if (result.day < 1 || result.day > 31)
627
+ return undefined;
628
+ if (result.hour < 0 || result.hour > 23)
629
+ return undefined;
630
+ if (result.minute < 0 || result.minute > 59)
631
+ return undefined;
632
+ if (result.second < 0 || result.second > 59)
633
+ return undefined;
634
+ if (result.millisecond < 0 || result.millisecond > 999)
635
+ return undefined;
636
+ try {
637
+ const date = new Date(result.year, result.month - 1,
638
+ result.day, result.hour, result.minute, result.second, result.millisecond);
639
+ if (isNaN(date.getTime())) {
640
+ return undefined;
641
+ }
642
+ return new Timez(date);
643
+ }
644
+ catch (error) {
645
+ return undefined;
646
+ }
647
+ }
648
+ static getTokenLength(token) {
649
+ const tokenLengths = {
650
+ 'Y': 4,
651
+ 'y': 2,
652
+ 'm': 2,
653
+ 'd': 2,
654
+ 'H': 2,
655
+ 'M': 2,
656
+ 'S': 2,
657
+ 'f': 3,
658
+ 'z': 5
659
+ };
660
+ return tokenLengths[token] || 1;
661
+ }
662
+ parseTimezoneOffset(timezone) {
663
+ const offsets = {
664
+ 'UTC': 0,
665
+ 'EST': -300,
666
+ 'EDT': -240,
667
+ 'CST': -360,
668
+ 'CDT': -300,
669
+ 'PST': -480,
670
+ 'PDT': -420,
671
+ };
672
+ if (offsets[timezone.toUpperCase()] !== undefined) {
673
+ return offsets[timezone.toUpperCase()];
674
+ }
675
+ const match = timezone.match(/^([+-])(\d{1,2}):?(\d{2})?$/);
676
+ if (match) {
677
+ const sign = match[1] === '+' ? 1 : -1;
678
+ const hours = parseInt(match[2], 10);
679
+ const minutes = match[3] ? parseInt(match[3], 10) : 0;
680
+ return sign * (hours * 60 + minutes);
681
+ }
682
+ return this._date ? -this._date.getTimezoneOffset() : 0;
683
+ }
684
+ static get FORMATS() {
685
+ return Object.assign({}, Timez.PREDEFINED_FORMATS);
686
+ }
687
+ static exposeToGlobal() {
688
+ if (typeof window !== 'undefined') {
689
+ window.Timez = Timez;
690
+ }
691
+ }
692
+ }
693
+ Timez.FORMAT_TOKENS = {
694
+ '%Y': (t) => { var _a; return (_a = t.year()) === null || _a === void 0 ? void 0 : _a.toString().padStart(4, '0'); },
695
+ '%y': (t) => { var _a; return (_a = t.year()) === null || _a === void 0 ? void 0 : _a.toString().slice(-2).padStart(2, '0'); },
696
+ '%m': (t) => { var _a; return (_a = t.month()) === null || _a === void 0 ? void 0 : _a.toString().padStart(2, '0'); },
697
+ '%d': (t) => { var _a; return (_a = t.date()) === null || _a === void 0 ? void 0 : _a.toString().padStart(2, '0'); },
698
+ '%H': (t) => { var _a; return (_a = t.hour()) === null || _a === void 0 ? void 0 : _a.toString().padStart(2, '0'); },
699
+ '%M': (t) => { var _a; return (_a = t.minute()) === null || _a === void 0 ? void 0 : _a.toString().padStart(2, '0'); },
700
+ '%S': (t) => { var _a; return (_a = t.second()) === null || _a === void 0 ? void 0 : _a.toString().padStart(2, '0'); },
701
+ '%f': (t) => { var _a; return (_a = t.millisecond()) === null || _a === void 0 ? void 0 : _a.toString().padStart(3, '0'); },
702
+ '%z': (t) => {
703
+ const offset = t.utcOffset();
704
+ if (!offset) {
705
+ return undefined;
706
+ }
707
+ const sign = offset >= 0 ? '+' : '-';
708
+ const hours = Math.floor(Math.abs(offset) / 60).toString().padStart(2, '0');
709
+ const minutes = (Math.abs(offset) % 60).toString().padStart(2, '0');
710
+ return `${sign}${hours}${minutes}`;
711
+ },
712
+ '%s': (t) => {
713
+ const val = t.valueOf();
714
+ return !!val ? Math.floor(val / 1000).toString() : undefined;
715
+ },
716
+ };
717
+ Timez.PREDEFINED_FORMATS = {
718
+ ISO: '%Y-%m-%dT%H:%M:%S.%fZ',
719
+ ISO_DATE: '%Y-%m-%d',
720
+ ISO_TIME: '%H:%M:%S.%fZ',
721
+ COMPACT: '%Y%m%d%H%M%S',
722
+ SLASH_DATETIME: '%Y/%m/%d %H:%M:%S.%fZ',
723
+ SLASH_DATETIME_SEC: '%Y/%m/%d %H:%M:%S',
724
+ SLASH_DATETIME_MIN: '%Y/%m/%d %H:%M',
725
+ EUROPEAN: '%d/%m/%Y %H:%M:%S GMT%z',
726
+ SLASH_DATE: '%Y/%m/%d',
727
+ TIME_MICRO: '%H:%M:%S.%fZ',
728
+ TIME_SEC: '%H:%M:%S',
729
+ CUSTOM_GREETING: '[Bonjour celestin, ][la date actuelle est:: le] %d/%m/%Y [à] %H:%M:%S.%f[Z]',
730
+ };
731
+ if (typeof window !== 'undefined') {
732
+ window.Timez = Timez;
733
+ }
734
+
735
+ timez.Timez = Timez;
736
+ timez.default = Timez;
737
+ return timez;
738
+ }
739
+
740
+ var hasRequiredCooks;
741
+
742
+ function requireCooks () {
743
+ if (hasRequiredCooks) return cooks;
744
+ hasRequiredCooks = 1;
745
+
746
+ Object.defineProperty(cooks, '__esModule', { value: true });
747
+
748
+ var timez = requireTimez();
749
+
750
+ const tabAlphabetique = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
751
+ [...tabAlphabetique, ...tabAlphabetique.map(x => x.toUpperCase())];
752
+
753
+ class Cooks {
754
+ static set(key, value, options = {}) {
755
+ if (!this.isBrowser())
756
+ return;
757
+ try {
758
+ const serializedValue = this.serialize(value);
759
+ const encodedValue = encodeURIComponent(serializedValue);
760
+ const cookieString = this.buildCookieString(key, encodedValue, options);
761
+ document.cookie = cookieString;
762
+ }
763
+ catch (error) {
764
+ console.error(`Cooks: Error setting cookie "${key}":`, error);
765
+ }
766
+ }
767
+ static get(key) {
768
+ if (!this.isBrowser())
769
+ return null;
770
+ try {
771
+ const cookies = this.getAllCookies();
772
+ const encodedValue = cookies[key];
773
+ if (!encodedValue)
774
+ return null;
775
+ const decodedValue = decodeURIComponent(encodedValue);
776
+ return this.deserialize(decodedValue);
777
+ }
778
+ catch (error) {
779
+ console.error(`Cooks: Error getting cookie "${key}":`, error);
780
+ return null;
781
+ }
782
+ }
783
+ static remove(key, path = '/', domain) {
784
+ if (!this.isBrowser())
785
+ return;
786
+ const options = {
787
+ expires: new Date(0),
788
+ path,
789
+ domain
790
+ };
791
+ this.set(key, '', options);
792
+ }
793
+ static has(key) {
794
+ return this.get(key) !== null;
795
+ }
796
+ static keys() {
797
+ if (!this.isBrowser())
798
+ return [];
799
+ const cookies = this.getAllCookies();
800
+ return Object.keys(cookies);
801
+ }
802
+ static clear() {
803
+ if (!this.isBrowser())
804
+ return;
805
+ const cookies = this.getAllCookies();
806
+ Object.keys(cookies).forEach(key => {
807
+ this.remove(key);
808
+ });
809
+ }
810
+ static serialize(value) {
811
+ if (value instanceof Date) {
812
+ return JSON.stringify({
813
+ __type: 'Date',
814
+ __value: value.toISOString()
815
+ });
816
+ }
817
+ return JSON.stringify(value);
818
+ }
819
+ static deserialize(value) {
820
+ const parsed = JSON.parse(value);
821
+ if (parsed && typeof parsed === 'object' && parsed.__type === 'Date') {
822
+ return new Date(parsed.__value);
823
+ }
824
+ return parsed;
825
+ }
826
+ static buildCookieString(key, value, options) {
827
+ const mergedOptions = Object.assign(Object.assign({}, this.DEFAULT_OPTIONS), options);
828
+ let cookieString = `${key}=${value}`;
829
+ if (mergedOptions.expires !== undefined) {
830
+ let expirationDate;
831
+ if (typeof mergedOptions.expires === 'number') {
832
+ const expirationDateInitial = new timez.Timez().add(mergedOptions.expires, 'seconds').toDate();
833
+ if (!!expirationDateInitial) {
834
+ expirationDate = expirationDateInitial;
835
+ }
836
+ else {
837
+ expirationDate = new Date();
838
+ }
839
+ }
840
+ else {
841
+ expirationDate = mergedOptions.expires;
842
+ }
843
+ cookieString += `; expires=${expirationDate.toUTCString()}`;
844
+ }
845
+ if (mergedOptions.path)
846
+ cookieString += `; path=${mergedOptions.path}`;
847
+ if (mergedOptions.domain)
848
+ cookieString += `; domain=${mergedOptions.domain}`;
849
+ if (mergedOptions.secure)
850
+ cookieString += `; secure`;
851
+ if (mergedOptions.sameSite)
852
+ cookieString += `; samesite=${mergedOptions.sameSite}`;
853
+ {
854
+ console.log(`Cooks - buildCookieString | cookieString:: `, cookieString);
855
+ }
856
+ return cookieString;
857
+ }
858
+ static getAllCookies() {
859
+ return document.cookie
860
+ .split(';')
861
+ .reduce((cookies, cookie) => {
862
+ const [key, value] = cookie.split('=').map(part => part.trim());
863
+ if (key) {
864
+ cookies[key] = value || '';
865
+ }
866
+ return cookies;
867
+ }, {});
868
+ }
869
+ static isBrowser() {
870
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
871
+ }
872
+ static exposeToGlobal() {
873
+ if (typeof window !== "undefined") {
874
+ window.Cooks = Cooks;
875
+ }
876
+ }
877
+ }
878
+ Cooks.DEFAULT_OPTIONS = {
879
+ path: '/',
880
+ secure: true,
881
+ sameSite: 'lax'
882
+ };
883
+ if (typeof window !== "undefined") {
884
+ window.Cooks = Cooks;
885
+ }
886
+
887
+ cooks.Cooks = Cooks;
888
+ cooks.default = Cooks;
889
+ return cooks;
890
+ }
891
+
892
+ var cooksExports = requireCooks();
893
+
894
+ const DEFAULT_SCOPE = 'app';
895
+ const COOKIE_NAME = 'app_config_scope';
896
+ const getSavedScope = () => {
897
+ const saved = cooksExports.Cooks.get(COOKIE_NAME);
898
+ return saved || DEFAULT_SCOPE;
899
+ };
900
+ const saveScope = (scope) => {
901
+ cooksExports.Cooks.set(COOKIE_NAME, scope, { expires: 365 * 24 * 3600, sameSite: 'strict' });
5
902
  };
6
903
 
7
- export { DEFAULT_CONFIG, configManagerConfig, setConfigManagerConfig };
904
+ export { COOKIE_NAME, DEFAULT_SCOPE, getSavedScope, saveScope };