apprun 4.0.0 → 6.0.0-rc.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 (135) hide show
  1. package/CHANGELOG.md +235 -12
  2. package/LICENSE +1 -1
  3. package/README.md +225 -110
  4. package/apprun.d.ts +240 -34
  5. package/cli/app.js +29 -0
  6. package/cli/colors.js +69 -0
  7. package/cli/index.html +13 -0
  8. package/cli/index.js +96 -0
  9. package/dist/apprun-code.js +2 -0
  10. package/dist/apprun-code.js.map +1 -0
  11. package/dist/apprun-dev-tools.js +1 -1
  12. package/dist/apprun-dev-tools.js.map +1 -1
  13. package/dist/apprun-html.esm.js +34 -0
  14. package/dist/apprun-html.esm.js.map +1 -0
  15. package/dist/apprun-html.js +2 -1
  16. package/dist/apprun-html.js.LICENSE.txt +11 -0
  17. package/dist/apprun-html.js.map +1 -1
  18. package/dist/apprun-play.js +2 -0
  19. package/dist/apprun-play.js.map +1 -0
  20. package/dist/apprun.esm.js +2 -0
  21. package/dist/apprun.esm.js.map +1 -0
  22. package/dist/apprun.js +1 -1
  23. package/dist/apprun.js.map +1 -1
  24. package/dist/createState.js +2 -0
  25. package/dist/createState.js.map +1 -0
  26. package/esm/add-components.js +90 -0
  27. package/esm/add-components.js.map +1 -0
  28. package/esm/app.js +209 -0
  29. package/esm/app.js.map +1 -0
  30. package/esm/apprun-code.js +170 -0
  31. package/esm/apprun-code.js.map +1 -0
  32. package/esm/apprun-dev-tools-tests.js +95 -0
  33. package/esm/apprun-dev-tools-tests.js.map +1 -0
  34. package/esm/apprun-dev-tools.js +281 -0
  35. package/esm/apprun-dev-tools.js.map +1 -0
  36. package/esm/apprun-html.js +24 -0
  37. package/esm/apprun-html.js.map +1 -0
  38. package/esm/apprun-play.js +248 -0
  39. package/esm/apprun-play.js.map +1 -0
  40. package/esm/apprun.js +220 -0
  41. package/esm/apprun.js.map +1 -0
  42. package/esm/component.js +413 -0
  43. package/esm/component.js.map +1 -0
  44. package/esm/createState.js +9 -0
  45. package/esm/createState.js.map +1 -0
  46. package/esm/decorator.js +88 -0
  47. package/esm/decorator.js.map +1 -0
  48. package/esm/directive.js +306 -0
  49. package/esm/directive.js.map +1 -0
  50. package/esm/router.js +345 -0
  51. package/esm/router.js.map +1 -0
  52. package/esm/type-utils.js +90 -0
  53. package/esm/type-utils.js.map +1 -0
  54. package/esm/types.js +58 -0
  55. package/esm/types.js.map +1 -0
  56. package/esm/vdom-lit-html.js +65 -0
  57. package/esm/vdom-lit-html.js.map +1 -0
  58. package/esm/vdom-my-prop-attr.js +227 -0
  59. package/esm/vdom-my-prop-attr.js.map +1 -0
  60. package/esm/vdom-my.js +293 -0
  61. package/esm/vdom-my.js.map +1 -0
  62. package/esm/vdom-to-html.js +54 -0
  63. package/esm/vdom-to-html.js.map +1 -0
  64. package/esm/vdom.js +28 -0
  65. package/esm/vdom.js.map +1 -0
  66. package/esm/version.js +15 -0
  67. package/esm/version.js.map +1 -0
  68. package/esm/web-component.js +155 -0
  69. package/esm/web-component.js.map +1 -0
  70. package/jsx-runtime.js +2 -0
  71. package/jsx-runtime.js.map +1 -0
  72. package/package.json +90 -41
  73. package/.travis.yml +0 -10
  74. package/.vscode/launch.json +0 -19
  75. package/BACKERS.md +0 -3
  76. package/apprun-cli.js +0 -177
  77. package/cli-templates/_gitignore +0 -6
  78. package/cli-templates/component.ts_ +0 -16
  79. package/cli-templates/index.html +0 -11
  80. package/cli-templates/karma.conf.js +0 -24
  81. package/cli-templates/main.ts_ +0 -13
  82. package/cli-templates/readme.md +0 -7
  83. package/cli-templates/spa_index.html +0 -14
  84. package/cli-templates/spa_main.ts_ +0 -47
  85. package/cli-templates/spec.ts_ +0 -11
  86. package/cli-templates/tsconfig.json +0 -12
  87. package/cli-templates/webpack.config.js +0 -23
  88. package/demo-html/app.js +0 -2
  89. package/demo-html/app.js.map +0 -1
  90. package/demo-html/counter-c.html +0 -29
  91. package/demo-html/counter-wc-event.html +0 -29
  92. package/demo-html/counter-wc.html +0 -29
  93. package/demo-html/counter.html +0 -26
  94. package/demo-html/index.html +0 -14
  95. package/demo-html/main.tsx +0 -31
  96. package/docs/README.md +0 -326
  97. package/docs/index.html +0 -23
  98. package/index.html +0 -85
  99. package/logo.png +0 -0
  100. package/src/app.ts +0 -69
  101. package/src/apprun-dev-tools.tsx +0 -67
  102. package/src/apprun-html.ts +0 -13
  103. package/src/apprun.ts +0 -53
  104. package/src/component.ts +0 -189
  105. package/src/createComponent.tsx +0 -38
  106. package/src/decorator.ts +0 -36
  107. package/src/router.ts +0 -19
  108. package/src/types.ts +0 -9
  109. package/src/vdom-html.ts +0 -17
  110. package/src/vdom-my.ts +0 -191
  111. package/src/vdom-to-html.tsx +0 -45
  112. package/src/vdom.ts +0 -7
  113. package/src/web-component.ts +0 -29
  114. package/tests/app-rx.spec_ +0 -41
  115. package/tests/app.spec.ts +0 -122
  116. package/tests/application.spec.tsx +0 -23
  117. package/tests/component.spec.tsx +0 -296
  118. package/tests/custom-element.spec.tsx +0 -19
  119. package/tests/data-attr.spec.tsx +0 -42
  120. package/tests/decorator.spec.tsx +0 -104
  121. package/tests/fragment.spec.tsx +0 -79
  122. package/tests/hyperscript.spec.ts +0 -43
  123. package/tests/node-test.js +0 -7
  124. package/tests/router.spec.ts +0 -69
  125. package/tests/stateful-component.spec.tsx +0 -248
  126. package/tests/typed.spec.tsx +0 -63
  127. package/tests/vdom-html.spec.ts +0 -35
  128. package/tests/vdom-jsx.spec.tsx +0 -131
  129. package/tests/vdom-my.spec.tsx +0 -195
  130. package/tests/view-engine.spec.js +0 -59
  131. package/tsconfig.json +0 -11
  132. package/tslint.json +0 -124
  133. package/typescriptreact.json +0 -87
  134. package/viewEngine.js +0 -54
  135. package/webpack.config.js +0 -30
package/apprun.d.ts CHANGED
@@ -1,51 +1,257 @@
1
+ /**
2
+ * AppRun TypeScript Declaration File
3
+ *
4
+ * This file provides TypeScript declarations for the AppRun framework:
5
+ * 1. Core Framework Types
6
+ * - Component lifecycle (View, Action, Update)
7
+ * - Virtual DOM (VNode, VDOM)
8
+ * - Event system with comprehensive options
9
+ *
10
+ * 2. Application Interfaces
11
+ * - IApp: Main framework interface
12
+ *
13
+ * 3. Configuration Options
14
+ * - EventOptions: Event handling configuration
15
+ * - ActionOptions: Action behavior settings
16
+ * - MountOptions: Component mounting configuration
17
+ * - CustomElementOptions: Web component settings
18
+ *
19
+ * 4. Integration Support
20
+ * - React integration types
21
+ * - Lit-html TemplateResult support
22
+ * - JSX namespace declarations
23
+ * - State management with createState
24
+ *
25
+ * Updated in v3.35.1:
26
+ * - Consolidated types from types.ts implementation
27
+ * - Enhanced type safety with better generic constraints
28
+ * - Improved lifecycle hook typing with proper signatures
29
+ * - Added routing system types with ComponentRoute
30
+ * - Better integration with external libraries
31
+ * - Comprehensive options typing matching implementation
32
+ * - Added trustedHTML and smaller script-tag browser global declarations
33
+ * - Enhanced error handling and validation
34
+ * - Added support for async generator and generator functions in Action types
35
+ * - Phase 3 removed public option `any` escape hatches and typed history options
36
+ */
37
+
38
+ import { TemplateResult } from 'lit-html';
39
+
40
+ type LitTemplateFunction = (strings: TemplateStringsArray, ...values: any[]) => TemplateResult;
41
+ type AppRunRunDirective = (...args: any[]) => any;
42
+
43
+ declare global {
44
+ var app: import('apprun').IApp;
45
+ var _AppRunVersions: string;
46
+ var Component: typeof import('apprun').Component;
47
+ var on: typeof import('apprun').on;
48
+ var customElement: typeof import('apprun').customElement;
49
+ var trustedHTML: typeof import('apprun').trustedHTML;
50
+ /** @deprecated Use trustedHTML() for caller-owned trusted markup. */
51
+ var safeHTML: typeof import('apprun').safeHTML;
52
+ var html: LitTemplateFunction;
53
+ var svg: LitTemplateFunction;
54
+ var run: AppRunRunDirective;
55
+
56
+ interface Window {
57
+ app: import('apprun').IApp;
58
+ _AppRunVersions: string;
59
+ Component: typeof import('apprun').Component;
60
+ on: typeof import('apprun').on;
61
+ customElement: typeof import('apprun').customElement;
62
+ trustedHTML: typeof import('apprun').trustedHTML;
63
+ /** @deprecated Use trustedHTML() for caller-owned trusted markup. */
64
+ safeHTML: typeof import('apprun').safeHTML;
65
+ html: LitTemplateFunction;
66
+ svg: LitTemplateFunction;
67
+ run: AppRunRunDirective;
68
+ }
69
+ }
70
+
1
71
  declare module 'apprun' {
2
72
 
3
73
  export type Element = HTMLElement | string;
74
+ export type HistoryOptions = boolean | { prev?: string; next?: string };
75
+
76
+ export type State<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
4
77
 
5
78
  export type VNode = {
6
- tag: string,
7
- props: {},
8
- children: Array<VNode|string>
79
+ tag: string | Function;
80
+ props: Record<string, any>;
81
+ children: Array<VNode | string>;
82
+ };
83
+
84
+ export type VDOM = false | string | VNode | Array<VNode | string> | TemplateResult;
85
+ export type View<T> = (state: T) => VDOM | void;
86
+ export type Action<T> = (state: T, ...p: any[]) => T | Promise<T> | void | AsyncGenerator<T> | Generator<T>;
87
+ export type ActionDef<T, E> = (readonly [E, Action<T>, EventOptions?]);
88
+ export type ActionUpdate<T> = Action<T> | [Action<T>, EventOptions?] | (Action<T> | EventOptions)[];
89
+ export type Update<T, E = unknown> = ActionDef<T, E>[] | { [name: string]: ActionUpdate<T> } | (E | Action<T> | EventOptions)[];
90
+ export type Router = (url: string, ...args: any[]) => any;
91
+
92
+ export type EventOptions = {
93
+ once?: boolean;
94
+ transition?: boolean;
95
+ delay?: number;
96
+ global?: boolean;
97
+ event?: string;
98
+ [name: string]: any;
9
99
  };
10
100
 
11
- export type View<T> = (state: T) => string | VNode | VNode[] | void;
12
- export type Action<T> = (state: T, ...p: any[]) => T | Promise<T>;
13
- export type Update<T> = { [name: string]: Action<T> | {}[] | void; };
101
+ export type ActionOptions = {
102
+ render?: boolean;
103
+ history?: HistoryOptions;
104
+ global?: boolean;
105
+ callback?: (state: any) => void;
106
+ };
107
+
108
+ export type MountOptions = {
109
+ render?: boolean;
110
+ history?: HistoryOptions;
111
+ global_event?: boolean;
112
+ route?: string;
113
+ transition?: boolean;
114
+ };
115
+
116
+ export type AppStartOptions<T> = {
117
+ render?: boolean;
118
+ history?: HistoryOptions;
119
+ transition?: boolean;
120
+ route?: string;
121
+ rendered?: (state: T) => void;
122
+ mounted?: (props: any, children: any, state: T) => T | Promise<T> | void;
123
+ };
124
+
125
+ export type CustomElementOptions = {
126
+ render?: boolean;
127
+ shadow?: boolean;
128
+ history?: boolean;
129
+ global_event?: boolean;
130
+ observedAttributes?: string[];
131
+ };
132
+
133
+ export type ComponentRoute = {
134
+ [route: string]: any;
135
+ };
14
136
 
15
137
  export interface IApp {
16
- start<T>(element?: Element, model?: T, view?: View<T>, update?: Update<T>,
17
- options?: { history?, rendered?: (state: T) => void }): Component<T>;
18
- on(name: string, fn: (...args: any[]) => void, options?: any): void;
19
- once(name: string, fn: (...args: any[]) => void, options?: any): void;
20
- off(name: string, fn: (...args: any[]) => void): void;
21
- run(name: string, ...args: any[]): void;
22
- createElement(tag: string | Function, props, ...children): VNode | VNode[];
23
- render(element: HTMLElement, node: VNode): void;
24
- Fragment(props, ...children): any[];
25
- webComponent(name: string, componentClass, options?): void;
138
+ // Event system methods
139
+ on(name: string, fn: (...args: any[]) => any, options?: EventOptions): void;
140
+ once(name: string, fn: (...args: any[]) => any, options?: EventOptions): void;
141
+ off(name: string, fn: (...args: any[]) => any): void;
142
+ find(name: string): any;
143
+ run(name: string, ...args: any[]): number;
144
+ runAsync(name: string, ...args: any[]): Promise<any[]>;
145
+
146
+ start<T, E = unknown>(element?: Element | string, state?: State<T>, view?: View<T>, update?: Update<T, E>,
147
+ options?: AppStartOptions<T>): Component<T, E>;
148
+
149
+ h(tag: string | Function, props?: any, ...children: any[]): VNode | VNode[];
150
+ createElement(tag: string | Function, props?: any, ...children: any[]): VNode | VNode[];
151
+ render(element: Element | ShadowRoot, node: VNode, component?: {}): void;
152
+ Fragment(props: any, ...children: any[]): any[];
153
+
154
+ route: Router;
155
+ basePath?: string;
156
+ addComponents: (element: Element | string, components: ComponentRoute) => void;
157
+
158
+ webComponent(name: string, componentClass: any, options?: CustomElementOptions): void;
159
+ trustedHTML(html: string): any[];
160
+ /** @deprecated Use trustedHTML() for caller-owned trusted markup. */
161
+ safeHTML(html: string): any[];
162
+ use_render(render: any, mode?: 0 | 1): void;
163
+ use_react(React: any, ReactDOM: any): void;
164
+ version: string;
26
165
  }
27
166
 
28
- export class Component<T=any> {
29
- constructor(state?: T, view?: View<T>, update?: Update<T>);
30
- readonly state: T;
31
- setState(state: T, options?: { render?: boolean, history?: boolean }): void;
32
- mount(element?: Element, options?: { render?: boolean, history?, global_event?: boolean }): Component<T>;
33
- start(element?: Element, options?: { render?: boolean, history?, global_event?: boolean }): Component<T>;
34
- on(name: string, fn: (...args: any[]) => void, options?: any): void;
35
- run(name: string, ...args: any[]): void;
36
- rendered: (state: T) => void;
37
- mounted: (props: any) => void;
38
- unmount: () => void;
167
+ export class Component<T = any, E = any> {
168
+ constructor(state?: State<T>, view?: View<T>, update?: Update<T, E>, options?: MountOptions);
169
+ readonly element: Element | null | undefined;
170
+ state: State<T>;
171
+ view?: View<T>;
172
+ update?: Update<T, E>;
173
+
174
+ // Lifecycle hooks
175
+ rendered?: (state: T) => void;
176
+ mounted?: (props: any, children: any[], state: T) => T | Promise<T> | void;
177
+ unload?: (state: T) => void;
178
+
179
+ // Component lifecycle methods
180
+ mount(element?: Element, options?: MountOptions): Component<T, E>;
181
+ start(element?: Element, options?: MountOptions): Component<T, E>;
182
+ unmount(): void;
183
+
184
+ // State management
185
+ setState(state: T, options?: ActionOptions & EventOptions): void;
186
+
187
+ // Event system
188
+ on(event: E, fn: (...args: any[]) => void, options?: EventOptions): void;
189
+ run(event: E, ...args: any[]): any;
190
+ runAsync(event: E, ...args: any[]): Promise<any[]>;
191
+
192
+ // Action management
193
+ add_action(name: string, action: Action<T>, options?: ActionOptions): void;
194
+ is_global_event(name: string): boolean;
39
195
  }
40
196
 
41
- export type StatelessComponent<T={}> = (args: T) => VNode | void;
197
+ export function on<E>(name?: E, options?: EventOptions): any;
198
+ export function customElement(name: string, options?: CustomElementOptions):
199
+ <T extends { new(...args: any[]): {} }>(constructor: T) => T;
42
200
 
43
- export function on(name?: string, options?: { render?: boolean, history?: boolean });
44
- // obsolete
45
- export function update(name?: string, options?: { render?: boolean, history?: boolean });
46
- export function event(name?: string, options?: { render?: boolean, history?: boolean });
201
+ // Deprecated exports (kept for backward compatibility)
202
+ /** @deprecated Use on() instead */
203
+ export function update<E>(name?: E, options?: EventOptions): any;
204
+ /** @deprecated Use on() instead */
205
+ export function event<E>(name?: E, options?: EventOptions): any;
47
206
 
48
- export const app: IApp
207
+ export const app: IApp;
49
208
  export default app;
209
+ export const App: IApp;
210
+
211
+ export const ROUTER_EVENT: string;
212
+ export const ROUTER_404_EVENT: string;
213
+ export const trustedHTML: (html: string) => any[];
214
+ /** @deprecated Use trustedHTML() for caller-owned trusted markup. */
215
+ export const safeHTML: (html: string) => any[];
216
+ export function Fragment(props: any, ...children: any[]): any[];
217
+ }
218
+
219
+ declare module 'apprun/apprun-html' {
220
+ export * from 'apprun';
221
+ export { default } from 'apprun';
222
+ export const html: LitTemplateFunction;
223
+ export const svg: LitTemplateFunction;
224
+ export const run: AppRunRunDirective;
225
+ export const render: (element: Element | ShadowRoot, node: import('apprun').VDOM, component?: {}) => void;
226
+ }
227
+
228
+ declare namespace app {
229
+ namespace JSX {
230
+ interface ElementAttributesProperty { props: {} }
231
+ interface ElementChildrenAttribute { children: {} }
232
+ interface IntrinsicElements {
233
+ [elemName: string]: any;
234
+ }
235
+ }
236
+ }
237
+
238
+ declare namespace JSX {
239
+ interface ElementAttributesProperty { props: {} }
240
+ interface ElementChildrenAttribute { children: {} }
241
+ interface IntrinsicElements {
242
+ [elemName: string]: any;
243
+ }
244
+ }
245
+
246
+ declare module 'apprun/react' {
247
+ import { Component } from 'apprun';
248
+ export default function toReact<T = unknown>(componentClass: Component<T>): Function;
249
+ }
50
250
 
51
- }
251
+ declare module 'apprun/createState' {
252
+ type Draft<T> = T;
253
+ export default function createState<T = unknown>(
254
+ state: T,
255
+ updater: (draft: Draft<T>) => void
256
+ ): Promise<T> | T;
257
+ }
package/cli/app.js ADDED
@@ -0,0 +1,29 @@
1
+ const { app, html } = window["apprun"];
2
+
3
+ // Routing (component event)
4
+ class Home extends Component {
5
+ view = () => html`<div>Home</div>`;
6
+ update = { '/, /home': state => state };
7
+ }
8
+
9
+ class Contact extends Component {
10
+ view = () => html`<div>Contact</div>`;
11
+ update = { '/contact': state => state };
12
+ }
13
+
14
+ class About extends Component {
15
+ view = () => html`<div>About</div>`;
16
+ update = { '/about': state => state };
17
+ }
18
+
19
+ const App = () => html`<div id="menus">
20
+ <a href="/home">Home</a> |
21
+ <a href="/contact">Contact</a> |
22
+ <a href="/about">About</a></div>
23
+ <div id="pages"></div>
24
+ `;
25
+
26
+ // app.basePath = '/'; // Uncomment this line if you want to set a base path for routing
27
+ app.start('#app', {}, App);
28
+
29
+ [About, Contact, Home].map(C => new C().start('pages'));
package/cli/colors.js ADDED
@@ -0,0 +1,69 @@
1
+ // ANSI escape codes for colors
2
+ const greenColor = "\x1b[32m";
3
+ const yellowColor = "\x1b[33m";
4
+ const redColor = "\x1b[31m";
5
+ const cyanColor = "\x1b[36m";
6
+ const blueColor = "\x1b[34m";
7
+ const magentaColor = "\x1b[35m";
8
+ const grayColor = "\x1b[90m";
9
+ const whiteColor = "\x1b[37m";
10
+ const blackColor = "\x1b[30m";
11
+ const resetColor = "\x1b[0m";
12
+
13
+ // Helper functions with tagged template literals
14
+ function green(strings, ...values) {
15
+ const text = String.raw({ raw: strings }, ...values);
16
+ return `${greenColor}${text}${resetColor}`;
17
+ }
18
+
19
+ function yellow(strings, ...values) {
20
+ const text = String.raw({ raw: strings }, ...values);
21
+ return `${yellowColor}${text}${resetColor}`;
22
+ }
23
+
24
+ function red(strings, ...values) {
25
+ const text = String.raw({ raw: strings }, ...values);
26
+ return `${redColor}${text}${resetColor}`;
27
+ }
28
+
29
+ function cyan(strings, ...values) {
30
+ const text = String.raw({ raw: strings }, ...values);
31
+ return `${cyanColor}${text}${resetColor}`;
32
+ }
33
+
34
+ function blue(strings, ...values) {
35
+ const text = String.raw({ raw: strings }, ...values);
36
+ return `${blueColor}${text}${resetColor}`;
37
+ }
38
+
39
+ function magenta(strings, ...values) {
40
+ const text = String.raw({ raw: strings }, ...values);
41
+ return `${magentaColor}${text}${resetColor}`;
42
+ }
43
+
44
+ function gray(strings, ...values) {
45
+ const text = String.raw({ raw: strings }, ...values);
46
+ return `${grayColor}${text}${resetColor}`;
47
+ }
48
+
49
+ function white(strings, ...values) {
50
+ const text = String.raw({ raw: strings }, ...values);
51
+ return `${whiteColor}${text}${resetColor}`;
52
+ }
53
+
54
+ function black(strings, ...values) {
55
+ const text = String.raw({ raw: strings }, ...values);
56
+ return `${blackColor}${text}${resetColor}`;
57
+ }
58
+
59
+ module.exports = {
60
+ green,
61
+ yellow,
62
+ red,
63
+ cyan,
64
+ blue,
65
+ magenta,
66
+ gray,
67
+ white,
68
+ black,
69
+ };
package/cli/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>AppRun App</title>
7
+ <script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="app.js"></script>
12
+ </body>
13
+ </html>
package/cli/index.js ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require('commander');
4
+ const { existsSync, writeFileSync, mkdirSync, copyFileSync } = require('fs');
5
+ const { resolve, dirname } = require('path');
6
+ const { red, green, yellow } = require('./colors');
7
+ const execSync = require('child_process').execSync;
8
+
9
+ const component_template = `import {app, Component} from 'apprun';
10
+
11
+ export default class #nameComponent extends Component {
12
+ state = '#name';
13
+
14
+ view = (state) => <>
15
+ <h1>{state}</h1>
16
+ </>;
17
+
18
+ // update = {
19
+ // '/#name': state => state,
20
+ // }
21
+ }
22
+ `;
23
+
24
+ const test_template = `import app from 'apprun';
25
+ import #name from './#fn';
26
+
27
+ describe('component', () => {
28
+ it('should render state upon route event', () => {
29
+ const element = document.createElement('div');
30
+ const component = new #name().start(element);
31
+ expect(element.textContent).toBe('#name');
32
+ })
33
+ })
34
+ `;
35
+
36
+ program
37
+ .version('3.36.0')
38
+ .description('AppRun CLI')
39
+ .option('-i, --init', 'Initialize AppRun Project')
40
+ .option('-c, --component <name>', 'Create a component')
41
+ .option('-t, --test <name>', 'Create a component spec')
42
+ .option('-p, --pages [directory]', 'Create example pages')
43
+
44
+ program.parse(process.argv);
45
+
46
+ const options = program.opts();
47
+ if (options.init) {
48
+ execSync('npm create apprun-app@latest', { stdio: 'inherit' });
49
+ }
50
+
51
+
52
+ function createTestFile(fn, name) {
53
+ const component_name = name || fn.split('/').pop();
54
+ const component_file = fn.split('/').pop();
55
+ const test = test_template
56
+ .replace(/#name/g, component_name)
57
+ .replace(/#fn/g, component_file);
58
+ writeFile(fn + '.spec.tsx', test);
59
+ }
60
+
61
+ function createComponent(fn, name) {
62
+ if (!name) name = fn.split('/').pop();
63
+ const component = component_template.replace(/#name/g, name);
64
+ writeFile(fn + '.tsx', component);
65
+ }
66
+
67
+ const cwd = process.cwd();
68
+ const writeFile = (fn, text) => {
69
+ fn = resolve(cwd, fn);
70
+ const dir = dirname(fn);
71
+ if (!existsSync(dir)) {
72
+ mkdirSync(dir, { recursive: true });
73
+ console.log(yellow(`✔ ${dir}`));
74
+
75
+ }
76
+ if (existsSync(fn)) {
77
+ console.log(red(`✘ ${fn} exists`));
78
+ return;
79
+ }
80
+ writeFileSync(fn, text, 'utf8');
81
+ console.log(green(`✔ ${fn}`));
82
+ }
83
+
84
+ options.component && createComponent(options.component);
85
+ options.test && createTestFile(options.test);
86
+
87
+ if (options.pages) {
88
+ let pages = typeof options.pages === 'string' ? options.pages : 'pages';
89
+ pages = resolve(cwd, pages);
90
+ createComponent(`${pages}/Home/index`, 'Home');
91
+ createTestFile(`${pages}/Home/index`, 'Home');
92
+ createComponent(`${pages}/About/index`, 'About');
93
+ createTestFile(`${pages}/About/index`, 'About');
94
+ createComponent(`${pages}/Contact/index`, 'Contact');
95
+ createTestFile(`${pages}/Contact/index`, 'Contact');
96
+ }
@@ -0,0 +1,2 @@
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.apprun=n():e.apprun=n()}(this,(()=>(()=>{"use strict";var e={9:(e,n,t)=>{t.d(n,{EM:()=>a,W9:()=>l,on:()=>r});var o=t(436);const l={meta:new WeakMap,defineMetadata(e,n,t){this.meta.has(t)||this.meta.set(t,{}),this.meta.get(t)[e]=n},getMetadataKeys(e){return e=Object.getPrototypeOf(e),this.meta.get(e)?Object.keys(this.meta.get(e)):[]},getMetadata(e,n){return n=Object.getPrototypeOf(n),this.meta.get(n)?this.meta.get(n)[e]:null}};function r(e,n={}){return function(t,o){const r=e?e.toString():o;l.defineMetadata(`apprun-update:${r}`,{name:r,key:o,options:n},t)}}function a(e,n){return function(t){return(0,o.A)(e,t,n),t}}},18:(e,n,t)=>{t.r(n),t.d(n,{boolean:()=>l,booleanish:()=>r,commaOrSpaceSeparated:()=>c,commaSeparated:()=>u,number:()=>i,overloadedBoolean:()=>a,spaceSeparated:()=>s});let o=0;const l=p(),r=p(),a=p(),i=p(),s=p(),u=p(),c=p();function p(){return 2**++o}},72:(e,n,t)=>{t.d(n,{z:()=>r});var o=t(259),l=t(530);const r=(0,o.v)({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:l._})},91:(e,n,t)=>{t.d(n,{u:()=>g});var o=t(859),l=t(9),r=t(741),a=t(634);const i=e=>e,s=o.A;let u=0;const c="_c",p=new Map;let d=null;function h(){0===p.size&&d&&(d.disconnect(),d=null)}function m(e){const n=p.get(e);n&&(p.delete(e),n.component.unload?.(n.component.state),h())}function f(e){e&&(p.delete(e),h())}class g{renderState(e,n=null){if(!this.view)return;let t=n||this.view(e);if(s.debug&&s.run("debug",{component:this,_:t?".":"-",state:e,vdom:t,el:this.element}),"object"!=typeof document)return;const o="string"==typeof this.element&&this.element?(0,a.oP)(this.element)||(0,a.bV)(this.element):this.element;o?(this.unload?o._component===this&&o.getAttribute(c)===this.tracking_id||(this.tracking_element&&this.tracking_element!==o&&f(this.tracking_element),this.tracking_id=(++u).toString(36),o.setAttribute(c,this.tracking_id),this.tracking_element=o,function(e,n,t){const o=p.get(n);o&&o.component!==e&&m(n),p.set(n,{component:e,tracking_id:t}),!d&&"undefined"!=typeof MutationObserver&&"object"==typeof document&&document.body&&(d=new MutationObserver((e=>{e.forEach((e=>{if("attributes"===e.type){const n=e.target,t=p.get(n);t&&e.oldValue===t.tracking_id&&m(n)}else"childList"===e.type&&Array.from(p.keys()).forEach((e=>{document.body.contains(e)||m(e)}))}))})),d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[c]}))}(this,o,this.tracking_id)):(f(this.tracking_element),this.tracking_element=null,o.removeAttribute&&o.removeAttribute(c)),o._component=this,!n&&t&&(t=(0,r.A)(t,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>s.render(o,t,this))):s.render(o,t,this)),this.rendered&&this.rendered(this.state)):console.warn(`Component element not found: ${this.element}`)}setState(e,n={render:!0,history:!1}){const t=e;if(t?.[Symbol.asyncIterator])this.setState((async e=>{try{for(;;){const{value:t,done:o}=await e.next();if(o)break;this.setState(t,n)}}catch(e){console.error("Error in async iterator:",e)}})(t[Symbol.asyncIterator]()),n);else if(t?.[Symbol.iterator]&&"function"==typeof t.next)for(const e of t)this.setState(e,n);else if(e&&e instanceof Promise){const t=e;this._pending_state=t,Promise.resolve(t).then((e=>{this._pending_state===t&&(this._pending_state=null,this.setState(e,n))}))}else{if(this._state=e,null==e)return;this._pending_state=null,this.state=e,!1!==n.render&&(n.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(e))):this.renderState(e)),!1!==n.history&&this.enable_history&&(this._history=[...this._history,e],this._history_idx=this._history.length-1),"function"==typeof n.callback&&n.callback(this.state)}}constructor(e,n,t,l={}){this.state=e,this.view=n,this.update=t,this.options=l,this._app=new o.q,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this.enable_history=!1,this.global_event=!1,this.tracking_element=null,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(e=null,n)=>{if(this.mount(e,{render:!0,...n}),this.mounted&&"function"==typeof this.mounted){const e=this.mounted({},[],this.state);void 0!==e&&this.setState(e)}return this}}mount(e=null,n){if(console.assert(!this.element,"Component already mounted."),this.options=n={...this.options,...n},this.element=e,this.global_event=n.global_event,this.enable_history=!!n.history,this.enable_history){const e=function(e){return"object"==typeof e&&null!==e?e:{}}(n.history);this.on(e.prev||"history-prev",this._history_prev),this.on(e.next||"history-next",this._history_next)}return n.route&&(this.update=this.update||{},this.update[n.route]||(this.update[n.route]=i)),this.add_actions(),this.state=this.state??this.model??{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!n.render,history:!0}),s.debug&&s.find("debug-create-component")?.length&&s.run("debug-create-component",this),this}is_global_event(e){return e&&(this.global_event||this._global_events.indexOf(e)>=0||e.startsWith("#")||e.startsWith("/")||e.startsWith("@"))}add_action(e,n,t={}){n&&"function"==typeof n?(t.global&&this._global_events.push(e),this.on(e,((...o)=>{s.debug&&s.run("debug",{component:this,_:">",event:e,p:o,current_state:this.state,options:t});try{const l=n(this.state,...o);s.debug&&s.run("debug",{component:this,_:"<",event:e,p:o,newState:l,state:this.state,options:t}),this.setState(l,t)}catch(n){const l={event:e,error:n,component:this,state:this.state,args:o,phase:"component"};s.find("error")?.length?s.run("error",l):console.error(`Error in component action '${e}':`,n),s.debug&&s.run("debug",{component:this,_:"!",event:e,p:o,error:n,state:this.state,options:t})}}),t)):console.warn(`Component action for '${e}' is not a valid function:`,n)}add_actions(){const e=this.update||{};l.W9.getMetadataKeys(this).forEach((n=>{if(n.startsWith("apprun-update:")){const t=l.W9.getMetadata(n,this);e[t.name]=[this[t.key].bind(this),t.options]}}));const n={};Array.isArray(e)?e.forEach((e=>{const[t,o,l]=e;t.toString().split(",").forEach((e=>n[e.trim()]=[o,l]))})):Object.keys(e).forEach((t=>{const o=e[t];("function"==typeof o||Array.isArray(o))&&t.split(",").forEach((e=>n[e.trim()]=o))})),n["."]||(n["."]=i),Object.keys(n).forEach((e=>{const t=n[e];"function"==typeof t?this.add_action(e,t):Array.isArray(t)&&this.add_action(e,t[0],t[1])}))}run(e,...n){if(this.state instanceof Promise)return Promise.resolve(this.state).then((t=>{this.state=t,this.run(e,...n)}));{const t=e.toString();return this.is_global_event(t)?s.run(t,...n):this._app.run(t,...n)}}on(e,n,t){const o=e.toString();return this._actions.push({name:o,fn:n}),this.is_global_event(o)?s.on(o,n,t):this._app.on(o,n,t)}runAsync(e,...n){const t=e.toString();return this.is_global_event(t)?s.runAsync(t,...n):this._app.runAsync(t,...n)}unmount(){f(this.tracking_element),this.tracking_element=null,this._actions.forEach((e=>{const{name:n,fn:t}=e;this.is_global_event(n)?s.off(n,t):this._app.off(n,t)}))}}g.__isAppRunComponent=!0},147:(e,n,t)=>{t.d(n,{E:()=>a});var o=t(627),l=t(18);const r=Object.keys(l);class a extends o.R{constructor(e,n,t,o){let a=-1;if(super(e,n),i(this,"space",o),"number"==typeof t)for(;++a<r.length;){const e=r[a];i(this,r[a],(t&l[e])===l[e])}}}function i(e,n,t){t&&(e[n]=t)}a.prototype.defined=!0},176:(e,n,t)=>{t.d(n,{S:()=>o});class o{constructor(e,n,t){this.normal=n,this.property=e,t&&(this.space=t)}}o.prototype.normal={},o.prototype.property={},o.prototype.space=void 0},259:(e,n,t)=>{t.d(n,{v:()=>a});var o=t(457),l=t(147),r=t(176);function a(e){const n={},t={};for(const[r,a]of Object.entries(e.properties)){const i=new l.E(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),n[r]=i,t[(0,o.S)(r)]=r,t[(0,o.S)(i.attribute)]=r}return new r.S(n,t,e.space)}},277:(e,n,t)=>{t.d(n,{a:()=>r});var o=t(259),l=t(18);const r=(0,o.v)({properties:{ariaActiveDescendant:null,ariaAtomic:l.booleanish,ariaAutoComplete:null,ariaBusy:l.booleanish,ariaChecked:l.booleanish,ariaColCount:l.number,ariaColIndex:l.number,ariaColSpan:l.number,ariaControls:l.spaceSeparated,ariaCurrent:null,ariaDescribedBy:l.spaceSeparated,ariaDetails:null,ariaDisabled:l.booleanish,ariaDropEffect:l.spaceSeparated,ariaErrorMessage:null,ariaExpanded:l.booleanish,ariaFlowTo:l.spaceSeparated,ariaGrabbed:l.booleanish,ariaHasPopup:null,ariaHidden:l.booleanish,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:l.spaceSeparated,ariaLevel:l.number,ariaLive:null,ariaModal:l.booleanish,ariaMultiLine:l.booleanish,ariaMultiSelectable:l.booleanish,ariaOrientation:null,ariaOwns:l.spaceSeparated,ariaPlaceholder:null,ariaPosInSet:l.number,ariaPressed:l.booleanish,ariaReadOnly:l.booleanish,ariaRelevant:null,ariaRequired:l.booleanish,ariaRoleDescription:l.spaceSeparated,ariaRowCount:l.number,ariaRowIndex:l.number,ariaRowSpan:l.number,ariaSelected:l.booleanish,ariaSetSize:l.number,ariaSort:null,ariaValueMax:l.number,ariaValueMin:l.number,ariaValueNow:l.number,ariaValueText:null,role:null},transform:(e,n)=>"role"===n?n:"aria-"+n.slice(4).toLowerCase()})},292:(e,n,t)=>{t.d(n,{app:()=>f});var o=t(859),l=t(791),r=t(91),a=t(9),i=t(475),s=t(436);function u(e){return e&&"object"==typeof e&&"function"==typeof e.mount}function c(e){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e&&(void 0!==e.prototype.mount||void 0!==e.prototype.state||void 0!==e.prototype.view)}function p(e){return"function"==typeof e&&!c(e)}async function d(e,n=3){let t=e,o=0;for(;p(t)&&o<n;)try{const e=await t();if(e===t)break;t=e,o++}catch(e){console.error(`Error executing component function: ${e}`);break}return t}const h=async(e,n)=>{for(const[t,l]of Object.entries(n))if(l&&t)if(u(l)){const n={route:t};l.mount(e,n)}else if(c(l)){const n={route:t};(new l).mount(e,n)}else if(p(l)){let n=await d(l);if(u(n)){const o={route:t};n.mount(e,o);continue}if(c(n)){const o={route:t};(new n).mount(e,o);continue}o.A.on(t,((...n)=>{const t=l(...n),r="string"==typeof e?document.querySelector(e):e;if(r)return o.A.render(r,t);console.error(`Element not found: ${e}`)}))}else console.error("Invalid component: component must be a class, instance, or function that returns a class/instance");else console.error(`Invalid component configuration: component=${l}, route=${t}`)};var m=t(672);const f=o.A;if(!f.start){f.version=m.a,f.h=f.createElement=l.n,f.render=l.cJ,f.Fragment=l.FK,f.webComponent=s.A,f.trustedHTML=l.Fs,f.safeHTML=l.t_,f.start=(e,n,t,o,l)=>{const a={render:!0,global_event:!0,...l},i=new r.u(n,t,o);return l&&l.rendered&&(i.rendered=l.rendered),l&&l.mounted&&(i.mounted=l.mounted),i.start(e,a),i};const e=e=>{};if(f.on("/",e),f.on("debug",(n=>e)),f.on(i.z0,e),f.on(i.a6,e),f.route=i.wE,f.on("route",(e=>f.route&&f.route(e))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const e=document.body.hasAttribute("apprun-no-init")||f["no-init-route"]||!1,n=f.find("#")||f.find("#/")||!1;window.addEventListener("hashchange",(()=>(0,i.wE)(location.hash))),window.addEventListener("popstate",(()=>(0,i.wE)(location.pathname))),n?!e&&(0,i.wE)(location.hash):(!e&&(()=>{const e=f.basePath||"";let n=location.pathname;e&&n.startsWith(e)&&(n=n.substring(e.length),n.startsWith("/")||(n="/"+n)),(0,i.wE)(n)})(),document.body.addEventListener("click",(e=>{const n=e.target,t=n instanceof Element?n:n?.parentElement;if(!t)return;((e,n)=>{if(!((e,n)=>!(!n||e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n.target&&"_self"!==n.target.toLowerCase()||n.hasAttribute("download")||(n.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("external")||n.origin!==location.origin||!n.pathname))(e,n))return!1;e.preventDefault();const t=(f.basePath||"")+n.pathname;history.pushState(null,"",t),(0,i.wE)(n.pathname)})(e,"A"===t.tagName?t:t.closest("a"))})))})),"object"==typeof window){const e=window;e.Component=r.u,e.on=a.on,e.customElement=a.EM,e.trustedHTML=l.Fs,e.safeHTML=l.t_}f.use_render=(e,n=0)=>{f.render=0===n?(n,t)=>e(t,n):(n,t)=>e(n,t)},f.use_react=(e,n)=>{if(e&&n)if("function"==typeof e.createElement)if(e.Fragment)if(f.h=f.createElement=e.createElement,f.Fragment=e.Fragment,e.version&&e.version.startsWith("18")){if(!n.createRoot||"function"!=typeof n.createRoot)return void console.error("AppRun use_react: ReactDOM.createRoot not found in React 18+");f.render=(e,t)=>{e&&void 0!==t&&(e._root||(e._root=n.createRoot(e)),e._root.render(t))}}else{if(!n.render||"function"!=typeof n.render)return void console.error("AppRun use_react: ReactDOM.render not found in legacy React");f.render=(e,t)=>n.render(t,e)}else console.error("AppRun use_react: Invalid React object - Fragment not found");else console.error("AppRun use_react: Invalid React object - createElement method not found");else console.error("AppRun use_react: React and ReactDOM parameters are required")},f.addComponents=h}},436:(e,n,t)=>{t.d(n,{A:()=>l});const o=(e,n={})=>class extends HTMLElement{constructor(){super(),this._pendingAttributes=[]}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(n.observedAttributes||[]).map((e=>e.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component&&null==this._mountFrame){const t=n||{};this._shadowRoot=t.shadow?this.attachShadow({mode:"open"}):this;const o=t.observedAttributes||[],l=o.reduce(((e,n)=>{const t=n.toLowerCase();return t!==n&&(e[t]=n),e}),{});this._attrMap=e=>l[e]||e;const r={};Array.from(this.attributes).forEach((e=>r[this._attrMap(e.name)]=e.value)),o.forEach((e=>{void 0!==this[e]&&(r[e]=this[e]),Object.defineProperty(this,e,{get:()=>r[e],set(n){this.attributeChangedCallback(e,r[e],n)},configurable:!0,enumerable:!0})})),this._mountFrame=requestAnimationFrame((()=>{if(this._mountFrame=null,!this.isConnected)return;const n=this.children?Array.from(this.children):[];if(this._component=new e({...r,children:n}).mount(this._shadowRoot,t),this._component._props=r,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const e=this._component.mounted(r,n,this._component.state);void 0!==e&&(this._component.state=e)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component);const o=this._pendingAttributes;this._pendingAttributes=[],o.forEach((({name:e,oldValue:n,value:t})=>{this.attributeChangedCallback(e,n,t)})),!1!==t.render&&this._component.run(".")}))}}disconnectedCallback(){null!=this._mountFrame&&(cancelAnimationFrame(this._mountFrame),this._mountFrame=null),this._pendingAttributes=[],this._component?.unload?.(this._component.state),this._component?.unmount?.(),this._component=null}attributeChangedCallback(e,t,o){if(this._component){const l=this._attrMap?this._attrMap(e):e;this._component._props[l]=o,this._component.run("attributeChanged",l,t,o),o!==t&&!1!==n.render&&window.requestAnimationFrame((()=>{this._component?.run(".")}))}else this._pendingAttributes.push({name:e,oldValue:t,value:o})}},l=(e,n,t)=>{"undefined"!=typeof customElements&&customElements.define(e,o(n,t))}},457:(e,n,t)=>{function o(e){return e.toLowerCase()}t.d(n,{S:()=>o})},475:(e,n,t)=>{t.d(n,{a6:()=>c,wE:()=>p,z0:()=>u});var o=t(859);function l(e){return e?e.startsWith("#/")?e.substring(2).split("/"):e.startsWith("#")||e.startsWith("/")?e.substring(1).split("/"):e.split("/"):[]}function r(e){return e.startsWith("#/")?"hash-slash":e.startsWith("#")?"hash":e.startsWith("/")?"path":"non-prefixed"}function a(){const e=o.A.find("#");if(e&&e.length>0)return o.A.run("#"),void o.A.run(u,"#");const n=o.A.find("/");if(n&&n.length>0)return o.A.run("/"),void o.A.run(u,"/");const t=o.A.find("#/");if(t&&t.length>0)return o.A.run("#/"),void o.A.run(u,"#/");o.A.debug&&console.warn("No subscribers for event: "),o.A.run(c,""),o.A.run(u,"")}function i(e){if(!e)return void a();e=function(e){return e&&"/"!==e&&"#"!==e&&"#/"!==e&&e.endsWith("/")?e.slice(0,-1):e}(e);const n=o.A.basePath;n&&(e=function(e,n){if(!n||"/"===n||""===n)return e;const t=n.startsWith("/")?n:"/"+n;if(e.startsWith(t)){const n=e.substring(t.length);return n.startsWith("/")?n:"/"+n}return e}(e,n));const t=l(e);!function(e){const n=e.filter(Boolean);n.length>11&&console.warn(`Deep route hierarchy detected: ${n.join("/")} (${n.length} levels)`)}(t);const i=r(e),p=function(e,n){const t=[];for(let o=e.length;o>0;o--){const l=e.slice(0,o);let r="";switch(n){case"path":r="/"+l.join("/");break;case"hash":r="#"+l.join("/");break;case"hash-slash":r="#/"+l.join("/");break;case"non-prefixed":r=l.join("/")}t.push(r)}return t}(t,i),d=p[0],h=o.A.find(d),m=h&&h.length>0?{eventName:d,parameters:[]}:function(e,n){const t=Object.keys(o.A._events||{}).map((t=>function(e,n,t){if(r(e)!==n||!l(e).some((e=>"*"===e||e.startsWith(":"))))return null;const o=l(e),a=[];let i=0;for(let n=0;n<o.length;n++){const l=o[n];if("*"===l)return a.push(t.slice(n).join("/")),{eventName:e,parameters:a,score:10*i+o.length};const r=t[n];if(void 0===r)return null;if(l.startsWith(":"))a.push(r);else{if(l!==r)return null;i++}}return o.length!==t.length?null:{eventName:e,parameters:a,score:10*i+o.length}}(t,e,n))).filter(Boolean).sort(((e,n)=>n.score-e.score||n.eventName.length-e.eventName.length));return t.length>0?{eventName:t[0].eventName,parameters:t[0].parameters}:null}(i,t)||function(e,n){for(let t=0;t<e.length;t++){const l=e[t],r=o.A.find(l);if(r&&r.length>0){const o=e.length-t;return{eventName:l,parameters:n.slice(o)}}}return null}(p.slice(1),t);if(m)s(m.eventName,...m.parameters);else if(p.length>0){const n=p[p.length-1];o.A.debug&&console.warn(`No subscribers for event: ${n}`),o.A.run(c,e),o.A.run(u,e)}else a()}const s=(e,...n)=>{if(!e||e===u||e===c)return;const t=o.A.find(e);t&&0!==t.length?o.A.run(e,...n):(o.A.debug&&console.warn(`No subscribers for event: ${e}`),o.A.run(c,e,...n)),o.A.run(u,e,...n)},u="//",c="///",p=e=>{o.A.lastUrl!==e&&(o.A.lastUrl=e,i(e))}},530:(e,n,t)=>{t.d(n,{_:()=>l});var o=t(815);function l(e,n){return(0,o.B)(e,n.toLowerCase())}},559:(e,n,t)=>{t.d(n,{_:()=>o});const o=(0,t(259).v)({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,n)=>"xml:"+n.slice(3).toLowerCase()})},564:(e,n,t)=>{t.d(n,{J:()=>a});var o=t(815),l=t(259),r=t(18);const a=(0,l.v)({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:r.commaOrSpaceSeparated,accentHeight:r.number,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:r.number,amplitude:r.number,arabicForm:null,ascent:r.number,attributeName:null,attributeType:null,azimuth:r.number,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:r.number,by:null,calcMode:null,capHeight:r.number,className:r.spaceSeparated,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:r.number,diffuseConstant:r.number,direction:null,display:null,dur:null,divisor:r.number,dominantBaseline:null,download:r.boolean,dx:null,dy:null,edgeMode:null,editable:null,elevation:r.number,enableBackground:null,end:null,event:null,exponent:r.number,externalResourcesRequired:null,fill:null,fillOpacity:r.number,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:r.commaSeparated,g2:r.commaSeparated,glyphName:r.commaSeparated,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:r.number,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:r.number,horizOriginX:r.number,horizOriginY:r.number,id:null,ideographic:r.number,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:r.number,k:r.number,k1:r.number,k2:r.number,k3:r.number,k4:r.number,kernelMatrix:r.commaOrSpaceSeparated,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:r.number,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:r.number,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:r.number,overlineThickness:r.number,paintOrder:null,panose1:null,path:null,pathLength:r.number,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:r.spaceSeparated,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:r.number,pointsAtY:r.number,pointsAtZ:r.number,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:r.commaOrSpaceSeparated,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:r.commaOrSpaceSeparated,rev:r.commaOrSpaceSeparated,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:r.commaOrSpaceSeparated,requiredFeatures:r.commaOrSpaceSeparated,requiredFonts:r.commaOrSpaceSeparated,requiredFormats:r.commaOrSpaceSeparated,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:r.number,specularExponent:r.number,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:r.number,strikethroughThickness:r.number,string:null,stroke:null,strokeDashArray:r.commaOrSpaceSeparated,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:r.number,strokeOpacity:r.number,strokeWidth:null,style:null,surfaceScale:r.number,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:r.commaOrSpaceSeparated,tabIndex:r.number,tableValues:null,target:null,targetX:r.number,targetY:r.number,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:r.commaOrSpaceSeparated,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:r.number,underlineThickness:r.number,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:r.number,values:null,vAlphabetic:r.number,vMathematical:r.number,vectorEffect:null,vHanging:r.number,vIdeographic:r.number,version:null,vertAdvY:r.number,vertOriginX:r.number,vertOriginY:r.number,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:r.number,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:o.B})},569:(e,n,t)=>{t.d(n,{q:()=>a});var o=t(530),l=t(259),r=t(18);const a=(0,l.v)({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:r.commaSeparated,acceptCharset:r.spaceSeparated,accessKey:r.spaceSeparated,action:null,allow:null,allowFullScreen:r.boolean,allowPaymentRequest:r.boolean,allowUserMedia:r.boolean,alt:null,as:null,async:r.boolean,autoCapitalize:null,autoComplete:r.spaceSeparated,autoFocus:r.boolean,autoPlay:r.boolean,blocking:r.spaceSeparated,capture:null,charSet:null,checked:r.boolean,cite:null,className:r.spaceSeparated,cols:r.number,colSpan:null,content:null,contentEditable:r.booleanish,controls:r.boolean,controlsList:r.spaceSeparated,coords:r.number|r.commaSeparated,crossOrigin:null,data:null,dateTime:null,decoding:null,default:r.boolean,defer:r.boolean,dir:null,dirName:null,disabled:r.boolean,download:r.overloadedBoolean,draggable:r.booleanish,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:r.boolean,formTarget:null,headers:r.spaceSeparated,height:r.number,hidden:r.overloadedBoolean,high:r.number,href:null,hrefLang:null,htmlFor:r.spaceSeparated,httpEquiv:r.spaceSeparated,id:null,imageSizes:null,imageSrcSet:null,inert:r.boolean,inputMode:null,integrity:null,is:null,isMap:r.boolean,itemId:null,itemProp:r.spaceSeparated,itemRef:r.spaceSeparated,itemScope:r.boolean,itemType:r.spaceSeparated,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:r.boolean,low:r.number,manifest:null,max:null,maxLength:r.number,media:null,method:null,min:null,minLength:r.number,multiple:r.boolean,muted:r.boolean,name:null,nonce:null,noModule:r.boolean,noValidate:r.boolean,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:r.boolean,optimum:r.number,pattern:null,ping:r.spaceSeparated,placeholder:null,playsInline:r.boolean,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:r.boolean,referrerPolicy:null,rel:r.spaceSeparated,required:r.boolean,reversed:r.boolean,rows:r.number,rowSpan:r.number,sandbox:r.spaceSeparated,scope:null,scoped:r.boolean,seamless:r.boolean,selected:r.boolean,shadowRootClonable:r.boolean,shadowRootDelegatesFocus:r.boolean,shadowRootMode:null,shape:null,size:r.number,sizes:null,slot:null,span:r.number,spellCheck:r.booleanish,src:null,srcDoc:null,srcLang:null,srcSet:null,start:r.number,step:null,style:null,tabIndex:r.number,target:null,title:null,translate:null,type:null,typeMustMatch:r.boolean,useMap:null,value:r.booleanish,width:r.number,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:r.spaceSeparated,axis:null,background:null,bgColor:null,border:r.number,borderColor:null,bottomMargin:r.number,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:r.boolean,declare:r.boolean,event:null,face:null,frame:null,frameBorder:null,hSpace:r.number,leftMargin:r.number,link:null,longDesc:null,lowSrc:null,marginHeight:r.number,marginWidth:r.number,noResize:r.boolean,noHref:r.boolean,noShade:r.boolean,noWrap:r.boolean,object:null,profile:null,prompt:null,rev:null,rightMargin:r.number,rules:null,scheme:null,scrolling:r.booleanish,standby:null,summary:null,text:null,topMargin:r.number,valueType:null,version:null,vAlign:null,vLink:null,vSpace:r.number,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:r.boolean,disableRemotePlayback:r.boolean,prefix:null,property:null,results:r.number,security:null,unselectable:null},space:"html",transform:o._})},597:(e,n,t)=>{t.d(n,{o:()=>d});var o=t(775),l=t(862);const r="_props",a=new Map;function i(e,n,t){!function(e){return null!=e&&!1!==e&&""!==e&&(!0===e||("string"==typeof e?"false"!==e.toLowerCase()&&"0"!==e:Boolean(e)))}(t)?e.removeAttribute(n):e.setAttribute(n,n)}function s(e,n,t){try{e[n]=t}catch(o){u(e,n,t,!1)}}function u(e,n,t,o){if(null==t)return void e.removeAttribute(n);const l=String(t);if(o&&n.includes(":")){const[t]=n.split(":");"xlink"===t?e.setAttributeNS("http://www.w3.org/1999/xlink",n,l):e.setAttribute(n,l)}else e.setAttribute(n,l)}function c(e,n,t,r){if(c=e,p=n,document.activeElement===c?["selectionStart","selectionEnd","selectionDirection"].includes(p):"scrollTop"===p||"scrollLeft"===p||c instanceof HTMLMediaElement&&["currentTime","paused","playbackRate","volume"].includes(p))return;var c,p;if("style"===n){if(e.style.cssText&&(e.style.cssText=""),"string"==typeof t)e.style.cssText=t;else if(t&&"object"==typeof t)for(const n in t)e.style[n]!==t[n]&&(e.style[n]=t[n]);return}if("key"===n)return void(null!=t&&(e.key=t));if(n.startsWith("data-"))return void function(e,n,t){const o=(l=n.slice(5)).length<=1?l.toLowerCase():l.split("-").map(((e,n)=>0===n?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join("");var l;null==t?delete e.dataset[o]:e.dataset[o]=String(t)}(e,n,t);if(n.startsWith("on"))return void function(e,n,t){n.startsWith("on")&&(t&&"function"!=typeof t?"string"==typeof t&&(t?e.setAttribute(n,t):e.removeAttribute(n)):e[n]=t)}(e,n,t);if(!("INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName&&"SELECT"!==e.tagName||"value"!==n&&"selected"!==n&&"selectedIndex"!==n))return void s(e,n,t);if("INPUT"===e.tagName&&"checked"===n)return s(e,n,t),void i(e,n,t);const d=function(e,n){const t=`${e}:${n}`;let r=a.get(t);return void 0===r&&(r=(0,o.I)(n?l.JW:l.qy,e)||null,a.set(t,r)),r}(n,r);d?d.boolean||d.overloadedBoolean?i(e,d.attribute,t):d.mustUseProperty&&!r?s(e,d.property,t):u(e,d.attribute,t,r):n.startsWith("aria-")||"role"===n?u(e,n,t,r):n in e||void 0!==e[n]?s(e,n,t):u(e,n,t,r)}function p(e){return/^[a-zA-Z_:][\w\-:.]*$/.test(e)&&!e.includes("<")&&!e.includes(">")&&!e.includes('"')&&!e.includes("'")}function d(e,n,t){const o=function(e,n){if(n&&(n.class=n.class||n.className,delete n.className),!e||0===Object.keys(e).length)return n||{};if(!n||0===Object.keys(n).length){const n={};return Object.keys(e).forEach((e=>n[e]=null)),n}const t={};return Object.keys(e).forEach((e=>{e in n||(t[e]=null)})),Object.keys(n).forEach((e=>t[e]=n[e])),t}(e[r]||{},n);e[r]=n||{},function(e,n,t,o){for(const t in n)p(t)&&c(e,t,n[t],o);n&&"function"==typeof n.ref&&window.requestAnimationFrame((()=>n.ref(e)))}(e,o,0,t)}},627:(e,n,t)=>{t.d(n,{R:()=>o});class o{constructor(e,n){this.attribute=n,this.property=e}}o.prototype.attribute="",o.prototype.booleanish=!1,o.prototype.boolean=!1,o.prototype.commaOrSpaceSeparated=!1,o.prototype.commaSeparated=!1,o.prototype.defined=!1,o.prototype.mustUseProperty=!1,o.prototype.number=!1,o.prototype.overloadedBoolean=!1,o.prototype.property="",o.prototype.spaceSeparated=!1,o.prototype.space=void 0},634:(e,n,t)=>{function o(e){return e?.target instanceof HTMLElement?e.target:null}function l(e,n=document){try{return n.querySelector(e)}catch(n){return console.warn(`Invalid selector: ${e}`,n),null}}function r(e){try{return document.getElementById(e)}catch(n){return console.warn(`Error getting element by id: ${e}`,n),null}}t.d(n,{PB:()=>o,bV:()=>l,oP:()=>r})},670:(e,n,t)=>{t.d(n,{F:()=>o});const o=(0,t(259).v)({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,n)=>"xlink:"+n.slice(5).toLowerCase()})},672:(e,n,t)=>{t.d(n,{C:()=>l,a:()=>o});const o="6.0.0",l=`AppRun-${o}`},741:(e,n,t)=>{t.d(n,{A:()=>u});var o=t(859),l=t(634);const r=e=>{if(!e)return[];const n=[];let t="",o=!1,l="";for(let r=0;r<e.length;r++){const a=e[r];"["!==a||o?"]"===a&&o?(l?t=t.slice(1,-1):/^\d+$/.test(t)&&(t=parseInt(t,10)),n.push(t),t="",o=!1,l=""):'"'!==a&&"'"!==a||!o?"."!==a||o?t+=a:t&&(n.push(t),t=""):(l?a===l&&(l=""):l=a,t+=a):(t&&(n.push(t),t=""),o=!0)}return t&&n.push(t),n},a=(e,n)=>{if(!n)return e.state||"";const t=r(n),o=((e,n)=>{let t=e;for(const e of n){if(null==t)return;t=t[e]}return t})(e.state,t);return void 0!==o?o:""},i=(e,n,t)=>{if(!n)return void e.setState(t);const o=r(n),l=((e,n,t)=>{if(0===n.length)return t;const o={...e};let l=o;for(let e=0;e<n.length-1;e++){const t=n[e],o=n[e+1];null==l[t]?l[t]="number"==typeof o?[]:{}:Array.isArray(l[t])?l[t]=[...l[t]]:"object"==typeof l[t]&&(l[t]={...l[t]}),l=l[t]}return l[n[n.length-1]]=t,o})(e.state||{},o,t);e.setState(l)},s=(e,n)=>{if(Array.isArray(e))return e.map((e=>s(e,n)));{let{type:t,tag:r,props:u,children:c}=e;return r=r||t,c=c||u?.children,u&&Object.keys(u).forEach((e=>{e.startsWith("$")&&(((e,n,t,r)=>{if(e.startsWith("$on")){const t=n[e];if(e=e.substring(1),"boolean"==typeof t)n[e]=n=>r.run?r.run(e,n):o.A.run(e,n);else if("string"==typeof t)n[e]=e=>r.run?r.run(t,e):o.A.run(t,e);else if("function"==typeof t)n[e]=e=>r.setState(t(r.state,e));else if(Array.isArray(t)){const[l,...a]=t;"string"==typeof l?n[e]=e=>r.run?r.run(l,...a,e):o.A.run(l,...a,e):"function"==typeof l&&(n[e]=e=>r.setState(l(r.state,...a,e)))}}else if("$bind"===e){const o=n.type||"text",s="string"==typeof n[e]?n[e]:n.name;if("input"===t)switch(o){case"checkbox":n.checked=a(r,s),n.onclick=e=>{const n=(0,l.PB)(e);n&&i(r,s||n.name,n.checked)};break;case"radio":n.checked=a(r,s)===n.value,n.onclick=e=>{const n=(0,l.PB)(e);n&&i(r,s||n.name,n.value)};break;case"number":case"range":n.value=a(r,s),n.oninput=e=>{const n=(0,l.PB)(e);n&&i(r,s||n.name,Number(n.value))};break;default:n.value=a(r,s),n.oninput=e=>{const n=(0,l.PB)(e);n&&i(r,s||n.name,n.value)}}else"select"===t?(n.value=a(r,s),n.onchange=e=>{const n=(0,l.PB)(e);n&&!n.multiple&&i(r,s||n.name,n.value)}):"option"===t?(n.selected=a(r,s),n.onclick=e=>{const n=(0,l.PB)(e);n&&i(r,s||n.name,n.selected)}):"textarea"===t&&(n.value=a(r,s),n.oninput=e=>{const n=(0,l.PB)(e);n&&i(r,s||n.name,n.value)})}else o.A.run("$",{key:e,tag:t,props:n,component:r})})(e,u,r,n),delete u[e])})),c&&s(c,n),e}},u=s},775:(e,n,t)=>{t.d(n,{I:()=>u});var o=t(147),l=t(627),r=t(457);const a=/[A-Z]/g,i=/-[a-z]/g,s=/^data[-\w.:]+$/i;function u(e,n){const t=(0,r.S)(n);let u=n,d=l.R;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&"data"===t.slice(0,4)&&s.test(n)){if("-"===n.charAt(4)){const e=n.slice(5).replace(i,p);u="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=n.slice(4);if(!i.test(e)){let t=e.replace(a,c);"-"!==t.charAt(0)&&(t="-"+t),n="data"+t}}d=o.E}return new d(u,n)}function c(e){return"-"+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}},791:(e,n,t)=>{t.d(n,{FK:()=>r,Fs:()=>d,cJ:()=>s,n:()=>i,t_:()=>h});var o=t(741),l=t(597);function r(e,...n){return a(n)}function a(e){const n=[],t=e=>{null!=e&&""!==e&&!1!==e&&n.push("function"==typeof e||"object"==typeof e?e:`${e}`)};return e&&e.forEach((e=>{Array.isArray(e)?e.forEach((e=>t(e))):t(e)})),n}function i(e,n,...t){const o=a(t);if("string"==typeof e)return{tag:e,props:n,children:o};if(Array.isArray(e))return e;if(void 0===e&&t)return o;if(Object.getPrototypeOf(e).__isAppRunComponent)return{tag:e,props:n,children:o};if("function"==typeof e)return e(n,o);throw new Error(`Unknown tag in vdom ${e}`)}const s=(e,n,t={})=>{null!=n&&!1!==n&&function(e,n,t={}){if(null==n||!1===n)return;if(function(e){e&&e.__componentCache&&(e.__componentCacheUsed={})}(t),n=g(n,t),function(e){e&&e.__componentCache&&e.__componentCacheUsed&&(Object.keys(e.__componentCache).forEach((n=>{e.__componentCacheUsed[n]||(e.__componentCache[n]?.unmount?.(),delete e.__componentCache[n])})),e.__componentCacheUsed=null)}(t),!e)return;const o="SVG"===e.nodeName;Array.isArray(n)?c(e,n,o):c(e,[n],o)}("string"==typeof e&&e?document.getElementById(e)||document.querySelector(e):e,n=(0,o.A)(n,t),t)};function u(e,n,t){t=t||"svg"===n.tag,function(e,n){const t=e.nodeName,o=`${n.tag||""}`;return t.toUpperCase()===o.toUpperCase()}(e,n)?(c(e,n.children,t),(0,l.o)(e,n.props,t)):e.parentNode.replaceChild(f(n,t),e)}function c(e,n,t){const o={};Array.from(e.childNodes||[]).forEach((e=>{void 0!==e.key&&null!==e.key&&(o[p(e.key)]=e)}));const l=e.childNodes?.length||0,r=n?.length||0,a=Math.min(l,r);for(let l=0;l<a;l++){const r=n[l],a=e.childNodes[l];if("string"==typeof r)a.textContent!==r&&(3===a.nodeType?a.nodeValue=r:e.replaceChild(m(r),a));else if(r instanceof HTMLElement||r instanceof SVGElement)e.insertBefore(r,a);else{const n=r.props?r.props.key:void 0;if(null!=n)if(a.key===n)u(e.childNodes[l],r,t);else{const i=o[p(n)];i?(e.insertBefore(i,a),u(e.childNodes[l],r,t)):e.replaceChild(f(r,t),a)}else u(e.childNodes[l],r,t)}}let i=e.childNodes?.length||0;for(;i>a;)e.removeChild(e.lastChild),i--;if(r>a){const o=document.createDocumentFragment();for(let e=a;e<n.length;e++)o.appendChild(f(n[e],t));e.appendChild(o)}}function p(e){return`${typeof e}:${String(e)}`}const d=e=>{const n=document.createElement("section");return n.insertAdjacentHTML("afterbegin",e),Array.from(n.children)},h=d;function m(e){return document.createTextNode(e??"")}function f(e,n){if(e instanceof HTMLElement||e instanceof SVGElement)return e;if("string"==typeof e)return m(e);if(!e.tag||"function"==typeof e.tag)return m(JSON.stringify(e));const t=(n=n||"svg"===e.tag)?document.createElementNS("http://www.w3.org/2000/svg",e.tag):document.createElement(e.tag);return(0,l.o)(t,e.props,n),e.children&&e.children.forEach((e=>t.appendChild(f(e,n)))),e.props&&void 0!==e.props.key&&null!==e.props.key&&(t.key=e.props.key),t}function g(e,n,t=0){if("string"==typeof e)return e;if(Array.isArray(e))return e.map((e=>g(e,n,t++)));let o=e;if(e&&"function"==typeof e.tag&&Object.getPrototypeOf(e.tag).__isAppRunComponent&&(o=function(e,n,t){const{tag:o,props:r,children:a}=e,i=r&&r.id,s=null!=i?String(i):`_${t}`;let u="section";r&&r.as&&(u=r.as,delete r.as),n.__componentCache||(n.__componentCache={}),function(e,n){e&&(e.__componentCacheUsed=e.__componentCacheUsed||{},e.__componentCacheUsed[n]=!0)}(n,s);let c=n.__componentCache[s];if(c&&c instanceof o&&c.element)c.renderState(c.state);else{const e=document.createElement(u);c=n.__componentCache[s]=new o({...r,children:a}).mount(e,{render:!0})}if(c.mounted){const e=c.mounted(r,a,c.state);void 0!==e&&c.setState(e)}return(0,l.o)(c.element,r,!1),c.element}(e,n,t)),o&&Array.isArray(o.children)){const e=o.props?._component;if(e){let n=0;o.children=o.children.map((t=>g(t,e,n++)))}else o.children=o.children.map((e=>g(e,n,t++)))}return o}},815:(e,n,t)=>{function o(e,n){return n in e?e[n]:n}t.d(n,{B:()=>o})},859:(e,n,t)=>{t.d(n,{A:()=>s,q:()=>l});var o=t(672);class l{constructor(){this._reporting_error=!1,this._events={},this._wildcard_events=[]}on(e,n,t={}){this._events[e]=this._events[e]||[];const o={fn:n,options:t};this._events[e].push(o),e.endsWith("*")&&(this._wildcard_events.push({name:e,prefix:e.replace("*",""),sub:o}),this._wildcard_events.sort(((e,n)=>n.name.length-e.name.length)))}off(e,n){const t=this._events[e]||[];this._events[e]=t.filter((e=>e.fn!==n)),e.endsWith("*")&&(this._wildcard_events=this._wildcard_events.filter((t=>!(t.name===e&&t.sub.fn===n))))}find(e){return this._events[e]}run(e,...n){const t=this.getSubscribers(e,this._events);return this.debug&&console.assert(t&&t.length>0,"No subscriber for event: "+e),t.forEach((t=>{const{fn:o,options:l}=t;if(!o||"function"!=typeof o)return console.error(`AppRun event handler for '${e}' is not a function:`,o),!1;if(l.delay)this.delay(e,t,n);else try{Object.keys(l).length>0?o.apply(this,[...n,l]):o.apply(this,n)}catch(t){this.reportError(e,t,{phase:"run",args:n})}})),t.length}once(e,n,t={}){this.on(e,n,{...t,once:!0})}delay(e,n,t){const o=n._source||n,{fn:l,options:r}=n;o._t&&clearTimeout(o._t),o._t=setTimeout((()=>{clearTimeout(o._t),o._t=null;try{Object.keys(r).length>0?l.apply(this,[...t,r]):l.apply(this,t)}catch(n){this.reportError(e,n,{phase:"delay",args:t})}}),r.delay)}runAsync(e,...n){const t=this.getSubscribers(e,this._events);this.debug&&console.assert(t&&t.length>0,"No subscriber for event: "+e);const o=t.map((t=>{const{fn:o,options:l}=t;if(!o||"function"!=typeof o)return console.error(`AppRun async event handler for '${e}' is not a function:`,o),Promise.resolve(null);try{const t=Object.keys(l).length>0?o.apply(this,[...n,l]):o.apply(this,n);return Promise.resolve(t).catch((t=>(this.reportError(e,t,{phase:"runAsync",args:n}),Promise.reject(t))))}catch(t){return this.reportError(e,t,{phase:"runAsync",args:n}),Promise.reject(t)}}));return Promise.all(o)}reportError(e,n,t={}){const o={event:e,error:n,app:this,...t},l="error"===e||this._reporting_error?[]:this.getSubscribers("error",this._events);if(l.length>0){this._reporting_error=!0;try{l.forEach((e=>{try{e.fn.call(this,o)}catch(e){console.error("Error in error event handler:",e)}}))}finally{this._reporting_error=!1}}else"delay"===t.phase?console.error(`Error in delayed event handler for '${e}':`,n):"runAsync"===t.phase?console.error(`Error in async event handler for '${e}':`,n):console.error(`Error in event handler for '${e}':`,n)}removeOnceWildcardSubscriber(e,n){this._events[e]=(this._events[e]||[]).filter((e=>e!==n)),this._wildcard_events=this._wildcard_events.filter((e=>e.sub!==n))}getSubscribers(e,n){const t=n[e]||[],o=t.slice();return n[e]=t.filter((e=>!e.options.once)),this._wildcard_events.filter((({name:n,prefix:t})=>n!==e&&e.startsWith(t))).forEach((({name:n,sub:t})=>{t.options.once&&this.removeOnceWildcardSubscriber(n,t),o.push({...t,_source:t,options:{...t.options,event:e}})})),o}}const r=o.C;let a;const i="undefined"!=typeof window?window:void 0!==t.g?t.g:"undefined"!=typeof self?self:{};i.app&&i._AppRunVersions?a=i.app:(a=new l,i.app=a,i._AppRunVersions=r);const s=a},862:(e,n,t)=>{t.d(n,{JW:()=>p,qy:()=>c});var o=t(987),l=t(277),r=t(569),a=t(564),i=t(670),s=t(72),u=t(559);const c=(0,o.h)([l.a,r.q,i.F,s.z,u._],"html"),p=(0,o.h)([l.a,a.J,i.F,s.z,u._],"svg")},987:(e,n,t)=>{t.d(n,{h:()=>l});var o=t(176);function l(e,n){const t={},l={};for(const n of e)Object.assign(t,n.property),Object.assign(l,n.normal);return new o.S(t,l,n)}}},n={};function t(o){var l=n[o];if(void 0!==l)return l.exports;var r=n[o]={exports:{}};return e[o](r,r.exports,t),r.exports}t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};t.r(o);var l=t(91),r=t(292);class a extends l.u{constructor(){super(...arguments),this.view=({code:e,hide_code:n})=>r.app.h(r.app.Fragment,null,r.app.h("style",null,"\n.CodeMirror, .apprun-play iframe {\n height: 100%;\n border: dotted gray 1px;\n}\n\n.apprun-play {\n height: 100%;\n display: flex;\n font-size: 1.1rem;\n}\n\n.apprun-play .col {\n margin: 2px;\n}\n\n.apprun-play .editor, .apprun-play .preview {\n width: 100%;\n height: 100%;\n}\n"),n?r.app.h("div",{class:"apprun-play"},r.app.h("iframe",{class:"preview"})):r.app.h("div",{class:"apprun-play"},r.app.h("div",{class:"col",style:"width:75%"},r.app.h("textarea",{class:"editor"},e)),r.app.h("div",{class:"col",style:"flex:1"},r.app.h("iframe",{class:"preview"})))),this.mounted=e=>{const n=this.element,t=e["code-id"],o=e["hide-code"],l=e["code-width"];let r;r=t?document.getElementById(t):n.previousElementSibling||n.parentElement.previousElementSibling;const a=r?.innerText||r?.value||n.textContent;return r&&(r.style.display="none"),{code:a,hide_code:o,code_width:l}},this.rendered=({code:e,hide_code:n,code_width:t})=>{const o=this.element,l=o.querySelector(".apprun-play .editor");let r=o.querySelector(".apprun-play .preview");if(!r||!l)return;const a=e=>{const n=r.cloneNode();r.parentNode?.replaceChild(n,r),r=n;const t=r.contentWindow?.document;t&&(t.open(),e.indexOf("<html")>=0?t.write(e):t.write((e=>`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <title>AppRun Playground</title>\n <style>\n body {\n font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;\n margin: 2em;\n }\n </style>\n <script src="https://cdn.jsdelivr.net/npm/typescript@latest"><\/script>\n <script src="dist/apprun-html.js"><\/script>\n</head>\n<body>\n<pre id="code" style="display:none">${(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"))(e)}</pre>\n<script type="module">\nconst code = document.getElementById('code').innerText;\nconst compiled = ts.transpileModule(code, {\n compilerOptions: {\n "jsx": "react",\n "jsxFactory": "app.h",\n "jsxFragmentFactory": "app.Fragment",\n "target": "es2020",\n "module": "esnext",\n },\n reportDiagnostics: true,\n});\n\nif (compiled.diagnostics && compiled.diagnostics.length) {\n const pre = document.createElement('pre');\n pre.style = 'font-size: 10px;';\n pre.innerText = compiled.diagnostics.map(d => {\n const start = d.start;\n const end = d.start + d.length;\n const line = code.substring(0, end).split('\\n').length;\n const column = code.substring(0, end).split('\\n').pop().length;\n return \`Line: \${line}, Column: \${column}, \${d.messageText}\`;\n }).join('\\n');\n document.body.appendChild(pre);\n} else {\n window.onerror = function () {\n const pre = document.createElement('pre');\n pre.style = 'font-size: 10px;';\n pre.innerText = compiled.outputText;;\n document.body.appendChild(pre);\n };\n const script = document.createElement('script');\n script.type = 'module';\n script.text = compiled.outputText;\n document.body.appendChild(script);\n}\n<\/script>\n</body>\n</html>`)(e)),t.close())};if(e&&a(e),!n&&l)if(t&&(l.parentElement.style.width=t),"undefined"==typeof CodeMirror)l.onkeyup=()=>a(l.value);else{const n=CodeMirror.fromTextArea(l,{lineNumbers:!0,mode:"jsx"});n.setValue(e),n.on("change",(e=>a(e.getValue())))}}}}return r.app.webComponent("apprun-code",a),o})()));
2
+ //# sourceMappingURL=apprun-code.js.map