@vettvangur/vanilla 0.0.7 → 0.0.8

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/index.esm.js CHANGED
@@ -1,618 +1,2 @@
1
- import path from 'node:path';
2
- import process from 'node:process';
3
- import dotenv from 'dotenv';
4
-
5
- /**
6
- * @memberof @vettvangur/react
7
- */
8
-
9
-
10
- /**
11
- * Capitalizes the first letter of a given string.
12
- *
13
- * @function capitalize
14
- * @param {string|null|undefined} value - The string to capitalize. If null or undefined, returns an empty string.
15
- * @param {boolean} [lowerRest=false] - If true, converts the rest of the string to lowercase.
16
- * @returns {string} The capitalized string, or an empty string if the input is falsy.
17
- *
18
- * @example capitalize(string)
19
- */
20
- function capitalize(value, lowerRest = false) {
21
- if (!value) {
22
- return '';
23
- }
24
- const firstChar = value[0].toUpperCase();
25
- const rest = lowerRest ? value.slice(1).toLowerCase() : value.slice(1);
26
- return firstChar + rest;
27
- }
28
-
29
- /**
30
- * Retrieves a translated string from a dictionary based on a given key and culture.
31
- *
32
- * @function dictionary
33
- * @param {string} key - The key for the translation.
34
- * @param {Array} data - The array of translation objects.
35
- * @param {string} [culture='is-IS'] - The language code to search for (default: 'is-IS').
36
- * @returns {string} The translated string if found, otherwise '[Translation not found]'.
37
- *
38
- * @example
39
- * dictionary(key)
40
- */
41
- function dictionary(key, data, culture = 'is-IS') {
42
- const notFound = '[Translation not found]';
43
- for (const item of data) {
44
- if (item.itemKey === key) {
45
- const translation = item.values.find(b => b.language === culture)?.value;
46
- return translation || notFound;
47
- }
48
- }
49
- return notFound;
50
- }
51
-
52
- /**
53
- * Fetches data from a given URL with customizable options and error handling.
54
- *
55
- * @async
56
- * @function fetcher
57
- * @param {Object} params - The parameters for the fetcher function.
58
- * @param {string} params.url - The URL to fetch data from.
59
- * @param {RequestInit|null} [params.options={}] - Fetch API options (headers, method, body, etc.).
60
- * @param {boolean} [params.throwOnError=false] - Whether to throw an error on non-OK HTTP responses.
61
- * @returns {Promise<Object|null>} The parsed JSON response or null if an error occurs.
62
- * @throws Will throw an error if `throwOnError` is true and the fetch fails or returns a non-OK status.
63
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
64
- *
65
- * @example
66
- * const getData = await fetcher({
67
- * url,
68
- * {
69
- * method: 'POST',
70
- * headers: {
71
- * 'Content-Type': 'application/json'
72
- * }
73
- * }
74
- * })
75
- */
76
-
77
- async function fetcher({
78
- url,
79
- options = null,
80
- throwOnError = false
81
- }) {
82
- const errorMessage = `[fetcher :: fetcher] Error: ${url}`;
83
- try {
84
- const request = await fetch(url, options);
85
- if (!request.ok) {
86
- const errorDetails = await request.text();
87
- const fullErrorMessage = `${errorMessage} - Status: ${request.status}, ${request.statusText}, Details: ${errorDetails}`;
88
- console.error(fullErrorMessage);
89
- if (throwOnError) {
90
- throw new Error(fullErrorMessage);
91
- }
92
-
93
- // Return null instead of undefined on error for predictable handling
94
- return null;
95
- }
96
- return await request.json();
97
- } catch (error) {
98
- const fullErrorMessage = `${errorMessage} - ${error}`;
99
- console.error(fullErrorMessage);
100
- if (throwOnError) {
101
- throw error;
102
- }
103
-
104
- // Return null instead of undefined on error for predictable handling
105
- return null;
106
- }
107
- }
108
-
109
- /**
110
- * Loads environment variables from `.env` and `.env.[NODE_ENV]` files.
111
- *
112
- * This function first loads the base `.env` file, then loads an environment-specific file
113
- * based on `NODE_ENV` (e.g., `.env.production`, `.env.development`). If `NODE_ENV` is not set,
114
- * it defaults to `'development'`.
115
- *
116
- * @async
117
- * @function loadEnvFiles
118
- * @param {boolean} [showMessage=true] - Whether to log a message indicating which env file was loaded.
119
- * @throws {Error} Throws an error if loading the environment-specific file fails.
120
- * @returns {Promise<void>} Resolves when environment files are loaded.
121
- */
122
- async function loadEnvFiles(showMessage = true) {
123
- // Always load the .env file first
124
- const envFilePath = path.resolve(process.cwd(), '.env');
125
- const baseResult = dotenv.config({
126
- path: envFilePath
127
- });
128
- if (baseResult.error) {
129
- console.warn(`Warning: Failed to load environment variables from .env: ${baseResult.error.message}`);
130
- }
131
- const env = process.env.NODE_ENV || 'development'; // Default to 'development' if NODE_ENV is not set
132
- const envFile = `.env.${env}`;
133
-
134
- // Load the specified environment file
135
- const result = dotenv.config({
136
- path: path.resolve(process.cwd(), envFile)
137
- });
138
- if (result.error) {
139
- throw new Error(`Failed to load environment variables from ${envFile}: ${result.error.message}`);
140
- }
141
- if (showMessage) {
142
- console.log(`Loaded environment variables from ${envFile}\n`);
143
- }
144
- }
145
-
146
- /**
147
- * Checks if a given string is a valid regular expression pattern.
148
- *
149
- * @ignore
150
- * @param {string} pattern - The regex pattern to validate.
151
- * @returns {boolean} Returns `true` if the pattern is a valid regex, otherwise `false`.
152
- */
153
- function isValidRegex(pattern) {
154
- try {
155
- new RegExp(pattern);
156
- return true;
157
- } catch {
158
- return false;
159
- }
160
- }
161
-
162
- /**
163
- * Utility object for regex operations.
164
- */
165
- const regexr = {
166
- /**
167
- * Tests whether a given value matches a regex pattern.
168
- *
169
- * @param {Object} params - Parameters for testing regex.
170
- * @param {string} params.value - The string to test against the regex.
171
- * @param {string} params.pattern - The regex pattern to match.
172
- * @param {string} [params.flags='g'] - Regex flags (default: 'g').
173
- * @returns {boolean} Returns `true` if the value matches the pattern, otherwise `false`.
174
- *
175
- * @example
176
- * const isMatch = regexr.match(pattern)
177
- * console.log(isMatch) // return true or false
178
- */
179
- test({
180
- value,
181
- pattern,
182
- flags = 'g'
183
- }) {
184
- if (!value || !pattern || !isValidRegex(pattern)) {
185
- return false;
186
- }
187
- const regexp = new RegExp(pattern, flags);
188
- return regexp.test(value);
189
- },
190
- /**
191
- * Matches a given value against a regex pattern and returns the matches.
192
- *
193
- * @param {Object} params - Parameters for matching regex.
194
- * @param {string} params.value - The string to match against the regex.
195
- * @param {string} params.pattern - The regex pattern to match.
196
- * @param {string} [params.flags='g'] - Regex flags (default: 'g').
197
- * @returns {Array<string>|null} Returns an array of matches, or `null` if no match is found.
198
- */
199
- match({
200
- value,
201
- pattern,
202
- flags = 'g'
203
- }) {
204
- if (!value || !pattern || !isValidRegex(pattern)) {
205
- return null;
206
- }
207
- const regexp = new RegExp(pattern, flags);
208
- return value.match(regexp);
209
- }
210
- };
211
-
212
- /**
213
- * Recursively flattens a nested object into a single-level object with prefixed keys.
214
- *
215
- * @param {Object} obj - The object to flatten.
216
- * @param {string} [prefix=''] - The prefix to append to keys for nested properties.
217
- * @returns {Object} A new object with flattened keys.
218
- *
219
- * @example
220
- * const nested = { sm: '640px', md: { base: '768px', xl: '1024px' } };
221
- * const result = flatten(nested);
222
- * console.log(result); // { sm: '640px', md-base: '768px', md-xl: '1024px' }
223
- */
224
- const flatten = (obj, prefix = '') => {
225
- try {
226
- if (!obj || typeof obj !== 'object') {
227
- console.error('❌ FLATTEN ERROR: Received invalid data:', obj);
228
- return {};
229
- }
230
- return Object.keys(obj).reduce((acc, key) => {
231
- const fullKey = key === 'DEFAULT' ? prefix : prefix ? `${prefix}-${key}` : key;
232
- if (typeof obj[key] === 'object' && key !== 'DEFAULT') {
233
- Object.assign(acc, flatten(obj[key], fullKey));
234
- } else if (typeof obj[key] === 'string') {
235
- acc[fullKey] = obj[key];
236
- } else {
237
- console.warn('⚠️ Skipping Invalid Key:', key, 'Value:', obj[key]);
238
- }
239
- return acc;
240
- }, {});
241
- } catch (error) {
242
- console.error('🚨 Flatten Function Error:', error);
243
- return {}; // Prevents Tailwind from crashing
244
- }
245
- };
246
-
247
- /**
248
- * Retrieves a template based on an alias, capitalizing the alias before lookup.
249
- *
250
- * @param {string} alias - The alias to search for in the templates object.
251
- * @param {Object} templates - An object containing templates indexed by alias.
252
- * @returns {*} - The matching template, or the 'Subpage' template if not found.
253
- *
254
- * @example
255
- * const template = getTemplate('name', templates);
256
- *
257
- */
258
- function getTemplate(alias, templates) {
259
- const template = templates[capitalize(alias)];
260
- if (!template) {
261
- return templates.Subpage;
262
- }
263
- return template;
264
- }
265
-
266
- /**
267
- * Checks if a given value is empty (i.e., '', undefined, or null).
268
- *
269
- * @param {*} value - The value to check.
270
- * @returns {boolean} - Returns `true` if the value is empty, otherwise `false`.
271
- *
272
- * @example
273
- * console.log(isEmpty('')); // true
274
- * console.log(isEmpty(null)); // true
275
- * console.log(isEmpty('hello')); // false
276
- */
277
- function isEmpty(value) {
278
- if (value === '' || value === undefined || value === null) {
279
- return true;
280
- }
281
- return false;
282
- }
283
- /**
284
- * Compiles a module map, converting a selector-importer pair into a `Map` for efficient lookups.
285
- *
286
- * @function createModuleMap
287
- * @param {Object} moduleMap - The module map where selectors are keys and dynamic imports are values.
288
- * @returns {Map} A Map where selectors are keys and dynamic import functions are values.
289
- *
290
- * @example
291
- * const moduleMap = {
292
- * '.selector': () => import('components/component'),
293
- * '.selector-1, .selector-2, .selector-3': () => import('components/component')
294
- * };
295
- * const compiledMap = createModuleMap(moduleMap);
296
- */
297
- function createModuleMap(moduleMap) {
298
- const compiledModuleMap = new Map();
299
- Object.entries(moduleMap).forEach(([selector, importer]) => {
300
- selector.split(',').forEach(subSelector => {
301
- compiledModuleMap.set(subSelector.trim(), importer);
302
- });
303
- });
304
- return compiledModuleMap;
305
- }
306
-
307
- /**
308
- * Adds a preload class to the body element after a short delay.
309
- * Also hides the preload animation after another delay.
310
- *
311
- * @function preloadTimeout
312
- *
313
- * @example
314
- * preloadTimeout(); // Adds 'loaded' class after a short delay, hides preload animation after another delay.
315
- */
316
- function preloadTimeout() {
317
- const body = document.querySelector('.body');
318
- if (!body) {
319
- return;
320
- }
321
- setTimeout(() => body.classList.add('loaded'), 100);
322
- setTimeout(() => {
323
- body.classList.add('preload--hidden');
324
- body.classList.remove('preload--transitions');
325
- }, 400);
326
- }
327
-
328
- /**
329
- * Lazy loads modules based on a selector in the provided module map using the IntersectionObserver API.
330
- *
331
- * @function lazyModules
332
- * @param {Map} moduleMap - A map of selectors to dynamic import functions.
333
- * @param {Element} [root=document] - The root element to query for selectors (defaults to `document`).
334
- *
335
- * @example
336
- * const moduleMap = new Map([
337
- * ['.selector', () => import('components/component')],
338
- * ['.selector-1, .selector-2, .selector-3', () => import('components/compomnent')],
339
- * ]);
340
- * lazyModules(moduleMap); // Lazy load the components when their selectors are in view.
341
- */
342
- // @ts-ignore
343
- function lazyModules(moduleMap, root = document) {
344
- const observer = new IntersectionObserver(entries => {
345
- entries.forEach(entry => {
346
- if (entry.isIntersecting) {
347
- const target = entry.target;
348
- const matchedImporters = Array.from(moduleMap.entries()).filter(([selector]) => target.matches(selector)).map(([_, importer]) => importer);
349
- if (matchedImporters.length > 0) {
350
- Promise.allSettled(matchedImporters.map(importer => importer())).then(results => {
351
- results.forEach(result => {
352
- if (result.status === 'fulfilled' && result.value?.default?.init) {
353
- result.value.default.init(target);
354
- }
355
- });
356
- }).catch(console.error);
357
- }
358
- observer.unobserve(target);
359
- }
360
- });
361
- });
362
- moduleMap.forEach((_, selector) => {
363
- root.querySelectorAll(selector).forEach(element => observer.observe(element));
364
- });
365
- }
366
-
367
- /**
368
- * Initializes core scripts with an optional callback function.
369
- *
370
- * @function initCoreScripts
371
- * @param {Function} callback - The callback function to initialize core scripts.
372
- *
373
- * @example
374
- * initCoreScripts(() => { console.log('Core scripts initialized'); });
375
- */
376
- function initCoreScripts(callback = null) {
377
- import(path.resolve(process.cwd(), 'scripts', 'core', 'prefetch.ts')).then(module => module.default.init());
378
- import(path.resolve(process.cwd(), 'scripts', 'core', 'recaptcha.ts')).then(module => module.default.init());
379
- if (callback) {
380
- callback();
381
- }
382
- }
383
-
384
- /**
385
- * Handles the `DOMContentLoaded` event to initialize core scripts and lazy load modules.
386
- *
387
- * @function onDomReady
388
- * @param {Map} moduleMap - The compiled module map for lazy loading.
389
- * @param {Function} initCoreScriptsCallback - The callback function to initialize core scripts.
390
- * @param {Function} [callback] - An optional callback to execute during `DOMContentLoaded` event handling.
391
- *
392
- * @example
393
- * onDomReady(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('DOM content loaded'); });
394
- */
395
- function onDomReady(moduleMap, initCoreScriptsCallback, callback = null) {
396
- document.addEventListener('DOMContentLoaded', e => {
397
- preloadTimeout();
398
- initCoreScripts(initCoreScriptsCallback);
399
- lazyModules(moduleMap);
400
- if (callback) {
401
- callback(e);
402
- }
403
- });
404
- }
405
-
406
- /**
407
- * Handles the `popstate` event to initialize core scripts and lazy load modules.
408
- *
409
- * @function onPopstate
410
- * @param {Map} moduleMap - The compiled module map for lazy loading.
411
- * @param {Function} initCoreScriptsCallback - The callback function to initialize core scripts.
412
- * @param {Function} [callback] - An optional callback to execute during `popstate` event handling.
413
- *
414
- * @example
415
- * onPopstate(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('Popstate event triggered'); });
416
- */
417
- function onPopstate(moduleMap, initCoreScriptsCallback, callback = null) {
418
- window.addEventListener('popstate', e => {
419
- setTimeout(() => {
420
- initCoreScripts(initCoreScriptsCallback);
421
- lazyModules(moduleMap);
422
- if (callback) {
423
- callback(e);
424
- }
425
- }, 0);
426
- });
427
- }
428
-
429
- /**
430
- * Handles the "pageshow" event to initialize core scripts and lazy load modules.
431
- *
432
- * This function listens for the "pageshow" event—which fires when a page is loaded from the bfcache
433
- * or initially loaded. After a short delay, it calls the provided core scripts initialization callback
434
- * and lazy loads modules using the supplied module map. An optional callback is executed with the event object.
435
- *
436
- * @function onPageShow
437
- * @param {Map} moduleMap - The compiled module map for lazy loading.
438
- * @param {Function} initCoreScriptsCallback - The callback function used to initialize core scripts.
439
- * @param {Function} [callback] - An optional callback to execute during event handling.
440
- *
441
- * @example
442
- * onPageShow(moduleMap, () => { console.log('Core scripts initialized'); }, (e) => {
443
- * console.log('Pageshow event triggered', e);
444
- * });
445
- */
446
- function onPageShow(moduleMap, initCoreScriptsCallback, callback = null) {
447
- window.addEventListener('pageshow', e => {
448
- setTimeout(() => {
449
- initCoreScripts(initCoreScriptsCallback);
450
- lazyModules(moduleMap);
451
- if (callback) {
452
- callback(e);
453
- }
454
- }, 0);
455
- });
456
- }
457
-
458
- /**
459
- * Handles the `htmx:beforeSwap` event to perform actions before HTMX swaps.
460
- *
461
- * @function onHtmxBeforeSwap
462
- * @param {Function} callback - The callback function to execute during `htmx:beforeSwap` event handling.
463
- *
464
- * @example
465
- * onHtmxBeforeSwap((e) => { console.log('HTMX before swap:', e); });
466
- */
467
- function onHtmxBeforeSwap(callback = null) {
468
- document.body.addEventListener('htmx:beforeSwap', e => {
469
- document.querySelectorAll('.button--loading')?.forEach(btn => btn.classList.remove('button--loading'));
470
- if (callback) {
471
- callback(e);
472
- }
473
- setTimeout(() => window.scrollTo({
474
- top: 0,
475
- behavior: 'smooth'
476
- }), 100);
477
- });
478
- }
479
-
480
- /**
481
- * Handles the `htmx:afterSwap` event to initialize core scripts and lazy load modules.
482
- *
483
- * @function onHtmxAfterSwap
484
- * @param {Map} moduleMap - The compiled module map for lazy loading.
485
- * @param {Function} [callback] - An optional callback to execute during `htmx:afterSwap` event handling.
486
- *
487
- * @example
488
- * onHtmxAfterSwap(moduleMap, () => { console.log('HTMX after swap completed'); });
489
- */
490
- function onHtmxAfterSwap(moduleMap, callback = null) {
491
- document.body.addEventListener('htmx:afterSwap', e => {
492
- // TODO: is initCoreScripts needed here?
493
- // initCoreScripts()
494
- lazyModules(moduleMap);
495
- if (callback) {
496
- callback(e);
497
- }
498
- });
499
- }
500
-
501
- /**
502
- * Handles the `htmx:afterSettle` event to initialize core scripts and lazy load modules.
503
- *
504
- * @function onHtmxAfterSettle
505
- * @param {Map} moduleMap - The compiled module map for lazy loading.
506
- * @param {Function} initCoreScriptsCallback - The callback function to initialize core scripts.
507
- * @param {Function} [callback] - An optional callback to execute during `htmx:afterSettle` event handling.
508
- *
509
- * @example
510
- * onHtmxAfterSettle(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('HTMX settle completed'); });
511
- */
512
- function onHtmxAfterSettle(moduleMap, initCoreScriptsCallback, callback = null) {
513
- document.body.addEventListener('htmx:afterSettle', e => {
514
- initCoreScripts(initCoreScriptsCallback);
515
- lazyModules(moduleMap);
516
- if (callback) {
517
- callback(e);
518
- }
519
- });
520
- }
521
-
522
- // /**
523
- // * Handles the `htmx:responseErrnr` event to display error messages based on the HTTP status code.
524
- // *
525
- // * @function onHtmxResponseError
526
- // * @param {Function} [callback] - An optional callback function to execute during handling of the error.
527
- // * @ignore
528
- // * @example
529
- // * onHtmxResponseError(toaster, (e) => {
530
- // * console.log('Custom error handling:', e);
531
- // * });
532
- // */
533
- // export function onHtmxResponseError(callback) {
534
- // if (!toaster) {
535
- // console.error('[@vettvangur/vanilla | onHtmxResponseError | No toaster provided.')
536
- // return
537
- // }
538
-
539
- // document.addEventListener('htmx:responseError', (e) => {
540
- // e.stopImmediatePropagation()
541
- // // @ts-ignore
542
- // const statusCode = e?.detail?.xhr?.status
543
-
544
- // if (statusCode === 404) {
545
- // toaster.error('Page not found (404)')
546
- // } else if (statusCode === 500) {
547
- // toaster.error('Server error (500)')
548
- // } else {
549
- // toaster.error(`HTMX error with status code: ${statusCode}`)
550
- // }
551
-
552
- // e.stopPropagation()
553
-
554
- // if (callback) {
555
- // callback(e)
556
- // }
557
- // })
558
- // }
559
-
560
- /**
561
- * Handles click outside and ESC key events to trigger a callback and close open elements with the `open` class.
562
- *
563
- * @function clickOutside
564
- * @param {Function} callback - The callback function to be executed when a click outside or ESC key event occurs.
565
- * @description
566
- * This function listens for `click` events and `keyup` events:
567
- * - When a click outside of `.co-trigger` is detected, the provided callback is executed.
568
- * - When the `ESC` key is pressed, the provided callback is executed, and any open elements (with the `open` class) are closed.
569
- *
570
- * @example
571
- * ClickOutside(() => {
572
- * console.log('Click outside or ESC pressed!');
573
- * });
574
- */
575
- function clickOutside(callback) {
576
- // Clicks
577
- document.addEventListener('click', e => {
578
- const target = e.target;
579
- const classTargets = document.querySelectorAll('.co-el');
580
-
581
- // Check if the click target is inside an element with class `.co-trigger`
582
- // @ts-ignore
583
- if (target.closest('.co-trigger')) {
584
- return;
585
- }
586
-
587
- // Execute the callback function
588
- callback(e);
589
-
590
- // Close open elements
591
- Array.prototype.forEach.call(classTargets, item => {
592
- if (item.classList.contains('open')) {
593
- item.classList.remove('open');
594
- }
595
- });
596
- }, false);
597
-
598
- // ESC key
599
- document.addEventListener('keyup', e => {
600
- const openElements = document.querySelectorAll('.open');
601
- const keys = e.keyCode || e.which;
602
-
603
- // If ESC key (key code 27) is pressed
604
- if (keys === 27) {
605
- // Execute the callback function
606
- callback(e);
607
-
608
- // Close open elements
609
- Array.prototype.forEach.call(openElements, item => {
610
- if (item.classList.contains('open')) {
611
- item.classList.remove('open');
612
- }
613
- });
614
- }
615
- });
616
- }
617
-
618
- export { capitalize, clickOutside, createModuleMap, dictionary, fetcher, flatten, getTemplate, initCoreScripts, isEmpty, lazyModules, loadEnvFiles, onDomReady, onHtmxAfterSettle, onHtmxAfterSwap, onHtmxBeforeSwap, onPageShow, onPopstate, preloadTimeout, regexr };
1
+ import e from"node:path";import t from"node:process";import n from"fs";import o from"path";import r from"os";import s from"crypto";function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c,i={exports:{}},l={name:"dotenv",version:"16.4.5",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard","lint-readme":"standard-markdown",pretest:"npm run lint && npm run dts-check",test:"tap tests/*.js --100 -Rspec","test:coverage":"tap --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3",decache:"^4.6.1",sinon:"^14.0.1",standard:"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0",tap:"^16.3.0",tar:"^6.1.11",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}};var u=function(){if(c)return i.exports;c=1;const e=n,t=o,a=r,u=s,p=l.version,d=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function f(e){console.log(`[dotenv@${p}][DEBUG] ${e}`)}function v(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function m(e,t){let n;try{n=new URL(t)}catch(e){if("ERR_INVALID_URL"===e.code){const e=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw e.code="INVALID_DOTENV_KEY",e}throw e}const o=n.password;if(!o){const e=new Error("INVALID_DOTENV_KEY: Missing key part");throw e.code="INVALID_DOTENV_KEY",e}const r=n.searchParams.get("environment");if(!r){const e=new Error("INVALID_DOTENV_KEY: Missing environment part");throw e.code="INVALID_DOTENV_KEY",e}const s=`DOTENV_VAULT_${r.toUpperCase()}`,a=e.parsed[s];if(!a){const e=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw e.code="NOT_FOUND_DOTENV_ENVIRONMENT",e}return{ciphertext:a,key:o}}function E(n){let o=null;if(n&&n.path&&n.path.length>0)if(Array.isArray(n.path))for(const t of n.path)e.existsSync(t)&&(o=t.endsWith(".vault")?t:`${t}.vault`);else o=n.path.endsWith(".vault")?n.path:`${n.path}.vault`;else o=t.resolve(process.cwd(),".env.vault");return e.existsSync(o)?o:null}function h(e){return"~"===e[0]?t.join(a.homedir(),e.slice(1)):e}const g={configDotenv:function(n){const o=t.resolve(process.cwd(),".env");let r="utf8";const s=Boolean(n&&n.debug);n&&n.encoding?r=n.encoding:s&&f("No encoding is specified. UTF-8 is used by default");let a,c=[o];if(n&&n.path)if(Array.isArray(n.path)){c=[];for(const e of n.path)c.push(h(e))}else c=[h(n.path)];const i={};for(const t of c)try{const o=g.parse(e.readFileSync(t,{encoding:r}));g.populate(i,o,n)}catch(e){s&&f(`Failed to load ${t} ${e.message}`),a=e}let l=process.env;return n&&null!=n.processEnv&&(l=n.processEnv),g.populate(l,i,n),a?{parsed:i,error:a}:{parsed:i}},_configVault:function(e){var t;t="Loading env from encrypted .env.vault",console.log(`[dotenv@${p}][INFO] ${t}`);const n=g._parseVault(e);let o=process.env;return e&&null!=e.processEnv&&(o=e.processEnv),g.populate(o,n,e),{parsed:n}},_parseVault:function(e){const t=E(e),n=g.configDotenv({path:t});if(!n.parsed){const e=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code="MISSING_DATA",e}const o=v(e).split(","),r=o.length;let s;for(let e=0;e<r;e++)try{const t=m(n,o[e].trim());s=g.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=r)throw t}return g.parse(s)},config:function(e){if(0===v(e).length)return g.configDotenv(e);const t=E(e);return t?g._configVault(e):(n=`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`,console.log(`[dotenv@${p}][WARN] ${n}`),g.configDotenv(e));var n},decrypt:function(e,t){const n=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const r=o.subarray(0,12),s=o.subarray(-16);o=o.subarray(12,-16);try{const e=u.createDecipheriv("aes-256-gcm",n,r);return e.setAuthTag(s),`${e.update(o)}${e.final()}`}catch(e){const t=e instanceof RangeError,n="Invalid key length"===e.message,o="Unsupported state or unable to authenticate data"===e.message;if(t||n){const e=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw e.code="INVALID_DOTENV_KEY",e}if(o){const e=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw e.code="DECRYPTION_FAILED",e}throw e}},parse:function(e){const t={};let n,o=e.toString();for(o=o.replace(/\r\n?/gm,"\n");null!=(n=d.exec(o));){const e=n[1];let o=n[2]||"";o=o.trim();const r=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),'"'===r&&(o=o.replace(/\\n/g,"\n"),o=o.replace(/\\r/g,"\r")),t[e]=o}return t},populate:function(e,t,n={}){const o=Boolean(n&&n.debug),r=Boolean(n&&n.override);if("object"!=typeof t){const e=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw e.code="OBJECT_REQUIRED",e}for(const n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(!0===r&&(e[n]=t[n]),o&&f(!0===r?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}};return i.exports.configDotenv=g.configDotenv,i.exports._configVault=g._configVault,i.exports._parseVault=g._parseVault,i.exports.config=g.config,i.exports.decrypt=g.decrypt,i.exports.parse=g.parse,i.exports.populate=g.populate,i.exports=g,i.exports}(),p=a(u);function d(e,t=!1){if(!e)return"";return e[0].toUpperCase()+(t?e.slice(1).toLowerCase():e.slice(1))}function f(e,t,n="is-IS"){const o="[Translation not found]";for(const s of t)if(s.itemKey===e){var r;return(null===(r=s.values.find((e=>e.language===n)))||void 0===r?void 0:r.value)||o}return o}async function v({url:e,options:t=null,throwOnError:n=!1}){const o=`[fetcher :: fetcher] Error: ${e}`;try{const r=await fetch(e,t);if(!r.ok){const e=await r.text(),t=`${o} - Status: ${r.status}, ${r.statusText}, Details: ${e}`;if(console.error(t),n)throw new Error(t);return null}return await r.json()}catch(e){const t=`${o} - ${e}`;if(console.error(t),n)throw e;return null}}async function m(n=!0){const o=e.resolve(t.cwd(),".env"),r=p.config({path:o});r.error&&console.warn(`Warning: Failed to load environment variables from .env: ${r.error.message}`);const s=`.env.${t.env.NODE_ENV||"development"}`,a=p.config({path:e.resolve(t.cwd(),s)});if(a.error)throw new Error(`Failed to load environment variables from ${s}: ${a.error.message}`);n&&console.log(`Loaded environment variables from ${s}\n`)}function E(e){try{return new RegExp(e),!0}catch(e){return!1}}const h={test({value:e,pattern:t,flags:n="g"}){if(!e||!t||!E(t))return!1;return new RegExp(t,n).test(e)},match({value:e,pattern:t,flags:n="g"}){if(!e||!t||!E(t))return null;const o=new RegExp(t,n);return e.match(o)}},g=(e,t="")=>{try{return e&&"object"==typeof e?Object.keys(e).reduce(((n,o)=>{const r="DEFAULT"===o?t:t?`${t}-${o}`:o;return"object"==typeof e[o]&&"DEFAULT"!==o?Object.assign(n,g(e[o],r)):"string"==typeof e[o]?n[r]=e[o]:console.warn("⚠️ Skipping Invalid Key:",o,"Value:",e[o]),n}),{}):(console.error("❌ FLATTEN ERROR: Received invalid data:",e),{})}catch(e){return console.error("🚨 Flatten Function Error:",e),{}}};function y(e,t){const n=t[d(e)];return n||t.Subpage}function w(e){return""===e||null==e}function D(e){const t=new Map;return Object.entries(e).forEach((([e,n])=>{e.split(",").forEach((e=>{t.set(e.trim(),n)}))})),t}function b(){console.log("PRELOAD");const e=document.querySelector(".body");e&&(setTimeout((()=>e.classList.add("loaded")),100),setTimeout((()=>{e.classList.add("preload--hidden"),e.classList.remove("preload--transitions")}),400))}function _(e,t=document){const n=new IntersectionObserver((t=>{t.forEach((t=>{if(t.isIntersecting){const o=t.target,r=Array.from(e.entries()).filter((([e])=>o.matches(e))).map((([e,t])=>t));r.length>0&&Promise.allSettled(r.map((e=>e()))).then((e=>{e.forEach((e=>{var t;"fulfilled"===e.status&&null!==(t=e.value)&&void 0!==t&&null!==(t=t.default)&&void 0!==t&&t.init&&e.value.default.init(o)}))})).catch(console.error),n.unobserve(o)}}))}));e.forEach(((e,o)=>{t.querySelectorAll(o).forEach((e=>n.observe(e)))}))}function N(n=null){import(e.resolve(t.cwd(),"scripts","core","prefetch.ts")).then((e=>e.default.init())),import(e.resolve(t.cwd(),"scripts","core","recaptcha.ts")).then((e=>e.default.init())),n&&n()}function O(e,t,n=null){document.addEventListener("DOMContentLoaded",(o=>{b(),N(t),_(e),n&&n(o)}))}function T(e,t,n=null){window.addEventListener("popstate",(o=>{setTimeout((()=>{N(t),_(e),n&&n(o)}),0)}))}function V(e,t,n=null){window.addEventListener("pageshow",(o=>{setTimeout((()=>{N(t),_(e),n&&n(o)}),0)}))}function L(e=null){document.body.addEventListener("htmx:beforeSwap",(t=>{var n;null===(n=document.querySelectorAll(".button--loading"))||void 0===n||n.forEach((e=>e.classList.remove("button--loading"))),e&&e(t),setTimeout((()=>window.scrollTo({top:0,behavior:"smooth"})),100)}))}function I(e,t=null){document.body.addEventListener("htmx:afterSwap",(n=>{_(e),t&&t(n)}))}function $(e,t,n=null){document.body.addEventListener("htmx:afterSettle",(o=>{N(t),_(e),n&&n(o)}))}function A(e){document.addEventListener("click",(t=>{const n=t.target,o=document.querySelectorAll(".co-el");n.closest(".co-trigger")||(e(t),Array.prototype.forEach.call(o,(e=>{e.classList.contains("open")&&e.classList.remove("open")})))}),!1),document.addEventListener("keyup",(t=>{const n=document.querySelectorAll(".open");27===(t.keyCode||t.which)&&(e(t),Array.prototype.forEach.call(n,(e=>{e.classList.contains("open")&&e.classList.remove("open")})))}))}export{d as capitalize,A as clickOutside,D as createModuleMap,f as dictionary,v as fetcher,g as flatten,y as getTemplate,N as initCoreScripts,w as isEmpty,_ as lazyModules,m as loadEnvFiles,O as onDomReady,$ as onHtmxAfterSettle,I as onHtmxAfterSwap,L as onHtmxBeforeSwap,V as onPageShow,T as onPopstate,b as preloadTimeout,h as regexr};
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js","../index.mjs"],"sourcesContent":["const fs = require('fs')\nconst path = require('path')\nconst os = require('os')\nconst crypto = require('crypto')\nconst packageJson = require('../package.json')\n\nconst version = packageJson.version\n\nconst LINE = /(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*'(?:\\\\'|[^'])*'|\\s*\"(?:\\\\\"|[^\"])*\"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)/mg\n\n// Parse src into an Object\nfunction parse (src) {\n const obj = {}\n\n // Convert buffer to string\n let lines = src.toString()\n\n // Convert line breaks to same format\n lines = lines.replace(/\\r\\n?/mg, '\\n')\n\n let match\n while ((match = LINE.exec(lines)) != null) {\n const key = match[1]\n\n // Default undefined or null to empty string\n let value = (match[2] || '')\n\n // Remove whitespace\n value = value.trim()\n\n // Check if double quoted\n const maybeQuote = value[0]\n\n // Remove surrounding quotes\n value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/mg, '$2')\n\n // Expand newlines if double quoted\n if (maybeQuote === '\"') {\n value = value.replace(/\\\\n/g, '\\n')\n value = value.replace(/\\\\r/g, '\\r')\n }\n\n // Add to object\n obj[key] = value\n }\n\n return obj\n}\n\nfunction _parseVault (options) {\n const vaultPath = _vaultPath(options)\n\n // Parse .env.vault\n const result = DotenvModule.configDotenv({ path: vaultPath })\n if (!result.parsed) {\n const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)\n err.code = 'MISSING_DATA'\n throw err\n }\n\n // handle scenario for comma separated keys - for use with key rotation\n // example: DOTENV_KEY=\"dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod\"\n const keys = _dotenvKey(options).split(',')\n const length = keys.length\n\n let decrypted\n for (let i = 0; i < length; i++) {\n try {\n // Get full key\n const key = keys[i].trim()\n\n // Get instructions for decrypt\n const attrs = _instructions(result, key)\n\n // Decrypt\n decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)\n\n break\n } catch (error) {\n // last key\n if (i + 1 >= length) {\n throw error\n }\n // try next key\n }\n }\n\n // Parse decrypted .env string\n return DotenvModule.parse(decrypted)\n}\n\nfunction _log (message) {\n console.log(`[dotenv@${version}][INFO] ${message}`)\n}\n\nfunction _warn (message) {\n console.log(`[dotenv@${version}][WARN] ${message}`)\n}\n\nfunction _debug (message) {\n console.log(`[dotenv@${version}][DEBUG] ${message}`)\n}\n\nfunction _dotenvKey (options) {\n // prioritize developer directly setting options.DOTENV_KEY\n if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {\n return options.DOTENV_KEY\n }\n\n // secondary infra already contains a DOTENV_KEY environment variable\n if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {\n return process.env.DOTENV_KEY\n }\n\n // fallback to empty string\n return ''\n}\n\nfunction _instructions (result, dotenvKey) {\n // Parse DOTENV_KEY. Format is a URI\n let uri\n try {\n uri = new URL(dotenvKey)\n } catch (error) {\n if (error.code === 'ERR_INVALID_URL') {\n const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n throw error\n }\n\n // Get decrypt key\n const key = uri.password\n if (!key) {\n const err = new Error('INVALID_DOTENV_KEY: Missing key part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get environment\n const environment = uri.searchParams.get('environment')\n if (!environment) {\n const err = new Error('INVALID_DOTENV_KEY: Missing environment part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get ciphertext payload\n const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`\n const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION\n if (!ciphertext) {\n const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)\n err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'\n throw err\n }\n\n return { ciphertext, key }\n}\n\nfunction _vaultPath (options) {\n let possibleVaultPath = null\n\n if (options && options.path && options.path.length > 0) {\n if (Array.isArray(options.path)) {\n for (const filepath of options.path) {\n if (fs.existsSync(filepath)) {\n possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`\n }\n }\n } else {\n possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`\n }\n } else {\n possibleVaultPath = path.resolve(process.cwd(), '.env.vault')\n }\n\n if (fs.existsSync(possibleVaultPath)) {\n return possibleVaultPath\n }\n\n return null\n}\n\nfunction _resolveHome (envPath) {\n return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath\n}\n\nfunction _configVault (options) {\n _log('Loading env from encrypted .env.vault')\n\n const parsed = DotenvModule._parseVault(options)\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsed, options)\n\n return { parsed }\n}\n\nfunction configDotenv (options) {\n const dotenvPath = path.resolve(process.cwd(), '.env')\n let encoding = 'utf8'\n const debug = Boolean(options && options.debug)\n\n if (options && options.encoding) {\n encoding = options.encoding\n } else {\n if (debug) {\n _debug('No encoding is specified. UTF-8 is used by default')\n }\n }\n\n let optionPaths = [dotenvPath] // default, look for .env\n if (options && options.path) {\n if (!Array.isArray(options.path)) {\n optionPaths = [_resolveHome(options.path)]\n } else {\n optionPaths = [] // reset default\n for (const filepath of options.path) {\n optionPaths.push(_resolveHome(filepath))\n }\n }\n }\n\n // Build the parsed data in a temporary object (because we need to return it). Once we have the final\n // parsed data, we will combine it with process.env (or options.processEnv if provided).\n let lastError\n const parsedAll = {}\n for (const path of optionPaths) {\n try {\n // Specifying an encoding returns a string instead of a buffer\n const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))\n\n DotenvModule.populate(parsedAll, parsed, options)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${path} ${e.message}`)\n }\n lastError = e\n }\n }\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsedAll, options)\n\n if (lastError) {\n return { parsed: parsedAll, error: lastError }\n } else {\n return { parsed: parsedAll }\n }\n}\n\n// Populates process.env from .env file\nfunction config (options) {\n // fallback to original dotenv if DOTENV_KEY is not set\n if (_dotenvKey(options).length === 0) {\n return DotenvModule.configDotenv(options)\n }\n\n const vaultPath = _vaultPath(options)\n\n // dotenvKey exists but .env.vault file does not exist\n if (!vaultPath) {\n _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)\n\n return DotenvModule.configDotenv(options)\n }\n\n return DotenvModule._configVault(options)\n}\n\nfunction decrypt (encrypted, keyStr) {\n const key = Buffer.from(keyStr.slice(-64), 'hex')\n let ciphertext = Buffer.from(encrypted, 'base64')\n\n const nonce = ciphertext.subarray(0, 12)\n const authTag = ciphertext.subarray(-16)\n ciphertext = ciphertext.subarray(12, -16)\n\n try {\n const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)\n aesgcm.setAuthTag(authTag)\n return `${aesgcm.update(ciphertext)}${aesgcm.final()}`\n } catch (error) {\n const isRange = error instanceof RangeError\n const invalidKeyLength = error.message === 'Invalid key length'\n const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'\n\n if (isRange || invalidKeyLength) {\n const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n } else if (decryptionFailed) {\n const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')\n err.code = 'DECRYPTION_FAILED'\n throw err\n } else {\n throw error\n }\n }\n}\n\n// Populate process.env with parsed values\nfunction populate (processEnv, parsed, options = {}) {\n const debug = Boolean(options && options.debug)\n const override = Boolean(options && options.override)\n\n if (typeof parsed !== 'object') {\n const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')\n err.code = 'OBJECT_REQUIRED'\n throw err\n }\n\n // Set process.env\n for (const key of Object.keys(parsed)) {\n if (Object.prototype.hasOwnProperty.call(processEnv, key)) {\n if (override === true) {\n processEnv[key] = parsed[key]\n }\n\n if (debug) {\n if (override === true) {\n _debug(`\"${key}\" is already defined and WAS overwritten`)\n } else {\n _debug(`\"${key}\" is already defined and was NOT overwritten`)\n }\n }\n } else {\n processEnv[key] = parsed[key]\n }\n }\n}\n\nconst DotenvModule = {\n configDotenv,\n _configVault,\n _parseVault,\n config,\n decrypt,\n parse,\n populate\n}\n\nmodule.exports.configDotenv = DotenvModule.configDotenv\nmodule.exports._configVault = DotenvModule._configVault\nmodule.exports._parseVault = DotenvModule._parseVault\nmodule.exports.config = DotenvModule.config\nmodule.exports.decrypt = DotenvModule.decrypt\nmodule.exports.parse = DotenvModule.parse\nmodule.exports.populate = DotenvModule.populate\n\nmodule.exports = DotenvModule\n","/**\r\n * @memberof @vettvangur/react\r\n */\r\n\r\nimport path from 'node:path'\r\nimport process from 'node:process'\r\nimport dotenv from 'dotenv'\r\n\r\n/**\r\n * Capitalizes the first letter of a given string.\r\n *\r\n * @function capitalize\r\n * @param {string|null|undefined} value - The string to capitalize. If null or undefined, returns an empty string.\r\n * @param {boolean} [lowerRest=false] - If true, converts the rest of the string to lowercase.\r\n * @returns {string} The capitalized string, or an empty string if the input is falsy.\r\n *\r\n * @example capitalize(string)\r\n */\r\nexport function capitalize(value, lowerRest = false) {\r\n if (!value) {\r\n return ''\r\n }\r\n\r\n const firstChar = value[0].toUpperCase()\r\n const rest = lowerRest ? value.slice(1).toLowerCase() : value.slice(1)\r\n\r\n return firstChar + rest\r\n}\r\n\r\n/**\r\n * Retrieves a translated string from a dictionary based on a given key and culture.\r\n *\r\n * @function dictionary\r\n * @param {string} key - The key for the translation.\r\n * @param {Array} data - The array of translation objects.\r\n * @param {string} [culture='is-IS'] - The language code to search for (default: 'is-IS').\r\n * @returns {string} The translated string if found, otherwise '[Translation not found]'.\r\n *\r\n * @example\r\n * dictionary(key)\r\n */\r\nexport function dictionary(key, data, culture = 'is-IS') {\r\n const notFound = '[Translation not found]'\r\n\r\n for (const item of data) {\r\n if (item.itemKey === key) {\r\n const translation = item.values.find((b) => b.language === culture)?.value\r\n return translation || notFound\r\n }\r\n }\r\n\r\n return notFound\r\n}\r\n\r\n/**\r\n * Fetches data from a given URL with customizable options and error handling.\r\n *\r\n * @async\r\n * @function fetcher\r\n * @param {Object} params - The parameters for the fetcher function.\r\n * @param {string} params.url - The URL to fetch data from.\r\n * @param {RequestInit|null} [params.options={}] - Fetch API options (headers, method, body, etc.).\r\n * @param {boolean} [params.throwOnError=false] - Whether to throw an error on non-OK HTTP responses.\r\n * @returns {Promise<Object|null>} The parsed JSON response or null if an error occurs.\r\n * @throws Will throw an error if `throwOnError` is true and the fetch fails or returns a non-OK status.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API\r\n *\r\n * @example\r\n * const getData = await fetcher({\r\n * url,\r\n * {\r\n * method: 'POST',\r\n * headers: {\r\n * 'Content-Type': 'application/json'\r\n * }\r\n * }\r\n * })\r\n */\r\n\r\nexport async function fetcher({ url, options = null, throwOnError = false }) {\r\n const errorMessage = `[fetcher :: fetcher] Error: ${url}`\r\n\r\n try {\r\n const request = await fetch(url, options)\r\n\r\n if (!request.ok) {\r\n const errorDetails = await request.text()\r\n const fullErrorMessage = `${errorMessage} - Status: ${request.status}, ${request.statusText}, Details: ${errorDetails}`\r\n console.error(fullErrorMessage)\r\n\r\n if (throwOnError) {\r\n throw new Error(fullErrorMessage)\r\n }\r\n\r\n // Return null instead of undefined on error for predictable handling\r\n return null\r\n }\r\n\r\n return await request.json()\r\n } catch (error) {\r\n const fullErrorMessage = `${errorMessage} - ${error}`\r\n console.error(fullErrorMessage)\r\n\r\n if (throwOnError) {\r\n throw error\r\n }\r\n\r\n // Return null instead of undefined on error for predictable handling\r\n return null\r\n }\r\n}\r\n\r\n/**\r\n * Loads environment variables from `.env` and `.env.[NODE_ENV]` files.\r\n *\r\n * This function first loads the base `.env` file, then loads an environment-specific file\r\n * based on `NODE_ENV` (e.g., `.env.production`, `.env.development`). If `NODE_ENV` is not set,\r\n * it defaults to `'development'`.\r\n *\r\n * @async\r\n * @function loadEnvFiles\r\n * @param {boolean} [showMessage=true] - Whether to log a message indicating which env file was loaded.\r\n * @throws {Error} Throws an error if loading the environment-specific file fails.\r\n * @returns {Promise<void>} Resolves when environment files are loaded.\r\n */\r\nexport async function loadEnvFiles(showMessage = true) {\r\n // Always load the .env file first\r\n const envFilePath = path.resolve(process.cwd(), '.env')\r\n const baseResult = dotenv.config({ path: envFilePath })\r\n\r\n if (baseResult.error) {\r\n console.warn(`Warning: Failed to load environment variables from .env: ${baseResult.error.message}`)\r\n }\r\n\r\n const env = process.env.NODE_ENV || 'development' // Default to 'development' if NODE_ENV is not set\r\n const envFile = `.env.${env}`\r\n\r\n // Load the specified environment file\r\n const result = dotenv.config({ path: path.resolve(process.cwd(), envFile) })\r\n\r\n if (result.error) {\r\n throw new Error(`Failed to load environment variables from ${envFile}: ${result.error.message}`)\r\n }\r\n\r\n if (showMessage) {\r\n console.log(`Loaded environment variables from ${envFile}\\n`)\r\n }\r\n}\r\n\r\n/**\r\n * Checks if a given string is a valid regular expression pattern.\r\n *\r\n * @ignore\r\n * @param {string} pattern - The regex pattern to validate.\r\n * @returns {boolean} Returns `true` if the pattern is a valid regex, otherwise `false`.\r\n */\r\nfunction isValidRegex(pattern) {\r\n try {\r\n new RegExp(pattern)\r\n return true\r\n } catch {\r\n return false\r\n }\r\n}\r\n\r\n/**\r\n * Utility object for regex operations.\r\n */\r\nexport const regexr = {\r\n /**\r\n * Tests whether a given value matches a regex pattern.\r\n *\r\n * @param {Object} params - Parameters for testing regex.\r\n * @param {string} params.value - The string to test against the regex.\r\n * @param {string} params.pattern - The regex pattern to match.\r\n * @param {string} [params.flags='g'] - Regex flags (default: 'g').\r\n * @returns {boolean} Returns `true` if the value matches the pattern, otherwise `false`.\r\n *\r\n * @example\r\n * const isMatch = regexr.match(pattern)\r\n * console.log(isMatch) // return true or false\r\n */\r\n test({ value, pattern, flags = 'g' }) {\r\n if (!value || !pattern || !isValidRegex(pattern)) {\r\n return false\r\n }\r\n\r\n const regexp = new RegExp(pattern, flags)\r\n return regexp.test(value)\r\n },\r\n\r\n /**\r\n * Matches a given value against a regex pattern and returns the matches.\r\n *\r\n * @param {Object} params - Parameters for matching regex.\r\n * @param {string} params.value - The string to match against the regex.\r\n * @param {string} params.pattern - The regex pattern to match.\r\n * @param {string} [params.flags='g'] - Regex flags (default: 'g').\r\n * @returns {Array<string>|null} Returns an array of matches, or `null` if no match is found.\r\n */\r\n match({ value, pattern, flags = 'g' }) {\r\n if (!value || !pattern || !isValidRegex(pattern)) {\r\n return null\r\n }\r\n\r\n const regexp = new RegExp(pattern, flags)\r\n return value.match(regexp)\r\n },\r\n}\r\n\r\n/**\r\n * Recursively flattens a nested object into a single-level object with prefixed keys.\r\n *\r\n * @param {Object} obj - The object to flatten.\r\n * @param {string} [prefix=''] - The prefix to append to keys for nested properties.\r\n * @returns {Object} A new object with flattened keys.\r\n *\r\n * @example\r\n * const nested = { sm: '640px', md: { base: '768px', xl: '1024px' } };\r\n * const result = flatten(nested);\r\n * console.log(result); // { sm: '640px', md-base: '768px', md-xl: '1024px' }\r\n */\r\nexport const flatten = (obj, prefix = '') => {\r\n try {\r\n if (!obj || typeof obj !== 'object') {\r\n console.error('❌ FLATTEN ERROR: Received invalid data:', obj)\r\n return {}\r\n }\r\n\r\n return Object.keys(obj).reduce((acc, key) => {\r\n const fullKey = key === 'DEFAULT' ? prefix : prefix ? `${prefix}-${key}` : key\r\n\r\n if (typeof obj[key] === 'object' && key !== 'DEFAULT') {\r\n Object.assign(acc, flatten(obj[key], fullKey))\r\n } else if (typeof obj[key] === 'string') {\r\n acc[fullKey] = obj[key]\r\n } else {\r\n console.warn('⚠️ Skipping Invalid Key:', key, 'Value:', obj[key])\r\n }\r\n\r\n return acc\r\n }, {})\r\n } catch (error) {\r\n console.error('🚨 Flatten Function Error:', error)\r\n return {} // Prevents Tailwind from crashing\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves a template based on an alias, capitalizing the alias before lookup.\r\n *\r\n * @param {string} alias - The alias to search for in the templates object.\r\n * @param {Object} templates - An object containing templates indexed by alias.\r\n * @returns {*} - The matching template, or the 'Subpage' template if not found.\r\n *\r\n * @example\r\n * const template = getTemplate('name', templates);\r\n *\r\n */\r\nexport function getTemplate(alias, templates) {\r\n const template = templates[capitalize(alias)]\r\n\r\n if (!template) {\r\n return templates.Subpage\r\n }\r\n\r\n return template\r\n}\r\n\r\n/**\r\n * Checks if a given value is empty (i.e., '', undefined, or null).\r\n *\r\n * @param {*} value - The value to check.\r\n * @returns {boolean} - Returns `true` if the value is empty, otherwise `false`.\r\n *\r\n * @example\r\n * console.log(isEmpty('')); // true\r\n * console.log(isEmpty(null)); // true\r\n * console.log(isEmpty('hello')); // false\r\n */\r\nexport function isEmpty(value) {\r\n if (value === '' || value === undefined || value === null) {\r\n return true\r\n }\r\n\r\n return false\r\n}\r\n/**\r\n * Compiles a module map, converting a selector-importer pair into a `Map` for efficient lookups.\r\n *\r\n * @function createModuleMap\r\n * @param {Object} moduleMap - The module map where selectors are keys and dynamic imports are values.\r\n * @returns {Map} A Map where selectors are keys and dynamic import functions are values.\r\n *\r\n * @example\r\n * const moduleMap = {\r\n * '.selector': () => import('components/component'),\r\n * '.selector-1, .selector-2, .selector-3': () => import('components/component')\r\n * };\r\n * const compiledMap = createModuleMap(moduleMap);\r\n */\r\nexport function createModuleMap(moduleMap) {\r\n const compiledModuleMap = new Map()\r\n\r\n Object.entries(moduleMap).forEach(([selector, importer]) => {\r\n selector.split(',').forEach((subSelector) => {\r\n compiledModuleMap.set(subSelector.trim(), importer)\r\n })\r\n })\r\n\r\n return compiledModuleMap\r\n}\r\n\r\n/**\r\n * Adds a preload class to the body element after a short delay.\r\n * Also hides the preload animation after another delay.\r\n *\r\n * @function preloadTimeout\r\n *\r\n * @example\r\n * preloadTimeout(); // Adds 'loaded' class after a short delay, hides preload animation after another delay.\r\n */\r\nexport function preloadTimeout() {\r\n console.log('PRELOAD')\r\n const body = document.querySelector('.body')\r\n if (!body) {\r\n return\r\n }\r\n\r\n setTimeout(() => body.classList.add('loaded'), 100)\r\n setTimeout(() => {\r\n body.classList.add('preload--hidden')\r\n body.classList.remove('preload--transitions')\r\n }, 400)\r\n}\r\n\r\n/**\r\n * Lazy loads modules based on a selector in the provided module map using the IntersectionObserver API.\r\n *\r\n * @function lazyModules\r\n * @param {Map} moduleMap - A map of selectors to dynamic import functions.\r\n * @param {Element} [root=document] - The root element to query for selectors (defaults to `document`).\r\n *\r\n * @example\r\n * const moduleMap = new Map([\r\n * ['.selector', () => import('components/component')],\r\n * ['.selector-1, .selector-2, .selector-3', () => import('components/compomnent')],\r\n * ]);\r\n * lazyModules(moduleMap); // Lazy load the components when their selectors are in view.\r\n */\r\n// @ts-ignore\r\nexport function lazyModules(moduleMap, root = document) {\r\n const observer = new IntersectionObserver((entries) => {\r\n entries.forEach((entry) => {\r\n if (entry.isIntersecting) {\r\n const target = entry.target\r\n const matchedImporters = Array.from(moduleMap.entries())\r\n .filter(([selector]) => target.matches(selector))\r\n .map(([_, importer]) => importer)\r\n\r\n if (matchedImporters.length > 0) {\r\n Promise.allSettled(matchedImporters.map((importer) => importer()))\r\n .then((results) => {\r\n results.forEach((result) => {\r\n if (result.status === 'fulfilled' && result.value?.default?.init) {\r\n result.value.default.init(target)\r\n }\r\n })\r\n })\r\n .catch(console.error)\r\n }\r\n\r\n observer.unobserve(target)\r\n }\r\n })\r\n })\r\n\r\n moduleMap.forEach((_, selector) => {\r\n root.querySelectorAll(selector).forEach((element) => observer.observe(element))\r\n })\r\n}\r\n\r\n/**\r\n * Initializes core scripts with an optional callback function.\r\n *\r\n * @function initCoreScripts\r\n * @param {Function} callback - The callback function to initialize core scripts.\r\n *\r\n * @example\r\n * initCoreScripts(() => { console.log('Core scripts initialized'); });\r\n */\r\nexport function initCoreScripts(callback = null) {\r\n import(path.resolve(process.cwd(), 'scripts', 'core', 'prefetch.ts')).then((module) => module.default.init())\r\n import(path.resolve(process.cwd(), 'scripts', 'core', 'recaptcha.ts')).then((module) => module.default.init())\r\n\r\n if (callback) {\r\n callback()\r\n }\r\n}\r\n\r\n/**\r\n * Handles the `DOMContentLoaded` event to initialize core scripts and lazy load modules.\r\n *\r\n * @function onDomReady\r\n * @param {Map} moduleMap - The compiled module map for lazy loading.\r\n * @param {Function} initCoreScriptsCallback - The callback function to initialize core scripts.\r\n * @param {Function} [callback] - An optional callback to execute during `DOMContentLoaded` event handling.\r\n *\r\n * @example\r\n * onDomReady(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('DOM content loaded'); });\r\n */\r\nexport function onDomReady(moduleMap, initCoreScriptsCallback, callback = null) {\r\n document.addEventListener('DOMContentLoaded', (e) => {\r\n preloadTimeout()\r\n initCoreScripts(initCoreScriptsCallback)\r\n lazyModules(moduleMap)\r\n\r\n if (callback) {\r\n callback(e)\r\n }\r\n })\r\n}\r\n\r\n/**\r\n * Handles the `popstate` event to initialize core scripts and lazy load modules.\r\n *\r\n * @function onPopstate\r\n * @param {Map} moduleMap - The compiled module map for lazy loading.\r\n * @param {Function} initCoreScriptsCallback - The callback function to initialize core scripts.\r\n * @param {Function} [callback] - An optional callback to execute during `popstate` event handling.\r\n *\r\n * @example\r\n * onPopstate(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('Popstate event triggered'); });\r\n */\r\nexport function onPopstate(moduleMap, initCoreScriptsCallback, callback = null) {\r\n window.addEventListener('popstate', (e) => {\r\n setTimeout(() => {\r\n initCoreScripts(initCoreScriptsCallback)\r\n lazyModules(moduleMap)\r\n\r\n if (callback) {\r\n callback(e)\r\n }\r\n }, 0)\r\n })\r\n}\r\n\r\n/**\r\n * Handles the \"pageshow\" event to initialize core scripts and lazy load modules.\r\n *\r\n * This function listens for the \"pageshow\" event—which fires when a page is loaded from the bfcache\r\n * or initially loaded. After a short delay, it calls the provided core scripts initialization callback\r\n * and lazy loads modules using the supplied module map. An optional callback is executed with the event object.\r\n *\r\n * @function onPageShow\r\n * @param {Map} moduleMap - The compiled module map for lazy loading.\r\n * @param {Function} initCoreScriptsCallback - The callback function used to initialize core scripts.\r\n * @param {Function} [callback] - An optional callback to execute during event handling.\r\n *\r\n * @example\r\n * onPageShow(moduleMap, () => { console.log('Core scripts initialized'); }, (e) => {\r\n * console.log('Pageshow event triggered', e);\r\n * });\r\n */\r\nexport function onPageShow(moduleMap, initCoreScriptsCallback, callback = null) {\r\n window.addEventListener('pageshow', (e) => {\r\n setTimeout(() => {\r\n initCoreScripts(initCoreScriptsCallback)\r\n lazyModules(moduleMap)\r\n\r\n if (callback) {\r\n callback(e)\r\n }\r\n }, 0)\r\n })\r\n}\r\n\r\n/**\r\n * Handles the `htmx:beforeSwap` event to perform actions before HTMX swaps.\r\n *\r\n * @function onHtmxBeforeSwap\r\n * @param {Function} callback - The callback function to execute during `htmx:beforeSwap` event handling.\r\n *\r\n * @example\r\n * onHtmxBeforeSwap((e) => { console.log('HTMX before swap:', e); });\r\n */\r\nexport function onHtmxBeforeSwap(callback = null) {\r\n document.body.addEventListener('htmx:beforeSwap', (e) => {\r\n document.querySelectorAll('.button--loading')?.forEach((btn) => btn.classList.remove('button--loading'))\r\n\r\n if (callback) {\r\n callback(e)\r\n }\r\n\r\n setTimeout(() => window.scrollTo({ top: 0, behavior: 'smooth' }), 100)\r\n })\r\n}\r\n\r\n/**\r\n * Handles the `htmx:afterSwap` event to initialize core scripts and lazy load modules.\r\n *\r\n * @function onHtmxAfterSwap\r\n * @param {Map} moduleMap - The compiled module map for lazy loading.\r\n * @param {Function} [callback] - An optional callback to execute during `htmx:afterSwap` event handling.\r\n *\r\n * @example\r\n * onHtmxAfterSwap(moduleMap, () => { console.log('HTMX after swap completed'); });\r\n */\r\nexport function onHtmxAfterSwap(moduleMap, callback = null) {\r\n document.body.addEventListener('htmx:afterSwap', (e) => {\r\n // TODO: is initCoreScripts needed here?\r\n // initCoreScripts()\r\n lazyModules(moduleMap)\r\n\r\n if (callback) {\r\n callback(e)\r\n }\r\n })\r\n}\r\n\r\n/**\r\n * Handles the `htmx:afterSettle` event to initialize core scripts and lazy load modules.\r\n *\r\n * @function onHtmxAfterSettle\r\n * @param {Map} moduleMap - The compiled module map for lazy loading.\r\n * @param {Function} initCoreScriptsCallback - The callback function to initialize core scripts.\r\n * @param {Function} [callback] - An optional callback to execute during `htmx:afterSettle` event handling.\r\n *\r\n * @example\r\n * onHtmxAfterSettle(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('HTMX settle completed'); });\r\n */\r\nexport function onHtmxAfterSettle(moduleMap, initCoreScriptsCallback, callback = null) {\r\n document.body.addEventListener('htmx:afterSettle', (e) => {\r\n initCoreScripts(initCoreScriptsCallback)\r\n lazyModules(moduleMap)\r\n\r\n if (callback) {\r\n callback(e)\r\n }\r\n })\r\n}\r\n\r\n// /**\r\n// * Handles the `htmx:responseErrnr` event to display error messages based on the HTTP status code.\r\n// *\r\n// * @function onHtmxResponseError\r\n// * @param {Function} [callback] - An optional callback function to execute during handling of the error.\r\n// * @ignore\r\n// * @example\r\n// * onHtmxResponseError(toaster, (e) => {\r\n// * console.log('Custom error handling:', e);\r\n// * });\r\n// */\r\n// export function onHtmxResponseError(callback) {\r\n// if (!toaster) {\r\n// console.error('[@vettvangur/vanilla | onHtmxResponseError | No toaster provided.')\r\n// return\r\n// }\r\n\r\n// document.addEventListener('htmx:responseError', (e) => {\r\n// e.stopImmediatePropagation()\r\n// // @ts-ignore\r\n// const statusCode = e?.detail?.xhr?.status\r\n\r\n// if (statusCode === 404) {\r\n// toaster.error('Page not found (404)')\r\n// } else if (statusCode === 500) {\r\n// toaster.error('Server error (500)')\r\n// } else {\r\n// toaster.error(`HTMX error with status code: ${statusCode}`)\r\n// }\r\n\r\n// e.stopPropagation()\r\n\r\n// if (callback) {\r\n// callback(e)\r\n// }\r\n// })\r\n// }\r\n\r\n/**\r\n * Handles click outside and ESC key events to trigger a callback and close open elements with the `open` class.\r\n *\r\n * @function clickOutside\r\n * @param {Function} callback - The callback function to be executed when a click outside or ESC key event occurs.\r\n * @description\r\n * This function listens for `click` events and `keyup` events:\r\n * - When a click outside of `.co-trigger` is detected, the provided callback is executed.\r\n * - When the `ESC` key is pressed, the provided callback is executed, and any open elements (with the `open` class) are closed.\r\n *\r\n * @example\r\n * ClickOutside(() => {\r\n * console.log('Click outside or ESC pressed!');\r\n * });\r\n */\r\nexport function clickOutside(callback) {\r\n // Clicks\r\n document.addEventListener(\r\n 'click',\r\n (e) => {\r\n const target = e.target\r\n const classTargets = document.querySelectorAll('.co-el')\r\n\r\n // Check if the click target is inside an element with class `.co-trigger`\r\n // @ts-ignore\r\n if (target.closest('.co-trigger')) {\r\n return\r\n }\r\n\r\n // Execute the callback function\r\n callback(e)\r\n\r\n // Close open elements\r\n Array.prototype.forEach.call(classTargets, (item) => {\r\n if (item.classList.contains('open')) {\r\n item.classList.remove('open')\r\n }\r\n })\r\n },\r\n false\r\n )\r\n\r\n // ESC key\r\n document.addEventListener('keyup', (e) => {\r\n const openElements = document.querySelectorAll('.open')\r\n const keys = e.keyCode || e.which\r\n\r\n // If ESC key (key code 27) is pressed\r\n if (keys === 27) {\r\n // Execute the callback function\r\n callback(e)\r\n\r\n // Close open elements\r\n Array.prototype.forEach.call(openElements, (item) => {\r\n if (item.classList.contains('open')) {\r\n item.classList.remove('open')\r\n }\r\n })\r\n }\r\n })\r\n}\r\n"],"names":["fs","require$$0","path","require$$1","os","require$$2","crypto","require$$3","version","require$$4","LINE","_debug","message","console","log","_dotenvKey","options","DOTENV_KEY","length","process","env","_instructions","result","dotenvKey","uri","URL","error","code","err","Error","key","password","environment","searchParams","get","environmentKey","toUpperCase","ciphertext","parsed","_vaultPath","possibleVaultPath","Array","isArray","filepath","existsSync","endsWith","resolve","cwd","_resolveHome","envPath","join","homedir","slice","DotenvModule","configDotenv","dotenvPath","encoding","debug","Boolean","lastError","optionPaths","push","parsedAll","parse","readFileSync","populate","e","processEnv","_configVault","_parseVault","vaultPath","keys","split","decrypted","i","attrs","trim","decrypt","config","encrypted","keyStr","Buffer","from","nonce","subarray","authTag","aesgcm","createDecipheriv","setAuthTag","update","final","isRange","RangeError","invalidKeyLength","decryptionFailed","src","obj","match","lines","toString","replace","exec","value","maybeQuote","override","Object","prototype","hasOwnProperty","call","mainModule","exports","capitalize","lowerRest","toLowerCase","dictionary","data","culture","notFound","item","itemKey","_item$values$find","values","find","b","language","async","fetcher","url","throwOnError","errorMessage","request","fetch","ok","errorDetails","text","fullErrorMessage","status","statusText","json","loadEnvFiles","showMessage","envFilePath","baseResult","dotenv","warn","envFile","NODE_ENV","isValidRegex","pattern","RegExp","_unused","regexr","test","flags","regexp","flatten","prefix","reduce","acc","fullKey","assign","getTemplate","alias","templates","template","Subpage","isEmpty","createModuleMap","moduleMap","compiledModuleMap","Map","entries","forEach","selector","importer","subSelector","set","preloadTimeout","body","document","querySelector","setTimeout","classList","add","remove","lazyModules","root","observer","IntersectionObserver","entry","isIntersecting","target","matchedImporters","filter","matches","map","_","Promise","allSettled","then","results","_result$value","default","init","catch","unobserve","querySelectorAll","element","observe","initCoreScripts","callback","import","module","onDomReady","initCoreScriptsCallback","addEventListener","onPopstate","window","onPageShow","onHtmxBeforeSwap","_document$querySelect","btn","scrollTo","top","behavior","onHtmxAfterSwap","onHtmxAfterSettle","clickOutside","classTargets","closest","contains","openElements","keyCode","which"],"mappings":"kiDAAA,MAAMA,EAAKC,EACLC,EAAOC,EACPC,EAAKC,EACLC,EAASC,EAGTC,EAFcC,EAEQD,QAEtBE,EAAO,+IA2Fb,SAASC,EAAQC,GACfC,QAAQC,IAAI,WAAWN,aAAmBI,IAC5C,CAEA,SAASG,EAAYC,GAEnB,OAAIA,GAAWA,EAAQC,YAAcD,EAAQC,WAAWC,OAAS,EACxDF,EAAQC,WAIbE,QAAQC,IAAIH,YAAcE,QAAQC,IAAIH,WAAWC,OAAS,EACrDC,QAAQC,IAAIH,WAId,EACT,CAEA,SAASI,E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A,GAA7CA,EAA+ChD,SAASiD,GAAQA,EAAIvC,UAAUE,OAAO,qBAEjF0B,GACFA,EAAShJ,GAGXmH,YAAW,IAAMoC,OAAOK,SAAS,CAAEC,IAAK,EAAGC,SAAU,YAAa,IAAI,GAE1E,CAYO,SAASC,EAAgBzD,EAAW0C,EAAW,MACpD/B,SAASD,KAAKqC,iBAAiB,kBAAmBrJ,IAGhDuH,EAAYjB,GAER0C,GACFA,EAAShJ,EACX,GAEJ,CAaO,SAASgK,EAAkB1D,EAAW8C,EAAyBJ,EAAW,MAC/E/B,SAASD,KAAKqC,iBAAiB,oBAAqBrJ,IAClD+I,EAAgBK,GAChB7B,EAAYjB,GAER0C,GACFA,EAAShJ,EACX,GAEJ,CAuDO,SAASiK,EAAajB,GAE3B/B,SAASoC,iBACP,SACCrJ,IACC,MAAM6H,EAAS7H,EAAE6H,OACXqC,EAAejD,SAAS2B,iBAAiB,UAI3Cf,EAAOsC,QAAQ,iBAKnBnB,EAAShJ,GAGTzB,MAAMiE,UAAUkE,QAAQhE,KAAKwH,GAAe9G,IACtCA,EAAKgE,UAAUgD,SAAS,SAC1BhH,EAAKgE,UAAUE,OAAO,OACxB,IACA,IAEJ,GAIFL,SAASoC,iBAAiB,SAAUrJ,IAClC,MAAMqK,EAAepD,SAAS2B,iBAAiB,SAIlC,MAHA5I,EAAEsK,SAAWtK,EAAEuK,SAK1BvB,EAAShJ,GAGTzB,MAAMiE,UAAUkE,QAAQhE,KAAK2H,GAAejH,IACtCA,EAAKgE,UAAUgD,SAAS,SAC1BhH,EAAKgE,UAAUE,OAAO,OACxB,IAEJ,GAEJ","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/vanilla",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Vettvangur | Vanilla JS Utility Library",
5
5
  "access": "private",
6
6
  "type": "module",
@@ -19,11 +19,13 @@
19
19
  "dotenv": "16.4.5"
20
20
  },
21
21
  "devDependencies": {
22
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
22
23
  "@rollup/plugin-babel": "6.0.4",
23
24
  "@rollup/plugin-commonjs": "28.0.1",
24
25
  "@rollup/plugin-json": "6.1.0",
25
26
  "@rollup/plugin-node-resolve": "15.3.0",
26
27
  "@rollup/plugin-typescript": "12.1.1",
28
+ "@rollup/pluginutils": "^5.1.4",
27
29
  "rollup": "4.28.1",
28
30
  "rollup-plugin-terser": "7.0.2",
29
31
  "shx": "0.3.4",