mates 0.0.15 โ†’ 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,152 +1,146 @@
1
- # ๐Ÿงช Mates
1
+ # Mates
2
2
 
3
- **Mates** is a lightweight, reactive state management framework for web applications that makes managing state a breeze! Think React hooks, but for any framework (or no framework at all)!
3
+ **Mates** is a lightweight framework that focuses on developer experience. It lets you build great web applications easily with it's awesome state management system. It's typescript First Framework. supports typescript all the way.
4
4
 
5
- ## ๐Ÿš€ Features
5
+ ## ๐Ÿš€ Features (MATES)
6
6
 
7
- - ๐Ÿ”„ **Reactive State**: Automatic UI updates when state changes
8
- - ๐Ÿงฉ **Composable**: Mix and match different state types
9
- - ๐Ÿ” **Transparent**: See exactly how data flows through your app
10
- - ๐ŸŽ๏ธ **Fast**: Minimal re-renders, optimized updates
11
- - ๐Ÿชถ **Lightweight**: Tiny footprint, big capabilities
12
- - ๐Ÿ”Œ **Framework-Agnostic**: Works with any framework or vanilla JS/TS
7
+ - **M**utable State: Mutate state directly through setters to update components (views)
8
+ - **A**ctions: Function utilities to help with business logic
9
+ - **T**emplates: Template functions that return **lit-html** result
10
+ - **E**vents: Event Utilites for event-driven development
11
+ - **S**etup functions: These are functions to intialise state needed for the view
13
12
 
14
13
  ## ๐Ÿ“ฆ Installation
15
14
 
16
15
  ```bash
17
- npm install mates
16
+
17
+ npm install mates
18
+
18
19
  # or
19
- yarn add mates
20
+
21
+ yarn add mates
22
+
20
23
  ```
21
24
 
22
25
  ## ๐Ÿง  Core Concepts
23
26
 
24
- Mates offers several types of state management tools that work together seamlessly as part of the framework:
25
-
26
- ### ๐Ÿ” Views: Building Reactive UIs
27
+ ### ๐Ÿ‘ Views: Components of Mates
27
28
 
28
- Views are the building blocks of your UI. They're functions that return HTML templates and automatically subscribe to state changes.
29
+ Views are similar to components in react. They are closure functions with outer function aka **Setup** function (the S from the MATES), and inner function is called **Template** function (the T from MATES) which returns html template string.
29
30
 
30
31
  ```typescript
31
- import { view, atom, setter } from "mates";
32
- import { html } from "lit-html";
32
+ import { renderView, setter, html } from "mates";
33
33
 
34
- // Create a view that uses this state
35
34
  const CounterView = (props) => {
35
+ // setup function: initialise state
36
36
  let count = 0;
37
37
  const incr = setter(() => count++);
38
- return () => {
39
- // This function renders the template
40
- return html`
41
- <div>
42
- <h1>Count: ${count}</h1>
43
- <button @click=${incr}>Increment</button>
44
- </div>
45
- `;
46
- };
38
+
39
+ // template function: returns html template strings.
40
+ return () => html` <div>
41
+ <h1>Count: ${count}</h1>
42
+ <button @click=${incr}>Increment</button>
43
+ </div>`;
47
44
  };
48
45
 
49
- // Render the view in your app in an element
50
- // second param should be id of the element
46
+ // Render the view in any html element by passing it's id
51
47
  renderView(CounterView, "app");
52
48
  ```
53
49
 
50
+ #### Formatting Support:
51
+
52
+ you can install lit-html plugin on your IDE like vs code or cursor for proper formatting for your template strings.
53
+
54
54
  ### โš›๏ธ Atoms: Simple Reactive State
55
55
 
56
- Atoms are the simplest form of state. They store a single value that can be read and updated.
56
+ Atoms hold mutable values. they can hold any Javascript value like primitive or objects or maps or sets.etc They store a single value that can be read, set (replaced with new value), or updated (if it's an object). They support typescript fully.
57
57
 
58
58
  ```typescript
59
- import { atom } from "mates";
59
+
60
+ import { atom } from "mates";
60
61
 
61
62
  // Create an atom with initial value
62
- const username = atom("guest");
63
+ const username = atom("guest");
63
64
 
64
65
  // Read the value
65
- console.log(username()); // "guest"
66
+ console.log(username()); // "guest"
67
+ // or
68
+ console.log(username.get()); // "guest"
66
69
 
67
- // Update the value
70
+ // set the value
68
71
  username.set("alice");
69
72
 
70
- // Use setter function
71
- username.set((prev) => prev.toUpperCase());
73
+ // you can also Use setter function
74
+ username.set((val) => val.toUpperCase());
72
75
 
73
- // you can also update the values in an object or array using .update()
76
+ // you can also update the value if it's of object type
77
+ const address = atom({ street: "" });
74
78
 
75
- const address = atom({ street: "" });
76
- address.update((s) => (s.street = "newstreet"));
79
+ // you are updating just the street value in an object.
80
+ address.update((s) => (s.street = "newstreet"));
81
+
82
+ // supports maps or sets:
83
+ const nums = atom(new Map());
84
+ // modify the map through update.
85
+ nums.update(m=>m.set(1, "one"));
86
+
87
+ const nums = atom(new Set([1,2,3]);
88
+ nums.update(s=>s.add(4));
89
+ // get the value
90
+ nums(); // Set(4) [1,2,3,4]
77
91
  ```
78
92
 
79
93
  ### Counter app using atoms
80
94
 
81
95
  ```typescript
82
-
96
+ const CounterView = (props) => {
97
+ // setup function: initialise state
98
+ const count = atom(0);
99
+ const incr = count.set(count() + 1);
100
+
101
+ // template function: returns html template strings.
102
+ return () => html` <div>
103
+ <h1>Count: ${count}</h1>
104
+ <button @click=${incr}>Increment</button>
105
+ </div>`;
106
+ };
83
107
  ```
84
108
 
85
- ### ๐Ÿงช Units: Object-Based State
109
+ ### Units: Independent Object-Based State
86
110
 
87
- Units are perfect for managing object-based state with methods.
111
+ Units are perfect for managing object-based state with methods and building store utilities.
112
+ Units have the following pieces
113
+
114
+ - Data: any type of javascript value
115
+ - Setters: methods whose name start with (\_)
116
+ - Getters: methods that returns data without changing it
117
+ - Actions: async or non-async methods that call getters or setters for getting, setting data.
88
118
 
89
119
  ```typescript
90
120
  import { unit } from "mates";
91
121
 
92
- // Create a unit
122
+ // Create a users unit
93
123
  const todoList = unit({
94
- items: [],
95
-
96
- // Methods with _ prefix automatically trigger updates
97
- _addItem(text) {
98
- this.items.push({ text, completed: false });
124
+ users: [],
125
+ isLoading = false,
126
+ // setter
127
+ _setIsLoading(value) {
128
+ this.isLoading = value;
99
129
  },
100
-
101
- _toggleItem(index) {
102
- this.items[index].completed = !this.items[index].completed;
103
- },
104
-
105
- // Computed property (cached and recalculated when dependencies change)
106
- get completedCount() {
107
- return this.items.filter((item) => item.completed).length;
130
+ // setter
131
+ _setUsers(newUsers) {
132
+ this.users = newUsers;
108
133
  },
109
-
110
- async loadData() {
111
- const data = await fetchData();
112
- this._addItem(data); // updates items
134
+ // async action that calls setters to set state
135
+ async loadUsers() {
136
+ this._setIsLoading(true);
137
+ this._setUsers(await fetch("/users").then((d) => d.json()));
138
+ this._setIsLoading(false);
113
139
  },
140
+ getUsersCount(){
141
+ return this.users.length;
142
+ }
114
143
  });
115
-
116
- // Use the unit
117
- todoList().items; // []
118
- todoList()._addItem("Learn Mates");
119
- ```
120
-
121
- ### ๐Ÿซง Bubbles: Encapsulated Logic
122
-
123
- Bubbles help you encapsulate complex state logic into a reusable entity.
124
-
125
- ```typescript
126
- import { bubble } from "mates";
127
-
128
- const counterBubble = bubble((setter) => {
129
- let count = 0;
130
-
131
- // Create functions that update state with setter
132
- const increment = setter(() => count++);
133
- const decrement = setter(() => count--);
134
- const reset = setter(() => (count = 0));
135
-
136
- // Return a function that returns the state object
137
- return () => ({
138
- count,
139
- increment,
140
- decrement,
141
- reset,
142
- });
143
- });
144
-
145
- // Use the bubble
146
- const { count, increment } = counterBubble();
147
- console.log(count); // 0
148
- increment();
149
- console.log(counterBubble().count); // 1
150
144
  ```
151
145
 
152
146
  ### ๐Ÿ“Š Getters: Computed Values
@@ -157,28 +151,30 @@ Getters create computed values that only recalculate when their dependencies cha
157
151
  import { atom, getter } from "mates";
158
152
 
159
153
  const firstName = atom("John");
154
+
160
155
  const lastName = atom("Doe");
161
156
 
162
157
  const fullName = getter(() => {
163
- return `${firstName()} ${lastName()}`;
158
+ return `${firstName()} ${lastName()}`;
164
159
  });
165
160
 
166
161
  console.log(fullName()); // "John Doe"
167
162
 
168
163
  // Only recalculates when dependencies change
164
+
169
165
  firstName.set("Jane");
166
+
170
167
  console.log(fullName()); // "Jane Doe"
171
168
  ```
172
169
 
173
- ### ๐Ÿงฌ Molecules: Organizing State
174
-
175
- Molecules help you organize your state into classes for better structure.
170
+ ### ๐Ÿงฌ Molecules: group atoms or units or getters into one molecule
176
171
 
177
172
  ```typescript
178
173
  import { molecule, atom } from "mates";
179
174
 
180
175
  class UserStore {
181
176
  name = atom("Guest");
177
+
182
178
  isLoggedIn = atom(false);
183
179
 
184
180
  login(username) {
@@ -193,11 +189,15 @@ class UserStore {
193
189
  }
194
190
 
195
191
  // Create a molecule from the class
192
+
196
193
  const userStore = molecule(UserStore);
197
194
 
198
195
  // Use the molecule
196
+
199
197
  console.log(userStore().name()); // "Guest"
198
+
200
199
  userStore().login("Alice");
200
+
201
201
  console.log(userStore().isLoggedIn()); // true
202
202
  ```
203
203
 
@@ -207,9 +207,11 @@ XProvider allows you to provide and consume context across your application.
207
207
 
208
208
  ```typescript
209
209
  import { html } from "lit-html";
210
+
210
211
  import { view, useContext } from "mates";
211
212
 
212
213
  // Create a context class
214
+
213
215
  class ThemeContext {
214
216
  theme = "light";
215
217
 
@@ -219,6 +221,7 @@ class ThemeContext {
219
221
  }
220
222
 
221
223
  // Provider component
224
+
222
225
  const ThemeProvider = view(
223
226
  (props) => {
224
227
  const themeContext = new ThemeContext();
@@ -227,12 +230,15 @@ const ThemeProvider = view(
227
230
  <x-provider .value=${themeContext}> ${props().children} </x-provider>
228
231
  `;
229
232
  },
233
+
230
234
  { children: [] }
231
235
  );
232
236
 
233
237
  // Consumer component
238
+
234
239
  const ThemedButton = view(() => {
235
240
  // Get context instance
241
+
236
242
  const theme = useContext(ThemeContext);
237
243
 
238
244
  return () => html`
@@ -249,11 +255,14 @@ Here's a complete todo list example that showcases Mates' features:
249
255
 
250
256
  ```typescript
251
257
  import { html } from "lit-html";
258
+
252
259
  import { view, bubble, atom } from "mates";
253
260
 
254
261
  // Create state with a bubble
262
+
255
263
  const todos = bubble((setter) => {
256
264
  let items = [];
265
+
257
266
  let newTodoText = "";
258
267
 
259
268
  const setNewTodoText = setter((text) => {
@@ -263,6 +272,7 @@ const todos = bubble((setter) => {
263
272
  const addTodo = setter(() => {
264
273
  if (newTodoText.trim()) {
265
274
  items.push({ text: newTodoText, completed: false });
275
+
266
276
  newTodoText = "";
267
277
  }
268
278
  });
@@ -277,29 +287,41 @@ const todos = bubble((setter) => {
277
287
 
278
288
  return () => ({
279
289
  items,
290
+
280
291
  newTodoText,
292
+
281
293
  setNewTodoText,
294
+
282
295
  addTodo,
296
+
283
297
  toggleTodo,
298
+
284
299
  deleteTodo,
285
300
  });
286
301
  });
287
302
 
288
303
  // Create a view for the todo app
304
+
289
305
  const TodoApp = view(() => {
290
306
  return () => {
291
307
  const {
292
308
  items,
309
+
293
310
  newTodoText,
311
+
294
312
  setNewTodoText,
313
+
295
314
  addTodo,
315
+
296
316
  toggleTodo,
317
+
297
318
  deleteTodo,
298
319
  } = todos();
299
320
 
300
321
  return html`
301
322
  <div class="todo-app">
302
323
  <h1>Todo List</h1>
324
+
303
325
  <div class="add-todo">
304
326
  <input
305
327
  value=${newTodoText}
@@ -307,6 +329,7 @@ const TodoApp = view(() => {
307
329
  @keypress=${(e) => e.key === "Enter" && addTodo()}
308
330
  placeholder="Add new todo"
309
331
  />
332
+
310
333
  <button @click=${addTodo}>Add</button>
311
334
  </div>
312
335
 
@@ -319,7 +342,9 @@ const TodoApp = view(() => {
319
342
  .checked=${item.completed}
320
343
  @change=${() => toggleTodo(index)}
321
344
  />
345
+
322
346
  <span>${item.text}</span>
347
+
323
348
  <button @click=${() => deleteTodo(index)}>Delete</button>
324
349
  </li>
325
350
  `
@@ -335,6 +360,7 @@ const TodoApp = view(() => {
335
360
  }, {});
336
361
 
337
362
  // Mount the app
363
+
338
364
  document.body.appendChild(TodoApp);
339
365
  ```
340
366
 
@@ -343,8 +369,11 @@ document.body.appendChild(TodoApp);
343
369
  Mates gives you the power and simplicity of React hooks without the React! As a complete framework, it's perfect for:
344
370
 
345
371
  - Building lightweight web apps without other heavy frameworks
372
+
346
373
  - Adding reactivity to existing applications
374
+
347
375
  - Creating reusable, reactive components
376
+
348
377
  - Prototyping ideas quickly
349
378
 
350
379
  ## ๐Ÿ“š Learn More
package/dist/index.d.ts CHANGED
@@ -10,4 +10,19 @@ import "./x-view";
10
10
  export { type Props, type Setter, getTemplateIsRunning, globalScheduler, } from "./x-view";
11
11
  import "./xProvider";
12
12
  export { view, renderView } from "./view";
13
+ export { html, render } from "./lit-html";
14
+ export { repeat } from "./lit-html/directives/repeat";
15
+ export { guard } from "./lit-html/directives/guard";
16
+ export { styleMap } from "./lit-html/directives/style-map";
17
+ export { classMap } from "./lit-html/directives/class-map";
18
+ export { when } from "./lit-html/directives/when";
19
+ export { ifDefined } from "./lit-html/directives/if-defined";
20
+ export { live } from "./lit-html/directives/live";
21
+ export { until } from "./lit-html/directives/until";
22
+ export { keyed } from "./lit-html/directives/keyed";
23
+ export { cache } from "./lit-html/directives/cache";
24
+ export { asyncReplace } from "./lit-html/directives/async-replace";
25
+ export { join } from "./lit-html/directives/join";
26
+ export { range } from "./lit-html/directives/range";
27
+ export { asyncAppend } from "./lit-html/directives/async-append";
13
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,EAAE,GACH,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,CAAC,EACD,QAAQ,EACR,MAAM,EACN,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,gBAAgB,EACrB,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,SAAS,IAAI,cAAc,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,KAAK,EACV,KAAK,MAAM,EACX,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,EAAE,GACH,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,CAAC,EACD,QAAQ,EACR,MAAM,EACN,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,gBAAgB,EACrB,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,SAAS,IAAI,cAAc,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,KAAK,EACV,KAAK,MAAM,EACX,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC"}
package/dist/index.esm.js CHANGED
@@ -3,5 +3,67 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- const t=globalThis,e=t.trustedTypes,n=e?e.createPolicy("lit-html",{createHTML:t=>t}):void 0,o="$lit$",s=`lit$${Math.random().toFixed(9).slice(2)}$`,r="?"+s,i=`<${r}>`,c=document,l=()=>c.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,h=Array.isArray,u="[ \t\n\f\r]",p=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,d=/-->/g,f=/>/g,_=RegExp(`>|${u}(?:([^\\s"'>=/]+)(${u}*=${u}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),y=/'/g,g=/"/g,m=/^(?:script|style|textarea|title)$/i,A=(E=1,(t,...e)=>({_$litType$:E,strings:t,values:e})),v=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),w=new WeakMap,$=c.createTreeWalker(c,129);var E;function x(t,e){if(!h(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==n?n.createHTML(e):e}class S{constructor({strings:t,_$litType$:n},c){let a;this.parts=[];let h=0,u=0;const A=t.length-1,v=this.parts,[b,w]=((t,e)=>{const n=t.length-1,r=[];let c,l=2===e?"<svg>":3===e?"<math>":"",a=p;for(let e=0;e<n;e++){const n=t[e];let h,u,A=-1,v=0;for(;v<n.length&&(a.lastIndex=v,u=a.exec(n),null!==u);)v=a.lastIndex,a===p?"!--"===u[1]?a=d:void 0!==u[1]?a=f:void 0!==u[2]?(m.test(u[2])&&(c=RegExp("</"+u[2],"g")),a=_):void 0!==u[3]&&(a=_):a===_?">"===u[0]?(a=c??p,A=-1):void 0===u[1]?A=-2:(A=a.lastIndex-u[2].length,h=u[1],a=void 0===u[3]?_:'"'===u[3]?g:y):a===g||a===y?a=_:a===d||a===f?a=p:(a=_,c=void 0);const b=a===_&&t[e+1].startsWith("/>")?" ":"";l+=a===p?n+i:A>=0?(r.push(h),n.slice(0,A)+o+n.slice(A)+s+b):n+s+(-2===A?e:b)}return[x(t,l+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]})(t,n);if(this.el=S.createElement(b,c),$.currentNode=this.el.content,2===n||3===n){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(a=$.nextNode())&&v.length<A;){if(1===a.nodeType){if(a.hasAttributes())for(const t of a.getAttributeNames())if(t.endsWith(o)){const e=w[u++],n=a.getAttribute(t).split(s),o=/([.?@])?(.*)/.exec(e);v.push({type:1,index:h,name:o[2],strings:n,ctor:"."===o[1]?T:"?"===o[1]?j:"@"===o[1]?N:O}),a.removeAttribute(t)}else t.startsWith(s)&&(v.push({type:6,index:h}),a.removeAttribute(t));if(m.test(a.tagName)){const t=a.textContent.split(s),n=t.length-1;if(n>0){a.textContent=e?e.emptyScript:"";for(let e=0;e<n;e++)a.append(t[e],l()),$.nextNode(),v.push({type:2,index:++h});a.append(t[n],l())}}}else if(8===a.nodeType)if(a.data===r)v.push({type:2,index:h});else{let t=-1;for(;-1!==(t=a.data.indexOf(s,t+1));)v.push({type:7,index:h}),t+=s.length-1}h++}}static createElement(t,e){const n=c.createElement("template");return n.innerHTML=t,n}}function M(t,e,n=t,o){if(e===v)return e;let s=void 0!==o?n.o?.[o]:n.l;const r=a(e)?void 0:e._$litDirective$;return s?.constructor!==r&&(s?._$AO?.(!1),void 0===r?s=void 0:(s=new r(t),s._$AT(t,n,o)),void 0!==o?(n.o??=[])[o]=s:n.l=s),void 0!==s&&(e=M(t,s._$AS(t,e.values),s,o)),e}class C{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,o=(t?.creationScope??c).importNode(e,!0);$.currentNode=o;let s=$.nextNode(),r=0,i=0,l=n[0];for(;void 0!==l;){if(r===l.index){let e;2===l.type?e=new H(s,s.nextSibling,this,t):1===l.type?e=new l.ctor(s,l.name,l.strings,this,t):6===l.type&&(e=new P(s,this,t)),this._$AV.push(e),l=n[++i]}r!==l?.index&&(s=$.nextNode(),r++)}return $.currentNode=c,o}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class H{get _$AU(){return this._$AM?._$AU??this.v}constructor(t,e,n,o){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=o,this.v=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=M(this,t,e),a(t)?t===b||null==t||""===t?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==v&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>h(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(c.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,o="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=S.createElement(x(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new C(o,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=w.get(t.strings);return void 0===e&&w.set(t.strings,e=new S(t)),e}k(t){h(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,o=0;for(const s of t)o===e.length?e.push(n=new H(this.O(l()),this.O(l()),this,this.options)):n=e[o],n._$AI(s),o++;o<e.length&&(this._$AR(n&&n._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this.v=t,this._$AP?.(t))}}class O{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,o,s){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=s,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=b}_$AI(t,e=this,n,o){const s=this.strings;let r=!1;if(void 0===s)t=M(this,t,e,0),r=!a(t)||t!==this._$AH&&t!==v,r&&(this._$AH=t);else{const o=t;let i,c;for(t=s[0],i=0;i<s.length-1;i++)c=M(this,o[n+i],e,i),c===v&&(c=this._$AH[i]),r||=!a(c)||c!==this._$AH[i],c===b?t=b:t!==b&&(t+=(c??"")+s[i+1]),this._$AH[i]=c}r&&!o&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class T extends O{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}}class j extends O{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}}class N extends O{constructor(t,e,n,o,s){super(t,e,n,o,s),this.type=5}_$AI(t,e=this){if((t=M(this,t,e,0)??b)===v)return;const n=this._$AH,o=t===b&&n!==b||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==b&&(n===b||o);o&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class P{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t)}}const k=t.litHtmlPolyfillSupport;k?.(S,H),(t.litHtmlVersions??=[]).push("3.2.0");const U=(t,e,n)=>{const o=n?.renderBefore??e;let s=o._$litPart$;if(void 0===s){const t=n?.renderBefore??null;o._$litPart$=s=new H(e.insertBefore(l(),t),t,void 0,n??{})}return s._$AI(t),s};let D=!1;const R=()=>D;const V=new class{constructor(){this.pendingComponents=new Set,this.isScheduled=!1}schedule(t){this.pendingComponents.add(t),this.isScheduled||(this.isScheduled=!0,queueMicrotask(()=>{this.pendingComponents.forEach(t=>t._render()),this.pendingComponents.clear(),this.isScheduled=!1}))}};class B extends HTMLElement{onEachUpdate(t){this.onEachUpdateCallbacks.push(t)}constructor(){super(),this.lastVersion=-1,this.onEachUpdateCallbacks=[],this._isViewLoading=!1,this._props={},this._propsFn=()=>this._props,this._view=null,this._componentFn=null,this._hasMounted=!1,this._renderScheduled=!1,this.componentId=Math.random(),this.cleanups=new Map,this._xviewRender=()=>{}}setter(t){const e=this;return(...n)=>(pt(),V.schedule(e),t(...n))}set props(t){"function"==typeof t?this._propsFn=t:(this._props=t,this._propsFn=()=>this._props),V.schedule(this)}get props(){return this._props}set view(t){if("AsyncFunction"===t.constructor.name||t instanceof Promise)return this._isViewLoading=!0,void("function"==typeof t?t():t).then(t=>{this._isViewLoading=!1,this.view=t.default||t});this.oldView!==t&&(this.oldView=t,this._view=t,this._hasMounted&&(this.cleanups.forEach(t=>t()),this.cleanups.clear(),this._hasMounted=!1),V.schedule(this))}get view(){return this._view}callOnEachUpdate(){this.onEachUpdateCallbacks.forEach(t=>t())}disconnectedCallback(){this.cleanups.forEach(t=>t()),this.cleanups.clear()}addToCleanUps(t,e){this.cleanups.set(t,e)}_render(){if(this._view&&!this._isViewLoading&&!this._renderScheduled){if(!this._hasMounted){const t=this._view;return this._componentFn=F(this,()=>t(this._propsFn,this.setter.bind(this))),void("function"==typeof this._componentFn&&(this._xviewRender=()=>{D=!0;try{if(this.lastVersion===ut)return;const t=F(this,this._componentFn);U(t,this)}catch(t){console.error(t)}finally{D=!1,this.lastVersion=ut}},this.callOnEachUpdate(),this._xviewRender(),this._hasMounted=!0))}this._xviewRender&&(this.callOnEachUpdate(),this._xviewRender())}}}customElements.define("x-view",B);const L=[];function F(t,e){L.push(t);let n=null;try{n=e()}finally{L.pop()}return n}function I(t=!0){const e=L[L.length-1];if(!e){if(t)throw new Error("getCurrentHost(): No active host context");return null}return e}function W(t,e=!0,n){const o=I(e);if(o&&t&&!o.cleanups.has(t)){const e=(n||t.subscribe)?.(()=>{V.schedule(o)});o.addToCleanUps(t,e)}}function q(t){return W(t,!0),t}function z(t){const e=t,n=I();if(!n)throw new Error("useStore must be called inside a component");if("object"!=typeof e||null===e)throw new Error("state must be an object");return[e,t=>{t(e),pt(),V.schedule(n)}]}function J(t,e){ct();const n=I();e.map(e=>e.subscribe(t)).forEach(t=>n.addToCleanUps(e,t))}function K(t){ct();const e=I();queueMicrotask(()=>{try{const n=t();e&&n&&e.addToCleanUps(t,n)}catch(t){console.error(t)}})}function Z(t){let e=null;const n=new CustomEvent("request-context",{bubbles:!0,composed:!0,detail:{contextClass:t,resolve(t){e=t}}});return I().dispatchEvent(n),e}const Y=t=>{ct();I().addToCleanUps(t,t)},G=t=>{if(nt)return et;ct();const e=new Set;try{const n=I(),o=(...o)=>{const s=t(...o);return pt(),e.forEach(t=>t()),n&&V.schedule(n),s};return o.subscribe=t=>(e.add(t),()=>e.delete(t)),o}catch(t){throw new Error("You can only use setter or _ inside a view or component.")}},Q=G,X=t=>{if(ct(),"object"!=typeof t||null===t)throw new Error("state must be an object");const e=I();if(!e)throw new Error("useState must be called inside a component");return[t,t=>(pt(),V.schedule(e),t?.())]},tt=()=>{ct();const t=I();return e=>{e?.(),pt(),V.schedule(t)}};let et,nt=!1;const ot=t=>{nt=t},st=t=>{et=t},rt=()=>nt,it=()=>et,ct=()=>{if(R())throw Error("atoms, units, bubbles, getters, setters and actions can't be created inside the template function, you can create them in view function. Because template function gets called everytime the view updates.")};let lt=!1,at=new Set;function ht(t){let e=null,n=1;ct();const o=()=>{if(e)try{let t=!1;for(const[n,o]of e.storeDeps){if(n.__version__!==o){t=!0;break}}if(!t)for(const[n,o]of e.getterDeps){if(n.areVersionsChanged(o)){t=!0;break}}if(!t)return lt&&at.add(s),e.value}catch(t){console.error(t)}const o=at,r=lt;let i;at=new Set,lt=!0;let c=new Map,l=new Map;try{i=t(),at.forEach(t=>{"function"==typeof t&&"function"==typeof t.areVersionsChanged?l.set(t,t.version):t&&"number"==typeof t.__version__&&c.set(t,t.__version__)}),e={value:i,storeDeps:new Map(c),getterDeps:new Map(l)},n++}catch(t){throw e=null,n++,at=o,lt=r,t}finally{at=o,lt=r,r&&at.add(s)}return i},s=()=>o();return Object.defineProperty(s,"val",{get:()=>o()}),Object.defineProperty(s,"version",{get:()=>n}),Object.defineProperty(s,"areVersionsChanged",{value:t=>{if(!e)return!0;if(void 0!==t){let o=!1;for(const[t,n]of e.storeDeps){if(t.__version__!==n){o=!0;break}}if(!o)for(const[t,n]of e.getterDeps){if(t.areVersionsChanged(n)){o=!0;break}}return!!o||n!==t}for(const[t,n]of e.storeDeps){if(t.__version__!==n)return!0}for(const[t,n]of e.getterDeps){if(t.areVersionsChanged(n))return!0}return!1}}),s}let ut=0;const pt=()=>{ut++};function dt(t,e=!1){ct();let n=t;e&&_t(n);let o=!1,s=new Set,r=!1,i=1;const c=()=>{i++,o||(o=!0,queueMicrotask(()=>{console.log("notify",s.size),[...s].forEach(t=>{try{t?.()}catch(t){console.error(t)}}),o=!1}))},l=()=>(W(a,!1),lt&&at.add(a),n),a=()=>l();return a.get=()=>l(),a.set=t=>{if(r)return;const o="function"==typeof t?t(n):t;n=o,e&&_t(n),pt(),c()},a.update=t=>{if(!r&&"object"==typeof n&&null!==n){if(e)throw new Error("update() is not supported for iAtoms or iAtom with deepFreeze enabled");t(n),pt(),c()}},a.subscribe=t=>(s.add(t),()=>s.delete(t)),a.lock=()=>{r=!0},a.unlock=()=>{r=!1},Object.defineProperty(a,"__isAtom___",{value:!0,writable:!1}),Object.defineProperty(a,"val",{get:()=>a.get()}),Object.defineProperty(a,"__version__",{get:()=>(W(a,!1),i)}),Object.defineProperty(a,"toJSON",{value:()=>JSON.stringify(n)}),Object.defineProperty(a,"__id__",{value:Math.random().toString(36).substring(2,15),writable:!1}),a.select=(t,o=void 0)=>{if(!e)throw Error("select() can only be used with iAtoms");let s=o;try{s=t(n)}catch(t){s=o}const r=()=>s,i=I(),c=a.subscribe(()=>{const e=s;try{s=t(n)}catch(t){s=o}e!==s&&i&&V.schedule(i)});return i&&!i?.cleanups?.has?.(r)&&i?.addToCleanUps?.(r,c),r},a}function ft(t){return dt(t,!0)}function _t(t){try{return Object.keys(t).forEach(e=>{"object"!=typeof t[e]||null===t[e]||Object.isFrozen(t[e])||_t(t[e])}),Object.freeze(t)}catch(t){console.error(t)}}function yt(t,e){let n=t,o=null,s=null,r="init",i=!1,c=null;const l=new Set,a=()=>{l.forEach(t=>{try{t()}catch(t){console.error(t)}})},h=()=>{c&&(c.abort(),c=null),i=!1,r="init",a()},u=t=>{W(p,!1),lt&&at.add(t)},p={getData:()=>(u(p),o),getError:()=>(u(p),s),getStatus:()=>(u(p),r),isLoading:()=>(u(p),i),set(t){n=t},cancel:h,run:async(...t)=>{h(),i=!0,r="loading",c=new AbortController;const l=c;a();try{const h=await n.call(e,...t,l);if(l.signal.aborted||c!==l)return;o=h,s=null,r="success",i=!1,a()}catch(t){if(l.signal.aborted||c!==l)return;o=null,s=t,r="error",i=!1,a()}finally{c===l&&(c=null)}},subscribe:t=>(l.add(t),()=>l.delete(t))};return p}function gt(t,e){let n=t;const o=new Set;let s=null,r=null,i=null,c=null,l=null,a=null,h=null,u=0,p=null,d=null;const f=t=>{o.forEach(e=>{try{e(t)}catch(t){console.error(t)}})},_=(t,e)=>{if(s){return s((...e)=>{const o=n.call(t,...e);return f(o),o},...e)}const o=n.call(t,...e);return f(o),o};function y(...t){const n=this;return e?.debounce?((t,n)=>(r&&clearTimeout(r),i||(i=new Promise(o=>{c=o,r=setTimeout(()=>{const e=_(t,n);o(e),r=null,i=null,c=null},e?.debounce||0)}),i)))(n,t):e?.throttle?((t,n)=>{const o=Date.now(),s=o-u,r=e?.throttle||0;return s>=r?(u=o,_(t,n)):(p=n,d=t,a||(a=new Promise(t=>{h=t,l=setTimeout(()=>{if(p&&d){u=Date.now();const e=_(d,p);t(e),p=null,d=null}l=null,a=null,h=null},r-s)}),a))})(n,t):_(n,t)}return y.subscribe=t=>(o.add(t),()=>o.delete(t)),y.set=t=>{n=t},y.intercept=t=>{s=t},y.cancel=()=>{r&&(clearTimeout(r),r=null),i&&c&&(c(void 0),i=null,c=null),l&&(clearTimeout(l),l=null,u=0,p=null,d=null),a&&h&&(h(void 0),a=null,h=null)},y}const mt=t=>{if(rt())throw new Error("you can't create a bubble in another bubble.");ct(),ot(!0);let e=!1,n=1;const o=t=>(...o)=>{const s=t(...o);return e||(e=!0,queueMicrotask(()=>{e=!1,pt(),n++,r.forEach(t=>t())})),s};st(o);let s=t(o);const r=new Set,i=()=>(W(i,!1),lt&&at.add(i),s());return i.__isBubble___=!0,i.__id__=Math.random().toString(36).substring(2,15),Object.defineProperty(i,"__version__",{get:()=>(W(i,!1),n)}),i.reset=()=>{s=t(o)},i.subscribe=t=>(r.add(t),()=>r.delete(t)),ot(!1),st(null),i},At={get path(){return this.pathAtom.get()},pathAtom:dt(window.location.pathname),navigateTo(t,e){e?window.history.replaceState({},"",t):window.history.pushState({},"",t),this.pathAtom.set(t)},matchPath:t=>vt(t)};window.addEventListener("popstate",()=>{At.pathAtom.set(window.location.pathname)}),window.addEventListener("hashchange",()=>{At.pathAtom.set(window.location.pathname)}),window.addEventListener("navigate",()=>{At.pathAtom.set(window.location.pathname)});const vt=t=>{const e=window.location.pathname;if(e===t)return!0;const n=t.split("/").filter(Boolean),o=e.split("/").filter(Boolean);if(n.length!==o.length)return!1;for(let t=0;t<n.length;t++){const e=n[t],s=o[t];if(e.startsWith(":")){if(!s)return!1}else if(e!==s)return!1}return!0};function bt(t){const e=new Set,n=[Object.prototype,Array.prototype,Function.prototype,String.prototype,Number.prototype,Boolean.prototype,Symbol.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Promise.prototype,Error.prototype];for(;t&&!n.includes(t);){for(const n of Reflect.ownKeys(t))"constructor"!==n&&e.add(n);t=Object.getPrototypeOf(t)}return Array.from(e)}const wt=function(t){if("function"!=typeof t)throw Error("molecule must be a class");let e=new t;bt(e).forEach(t=>{if("function"==typeof e[t]){const n=e[t];e[t]=gt((...t)=>n.apply(e,t))}});const n=()=>e;return n.reset=()=>{const n=new t;bt(n).forEach(t=>{const o=n[t];o.__isAtom___||o.__isUnit___?e[t].set(o()):o.__isBubble___?e[t].reset():e[t]=o})},n},$t=(t,e)=>{const n=I();if(!n)throw new Error("refEffect must be called inside a component");let o=[];t(),o=e(),n.onEachUpdate(()=>{const n=e();o.some((t,e)=>t!==n[e])&&(t(),o=n)})};function Et(t){const e=new Set,n=[Object.prototype,Array.prototype,Function.prototype,String.prototype,Number.prototype,Boolean.prototype,Symbol.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Promise.prototype,Error.prototype];for(;t&&!n.includes(t);){for(const n of Reflect.ownKeys(t))"constructor"!==n&&e.add(n);t=Object.getPrototypeOf(t)}return Array.from(e)}const xt=function(t){if(null===t||"object"!=typeof t)throw Error("unit must be an object");ct();const e=Et(t),n=()=>(W(n,!1),lt&&at.add(n),t),o=new Set;n.__isUnit___=!0,Object.defineProperty(n,"__version__",{get:()=>(W(n,!1),1)}),n.subscribe=t=>(o.add(t),()=>{o.delete(t)});let s=!1;return e.forEach(e=>{const n=Object.getOwnPropertyDescriptor(t,e);if(n&&n.get&&"function"==typeof n.get){const o=n.get,s=ht(()=>o.call(t));Object.defineProperty(t,e,{get:function(){return s()},enumerable:n.enumerable,configurable:n.configurable})}if("function"==typeof t[e]&&e.toString().startsWith("_")){const n=t[e];if("AsyncFunction"===n.constructor.name)throw new Error("Async method's name can't start with _. you can use "+e.toString().replace(/^_/,"")+" instead and move set operations to a setter function");t[e]=function(...e){const r=n.apply(t,e);return function(){try{s||(s=!0,queueMicrotask(()=>{pt(),o.forEach(t=>t())}),s=!1)}catch(t){"production"!==process?.env?.NODE_ENV&&console.error(t)}}(),r}}}),Object.preventExtensions(t),n};class St extends HTMLElement{constructor(){super(...arguments),this._onRequestContext=t=>{const e=t,n=e.detail?.contextClass;if(!n||null==this._value)return;this._value.constructor===n&&(e.stopPropagation(),e.detail.resolve(this._value))}}connectedCallback(){this.addEventListener("request-context",this._onRequestContext)}disconnectedCallback(){this.removeEventListener("request-context",this._onRequestContext)}set value(t){this._value=t}get value(){return this._value}}customElements.define("x-provider",St);const Mt=(t,e={})=>A`<x-view .view=${t} .props=${()=>e}></x-view>`,Ct=(t,e)=>{const n=document.getElementById(e);if(!n)throw new Error(`Element with id ${e} not found`);return U(Mt(t,{}),n)};export{G as _,gt as action,yt as asyncAtom,dt as atom,mt as bubble,_t as df,I as getCurrentHost,Et as getStoreProps,R as getTemplateIsRunning,rt as getbubbleInProgress,it as getbubblesSetter,ht as getter,V as globalScheduler,ut as globalVersion,ft as iAtom,pt as incrGlobalVersion,vt as isPathMatching,At as location,wt as molecule,Ct as renderView,ct as safetyCheck,ot as setBubbleInProgress,st as setBubblesSetter,Q as setter,W as subscribe,xt as unit,Z as useContext,tt as useForceUpdate,z as useMutable,K as useOnMount,Y as useOnUnmount,$t as useRefEffect,X as useState,q as useStore,J as useSubscribe,tt as useUpdate,Mt as view,F as withHost};
6
+ const t=globalThis,e=t.trustedTypes,s=e?e.createPolicy("lit-html",{createHTML:t=>t}):void 0,n="$lit$",o=`lit$${Math.random().toFixed(9).slice(2)}$`,i="?"+o,r=`<${i}>`,c=document,l=()=>c.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,h=Array.isArray,u=t=>h(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",p=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,f=/-->/g,_=/>/g,$=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),y=/'/g,A=/"/g,v=/^(?:script|style|textarea|title)$/i,g=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),m=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),b=new WeakMap,C=c.createTreeWalker(c,129);function E(t,e){if(!h(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(e):e}const x=(t,e)=>{const s=t.length-1,i=[];let c,l=2===e?"<svg>":3===e?"<math>":"",a=p;for(let e=0;e<s;e++){const s=t[e];let h,u,d=-1,g=0;for(;g<s.length&&(a.lastIndex=g,u=a.exec(s),null!==u);)g=a.lastIndex,a===p?"!--"===u[1]?a=f:void 0!==u[1]?a=_:void 0!==u[2]?(v.test(u[2])&&(c=RegExp("</"+u[2],"g")),a=$):void 0!==u[3]&&(a=$):a===$?">"===u[0]?(a=c??p,d=-1):void 0===u[1]?d=-2:(d=a.lastIndex-u[2].length,h=u[1],a=void 0===u[3]?$:'"'===u[3]?A:y):a===A||a===y?a=$:a===f||a===_?a=p:(a=$,c=void 0);const m=a===$&&t[e+1].startsWith("/>")?" ":"";l+=a===p?s+r:d>=0?(i.push(h),s.slice(0,d)+n+s.slice(d)+o+m):s+o+(-2===d?e:m)}return[E(t,l+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class S{constructor({strings:t,_$litType$:s},r){let c;this.parts=[];let a=0,h=0;const u=t.length-1,d=this.parts,[p,f]=x(t,s);if(this.el=S.createElement(p,r),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(c=C.nextNode())&&d.length<u;){if(1===c.nodeType){if(c.hasAttributes())for(const t of c.getAttributeNames())if(t.endsWith(n)){const e=f[h++],s=c.getAttribute(t).split(o),n=/([.?@])?(.*)/.exec(e);d.push({type:1,index:a,name:n[2],strings:s,ctor:"."===n[1]?H:"?"===n[1]?j:"@"===n[1]?k:O}),c.removeAttribute(t)}else t.startsWith(o)&&(d.push({type:6,index:a}),c.removeAttribute(t));if(v.test(c.tagName)){const t=c.textContent.split(o),s=t.length-1;if(s>0){c.textContent=e?e.emptyScript:"";for(let e=0;e<s;e++)c.append(t[e],l()),C.nextNode(),d.push({type:2,index:++a});c.append(t[s],l())}}}else if(8===c.nodeType)if(c.data===i)d.push({type:2,index:a});else{let t=-1;for(;-1!==(t=c.data.indexOf(o,t+1));)d.push({type:7,index:a}),t+=o.length-1}a++}}static createElement(t,e){const s=c.createElement("template");return s.innerHTML=t,s}}function M(t,e,s=t,n){if(e===m)return e;let o=void 0!==n?s._$Co?.[n]:s._$Cl;const i=a(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),void 0===i?o=void 0:(o=new i(t),o._$AT(t,s,n)),void 0!==n?(s._$Co??=[])[n]=o:s._$Cl=o),void 0!==o&&(e=M(t,o._$AS(t,e.values),o,n)),e}let T=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,n=(t?.creationScope??c).importNode(e,!0);C.currentNode=n;let o=C.nextNode(),i=0,r=0,l=s[0];for(;void 0!==l;){if(i===l.index){let e;2===l.type?e=new N(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new P(o,this,t)),this._$AV.push(e),l=s[++r]}i!==l?.index&&(o=C.nextNode(),i++)}return C.currentNode=c,n}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}};class N{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=M(this,t,e),a(t)?t===w||null==t||""===t?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==m&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==w&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(c.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,n="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=S.createElement(E(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new T(n,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=b.get(t.strings);return void 0===e&&b.set(t.strings,e=new S(t)),e}k(t){h(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,n=0;for(const o of t)n===e.length?e.push(s=new N(this.O(l()),this.O(l()),this,this.options)):s=e[n],s._$AI(o),n++;n<e.length&&(this._$AR(s&&s._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class O{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=w}_$AI(t,e=this,s,n){const o=this.strings;let i=!1;if(void 0===o)t=M(this,t,e,0),i=!a(t)||t!==this._$AH&&t!==m,i&&(this._$AH=t);else{const n=t;let r,c;for(t=o[0],r=0;r<o.length-1;r++)c=M(this,n[s+r],e,r),c===m&&(c=this._$AH[r]),i||=!a(c)||c!==this._$AH[r],c===w?t=w:t!==w&&(t+=(c??"")+o[r+1]),this._$AH[r]=c}i&&!n&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class H extends O{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}}class j extends O{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}}class k extends O{constructor(t,e,s,n,o){super(t,e,s,n,o),this.type=5}_$AI(t,e=this){if((t=M(this,t,e,0)??w)===m)return;const s=this._$AH,n=t===w&&s!==w||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==w&&(s===w||n);n&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class P{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t)}}const U={M:n,P:o,A:i,C:1,L:x,R:T,D:u,V:M,I:N,H:O,N:j,U:k,B:H,F:P},V=t.litHtmlPolyfillSupport;V?.(S,N),(t.litHtmlVersions??=[]).push("3.3.1");const B=(t,e,s)=>{const n=s?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=s?.renderBefore??null;n._$litPart$=o=new N(e.insertBefore(l(),t),t,void 0,s??{})}return o._$AI(t),o};let D=!1;const R=()=>D;const L=new class{constructor(){this.pendingComponents=new Set,this.isScheduled=!1}schedule(t){this.pendingComponents.add(t),this.isScheduled||(this.isScheduled=!0,queueMicrotask(()=>{this.pendingComponents.forEach(t=>t._render()),this.pendingComponents.clear(),this.isScheduled=!1}))}};class F extends HTMLElement{onEachUpdate(t){this.onEachUpdateCallbacks.push(t)}constructor(){super(),this.lastVersion=-1,this.onEachUpdateCallbacks=[],this._isViewLoading=!1,this._props={},this._propsFn=()=>this._props,this._view=null,this._componentFn=null,this._hasMounted=!1,this._renderScheduled=!1,this.componentId=Math.random(),this.cleanups=new Map,this._xviewRender=()=>{}}setter(t){const e=this;return(...s)=>(ft(),L.schedule(e),t(...s))}set props(t){"function"==typeof t?this._propsFn=t:(this._props=t,this._propsFn=()=>this._props),L.schedule(this)}get props(){return this._props}set view(t){if("AsyncFunction"===t.constructor.name||t instanceof Promise)return this._isViewLoading=!0,void("function"==typeof t?t():t).then(t=>{this._isViewLoading=!1,this.view=t.default||t});this.oldView!==t&&(this.oldView=t,this._view=t,this._hasMounted&&(this.cleanups.forEach(t=>t()),this.cleanups.clear(),this._hasMounted=!1),L.schedule(this))}get view(){return this._view}callOnEachUpdate(){this.onEachUpdateCallbacks.forEach(t=>t())}disconnectedCallback(){this.cleanups.forEach(t=>t()),this.cleanups.clear()}addToCleanUps(t,e){this.cleanups.set(t,e)}_render(){if(this._view&&!this._isViewLoading&&!this._renderScheduled){if(!this._hasMounted){const t=this._view;return this._componentFn=W(this,()=>t(this._propsFn,this.setter.bind(this))),void("function"==typeof this._componentFn&&(this._xviewRender=()=>{D=!0;try{if(this.lastVersion===pt)return;const t=W(this,this._componentFn);B(t,this)}catch(t){console.error(t)}finally{D=!1,this.lastVersion=pt}},this.callOnEachUpdate(),this._xviewRender(),this._hasMounted=!0))}this._xviewRender&&(this.callOnEachUpdate(),this._xviewRender())}}}customElements.define("x-view",F);const I=[];function W(t,e){I.push(t);let s=null;try{s=e()}finally{I.pop()}return s}function q(t=!0){const e=I[I.length-1];if(!e){if(t)throw new Error("getCurrentHost(): No active host context");return null}return e}function K(t,e=!0,s){const n=q(e);if(n&&t&&!n.cleanups.has(t)){const e=(s||t.subscribe)?.(()=>{L.schedule(n)});n.addToCleanUps(t,e)}}function z(t){return K(t,!0),t}function X(t){const e=t,s=q();if(!s)throw new Error("useStore must be called inside a component");if("object"!=typeof e||null===e)throw new Error("state must be an object");return[e,t=>{t(e),ft(),L.schedule(s)}]}function Z(t,e){at();const s=q();e.map(e=>e.subscribe(t)).forEach(t=>s.addToCleanUps(e,t))}function J(t){at();const e=q();queueMicrotask(()=>{try{const s=t();e&&s&&e.addToCleanUps(t,s)}catch(t){console.error(t)}})}function Y(t){let e=null;const s=new CustomEvent("request-context",{bubbles:!0,composed:!0,detail:{contextClass:t,resolve(t){e=t}}});return q().dispatchEvent(s),e}const G=t=>{at();q().addToCleanUps(t,t)},Q=t=>{if(ot)return nt;at();const e=new Set;try{const s=q(),n=(...n)=>{const o=t(...n);return ft(),e.forEach(t=>t()),s&&L.schedule(s),o};return n.subscribe=t=>(e.add(t),()=>e.delete(t)),n}catch(t){throw new Error("You can only use setter or _ inside a view or component.")}},tt=Q,et=t=>{if(at(),"object"!=typeof t||null===t)throw new Error("state must be an object");const e=q();if(!e)throw new Error("useState must be called inside a component");return[t,t=>(ft(),L.schedule(e),t?.())]},st=()=>{at();const t=q();return e=>{e?.(),ft(),L.schedule(t)}};let nt,ot=!1;const it=t=>{ot=t},rt=t=>{nt=t},ct=()=>ot,lt=()=>nt,at=()=>{if(R())throw Error("atoms, units, bubbles, getters, setters and actions can't be created inside the template function, you can create them in view function. Because template function gets called everytime the view updates.")};let ht=!1,ut=new Set;function dt(t){let e=null,s=1;at();const n=()=>{if(e)try{let t=!1;for(const[s,n]of e.storeDeps){if(s.__version__!==n){t=!0;break}}if(!t)for(const[s,n]of e.getterDeps){if(s.areVersionsChanged(n)){t=!0;break}}if(!t)return ht&&ut.add(o),e.value}catch(t){console.error(t)}const n=ut,i=ht;let r;ut=new Set,ht=!0;let c=new Map,l=new Map;try{r=t(),ut.forEach(t=>{"function"==typeof t&&"function"==typeof t.areVersionsChanged?l.set(t,t.version):t&&"number"==typeof t.__version__&&c.set(t,t.__version__)}),e={value:r,storeDeps:new Map(c),getterDeps:new Map(l)},s++}catch(t){throw e=null,s++,ut=n,ht=i,t}finally{ut=n,ht=i,i&&ut.add(o)}return r},o=()=>n();return Object.defineProperty(o,"val",{get:()=>n()}),Object.defineProperty(o,"version",{get:()=>s}),Object.defineProperty(o,"areVersionsChanged",{value:t=>{if(!e)return!0;if(void 0!==t){let n=!1;for(const[t,s]of e.storeDeps){if(t.__version__!==s){n=!0;break}}if(!n)for(const[t,s]of e.getterDeps){if(t.areVersionsChanged(s)){n=!0;break}}return!!n||s!==t}for(const[t,s]of e.storeDeps){if(t.__version__!==s)return!0}for(const[t,s]of e.getterDeps){if(t.areVersionsChanged(s))return!0}return!1}}),o}let pt=0;const ft=()=>{pt++};function _t(t,e=!1){at();let s=t;e&&yt(s);let n=!1,o=new Set,i=!1,r=1;const c=()=>{r++,n||(n=!0,queueMicrotask(()=>{console.log("notify",o.size),[...o].forEach(t=>{try{t?.()}catch(t){console.error(t)}}),n=!1}))},l=()=>(K(a,!1),ht&&ut.add(a),s),a=()=>l();return a.get=()=>l(),a.set=t=>{if(i)return;const n="function"==typeof t?t(s):t;s=n,e&&yt(s),ft(),c()},a.update=t=>{if(!i&&"object"==typeof s&&null!==s){if(e)throw new Error("update() is not supported for iAtoms or iAtom with deepFreeze enabled");t(s),ft(),c()}},a.subscribe=t=>(o.add(t),()=>o.delete(t)),a.lock=()=>{i=!0},a.unlock=()=>{i=!1},Object.defineProperty(a,"__isAtom___",{value:!0,writable:!1}),Object.defineProperty(a,"val",{get:()=>a.get()}),Object.defineProperty(a,"__version__",{get:()=>(K(a,!1),r)}),Object.defineProperty(a,"toJSON",{value:()=>JSON.stringify(s)}),Object.defineProperty(a,"__id__",{value:Math.random().toString(36).substring(2,15),writable:!1}),a.select=(t,n=void 0)=>{if(!e)throw Error("select() can only be used with iAtoms");let o=n;try{o=t(s)}catch(t){o=n}const i=()=>o,r=q(),c=a.subscribe(()=>{const e=o;try{o=t(s)}catch(t){o=n}e!==o&&r&&L.schedule(r)});return r&&!r?.cleanups?.has?.(i)&&r?.addToCleanUps?.(i,c),i},a}function $t(t){return _t(t,!0)}function yt(t){try{return Object.keys(t).forEach(e=>{"object"!=typeof t[e]||null===t[e]||Object.isFrozen(t[e])||yt(t[e])}),Object.freeze(t)}catch(t){console.error(t)}}function At(t,e){let s=t,n=null,o=null,i="init",r=!1,c=null;const l=new Set,a=()=>{l.forEach(t=>{try{t()}catch(t){console.error(t)}})},h=()=>{c&&(c.abort(),c=null),r=!1,i="init",a()},u=t=>{K(d,!1),ht&&ut.add(t)},d={getData:()=>(u(d),n),getError:()=>(u(d),o),getStatus:()=>(u(d),i),isLoading:()=>(u(d),r),set(t){s=t},cancel:h,run:async(...t)=>{h(),r=!0,i="loading",c=new AbortController;const l=c;a();try{const h=await s.call(e,...t,l);if(l.signal.aborted||c!==l)return;n=h,o=null,i="success",r=!1,a()}catch(t){if(l.signal.aborted||c!==l)return;n=null,o=t,i="error",r=!1,a()}finally{c===l&&(c=null)}},subscribe:t=>(l.add(t),()=>l.delete(t))};return d}function vt(t,e){let s=t;const n=new Set;let o=null,i=null,r=null,c=null,l=null,a=null,h=null,u=0,d=null,p=null;const f=t=>{n.forEach(e=>{try{e(t)}catch(t){console.error(t)}})},_=(t,e)=>{if(o){return o((...e)=>{const n=s.call(t,...e);return f(n),n},...e)}const n=s.call(t,...e);return f(n),n};function $(...t){const s=this;return e?.debounce?((t,s)=>(i&&clearTimeout(i),r||(r=new Promise(n=>{c=n,i=setTimeout(()=>{const e=_(t,s);n(e),i=null,r=null,c=null},e?.debounce||0)}),r)))(s,t):e?.throttle?((t,s)=>{const n=Date.now(),o=n-u,i=e?.throttle||0;return o>=i?(u=n,_(t,s)):(d=s,p=t,a||(a=new Promise(t=>{h=t,l=setTimeout(()=>{if(d&&p){u=Date.now();const e=_(p,d);t(e),d=null,p=null}l=null,a=null,h=null},i-o)}),a))})(s,t):_(s,t)}return $.subscribe=t=>(n.add(t),()=>n.delete(t)),$.set=t=>{s=t},$.intercept=t=>{o=t},$.cancel=()=>{i&&(clearTimeout(i),i=null),r&&c&&(c(void 0),r=null,c=null),l&&(clearTimeout(l),l=null,u=0,d=null,p=null),a&&h&&(h(void 0),a=null,h=null)},$}const gt=t=>{if(ct())throw new Error("you can't create a bubble in another bubble.");at(),it(!0);let e=!1,s=1;const n=t=>(...n)=>{const o=t(...n);return e||(e=!0,queueMicrotask(()=>{e=!1,ft(),s++,i.forEach(t=>t())})),o};rt(n);let o=t(n);const i=new Set,r=()=>(K(r,!1),ht&&ut.add(r),o());return r.__isBubble___=!0,r.__id__=Math.random().toString(36).substring(2,15),Object.defineProperty(r,"__version__",{get:()=>(K(r,!1),s)}),r.reset=()=>{o=t(n)},r.subscribe=t=>(i.add(t),()=>i.delete(t)),it(!1),rt(null),r},mt={get path(){return this.pathAtom.get()},pathAtom:_t(window.location.pathname),navigateTo(t,e){e?window.history.replaceState({},"",t):window.history.pushState({},"",t),this.pathAtom.set(t)},matchPath:t=>wt(t)};window.addEventListener("popstate",()=>{mt.pathAtom.set(window.location.pathname)}),window.addEventListener("hashchange",()=>{mt.pathAtom.set(window.location.pathname)}),window.addEventListener("navigate",()=>{mt.pathAtom.set(window.location.pathname)});const wt=t=>{const e=window.location.pathname;if(e===t)return!0;const s=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(s.length!==n.length)return!1;for(let t=0;t<s.length;t++){const e=s[t],o=n[t];if(e.startsWith(":")){if(!o)return!1}else if(e!==o)return!1}return!0};function bt(t){const e=new Set,s=[Object.prototype,Array.prototype,Function.prototype,String.prototype,Number.prototype,Boolean.prototype,Symbol.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Promise.prototype,Error.prototype];for(;t&&!s.includes(t);){for(const s of Reflect.ownKeys(t))"constructor"!==s&&e.add(s);t=Object.getPrototypeOf(t)}return Array.from(e)}const Ct=function(t){if("function"!=typeof t)throw Error("molecule must be a class");let e=new t;bt(e).forEach(t=>{if("function"==typeof e[t]){const s=e[t];e[t]=vt((...t)=>s.apply(e,t))}});const s=()=>e;return s.reset=()=>{const s=new t;bt(s).forEach(t=>{const n=s[t];n.__isAtom___||n.__isUnit___?e[t].set(n()):n.__isBubble___?e[t].reset():e[t]=n})},s},Et=(t,e)=>{const s=q();if(!s)throw new Error("refEffect must be called inside a component");let n=[];t(),n=e(),s.onEachUpdate(()=>{const s=e();n.some((t,e)=>t!==s[e])&&(t(),n=s)})};function xt(t){const e=new Set,s=[Object.prototype,Array.prototype,Function.prototype,String.prototype,Number.prototype,Boolean.prototype,Symbol.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Promise.prototype,Error.prototype];for(;t&&!s.includes(t);){for(const s of Reflect.ownKeys(t))"constructor"!==s&&e.add(s);t=Object.getPrototypeOf(t)}return Array.from(e)}const St=function(t){if(null===t||"object"!=typeof t)throw Error("unit must be an object");at();const e=xt(t),s=()=>(K(s,!1),ht&&ut.add(s),t),n=new Set;s.__isUnit___=!0,Object.defineProperty(s,"__version__",{get:()=>(K(s,!1),1)}),s.subscribe=t=>(n.add(t),()=>{n.delete(t)});let o=!1;return e.forEach(e=>{const s=Object.getOwnPropertyDescriptor(t,e);if(s&&s.get&&"function"==typeof s.get){const n=s.get,o=dt(()=>n.call(t));Object.defineProperty(t,e,{get:function(){return o()},enumerable:s.enumerable,configurable:s.configurable})}if("function"==typeof t[e]&&e.toString().startsWith("_")){const s=t[e];if("AsyncFunction"===s.constructor.name)throw new Error("Async method's name can't start with _. you can use "+e.toString().replace(/^_/,"")+" instead and move set operations to a setter function");t[e]=function(...e){const i=s.apply(t,e);return function(){try{o||(o=!0,queueMicrotask(()=>{ft(),n.forEach(t=>t())}),o=!1)}catch(t){"production"!==process?.env?.NODE_ENV&&console.error(t)}}(),i}}}),Object.preventExtensions(t),s};class Mt extends HTMLElement{constructor(){super(...arguments),this._onRequestContext=t=>{const e=t,s=e.detail?.contextClass;if(!s||null==this._value)return;this._value.constructor===s&&(e.stopPropagation(),e.detail.resolve(this._value))}}connectedCallback(){this.addEventListener("request-context",this._onRequestContext)}disconnectedCallback(){this.removeEventListener("request-context",this._onRequestContext)}set value(t){this._value=t}get value(){return this._value}}customElements.define("x-provider",Mt);const Tt=(t,e={})=>g`<x-view .view=${t} .props=${()=>e}></x-view>`,Nt=(t,e)=>{const s=document.getElementById(e);if(!s)throw new Error(`Element with id ${e} not found`);return B(Tt(t,{}),s)},Ot=1,Ht=2,jt=3,kt=4,Pt=t=>(...e)=>({_$litDirective$:t,values:e});let Ut=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
7
+ /**
8
+ * @license
9
+ * Copyright 2020 Google LLC
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ */const{I:Vt}=U,Bt=(t,e)=>void 0===e?void 0!==t?._$litType$:t?._$litType$===e,Dt=t=>void 0===t.strings,Rt=()=>document.createComment(""),Lt=(t,e,s)=>{const n=t._$AA.parentNode,o=void 0===e?t._$AB:e._$AA;if(void 0===s){const e=n.insertBefore(Rt(),o),i=n.insertBefore(Rt(),o);s=new Vt(e,i,t,t.options)}else{const e=s._$AB.nextSibling,i=s._$AM,r=i!==t;if(r){let e;s._$AQ?.(t),s._$AM=t,void 0!==s._$AP&&(e=t._$AU)!==i._$AU&&s._$AP(e)}if(e!==o||r){let t=s._$AA;for(;t!==e;){const e=t.nextSibling;n.insertBefore(t,o),t=e}}}return s},Ft=(t,e,s=t)=>(t._$AI(e,s),t),It={},Wt=(t,e=It)=>t._$AH=e,qt=t=>t._$AH,Kt=t=>{t._$AR(),t._$AA.remove()},zt=t=>{t._$AR()},Xt=(t,e,s)=>{const n=new Map;for(let o=e;o<=s;o++)n.set(t[o],o);return n},Zt=Pt(class extends Ut{constructor(t){if(super(t),t.type!==Ht)throw Error("repeat() can only be used in text expressions")}dt(t,e,s){let n;void 0===s?s=e:void 0!==e&&(n=e);const o=[],i=[];let r=0;for(const e of t)o[r]=n?n(e,r):r,i[r]=s(e,r),r++;return{values:i,keys:o}}render(t,e,s){return this.dt(t,e,s).values}update(t,[e,s,n]){const o=qt(t),{values:i,keys:r}=this.dt(e,s,n);if(!Array.isArray(o))return this.ut=r,i;const c=this.ut??=[],l=[];let a,h,u=0,d=o.length-1,p=0,f=i.length-1;for(;u<=d&&p<=f;)if(null===o[u])u++;else if(null===o[d])d--;else if(c[u]===r[p])l[p]=Ft(o[u],i[p]),u++,p++;else if(c[d]===r[f])l[f]=Ft(o[d],i[f]),d--,f--;else if(c[u]===r[f])l[f]=Ft(o[u],i[f]),Lt(t,l[f+1],o[u]),u++,f--;else if(c[d]===r[p])l[p]=Ft(o[d],i[p]),Lt(t,o[u],o[d]),d--,p++;else if(void 0===a&&(a=Xt(r,p,f),h=Xt(c,u,d)),a.has(c[u]))if(a.has(c[d])){const e=h.get(r[p]),s=void 0!==e?o[e]:null;if(null===s){const e=Lt(t,o[u]);Ft(e,i[p]),l[p]=e}else l[p]=Ft(s,i[p]),Lt(t,o[u],s),o[e]=null;p++}else Kt(o[d]),d--;else Kt(o[u]),u++;for(;p<=f;){const e=Lt(t,l[f+1]);Ft(e,i[p]),l[p++]=e}for(;u<=d;){const t=o[u++];null!==t&&Kt(t)}return this.ut=r,Wt(t,l),m}}),Jt={},Yt=Pt(class extends Ut{constructor(){super(...arguments),this.ot=Jt}render(t,e){return e()}update(t,[e,s]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((t,e)=>t===this.ot[e]))return m}else if(this.ot===e)return m;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,s)}}),Gt="important",Qt=" !"+Gt,te=Pt(class extends Ut{constructor(t){if(super(t),t.type!==Ot||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,s)=>{const n=t[s];return null==n?e:e+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`},"")}update(t,[e]){const{style:s}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ft.add(t);const e="string"==typeof n&&n.endsWith(Qt);t.includes("-")||e?s.setProperty(t,e?n.slice(0,-11):n,e?Gt:""):s[t]=n}}return m}}),ee=Pt(class extends Ut{constructor(t){if(super(t),t.type!==Ot||"class"!==t.name||t.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in e)e[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(e)}const s=t.element.classList;for(const t of this.st)t in e||(s.remove(t),this.st.delete(t));for(const t in e){const n=!!e[t];n===this.st.has(t)||this.nt?.has(t)||(n?(s.add(t),this.st.add(t)):(s.remove(t),this.st.delete(t)))}return m}});
12
+ /**
13
+ * @license
14
+ * Copyright 2017 Google LLC
15
+ * SPDX-License-Identifier: BSD-3-Clause
16
+ */
17
+ /**
18
+ * @license
19
+ * Copyright 2021 Google LLC
20
+ * SPDX-License-Identifier: BSD-3-Clause
21
+ */
22
+ function se(t,e,s){return t?e(t):s?.(t)}
23
+ /**
24
+ * @license
25
+ * Copyright 2018 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */const ne=t=>t??w,oe=Pt(class extends Ut{constructor(t){if(super(t),t.type!==jt&&t.type!==Ot&&t.type!==kt)throw Error("The `live` directive is not allowed on child or event bindings");if(!Dt(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===m||e===w)return e;const s=t.element,n=t.name;if(t.type===jt){if(e===s[n])return m}else if(t.type===kt){if(!!e===s.hasAttribute(n))return m}else if(t.type===Ot&&s.getAttribute(n)===e+"")return m;return Wt(t),e}}),ie=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),ie(t,e);return!0},re=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},ce=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(void 0===s)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),he(e)}};
28
+ /**
29
+ * @license
30
+ * Copyright 2020 Google LLC
31
+ * SPDX-License-Identifier: BSD-3-Clause
32
+ */function le(t){void 0!==this._$AN?(re(this),this._$AM=t,ce(this)):this._$AM=t}function ae(t,e=!1,s=0){const n=this._$AH,o=this._$AN;if(void 0!==o&&0!==o.size)if(e)if(Array.isArray(n))for(let t=s;t<n.length;t++)ie(n[t],!1),re(n[t]);else null!=n&&(ie(n,!1),re(n));else ie(this,t)}const he=t=>{t.type==Ht&&(t._$AP??=ae,t._$AQ??=le)};class ue extends Ut{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),ce(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ie(this,t),re(this))}setValue(t){if(Dt(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}
33
+ /**
34
+ * @license
35
+ * Copyright 2021 Google LLC
36
+ * SPDX-License-Identifier: BSD-3-Clause
37
+ */class de{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}}let pe=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(t=>this.Z=t)}resume(){this.Z?.(),this.Y=this.Z=void 0}};
38
+ /**
39
+ * @license
40
+ * Copyright 2017 Google LLC
41
+ * SPDX-License-Identifier: BSD-3-Clause
42
+ */const fe=t=>!(t=>null===t||"object"!=typeof t&&"function"!=typeof t)(t)&&"function"==typeof t.then,_e=1073741823;const $e=Pt(class extends ue{constructor(){super(...arguments),this._$Cwt=_e,this._$Cbt=[],this._$CK=new de(this),this._$CX=new pe}render(...t){return t.find(t=>!fe(t))??m}update(t,e){const s=this._$Cbt;let n=s.length;this._$Cbt=e;const o=this._$CK,i=this._$CX;this.isConnected||this.disconnected();for(let t=0;t<e.length&&!(t>this._$Cwt);t++){const r=e[t];if(!fe(r))return this._$Cwt=t,r;t<n&&r===s[t]||(this._$Cwt=_e,n=0,Promise.resolve(r).then(async t=>{for(;i.get();)await i.get();const e=o.deref();if(void 0!==e){const s=e._$Cbt.indexOf(r);s>-1&&s<e._$Cwt&&(e._$Cwt=s,e.setValue(t))}}))}return m}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}),ye=Pt(class extends Ut{constructor(){super(...arguments),this.key=w}render(t,e){return this.key=t,e}update(t,[e,s]){return e!==this.key&&(Wt(t),this.key=e),s}}),Ae=t=>(t=>null!=t?._$litType$?.h)(t)?t._$litType$.h:t.strings,ve=Pt(class extends Ut{constructor(t){super(t),this.et=new WeakMap}render(t){return[t]}update(t,[e]){const s=Bt(this.it)?Ae(this.it):null,n=Bt(e)?Ae(e):null;if(null!==s&&(null===n||s!==n)){const e=qt(t).pop();let n=this.et.get(s);if(void 0===n){const t=document.createDocumentFragment();n=B(w,t),n.setConnected(!1),this.et.set(s,n)}Wt(n,[e]),Lt(n,void 0,e)}if(null!==n){if(null===s||s!==n){const e=this.et.get(n);if(void 0!==e){const s=qt(e).pop();zt(t),Lt(t,void 0,s),Wt(t,[s])}}this.it=e}else this.it=void 0;return this.render(e)}});
43
+ /**
44
+ * @license
45
+ * Copyright 2021 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */
48
+ /**
49
+ * @license
50
+ * Copyright 2017 Google LLC
51
+ * SPDX-License-Identifier: BSD-3-Clause
52
+ */
53
+ let ge=class extends ue{constructor(){super(...arguments),this._$CK=new de(this),this._$CX=new pe}render(t,e){return m}update(t,[e,s]){if(this.isConnected||this.disconnected(),e===this._$CJ)return m;this._$CJ=e;let n=0;const{_$CK:o,_$CX:i}=this;return(async(t,e)=>{for await(const s of t)if(!1===await e(s))return})(e,async t=>{for(;i.get();)await i.get();const r=o.deref();if(void 0!==r){if(r._$CJ!==e)return!1;void 0!==s&&(t=s(t,n)),r.commitValue(t,n),n++}return!0}),m}commitValue(t,e){this.setValue(t)}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}};const me=Pt(ge);
54
+ /**
55
+ * @license
56
+ * Copyright 2021 Google LLC
57
+ * SPDX-License-Identifier: BSD-3-Clause
58
+ */function*we(t,e){const s="function"==typeof e;if(void 0!==t){let n=-1;for(const o of t)n>-1&&(yield s?e(n):e),n++,yield o}}
59
+ /**
60
+ * @license
61
+ * Copyright 2021 Google LLC
62
+ * SPDX-License-Identifier: BSD-3-Clause
63
+ */function*be(t,e,s=1){const n=void 0===e?0:t;e??=t;for(let t=n;s>0?t<e:e<t;t+=s)yield t}
64
+ /**
65
+ * @license
66
+ * Copyright 2017 Google LLC
67
+ * SPDX-License-Identifier: BSD-3-Clause
68
+ */const Ce=Pt(class extends ge{constructor(t){if(super(t),t.type!==Ht)throw Error("asyncAppend can only be used in child expressions")}update(t,e){return this._$Ctt=t,super.update(t,e)}commitValue(t,e){0===e&&zt(this._$Ctt);const s=Lt(this._$Ctt);Ft(s,t)}});export{Q as _,vt as action,Ce as asyncAppend,At as asyncAtom,me as asyncReplace,_t as atom,gt as bubble,ve as cache,ee as classMap,yt as df,q as getCurrentHost,xt as getStoreProps,R as getTemplateIsRunning,ct as getbubbleInProgress,lt as getbubblesSetter,dt as getter,L as globalScheduler,pt as globalVersion,Yt as guard,g as html,$t as iAtom,ne as ifDefined,ft as incrGlobalVersion,wt as isPathMatching,we as join,ye as keyed,oe as live,mt as location,Ct as molecule,be as range,B as render,Nt as renderView,Zt as repeat,at as safetyCheck,it as setBubbleInProgress,rt as setBubblesSetter,tt as setter,te as styleMap,K as subscribe,St as unit,$e as until,Y as useContext,st as useForceUpdate,X as useMutable,J as useOnMount,G as useOnUnmount,Et as useRefEffect,et as useState,z as useStore,Z as useSubscribe,st as useUpdate,Tt as view,se as when,W as withHost};
7
69
  //# sourceMappingURL=index.esm.js.map