@relax.js/core 1.0.0

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.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +188 -0
  3. package/dist/DataLoader.d.ts +51 -0
  4. package/dist/DependencyInjection.d.ts +271 -0
  5. package/dist/DependencyInjectionOld.d.ts +35 -0
  6. package/dist/Metadata.d.ts +8 -0
  7. package/dist/SequentialId.d.ts +47 -0
  8. package/dist/_alt/src/MustardEngine.d.ts +30 -0
  9. package/dist/_alt/src/MustardParser.d.ts +63 -0
  10. package/dist/_alt/src/MustardParser2.d.ts +35 -0
  11. package/dist/_alt/src/pipes.d.ts +93 -0
  12. package/dist/_alt/src/template.d.ts +166 -0
  13. package/dist/_alt/src/tools.d.ts +4 -0
  14. package/dist/_alt/tests/pipes.tests.d.ts +1 -0
  15. package/dist/_alt/tests/template.tests.d.ts +1 -0
  16. package/dist/_alt/vitest.config.d.ts +2 -0
  17. package/dist/collections/Index.d.ts +1 -0
  18. package/dist/collections/LinkedList.d.ts +75 -0
  19. package/dist/collections/Pager.d.ts +15 -0
  20. package/dist/collections/index.js +2 -0
  21. package/dist/collections/index.js.map +7 -0
  22. package/dist/collections/index.mjs +2 -0
  23. package/dist/collections/index.mjs.map +7 -0
  24. package/dist/components/Table.d.ts +13 -0
  25. package/dist/components/index.d.ts +4 -0
  26. package/dist/components/index.js +128 -0
  27. package/dist/components/index.js.map +7 -0
  28. package/dist/components/index.mjs +128 -0
  29. package/dist/components/index.mjs.map +7 -0
  30. package/dist/components/lists/Table.d.ts +59 -0
  31. package/dist/components/lists/TreeView.d.ts +67 -0
  32. package/dist/components/lists/index.d.ts +2 -0
  33. package/dist/components/loader.d.ts +60 -0
  34. package/dist/components/menus/MenuItem.d.ts +30 -0
  35. package/dist/components/menus/TopMenu.d.ts +16 -0
  36. package/dist/components/menus/index.d.ts +2 -0
  37. package/dist/components/panels/tabs.d.ts +15 -0
  38. package/dist/di/index.d.ts +1 -0
  39. package/dist/di/index.js +2 -0
  40. package/dist/di/index.js.map +7 -0
  41. package/dist/di/index.mjs +2 -0
  42. package/dist/di/index.mjs.map +7 -0
  43. package/dist/elements/CopyAttributes.d.ts +2 -0
  44. package/dist/elements/dom.d.ts +18 -0
  45. package/dist/elements/index.d.ts +2 -0
  46. package/dist/elements/index.js +2 -0
  47. package/dist/elements/index.js.map +7 -0
  48. package/dist/elements/index.mjs +2 -0
  49. package/dist/elements/index.mjs.map +7 -0
  50. package/dist/errors.d.ts +71 -0
  51. package/dist/forms/FormReader.d.ts +182 -0
  52. package/dist/forms/FormValidator.d.ts +114 -0
  53. package/dist/forms/ValidationRules.d.ts +103 -0
  54. package/dist/forms/index.d.ts +4 -0
  55. package/dist/forms/index.js +2 -0
  56. package/dist/forms/index.js.map +7 -0
  57. package/dist/forms/index.mjs +2 -0
  58. package/dist/forms/index.mjs.map +7 -0
  59. package/dist/forms/setFormData.d.ts +49 -0
  60. package/dist/getParentComponent.d.ts +43 -0
  61. package/dist/html/TableRenderer.d.ts +44 -0
  62. package/dist/html/TreeBinder.d.ts +9 -0
  63. package/dist/html/html.d.ts +55 -0
  64. package/dist/html/index.d.ts +5 -0
  65. package/dist/html/index.js +2 -0
  66. package/dist/html/index.js.map +7 -0
  67. package/dist/html/index.mjs +2 -0
  68. package/dist/html/index.mjs.map +7 -0
  69. package/dist/html/template.d.ts +167 -0
  70. package/dist/http/ServerSentEvents.d.ts +116 -0
  71. package/dist/http/SimpleWebSocket.d.ts +153 -0
  72. package/dist/http/http.d.ts +177 -0
  73. package/dist/http/index.d.ts +3 -0
  74. package/dist/http/index.js +2 -0
  75. package/dist/http/index.js.map +7 -0
  76. package/dist/http/index.mjs +2 -0
  77. package/dist/http/index.mjs.map +7 -0
  78. package/dist/i18n/i18n.d.ts +105 -0
  79. package/dist/i18n/icu.d.ts +64 -0
  80. package/dist/i18n/index.d.ts +2 -0
  81. package/dist/i18n/index.js +2 -0
  82. package/dist/i18n/index.js.map +7 -0
  83. package/dist/i18n/index.mjs +2 -0
  84. package/dist/i18n/index.mjs.map +7 -0
  85. package/dist/index.d.ts +16 -0
  86. package/dist/index.js +5 -0
  87. package/dist/index.js.map +7 -0
  88. package/dist/index.mjs +5 -0
  89. package/dist/index.mjs.map +7 -0
  90. package/dist/lib/DataLoader.d.ts +51 -0
  91. package/dist/lib/DependencyInjection.d.ts +271 -0
  92. package/dist/lib/InvokeParent.d.ts +10 -0
  93. package/dist/lib/Pipes.d.ts +236 -0
  94. package/dist/lib/SequentialId.d.ts +47 -0
  95. package/dist/lib/collections/Index.d.ts +1 -0
  96. package/dist/lib/collections/LinkedList.d.ts +75 -0
  97. package/dist/lib/collections/Pager.d.ts +15 -0
  98. package/dist/lib/collections/TableRenderer.d.ts +44 -0
  99. package/dist/lib/di/index.d.ts +1 -0
  100. package/dist/lib/elements/CopyAttributes.d.ts +2 -0
  101. package/dist/lib/elements/dom.d.ts +18 -0
  102. package/dist/lib/elements/index.d.ts +2 -0
  103. package/dist/lib/errors.d.ts +71 -0
  104. package/dist/lib/forms/FormReader.d.ts +182 -0
  105. package/dist/lib/forms/FormValidator.d.ts +114 -0
  106. package/dist/lib/forms/ValidationRules.d.ts +103 -0
  107. package/dist/lib/forms/index.d.ts +4 -0
  108. package/dist/lib/forms/setFormData.d.ts +49 -0
  109. package/dist/lib/getParentComponent.d.ts +43 -0
  110. package/dist/lib/html/TableRenderer.d.ts +44 -0
  111. package/dist/lib/html/TreeBinder.d.ts +9 -0
  112. package/dist/lib/html/html.d.ts +55 -0
  113. package/dist/lib/html/html2.d.ts +55 -0
  114. package/dist/lib/html/index.d.ts +5 -0
  115. package/dist/lib/html/m.d.ts +167 -0
  116. package/dist/lib/html/m2.d.ts +8 -0
  117. package/dist/lib/html/m3.d.ts +0 -0
  118. package/dist/lib/html/template.d.ts +167 -0
  119. package/dist/lib/http/HttpClient.d.ts +153 -0
  120. package/dist/lib/http/ServerSentEvents.d.ts +116 -0
  121. package/dist/lib/http/SimpleWebSocket.d.ts +153 -0
  122. package/dist/lib/http/http.d.ts +177 -0
  123. package/dist/lib/http/index.d.ts +3 -0
  124. package/dist/lib/i18n/i18n.d.ts +105 -0
  125. package/dist/lib/i18n/icu.d.ts +64 -0
  126. package/dist/lib/i18n/index.d.ts +2 -0
  127. package/dist/lib/index.d.ts +16 -0
  128. package/dist/lib/routing/NavigateRouteEvent.d.ts +52 -0
  129. package/dist/lib/routing/RouteLink.d.ts +7 -0
  130. package/dist/lib/routing/Routing.d.ts +270 -0
  131. package/dist/lib/routing/RoutingTarget.d.ts +22 -0
  132. package/dist/lib/routing/index.d.ts +7 -0
  133. package/dist/lib/routing/navigation.d.ts +70 -0
  134. package/dist/lib/routing/routeMatching.d.ts +21 -0
  135. package/dist/lib/routing/routeTargetRegistry.d.ts +23 -0
  136. package/dist/lib/routing/types.d.ts +130 -0
  137. package/dist/lib/templates/NodeTemplate.d.ts +38 -0
  138. package/dist/lib/templates/accessorParser.d.ts +87 -0
  139. package/dist/lib/templates/parseTemplate.d.ts +6 -0
  140. package/dist/lib/templates/tokenizer.d.ts +76 -0
  141. package/dist/lib/tools.d.ts +30 -0
  142. package/dist/lib/utils/index.d.ts +4 -0
  143. package/dist/pipes.d.ts +236 -0
  144. package/dist/routing/NavigateRouteEvent.d.ts +52 -0
  145. package/dist/routing/RouteLink.d.ts +7 -0
  146. package/dist/routing/RoutingTarget.d.ts +22 -0
  147. package/dist/routing/index.d.ts +7 -0
  148. package/dist/routing/index.js +5 -0
  149. package/dist/routing/index.js.map +7 -0
  150. package/dist/routing/index.mjs +5 -0
  151. package/dist/routing/index.mjs.map +7 -0
  152. package/dist/routing/navigation.d.ts +70 -0
  153. package/dist/routing/routeMatching.d.ts +21 -0
  154. package/dist/routing/routeTargetRegistry.d.ts +23 -0
  155. package/dist/routing/types.d.ts +130 -0
  156. package/dist/templates/NodeTemplate.d.ts +38 -0
  157. package/dist/templates/accessorParser.d.ts +87 -0
  158. package/dist/templates/parseTemplate.d.ts +6 -0
  159. package/dist/templates/tokenizer.d.ts +76 -0
  160. package/dist/tools.d.ts +30 -0
  161. package/dist/utils/index.d.ts +4 -0
  162. package/dist/utils/index.js +2 -0
  163. package/dist/utils/index.js.map +7 -0
  164. package/dist/utils/index.mjs +2 -0
  165. package/dist/utils/index.mjs.map +7 -0
  166. package/docs/Architecture.md +333 -0
  167. package/docs/DependencyInjection.md +237 -0
  168. package/docs/Errors.md +87 -0
  169. package/docs/GettingStarted.md +231 -0
  170. package/docs/Pipes.md +211 -0
  171. package/docs/Translations.md +312 -0
  172. package/docs/WhyRelaxjs.md +336 -0
  173. package/docs/elements/dom.md +102 -0
  174. package/docs/forms/creating-form-components.md +924 -0
  175. package/docs/forms/form-api.md +94 -0
  176. package/docs/forms/forms.md +99 -0
  177. package/docs/forms/patterns.md +311 -0
  178. package/docs/forms/reading-writing.md +365 -0
  179. package/docs/forms/validation.md +351 -0
  180. package/docs/html/TableRenderer.md +292 -0
  181. package/docs/html/html.md +175 -0
  182. package/docs/html/index.md +54 -0
  183. package/docs/html/template.md +422 -0
  184. package/docs/http/HttpClient.md +459 -0
  185. package/docs/http/ServerSentEvents.md +184 -0
  186. package/docs/http/index.md +109 -0
  187. package/docs/i18n/i18n.md +309 -0
  188. package/docs/i18n/intl-standard.md +178 -0
  189. package/docs/routing/RouteLink.md +98 -0
  190. package/docs/routing/Routing.md +332 -0
  191. package/docs/routing/RoutingTarget.md +136 -0
  192. package/docs/routing/layouts.md +207 -0
  193. package/docs/utilities.md +143 -0
  194. package/package.json +93 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @module i18n
3
+ * Internationalization support with namespace-based translations.
4
+ * Uses ICU message format for pluralization, select, and formatting.
5
+ *
6
+ * @example
7
+ * // Initialize locale
8
+ * await setLocale('sv');
9
+ *
10
+ * // Use translations
11
+ * const greeting = t('r-common:greeting', { name: 'John' });
12
+ * const items = t('shop:items', { count: 5 });
13
+ */
14
+ type Namespace = string;
15
+ export type MissingTranslationHandler = (key: string, namespace: string, locale: string) => void;
16
+ /**
17
+ * Dispatched on `document` after `setLocale()` completes.
18
+ * The `locale` property contains the new normalized locale code.
19
+ *
20
+ * @example
21
+ * document.addEventListener('localechange', (e) => {
22
+ * console.log(`Locale changed to ${e.locale}`);
23
+ * this.render();
24
+ * });
25
+ */
26
+ export declare class LocaleChangeEvent extends Event {
27
+ readonly locale: string;
28
+ constructor(locale: string);
29
+ }
30
+ declare global {
31
+ interface DocumentEventMap {
32
+ localechange: LocaleChangeEvent;
33
+ }
34
+ }
35
+ /**
36
+ * Sets the current locale and loads the common namespace.
37
+ * Clears previously loaded translations and dispatches a `localechange` event.
38
+ *
39
+ * @param locale - The locale code (e.g., 'en', 'sv', 'en-US')
40
+ *
41
+ * @example
42
+ * await setLocale('sv');
43
+ */
44
+ export declare function setLocale(locale: string): Promise<void>;
45
+ /**
46
+ * Loads a translation namespace on demand.
47
+ * Falls back to the default locale if translations are not found.
48
+ *
49
+ * @param namespace - The namespace to load (e.g., 'shop', 'errors')
50
+ *
51
+ * @example
52
+ * await loadNamespace('shop');
53
+ * const price = t('shop:priceLabel');
54
+ */
55
+ export declare function loadNamespace(namespace: Namespace): Promise<void>;
56
+ /**
57
+ * Loads multiple translation namespaces in parallel.
58
+ *
59
+ * @param namespaces - Array of namespace names to load
60
+ *
61
+ * @example
62
+ * await loadNamespaces(['r-pipes', 'r-validation']);
63
+ */
64
+ export declare function loadNamespaces(namespaces: Namespace[]): Promise<void>;
65
+ /**
66
+ * Translates a key with optional value interpolation.
67
+ * Supports ICU message format for pluralization and select.
68
+ *
69
+ * @param fullKey - Translation key in format 'namespace:key' or just 'key' (uses 'r-common')
70
+ * @param values - Values to interpolate into the message
71
+ * @returns The translated string, or the key if not found
72
+ *
73
+ * @example
74
+ * // Simple translation
75
+ * t('greeting'); // Uses r-common:greeting
76
+ *
77
+ * // With namespace
78
+ * t('errors:notFound');
79
+ *
80
+ * // With interpolation
81
+ * t('welcome', { name: 'John' }); // "Welcome, John!"
82
+ *
83
+ * // With pluralization (ICU format)
84
+ * t('items', { count: 5 }); // "5 items" or "5 föremål"
85
+ */
86
+ export declare function t(fullKey: string, values?: Record<string, any>): string;
87
+ /**
88
+ * Returns the current locale code.
89
+ *
90
+ * @returns The normalized locale code (e.g., 'en', 'sv')
91
+ */
92
+ export declare function getCurrentLocale(): string;
93
+ /**
94
+ * Registers a handler called when `t()` encounters a missing translation key.
95
+ * Pass `null` to remove the handler.
96
+ *
97
+ * @param handler - Callback receiving the key, namespace, and locale
98
+ *
99
+ * @example
100
+ * onMissingTranslation((key, ns, locale) => {
101
+ * console.warn(`Missing: ${ns}:${key} [${locale}]`);
102
+ * });
103
+ */
104
+ export declare function onMissingTranslation(handler: MissingTranslationHandler | null): void;
105
+ export {};
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @module icu
3
+ * ICU message format support for internationalization.
4
+ * Provides pluralization, select, and value interpolation.
5
+ *
6
+ * @example
7
+ * // Simple interpolation
8
+ * formatICU('Hello, {name}!', { name: 'World' });
9
+ * // Returns: 'Hello, World!'
10
+ *
11
+ * @example
12
+ * // Pluralization
13
+ * formatICU('{count, plural, one {# item} other {# items}}', { count: 5 });
14
+ * // Returns: '5 items'
15
+ *
16
+ * @example
17
+ * // Select
18
+ * formatICU('{gender, select, male {He} female {She} other {They}}', { gender: 'female' });
19
+ * // Returns: 'She'
20
+ */
21
+ /**
22
+ * Function type for message formatters.
23
+ * Implement this to provide custom message formatting.
24
+ */
25
+ export type MessageFormatter = (message: string, values?: Record<string, any>, locale?: string) => string;
26
+ /**
27
+ * Default ICU message formatter implementation.
28
+ * Supports simple interpolation, pluralization with exact matches, and select.
29
+ *
30
+ * @param message - ICU format message string
31
+ * @param values - Values to interpolate
32
+ * @param locale - Locale for plural rules (default: 'en')
33
+ * @returns Formatted message string
34
+ *
35
+ * @example
36
+ * defaultFormatICU('{n, plural, =0 {none} one {# item} other {# items}}', { n: 0 }, 'en');
37
+ * // Returns: 'none'
38
+ *
39
+ * @example
40
+ * defaultFormatICU('{role, select, admin {Full access} other {Limited access}}', { role: 'admin' });
41
+ * // Returns: 'Full access'
42
+ */
43
+ export declare function defaultFormatICU(message: string, values: Record<string, any>, locale?: string): string;
44
+ /**
45
+ * The active message formatter. Defaults to `defaultFormatICU`.
46
+ * Can be replaced with `setMessageFormatter` for custom formatting.
47
+ */
48
+ export declare let formatICU: MessageFormatter;
49
+ /**
50
+ * Replaces the default message formatter with a custom implementation.
51
+ * Use this to integrate with external i18n libraries like FormatJS.
52
+ *
53
+ * @param formatter - The custom formatter function
54
+ *
55
+ * @example
56
+ * // Use FormatJS IntlMessageFormat
57
+ * import { IntlMessageFormat } from 'intl-messageformat';
58
+ *
59
+ * setMessageFormatter((message, values, locale) => {
60
+ * const fmt = new IntlMessageFormat(message, locale);
61
+ * return fmt.format(values);
62
+ * });
63
+ */
64
+ export declare function setMessageFormatter(formatter: MessageFormatter): void;
@@ -0,0 +1,2 @@
1
+ export { t, setLocale, loadNamespace, loadNamespaces, getCurrentLocale, onMissingTranslation, LocaleChangeEvent, MissingTranslationHandler, } from './i18n';
2
+ export { MessageFormatter, formatICU, setMessageFormatter, } from './icu';
@@ -0,0 +1,2 @@
1
+ var z=Object.create;var m=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var b=e=>t=>{var n=e[t];if(n)return n();throw new Error("Module not found in bundle: "+t)};var i=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),G=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of O(t))!B.call(e,r)&&r!==n&&m(e,r,{get:()=>t[r],enumerable:!(o=D(t,r))||o.enumerable});return e};var l=(e,t,n)=>(n=e!=null?z(_(e)):{},v(t||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>v(m({},"__esModule",{value:!0}),e);var N=i((se,W)=>{W.exports={greeting:"Hello, {name}!",items:"{count, plural, one {# item} other {# items}}"}});var E=i((oe,X)=>{X.exports={today:"today",yesterday:"yesterday",daysAgo:"{count, plural, one {# day ago} other {# days ago}}",pieces:"{count, plural, =0 {none} one {one} other {# pcs}}"}});var S=i((ie,Y)=>{Y.exports={required:"This field is required.",range:"Number must be between {min} and {max}, was {actual}.",digits:"Please enter only digits."}});var C=i((le,Z)=>{Z.exports={greeting:"Hej, {name}!",items:"{count, plural, one {# sak} other {# saker}}"}});var F=i((ce,K)=>{K.exports={today:"idag",yesterday:"ig\xE5r",daysAgo:"{count, plural, one {# dag sedan} other {# dagar sedan}}",pieces:"{count, plural, =0 {inga} one {en} other {# st}}"}});var H=i((ge,ee)=>{ee.exports={required:"Detta f\xE4lt \xE4r obligatoriskt.",range:"Talet m\xE5ste vara mellan {min} och {max}, var {actual}.",digits:"Ange endast siffror."}});var ne={};G(ne,{LocaleChangeEvent:()=>u,formatICU:()=>g,getCurrentLocale:()=>j,loadNamespace:()=>x,loadNamespaces:()=>P,onMissingTranslation:()=>q,setLocale:()=>k,setMessageFormatter:()=>T,t:()=>U});module.exports=J(ne);var h=new Map;function Q(e){return h.has(e)||h.set(e,new Intl.PluralRules(e)),h.get(e)}function L(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(e,t,n="en"){return e.replace(/\{(\w+)(?:, (plural|select),((?:[^{}]*\{[^{}]*\})+))?\}/g,(o,r,R,c)=>{let a=t[r];if(R==="plural"){let p=new RegExp(`=${L(String(a))}\\s*\\{([^{}]*)\\}`).exec(c);if(p)return p[1].replace(`{${r}}`,String(a)).replace("#",String(a));let A=Q(n).select(a),$=new RegExp(`${A}\\s*\\{([^{}]*)\\}`).exec(c)||new RegExp("other\\s*\\{([^{}]*)\\}").exec(c);return $?$[1].replace(`{${r}}`,String(a)).replace("#",String(a)):String(a)}if(R==="select"){let p=L(String(a)),y=new RegExp(`\\b${p}\\s*\\{([^{}]*)\\}`).exec(c)||new RegExp("\\bother\\s*\\{([^{}]*)\\}").exec(c);return y?y[1]:String(a)}return a!==void 0?String(a):`{${r}}`})}var g=V;function T(e){g=e}var I=b({"./locales/en/r-common.json":()=>Promise.resolve().then(()=>l(N())),"./locales/en/r-pipes.json":()=>Promise.resolve().then(()=>l(E())),"./locales/en/r-validation.json":()=>Promise.resolve().then(()=>l(S())),"./locales/sv/r-common.json":()=>Promise.resolve().then(()=>l(C())),"./locales/sv/r-pipes.json":()=>Promise.resolve().then(()=>l(F())),"./locales/sv/r-validation.json":()=>Promise.resolve().then(()=>l(H()))});var u=class extends Event{constructor(t){super("localechange",{bubbles:!1}),this.locale=t}},w="en",s=w,f=new Set,d={},M=null;function te(e){return e.toLowerCase().split("-")[0]}async function k(e){let t=te(e);s=t,f.clear(),Object.keys(d).forEach(n=>delete d[n]),await x("r-common"),typeof document<"u"&&document.dispatchEvent(new u(t))}async function x(e){if(!f.has(e))try{let t=await I(`./locales/${s}/${e}.json`);d[e]=t.default,f.add(e)}catch{if(s!==w){let n=await I(`./locales/${w}/${e}.json`);d[e]=n.default,f.add(e)}else console.warn(`i18n: Failed to load namespace '${e}' for locale '${s}'`)}}async function P(e){await Promise.all(e.map(t=>x(t)))}function U(e,t){let[n,o]=e.includes(":")?e.split(":"):["r-common",e],r=d[n]?.[o];if(!r)return M&&M(o,n,s),e;try{return g(r,t,s)}catch{return e}}function j(){return s}function q(e){M=e}
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/i18n/locales/en/r-common.json", "../../src/i18n/locales/en/r-pipes.json", "../../src/i18n/locales/en/r-validation.json", "../../src/i18n/locales/sv/r-common.json", "../../src/i18n/locales/sv/r-pipes.json", "../../src/i18n/locales/sv/r-validation.json", "../../src/i18n/index.ts", "../../src/i18n/icu.ts", "../../src/i18n/i18n.ts"],
4
+ "sourcesContent": ["{\r\n \"greeting\": \"Hello, {name}!\",\r\n \"items\": \"{count, plural, one {# item} other {# items}}\"\r\n}\r\n", "{\r\n \"today\": \"today\",\r\n \"yesterday\": \"yesterday\",\r\n \"daysAgo\": \"{count, plural, one {# day ago} other {# days ago}}\",\r\n \"pieces\": \"{count, plural, =0 {none} one {one} other {# pcs}}\"\r\n}\r\n", "{\r\n \"required\": \"This field is required.\",\r\n \"range\": \"Number must be between {min} and {max}, was {actual}.\",\r\n \"digits\": \"Please enter only digits.\"\r\n}\r\n", "{\r\n \"greeting\": \"Hej, {name}!\",\r\n \"items\": \"{count, plural, one {# sak} other {# saker}}\"\r\n}\r\n", "{\r\n \"today\": \"idag\",\r\n \"yesterday\": \"ig\u00E5r\",\r\n \"daysAgo\": \"{count, plural, one {# dag sedan} other {# dagar sedan}}\",\r\n \"pieces\": \"{count, plural, =0 {inga} one {en} other {# st}}\"\r\n}\r\n", "{\r\n \"required\": \"Detta f\u00E4lt \u00E4r obligatoriskt.\",\r\n \"range\": \"Talet m\u00E5ste vara mellan {min} och {max}, var {actual}.\",\r\n \"digits\": \"Ange endast siffror.\"\r\n}\r\n", "export {\r\n t,\r\n setLocale,\r\n loadNamespace,\r\n loadNamespaces,\r\n getCurrentLocale,\r\n onMissingTranslation,\r\n LocaleChangeEvent,\r\n MissingTranslationHandler,\r\n} from './i18n';\r\n\r\nexport {\r\n MessageFormatter,\r\n formatICU,\r\n setMessageFormatter,\r\n} from './icu';\r\n", "/**\r\n * @module icu\r\n * ICU message format support for internationalization.\r\n * Provides pluralization, select, and value interpolation.\r\n *\r\n * @example\r\n * // Simple interpolation\r\n * formatICU('Hello, {name}!', { name: 'World' });\r\n * // Returns: 'Hello, World!'\r\n *\r\n * @example\r\n * // Pluralization\r\n * formatICU('{count, plural, one {# item} other {# items}}', { count: 5 });\r\n * // Returns: '5 items'\r\n *\r\n * @example\r\n * // Select\r\n * formatICU('{gender, select, male {He} female {She} other {They}}', { gender: 'female' });\r\n * // Returns: 'She'\r\n */\r\n\r\nconst pluralRulesCache = new Map<string, Intl.PluralRules>();\r\n\r\n/**\r\n * Function type for message formatters.\r\n * Implement this to provide custom message formatting.\r\n */\r\nexport type MessageFormatter = (\r\n message: string,\r\n values?: Record<string, any>,\r\n locale?: string\r\n) => string;\r\n\r\n\r\nfunction getPluralRule(locale: string): Intl.PluralRules {\r\n if (!pluralRulesCache.has(locale)) {\r\n pluralRulesCache.set(locale, new Intl.PluralRules(locale));\r\n }\r\n return pluralRulesCache.get(locale)!;\r\n}\r\n\r\nfunction escapeRegex(s: string): string {\r\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\r\n}\r\n\r\n/**\r\n * Default ICU message formatter implementation.\r\n * Supports simple interpolation, pluralization with exact matches, and select.\r\n *\r\n * @param message - ICU format message string\r\n * @param values - Values to interpolate\r\n * @param locale - Locale for plural rules (default: 'en')\r\n * @returns Formatted message string\r\n *\r\n * @example\r\n * defaultFormatICU('{n, plural, =0 {none} one {# item} other {# items}}', { n: 0 }, 'en');\r\n * // Returns: 'none'\r\n *\r\n * @example\r\n * defaultFormatICU('{role, select, admin {Full access} other {Limited access}}', { role: 'admin' });\r\n * // Returns: 'Full access'\r\n */\r\nexport function defaultFormatICU(\r\n message: string,\r\n values: Record<string, any>,\r\n locale: string = 'en'\r\n): string {\r\n return message.replace(\r\n /\\{(\\w+)(?:, (plural|select),((?:[^{}]*\\{[^{}]*\\})+))?\\}/g,\r\n (_, key, type, categoriesPart) => {\r\n const value = values[key];\r\n\r\n if (type === 'plural') {\r\n const exact = new RegExp(\r\n `=${escapeRegex(String(value))}\\\\s*\\\\{([^{}]*)\\\\}`\r\n ).exec(categoriesPart);\r\n if (exact) {\r\n return exact[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n\r\n const rules = getPluralRule(locale);\r\n const category = rules.select(value);\r\n const match =\r\n new RegExp(`${category}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`other\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n if (match) {\r\n return match[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n return String(value);\r\n }\r\n\r\n if (type === 'select') {\r\n const escaped = escapeRegex(String(value));\r\n const match =\r\n new RegExp(`\\\\b${escaped}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`\\\\bother\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n return match ? match[1] : String(value);\r\n }\r\n\r\n return value !== undefined ? String(value) : `{${key}}`;\r\n },\r\n );\r\n}\r\n\r\n/**\r\n * The active message formatter. Defaults to `defaultFormatICU`.\r\n * Can be replaced with `setMessageFormatter` for custom formatting.\r\n */\r\nexport let formatICU: MessageFormatter = defaultFormatICU;\r\n\r\n/**\r\n * Replaces the default message formatter with a custom implementation.\r\n * Use this to integrate with external i18n libraries like FormatJS.\r\n *\r\n * @param formatter - The custom formatter function\r\n *\r\n * @example\r\n * // Use FormatJS IntlMessageFormat\r\n * import { IntlMessageFormat } from 'intl-messageformat';\r\n *\r\n * setMessageFormatter((message, values, locale) => {\r\n * const fmt = new IntlMessageFormat(message, locale);\r\n * return fmt.format(values);\r\n * });\r\n */\r\nexport function setMessageFormatter(formatter: MessageFormatter) {\r\n formatICU = formatter;\r\n}", "/**\r\n * @module i18n\r\n * Internationalization support with namespace-based translations.\r\n * Uses ICU message format for pluralization, select, and formatting.\r\n *\r\n * @example\r\n * // Initialize locale\r\n * await setLocale('sv');\r\n *\r\n * // Use translations\r\n * const greeting = t('r-common:greeting', { name: 'John' });\r\n * const items = t('shop:items', { count: 5 });\r\n */\r\n\r\nimport { formatICU } from './icu';\r\n\r\ntype Locale = string;\r\ntype Namespace = string;\r\ntype TranslationMap = Record<string, string>;\r\ntype Translations = Record<Namespace, TranslationMap>;\r\n\r\nexport type MissingTranslationHandler = (\r\n key: string,\r\n namespace: string,\r\n locale: string,\r\n) => void;\r\n\r\n/**\r\n * Dispatched on `document` after `setLocale()` completes.\r\n * The `locale` property contains the new normalized locale code.\r\n *\r\n * @example\r\n * document.addEventListener('localechange', (e) => {\r\n * console.log(`Locale changed to ${e.locale}`);\r\n * this.render();\r\n * });\r\n */\r\nexport class LocaleChangeEvent extends Event {\r\n readonly locale: string;\r\n constructor(locale: string) {\r\n super('localechange', { bubbles: false });\r\n this.locale = locale;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface DocumentEventMap {\r\n localechange: LocaleChangeEvent;\r\n }\r\n}\r\n\r\nconst fallbackLocale: Locale = 'en';\r\nlet currentLocale: Locale = fallbackLocale;\r\nconst loadedNamespaces = new Set<Namespace>();\r\nconst translations: Translations = {};\r\nlet missingHandler: MissingTranslationHandler | null = null;\r\n\r\nfunction normalizeLocale(locale: string): string {\r\n return locale.toLowerCase().split('-')[0];\r\n}\r\n\r\n/**\r\n * Sets the current locale and loads the common namespace.\r\n * Clears previously loaded translations and dispatches a `localechange` event.\r\n *\r\n * @param locale - The locale code (e.g., 'en', 'sv', 'en-US')\r\n *\r\n * @example\r\n * await setLocale('sv');\r\n */\r\nexport async function setLocale(locale: string): Promise<void> {\r\n const normalized = normalizeLocale(locale);\r\n currentLocale = normalized;\r\n loadedNamespaces.clear();\r\n Object.keys(translations).forEach(ns => delete translations[ns]);\r\n await loadNamespace('r-common');\r\n if (typeof document !== 'undefined') {\r\n document.dispatchEvent(new LocaleChangeEvent(normalized));\r\n }\r\n}\r\n\r\n/**\r\n * Loads a translation namespace on demand.\r\n * Falls back to the default locale if translations are not found.\r\n *\r\n * @param namespace - The namespace to load (e.g., 'shop', 'errors')\r\n *\r\n * @example\r\n * await loadNamespace('shop');\r\n * const price = t('shop:priceLabel');\r\n */\r\nexport async function loadNamespace(namespace: Namespace): Promise<void> {\r\n if (loadedNamespaces.has(namespace)) return;\r\n\r\n try {\r\n const module = await import(`./locales/${currentLocale}/${namespace}.json`);\r\n translations[namespace] = module.default;\r\n loadedNamespaces.add(namespace);\r\n } catch (err) {\r\n if (currentLocale !== fallbackLocale) {\r\n const fallback = await import(`./locales/${fallbackLocale}/${namespace}.json`);\r\n translations[namespace] = fallback.default;\r\n loadedNamespaces.add(namespace);\r\n } else {\r\n console.warn(`i18n: Failed to load namespace '${namespace}' for locale '${currentLocale}'`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Loads multiple translation namespaces in parallel.\r\n *\r\n * @param namespaces - Array of namespace names to load\r\n *\r\n * @example\r\n * await loadNamespaces(['r-pipes', 'r-validation']);\r\n */\r\nexport async function loadNamespaces(namespaces: Namespace[]): Promise<void> {\r\n await Promise.all(namespaces.map(ns => loadNamespace(ns)));\r\n}\r\n\r\n/**\r\n * Translates a key with optional value interpolation.\r\n * Supports ICU message format for pluralization and select.\r\n *\r\n * @param fullKey - Translation key in format 'namespace:key' or just 'key' (uses 'r-common')\r\n * @param values - Values to interpolate into the message\r\n * @returns The translated string, or the key if not found\r\n *\r\n * @example\r\n * // Simple translation\r\n * t('greeting'); // Uses r-common:greeting\r\n *\r\n * // With namespace\r\n * t('errors:notFound');\r\n *\r\n * // With interpolation\r\n * t('welcome', { name: 'John' }); // \"Welcome, John!\"\r\n *\r\n * // With pluralization (ICU format)\r\n * t('items', { count: 5 }); // \"5 items\" or \"5 f\u00F6rem\u00E5l\"\r\n */\r\nexport function t(fullKey: string, values?: Record<string, any>): string {\r\n const [namespace, key] = fullKey.includes(':')\r\n ? fullKey.split(':')\r\n : ['r-common', fullKey];\r\n const message = translations[namespace]?.[key];\r\n if (!message) {\r\n if (missingHandler) missingHandler(key, namespace, currentLocale);\r\n return fullKey;\r\n }\r\n try {\r\n return formatICU(message, values, currentLocale) as string;\r\n } catch {\r\n return fullKey;\r\n }\r\n}\r\n\r\n/**\r\n * Returns the current locale code.\r\n *\r\n * @returns The normalized locale code (e.g., 'en', 'sv')\r\n */\r\nexport function getCurrentLocale(): string {\r\n return currentLocale;\r\n}\r\n\r\n/**\r\n * Registers a handler called when `t()` encounters a missing translation key.\r\n * Pass `null` to remove the handler.\r\n *\r\n * @param handler - Callback receiving the key, namespace, and locale\r\n *\r\n * @example\r\n * onMissingTranslation((key, ns, locale) => {\r\n * console.warn(`Missing: ${ns}:${key} [${locale}]`);\r\n * });\r\n */\r\nexport function onMissingTranslation(handler: MissingTranslationHandler | null): void {\r\n missingHandler = handler;\r\n}\r\n"],
5
+ "mappings": "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",
6
+ "names": ["require_r_common", "__commonJSMin", "exports", "module", "require_r_pipes", "__commonJSMin", "exports", "module", "require_r_validation", "__commonJSMin", "exports", "module", "require_r_common", "__commonJSMin", "exports", "module", "require_r_pipes", "__commonJSMin", "exports", "module", "require_r_validation", "__commonJSMin", "exports", "module", "index_exports", "__export", "LocaleChangeEvent", "formatICU", "getCurrentLocale", "loadNamespace", "loadNamespaces", "onMissingTranslation", "setLocale", "setMessageFormatter", "t", "__toCommonJS", "pluralRulesCache", "getPluralRule", "locale", "escapeRegex", "s", "defaultFormatICU", "message", "values", "_", "key", "type", "categoriesPart", "value", "exact", "category", "match", "escaped", "formatICU", "setMessageFormatter", "formatter", "LocaleChangeEvent", "locale", "fallbackLocale", "currentLocale", "loadedNamespaces", "translations", "missingHandler", "normalizeLocale", "setLocale", "normalized", "ns", "loadNamespace", "namespace", "module", "globImport_locales_json", "fallback", "loadNamespaces", "namespaces", "t", "fullKey", "values", "key", "message", "formatICU", "getCurrentLocale", "onMissingTranslation", "handler"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var I=Object.create;var $=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var b=e=>t=>{var n=e[t];if(n)return n();throw new Error("Module not found in bundle: "+t)};var i=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var q=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!j.call(e,r)&&r!==n&&$(e,r,{get:()=>t[r],enumerable:!(o=k(t,r))||o.enumerable});return e};var l=(e,t,n)=>(n=e!=null?I(U(e)):{},q(t||!e||!e.__esModule?$(n,"default",{value:e,enumerable:!0}):n,e));var L=i((ne,O)=>{O.exports={greeting:"Hello, {name}!",items:"{count, plural, one {# item} other {# items}}"}});var T=i((re,_)=>{_.exports={today:"today",yesterday:"yesterday",daysAgo:"{count, plural, one {# day ago} other {# days ago}}",pieces:"{count, plural, =0 {none} one {one} other {# pcs}}"}});var N=i((ae,B)=>{B.exports={required:"This field is required.",range:"Number must be between {min} and {max}, was {actual}.",digits:"Please enter only digits."}});var E=i((se,G)=>{G.exports={greeting:"Hej, {name}!",items:"{count, plural, one {# sak} other {# saker}}"}});var S=i((oe,J)=>{J.exports={today:"idag",yesterday:"ig\xE5r",daysAgo:"{count, plural, one {# dag sedan} other {# dagar sedan}}",pieces:"{count, plural, =0 {inga} one {en} other {# st}}"}});var C=i((ie,Q)=>{Q.exports={required:"Detta f\xE4lt \xE4r obligatoriskt.",range:"Talet m\xE5ste vara mellan {min} och {max}, var {actual}.",digits:"Ange endast siffror."}});var x=new Map;function A(e){return x.has(e)||x.set(e,new Intl.PluralRules(e)),x.get(e)}function v(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function z(e,t,n="en"){return e.replace(/\{(\w+)(?:, (plural|select),((?:[^{}]*\{[^{}]*\})+))?\}/g,(o,r,M,c)=>{let a=t[r];if(M==="plural"){let u=new RegExp(`=${v(String(a))}\\s*\\{([^{}]*)\\}`).exec(c);if(u)return u[1].replace(`{${r}}`,String(a)).replace("#",String(a));let H=A(n).select(a),R=new RegExp(`${H}\\s*\\{([^{}]*)\\}`).exec(c)||new RegExp("other\\s*\\{([^{}]*)\\}").exec(c);return R?R[1].replace(`{${r}}`,String(a)).replace("#",String(a)):String(a)}if(M==="select"){let u=v(String(a)),f=new RegExp(`\\b${u}\\s*\\{([^{}]*)\\}`).exec(c)||new RegExp("\\bother\\s*\\{([^{}]*)\\}").exec(c);return f?f[1]:String(a)}return a!==void 0?String(a):`{${r}}`})}var d=z;function D(e){d=e}var F=b({"./locales/en/r-common.json":()=>Promise.resolve().then(()=>l(L())),"./locales/en/r-pipes.json":()=>Promise.resolve().then(()=>l(T())),"./locales/en/r-validation.json":()=>Promise.resolve().then(()=>l(N())),"./locales/sv/r-common.json":()=>Promise.resolve().then(()=>l(E())),"./locales/sv/r-pipes.json":()=>Promise.resolve().then(()=>l(S())),"./locales/sv/r-validation.json":()=>Promise.resolve().then(()=>l(C()))});var m=class extends Event{constructor(t){super("localechange",{bubbles:!1}),this.locale=t}},y="en",s=y,p=new Set,g={},h=null;function V(e){return e.toLowerCase().split("-")[0]}async function W(e){let t=V(e);s=t,p.clear(),Object.keys(g).forEach(n=>delete g[n]),await w("r-common"),typeof document<"u"&&document.dispatchEvent(new m(t))}async function w(e){if(!p.has(e))try{let t=await F(`./locales/${s}/${e}.json`);g[e]=t.default,p.add(e)}catch{if(s!==y){let n=await F(`./locales/${y}/${e}.json`);g[e]=n.default,p.add(e)}else console.warn(`i18n: Failed to load namespace '${e}' for locale '${s}'`)}}async function X(e){await Promise.all(e.map(t=>w(t)))}function Y(e,t){let[n,o]=e.includes(":")?e.split(":"):["r-common",e],r=g[n]?.[o];if(!r)return h&&h(o,n,s),e;try{return d(r,t,s)}catch{return e}}function Z(){return s}function K(e){h=e}export{m as LocaleChangeEvent,d as formatICU,Z as getCurrentLocale,w as loadNamespace,X as loadNamespaces,K as onMissingTranslation,W as setLocale,D as setMessageFormatter,Y as t};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/i18n/locales/en/r-common.json", "../../src/i18n/locales/en/r-pipes.json", "../../src/i18n/locales/en/r-validation.json", "../../src/i18n/locales/sv/r-common.json", "../../src/i18n/locales/sv/r-pipes.json", "../../src/i18n/locales/sv/r-validation.json", "../../src/i18n/icu.ts", "../../src/i18n/i18n.ts"],
4
+ "sourcesContent": ["{\r\n \"greeting\": \"Hello, {name}!\",\r\n \"items\": \"{count, plural, one {# item} other {# items}}\"\r\n}\r\n", "{\r\n \"today\": \"today\",\r\n \"yesterday\": \"yesterday\",\r\n \"daysAgo\": \"{count, plural, one {# day ago} other {# days ago}}\",\r\n \"pieces\": \"{count, plural, =0 {none} one {one} other {# pcs}}\"\r\n}\r\n", "{\r\n \"required\": \"This field is required.\",\r\n \"range\": \"Number must be between {min} and {max}, was {actual}.\",\r\n \"digits\": \"Please enter only digits.\"\r\n}\r\n", "{\r\n \"greeting\": \"Hej, {name}!\",\r\n \"items\": \"{count, plural, one {# sak} other {# saker}}\"\r\n}\r\n", "{\r\n \"today\": \"idag\",\r\n \"yesterday\": \"ig\u00E5r\",\r\n \"daysAgo\": \"{count, plural, one {# dag sedan} other {# dagar sedan}}\",\r\n \"pieces\": \"{count, plural, =0 {inga} one {en} other {# st}}\"\r\n}\r\n", "{\r\n \"required\": \"Detta f\u00E4lt \u00E4r obligatoriskt.\",\r\n \"range\": \"Talet m\u00E5ste vara mellan {min} och {max}, var {actual}.\",\r\n \"digits\": \"Ange endast siffror.\"\r\n}\r\n", "/**\r\n * @module icu\r\n * ICU message format support for internationalization.\r\n * Provides pluralization, select, and value interpolation.\r\n *\r\n * @example\r\n * // Simple interpolation\r\n * formatICU('Hello, {name}!', { name: 'World' });\r\n * // Returns: 'Hello, World!'\r\n *\r\n * @example\r\n * // Pluralization\r\n * formatICU('{count, plural, one {# item} other {# items}}', { count: 5 });\r\n * // Returns: '5 items'\r\n *\r\n * @example\r\n * // Select\r\n * formatICU('{gender, select, male {He} female {She} other {They}}', { gender: 'female' });\r\n * // Returns: 'She'\r\n */\r\n\r\nconst pluralRulesCache = new Map<string, Intl.PluralRules>();\r\n\r\n/**\r\n * Function type for message formatters.\r\n * Implement this to provide custom message formatting.\r\n */\r\nexport type MessageFormatter = (\r\n message: string,\r\n values?: Record<string, any>,\r\n locale?: string\r\n) => string;\r\n\r\n\r\nfunction getPluralRule(locale: string): Intl.PluralRules {\r\n if (!pluralRulesCache.has(locale)) {\r\n pluralRulesCache.set(locale, new Intl.PluralRules(locale));\r\n }\r\n return pluralRulesCache.get(locale)!;\r\n}\r\n\r\nfunction escapeRegex(s: string): string {\r\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\r\n}\r\n\r\n/**\r\n * Default ICU message formatter implementation.\r\n * Supports simple interpolation, pluralization with exact matches, and select.\r\n *\r\n * @param message - ICU format message string\r\n * @param values - Values to interpolate\r\n * @param locale - Locale for plural rules (default: 'en')\r\n * @returns Formatted message string\r\n *\r\n * @example\r\n * defaultFormatICU('{n, plural, =0 {none} one {# item} other {# items}}', { n: 0 }, 'en');\r\n * // Returns: 'none'\r\n *\r\n * @example\r\n * defaultFormatICU('{role, select, admin {Full access} other {Limited access}}', { role: 'admin' });\r\n * // Returns: 'Full access'\r\n */\r\nexport function defaultFormatICU(\r\n message: string,\r\n values: Record<string, any>,\r\n locale: string = 'en'\r\n): string {\r\n return message.replace(\r\n /\\{(\\w+)(?:, (plural|select),((?:[^{}]*\\{[^{}]*\\})+))?\\}/g,\r\n (_, key, type, categoriesPart) => {\r\n const value = values[key];\r\n\r\n if (type === 'plural') {\r\n const exact = new RegExp(\r\n `=${escapeRegex(String(value))}\\\\s*\\\\{([^{}]*)\\\\}`\r\n ).exec(categoriesPart);\r\n if (exact) {\r\n return exact[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n\r\n const rules = getPluralRule(locale);\r\n const category = rules.select(value);\r\n const match =\r\n new RegExp(`${category}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`other\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n if (match) {\r\n return match[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n return String(value);\r\n }\r\n\r\n if (type === 'select') {\r\n const escaped = escapeRegex(String(value));\r\n const match =\r\n new RegExp(`\\\\b${escaped}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`\\\\bother\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n return match ? match[1] : String(value);\r\n }\r\n\r\n return value !== undefined ? String(value) : `{${key}}`;\r\n },\r\n );\r\n}\r\n\r\n/**\r\n * The active message formatter. Defaults to `defaultFormatICU`.\r\n * Can be replaced with `setMessageFormatter` for custom formatting.\r\n */\r\nexport let formatICU: MessageFormatter = defaultFormatICU;\r\n\r\n/**\r\n * Replaces the default message formatter with a custom implementation.\r\n * Use this to integrate with external i18n libraries like FormatJS.\r\n *\r\n * @param formatter - The custom formatter function\r\n *\r\n * @example\r\n * // Use FormatJS IntlMessageFormat\r\n * import { IntlMessageFormat } from 'intl-messageformat';\r\n *\r\n * setMessageFormatter((message, values, locale) => {\r\n * const fmt = new IntlMessageFormat(message, locale);\r\n * return fmt.format(values);\r\n * });\r\n */\r\nexport function setMessageFormatter(formatter: MessageFormatter) {\r\n formatICU = formatter;\r\n}", "/**\r\n * @module i18n\r\n * Internationalization support with namespace-based translations.\r\n * Uses ICU message format for pluralization, select, and formatting.\r\n *\r\n * @example\r\n * // Initialize locale\r\n * await setLocale('sv');\r\n *\r\n * // Use translations\r\n * const greeting = t('r-common:greeting', { name: 'John' });\r\n * const items = t('shop:items', { count: 5 });\r\n */\r\n\r\nimport { formatICU } from './icu';\r\n\r\ntype Locale = string;\r\ntype Namespace = string;\r\ntype TranslationMap = Record<string, string>;\r\ntype Translations = Record<Namespace, TranslationMap>;\r\n\r\nexport type MissingTranslationHandler = (\r\n key: string,\r\n namespace: string,\r\n locale: string,\r\n) => void;\r\n\r\n/**\r\n * Dispatched on `document` after `setLocale()` completes.\r\n * The `locale` property contains the new normalized locale code.\r\n *\r\n * @example\r\n * document.addEventListener('localechange', (e) => {\r\n * console.log(`Locale changed to ${e.locale}`);\r\n * this.render();\r\n * });\r\n */\r\nexport class LocaleChangeEvent extends Event {\r\n readonly locale: string;\r\n constructor(locale: string) {\r\n super('localechange', { bubbles: false });\r\n this.locale = locale;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface DocumentEventMap {\r\n localechange: LocaleChangeEvent;\r\n }\r\n}\r\n\r\nconst fallbackLocale: Locale = 'en';\r\nlet currentLocale: Locale = fallbackLocale;\r\nconst loadedNamespaces = new Set<Namespace>();\r\nconst translations: Translations = {};\r\nlet missingHandler: MissingTranslationHandler | null = null;\r\n\r\nfunction normalizeLocale(locale: string): string {\r\n return locale.toLowerCase().split('-')[0];\r\n}\r\n\r\n/**\r\n * Sets the current locale and loads the common namespace.\r\n * Clears previously loaded translations and dispatches a `localechange` event.\r\n *\r\n * @param locale - The locale code (e.g., 'en', 'sv', 'en-US')\r\n *\r\n * @example\r\n * await setLocale('sv');\r\n */\r\nexport async function setLocale(locale: string): Promise<void> {\r\n const normalized = normalizeLocale(locale);\r\n currentLocale = normalized;\r\n loadedNamespaces.clear();\r\n Object.keys(translations).forEach(ns => delete translations[ns]);\r\n await loadNamespace('r-common');\r\n if (typeof document !== 'undefined') {\r\n document.dispatchEvent(new LocaleChangeEvent(normalized));\r\n }\r\n}\r\n\r\n/**\r\n * Loads a translation namespace on demand.\r\n * Falls back to the default locale if translations are not found.\r\n *\r\n * @param namespace - The namespace to load (e.g., 'shop', 'errors')\r\n *\r\n * @example\r\n * await loadNamespace('shop');\r\n * const price = t('shop:priceLabel');\r\n */\r\nexport async function loadNamespace(namespace: Namespace): Promise<void> {\r\n if (loadedNamespaces.has(namespace)) return;\r\n\r\n try {\r\n const module = await import(`./locales/${currentLocale}/${namespace}.json`);\r\n translations[namespace] = module.default;\r\n loadedNamespaces.add(namespace);\r\n } catch (err) {\r\n if (currentLocale !== fallbackLocale) {\r\n const fallback = await import(`./locales/${fallbackLocale}/${namespace}.json`);\r\n translations[namespace] = fallback.default;\r\n loadedNamespaces.add(namespace);\r\n } else {\r\n console.warn(`i18n: Failed to load namespace '${namespace}' for locale '${currentLocale}'`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Loads multiple translation namespaces in parallel.\r\n *\r\n * @param namespaces - Array of namespace names to load\r\n *\r\n * @example\r\n * await loadNamespaces(['r-pipes', 'r-validation']);\r\n */\r\nexport async function loadNamespaces(namespaces: Namespace[]): Promise<void> {\r\n await Promise.all(namespaces.map(ns => loadNamespace(ns)));\r\n}\r\n\r\n/**\r\n * Translates a key with optional value interpolation.\r\n * Supports ICU message format for pluralization and select.\r\n *\r\n * @param fullKey - Translation key in format 'namespace:key' or just 'key' (uses 'r-common')\r\n * @param values - Values to interpolate into the message\r\n * @returns The translated string, or the key if not found\r\n *\r\n * @example\r\n * // Simple translation\r\n * t('greeting'); // Uses r-common:greeting\r\n *\r\n * // With namespace\r\n * t('errors:notFound');\r\n *\r\n * // With interpolation\r\n * t('welcome', { name: 'John' }); // \"Welcome, John!\"\r\n *\r\n * // With pluralization (ICU format)\r\n * t('items', { count: 5 }); // \"5 items\" or \"5 f\u00F6rem\u00E5l\"\r\n */\r\nexport function t(fullKey: string, values?: Record<string, any>): string {\r\n const [namespace, key] = fullKey.includes(':')\r\n ? fullKey.split(':')\r\n : ['r-common', fullKey];\r\n const message = translations[namespace]?.[key];\r\n if (!message) {\r\n if (missingHandler) missingHandler(key, namespace, currentLocale);\r\n return fullKey;\r\n }\r\n try {\r\n return formatICU(message, values, currentLocale) as string;\r\n } catch {\r\n return fullKey;\r\n }\r\n}\r\n\r\n/**\r\n * Returns the current locale code.\r\n *\r\n * @returns The normalized locale code (e.g., 'en', 'sv')\r\n */\r\nexport function getCurrentLocale(): string {\r\n return currentLocale;\r\n}\r\n\r\n/**\r\n * Registers a handler called when `t()` encounters a missing translation key.\r\n * Pass `null` to remove the handler.\r\n *\r\n * @param handler - Callback receiving the key, namespace, and locale\r\n *\r\n * @example\r\n * onMissingTranslation((key, ns, locale) => {\r\n * console.warn(`Missing: ${ns}:${key} [${locale}]`);\r\n * });\r\n */\r\nexport function onMissingTranslation(handler: MissingTranslationHandler | null): void {\r\n missingHandler = handler;\r\n}\r\n"],
5
+ "mappings": "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",
6
+ "names": ["require_r_common", "__commonJSMin", "exports", "module", "require_r_pipes", "__commonJSMin", "exports", "module", "require_r_validation", "__commonJSMin", "exports", "module", "require_r_common", "__commonJSMin", "exports", "module", "require_r_pipes", "__commonJSMin", "exports", "module", "require_r_validation", "__commonJSMin", "exports", "module", "pluralRulesCache", "getPluralRule", "locale", "escapeRegex", "s", "defaultFormatICU", "message", "values", "_", "key", "type", "categoriesPart", "value", "exact", "category", "match", "escaped", "formatICU", "setMessageFormatter", "formatter", "LocaleChangeEvent", "locale", "fallbackLocale", "currentLocale", "loadedNamespaces", "translations", "missingHandler", "normalizeLocale", "setLocale", "normalized", "ns", "loadNamespace", "namespace", "module", "globImport_locales_json", "fallback", "loadNamespaces", "namespaces", "t", "fullKey", "values", "key", "message", "formatICU", "getCurrentLocale", "onMissingTranslation", "handler"]
7
+ }
@@ -0,0 +1,16 @@
1
+ export * from './errors';
2
+ export * from './collections/Index';
3
+ export * from './forms/FormValidator';
4
+ export * from './forms/FormReader';
5
+ export * from './forms/ValidationRules';
6
+ export * from './forms/setFormData';
7
+ export * from './html/index';
8
+ export * from './routing';
9
+ export * from "./DependencyInjection";
10
+ export * from "./getParentComponent";
11
+ export * from "./templates/NodeTemplate";
12
+ export { generateSequentialId } from './SequentialId';
13
+ export * from "./http/http";
14
+ export * from "./http/ServerSentEvents";
15
+ export * from './pipes';
16
+ export * from './tools';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ var Ke=Object.create;var M=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var rn=Object.getOwnPropertyNames;var on=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty;var Ye=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),q=n=>{throw TypeError(n)};var an=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Ge=(n,t)=>M(n,"name",{value:t,configurable:!0});var Qe=n=>t=>{var e=n[t];if(e)return e();throw new Error("Module not found in bundle: "+t)};var P=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),cn=(n,t)=>{for(var e in t)M(n,e,{get:t[e],enumerable:!0})},et=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rn(t))!sn.call(n,o)&&o!==e&&M(n,o,{get:()=>t[o],enumerable:!(r=Ze(t,o))||r.enumerable});return n};var $=(n,t,e)=>(e=n!=null?Ke(on(n)):{},et(t||!n||!n.__esModule?M(e,"default",{value:n,enumerable:!0}):e,n)),ln=n=>et(M({},"__esModule",{value:!0}),n);var X=n=>[,,,Ke(n?.[Ye("metadata")]??null)],tt=["class","method","getter","setter","accessor","field","value","get","set"],V=n=>n!==void 0&&typeof n!="function"?q("Function expected"):n,un=(n,t,e,r,o)=>({kind:tt[n],name:t,metadata:r,addInitializer:s=>e._?q("Already initialized"):o.push(V(s||null))}),pn=(n,t)=>an(t,Ye("metadata"),n[3]),K=(n,t,e,r)=>{for(var o=0,s=n[t>>1],i=s&&s.length;o<i;o++)t&1?s[o].call(e):r=s[o].call(e,r);return r},Z=(n,t,e,r,o,s)=>{var i,a,c,l,p,u=t&7,d=!!(t&8),m=!!(t&16),f=u>3?n.length+1:u?d?1:2:0,x=tt[u+5],g=u>3&&(n[f-1]=[]),b=n[f]||(n[f]=[]),h=u&&(!m&&!d&&(o=o.prototype),u<5&&(u>3||!m)&&Ze(u<4?o:{get[e](){return Je(this,s)},set[e](y){return Xe(this,s,y)}},e));u?m&&u<4&&Ge(s,(u>2?"set ":u>1?"get ":"")+e):Ge(o,e);for(var T=r.length-1;T>=0;T--)l=un(u,e,c={},n[3],b),u&&(l.static=d,l.private=m,p=l.access={has:m?y=>dn(o,y):y=>e in y},u^3&&(p.get=m?y=>(u^1?Je:mn)(y,o,u^4?s:h.get):y=>y[e]),u>2&&(p.set=m?(y,A)=>Xe(y,o,A,u^4?s:h.set):(y,A)=>y[e]=A)),a=(0,r[T])(u?u<4?m?s:h[x]:u>4?void 0:{get:h.get,set:h.set}:o,l),c._=1,u^4||a===void 0?V(a)&&(u>4?g.unshift(a):u?m?s=a:h[x]=a:o=a):typeof a!="object"||a===null?q("Object expected"):(V(i=a.get)&&(h.get=i),V(i=a.set)&&(h.set=i),V(i=a.init)&&g.unshift(i));return u||pn(n,o),h&&M(o,e,h),m?u^4?s:h:o};var Te=(n,t,e)=>t.has(n)||q("Cannot "+e),dn=(n,t)=>Object(t)!==t?q('Cannot use the "in" operator on this value'):n.has(t),Je=(n,t,e)=>(Te(n,t,"read from private field"),e?e.call(n):t.get(n));var Xe=(n,t,e,r)=>(Te(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),mn=(n,t,e)=>(Te(n,t,"access private method"),e);var ot=P((Cr,vn)=>{vn.exports={greeting:"Hello, {name}!",items:"{count, plural, one {# item} other {# items}}"}});var st=P((Nr,En)=>{En.exports={today:"today",yesterday:"yesterday",daysAgo:"{count, plural, one {# day ago} other {# days ago}}",pieces:"{count, plural, =0 {none} one {one} other {# pcs}}"}});var it=P((Sr,xn)=>{xn.exports={required:"This field is required.",range:"Number must be between {min} and {max}, was {actual}.",digits:"Please enter only digits."}});var at=P((Mr,Tn)=>{Tn.exports={greeting:"Hej, {name}!",items:"{count, plural, one {# sak} other {# saker}}"}});var ct=P((kr,bn)=>{bn.exports={today:"idag",yesterday:"ig\xE5r",daysAgo:"{count, plural, one {# dag sedan} other {# dagar sedan}}",pieces:"{count, plural, =0 {inga} one {en} other {# st}}"}});var lt=P((Lr,wn)=>{wn.exports={required:"Detta f\xE4lt \xE4r obligatoriskt.",range:"Talet m\xE5ste vara mellan {min} och {max}, var {actual}.",digits:"Ange endast siffror."}});var yr={};cn(yr,{Blueprint:()=>ie,BooleanConverter:()=>ee,BoundNode:()=>se,ContainerService:()=>ar,DateConverter:()=>Se,DigitsValidation:()=>$e,FormValidator:()=>we,GuardResult:()=>le,HttpError:()=>We,Inject:()=>ir,LinkedList:()=>Y,NavigateRouteEvent:()=>R,Node:()=>F,NumberConverter:()=>Ne,RangeValidation:()=>Pe,RegisterValidator:()=>te,RelaxError:()=>C,RequiredValidation:()=>Ae,RouteError:()=>k,RouteGuardError:()=>L,RouteLink:()=>B,RouteTarget:()=>O,SSEClient:()=>ze,SSEDataEvent:()=>xe,ServiceCollection:()=>he,ServiceContainer:()=>ye,SortChangeEvent:()=>W,TableRenderer:()=>ae,TableSorter:()=>ce,applyPipes:()=>Fe,capitalizePipe:()=>Rt,clearPendingNavigations:()=>Gt,compileTemplate:()=>Vt,configure:()=>pr,container:()=>Qt,createBluePrint:()=>Qn,createConverterFromDataType:()=>dt,createConverterFromInputType:()=>mt,createPipeRegistry:()=>It,currencyPipe:()=>Nt,datePipe:()=>St,daysAgoPipe:()=>Mt,defaultPipe:()=>Ft,defaultPipes:()=>N,defineRoutes:()=>Xt,del:()=>gr,findRouteByName:()=>qe,findRouteByUrl:()=>Ue,firstPipe:()=>At,generateSequentialId:()=>tn,get:()=>dr,getDataConverter:()=>pt,getParentComponent:()=>cr,getValidator:()=>Ln,html:()=>Dt,internalRoutes:()=>_,joinPipe:()=>Lt,keysPipe:()=>$t,lastPipe:()=>Pt,lowercasePipe:()=>wt,mapFormToClass:()=>Nn,matchRoute:()=>me,navigate:()=>G,onError:()=>fn,piecesPipe:()=>kt,post:()=>mr,printRoutes:()=>fe,put:()=>fr,readData:()=>Sn,registerRouteTarget:()=>pe,reportError:()=>v,request:()=>J,resolveValue:()=>hr,serviceCollection:()=>ve,setFetch:()=>ur,setFormData:()=>An,shortenPipe:()=>Ct,startRouting:()=>Kt,ternaryPipe:()=>Ht,trimPipe:()=>bt,unregisterRouteTarget:()=>de,uppercasePipe:()=>Tt});module.exports=ln(yr);var C=class extends Error{constructor(e,r){super(e);this.context=r}},be=null;function fn(n){be=n}function v(n,t){let e=new C(n,t);if(be){let r=!1;if(be(e,{suppress(){r=!0}}),r)return null}return e}var F=class{constructor(t,e){this.value=t;this.removeCallback=e;this.next=null;this.prev=null}remove(){this.prev.next=this.next,this.next.prev=this.prev,this.removeCallback()}},Y=class{constructor(){this._length=0}addFirst(t){let e=new F(t,()=>this._length--);this._first?(e.next=this._first,this._first.prev=e,this._first=e):(this._first=e,this._last=this._first),this._length++}addLast(t){let e=new F(t,()=>this._length--);this._first?(e.prev=this._last,this._last.next=e,this._last=e):(this._first=e,this._last=this._first),this._length++}removeFirst(){if(!this.first)throw new Error("The list is empty.");let t=this._first.value;return this._first=this._first.next,this._length--,t}removeLast(){if(!this.last)throw new Error("The list is empty.");let t=this._last.value;return this._last=this._last.prev,this._length--,t}get length(){return this._length}get first(){return this._first}get firstValue(){return this._first?.value}get last(){return this._last}get lastValue(){return this._last?.value}};function gn(n){let t=n.getAttribute("id");if(t){let e=n.closest("form");if(e){let r=e.querySelector(`label[for="${t}"]`);if(r)return r.textContent?.trim()||null}}return null}var we=class{constructor(t,e){this.form=t;this.options=e;if(!this.form)throw new Error("Form must be specified.");this.form.addEventListener("submit",r=>{(e?.preventDefault||this.options?.submitCallback!=null)&&r.preventDefault(),this.options?.customChecks&&this.options.customChecks(t),this.validateForm()?this.options?.submitCallback?.apply(this):e?.preventDefaultOnFailed!==!1&&r.preventDefault()}),e?.autoValidate&&t.addEventListener("input",()=>{this.validateForm()})}validateForm(){let t=Array.from(this.form.querySelectorAll("input,textarea,select")),e=!0;if(this.options?.useSummary!==!0)return this.form.checkValidity()?!0:(this.form.reportValidity(),this.focusFirstErrorElement(),!1);let r=[];return t.forEach(o=>{if(!o.checkValidity()){e=!1;let s=gn.call(this,o)||o.name||"Unnamed Field";r.push(`${s}: ${o.validationMessage}`)}}),e?this.clearErrorSummary():(this.displayErrorSummary(r),this.focusFirstErrorElement()),e}displayErrorSummary(t){this.clearErrorSummary(),this.errorSummary||this.createErrorSummary();let e=this.errorSummary.querySelector("ul");t.forEach(r=>{let o=document.createElement("li");o.textContent=r,e.appendChild(o)})}createErrorSummary(){let t=document.createElement("div");t.className="error-summary",t.style.color="red",t.setAttribute("role","alert"),t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),this.errorSummary=t;let e=document.createElement("ul");this.errorSummary.appendChild(e),this.form.prepend(t)}addErrorToSummary(t,e){this.errorSummary||this.createErrorSummary();let r=this.errorSummary.querySelector("ul"),o=document.createElement("li");o.textContent=`${t}: ${e}`,r.appendChild(o)}clearErrorSummary(){this.errorSummary&&(this.errorSummary.querySelector("ul").innerHTML="")}focusFirstErrorElement(){let t=this.form.querySelector(":invalid");t instanceof HTMLElement&&document.activeElement!==t&&t.focus()}static FindForm(t){if(t.parentElement?.tagName=="FORM")return t.parentElement;for(let e=0;e<t.children.length;e++){let r=t.children[e];if(r.tagName=="FORM")return r}throw new Error("Parent or a direct child must be a FORM for class "+t.constructor.name)}};var Re=new Map;function hn(n){return Re.has(n)||Re.set(n,new Intl.PluralRules(n)),Re.get(n)}function nt(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yn(n,t,e="en"){return n.replace(/\{(\w+)(?:, (plural|select),((?:[^{}]*\{[^{}]*\})+))?\}/g,(r,o,s,i)=>{let a=t[o];if(s==="plural"){let c=new RegExp(`=${nt(String(a))}\\s*\\{([^{}]*)\\}`).exec(i);if(c)return c[1].replace(`{${o}}`,String(a)).replace("#",String(a));let p=hn(e).select(a),u=new RegExp(`${p}\\s*\\{([^{}]*)\\}`).exec(i)||new RegExp("other\\s*\\{([^{}]*)\\}").exec(i);return u?u[1].replace(`{${o}}`,String(a)).replace("#",String(a)):String(a)}if(s==="select"){let c=nt(String(a)),l=new RegExp(`\\b${c}\\s*\\{([^{}]*)\\}`).exec(i)||new RegExp("\\bother\\s*\\{([^{}]*)\\}").exec(i);return l?l[1]:String(a)}return a!==void 0?String(a):`{${o}}`})}var rt=yn;var $r=Qe({"./locales/en/r-common.json":()=>Promise.resolve().then(()=>$(ot())),"./locales/en/r-pipes.json":()=>Promise.resolve().then(()=>$(st())),"./locales/en/r-validation.json":()=>Promise.resolve().then(()=>$(it())),"./locales/sv/r-common.json":()=>Promise.resolve().then(()=>$(at())),"./locales/sv/r-pipes.json":()=>Promise.resolve().then(()=>$(ct())),"./locales/sv/r-validation.json":()=>Promise.resolve().then(()=>$(lt()))});var Rn="en",Ce=Rn;var Cn={},ut=null;function w(n,t){let[e,r]=n.includes(":")?n.split(":"):["r-common",n],o=Cn[e]?.[r];if(!o)return ut&&ut(r,e,Ce),n;try{return rt(o,t,Ce)}catch{return n}}function U(){return Ce}function Nn(n,t,e={}){let r=n.querySelectorAll("input, select, textarea");if(r.forEach(o=>{if(!o.hasAttribute("name")||Q(o,"disabled"))return;let s=o.getAttribute("name");if(!(s in t)){if(e.throwOnMissingProperty)throw new Error(`Form field "${s}" has no matching property in class instance`);return}let i=kn(o);i!==ft&&(t[s]=i)}),e.throwOnMissingField){let o=new Set;r.forEach(s=>{s.hasAttribute("name")&&o.add(s.getAttribute("name"))});for(let s in t)if(typeof t[s]!="function"&&Object.prototype.hasOwnProperty.call(t,s)&&!o.has(s))throw new Error(`Class property "${s}" has no matching form field`)}return t}function pt(n){let t=n.getAttribute("data-type");return t?dt(t):n instanceof HTMLInputElement?mt(n.type):"checked"in n&&typeof n.checked=="boolean"?ee:e=>e}function Sn(n){let t={},e=new FormData(n),r=new Set;e.forEach((o,s)=>{if(r.has(s))return;r.add(s);let i=e.getAll(s),a=n.elements.namedItem(s),c=a?pt(a):l=>l;if(i.length===1){let l=i[0];t[s]=typeof l=="string"?c(l):l}else t[s]=i.map(l=>typeof l=="string"?c(l):l)});for(let o=0;o<n.elements.length;o++){let s=n.elements[o];s.type==="checkbox"&&s.name&&!r.has(s.name)&&(r.add(s.name),t[s.name]=!1)}return t}function ee(n){if(!n||n=="")return;let t=n.toLowerCase();if(t==="true"||t==="on"||Number(n)>0)return!0;if(t==="false"||t==="off"||Number(n)<=0)return!1;throw new Error("Could not convert value '"+n+"' to boolean.")}function Ne(n){if(!n||n=="")return;let t=Number(n);if(!isNaN(t))return t;throw new Error("Could not convert value '"+n+"' to number.")}function Mn(n){return new Intl.DateTimeFormat(n).formatToParts(new Date(2024,0,15)).filter(e=>e.type==="day"||e.type==="month"||e.type==="year").map(e=>e.type)}function Se(n){if(!n||n==="")return;if(/^\d{4}-\d{2}-\d{2}(T|$)/.test(n)){let r=new Date(n);if(!isNaN(r.getTime()))return r}let t=n.split(/[\/.\-\s]/);if(t.length>=3&&t.every(r=>/^\d+$/.test(r))){let r=U(),o=Mn(r),s={};if(o.forEach((i,a)=>{s[i]=parseInt(t[a],10)}),s.year!==void 0&&s.month!==void 0&&s.day!==void 0){s.year<100&&(s.year+=2e3);let i=new Date(s.year,s.month-1,s.day);if(!isNaN(i.getTime()))return i}}let e=new Date(n);if(isNaN(e.getTime()))throw new Error("Invalid date format");return e}function dt(n){switch(n){case"boolean":return ee;case"number":return Ne;case"Date":return Se;case"string":return t=>!t||t==""?void 0:t;default:throw new Error(`Unknown data-type "${n}".`)}}function mt(n){switch(n){case"checkbox":return ee;case"number":return Ne;case"date":case"datetime-local":return Se;case"month":return t=>{let[e,r]=t.split("-").map(Number);return new Date(e,r-1)};case"week":return t=>{let[e,r]=t.split("-W").map(Number);return{year:e,week:r}};case"time":return t=>{let[e,r,o=0]=t.split(":").map(Number);return{hours:e,minutes:r,seconds:o}};default:return t=>!t||t==""?void 0:t}}function Q(n,t){let e=n;if(t in e&&typeof e[t]=="boolean")return e[t];let r=n.getAttribute(t);return r===null?!1:r===""||r.toLowerCase()==="true"||r.toLowerCase()===t}var ft=Symbol("skip");function kn(n){let t=n,e=t.type||n.getAttribute("type")||"";if(e==="checkbox")return Q(n,"checked");if(e==="radio")return Q(n,"checked")?t.value:ft;if(e==="number")return t.value?Number(t.value):null;if(e==="date")return t.value?new Date(t.value):null;if("selectedOptions"in t&&Q(n,"multiple"))return Array.from(t.selectedOptions).map(r=>r.value);if("value"in t)return t.value}var vt=new Map;function te(n,t=[]){return function(e){vt.set(n,{validator:e,validInputTypes:t})}}function Ln(n){return vt.get(n)}var gt,Me;gt=[te("required")];var H=class H{static create(t){return t==="required"?new H:null}validate(t,e){t.trim()===""&&e.addError(this.getMessage())}getMessage(){return w("r-validation:required")}};Me=X(null),H=Z(Me,0,"RequiredValidation",gt,H),K(Me,1,H);var Ae=H,ht,ke;ht=[te("range",["number"])];var I=class I{constructor(t,e){this.min=void 0;this.max=void 0;this.min=t,this.max=e}static create(t){let e=t.match(/^range\((-?\d+(?:\.\d+)?)-(-?\d+(?:\.\d+)?)\)$/);if(e){let[,r,o]=e;return new I(parseFloat(r),parseFloat(o))}return null}validate(t,e){if(t.trim()==="")return;let r=parseFloat(t);!isNaN(r)&&r>=this.min&&r<=this.max||e.addError(this.getMessage(t))}getMessage(t){return w("r-validation:range",{min:this.min,max:this.max,actual:t})}};ke=X(null),I=Z(ke,0,"RangeValidation",ht,I),K(ke,1,I);var Pe=I,yt,Le;yt=[te("digits",["number"])];var D=class D{static create(t){return t==="digits"?new D:null}validate(t,e){/^\d+$/.test(t)||e.addError(this.getMessage())}getMessage(){return w("r-validation:digits")}};Le=X(null),D=Z(Le,0,"DigitsValidation",yt,D),K(Le,1,D);var $e=D;function An(n,t){n.querySelectorAll("[name]").forEach(r=>{let o=r.getAttribute("name");if(!o)return;if(o.endsWith("[]")){let i=o.slice(0,-2),a=Et(t,i);if(Array.isArray(a)){let c=r,l=c.type||r.getAttribute("type")||"";if(l==="checkbox"||l==="radio")c.checked=a.includes(c.value);else if("options"in c&&xt(r,"multiple"))a.forEach(p=>{let u=Array.from(c.options).find(d=>d.value===String(p));u&&(u.selected=!0)});else if("value"in c){let p=n.querySelectorAll(`[name="${o}"]`),u=Array.from(p).indexOf(r);u>=0&&u<a.length&&(c.value=String(a[u]))}}return}let s=Et(t,o);s!=null&&Pn(r,s)})}function Et(n,t){let e=[],r="",o=!1;for(let s=0;s<t.length;s++){let i=t[s];i==="["&&!o?(r&&(e.push(r),r=""),o=!0,r+=i):i==="]"&&o?(r+=i,e.push(r),r="",o=!1):i==="."&&!o?r&&(e.push(r),r=""):r+=i}return r&&e.push(r),e.reduce((s,i)=>{if(!(!s||typeof s!="object")){if(i.startsWith("[")&&i.endsWith("]")){let a=i.slice(1,-1);return s[a]}return s[i]}},n)}function Pn(n,t){let e=n,r=e.type||n.getAttribute("type")||"";if(r==="checkbox")e.checked=!!t;else if(r==="radio")e.checked=e.value===String(t);else if(r==="date"&&t instanceof Date)e.value=t.toISOString().split("T")[0];else if(r==="datetime-local"&&t instanceof Date){let o=s=>String(s).padStart(2,"0");e.value=`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}T${o(t.getHours())}:${o(t.getMinutes())}`}else if("options"in e&&xt(n,"multiple")&&Array.isArray(t)){let o=Array.from(e.options),s=t.map(String);o.forEach(i=>{i.selected=s.includes(i.value)})}else"value"in e&&(e.value=String(t))}function xt(n,t){let e=n;if(t in e&&typeof e[t]=="boolean")return e[t];let r=n.getAttribute(t);return r===null?!1:r===""||r.toLowerCase()==="true"||r.toLowerCase()===t}function Tt(n){return String(n).toUpperCase()}function bt(n){return String(n).trimEnd().trimStart()}function wt(n){return String(n).toLowerCase()}function Rt(n){let t=String(n);return t.charAt(0).toUpperCase()+t.slice(1)}function Ct(n,t){let e=String(n),r=parseInt(t,10);return e.length>r?e.substring(0,r-3)+"...":e}function Nt(n,t="USD"){let e=U();return new Intl.NumberFormat(e,{style:"currency",currency:t}).format(n)}function St(n,t){let e=new Date(n),r=U();return t==="short"?e.toLocaleDateString(r):t==="long"?e.toLocaleDateString(r,{weekday:"long",year:"numeric",month:"long",day:"numeric"}):e.toISOString()}function Mt(n){if(!n)return"n/a";let t=new Date(n),e=new Date;t.setHours(0,0,0,0),e.setHours(0,0,0,0);let r=e.getTime()-t.getTime(),o=Math.round(r/(1e3*60*60*24));return o===0?w("r-pipes:today"):o===1?w("r-pipes:yesterday"):w("r-pipes:daysAgo",{count:o})}function kt(n){if(n==null)return"n/a";let t=Number(n);return w("r-pipes:pieces",{count:t})}function Lt(n,t=","){return Array.isArray(n)?n.join(t):n}function At(n){return!Array.isArray(n)||n.length===0?"":n[0]}function Pt(n){return!Array.isArray(n)||n.length===0?"":n[n.length-1]}function $t(n){return typeof n!="object"||n===null?[]:Object.keys(n)}function Ft(n,t){return n||t}function Ht(n,t,e){return n?t:e}function It(){let n=new Map;return n.set("uppercase",Tt),n.set("lowercase",wt),n.set("capitalize",Rt),n.set("trim",bt),n.set("shorten",Ct),n.set("currency",Nt),n.set("date",St),n.set("daysAgo",Mt),n.set("pieces",kt),n.set("join",Lt),n.set("first",At),n.set("last",Pt),n.set("keys",$t),n.set("default",Ft),n.set("ternary",Ht),{lookup(t){return n.get(t)},get(t){var e=n.get(t);if(!e)throw Error("Pipe '"+t+"' not found.");return e},has(t){return n.has(t)}}}var N=It();function Fe(n,t,e=N){return t.reduce((r,o)=>{let[s,...i]=o.split(":").map(a=>a.trim());if(!e.has(s))return`[Pipe ${s} not found]`;try{return e.get(s)(r,...i)}catch(a){return`[Pipe ${s}, value: ${n}, error: ${a}]`}},n)}var $n=N;function Dt(n,...t){let e=document.createElement("template"),r=Fn(n);e.innerHTML=r;let o=[],s=document.createTreeWalker(e.content,NodeFilter.SHOW_ALL),i;for(;i=s.nextNode();)if(i.nodeType===Node.ELEMENT_NODE){let a=i;Hn(a,t,o),customElements.get(a.tagName.toLowerCase())&&customElements.upgrade(a)}else if(i.nodeType===Node.TEXT_NODE){let a=i,c=a.textContent,l=Bt(c,t);if(l)if(/€€\d+€€/.test(c)){let u=null,d=null,m=[];o.push({originalValue:c,setter(f){var x=l(f);u||(u=document.createComment(""),d=document.createComment(""),a.parentNode?.replaceChild(d,a),d.parentNode?.insertBefore(u,d)),m.forEach(T=>T.parentNode?.removeChild(T)),m=[];let g=document.createElement("template");g.innerHTML=x;let b=Array.from(g.content.childNodes),h=d.parentNode;b.forEach(T=>{h.insertBefore(T,d),m.push(T)})}})}else o.push({originalValue:c,setter(u){var d=l(u);a.textContent=d}})}return function(c){return o.forEach(l=>{l.setter(c)}),{fragment:e.content,update(l){o.forEach(p=>{p.setter(l)})}}}}function Fn(n){return n.raw.map((t,e)=>e<n.raw.length-1?`${t}\u20AC\u20AC${e}\u20AC\u20AC`:t).join("")}function Hn(n,t,e){let r=[];for(let i of Array.from(n.attributes)){var o=i.value;if(o=="")continue;let a=/€€(\d+)€€/,c=o.match(a);if(c){let l=parseInt(c[1],10),p=t[l];if(typeof p=="function"){r.push({setter(u){let d=p.bind(u);n.removeAttribute(i.name),n[i.name]=d}});continue}}var s=Bt(o,t);s!=null&&r.push({originalValue:o,setter(l){let p=s(l)??o;i.name in n?n[i.name]=p:i.value=p}})}r.length>0&&e.push({originalValue:n.tagName,setter(i){r.forEach(a=>a.setter(i))}})}function In(n,t){return n.split(",").map(e=>{if(e=e.trim(),e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(!isNaN(Number(e)))return Number(e);if(e.includes(".")){let r=e.split("."),o=t;for(let s of r){if(o==null)return;o=o[s]}return o}return t[e]})}function Bt(n,t){let e=/€€(\d+)€€|{{\s*([^|]+?)(?:\|([\w|]+))?\s*}}/g,r=0,o,s=[];for(;(o=e.exec(n))!==null;){var i=n.slice(r,o.index);if(i.length>0&&s.push(c=>i),o[1]){let c=parseInt(o[1],10),l=t[c];if(!l)continue;if(typeof l=="function"){let p=l;s.push(u=>{var d=p.apply(u);return d})}else l&&l.length>0&&s.push(p=>l)}else if(o[2]){let c=o[2].trim(),l=o[3]?o[3].trim():null,p=o[4]?o[4].split("|").map(u=>u.trim()):[];s.push(u=>{var d=u[c];if(typeof d=="function")if(l){let m=In(l,u);d=d.apply(u,m)}else d=d.call(u);return p.forEach(m=>{d=$n[m](d)}),d})}r=e.lastIndex}if(s.length==0)return null;var a=n.slice(r);return a.length>0&&s.push(c=>a),c=>{var l="";return s.forEach(p=>{var u=p(c);l+=u}),l}}function Ot(n){let t=n.split("|").map(s=>s.trim()),e=t[0],r=t.slice(1),o=e.match(/^(\w+)\s*\((.*)\)$/);if(o){let[,s,i]=o,a=i?i.split(",").map(c=>c.trim()):[];return{type:"function",fnName:s,fnArgs:a,pipes:r}}return{type:"path",path:e,pipes:r}}function ne(n,t){let r=t.replace(/\[(\d+)\]/g,".$1").split("."),o=n;for(let s of r)if(o&&typeof o=="object"&&s in o)o=o[s];else return;return o}function S(n,t,e,r=!1){let o=`[template error] ${t} (at ${e})`;if(n.onError&&n.onError(o),n.strict||r)throw new Error(o)}function Dn(n){return function(e,r,o=""){try{let s=ne(e,r);return s===void 0?(S(n,`Cannot resolve "${r}"`,o),""):s===null?"":Array.isArray(s)?s.length>0?JSON.stringify(s):"":typeof s=="object"?JSON.stringify(s):s}catch(s){let i=s instanceof Error?s.message:String(s);return S(n,`Exception resolving "${r}": ${i}`,o,!0),""}}}function jt(n,t,e,r,o){let s,i=r.pipeRegistry??N;if(n.type==="function"){let a=e?.[n.fnName];if(typeof a!="function")return S(r,`Function "${n.fnName}" not found`,o),"";let c=(n.fnArgs??[]).map(l=>l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'")?l.slice(1,-1):isNaN(Number(l))?ne(t,l):Number(l));try{s=a(...c)}catch(l){let p=l instanceof Error?l.message:String(l);return S(r,`Error calling "${n.fnName}": ${p}`,o),""}}else{let a=ne(t,n.path);if(a===void 0)return S(r,`Cannot resolve "${n.path}"`,o),"";a===null?s="":typeof a=="object"?s=JSON.stringify(a):s=a}return n.pipes.length>0&&(s=Fe(s,n.pipes,i)),s}var He=new Map;function Bn(n,t,e){if(n.nodeType!==Node.TEXT_NODE||!n.textContent?.includes("{{"))return;let r=n.textContent;if(!He.has(r)){let a=r.split(/(\{\{.*?\}\})/).map(c=>{if(c.startsWith("{{")){let l=c.slice(2,-2).trim();return{parsed:Ot(l),literal:""}}else return{parsed:null,literal:c}});He.set(r,a)}let o=He.get(r),s=`TextNode: "${r}"`;return(i,a)=>{let c=o.map(({parsed:l,literal:p})=>l?String(jt(l,i,a,e,s)):p).join("");n.textContent=c}}function On(n,t,e){if(n.nodeType!==Node.ELEMENT_NODE)return;let r=n,o=[],s=Array.from(r.attributes);for(let i of s){let a=i.value.match(/\{\{(.+?)\}\}/);if(a){let c=a[1].trim(),l=Ot(c),p=i.name,u=`Attribute: ${p} on <${r.tagName.toLowerCase()}>`;o.push((d,m)=>{let f=jt(l,d,m,e,u);r.setAttribute(p,String(f))})}}if(o.length>0)return(i,a)=>o.forEach(c=>c(i,a))}function _t(n,t,e,r,o){if(n.nodeType!==Node.ELEMENT_NODE||!n.hasAttribute(r))return;let s=n,i=s.getAttribute(r),a=s.cloneNode(!0),c=document.createComment(`${r}: ${i}`),l=s.parentNode;l.insertBefore(c,s),s.remove();let p=null,u=null,d=null,m=null;return(f,x)=>{let g=t(f,i,`${r}="${i}"`),b=o(g);if(b&&!p){if(d&&m)p=d,u=m,d=null,m=null;else{let h=a.cloneNode(!0);h.removeAttribute(r),p=h,u=Ie(h,e)}u(f,x),l.insertBefore(p,c.nextSibling)}else b&&u&&u(f,x);!b&&p&&(p.remove(),d=p,m=u,p=null,u=null)}}function jn(n,t,e){return _t(n,t,e,"if",r=>!!r)}function _n(n,t,e){return _t(n,t,e,"unless",r=>!r)}function Vn(n,t,e){if(n.nodeType!==Node.ELEMENT_NODE||!n.hasAttribute("loop"))return;let r=n,o=r.getAttribute("loop"),s=o.match(/(\w+)\s+in\s+(.+)/);if(!s){S(e,`Invalid loop syntax: "${o}"`,`Element: <${r.tagName.toLowerCase()}>`);return}let[,i,a]=s,c=r.cloneNode(!0);c.removeAttribute("loop");let l=r.parentNode,p=document.createComment(`loop: ${o}`);l.insertBefore(p,r),r.remove();let u=[];return(d,m)=>{let f=ne(d,a);if(f===void 0){S(e,`Cannot resolve "${a}"`,`Loop source: "${o}"`);return}if(!Array.isArray(f)){S(e,`"${a}" is not an array in loop: "${o}"`,`Element: <${c.tagName.toLowerCase()}>`);return}let x=Math.min(u.length,f.length);for(let g=0;g<x;g++)u[g].renderer({...d,[i]:f[g]},m);for(let g=u.length-1;g>=f.length;g--)u[g].element.remove();if(f.length>x){let g=document.createDocumentFragment(),b=[];for(let T=x;T<f.length;T++){let y=c.cloneNode(!0),A=Ie(y,e);A({...d,[i]:f[T]},m),g.appendChild(y),b.push({element:y,renderer:A})}let h=x>0?u[x-1].element:p;l.insertBefore(g,h.nextSibling),u=u.slice(0,x).concat(b)}else u.length=f.length}}var qn=[Vn,jn,_n],Un=[Bn,On];function Ie(n,t){let e=[],r=Dn(t);function o(a){for(let c of qn){let l=c(a,r,t);if(l){e.push(l);return}}for(let c of Un){let l=c(a,r,t);l&&e.push(l)}for(let c of Array.from(a.childNodes))o(c)}o(n);let s=null,i;return(a,c)=>{(s!==a||i!==c)&&(e.forEach(l=>l(a,c)),s=a,i=c)}}function Vt(n,t={strict:!1}){let o=new DOMParser().parseFromString(`<template><div>${n}</div></template>`,"text/html").querySelector("template").content.firstElementChild,s=Ie(o,t);return{content:o,render:s}}function Wn(n,t={}){let{delimiter:e=".",escapeChar:r="\\"}=t;if(!n||typeof n!="string")throw new Error("Notation must be a non-empty string");let o=[],s="",i=0,a=!1,c="";for(;i<n.length;){let l=n[i],p=n.substring(i,e.length+i),u=n[i+1],d=n.substring(i+1,e.length+i+1);if(l===r&&(d===e||u==="["||u==="]"))a?c+=u:s+=u,i+=2;else if(l==="["&&!a)s&&(o.push({type:"property",key:s}),s=""),a=!0,c="",i++;else if(l==="]"&&a){if(!/^\d+$/.test(c.trim()))throw new Error(`Invalid array index: [${c}]. Only numeric indices are supported.`);o.push({type:"index",key:c.trim()}),a=!1,c="",i++}else p===e&&!a?(s&&(o.push({type:"property",key:s}),s=""),i+=e.length):a?(c+=l,i++):(s+=l,i++)}if(a)throw new Error("Unclosed bracket in notation");if(s&&o.push({type:"property",key:s}),o.length===0)throw new Error("Invalid notation: must contain at least one property or index");return o}function zn(n){return t=>{let e=t;for(let r of n){if(e==null)return;if(r.type==="property"){if(typeof e!="object")return;e=e[r.key]}else if(r.type==="index"){if(!Array.isArray(e))return;let o=parseInt(r.key,10);if(o<0||o>=e.length)return;e=e[o]}}return e}}function re(n,t={}){let e=Wn(n,t);return zn(e)}function Ut(n){let t=[],e=0;for(;e<n.length;){let r=n[e];if(/\s/.test(r)){e++;continue}if(r==="|"){for(e++;e<n.length&&/\s/.test(n[e]);)e++;let o="";for(;e<n.length&&!/[\s\(\)\[\]\{\}\|\+\-\*\/\=\;\,\.]/.test(n[e]);)o+=n[e],e++;t.push({type:3,value:o});continue}if(r==='"'||r==="'"){let o=r,s=o;for(e++;e<n.length&&n[e]!==o;)n[e]==="\\"&&e+1<n.length&&n[e+1]===o?(s+="\\"+o,e+=2):(s+=n[e],e++);e<n.length&&(s+=o,e++),t.push({type:0,value:s});continue}if(/[0-9]/.test(r)){let o="",s=!1;for(;e<n.length&&(/[0-9]/.test(n[e])||n[e]==="."&&!s);)n[e]==="."&&(s=!0),o+=n[e],e++;t.push({type:0,value:o});continue}if(/[a-zA-Z_$]/.test(r)){let o="",s=!1;for(;e<n.length;)if(/[a-zA-Z0-9_$.]/.test(n[e]))o+=n[e],e++;else if(n[e]==="["){let l=1;for(o+=n[e++];e<n.length&&l>0;)n[e]==="["&&l++,n[e]==="]"&&l--,o+=n[e++]}else break;let i=0;for(;e<n.length&&/\s/.test(n[e]);)i++,e++;if(e<n.length&&n[e]==="("){s=!0,o+="(",e++;let l=1;for(;e<n.length&&l>0;)n[e]==="("&&l++,n[e]===")"&&l--,o+=n[e++]}else e-=i;let a=t[t.length-1],c=n[e-o.length-1]==="."&&a?.type===0;t.push({type:s||c?1:2,value:o});continue}e++}return t}function oe(n){let t=[],e=n.indexOf("("),r=n.lastIndexOf(")");if(e===-1||r===-1||r<=e)throw new Error("Invalid function call syntax");let o=n.slice(e+1,r),s=0;for(;s<o.length;){let i=o[s];if(/\s/.test(i)){s++;continue}if(i==='"'||i==="'"){let a=i,c="";for(s++;s<o.length&&o[s]!==a;)o[s]==="\\"?(s++,s<o.length&&(c+=o[s])):c+=o[s],s++;if(s>=o.length)throw new Error("Unterminated string in arguments");s++,t.push({type:"string",value:c});continue}if(/[0-9]/.test(i)){let a="";for(;s<o.length&&/[0-9.]/.test(o[s]);)a+=o[s],s++;t.push({type:"number",value:parseFloat(a)});continue}if(/[a-zA-Z_]/.test(i)){let a="";for(;s<o.length&&/[a-zA-Z0-9_\.]/.test(o[s]);)a+=o[s],s++;t.push({type:"identifier",value:a});continue}if(i===","){s++;continue}throw new Error(`Unexpected character in arguments: ${i}`)}return t}function Wt(n){let t=[],e=0;for(;e<n.length;){let r=n.indexOf("{{",e);if(r===-1){t.push(qt(n.slice(e)));break}r>e&&t.push(qt(n.slice(e,r)));let{value:o,endIndex:s,balanced:i}=Jn(n,r);if(!i)throw new Error(`Unclosed mustache tag starting at index ${r}, template: ${n}`);t.push(Gn(o)),e=s}return t}function qt(n){return{type:"string",value:n}}function Gn(n){return{type:"mustache",value:n}}function Jn(n,t){let e="{{",r="}}",o=t+e.length,s=1;for(;o<n.length&&s>0;)n.slice(o,o+e.length)===e?(s++,o+=e.length):n.slice(o,o+r.length)===r?(s--,o+=r.length):o++;let i=s===0,a=i?o:n.length;return{value:n.slice(t,a),endIndex:a,balanced:i}}function De(n,t){let e=Wt(n).map(r=>r.type==="string"?(o,s)=>r.value:Xn(r,t));return(r,o)=>e.map(s=>s(r,o)).join("")}function Xn(n,t){let e=Ut(n.value),r=Kn(e,n.value,t?.pipeRegistry);return Zn(r)}function Kn(n,t,e){let r=null;e||(e=N);for(let o of n)switch(o.type){case 0:throw Error(`Constants not supported: ${o.value}`);case 2:{r={source:re(o.value),pipes:[]};break}case 1:{r={source:Yn(o.value),pipes:[]};break}case 3:{if(!r)throw Error(`Pipe '${o.value}' has no input expression in: ${t}`);if(!o.value||o.value==="")throw Error("Pipe symbol was provided, but no pipes. Template: "+t);let[s,...i]=o.value.split(":").map(c=>c.trim()),a=e.lookup(s);if(!a)throw Error(`Pipe not found: ${s}`);r.pipes.push(c=>a(c,i));break}}if(!r)throw Error(`Invalid expression: ${t}`);return r}function Zn(n){return(t,e)=>{let r=n.source(t,e),o=n.pipes.reduce((s,i)=>i(s),r);return o!=null?o.toString():""}}function Yn(n){let t=n.indexOf("(");if(t===-1)throw Error(`Invalid function: ${n}`);let r=oe(n).map(i=>{if(i.type==="number"||i.type==="string")return()=>i.value;if(i.type==="identifier")return a=>re(i.value)(a);throw Error(`Unsupported argument type: ${i.type}`)}),o=n.substring(0,t),s=re(o);return(i,a)=>{if(!a)throw Error(`Component context is required for calling '${o}'`);let c=s(a);if(typeof c!="function")throw Error(`Resolved '${o}' is not a function`);let l=r.map(p=>p(i));return c.apply(a,l)}}var se=class{constructor(t,e,r,o){this.root=t;this.bindings=e;this.clickBindings=r;this.component=o}render(t){for(let e of this.bindings)e.type==="text"?e.func(t,e.node):e.func(t,e.element);for(let e of this.clickBindings){let r=this.getNodeAtPath(this.root,e.path),o=this.component?.[e.methodName];r instanceof HTMLElement&&typeof o=="function"&&(r.onclick=s=>{let i=e.argTokens.map(a=>{if(a.type==="number"||a.type==="string")return a.value;if(a.type==="identifier")return a.value==="event"?s:a.value.split(".").reduce((l,p)=>l?.[p],t)});o.apply(this.component,i)})}return this.root}getNodeAtPath(t,e){return e.reduce((r,o)=>r.childNodes[o],t)}};function Qn(n){var t=new ie(n);return t}var ie=class{constructor(t){if(typeof t=="string"){let r=t.trim();if(r.startsWith("<template")){let o=document.createElement("div");o.innerHTML=r;let s=o.querySelector("template");if(!s)throw new Error("Could not find <template> in input string");this.template=s}else this.template=document.createElement("template"),this.template.innerHTML=r}else this.template=t;let e=this.getRootElement();this.bindings=this.collectBindings(e),this.clickBindings=this.collectClickBindings(e)}createInstance(t){let e=this.getRootElement().cloneNode(!0),r=this.bindings.map(o=>{let s=this.getNodeAtPath(e,o.path);return o.type==="text"?{type:"text",node:s,func:(i,a)=>o.func(i,t,a)}:{type:"attribute",element:s,name:o.name,func:(i,a)=>o.func(i,t,a)}});return new se(e,r,this.clickBindings,t)}getRootElement(){let t=Array.from(this.template.content.childNodes).find(e=>e.nodeType===Node.ELEMENT_NODE);if(!(t instanceof HTMLElement))throw new Error("Template must contain a single root element");return t}collectBindings(t){let e=[],r=(o,s=[])=>{if(o.nodeType===Node.TEXT_NODE&&o.textContent&&o.textContent.match(/\{\{\s*(.*?)\s*\}\}/g)){let i=De(o.textContent);e.push({type:"text",path:[...s],func:(a,c,l)=>{l.textContent=i(a,c)}})}if(o.nodeType===Node.ELEMENT_NODE){let i=o;if(i.tagName==="TEMPLATE")return;for(let a=0;a<i.attributes.length;a++){let c=i.attributes[a];if(c.value.match(/\{\{\s*(.*?)\s*\}\}/g)){let l=De(c.value);e.push({type:"attribute",path:[...s],name:c.name,func:(p,u,d)=>{d.setAttribute(c.name,l(p,u))}})}}Array.from(o.childNodes).forEach((a,c)=>{r(a,[...s,c])})}};return r(t),e}collectClickBindings(t){let e=[],r=(o,s=[])=>{if(o.nodeType===Node.ELEMENT_NODE){let a=o.getAttribute("click");if(a?.trim()){let c=a.trim(),l=c.match(/^([a-zA-Z_$][\w$]*)\s*\((.*)\)$/);if(l){let p=l[1],u=oe(c);e.push({path:[...s],methodName:p,argTokens:u})}else e.push({path:[...s],methodName:c,argTokens:[]})}Array.from(o.childNodes).forEach((c,l)=>{r(c,[...s,l])})}};return r(t),e}getNodeAtPath(t,e){return e.reduce((r,o)=>r.childNodes[o],t)}};var ae=class{constructor(t,e,r,o){this.dataMap=new Map;this.rowMap=new Map;this.table=t,this.template=e,this.IdColumn=r,this.component=o}render(t){this.clearRows();for(let e of t)this.renderRow(e)}clearRows(){this.table.tBodies[0].innerHTML="",this.dataMap.clear(),this.rowMap.clear()}renderRow(t){let e=t[this.IdColumn];if(e==null)throw new Error(`Missing IdColumn '${this.IdColumn}' in data`);let r=this.template.content.firstElementChild?.cloneNode(!0);if(!r)throw new Error("Template must have a <tr> as its first child");this.populateRow(r,t),this.attachEventHandlers(r,t),this.table.tBodies[0].appendChild(r),this.dataMap.set(e,t),this.rowMap.set(e,r)}populateRow(t,e){t.querySelectorAll("[data-field]").forEach(o=>{let s=o.dataset.field;s&&s in e&&(o.textContent=String(e[s]))})}attachEventHandlers(t,e){t.querySelectorAll("[onclick]").forEach(o=>{let s=o,i=s.getAttribute("onclick");if(!i)return;let a=i.match(/^(\w+)(\(([^)]*)\))?$/);if(!a)return;let[,c,,l]=a,p=l?l.split(",").map(u=>u.trim().replace(/^['"]|['"]$/g,"")):[];typeof this.component[c]=="function"&&(s.removeAttribute("onclick"),s.addEventListener("click",u=>{this.component[c](...p,e,u)}))})}update(t){let e=t[this.IdColumn];if(e==null)throw new Error(`Missing IdColumn '${this.IdColumn}' in update data`);let r=this.rowMap.get(e);r?(this.populateRow(r,t),this.attachEventHandlers(r,t),this.dataMap.set(e,t)):this.renderRow(t)}},W=class extends CustomEvent{constructor(t){super("sortchange",{detail:t,bubbles:!0,composed:!0})}},ce=class{constructor(t,e){this.sortColumns=[];this.table=t,this.component=e,this.setupListeners()}setupListeners(){this.table.tHead?.querySelectorAll("th[name]")?.forEach(e=>{e.addEventListener("click",()=>{let r=e.getAttribute("name");this.toggle(r),this.updateSortIndicators(),this.emit()})})}toggle(t){let e=this.sortColumns.findIndex(r=>r.column===t);e===-1?this.sortColumns.push({column:t,direction:"asc"}):this.sortColumns[e].direction==="asc"?this.sortColumns[e].direction="desc":this.sortColumns.splice(e,1)}emit(){let t=new W(this.sortColumns);this.component.dispatchEvent(t)}updateSortIndicators(){this.table.tHead?.querySelectorAll("th[name]")?.forEach(e=>{let r=e.querySelector(".sort-indicator");r&&e.removeChild(r);let o=e.getAttribute("name"),s=this.sortColumns.find(i=>i.column===o);if(s){let i=document.createElement("span");i.className="sort-indicator",i.textContent=s.direction==="asc"?"\u2191":"\u2193",i.style.float="right",i.style.marginLeft="5px",e.appendChild(i)}e.style.position||(e.style.position="relative")})}getSortColumns(){return[...this.sortColumns]}clear(){this.sortColumns=[],this.updateSortIndicators(),this.emit()}};var le=(o=>(o[o.Allow=0]="Allow",o[o.Deny=1]="Deny",o[o.Continue=2]="Continue",o[o.Stop=3]="Stop",o))(le||{}),k=class extends Error{},L=class extends k{};var R=class n extends Event{constructor(e,r,o,s,i){super(n.NAME,i);this.route=e;this.urlSegments=r;this.routeData=o;this.routeTarget=s}static{this.NAME="rlx.navigateRoute"}};var z=new Map,ue=new Map;function pe(n,t){if(Be(),z.has(n)){let r=v("Duplicate route target",{target:n??"default"});if(r)throw r;return}z.set(n,t);let e=ue.get(n);e&&(ue.delete(n),t(e))}function de(n){z.delete(n)}function Gt(){ue.clear(),z.clear()}function er(n){let t=z.get(n.routeTarget);t?t(n):ue.set(n.routeTarget,n)}var zt=!1;function Be(){zt||(zt=!0,document.addEventListener(R.NAME,n=>{er(n)}))}var Oe=class{constructor(t){this.paramName=t}isMatch(t){return!!/^\d+$/.test(t)}getValue(t){if(/^\d+$/.test(t)===!1)throw new Error(`Path is not a number, parameter name '${this.paramName}', value: '${t}'.`);return parseInt(t)}},je=class{constructor(t){this.paramName=t}isMatch(t){return!0}getValue(t){return t}},_e=class{constructor(t){this.value=t}isMatch(t){return t==this.value}getValue(t){return this.value}},Ve=class{constructor(t,e){this.route=t;this.segments=e}match(t){if(t.length!=this.segments.length)return null;let e=[];var r={};for(let o=0;o<t.length;o++){let s=t[o],i=this.segments[o];if(!i.isMatch(s))return null;if(i.paramName){let a=i.getValue(s);r[i.paramName]=a,e.push(a.toString())}else e.push(s)}return{route:this.route,params:r,urlSegments:e}}buildUrl(t){let e=[];for(let o=0;o<this.segments.length;o++){let s=this.segments[o];if(s.paramName){var r=t[s.paramName];if(!r)throw new Error(`Route "${this.route.name}" did not get value for parameter "${s.paramName} from the provided routeData: "${JSON.stringify(t)}".`);e.push(r.toString())}else e.push(s.getValue("").toString())}return{route:this.route,params:t,urlSegments:e}}parseParameters(t){let e={};return this.segments.forEach(r=>{if(r.paramName){if(!r.isMatch(o))throw new Error(`Failed to convert parameter ${r.paramName}, or missing value: ${o}, route: ${this.route.name}.`);var o=t[r.paramName];if(!o)throw new Error(`Parameter ${r.paramName} was not provided, route: ${this.route.name}.`);var s=r.getValue(o);e[r.paramName]=s}}),e}};function me(n,t,e){return t===""||t.indexOf("/")>=0?Ue(n,t||"/"):qe(n,t,e)}function qe(n,t,e){var r=n.find(i=>i.name===t);if(!r)return null;var o=Jt(r),s=o.buildUrl(e);return s}function Ue(n,t){let e=t.replace(/^\/|\/$/g,"").split("/"),r=tr(n);for(let o=0;o<r.length;o++){let i=r[o].match(e);if(i)return i}return null}function tr(n){let t=[];return n.forEach(e=>{var r=Jt(e);t.push(r)}),t}function Jt(n){var t=[];n.path.replace(/^\/|\/$/g,"").split("/").forEach(o=>{o.substring(0,1)==":"?t.push(new je(o.substring(1))):o.substring(0,1)===";"?t.push(new Oe(o.substring(1))):o.substring(0,1)==="{"||t.push(new _e(o))});var r=new Ve(n,t);return r}var B=class extends HTMLElement{static get observedAttributes(){return["name","target","params"]}constructor(){super(),this.addEventListener("click",t=>this.handleClick(t))}handleClick(t){t.preventDefault();let e=this.getAttribute("name");if(!e)return;console.log("Calling printRoutes from RouteLink in relaxjs/components"),fe();let r={};for(let a of Array.from(this.attributes))if(a.name.startsWith("param-")){let c=a.name.substring(6);r[c]=a.value}let o=this.getAttribute("params"),s;if(o)try{s=JSON.parse(o)}catch(a){let c=v("Failed to parse route params",{element:"r-link",params:o,cause:a});if(c)throw c}let i=this.getAttribute("target");s&&Object.assign(r,s);try{G(e,{params:r,target:i||void 0})}catch(a){if(a instanceof C)throw a;let c=v("Navigation failed",{element:"r-link",route:e,params:r,target:i,cause:a});if(c)throw c}}connectedCallback(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.style.cursor="pointer",this.role="link"}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}};var O=class extends HTMLElement{constructor(){super(...arguments);this.name=void 0}connectedCallback(){this.name=this.getAttribute("name")??void 0,this.hasAttribute("dialog")&&(this.dialog=document.createElement("dialog"),this.dialog.addEventListener("close",()=>{this.dialog.replaceChildren()}),this.appendChild(this.dialog)),pe(this.name,e=>this.onNavigate(e)),console.log("registered")}disconnectedCallback(){de(this.name)}onNavigate(e){console.log("got nav",e),this.loadComponent(e).catch(r=>{r instanceof C||(r=v("Route navigation failed",{route:e.route.name,routeTarget:e.routeTarget,cause:r})),r&&console.error(r)})}async loadComponent(e){let r=e.route.componentTagName??customElements.getName(e.route.component);if(!r){let s=v("Failed to find component for route",{route:e.route.name,componentTagName:e.route.componentTagName,component:e.route.component?.name,routeData:e.routeData});if(s)throw s;return}await customElements.whenDefined(r);let o=document.createElement(r);await this.applyRouteData(o,e.routeData),this.dialog?(this.dialog.replaceChildren(o),this.dialog.open||this.dialog.showModal()):document.startViewTransition?document.startViewTransition(()=>this.replaceChildren(o)):this.replaceChildren(o)}close(){this.dialog?.close()}async applyRouteData(e,r){if("loadRoute"in e){let o=r??{error:"loadRoute function without mapped route data in the routes"};await e.loadRoute(o)}r&&(e.routeData=r)}};var j=nr()??"default";function nr(){let n=window.location.pathname;return n=="/index.html"?"default":n.endsWith(".html")?n.slice(1,-5):null}var _=[];function fe(){console.log(_)}function Xt(n){console.log("defining routes1",n),Be(),customElements.get("r-route-target")||customElements.define("r-route-target",O),customElements.get("r-link")||customElements.define("r-link",B),console.log("defining routes",n),_.length=0,_.push(...n);var t=[];if(n.forEach(e=>{e.componentTagName&&!customElements.get(e.componentTagName)&&t.push(`Component with tagName '${e.componentTagName}' is not defined in customElements.`),e.component&&!customElements.getName(e.component)&&t.push(`Component '${e.component.name}' is not defined in customElements. Used in route '${JSON.stringify(e)}'.`),e.layout===""&&(console.log("should not use empty string layout.",e),e.layout=void 0)}),t.length>0)throw new Error(t.join(`
2
+ `))}function Kt(){let n=!1;if(j==""){let i=window.location.pathname.match(/\/([^\/]+)\.html$/);i&&i[1]!==""?(console.log("setting current layut",i[1]),j=i[1],n=!0):(console.log("Setting default layout name"),j="default")}if(rr())return;let t=window.location.pathname.replace(/^\/|\/$/g,"")||"/",e=Zt(t,{}),r=new URLSearchParams(window.location.search);if(r.size>0&&(e.params??={},r.forEach((s,i)=>{e.params[i]=s})),Yt(e))return;history.replaceState(e.urlSegments,"","/"+e.urlSegments.join("/"));let o=new R(e.route,e.urlSegments,e.params,e.route.target);document.dispatchEvent(o)}function G(n,t){console.log("navigating to ",n,t);let e=Zt(n,t);if(Yt(e))return;let r=t?.target??e.route.target,o=e.urlSegments.join("/");window.location.pathname.replace(/^\/|\/$/g,"")!=o&&history.pushState(e.urlSegments,"","/"+e.urlSegments.join("/"));let i=new R(e.route,e.urlSegments,e.params,r);document.dispatchEvent(i)}function Zt(n,t){let e=t?.routes??_,r=t?.params,o=me(e,n,r);if(!o){let s=or(n,r,e);throw console.error(s),new k(s)}if(!sr(o))throw new L("Route guards stopped navigation for route "+n);return o}function Yt(n){n||console.error("Route result is null, cannot navigate to layout.");let t=(n.route.layout??"default").replace(/\.html?$/,"");if(t===j)return!1;if(console.log("Current layout: "+j,"Wanted layout: "+t),window.location.hash)throw Error('A redirect failed, does the requsted layout exist? "'+t+'"?');console.log(`requires layout switch from ${j} to ${t}`);let e={routeName:n.route.name,params:n.params||{}};sessionStorage.setItem("layoutNavigation",JSON.stringify(e));let r=t.indexOf(".htm")>-1?`/${t}#layout`:`/${t}.html#layout`;return console.log("redirecting to ",r),window.location.href=r,!0}function rr(){try{let n=sessionStorage.getItem("layoutNavigation");if(!n)return!1;let t=JSON.parse(n);return sessionStorage.removeItem("layoutNavigation"),console.log("session store navigation ",t),G(t.routeName,{params:t.params}),!0}catch(n){return sessionStorage.removeItem("layoutNavigation"),v("Failed to navigate from session storage",{cause:n}),!1}}function or(n,t,e){var r="";t?r+=Object.entries(t).map(([s,i])=>`${s}=${i}`).join(", "):r=".";var o=e.map(s=>` * Name: '${s.name}', path: '${s.path}', target: ${s.target??"default"}
3
+ `);return`No route matched '${n}${r}'. Available routes:
4
+ ${o}`}function sr(n){if(!n||!n.route.guards||n.route.guards.length==0)return!0;for(let e=0;e<n.route.guards.length;e++){let r=n.route.guards[e];var t=r.check(n);if(t==0)return!0;if(t==3)return!1;if(t==1)throw new L(`Guard ${r.constructor.name} said 'Deny' for ${n.route.name}`)}return!0}function ir(n){return(t,e)=>{var r=Qt.resolve(n);return function(){return r}}}function ar(n){return t=>{let e=n??{inject:[]};e.key?ve.register(t,e):ve.registerByType(t,e)}}var ge=class{constructor(t,e,r,o={},s,i){this.classConstructor=t;this.scope=e;this.inject=r;this.properties=o;this.key=s;this.instance=i}},he=class{constructor(){this.servicesByKey=new Map;this.servicesByClassName=new Map}register(t,e){this.validateRegistration(t,e);let r=new ge(t,e.scope??"global",e.inject,e.properties??{},e.key,e.instance);e.key&&this.servicesByKey.set(e.key,r),this.servicesByClassName.set(t.name,r)}registerByType(t,e){this.checkNameCollision(t),e&&this.validateRegistration(t,e);let r=new ge(t,e?.scope,e?.inject??[],e?.properties,e?.key,e?.instance);e?.key&&this.servicesByKey.set(e.key,r),this.servicesByClassName.set(t.name,r)}checkNameCollision(t){let e=this.servicesByClassName.get(t.name);if(e&&e.classConstructor!==t){let r=v("Service name collision: different class registered with same name",{service:t.name});if(r)throw r}}validateRegistration(t,e){if(this.checkNameCollision(t),e.key){let r=this.servicesByKey.get(e.key);if(r&&r.classConstructor!==t){let o=v("Service key already registered to a different class",{key:e.key,existingClass:r.classConstructor.name,newClass:t.name});if(o)throw o}}if(e.instance&&e.inject.length>0){let r=v("Service has both instance and inject (inject will be ignored)",{service:t.name});if(r)throw r}}tryGet(t){return typeof t=="string"?this.servicesByKey.get(t):this.servicesByClassName.get(t.name)}get(t){let e=this.tryGet(t);if(!e){let r=typeof t=="string"?t:t.name,o=v(`Failed to resolve service '${r}'`,{service:r,registeredTypes:Array.from(this.servicesByClassName.keys()),registeredKeys:Array.from(this.servicesByKey.keys())});if(o)throw o}return e}};var ye=class{constructor(t){this.serviceCollection=t;this.instances=new Map}resolve(t){let e=typeof t=="string"?t:t.name;if(this.instances.has(e))return this.instances.get(e);let r=this.serviceCollection.get(t);if(!r){let s=v(`Failed to resolve service '${e}'`,{service:e});if(s)throw s;return}if(r.instance){let s=r.instance;return this.injectFields(s,r),this.instances.set(e,s),s}let o=this.createInstance(r);return r.scope==="global"&&this.instances.set(e,o),this.injectFields(o,r),o}createInstance(t){let e=t.classConstructor,r=t.inject.map(o=>this.resolve(o));return new e(...r)}injectFields(t,e){for(let[r,o]of Object.entries(e.properties))t[r]=this.resolve(o)}},ve=new he,Qt=new ye(ve);function cr(n,t){let e=n.parentElement;for(;e;){if(e instanceof t)return e;e=e.parentElement}return null}var lr=Math.floor(new Date("2025-01-01T00:00:00Z").getTime()/1e3),en=0,Ee=0;function tn(n){if(n<0||n>1048575)throw new Error("baseId must be between 0 and 1048575");let t=Math.floor(Date.now()/1e3);if(t===en){if(Ee++,Ee>255)throw new Error("Too many IDs generated in one second")}else en=t,Ee=0;let e=t-lr;if(e>1073741823)throw new Error("Timestamp exceeds allowed range (beyond 2045-01-01)");let r=BigInt(e),o=BigInt(Ee),s=BigInt(n);return(r<<BigInt(28)|o<<BigInt(20)|s).toString(36).toLowerCase()}var We=class extends Error{constructor(t){super(t.statusReason),this.message=t.statusReason,this.response=t}},E={bearerTokenName:"jwt"},nn=fetch;function ur(n){nn=n??fetch}function pr(n){E={...E,...n},n.bearerTokenName===void 0&&(E.bearerTokenName="jwt")}async function J(n,t){if(E.bearerTokenName){let o=localStorage.getItem(E.bearerTokenName);if(o&&t){let s=t?.headers?new Headers(t.headers):new Headers;s.get("Authorization")||s.set("Authorization","Bearer "+o),t.headers=s}}E.timeout&&!t?.signal&&(t??={},t.signal=AbortSignal.timeout(E.timeout)),E.baseUrl&&(n[0]!=="/"&&E.baseUrl[E.baseUrl.length-1]!=="/"?n=`${E.baseUrl}/${n}`:n=E.baseUrl+n);let e=await nn(n,t);if(!e.ok)return{statusCode:e.status,statusReason:e.statusText,success:!1,contentType:e.headers.get("content-type"),body:await e.text(),charset:e.headers.get("charset"),as(){throw new Error("No response received")}};let r=null;return e.status!==204&&(r=await e.json()),{success:!0,statusCode:e.status,statusReason:e.statusText,contentType:e.headers.get("content-type"),body:r,charset:e.headers.get("charset"),as(){return r}}}async function dr(n,t,e){if(e?e.method="GET":e={method:"GET",headers:{"content-type":E.contentType??"application/json"}},t){let r="&";n.indexOf("?")===-1&&(r="?");for(let o in t){let s=t[o];n+=`${r}${o}=${s}`,r="&"}}return J(n,e)}async function mr(n,t,e){return e?(e.method="POST",e.body=t):e={method:"POST",body:t,headers:{"content-type":E.contentType??"application/json"}},J(n,e)}async function fr(n,t,e){return e?(e.method="PUT",e.body=t):e={method:"PUT",body:t,headers:{"content-type":E.contentType??"application/json"}},J(n,e)}async function gr(n,t){return t?t.method="DELETE":t={method:"DELETE",headers:{"content-type":E.contentType??"application/json"}},J(n,t)}var xe=class extends Event{constructor(e,r,o){super(e,{bubbles:!0,...o});this.data=r}},ze=class{constructor(t,e){this.url=t;this.options=e;this.target=this.resolveTarget(e?.target)}get connected(){return this.eventSource?.readyState===EventSource.OPEN}connect(){if(this.eventSource)return;let t=new EventSource(this.url,{withCredentials:this.options?.withCredentials??!1});if(this.eventSource=t,t.onopen=()=>{this.options?.onConnect?.(this)},t.onerror=e=>{this.options?.onError?.(this,e)},this.options?.eventTypes&&this.options.eventTypes.length>0)for(let e of this.options.eventTypes)t.addEventListener(e,r=>{this.dispatchEvent(e,r.data)});else t.onmessage=e=>{this.dispatchEvent("message",e.data)}}disconnect(){this.eventSource?.close(),this.eventSource=void 0}resolveTarget(t){if(!t)return document;if(typeof t=="string"){let e=document.querySelector(t);if(!e)throw new Error(`SSEClient: Target element not found: ${t}`);return e}return t}dispatchEvent(t,e){let r;if(e.length>0&&(e[0]==="{"||e[0]==="["||e[0]==='"'))try{r=JSON.parse(e)}catch{r=e}else r=e;let o=this.options?.eventFactory?this.options.eventFactory(t,r):new xe(t,r);this.target.dispatchEvent(o)}};function hr(n,t){let e=t;for(let r of n){if(e==null)return;e=e[r]}return e??void 0}
5
+ //# sourceMappingURL=index.js.map