@akashjs/runtime 0.1.1 → 0.1.3
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 +21 -0
- package/dist/animate.cjs +2 -0
- package/dist/animate.cjs.map +1 -0
- package/dist/animate.js +2 -0
- package/dist/animate.js.map +1 -0
- package/dist/chunk-24I477TY.js +32 -0
- package/dist/chunk-24I477TY.js.map +1 -0
- package/dist/chunk-2PUQBTK5.cjs +5 -0
- package/dist/chunk-2PUQBTK5.cjs.map +1 -0
- package/dist/chunk-2X7GUBTG.cjs +2 -0
- package/dist/chunk-2X7GUBTG.cjs.map +1 -0
- package/dist/chunk-3HWR5MIF.js +2 -0
- package/dist/chunk-3HWR5MIF.js.map +1 -0
- package/dist/chunk-4K6DIB7A.js +2 -0
- package/dist/chunk-4K6DIB7A.js.map +1 -0
- package/dist/chunk-BJKK7MKL.js +5 -0
- package/dist/chunk-BJKK7MKL.js.map +1 -0
- package/dist/chunk-FWWD2YSS.cjs +2 -0
- package/dist/chunk-FWWD2YSS.cjs.map +1 -0
- package/dist/chunk-GWEBEL7E.js +2 -0
- package/dist/chunk-GWEBEL7E.js.map +1 -0
- package/dist/chunk-J4TFVNKP.cjs +32 -0
- package/dist/chunk-J4TFVNKP.cjs.map +1 -0
- package/dist/chunk-KI5MVV64.cjs +2 -0
- package/dist/chunk-KI5MVV64.cjs.map +1 -0
- package/dist/chunk-N4IP63GR.js +2 -0
- package/dist/chunk-N4IP63GR.js.map +1 -0
- package/dist/chunk-PEDMDFZM.js +2 -0
- package/dist/chunk-PEDMDFZM.js.map +1 -0
- package/dist/chunk-Q3E2UVUK.js +2 -0
- package/dist/chunk-Q3E2UVUK.js.map +1 -0
- package/dist/chunk-RRB7VGW7.js +2 -0
- package/dist/chunk-RRB7VGW7.js.map +1 -0
- package/dist/chunk-UVM6CYWX.cjs +2 -0
- package/dist/chunk-UVM6CYWX.cjs.map +1 -0
- package/dist/chunk-Y5HEEST4.cjs +2 -0
- package/dist/chunk-Y5HEEST4.cjs.map +1 -0
- package/dist/chunk-YFCIWM3C.cjs +2 -0
- package/dist/chunk-YFCIWM3C.cjs.map +1 -0
- package/dist/chunk-ZE7R72IH.cjs +2 -0
- package/dist/chunk-ZE7R72IH.cjs.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +51 -5458
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -4579
- package/dist/index.js.map +1 -1
- package/dist/machine.cjs +2 -0
- package/dist/machine.cjs.map +1 -0
- package/dist/machine.js +2 -0
- package/dist/machine.js.map +1 -0
- package/dist/offline.cjs +2 -0
- package/dist/offline.cjs.map +1 -0
- package/dist/offline.js +2 -0
- package/dist/offline.js.map +1 -0
- package/dist/pwa.cjs +2 -0
- package/dist/pwa.cjs.map +1 -0
- package/dist/pwa.js +2 -0
- package/dist/pwa.js.map +1 -0
- package/dist/ssr.cjs +2 -0
- package/dist/ssr.cjs.map +1 -0
- package/dist/ssr.js +2 -0
- package/dist/ssr.js.map +1 -0
- package/dist/store.cjs +2 -0
- package/dist/store.cjs.map +1 -0
- package/dist/store.js +2 -0
- package/dist/store.js.map +1 -0
- package/dist/sync.cjs +2 -0
- package/dist/sync.cjs.map +1 -0
- package/dist/sync.js +2 -0
- package/dist/sync.js.map +1 -0
- package/dist/test.cjs +4 -369
- package/dist/test.cjs.map +1 -1
- package/dist/test.js +4 -165
- package/dist/test.js.map +1 -1
- package/package.json +30 -5
- package/dist/chunk-D3IR22HI.js +0 -662
- package/dist/chunk-D3IR22HI.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,3021 +1,45 @@
|
|
|
1
|
-
import { defineComponent,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function renderSlot(slot, fallback) {
|
|
6
|
-
if (slot) {
|
|
7
|
-
const content = slot();
|
|
8
|
-
return nodeToDOM(content);
|
|
9
|
-
}
|
|
10
|
-
if (fallback) {
|
|
11
|
-
return nodeToDOM(fallback());
|
|
12
|
-
}
|
|
13
|
-
return document.createComment("empty slot");
|
|
14
|
-
}
|
|
15
|
-
function hasSlot(slot) {
|
|
16
|
-
if (!slot) return false;
|
|
17
|
-
const content = slot();
|
|
18
|
-
if (content == null || content === false) return false;
|
|
19
|
-
if (typeof content === "string" && content.trim() === "") return false;
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
function createSlots(props, slotNames) {
|
|
23
|
-
const slots = {};
|
|
24
|
-
for (const name of slotNames) {
|
|
25
|
-
const value = props[name];
|
|
26
|
-
if (typeof value === "function") {
|
|
27
|
-
slots[name] = value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return slots;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/error-boundary.ts
|
|
34
|
-
var ErrorBoundary = defineComponent((ctx) => {
|
|
35
|
-
const error = signal(null);
|
|
36
|
-
onError((err) => {
|
|
37
|
-
error.set(err);
|
|
38
|
-
});
|
|
39
|
-
function retry() {
|
|
40
|
-
error.set(null);
|
|
41
|
-
}
|
|
42
|
-
return () => {
|
|
43
|
-
const currentError = error();
|
|
44
|
-
if (currentError) {
|
|
45
|
-
return nodeToDOM(ctx.props.fallback(currentError, retry));
|
|
46
|
-
}
|
|
47
|
-
return nodeToDOM(ctx.children());
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// src/suspense.ts
|
|
52
|
-
var currentSuspenseCtx = null;
|
|
53
|
-
function getSuspenseContext() {
|
|
54
|
-
return currentSuspenseCtx;
|
|
55
|
-
}
|
|
56
|
-
function registerPending(promise) {
|
|
57
|
-
if (currentSuspenseCtx) {
|
|
58
|
-
currentSuspenseCtx.addPending(promise);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
var Suspense = defineComponent((ctx) => {
|
|
62
|
-
const resolved = signal(false);
|
|
63
|
-
const pending = [];
|
|
64
|
-
const suspenseCtx = {
|
|
65
|
-
addPending(promise) {
|
|
66
|
-
pending.push(promise);
|
|
67
|
-
},
|
|
68
|
-
isResolved: () => resolved()
|
|
69
|
-
};
|
|
70
|
-
const prevCtx = currentSuspenseCtx;
|
|
71
|
-
currentSuspenseCtx = suspenseCtx;
|
|
72
|
-
let childrenNode;
|
|
73
|
-
try {
|
|
74
|
-
childrenNode = ctx.children();
|
|
75
|
-
} finally {
|
|
76
|
-
currentSuspenseCtx = prevCtx;
|
|
77
|
-
}
|
|
78
|
-
if (pending.length > 0) {
|
|
79
|
-
Promise.all(pending).then(() => {
|
|
80
|
-
resolved.set(true);
|
|
81
|
-
});
|
|
82
|
-
} else {
|
|
83
|
-
resolved.set(true);
|
|
84
|
-
}
|
|
85
|
-
return () => {
|
|
86
|
-
const container = document.createElement("div");
|
|
87
|
-
container.setAttribute("data-akash-suspense", "");
|
|
88
|
-
container.style.display = "contents";
|
|
89
|
-
if (resolved()) {
|
|
90
|
-
container.appendChild(nodeToDOM(childrenNode));
|
|
91
|
-
} else {
|
|
92
|
-
container.appendChild(nodeToDOM(ctx.props.fallback()));
|
|
93
|
-
}
|
|
94
|
-
effect(() => {
|
|
95
|
-
if (resolved()) {
|
|
96
|
-
while (container.firstChild) {
|
|
97
|
-
container.removeChild(container.firstChild);
|
|
98
|
-
}
|
|
99
|
-
container.appendChild(nodeToDOM(childrenNode));
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
return container;
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// src/hydration.ts
|
|
107
|
-
var isHydrating = false;
|
|
108
|
-
var hydrateWalker = null;
|
|
109
|
-
function isHydrationActive() {
|
|
110
|
-
return isHydrating;
|
|
111
|
-
}
|
|
112
|
-
function hydrate(options) {
|
|
113
|
-
const { container, component, props = {} } = options;
|
|
114
|
-
isHydrating = true;
|
|
115
|
-
hydrateWalker = document.createTreeWalker(
|
|
116
|
-
container,
|
|
117
|
-
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
|
|
118
|
-
);
|
|
119
|
-
try {
|
|
120
|
-
component(props);
|
|
121
|
-
} finally {
|
|
122
|
-
isHydrating = false;
|
|
123
|
-
hydrateWalker = null;
|
|
124
|
-
}
|
|
125
|
-
return () => {
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function claimElement(tag) {
|
|
129
|
-
if (!isHydrating || !hydrateWalker) return null;
|
|
130
|
-
let node = hydrateWalker.nextNode();
|
|
131
|
-
while (node) {
|
|
132
|
-
if (node instanceof HTMLElement && node.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
133
|
-
return node;
|
|
134
|
-
}
|
|
135
|
-
node = hydrateWalker.nextNode();
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
function claimText() {
|
|
140
|
-
if (!isHydrating || !hydrateWalker) return null;
|
|
141
|
-
let node = hydrateWalker.nextNode();
|
|
142
|
-
while (node) {
|
|
143
|
-
if (node instanceof Text) {
|
|
144
|
-
return node;
|
|
145
|
-
}
|
|
146
|
-
node = hydrateWalker.nextNode();
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
function progressiveHydrate(options) {
|
|
151
|
-
const { target, component, props, rootMargin = "200px" } = options;
|
|
152
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
153
|
-
return hydrate({ container: target, component, props });
|
|
154
|
-
}
|
|
155
|
-
let disposed = false;
|
|
156
|
-
const observer = new IntersectionObserver(
|
|
157
|
-
(entries2) => {
|
|
158
|
-
for (const entry of entries2) {
|
|
159
|
-
if (entry.isIntersecting && !disposed) {
|
|
160
|
-
observer.disconnect();
|
|
161
|
-
hydrate({ container: target, component, props });
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
{ rootMargin }
|
|
166
|
-
);
|
|
167
|
-
observer.observe(target);
|
|
168
|
-
return () => {
|
|
169
|
-
disposed = true;
|
|
170
|
-
observer.disconnect();
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
var HYDRATE_ATTR = "data-akash-hydrate";
|
|
174
|
-
function findHydrationBoundaries(root = document.body) {
|
|
175
|
-
return Array.from(root.querySelectorAll(`[${HYDRATE_ATTR}]`));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/ssr.ts
|
|
179
|
-
var ESCAPE_MAP = {
|
|
180
|
-
"&": "&",
|
|
181
|
-
"<": "<",
|
|
182
|
-
">": ">",
|
|
183
|
-
'"': """,
|
|
184
|
-
"'": "'"
|
|
185
|
-
};
|
|
186
|
-
function escapeHtml(str) {
|
|
187
|
-
return str.replace(/[&<>"']/g, (ch) => ESCAPE_MAP[ch]);
|
|
188
|
-
}
|
|
189
|
-
var isSSR = false;
|
|
190
|
-
function isServerRendering() {
|
|
191
|
-
return isSSR;
|
|
192
|
-
}
|
|
193
|
-
async function renderToString(component, props) {
|
|
194
|
-
isSSR = true;
|
|
195
|
-
try {
|
|
196
|
-
const node = renderComponent(component, props ?? {});
|
|
197
|
-
return nodeToHtml(node);
|
|
198
|
-
} finally {
|
|
199
|
-
isSSR = false;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function renderToStringSync(component, props) {
|
|
203
|
-
isSSR = true;
|
|
204
|
-
try {
|
|
205
|
-
const node = renderComponent(component, props ?? {});
|
|
206
|
-
return nodeToHtml(node);
|
|
207
|
-
} finally {
|
|
208
|
-
isSSR = false;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function renderToStream(component, props) {
|
|
212
|
-
return new ReadableStream({
|
|
213
|
-
start(controller) {
|
|
214
|
-
isSSR = true;
|
|
215
|
-
try {
|
|
216
|
-
const node = renderComponent(component, props ?? {});
|
|
217
|
-
const html = nodeToHtml(node);
|
|
218
|
-
controller.enqueue(html);
|
|
219
|
-
controller.close();
|
|
220
|
-
} catch (err) {
|
|
221
|
-
controller.error(err);
|
|
222
|
-
} finally {
|
|
223
|
-
isSSR = false;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
function renderComponent(component, props) {
|
|
229
|
-
return { type: "raw", html: `<!-- SSR placeholder for ${component.name || "component"} -->` };
|
|
230
|
-
}
|
|
231
|
-
function ssrElement(tag, attrs, children) {
|
|
232
|
-
const processedAttrs = {};
|
|
233
|
-
if (attrs) {
|
|
234
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
235
|
-
if (value === true) {
|
|
236
|
-
processedAttrs[key] = "";
|
|
237
|
-
} else if (value !== false && value != null) {
|
|
238
|
-
processedAttrs[key] = String(value);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
type: "element",
|
|
244
|
-
tag,
|
|
245
|
-
attrs: processedAttrs,
|
|
246
|
-
children: children ?? []
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
function ssrText(content) {
|
|
250
|
-
return { type: "text", content };
|
|
251
|
-
}
|
|
252
|
-
function ssrRaw(html) {
|
|
253
|
-
return { type: "raw", html };
|
|
254
|
-
}
|
|
255
|
-
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
256
|
-
"area",
|
|
257
|
-
"base",
|
|
258
|
-
"br",
|
|
259
|
-
"col",
|
|
260
|
-
"embed",
|
|
261
|
-
"hr",
|
|
262
|
-
"img",
|
|
263
|
-
"input",
|
|
264
|
-
"link",
|
|
265
|
-
"meta",
|
|
266
|
-
"param",
|
|
267
|
-
"source",
|
|
268
|
-
"track",
|
|
269
|
-
"wbr"
|
|
270
|
-
]);
|
|
271
|
-
function nodeToHtml(node) {
|
|
272
|
-
switch (node.type) {
|
|
273
|
-
case "text":
|
|
274
|
-
return escapeHtml(node.content);
|
|
275
|
-
case "raw":
|
|
276
|
-
return node.html;
|
|
277
|
-
case "element": {
|
|
278
|
-
const { tag, attrs, children } = node;
|
|
279
|
-
let html = `<${tag}`;
|
|
280
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
281
|
-
if (value === "") {
|
|
282
|
-
html += ` ${key}`;
|
|
283
|
-
} else {
|
|
284
|
-
html += ` ${key}="${escapeHtml(value)}"`;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (VOID_ELEMENTS.has(tag)) {
|
|
288
|
-
html += " />";
|
|
289
|
-
return html;
|
|
290
|
-
}
|
|
291
|
-
html += ">";
|
|
292
|
-
for (const child of children) {
|
|
293
|
-
html += nodeToHtml(child);
|
|
294
|
-
}
|
|
295
|
-
html += `</${tag}>`;
|
|
296
|
-
return html;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function renderNodes(nodes) {
|
|
301
|
-
return nodes.map(nodeToHtml).join("");
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// src/store.ts
|
|
305
|
-
var storeInstances = /* @__PURE__ */ new Map();
|
|
306
|
-
function defineStore(id, definition) {
|
|
307
|
-
return () => {
|
|
308
|
-
if (storeInstances.has(id)) {
|
|
309
|
-
return storeInstances.get(id);
|
|
310
|
-
}
|
|
311
|
-
const initialState = definition.state();
|
|
312
|
-
const store = createStoreInstance(id, initialState, definition);
|
|
313
|
-
storeInstances.set(id, store);
|
|
314
|
-
return store;
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
function createStoreInstance(id, initialState, definition) {
|
|
318
|
-
const stateSignals = {};
|
|
319
|
-
const stateKeys = Object.keys(initialState);
|
|
320
|
-
for (const key of stateKeys) {
|
|
321
|
-
stateSignals[key] = signal(initialState[key]);
|
|
322
|
-
}
|
|
323
|
-
const getterComputeds = {};
|
|
324
|
-
if (definition.getters) {
|
|
325
|
-
for (const [key, getterFn] of Object.entries(definition.getters)) {
|
|
326
|
-
getterComputeds[key] = computed(
|
|
327
|
-
() => getterFn(stateSignals)
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
const store = { $id: id };
|
|
332
|
-
for (const key of stateKeys) {
|
|
333
|
-
store[key] = stateSignals[key];
|
|
334
|
-
}
|
|
335
|
-
for (const [key, comp] of Object.entries(getterComputeds)) {
|
|
336
|
-
store[key] = comp;
|
|
337
|
-
}
|
|
338
|
-
if (definition.actions) {
|
|
339
|
-
for (const [key, actionFn] of Object.entries(definition.actions)) {
|
|
340
|
-
store[key] = (...args) => actionFn.apply(stateSignals, args);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
store.$reset = () => {
|
|
344
|
-
const fresh = definition.state();
|
|
345
|
-
for (const key of stateKeys) {
|
|
346
|
-
stateSignals[key].set(fresh[key]);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
store.$snapshot = () => {
|
|
350
|
-
const snapshot = {};
|
|
351
|
-
for (const key of stateKeys) {
|
|
352
|
-
snapshot[key] = stateSignals[key]();
|
|
353
|
-
}
|
|
354
|
-
return snapshot;
|
|
355
|
-
};
|
|
356
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
357
|
-
store.$subscribe = (callback) => {
|
|
358
|
-
subscribers.add(callback);
|
|
359
|
-
return () => subscribers.delete(callback);
|
|
360
|
-
};
|
|
361
|
-
return store;
|
|
362
|
-
}
|
|
363
|
-
function clearStores() {
|
|
364
|
-
storeInstances.clear();
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// src/transition.ts
|
|
368
|
-
function getTransitionClasses(name) {
|
|
369
|
-
return {
|
|
370
|
-
enterFrom: `${name}-enter-from`,
|
|
371
|
-
enterActive: `${name}-enter-active`,
|
|
372
|
-
enterTo: `${name}-enter-to`,
|
|
373
|
-
exitFrom: `${name}-exit-from`,
|
|
374
|
-
exitActive: `${name}-exit-active`,
|
|
375
|
-
exitTo: `${name}-exit-to`
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
function enterTransition(el, classes, duration) {
|
|
379
|
-
return new Promise((resolve) => {
|
|
380
|
-
el.classList.add(classes.enterFrom, classes.enterActive);
|
|
381
|
-
void el.offsetHeight;
|
|
382
|
-
el.classList.remove(classes.enterFrom);
|
|
383
|
-
el.classList.add(classes.enterTo);
|
|
384
|
-
const onEnd = () => {
|
|
385
|
-
el.classList.remove(classes.enterActive, classes.enterTo);
|
|
386
|
-
el.removeEventListener("transitionend", onEnd);
|
|
387
|
-
resolve();
|
|
388
|
-
};
|
|
389
|
-
if (duration !== void 0) {
|
|
390
|
-
setTimeout(onEnd, duration);
|
|
391
|
-
} else {
|
|
392
|
-
el.addEventListener("transitionend", onEnd, { once: true });
|
|
393
|
-
setTimeout(onEnd, 5e3);
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
function exitTransition(el, classes, duration) {
|
|
398
|
-
return new Promise((resolve) => {
|
|
399
|
-
el.classList.add(classes.exitFrom, classes.exitActive);
|
|
400
|
-
void el.offsetHeight;
|
|
401
|
-
el.classList.remove(classes.exitFrom);
|
|
402
|
-
el.classList.add(classes.exitTo);
|
|
403
|
-
const onEnd = () => {
|
|
404
|
-
el.classList.remove(classes.exitActive, classes.exitTo);
|
|
405
|
-
el.removeEventListener("transitionend", onEnd);
|
|
406
|
-
resolve();
|
|
407
|
-
};
|
|
408
|
-
if (duration !== void 0) {
|
|
409
|
-
setTimeout(onEnd, duration);
|
|
410
|
-
} else {
|
|
411
|
-
el.addEventListener("transitionend", onEnd, { once: true });
|
|
412
|
-
setTimeout(onEnd, 5e3);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
var Transition = defineComponent((ctx) => {
|
|
417
|
-
const name = ctx.props.name ?? "akash";
|
|
418
|
-
const classes = getTransitionClasses(name);
|
|
419
|
-
return () => {
|
|
420
|
-
const container = document.createElement("div");
|
|
421
|
-
container.style.display = "contents";
|
|
422
|
-
if (ctx.props.when) {
|
|
423
|
-
const content = nodeToDOM(ctx.children());
|
|
424
|
-
container.appendChild(content);
|
|
425
|
-
if (content instanceof HTMLElement) {
|
|
426
|
-
ctx.props.onEnter?.(content);
|
|
427
|
-
enterTransition(content, classes, ctx.props.duration).then(() => {
|
|
428
|
-
ctx.props.onAfterEnter?.(content);
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return container;
|
|
433
|
-
};
|
|
434
|
-
});
|
|
435
|
-
function generateTransitionCSS(name, options = {}) {
|
|
436
|
-
const {
|
|
437
|
-
property = "all",
|
|
438
|
-
duration = "0.3s",
|
|
439
|
-
easing = "ease"
|
|
440
|
-
} = options;
|
|
441
|
-
return `
|
|
442
|
-
.${name}-enter-active,
|
|
443
|
-
.${name}-exit-active {
|
|
444
|
-
transition: ${property} ${duration} ${easing};
|
|
1
|
+
export{a as createMachine}from'./chunk-RRB7VGW7.js';export{b as generateSWScript,a as registerServiceWorker,c as subscribePush}from'./chunk-24I477TY.js';import {y,w,s,v,f}from'./chunk-BJKK7MKL.js';export{r as For,q as Show,b as akashError,m as bindProperty,l as bindText,n as bindVisible,j as cloneTemplate,e as createContext,h as createElement,i as createText,y as defineComponent,a as formatError,d as getAllErrorCodes,c as getErrorDef,g as inject,t as insert,s as nodeToDOM,w as onError,u as onMount,v as onUnmount,f as provide,x as ref,o as renderConditional,p as renderList,k as setProperty}from'./chunk-BJKK7MKL.js';export{b as clearStores,a as defineStore}from'./chunk-GWEBEL7E.js';export{a as escapeHtml,b as isServerRendering,i as nodeToHtml,j as renderNodes,e as renderToStream,c as renderToString,d as renderToStringSync,f as ssrElement,h as ssrRaw,g as ssrText}from'./chunk-3HWR5MIF.js';export{a as LWWRegister,c as createLocalTransport,d as createSync,b as createWebSocketTransport}from'./chunk-PEDMDFZM.js';export{a as createOfflineStore}from'./chunk-N4IP63GR.js';import {c,e,d,a}from'./chunk-4K6DIB7A.js';export{a as batch,d as computed,e as effect,b as flushSync,c as signal,f as untrack}from'./chunk-4K6DIB7A.js';export{a as animate,d as animateGroup,c as animateSequence,e as animateSpring,b as animateStagger,g as defineStates,f as keyframes}from'./chunk-Q3E2UVUK.js';function It(e,t){if(e){let n=e();return s(n)}return t?s(t()):document.createComment("empty slot")}function jt(e){if(!e)return false;let t=e();return !(t==null||t===false||typeof t=="string"&&t.trim()==="")}function Ft(e,t){let n={};for(let r of t){let o=e[r];typeof o=="function"&&(n[r]=o);}return n}var Nt=y(e=>{let t=c(null);w(r=>{t.set(r);});function n(){t.set(null);}return ()=>{let r=t();return r?s(e.props.fallback(r,n)):s(e.children())}});var I=null;function _t(){return I}function $t(e){I&&I.addPending(e);}var Kt=y(e$1=>{let t=c(false),n=[],r={addPending(s){n.push(s);},isResolved:()=>t()},o=I;I=r;let i;try{i=e$1.children();}finally{I=o;}return n.length>0?Promise.all(n).then(()=>{t.set(true);}):t.set(true),()=>{let s$1=document.createElement("div");return s$1.setAttribute("data-akash-suspense",""),s$1.style.display="contents",t()?s$1.appendChild(s(i)):s$1.appendChild(s(e$1.props.fallback())),e(()=>{if(t()){for(;s$1.firstChild;)s$1.removeChild(s$1.firstChild);s$1.appendChild(s(i));}}),s$1}});var N=false,L=null;function Vt(){return N}function Q(e){let{container:t,component:n,props:r={}}=e;N=true,L=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);try{n(r);}finally{N=false,L=null;}return ()=>{}}function Bt(e){if(!N||!L)return null;let t=L.nextNode();for(;t;){if(t instanceof HTMLElement&&t.tagName.toLowerCase()===e.toLowerCase())return t;t=L.nextNode();}return null}function qt(){if(!N||!L)return null;let e=L.nextNode();for(;e;){if(e instanceof Text)return e;e=L.nextNode();}return null}function Wt(e){let{target:t,component:n,props:r,rootMargin:o="200px"}=e;if(typeof IntersectionObserver>"u")return Q({container:t,component:n,props:r});let i=false,s=new IntersectionObserver(a=>{for(let l of a)l.isIntersecting&&!i&&(s.disconnect(),Q({container:t,component:n,props:r}));},{rootMargin:o});return s.observe(t),()=>{i=true,s.disconnect();}}var ce="data-akash-hydrate";function zt(e=document.body){return Array.from(e.querySelectorAll(`[${ce}]`))}function ue(e){return {enterFrom:`${e}-enter-from`,enterActive:`${e}-enter-active`,enterTo:`${e}-enter-to`,exitFrom:`${e}-exit-from`,exitActive:`${e}-exit-active`,exitTo:`${e}-exit-to`}}function de(e,t,n){return new Promise(r=>{e.classList.add(t.enterFrom,t.enterActive),e.offsetHeight,e.classList.remove(t.enterFrom),e.classList.add(t.enterTo);let o=()=>{e.classList.remove(t.enterActive,t.enterTo),e.removeEventListener("transitionend",o),r();};n!==void 0?setTimeout(o,n):(e.addEventListener("transitionend",o,{once:true}),setTimeout(o,5e3));})}function Ut(e,t,n){return new Promise(r=>{e.classList.add(t.exitFrom,t.exitActive),e.offsetHeight,e.classList.remove(t.exitFrom),e.classList.add(t.exitTo);let o=()=>{e.classList.remove(t.exitActive,t.exitTo),e.removeEventListener("transitionend",o),r();};n!==void 0?setTimeout(o,n):(e.addEventListener("transitionend",o,{once:true}),setTimeout(o,5e3));})}var Gt=y(e=>{let t=e.props.name??"akash",n=ue(t);return ()=>{let r=document.createElement("div");if(r.style.display="contents",e.props.when){let o=s(e.children());r.appendChild(o),o instanceof HTMLElement&&(e.props.onEnter?.(o),de(o,n,e.props.duration).then(()=>{e.props.onAfterEnter?.(o);}));}return r}});function Qt(e,t={}){let{property:n="all",duration:r="0.3s",easing:o="ease"}=t;return `
|
|
2
|
+
.${e}-enter-active,
|
|
3
|
+
.${e}-exit-active {
|
|
4
|
+
transition: ${n} ${r} ${o};
|
|
445
5
|
}
|
|
446
6
|
|
|
447
|
-
.${
|
|
448
|
-
.${
|
|
7
|
+
.${e}-enter-from,
|
|
8
|
+
.${e}-exit-to {
|
|
449
9
|
opacity: 0;
|
|
450
10
|
}
|
|
451
11
|
|
|
452
|
-
.${
|
|
453
|
-
.${
|
|
12
|
+
.${e}-enter-to,
|
|
13
|
+
.${e}-exit-from {
|
|
454
14
|
opacity: 1;
|
|
455
15
|
}
|
|
456
|
-
`.trim();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// src/head.ts
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
for (const config of configs) {
|
|
486
|
-
for (const link of config.link ?? []) {
|
|
487
|
-
html += ` <link rel="${link.rel}" href="${link.href}"`;
|
|
488
|
-
if (link.type) html += ` type="${link.type}"`;
|
|
489
|
-
html += " />\n";
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
return html;
|
|
493
|
-
}
|
|
494
|
-
var MANAGED_ATTR = "data-akash-head";
|
|
495
|
-
function useHead(config) {
|
|
496
|
-
const getConfig = typeof config === "function" ? config : () => config;
|
|
497
|
-
if (typeof document === "undefined") {
|
|
498
|
-
ssrHeadTags.push(getConfig());
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
const managedElements = [];
|
|
502
|
-
const dispose = effect(() => {
|
|
503
|
-
const cfg = getConfig();
|
|
504
|
-
for (const el of managedElements) {
|
|
505
|
-
el.remove();
|
|
506
|
-
}
|
|
507
|
-
managedElements.length = 0;
|
|
508
|
-
if (cfg.title) {
|
|
509
|
-
const title = cfg.titleTemplate ? cfg.titleTemplate.replace("%s", cfg.title) : cfg.title;
|
|
510
|
-
document.title = title;
|
|
511
|
-
}
|
|
512
|
-
for (const meta of cfg.meta ?? []) {
|
|
513
|
-
const el = document.createElement("meta");
|
|
514
|
-
el.setAttribute(MANAGED_ATTR, "");
|
|
515
|
-
if (meta.name) el.setAttribute("name", meta.name);
|
|
516
|
-
if (meta.property) el.setAttribute("property", meta.property);
|
|
517
|
-
if (meta.httpEquiv) el.setAttribute("http-equiv", meta.httpEquiv);
|
|
518
|
-
el.setAttribute("content", meta.content);
|
|
519
|
-
document.head.appendChild(el);
|
|
520
|
-
managedElements.push(el);
|
|
521
|
-
}
|
|
522
|
-
for (const link of cfg.link ?? []) {
|
|
523
|
-
const el = document.createElement("link");
|
|
524
|
-
el.setAttribute(MANAGED_ATTR, "");
|
|
525
|
-
el.setAttribute("rel", link.rel);
|
|
526
|
-
el.setAttribute("href", link.href);
|
|
527
|
-
if (link.type) el.setAttribute("type", link.type);
|
|
528
|
-
document.head.appendChild(el);
|
|
529
|
-
managedElements.push(el);
|
|
530
|
-
}
|
|
531
|
-
for (const script of cfg.script ?? []) {
|
|
532
|
-
const el = document.createElement("script");
|
|
533
|
-
el.setAttribute(MANAGED_ATTR, "");
|
|
534
|
-
if (script.src) el.setAttribute("src", script.src);
|
|
535
|
-
if (script.type) el.setAttribute("type", script.type);
|
|
536
|
-
if (script.async) el.setAttribute("async", "");
|
|
537
|
-
if (script.defer) el.setAttribute("defer", "");
|
|
538
|
-
if (script.innerHTML) el.textContent = script.innerHTML;
|
|
539
|
-
document.head.appendChild(el);
|
|
540
|
-
managedElements.push(el);
|
|
541
|
-
}
|
|
542
|
-
if (cfg.htmlAttrs) {
|
|
543
|
-
for (const [key, value] of Object.entries(cfg.htmlAttrs)) {
|
|
544
|
-
document.documentElement.setAttribute(key, value);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if (cfg.bodyAttrs) {
|
|
548
|
-
for (const [key, value] of Object.entries(cfg.bodyAttrs)) {
|
|
549
|
-
document.body.setAttribute(key, value);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
});
|
|
553
|
-
try {
|
|
554
|
-
onUnmount(() => {
|
|
555
|
-
dispose();
|
|
556
|
-
for (const el of managedElements) {
|
|
557
|
-
el.remove();
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
} catch {
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// src/plugin.ts
|
|
565
|
-
function definePlugin(plugin) {
|
|
566
|
-
return plugin;
|
|
567
|
-
}
|
|
568
|
-
function createApp(rootComponent, rootProps) {
|
|
569
|
-
const plugins = [];
|
|
570
|
-
const errorHandlers = [];
|
|
571
|
-
const beforeMountHooks = [];
|
|
572
|
-
const appConfig = {};
|
|
573
|
-
let mountedNode = null;
|
|
574
|
-
let containerEl = null;
|
|
575
|
-
const pluginCtx = {
|
|
576
|
-
provide(key, value) {
|
|
577
|
-
provide(key, value);
|
|
578
|
-
},
|
|
579
|
-
onError(handler) {
|
|
580
|
-
errorHandlers.push(handler);
|
|
581
|
-
},
|
|
582
|
-
onBeforeMount(hook) {
|
|
583
|
-
beforeMountHooks.push(hook);
|
|
584
|
-
},
|
|
585
|
-
config: appConfig
|
|
586
|
-
};
|
|
587
|
-
const app = {
|
|
588
|
-
use(plugin) {
|
|
589
|
-
plugins.push(plugin);
|
|
590
|
-
return app;
|
|
591
|
-
},
|
|
592
|
-
config(key, value) {
|
|
593
|
-
appConfig[key] = value;
|
|
594
|
-
return app;
|
|
595
|
-
},
|
|
596
|
-
mount(selector) {
|
|
597
|
-
containerEl = typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
598
|
-
if (!containerEl) {
|
|
599
|
-
throw new Error(
|
|
600
|
-
`[AkashJS] Mount target not found: ${selector}`
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
for (const plugin of plugins) {
|
|
604
|
-
plugin.setup(pluginCtx);
|
|
605
|
-
}
|
|
606
|
-
for (const hook of beforeMountHooks) {
|
|
607
|
-
hook();
|
|
608
|
-
}
|
|
609
|
-
try {
|
|
610
|
-
mountedNode = rootComponent(rootProps ?? {});
|
|
611
|
-
containerEl.appendChild(mountedNode);
|
|
612
|
-
} catch (err) {
|
|
613
|
-
const e = err instanceof Error ? err : new Error(String(err));
|
|
614
|
-
if (errorHandlers.length > 0) {
|
|
615
|
-
for (const handler of errorHandlers) {
|
|
616
|
-
handler(e);
|
|
617
|
-
}
|
|
618
|
-
} else {
|
|
619
|
-
throw e;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
unmount() {
|
|
624
|
-
if (mountedNode && containerEl) {
|
|
625
|
-
containerEl.removeChild(mountedNode);
|
|
626
|
-
mountedNode = null;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
return app;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// src/composables.ts
|
|
634
|
-
function useInterval(ms, options) {
|
|
635
|
-
const count = signal(0);
|
|
636
|
-
const isActive = signal(options?.immediate !== false);
|
|
637
|
-
let timer = null;
|
|
638
|
-
function start() {
|
|
639
|
-
stop();
|
|
640
|
-
timer = setInterval(() => count.update((c) => c + 1), ms);
|
|
641
|
-
}
|
|
642
|
-
function stop() {
|
|
643
|
-
if (timer) {
|
|
644
|
-
clearInterval(timer);
|
|
645
|
-
timer = null;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
if (isActive()) start();
|
|
649
|
-
return {
|
|
650
|
-
count: (() => count()),
|
|
651
|
-
isActive: (() => isActive()),
|
|
652
|
-
pause() {
|
|
653
|
-
isActive.set(false);
|
|
654
|
-
stop();
|
|
655
|
-
},
|
|
656
|
-
resume() {
|
|
657
|
-
isActive.set(true);
|
|
658
|
-
start();
|
|
659
|
-
},
|
|
660
|
-
reset() {
|
|
661
|
-
count.set(0);
|
|
662
|
-
},
|
|
663
|
-
dispose() {
|
|
664
|
-
stop();
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
function useTimeout(ms) {
|
|
669
|
-
const ready = signal(false);
|
|
670
|
-
let timer = null;
|
|
671
|
-
function start() {
|
|
672
|
-
stop();
|
|
673
|
-
ready.set(false);
|
|
674
|
-
timer = setTimeout(() => ready.set(true), ms);
|
|
675
|
-
}
|
|
676
|
-
function stop() {
|
|
677
|
-
if (timer) {
|
|
678
|
-
clearTimeout(timer);
|
|
679
|
-
timer = null;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
start();
|
|
683
|
-
return {
|
|
684
|
-
ready: (() => ready()),
|
|
685
|
-
restart() {
|
|
686
|
-
start();
|
|
687
|
-
},
|
|
688
|
-
dispose() {
|
|
689
|
-
stop();
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
function useDebounce(source, delay) {
|
|
694
|
-
const debounced = signal(source());
|
|
695
|
-
let timer = null;
|
|
696
|
-
effect(() => {
|
|
697
|
-
const value = source();
|
|
698
|
-
if (timer) clearTimeout(timer);
|
|
699
|
-
timer = setTimeout(() => debounced.set(value), delay);
|
|
700
|
-
});
|
|
701
|
-
return (() => debounced());
|
|
702
|
-
}
|
|
703
|
-
function useThrottle(source, interval) {
|
|
704
|
-
const throttled = signal(source());
|
|
705
|
-
let lastUpdate = 0;
|
|
706
|
-
let timer = null;
|
|
707
|
-
effect(() => {
|
|
708
|
-
const value = source();
|
|
709
|
-
const now = Date.now();
|
|
710
|
-
const elapsed = now - lastUpdate;
|
|
711
|
-
if (elapsed >= interval) {
|
|
712
|
-
throttled.set(value);
|
|
713
|
-
lastUpdate = now;
|
|
714
|
-
} else {
|
|
715
|
-
if (timer) clearTimeout(timer);
|
|
716
|
-
timer = setTimeout(() => {
|
|
717
|
-
throttled.set(value);
|
|
718
|
-
lastUpdate = Date.now();
|
|
719
|
-
}, interval - elapsed);
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
return (() => throttled());
|
|
723
|
-
}
|
|
724
|
-
function useCounter(initial = 0) {
|
|
725
|
-
const count = signal(initial);
|
|
726
|
-
return {
|
|
727
|
-
count: (() => count()),
|
|
728
|
-
inc(delta = 1) {
|
|
729
|
-
count.update((c) => c + delta);
|
|
730
|
-
},
|
|
731
|
-
dec(delta = 1) {
|
|
732
|
-
count.update((c) => c - delta);
|
|
733
|
-
},
|
|
734
|
-
set(value) {
|
|
735
|
-
count.set(value);
|
|
736
|
-
},
|
|
737
|
-
reset() {
|
|
738
|
-
count.set(initial);
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
function useToggle(initial = false) {
|
|
743
|
-
const value = signal(initial);
|
|
744
|
-
return {
|
|
745
|
-
value: (() => value()),
|
|
746
|
-
toggle() {
|
|
747
|
-
value.update((v) => !v);
|
|
748
|
-
},
|
|
749
|
-
setTrue() {
|
|
750
|
-
value.set(true);
|
|
751
|
-
},
|
|
752
|
-
setFalse() {
|
|
753
|
-
value.set(false);
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
function usePrevious(source) {
|
|
758
|
-
signal(void 0);
|
|
759
|
-
effect(() => {
|
|
760
|
-
source();
|
|
761
|
-
});
|
|
762
|
-
let lastValue;
|
|
763
|
-
const tracked = signal(void 0);
|
|
764
|
-
effect(() => {
|
|
765
|
-
const current = source();
|
|
766
|
-
tracked.set(lastValue);
|
|
767
|
-
lastValue = current;
|
|
768
|
-
});
|
|
769
|
-
return (() => tracked());
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// src/browser.ts
|
|
773
|
-
function useMediaQuery(query) {
|
|
774
|
-
if (typeof window === "undefined") {
|
|
775
|
-
return (() => false);
|
|
776
|
-
}
|
|
777
|
-
const mql = window.matchMedia(query);
|
|
778
|
-
const matches = signal(mql.matches);
|
|
779
|
-
const handler = (e) => matches.set(e.matches);
|
|
780
|
-
mql.addEventListener("change", handler);
|
|
781
|
-
return (() => matches());
|
|
782
|
-
}
|
|
783
|
-
var DEFAULT_BREAKPOINTS = {
|
|
784
|
-
sm: 640,
|
|
785
|
-
md: 768,
|
|
786
|
-
lg: 1024,
|
|
787
|
-
xl: 1280,
|
|
788
|
-
"2xl": 1536
|
|
789
|
-
};
|
|
790
|
-
function useBreakpoint(breakpoints = DEFAULT_BREAKPOINTS) {
|
|
791
|
-
const sorted = Object.entries(breakpoints).sort((a, b) => a[1] - b[1]);
|
|
792
|
-
const width = signal(typeof window !== "undefined" ? window.innerWidth : 1024);
|
|
793
|
-
if (typeof window !== "undefined") {
|
|
794
|
-
const handler = () => width.set(window.innerWidth);
|
|
795
|
-
window.addEventListener("resize", handler, { passive: true });
|
|
796
|
-
}
|
|
797
|
-
function current() {
|
|
798
|
-
const w = width();
|
|
799
|
-
let result = "";
|
|
800
|
-
for (const [name, min] of sorted) {
|
|
801
|
-
if (w >= min) result = name;
|
|
802
|
-
}
|
|
803
|
-
return result || sorted[0]?.[0] || "";
|
|
804
|
-
}
|
|
805
|
-
function gte(name) {
|
|
806
|
-
const bp = breakpoints[name];
|
|
807
|
-
return bp !== void 0 && width() >= bp;
|
|
808
|
-
}
|
|
809
|
-
function lt(name) {
|
|
810
|
-
const bp = breakpoints[name];
|
|
811
|
-
return bp !== void 0 && width() < bp;
|
|
812
|
-
}
|
|
813
|
-
return { current, gte, lt, width: (() => width()) };
|
|
814
|
-
}
|
|
815
|
-
function useStorage(key, initialValue, storage = "local") {
|
|
816
|
-
const store = typeof window !== "undefined" ? storage === "local" ? localStorage : sessionStorage : null;
|
|
817
|
-
let startValue = initialValue;
|
|
818
|
-
if (store) {
|
|
819
|
-
try {
|
|
820
|
-
const raw = store.getItem(key);
|
|
821
|
-
if (raw !== null) startValue = JSON.parse(raw);
|
|
822
|
-
} catch {
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
const state = signal(startValue);
|
|
826
|
-
if (store) {
|
|
827
|
-
effect(() => {
|
|
828
|
-
const value = state();
|
|
829
|
-
try {
|
|
830
|
-
store.setItem(key, JSON.stringify(value));
|
|
831
|
-
} catch {
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
if (typeof window !== "undefined") {
|
|
835
|
-
window.addEventListener("storage", (e) => {
|
|
836
|
-
if (e.key === key && e.newValue !== null) {
|
|
837
|
-
try {
|
|
838
|
-
state.set(JSON.parse(e.newValue));
|
|
839
|
-
} catch {
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
return state;
|
|
846
|
-
}
|
|
847
|
-
function useClipboard(options) {
|
|
848
|
-
const text = signal("");
|
|
849
|
-
const copied = signal(false);
|
|
850
|
-
const timeout = options?.timeout ?? 2e3;
|
|
851
|
-
let timer = null;
|
|
852
|
-
async function copy(value) {
|
|
853
|
-
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
854
|
-
await navigator.clipboard.writeText(value);
|
|
855
|
-
text.set(value);
|
|
856
|
-
copied.set(true);
|
|
857
|
-
if (timer) clearTimeout(timer);
|
|
858
|
-
timer = setTimeout(() => copied.set(false), timeout);
|
|
859
|
-
}
|
|
860
|
-
return {
|
|
861
|
-
text: (() => text()),
|
|
862
|
-
copied: (() => copied()),
|
|
863
|
-
copy
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
function useOnline() {
|
|
867
|
-
if (typeof window === "undefined") {
|
|
868
|
-
return (() => true);
|
|
869
|
-
}
|
|
870
|
-
const online = signal(navigator.onLine);
|
|
871
|
-
window.addEventListener("online", () => online.set(true));
|
|
872
|
-
window.addEventListener("offline", () => online.set(false));
|
|
873
|
-
return (() => online());
|
|
874
|
-
}
|
|
875
|
-
function useGeolocation(options) {
|
|
876
|
-
const state = signal({
|
|
877
|
-
latitude: null,
|
|
878
|
-
longitude: null,
|
|
879
|
-
accuracy: null,
|
|
880
|
-
error: null,
|
|
881
|
-
loading: true
|
|
882
|
-
});
|
|
883
|
-
if (typeof navigator !== "undefined" && navigator.geolocation) {
|
|
884
|
-
navigator.geolocation.watchPosition(
|
|
885
|
-
(pos) => {
|
|
886
|
-
state.set({
|
|
887
|
-
latitude: pos.coords.latitude,
|
|
888
|
-
longitude: pos.coords.longitude,
|
|
889
|
-
accuracy: pos.coords.accuracy,
|
|
890
|
-
error: null,
|
|
891
|
-
loading: false
|
|
892
|
-
});
|
|
893
|
-
},
|
|
894
|
-
(err) => {
|
|
895
|
-
state.set({
|
|
896
|
-
latitude: null,
|
|
897
|
-
longitude: null,
|
|
898
|
-
accuracy: null,
|
|
899
|
-
error: err,
|
|
900
|
-
loading: false
|
|
901
|
-
});
|
|
902
|
-
},
|
|
903
|
-
options
|
|
904
|
-
);
|
|
905
|
-
} else {
|
|
906
|
-
state.set({ ...state(), loading: false });
|
|
907
|
-
}
|
|
908
|
-
return (() => state());
|
|
909
|
-
}
|
|
910
|
-
function useWindowSize() {
|
|
911
|
-
const width = signal(typeof window !== "undefined" ? window.innerWidth : 0);
|
|
912
|
-
const height = signal(typeof window !== "undefined" ? window.innerHeight : 0);
|
|
913
|
-
if (typeof window !== "undefined") {
|
|
914
|
-
window.addEventListener("resize", () => {
|
|
915
|
-
width.set(window.innerWidth);
|
|
916
|
-
height.set(window.innerHeight);
|
|
917
|
-
}, { passive: true });
|
|
918
|
-
}
|
|
919
|
-
return {
|
|
920
|
-
width: (() => width()),
|
|
921
|
-
height: (() => height())
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
function useClickOutside(target, handler, options = {}) {
|
|
925
|
-
if (typeof document === "undefined") return () => {
|
|
926
|
-
};
|
|
927
|
-
const {
|
|
928
|
-
events = ["pointerdown"],
|
|
929
|
-
ignore = [],
|
|
930
|
-
active = true
|
|
931
|
-
} = options;
|
|
932
|
-
let isActive = active;
|
|
933
|
-
function getTarget() {
|
|
934
|
-
return typeof target === "function" ? target() : target;
|
|
935
|
-
}
|
|
936
|
-
function shouldIgnore(event) {
|
|
937
|
-
const eventTarget = event.target;
|
|
938
|
-
if (!eventTarget) return false;
|
|
939
|
-
for (const pattern of ignore) {
|
|
940
|
-
if (typeof pattern === "string") {
|
|
941
|
-
if (eventTarget.closest(pattern)) return true;
|
|
942
|
-
} else {
|
|
943
|
-
if (pattern === eventTarget || pattern.contains(eventTarget)) return true;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
return false;
|
|
947
|
-
}
|
|
948
|
-
function listener(event) {
|
|
949
|
-
if (!isActive) return;
|
|
950
|
-
const el = getTarget();
|
|
951
|
-
if (!el) return;
|
|
952
|
-
const eventTarget = event.target;
|
|
953
|
-
if (el === eventTarget || el.contains(eventTarget)) return;
|
|
954
|
-
if (shouldIgnore(event)) return;
|
|
955
|
-
handler(event);
|
|
956
|
-
}
|
|
957
|
-
for (const eventName of events) {
|
|
958
|
-
document.addEventListener(eventName, listener, { passive: true, capture: true });
|
|
959
|
-
}
|
|
960
|
-
const dispose = () => {
|
|
961
|
-
for (const eventName of events) {
|
|
962
|
-
document.removeEventListener(eventName, listener, { capture: true });
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
dispose.enable = () => {
|
|
966
|
-
isActive = true;
|
|
967
|
-
};
|
|
968
|
-
dispose.disable = () => {
|
|
969
|
-
isActive = false;
|
|
970
|
-
};
|
|
971
|
-
return dispose;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
// src/portal.ts
|
|
975
|
-
var Portal = defineComponent((ctx) => {
|
|
976
|
-
let container = null;
|
|
977
|
-
let mountedNode = null;
|
|
978
|
-
function getTarget() {
|
|
979
|
-
const target = ctx.props.target;
|
|
980
|
-
if (!target) return document.body;
|
|
981
|
-
if (typeof target === "string") {
|
|
982
|
-
return document.querySelector(target) ?? document.body;
|
|
983
|
-
}
|
|
984
|
-
return target;
|
|
985
|
-
}
|
|
986
|
-
onUnmount(() => {
|
|
987
|
-
if (mountedNode && container) {
|
|
988
|
-
container.removeChild(mountedNode);
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
return () => {
|
|
992
|
-
container = getTarget();
|
|
993
|
-
const content = ctx.children();
|
|
994
|
-
mountedNode = nodeToDOM(content);
|
|
995
|
-
container.appendChild(mountedNode);
|
|
996
|
-
return document.createComment("portal");
|
|
997
|
-
};
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
// src/toast.ts
|
|
1001
|
-
var idCounter = 0;
|
|
1002
|
-
function createToaster(options = {}) {
|
|
1003
|
-
const {
|
|
1004
|
-
maxVisible = 5,
|
|
1005
|
-
defaultDuration = 3e3,
|
|
1006
|
-
position = "top-right"
|
|
1007
|
-
} = options;
|
|
1008
|
-
const toasts = signal([]);
|
|
1009
|
-
const timers = /* @__PURE__ */ new Map();
|
|
1010
|
-
function add(type, message, opts) {
|
|
1011
|
-
const id = `toast-${++idCounter}`;
|
|
1012
|
-
const duration = opts?.duration ?? defaultDuration;
|
|
1013
|
-
const dismissible = opts?.dismissible ?? true;
|
|
1014
|
-
const toast = {
|
|
1015
|
-
id,
|
|
1016
|
-
type,
|
|
1017
|
-
message,
|
|
1018
|
-
duration,
|
|
1019
|
-
dismissible,
|
|
1020
|
-
createdAt: Date.now()
|
|
1021
|
-
};
|
|
1022
|
-
toasts.update((list) => {
|
|
1023
|
-
const next = [...list, toast];
|
|
1024
|
-
if (next.length > maxVisible) {
|
|
1025
|
-
const removed = next.shift();
|
|
1026
|
-
clearTimer(removed.id);
|
|
1027
|
-
}
|
|
1028
|
-
return next;
|
|
1029
|
-
});
|
|
1030
|
-
if (duration > 0) {
|
|
1031
|
-
const timer = setTimeout(() => dismiss(id), duration);
|
|
1032
|
-
timers.set(id, timer);
|
|
1033
|
-
}
|
|
1034
|
-
return id;
|
|
1035
|
-
}
|
|
1036
|
-
function dismiss(id) {
|
|
1037
|
-
clearTimer(id);
|
|
1038
|
-
toasts.update((list) => list.filter((t) => t.id !== id));
|
|
1039
|
-
}
|
|
1040
|
-
function dismissAll() {
|
|
1041
|
-
for (const [id] of timers) {
|
|
1042
|
-
clearTimer(id);
|
|
1043
|
-
}
|
|
1044
|
-
toasts.set([]);
|
|
1045
|
-
}
|
|
1046
|
-
function clearTimer(id) {
|
|
1047
|
-
const timer = timers.get(id);
|
|
1048
|
-
if (timer) {
|
|
1049
|
-
clearTimeout(timer);
|
|
1050
|
-
timers.delete(id);
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
return {
|
|
1054
|
-
toasts: (() => toasts()),
|
|
1055
|
-
position,
|
|
1056
|
-
success: (msg, opts) => add("success", msg, opts),
|
|
1057
|
-
error: (msg, opts) => add("error", msg, opts),
|
|
1058
|
-
info: (msg, opts) => add("info", msg, opts),
|
|
1059
|
-
warning: (msg, opts) => add("warning", msg, opts),
|
|
1060
|
-
add,
|
|
1061
|
-
dismiss,
|
|
1062
|
-
dismissAll
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
// src/theme.ts
|
|
1067
|
-
function useTheme(config = {}) {
|
|
1068
|
-
const {
|
|
1069
|
-
themes = {
|
|
1070
|
-
light: {},
|
|
1071
|
-
dark: {}
|
|
1072
|
-
},
|
|
1073
|
-
storageKey = "akash-theme",
|
|
1074
|
-
attribute = "data-theme",
|
|
1075
|
-
syncSystem = true
|
|
1076
|
-
} = config;
|
|
1077
|
-
const themeNames = Object.keys(themes);
|
|
1078
|
-
function getSystemTheme() {
|
|
1079
|
-
if (typeof window === "undefined") return config.defaultTheme ?? "light";
|
|
1080
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1081
|
-
}
|
|
1082
|
-
function getInitialTheme() {
|
|
1083
|
-
if (typeof window !== "undefined" && storageKey) {
|
|
1084
|
-
const stored = localStorage.getItem(storageKey);
|
|
1085
|
-
if (stored && themeNames.includes(stored)) return stored;
|
|
1086
|
-
}
|
|
1087
|
-
return config.defaultTheme ?? getSystemTheme();
|
|
1088
|
-
}
|
|
1089
|
-
const current = signal(getInitialTheme());
|
|
1090
|
-
const isDark = computed(() => current() === "dark");
|
|
1091
|
-
function applyTheme(name) {
|
|
1092
|
-
if (typeof document === "undefined") return;
|
|
1093
|
-
document.documentElement.setAttribute(attribute, name);
|
|
1094
|
-
const vars = themes[name];
|
|
1095
|
-
if (vars) {
|
|
1096
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
1097
|
-
document.documentElement.style.setProperty(key, value);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
document.documentElement.classList.remove(...themeNames);
|
|
1101
|
-
document.documentElement.classList.add(name);
|
|
1102
|
-
}
|
|
1103
|
-
effect(() => {
|
|
1104
|
-
const name = current();
|
|
1105
|
-
applyTheme(name);
|
|
1106
|
-
if (typeof window !== "undefined" && storageKey) {
|
|
1107
|
-
localStorage.setItem(storageKey, name);
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
if (syncSystem && typeof window !== "undefined") {
|
|
1111
|
-
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1112
|
-
mql.addEventListener("change", (e) => {
|
|
1113
|
-
const stored = localStorage.getItem(storageKey);
|
|
1114
|
-
if (!stored) {
|
|
1115
|
-
current.set(e.matches ? "dark" : "light");
|
|
1116
|
-
}
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
return {
|
|
1120
|
-
current: () => current(),
|
|
1121
|
-
isDark,
|
|
1122
|
-
set(theme) {
|
|
1123
|
-
if (themeNames.includes(theme)) {
|
|
1124
|
-
current.set(theme);
|
|
1125
|
-
}
|
|
1126
|
-
},
|
|
1127
|
-
toggle() {
|
|
1128
|
-
current.set(isDark() ? "light" : "dark");
|
|
1129
|
-
},
|
|
1130
|
-
setSystem() {
|
|
1131
|
-
if (typeof window !== "undefined" && storageKey) {
|
|
1132
|
-
localStorage.removeItem(storageKey);
|
|
1133
|
-
}
|
|
1134
|
-
current.set(getSystemTheme());
|
|
1135
|
-
},
|
|
1136
|
-
themes: themeNames
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
// src/virtual-list.ts
|
|
1141
|
-
function calculateRange(scrollTop, containerHeight, itemHeight, totalItems, overscan = 3) {
|
|
1142
|
-
const firstVisible = Math.floor(scrollTop / itemHeight);
|
|
1143
|
-
const visibleCount = Math.ceil(containerHeight / itemHeight);
|
|
1144
|
-
const start = Math.max(0, firstVisible - overscan);
|
|
1145
|
-
const end = Math.min(totalItems, firstVisible + visibleCount + overscan);
|
|
1146
|
-
return {
|
|
1147
|
-
start,
|
|
1148
|
-
end,
|
|
1149
|
-
totalHeight: totalItems * itemHeight,
|
|
1150
|
-
offsetTop: start * itemHeight
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
function useVirtualList(options) {
|
|
1154
|
-
const scrollTop = signal(0);
|
|
1155
|
-
const containerHeight = signal(options.containerHeight ?? 400);
|
|
1156
|
-
const overscan = options.overscan ?? 3;
|
|
1157
|
-
const range = computed(() => {
|
|
1158
|
-
return calculateRange(
|
|
1159
|
-
scrollTop(),
|
|
1160
|
-
containerHeight(),
|
|
1161
|
-
options.itemHeight,
|
|
1162
|
-
options.items().length,
|
|
1163
|
-
overscan
|
|
1164
|
-
);
|
|
1165
|
-
});
|
|
1166
|
-
const visibleItems = computed(() => {
|
|
1167
|
-
const r = range();
|
|
1168
|
-
return options.items().slice(r.start, r.end).map((item, i) => ({
|
|
1169
|
-
item,
|
|
1170
|
-
index: r.start + i
|
|
1171
|
-
}));
|
|
1172
|
-
});
|
|
1173
|
-
function onScroll(e) {
|
|
1174
|
-
const target = e.target;
|
|
1175
|
-
scrollTop.set(target.scrollTop);
|
|
1176
|
-
}
|
|
1177
|
-
function setContainerHeight(height) {
|
|
1178
|
-
containerHeight.set(height);
|
|
1179
|
-
}
|
|
1180
|
-
return {
|
|
1181
|
-
range,
|
|
1182
|
-
visibleItems,
|
|
1183
|
-
onScroll,
|
|
1184
|
-
setContainerHeight,
|
|
1185
|
-
scrollTop: (() => scrollTop())
|
|
1186
|
-
};
|
|
1187
|
-
}
|
|
1188
|
-
var VirtualFor = defineComponent((ctx) => {
|
|
1189
|
-
const {
|
|
1190
|
-
itemHeight,
|
|
1191
|
-
containerHeight: fixedHeight,
|
|
1192
|
-
overscan = 3
|
|
1193
|
-
} = ctx.props;
|
|
1194
|
-
const scrollTop = signal(0);
|
|
1195
|
-
return () => {
|
|
1196
|
-
const items = ctx.props.each;
|
|
1197
|
-
const height = fixedHeight ?? 400;
|
|
1198
|
-
const r = calculateRange(scrollTop(), height, itemHeight, items.length, overscan);
|
|
1199
|
-
const outer = document.createElement("div");
|
|
1200
|
-
outer.style.height = `${height}px`;
|
|
1201
|
-
outer.style.overflow = "auto";
|
|
1202
|
-
outer.style.position = "relative";
|
|
1203
|
-
outer.addEventListener("scroll", () => {
|
|
1204
|
-
scrollTop.set(outer.scrollTop);
|
|
1205
|
-
}, { passive: true });
|
|
1206
|
-
const inner = document.createElement("div");
|
|
1207
|
-
inner.style.height = `${r.totalHeight}px`;
|
|
1208
|
-
inner.style.position = "relative";
|
|
1209
|
-
const content = document.createElement("div");
|
|
1210
|
-
content.style.position = "absolute";
|
|
1211
|
-
content.style.top = `${r.offsetTop}px`;
|
|
1212
|
-
content.style.left = "0";
|
|
1213
|
-
content.style.right = "0";
|
|
1214
|
-
for (let i = r.start; i < r.end; i++) {
|
|
1215
|
-
const item = items[i];
|
|
1216
|
-
if (!item) continue;
|
|
1217
|
-
const row = nodeToDOM(ctx.props.children(item, i));
|
|
1218
|
-
if (row instanceof HTMLElement) {
|
|
1219
|
-
row.style.height = `${itemHeight}px`;
|
|
1220
|
-
}
|
|
1221
|
-
content.appendChild(row);
|
|
1222
|
-
}
|
|
1223
|
-
inner.appendChild(content);
|
|
1224
|
-
outer.appendChild(inner);
|
|
1225
|
-
return outer;
|
|
1226
|
-
};
|
|
1227
|
-
});
|
|
1228
|
-
|
|
1229
|
-
// src/async-component.ts
|
|
1230
|
-
function defineAsyncComponent(loaderOrOptions) {
|
|
1231
|
-
const options = typeof loaderOrOptions === "function" ? { loader: loaderOrOptions } : loaderOrOptions;
|
|
1232
|
-
const {
|
|
1233
|
-
loader,
|
|
1234
|
-
loading: loadingFn,
|
|
1235
|
-
error: errorFn,
|
|
1236
|
-
timeout,
|
|
1237
|
-
delay = 200
|
|
1238
|
-
} = options;
|
|
1239
|
-
let resolvedComp = null;
|
|
1240
|
-
let loadPromise = null;
|
|
1241
|
-
let loadError = null;
|
|
1242
|
-
function startLoad() {
|
|
1243
|
-
if (loadPromise) return loadPromise;
|
|
1244
|
-
loadPromise = loader().then((mod) => {
|
|
1245
|
-
resolvedComp = mod.default;
|
|
1246
|
-
}).catch((err) => {
|
|
1247
|
-
loadError = err instanceof Error ? err : new Error(String(err));
|
|
1248
|
-
});
|
|
1249
|
-
return loadPromise;
|
|
1250
|
-
}
|
|
1251
|
-
return defineComponent((ctx) => {
|
|
1252
|
-
const state = signal("loading");
|
|
1253
|
-
const showLoading = signal(false);
|
|
1254
|
-
startLoad().then(() => {
|
|
1255
|
-
if (loadError) {
|
|
1256
|
-
state.set("error");
|
|
1257
|
-
} else {
|
|
1258
|
-
state.set("ready");
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
let delayTimer = null;
|
|
1262
|
-
if (delay > 0) {
|
|
1263
|
-
delayTimer = setTimeout(() => showLoading.set(true), delay);
|
|
1264
|
-
} else {
|
|
1265
|
-
showLoading.set(true);
|
|
1266
|
-
}
|
|
1267
|
-
let timeoutTimer = null;
|
|
1268
|
-
if (timeout) {
|
|
1269
|
-
timeoutTimer = setTimeout(() => {
|
|
1270
|
-
if (state() === "loading") {
|
|
1271
|
-
loadError = new Error(`Async component timed out after ${timeout}ms`);
|
|
1272
|
-
state.set("error");
|
|
1273
|
-
}
|
|
1274
|
-
}, timeout);
|
|
1275
|
-
}
|
|
1276
|
-
return () => {
|
|
1277
|
-
const s = state();
|
|
1278
|
-
if (s !== "loading") {
|
|
1279
|
-
if (delayTimer) clearTimeout(delayTimer);
|
|
1280
|
-
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
1281
|
-
}
|
|
1282
|
-
if (s === "ready" && resolvedComp) {
|
|
1283
|
-
return resolvedComp(ctx.props);
|
|
1284
|
-
}
|
|
1285
|
-
if (s === "error" && errorFn && loadError) {
|
|
1286
|
-
return nodeToDOM(errorFn(loadError));
|
|
1287
|
-
}
|
|
1288
|
-
if (s === "loading" && showLoading() && loadingFn) {
|
|
1289
|
-
return nodeToDOM(loadingFn());
|
|
1290
|
-
}
|
|
1291
|
-
return document.createComment("async-loading");
|
|
1292
|
-
};
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
// src/reconcile.ts
|
|
1297
|
-
function longestIncreasingSubsequence(arr) {
|
|
1298
|
-
const n = arr.length;
|
|
1299
|
-
if (n === 0) return [];
|
|
1300
|
-
const tails = [];
|
|
1301
|
-
const predecessors = new Array(n).fill(-1);
|
|
1302
|
-
const indices = [];
|
|
1303
|
-
for (let i = 0; i < n; i++) {
|
|
1304
|
-
const value = arr[i];
|
|
1305
|
-
if (value === -1) continue;
|
|
1306
|
-
let lo = 0;
|
|
1307
|
-
let hi = tails.length;
|
|
1308
|
-
while (lo < hi) {
|
|
1309
|
-
const mid = lo + hi >> 1;
|
|
1310
|
-
if (tails[mid] < value) {
|
|
1311
|
-
lo = mid + 1;
|
|
1312
|
-
} else {
|
|
1313
|
-
hi = mid;
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
tails[lo] = value;
|
|
1317
|
-
indices[lo] = i;
|
|
1318
|
-
if (lo > 0) {
|
|
1319
|
-
predecessors[i] = indices[lo - 1];
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
const result = new Array(tails.length);
|
|
1323
|
-
let k = indices[tails.length - 1];
|
|
1324
|
-
for (let i = tails.length - 1; i >= 0; i--) {
|
|
1325
|
-
result[i] = k;
|
|
1326
|
-
k = predecessors[k];
|
|
1327
|
-
}
|
|
1328
|
-
return result;
|
|
1329
|
-
}
|
|
1330
|
-
function reconcileKeys(oldKeys, newKeys) {
|
|
1331
|
-
const ops = [];
|
|
1332
|
-
const oldKeyMap = /* @__PURE__ */ new Map();
|
|
1333
|
-
for (let i = 0; i < oldKeys.length; i++) {
|
|
1334
|
-
oldKeyMap.set(oldKeys[i], i);
|
|
1335
|
-
}
|
|
1336
|
-
const newToOld = new Array(newKeys.length);
|
|
1337
|
-
for (let i = 0; i < newKeys.length; i++) {
|
|
1338
|
-
newToOld[i] = oldKeyMap.get(newKeys[i]) ?? -1;
|
|
1339
|
-
}
|
|
1340
|
-
const newKeySet = new Set(newKeys);
|
|
1341
|
-
for (let i = 0; i < oldKeys.length; i++) {
|
|
1342
|
-
if (!newKeySet.has(oldKeys[i])) {
|
|
1343
|
-
ops.push({ type: "remove", oldIndex: i });
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
const lis = new Set(longestIncreasingSubsequence(newToOld));
|
|
1347
|
-
for (let i = 0; i < newKeys.length; i++) {
|
|
1348
|
-
if (newToOld[i] === -1) {
|
|
1349
|
-
ops.push({ type: "insert", newIndex: i });
|
|
1350
|
-
} else if (!lis.has(i)) {
|
|
1351
|
-
ops.push({ type: "move", newIndex: i, oldIndex: newToOld[i] });
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
return ops;
|
|
1355
|
-
}
|
|
1356
|
-
function countOps(oldKeys, newKeys) {
|
|
1357
|
-
const ops = reconcileKeys(oldKeys, newKeys);
|
|
1358
|
-
let inserts = 0, moves = 0, removes = 0;
|
|
1359
|
-
for (const op of ops) {
|
|
1360
|
-
if (op.type === "insert") inserts++;
|
|
1361
|
-
else if (op.type === "move") moves++;
|
|
1362
|
-
else removes++;
|
|
1363
|
-
}
|
|
1364
|
-
return { inserts, moves, removes };
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
// src/leak-detector.ts
|
|
1368
|
-
var tracking = false;
|
|
1369
|
-
var activeEffects = /* @__PURE__ */ new Map();
|
|
1370
|
-
var effectIdCounter = 0;
|
|
1371
|
-
function enableLeakDetection() {
|
|
1372
|
-
tracking = true;
|
|
1373
|
-
}
|
|
1374
|
-
function disableLeakDetection() {
|
|
1375
|
-
tracking = false;
|
|
1376
|
-
activeEffects.clear();
|
|
1377
|
-
}
|
|
1378
|
-
function isLeakDetectionEnabled() {
|
|
1379
|
-
return tracking;
|
|
1380
|
-
}
|
|
1381
|
-
function trackEffect(componentName) {
|
|
1382
|
-
if (!tracking) return -1;
|
|
1383
|
-
const id = ++effectIdCounter;
|
|
1384
|
-
activeEffects.set(id, {
|
|
1385
|
-
id,
|
|
1386
|
-
createdAt: Date.now(),
|
|
1387
|
-
stackTrace: captureStack(),
|
|
1388
|
-
componentName: componentName ?? null,
|
|
1389
|
-
disposed: false
|
|
1390
|
-
});
|
|
1391
|
-
return id;
|
|
1392
|
-
}
|
|
1393
|
-
function untrackEffect(id) {
|
|
1394
|
-
if (!tracking || id === -1) return;
|
|
1395
|
-
const record = activeEffects.get(id);
|
|
1396
|
-
if (record) {
|
|
1397
|
-
record.disposed = true;
|
|
1398
|
-
activeEffects.delete(id);
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
function getActiveEffects() {
|
|
1402
|
-
return Array.from(activeEffects.values());
|
|
1403
|
-
}
|
|
1404
|
-
function checkForLeaks(thresholdMs = 3e4) {
|
|
1405
|
-
if (!tracking) return [];
|
|
1406
|
-
const now = Date.now();
|
|
1407
|
-
const warnings = [];
|
|
1408
|
-
for (const record of activeEffects.values()) {
|
|
1409
|
-
if (!record.disposed && now - record.createdAt > thresholdMs) {
|
|
1410
|
-
warnings.push({
|
|
1411
|
-
effectId: record.id,
|
|
1412
|
-
age: now - record.createdAt,
|
|
1413
|
-
componentName: record.componentName,
|
|
1414
|
-
stackTrace: record.stackTrace
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
return warnings;
|
|
1419
|
-
}
|
|
1420
|
-
function reportLeaks(thresholdMs = 3e4) {
|
|
1421
|
-
const leaks = checkForLeaks(thresholdMs);
|
|
1422
|
-
if (leaks.length === 0) return;
|
|
1423
|
-
console.warn(
|
|
1424
|
-
`[AkashJS] ${leaks.length} potential effect leak(s) detected:`
|
|
1425
|
-
);
|
|
1426
|
-
for (const leak of leaks) {
|
|
1427
|
-
const component = leak.componentName ? ` in ${leak.componentName}` : "";
|
|
1428
|
-
console.warn(
|
|
1429
|
-
` Effect #${leak.effectId}${component} \u2014 active for ${(leak.age / 1e3).toFixed(1)}s`
|
|
1430
|
-
);
|
|
1431
|
-
if (leak.stackTrace) {
|
|
1432
|
-
console.warn(` Created at:
|
|
1433
|
-
${leak.stackTrace}`);
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
function getLeakDetectionStats() {
|
|
1438
|
-
return {
|
|
1439
|
-
enabled: tracking,
|
|
1440
|
-
activeCount: activeEffects.size,
|
|
1441
|
-
totalTracked: effectIdCounter
|
|
1442
|
-
};
|
|
1443
|
-
}
|
|
1444
|
-
function captureStack() {
|
|
1445
|
-
try {
|
|
1446
|
-
const err = new Error();
|
|
1447
|
-
const stack = err.stack;
|
|
1448
|
-
if (!stack) return null;
|
|
1449
|
-
const lines = stack.split("\n");
|
|
1450
|
-
return lines.slice(3, 8).join("\n");
|
|
1451
|
-
} catch {
|
|
1452
|
-
return null;
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
// src/perf.ts
|
|
1457
|
-
var profiling = false;
|
|
1458
|
-
var entries = [];
|
|
1459
|
-
var profileStart = 0;
|
|
1460
|
-
function startProfiling() {
|
|
1461
|
-
profiling = true;
|
|
1462
|
-
entries = [];
|
|
1463
|
-
profileStart = performance.now();
|
|
1464
|
-
}
|
|
1465
|
-
function stopProfiling() {
|
|
1466
|
-
profiling = false;
|
|
1467
|
-
const endTime = performance.now();
|
|
1468
|
-
return {
|
|
1469
|
-
entries: [...entries],
|
|
1470
|
-
totalDuration: endTime - profileStart,
|
|
1471
|
-
startTime: profileStart,
|
|
1472
|
-
endTime
|
|
1473
|
-
};
|
|
1474
|
-
}
|
|
1475
|
-
function isProfiling() {
|
|
1476
|
-
return profiling;
|
|
1477
|
-
}
|
|
1478
|
-
function recordPerfEntry(type, name, duration) {
|
|
1479
|
-
if (!profiling) return;
|
|
1480
|
-
entries.push({
|
|
1481
|
-
type,
|
|
1482
|
-
name,
|
|
1483
|
-
duration,
|
|
1484
|
-
timestamp: performance.now()
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
function getProfileSummary(profile) {
|
|
1488
|
-
const renders = profile.entries.filter((e) => e.type === "render");
|
|
1489
|
-
const effects = profile.entries.filter((e) => e.type === "effect");
|
|
1490
|
-
const signalUpdates = profile.entries.filter((e) => e.type === "signal-update");
|
|
1491
|
-
const computeds = profile.entries.filter((e) => e.type === "computed");
|
|
1492
|
-
const avg = (arr) => arr.length > 0 ? arr.reduce((s, e) => s + e.duration, 0) / arr.length : 0;
|
|
1493
|
-
const slowest = (arr) => arr.length > 0 ? arr.reduce((s, e) => e.duration > s.duration ? e : s) : null;
|
|
1494
|
-
return {
|
|
1495
|
-
totalRenders: renders.length,
|
|
1496
|
-
totalEffects: effects.length,
|
|
1497
|
-
totalSignalUpdates: signalUpdates.length,
|
|
1498
|
-
totalComputedEvals: computeds.length,
|
|
1499
|
-
avgRenderTime: avg(renders),
|
|
1500
|
-
avgEffectTime: avg(effects),
|
|
1501
|
-
slowestRender: slowest(renders),
|
|
1502
|
-
slowestEffect: slowest(effects)
|
|
1503
|
-
};
|
|
1504
|
-
}
|
|
1505
|
-
function measureSync(name, fn) {
|
|
1506
|
-
const start = performance.now();
|
|
1507
|
-
const result = fn();
|
|
1508
|
-
const duration = performance.now() - start;
|
|
1509
|
-
recordPerfEntry("render", name, duration);
|
|
1510
|
-
return { result, duration };
|
|
1511
|
-
}
|
|
1512
|
-
async function measureAsync(name, fn) {
|
|
1513
|
-
const start = performance.now();
|
|
1514
|
-
const result = await fn();
|
|
1515
|
-
const duration = performance.now() - start;
|
|
1516
|
-
recordPerfEntry("render", name, duration);
|
|
1517
|
-
return { result, duration };
|
|
1518
|
-
}
|
|
1519
|
-
function createTimer(name) {
|
|
1520
|
-
let startTime = 0;
|
|
1521
|
-
let dur = 0;
|
|
1522
|
-
return {
|
|
1523
|
-
start() {
|
|
1524
|
-
startTime = performance.now();
|
|
1525
|
-
},
|
|
1526
|
-
stop() {
|
|
1527
|
-
dur = performance.now() - startTime;
|
|
1528
|
-
recordPerfEntry("render", name, dur);
|
|
1529
|
-
},
|
|
1530
|
-
get duration() {
|
|
1531
|
-
return dur;
|
|
1532
|
-
}
|
|
1533
|
-
};
|
|
1534
|
-
}
|
|
1535
|
-
function formatProfile(profile) {
|
|
1536
|
-
const summary = getProfileSummary(profile);
|
|
1537
|
-
let out = "\n Performance Profile\n";
|
|
1538
|
-
out += " " + "\u2500".repeat(50) + "\n";
|
|
1539
|
-
out += ` Duration: ${profile.totalDuration.toFixed(1)} ms
|
|
1540
|
-
`;
|
|
1541
|
-
out += ` Renders: ${summary.totalRenders} (avg ${summary.avgRenderTime.toFixed(2)} ms)
|
|
1542
|
-
`;
|
|
1543
|
-
out += ` Effects: ${summary.totalEffects} (avg ${summary.avgEffectTime.toFixed(2)} ms)
|
|
1544
|
-
`;
|
|
1545
|
-
out += ` Signal updates: ${summary.totalSignalUpdates}
|
|
1546
|
-
`;
|
|
1547
|
-
out += ` Computed evals: ${summary.totalComputedEvals}
|
|
1548
|
-
`;
|
|
1549
|
-
if (summary.slowestRender) {
|
|
1550
|
-
out += ` Slowest render: ${summary.slowestRender.name} (${summary.slowestRender.duration.toFixed(2)} ms)
|
|
1551
|
-
`;
|
|
1552
|
-
}
|
|
1553
|
-
if (summary.slowestEffect) {
|
|
1554
|
-
out += ` Slowest effect: ${summary.slowestEffect.name} (${summary.slowestEffect.duration.toFixed(2)} ms)
|
|
1555
|
-
`;
|
|
1556
|
-
}
|
|
1557
|
-
out += " " + "\u2500".repeat(50) + "\n";
|
|
1558
|
-
return out;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
// src/a11y.ts
|
|
1562
|
-
var FOCUSABLE_SELECTOR = [
|
|
1563
|
-
"a[href]",
|
|
1564
|
-
"button:not([disabled])",
|
|
1565
|
-
"input:not([disabled])",
|
|
1566
|
-
"select:not([disabled])",
|
|
1567
|
-
"textarea:not([disabled])",
|
|
1568
|
-
'[tabindex]:not([tabindex="-1"])',
|
|
1569
|
-
"[contenteditable]"
|
|
1570
|
-
].join(", ");
|
|
1571
|
-
function useFocusTrap(container, options = {}) {
|
|
1572
|
-
const {
|
|
1573
|
-
initialFocus,
|
|
1574
|
-
returnFocus = true,
|
|
1575
|
-
escapeDeactivates = true,
|
|
1576
|
-
allowOutsideClick = false,
|
|
1577
|
-
onDeactivate
|
|
1578
|
-
} = options;
|
|
1579
|
-
const active = signal(false);
|
|
1580
|
-
let previouslyFocused = null;
|
|
1581
|
-
function getContainer() {
|
|
1582
|
-
return typeof container === "function" ? container() : container;
|
|
1583
|
-
}
|
|
1584
|
-
function getFocusableElements() {
|
|
1585
|
-
const el = getContainer();
|
|
1586
|
-
if (!el) return [];
|
|
1587
|
-
return Array.from(el.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
1588
|
-
}
|
|
1589
|
-
function handleKeyDown(e) {
|
|
1590
|
-
if (e.key === "Escape" && escapeDeactivates) {
|
|
1591
|
-
e.preventDefault();
|
|
1592
|
-
deactivate();
|
|
1593
|
-
onDeactivate?.();
|
|
1594
|
-
return;
|
|
1595
|
-
}
|
|
1596
|
-
if (e.key !== "Tab") return;
|
|
1597
|
-
const focusable = getFocusableElements();
|
|
1598
|
-
if (focusable.length === 0) return;
|
|
1599
|
-
const first = focusable[0];
|
|
1600
|
-
const last = focusable[focusable.length - 1];
|
|
1601
|
-
if (e.shiftKey) {
|
|
1602
|
-
if (document.activeElement === first) {
|
|
1603
|
-
e.preventDefault();
|
|
1604
|
-
last.focus();
|
|
1605
|
-
}
|
|
1606
|
-
} else {
|
|
1607
|
-
if (document.activeElement === last) {
|
|
1608
|
-
e.preventDefault();
|
|
1609
|
-
first.focus();
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
function handleFocusOut(e) {
|
|
1614
|
-
if (!active() || allowOutsideClick) return;
|
|
1615
|
-
const el = getContainer();
|
|
1616
|
-
if (!el) return;
|
|
1617
|
-
const relatedTarget = e.relatedTarget;
|
|
1618
|
-
if (relatedTarget && !el.contains(relatedTarget)) {
|
|
1619
|
-
const focusable = getFocusableElements();
|
|
1620
|
-
if (focusable.length > 0) {
|
|
1621
|
-
focusable[0].focus();
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
function activate() {
|
|
1626
|
-
if (active()) return;
|
|
1627
|
-
active.set(true);
|
|
1628
|
-
previouslyFocused = document.activeElement;
|
|
1629
|
-
document.addEventListener("keydown", handleKeyDown, true);
|
|
1630
|
-
const el = getContainer();
|
|
1631
|
-
if (el) {
|
|
1632
|
-
el.addEventListener("focusout", handleFocusOut);
|
|
1633
|
-
}
|
|
1634
|
-
requestAnimationFrame(() => {
|
|
1635
|
-
if (initialFocus) {
|
|
1636
|
-
const target = typeof initialFocus === "string" ? getContainer()?.querySelector(initialFocus) : initialFocus;
|
|
1637
|
-
target?.focus();
|
|
1638
|
-
} else {
|
|
1639
|
-
const focusable = getFocusableElements();
|
|
1640
|
-
if (focusable.length > 0) focusable[0].focus();
|
|
1641
|
-
}
|
|
1642
|
-
});
|
|
1643
|
-
}
|
|
1644
|
-
function deactivate() {
|
|
1645
|
-
if (!active()) return;
|
|
1646
|
-
active.set(false);
|
|
1647
|
-
document.removeEventListener("keydown", handleKeyDown, true);
|
|
1648
|
-
const el = getContainer();
|
|
1649
|
-
if (el) {
|
|
1650
|
-
el.removeEventListener("focusout", handleFocusOut);
|
|
1651
|
-
}
|
|
1652
|
-
if (returnFocus && previouslyFocused) {
|
|
1653
|
-
previouslyFocused.focus();
|
|
1654
|
-
previouslyFocused = null;
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
return {
|
|
1658
|
-
activate,
|
|
1659
|
-
deactivate,
|
|
1660
|
-
active: () => active()
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
var announceRegion = null;
|
|
1664
|
-
function ensureAnnounceRegion() {
|
|
1665
|
-
if (announceRegion && document.body.contains(announceRegion)) {
|
|
1666
|
-
return announceRegion;
|
|
1667
|
-
}
|
|
1668
|
-
const el = document.createElement("div");
|
|
1669
|
-
el.setAttribute("role", "status");
|
|
1670
|
-
el.setAttribute("aria-live", "polite");
|
|
1671
|
-
el.setAttribute("aria-atomic", "true");
|
|
1672
|
-
el.style.cssText = [
|
|
1673
|
-
"position: absolute",
|
|
1674
|
-
"width: 1px",
|
|
1675
|
-
"height: 1px",
|
|
1676
|
-
"padding: 0",
|
|
1677
|
-
"margin: -1px",
|
|
1678
|
-
"overflow: hidden",
|
|
1679
|
-
"clip: rect(0,0,0,0)",
|
|
1680
|
-
"white-space: nowrap",
|
|
1681
|
-
"border: 0"
|
|
1682
|
-
].join("; ");
|
|
1683
|
-
document.body.appendChild(el);
|
|
1684
|
-
announceRegion = el;
|
|
1685
|
-
return el;
|
|
1686
|
-
}
|
|
1687
|
-
function useAnnounce() {
|
|
1688
|
-
return (message, politeness = "polite") => {
|
|
1689
|
-
if (typeof document === "undefined") return;
|
|
1690
|
-
const region = ensureAnnounceRegion();
|
|
1691
|
-
region.setAttribute("aria-live", politeness);
|
|
1692
|
-
region.textContent = "";
|
|
1693
|
-
requestAnimationFrame(() => {
|
|
1694
|
-
region.textContent = message;
|
|
1695
|
-
});
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
|
-
function useKeyboard() {
|
|
1699
|
-
const bindings = [];
|
|
1700
|
-
const activeScopes = /* @__PURE__ */ new Set();
|
|
1701
|
-
let listening = false;
|
|
1702
|
-
function handleKeyDown(e) {
|
|
1703
|
-
for (const binding of bindings) {
|
|
1704
|
-
if (binding.scope && !activeScopes.has(binding.scope)) continue;
|
|
1705
|
-
if (matchesKey(e, binding.key)) {
|
|
1706
|
-
if (binding.preventDefault !== false) {
|
|
1707
|
-
e.preventDefault();
|
|
1708
|
-
}
|
|
1709
|
-
binding.handler(e);
|
|
1710
|
-
return;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
function startListening() {
|
|
1715
|
-
if (listening) return;
|
|
1716
|
-
if (typeof document === "undefined") return;
|
|
1717
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
1718
|
-
listening = true;
|
|
1719
|
-
}
|
|
1720
|
-
function bind(key, handler, options) {
|
|
1721
|
-
const binding = {
|
|
1722
|
-
key,
|
|
1723
|
-
handler,
|
|
1724
|
-
scope: options?.scope,
|
|
1725
|
-
description: options?.description ?? "",
|
|
1726
|
-
preventDefault: options?.preventDefault
|
|
1727
|
-
};
|
|
1728
|
-
bindings.push(binding);
|
|
1729
|
-
startListening();
|
|
1730
|
-
return () => {
|
|
1731
|
-
const idx = bindings.indexOf(binding);
|
|
1732
|
-
if (idx !== -1) bindings.splice(idx, 1);
|
|
1733
|
-
};
|
|
1734
|
-
}
|
|
1735
|
-
return {
|
|
1736
|
-
bind,
|
|
1737
|
-
enableScope(scope) {
|
|
1738
|
-
activeScopes.add(scope);
|
|
1739
|
-
},
|
|
1740
|
-
disableScope(scope) {
|
|
1741
|
-
activeScopes.delete(scope);
|
|
1742
|
-
},
|
|
1743
|
-
getBindings() {
|
|
1744
|
-
return bindings.map((b) => ({
|
|
1745
|
-
key: formatKeyCombo(b.key),
|
|
1746
|
-
description: b.description ?? "",
|
|
1747
|
-
scope: b.scope
|
|
1748
|
-
}));
|
|
1749
|
-
},
|
|
1750
|
-
dispose() {
|
|
1751
|
-
bindings.length = 0;
|
|
1752
|
-
if (typeof document !== "undefined") {
|
|
1753
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
1754
|
-
}
|
|
1755
|
-
listening = false;
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1758
|
-
}
|
|
1759
|
-
function matchesKey(e, combo) {
|
|
1760
|
-
const parts = combo.toLowerCase().split("+");
|
|
1761
|
-
const key = parts.pop();
|
|
1762
|
-
const needsMod = parts.includes("mod");
|
|
1763
|
-
const needsCtrl = parts.includes("ctrl");
|
|
1764
|
-
const needsShift = parts.includes("shift");
|
|
1765
|
-
const needsAlt = parts.includes("alt");
|
|
1766
|
-
const isMac = typeof navigator !== "undefined" && navigator.platform?.includes("Mac");
|
|
1767
|
-
const modPressed = isMac ? e.metaKey : e.ctrlKey;
|
|
1768
|
-
if (needsMod && !modPressed) return false;
|
|
1769
|
-
if (needsCtrl && !e.ctrlKey) return false;
|
|
1770
|
-
if (needsShift && !e.shiftKey) return false;
|
|
1771
|
-
if (needsAlt && !e.altKey) return false;
|
|
1772
|
-
return e.key.toLowerCase() === key || e.code.toLowerCase() === key;
|
|
1773
|
-
}
|
|
1774
|
-
function formatKeyCombo(combo) {
|
|
1775
|
-
const isMac = typeof navigator !== "undefined" && navigator.platform?.includes("Mac");
|
|
1776
|
-
return combo.replace(/mod/gi, isMac ? "\u2318" : "Ctrl").replace(/shift/gi, isMac ? "\u21E7" : "Shift").replace(/alt/gi, isMac ? "\u2325" : "Alt").replace(/\+/g, isMac ? "" : "+");
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
// src/image.ts
|
|
1780
|
-
var Image = defineComponent((ctx) => {
|
|
1781
|
-
const loaded = signal(false);
|
|
1782
|
-
const errored = signal(false);
|
|
1783
|
-
return () => {
|
|
1784
|
-
const {
|
|
1785
|
-
src,
|
|
1786
|
-
alt,
|
|
1787
|
-
width,
|
|
1788
|
-
height,
|
|
1789
|
-
loading = "lazy",
|
|
1790
|
-
srcset,
|
|
1791
|
-
sizes,
|
|
1792
|
-
placeholder,
|
|
1793
|
-
blurDataUrl,
|
|
1794
|
-
class: className,
|
|
1795
|
-
fallbackSrc,
|
|
1796
|
-
onLoad,
|
|
1797
|
-
onError: onErrorCb
|
|
1798
|
-
} = ctx.props;
|
|
1799
|
-
const wrapper = document.createElement("div");
|
|
1800
|
-
wrapper.style.position = "relative";
|
|
1801
|
-
wrapper.style.display = "inline-block";
|
|
1802
|
-
wrapper.style.overflow = "hidden";
|
|
1803
|
-
if (width) wrapper.style.width = `${width}px`;
|
|
1804
|
-
if (height) wrapper.style.height = `${height}px`;
|
|
1805
|
-
if (placeholder === "blur" && blurDataUrl && !loaded()) {
|
|
1806
|
-
const blur = document.createElement("img");
|
|
1807
|
-
blur.src = blurDataUrl;
|
|
1808
|
-
blur.alt = "";
|
|
1809
|
-
blur.setAttribute("aria-hidden", "true");
|
|
1810
|
-
blur.style.cssText = "position:absolute;inset:0;width:100%;height:100%;object-fit:cover;filter:blur(20px);transform:scale(1.1);";
|
|
1811
|
-
wrapper.appendChild(blur);
|
|
1812
|
-
}
|
|
1813
|
-
const img = document.createElement("img");
|
|
1814
|
-
img.alt = alt;
|
|
1815
|
-
img.loading = loading;
|
|
1816
|
-
if (errored() && fallbackSrc) {
|
|
1817
|
-
img.src = fallbackSrc;
|
|
1818
|
-
} else {
|
|
1819
|
-
img.src = src;
|
|
1820
|
-
}
|
|
1821
|
-
if (srcset) img.srcset = srcset;
|
|
1822
|
-
if (sizes) img.sizes = sizes;
|
|
1823
|
-
if (width) img.width = width;
|
|
1824
|
-
if (height) img.height = height;
|
|
1825
|
-
if (className) img.className = className;
|
|
1826
|
-
img.style.display = "block";
|
|
1827
|
-
img.style.width = "100%";
|
|
1828
|
-
img.style.height = "auto";
|
|
1829
|
-
img.addEventListener("load", () => {
|
|
1830
|
-
loaded.set(true);
|
|
1831
|
-
onLoad?.();
|
|
1832
|
-
});
|
|
1833
|
-
img.addEventListener("error", (e) => {
|
|
1834
|
-
errored.set(true);
|
|
1835
|
-
onErrorCb?.(e);
|
|
1836
|
-
});
|
|
1837
|
-
if (loading === "lazy" && typeof IntersectionObserver !== "undefined") {
|
|
1838
|
-
img.setAttribute("data-src", img.src);
|
|
1839
|
-
const actualSrc = img.src;
|
|
1840
|
-
img.removeAttribute("src");
|
|
1841
|
-
const observer = new IntersectionObserver(
|
|
1842
|
-
(entries2) => {
|
|
1843
|
-
if (entries2[0].isIntersecting) {
|
|
1844
|
-
img.src = actualSrc;
|
|
1845
|
-
observer.disconnect();
|
|
1846
|
-
}
|
|
1847
|
-
},
|
|
1848
|
-
{ rootMargin: "200px" }
|
|
1849
|
-
);
|
|
1850
|
-
requestAnimationFrame(() => {
|
|
1851
|
-
if (img.parentElement) {
|
|
1852
|
-
observer.observe(img);
|
|
1853
|
-
} else {
|
|
1854
|
-
img.src = actualSrc;
|
|
1855
|
-
}
|
|
1856
|
-
});
|
|
1857
|
-
}
|
|
1858
|
-
wrapper.appendChild(img);
|
|
1859
|
-
return wrapper;
|
|
1860
|
-
};
|
|
1861
|
-
});
|
|
1862
|
-
|
|
1863
|
-
// src/infinite-scroll.ts
|
|
1864
|
-
function useInfiniteScroll(options) {
|
|
1865
|
-
const { onLoadMore, hasMore, rootMargin = "200px", threshold = 0 } = options;
|
|
1866
|
-
const loading = signal(false);
|
|
1867
|
-
const done = signal(false);
|
|
1868
|
-
let observer = null;
|
|
1869
|
-
let sentinelEl = null;
|
|
1870
|
-
let disposed = false;
|
|
1871
|
-
async function handleIntersect() {
|
|
1872
|
-
if (loading() || done() || disposed) return;
|
|
1873
|
-
if (!hasMore()) {
|
|
1874
|
-
done.set(true);
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
loading.set(true);
|
|
1878
|
-
try {
|
|
1879
|
-
await onLoadMore();
|
|
1880
|
-
if (!hasMore()) {
|
|
1881
|
-
done.set(true);
|
|
1882
|
-
}
|
|
1883
|
-
} finally {
|
|
1884
|
-
loading.set(false);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
function createObserver(el) {
|
|
1888
|
-
if (typeof IntersectionObserver === "undefined") return;
|
|
1889
|
-
observer = new IntersectionObserver(
|
|
1890
|
-
(entries2) => {
|
|
1891
|
-
if (entries2[0]?.isIntersecting) {
|
|
1892
|
-
handleIntersect();
|
|
1893
|
-
}
|
|
1894
|
-
},
|
|
1895
|
-
{ rootMargin, threshold }
|
|
1896
|
-
);
|
|
1897
|
-
observer.observe(el);
|
|
1898
|
-
}
|
|
1899
|
-
function sentinel() {
|
|
1900
|
-
if (sentinelEl) return sentinelEl;
|
|
1901
|
-
sentinelEl = document.createElement("div");
|
|
1902
|
-
sentinelEl.setAttribute("data-akash-sentinel", "");
|
|
1903
|
-
sentinelEl.style.height = "1px";
|
|
1904
|
-
sentinelEl.setAttribute("aria-hidden", "true");
|
|
1905
|
-
requestAnimationFrame(() => {
|
|
1906
|
-
if (sentinelEl && !disposed) {
|
|
1907
|
-
createObserver(sentinelEl);
|
|
1908
|
-
}
|
|
1909
|
-
});
|
|
1910
|
-
return sentinelEl;
|
|
1911
|
-
}
|
|
1912
|
-
return {
|
|
1913
|
-
sentinel,
|
|
1914
|
-
loading: () => loading(),
|
|
1915
|
-
done: () => done(),
|
|
1916
|
-
reset() {
|
|
1917
|
-
done.set(false);
|
|
1918
|
-
loading.set(false);
|
|
1919
|
-
},
|
|
1920
|
-
dispose() {
|
|
1921
|
-
disposed = true;
|
|
1922
|
-
observer?.disconnect();
|
|
1923
|
-
observer = null;
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
|
-
// src/css.ts
|
|
1929
|
-
function cx(...inputs) {
|
|
1930
|
-
const classes = [];
|
|
1931
|
-
for (const input of inputs) {
|
|
1932
|
-
if (!input) continue;
|
|
1933
|
-
if (typeof input === "string") {
|
|
1934
|
-
classes.push(input);
|
|
1935
|
-
} else if (Array.isArray(input)) {
|
|
1936
|
-
const nested = cx(...input);
|
|
1937
|
-
if (nested) classes.push(nested);
|
|
1938
|
-
} else if (typeof input === "object") {
|
|
1939
|
-
for (const [key, value] of Object.entries(input)) {
|
|
1940
|
-
if (value) classes.push(key);
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
return classes.join(" ");
|
|
1945
|
-
}
|
|
1946
|
-
function css(styles) {
|
|
1947
|
-
const parts = [];
|
|
1948
|
-
for (const [key, value] of Object.entries(styles)) {
|
|
1949
|
-
if (value == null) continue;
|
|
1950
|
-
const prop = camelToKebab(key);
|
|
1951
|
-
const val = typeof value === "number" && !UNITLESS_PROPS.has(key) ? `${value}px` : String(value);
|
|
1952
|
-
parts.push(`${prop}: ${val}`);
|
|
1953
|
-
}
|
|
1954
|
-
return parts.join("; ");
|
|
1955
|
-
}
|
|
1956
|
-
function applyStyles(el, styles) {
|
|
1957
|
-
for (const [key, value] of Object.entries(styles)) {
|
|
1958
|
-
if (value == null) {
|
|
1959
|
-
el.style.removeProperty(camelToKebab(key));
|
|
1960
|
-
} else {
|
|
1961
|
-
const val = typeof value === "number" && !UNITLESS_PROPS.has(key) ? `${value}px` : String(value);
|
|
1962
|
-
el.style.setProperty(camelToKebab(key), val);
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
function camelToKebab(str) {
|
|
1967
|
-
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
1968
|
-
}
|
|
1969
|
-
var UNITLESS_PROPS = /* @__PURE__ */ new Set([
|
|
1970
|
-
"animationIterationCount",
|
|
1971
|
-
"boxFlex",
|
|
1972
|
-
"boxFlexGroup",
|
|
1973
|
-
"boxOrdinalGroup",
|
|
1974
|
-
"columnCount",
|
|
1975
|
-
"fillOpacity",
|
|
1976
|
-
"flex",
|
|
1977
|
-
"flexGrow",
|
|
1978
|
-
"flexPositive",
|
|
1979
|
-
"flexShrink",
|
|
1980
|
-
"flexNegative",
|
|
1981
|
-
"flexOrder",
|
|
1982
|
-
"fontWeight",
|
|
1983
|
-
"gridColumn",
|
|
1984
|
-
"gridRow",
|
|
1985
|
-
"lineClamp",
|
|
1986
|
-
"lineHeight",
|
|
1987
|
-
"opacity",
|
|
1988
|
-
"order",
|
|
1989
|
-
"orphans",
|
|
1990
|
-
"tabSize",
|
|
1991
|
-
"widows",
|
|
1992
|
-
"zIndex",
|
|
1993
|
-
"zoom"
|
|
1994
|
-
]);
|
|
1995
|
-
|
|
1996
|
-
// src/data-table.ts
|
|
1997
|
-
function createDataTable(options) {
|
|
1998
|
-
const { data, columns, pageSize = 0, initialSort } = options;
|
|
1999
|
-
const sortState = signal(initialSort ?? { column: null, direction: null });
|
|
2000
|
-
const filterText = signal("");
|
|
2001
|
-
const page = signal(1);
|
|
2002
|
-
const columnVisibility = signal(
|
|
2003
|
-
Object.fromEntries(columns.map((c) => [c.key, c.visible !== false]))
|
|
2004
|
-
);
|
|
2005
|
-
const visibleColumns = computed(() => {
|
|
2006
|
-
const vis = columnVisibility();
|
|
2007
|
-
return columns.filter((c) => vis[c.key]);
|
|
2008
|
-
});
|
|
2009
|
-
const filteredRows = computed(() => {
|
|
2010
|
-
const text = filterText().toLowerCase().trim();
|
|
2011
|
-
if (!text) return data();
|
|
2012
|
-
const filterableCols = columns.filter((c) => c.filterable);
|
|
2013
|
-
if (filterableCols.length === 0) return data();
|
|
2014
|
-
return data().filter((row) => {
|
|
2015
|
-
return filterableCols.some((col) => {
|
|
2016
|
-
const value = getNestedValue(row, col.key);
|
|
2017
|
-
return String(value).toLowerCase().includes(text);
|
|
2018
|
-
});
|
|
2019
|
-
});
|
|
2020
|
-
});
|
|
2021
|
-
const sortedRows = computed(() => {
|
|
2022
|
-
const { column, direction } = sortState();
|
|
2023
|
-
const rows = [...filteredRows()];
|
|
2024
|
-
if (!column || !direction) return rows;
|
|
2025
|
-
const colDef = columns.find((c) => c.key === column);
|
|
2026
|
-
if (!colDef) return rows;
|
|
2027
|
-
return rows.sort((a, b) => {
|
|
2028
|
-
if (colDef.compare) {
|
|
2029
|
-
const result2 = colDef.compare(a, b);
|
|
2030
|
-
return direction === "desc" ? -result2 : result2;
|
|
2031
|
-
}
|
|
2032
|
-
const aVal = getNestedValue(a, column);
|
|
2033
|
-
const bVal = getNestedValue(b, column);
|
|
2034
|
-
const result = defaultCompare(aVal, bVal);
|
|
2035
|
-
return direction === "desc" ? -result : result;
|
|
2036
|
-
});
|
|
2037
|
-
});
|
|
2038
|
-
const totalRows = computed(() => filteredRows().length);
|
|
2039
|
-
const totalPages = computed(() => {
|
|
2040
|
-
if (pageSize <= 0) return 1;
|
|
2041
|
-
return Math.max(1, Math.ceil(totalRows() / pageSize));
|
|
2042
|
-
});
|
|
2043
|
-
const paginatedRows = computed(() => {
|
|
2044
|
-
const all = sortedRows();
|
|
2045
|
-
if (pageSize <= 0) return all;
|
|
2046
|
-
const start = (page() - 1) * pageSize;
|
|
2047
|
-
return all.slice(start, start + pageSize);
|
|
2048
|
-
});
|
|
2049
|
-
function sort(columnKey) {
|
|
2050
|
-
const current = sortState();
|
|
2051
|
-
if (current.column === columnKey) {
|
|
2052
|
-
if (current.direction === "asc") {
|
|
2053
|
-
sortState.set({ column: columnKey, direction: "desc" });
|
|
2054
|
-
} else if (current.direction === "desc") {
|
|
2055
|
-
sortState.set({ column: null, direction: null });
|
|
2056
|
-
} else {
|
|
2057
|
-
sortState.set({ column: columnKey, direction: "asc" });
|
|
2058
|
-
}
|
|
2059
|
-
} else {
|
|
2060
|
-
sortState.set({ column: columnKey, direction: "asc" });
|
|
2061
|
-
}
|
|
2062
|
-
page.set(1);
|
|
2063
|
-
}
|
|
2064
|
-
function filter(text) {
|
|
2065
|
-
filterText.set(text);
|
|
2066
|
-
page.set(1);
|
|
2067
|
-
}
|
|
2068
|
-
function toggleColumn(key) {
|
|
2069
|
-
columnVisibility.update((vis) => ({ ...vis, [key]: !vis[key] }));
|
|
2070
|
-
}
|
|
2071
|
-
function showColumn(key) {
|
|
2072
|
-
columnVisibility.update((vis) => ({ ...vis, [key]: true }));
|
|
2073
|
-
}
|
|
2074
|
-
function hideColumn(key) {
|
|
2075
|
-
columnVisibility.update((vis) => ({ ...vis, [key]: false }));
|
|
2076
|
-
}
|
|
2077
|
-
return {
|
|
2078
|
-
rows: paginatedRows,
|
|
2079
|
-
allRows: sortedRows,
|
|
2080
|
-
totalRows,
|
|
2081
|
-
visibleColumns,
|
|
2082
|
-
sortState: () => sortState(),
|
|
2083
|
-
filterText: () => filterText(),
|
|
2084
|
-
page: () => page(),
|
|
2085
|
-
totalPages,
|
|
2086
|
-
sort,
|
|
2087
|
-
filter,
|
|
2088
|
-
toggleColumn,
|
|
2089
|
-
showColumn,
|
|
2090
|
-
hideColumn,
|
|
2091
|
-
nextPage() {
|
|
2092
|
-
if (page() < totalPages()) page.update((p) => p + 1);
|
|
2093
|
-
},
|
|
2094
|
-
prevPage() {
|
|
2095
|
-
if (page() > 1) page.update((p) => p - 1);
|
|
2096
|
-
},
|
|
2097
|
-
goToPage(p) {
|
|
2098
|
-
page.set(Math.max(1, Math.min(p, totalPages())));
|
|
2099
|
-
},
|
|
2100
|
-
reset() {
|
|
2101
|
-
sortState.set({ column: null, direction: null });
|
|
2102
|
-
filterText.set("");
|
|
2103
|
-
page.set(1);
|
|
2104
|
-
}
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
function getNestedValue(obj, path) {
|
|
2108
|
-
return path.split(".").reduce((o, k) => o?.[k], obj);
|
|
2109
|
-
}
|
|
2110
|
-
function defaultCompare(a, b) {
|
|
2111
|
-
if (a == null && b == null) return 0;
|
|
2112
|
-
if (a == null) return -1;
|
|
2113
|
-
if (b == null) return 1;
|
|
2114
|
-
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
2115
|
-
return String(a).localeCompare(String(b));
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
// src/seo.ts
|
|
2119
|
-
function useStructuredData(data) {
|
|
2120
|
-
const items = Array.isArray(data) ? data : [data];
|
|
2121
|
-
for (const item of items) {
|
|
2122
|
-
const ld = { "@context": "https://schema.org", ...item };
|
|
2123
|
-
useHead({
|
|
2124
|
-
script: [
|
|
2125
|
-
{ type: "application/ld+json", innerHTML: JSON.stringify(ld) }
|
|
2126
|
-
]
|
|
2127
|
-
});
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
function useOpenGraph(data) {
|
|
2131
|
-
const meta = [
|
|
2132
|
-
{ property: "og:title", content: data.title }
|
|
2133
|
-
];
|
|
2134
|
-
if (data.description) meta.push({ property: "og:description", content: data.description });
|
|
2135
|
-
if (data.image) meta.push({ property: "og:image", content: data.image });
|
|
2136
|
-
if (data.url) meta.push({ property: "og:url", content: data.url });
|
|
2137
|
-
if (data.type) meta.push({ property: "og:type", content: data.type });
|
|
2138
|
-
if (data.siteName) meta.push({ property: "og:site_name", content: data.siteName });
|
|
2139
|
-
if (data.locale) meta.push({ property: "og:locale", content: data.locale });
|
|
2140
|
-
useHead({ meta });
|
|
2141
|
-
}
|
|
2142
|
-
function useTwitterCard(data) {
|
|
2143
|
-
const meta = [
|
|
2144
|
-
{ name: "twitter:title", content: data.title }
|
|
2145
|
-
];
|
|
2146
|
-
if (data.card) meta.push({ name: "twitter:card", content: data.card });
|
|
2147
|
-
if (data.description) meta.push({ name: "twitter:description", content: data.description });
|
|
2148
|
-
if (data.image) meta.push({ name: "twitter:image", content: data.image });
|
|
2149
|
-
if (data.site) meta.push({ name: "twitter:site", content: data.site });
|
|
2150
|
-
if (data.creator) meta.push({ name: "twitter:creator", content: data.creator });
|
|
2151
|
-
useHead({ meta });
|
|
2152
|
-
}
|
|
2153
|
-
function useSEO(config) {
|
|
2154
|
-
const meta = [];
|
|
2155
|
-
if (config.description) {
|
|
2156
|
-
meta.push({ name: "description", content: config.description });
|
|
2157
|
-
}
|
|
2158
|
-
if (config.robots) {
|
|
2159
|
-
meta.push({ name: "robots", content: config.robots });
|
|
2160
|
-
}
|
|
2161
|
-
const link = [];
|
|
2162
|
-
if (config.canonical) {
|
|
2163
|
-
link.push({ rel: "canonical", href: config.canonical });
|
|
2164
|
-
}
|
|
2165
|
-
useHead({ title: config.title, meta, link });
|
|
2166
|
-
if (config.openGraph) useOpenGraph(config.openGraph);
|
|
2167
|
-
if (config.twitter) useTwitterCard(config.twitter);
|
|
2168
|
-
if (config.structuredData) useStructuredData(config.structuredData);
|
|
2169
|
-
}
|
|
2170
|
-
function generateSitemap(baseUrl, entries2) {
|
|
2171
|
-
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
2172
|
-
xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n';
|
|
2173
|
-
for (const entry of entries2) {
|
|
2174
|
-
xml += " <url>\n";
|
|
2175
|
-
xml += ` <loc>${baseUrl}${entry.url}</loc>
|
|
2176
|
-
`;
|
|
2177
|
-
if (entry.lastmod) xml += ` <lastmod>${entry.lastmod}</lastmod>
|
|
2178
|
-
`;
|
|
2179
|
-
if (entry.changefreq) xml += ` <changefreq>${entry.changefreq}</changefreq>
|
|
2180
|
-
`;
|
|
2181
|
-
if (entry.priority != null) xml += ` <priority>${entry.priority}</priority>
|
|
2182
|
-
`;
|
|
2183
|
-
xml += " </url>\n";
|
|
2184
|
-
}
|
|
2185
|
-
xml += "</urlset>\n";
|
|
2186
|
-
return xml;
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
// src/sync.ts
|
|
2190
|
-
var LWWRegister = class {
|
|
2191
|
-
entry;
|
|
2192
|
-
constructor(initialValue, peerId) {
|
|
2193
|
-
this.entry = { value: initialValue, timestamp: Date.now(), peerId };
|
|
2194
|
-
}
|
|
2195
|
-
get value() {
|
|
2196
|
-
return this.entry.value;
|
|
2197
|
-
}
|
|
2198
|
-
get timestamp() {
|
|
2199
|
-
return this.entry.timestamp;
|
|
2200
|
-
}
|
|
2201
|
-
set(value, peerId) {
|
|
2202
|
-
const ts = Date.now();
|
|
2203
|
-
if (peerId === this.entry.peerId || ts > this.entry.timestamp || ts === this.entry.timestamp && peerId > this.entry.peerId) {
|
|
2204
|
-
this.entry = { value, timestamp: Math.max(ts, this.entry.timestamp + 1), peerId };
|
|
2205
|
-
return true;
|
|
2206
|
-
}
|
|
2207
|
-
return false;
|
|
2208
|
-
}
|
|
2209
|
-
merge(remote) {
|
|
2210
|
-
if (remote.timestamp > this.entry.timestamp || remote.timestamp === this.entry.timestamp && remote.peerId > this.entry.peerId) {
|
|
2211
|
-
this.entry = remote;
|
|
2212
|
-
return true;
|
|
2213
|
-
}
|
|
2214
|
-
return false;
|
|
2215
|
-
}
|
|
2216
|
-
toEntry() {
|
|
2217
|
-
return { ...this.entry };
|
|
2218
|
-
}
|
|
2219
|
-
};
|
|
2220
|
-
function createWebSocketTransport(options) {
|
|
2221
|
-
let ws = null;
|
|
2222
|
-
const opHandlers = [];
|
|
2223
|
-
const presenceHandlers = [];
|
|
2224
|
-
return {
|
|
2225
|
-
send(op) {
|
|
2226
|
-
ws?.send(JSON.stringify({ type: "op", room: options.room, ...op }));
|
|
2227
|
-
},
|
|
2228
|
-
onReceive(handler) {
|
|
2229
|
-
opHandlers.push(handler);
|
|
2230
|
-
return () => {
|
|
2231
|
-
const i = opHandlers.indexOf(handler);
|
|
2232
|
-
if (i !== -1) opHandlers.splice(i, 1);
|
|
2233
|
-
};
|
|
2234
|
-
},
|
|
2235
|
-
onPresence(handler) {
|
|
2236
|
-
presenceHandlers.push(handler);
|
|
2237
|
-
return () => {
|
|
2238
|
-
const i = presenceHandlers.indexOf(handler);
|
|
2239
|
-
if (i !== -1) presenceHandlers.splice(i, 1);
|
|
2240
|
-
};
|
|
2241
|
-
},
|
|
2242
|
-
sendPresence(data) {
|
|
2243
|
-
ws?.send(JSON.stringify({ type: "presence", room: options.room, data }));
|
|
2244
|
-
},
|
|
2245
|
-
connect() {
|
|
2246
|
-
ws = new WebSocket(options.url, options.protocols);
|
|
2247
|
-
ws.onmessage = (e) => {
|
|
2248
|
-
try {
|
|
2249
|
-
const msg = JSON.parse(e.data);
|
|
2250
|
-
if (msg.type === "op") {
|
|
2251
|
-
for (const h of opHandlers) h(msg);
|
|
2252
|
-
} else if (msg.type === "presence") {
|
|
2253
|
-
for (const h of presenceHandlers) h(msg.peerId, msg.data);
|
|
2254
|
-
}
|
|
2255
|
-
} catch {
|
|
2256
|
-
}
|
|
2257
|
-
};
|
|
2258
|
-
ws.onopen = () => {
|
|
2259
|
-
ws?.send(JSON.stringify({ type: "join", room: options.room }));
|
|
2260
|
-
};
|
|
2261
|
-
},
|
|
2262
|
-
disconnect() {
|
|
2263
|
-
ws?.close();
|
|
2264
|
-
ws = null;
|
|
2265
|
-
}
|
|
2266
|
-
};
|
|
2267
|
-
}
|
|
2268
|
-
function createLocalTransport() {
|
|
2269
|
-
const opHandlers = [];
|
|
2270
|
-
return {
|
|
2271
|
-
send(op) {
|
|
2272
|
-
for (const h of opHandlers) h(op);
|
|
2273
|
-
},
|
|
2274
|
-
onReceive(handler) {
|
|
2275
|
-
opHandlers.push(handler);
|
|
2276
|
-
return () => {
|
|
2277
|
-
const i = opHandlers.indexOf(handler);
|
|
2278
|
-
if (i !== -1) opHandlers.splice(i, 1);
|
|
2279
|
-
};
|
|
2280
|
-
},
|
|
2281
|
-
connect() {
|
|
2282
|
-
},
|
|
2283
|
-
disconnect() {
|
|
2284
|
-
}
|
|
2285
|
-
};
|
|
2286
|
-
}
|
|
2287
|
-
var peerIdCounter = 0;
|
|
2288
|
-
function createSync(roomId, initialState, options = {}) {
|
|
2289
|
-
const peerId = options.peerId ?? `peer-${++peerIdCounter}-${Date.now()}`;
|
|
2290
|
-
const transport = options.transport ?? createLocalTransport();
|
|
2291
|
-
const registers = /* @__PURE__ */ new Map();
|
|
2292
|
-
const stateSignals = {};
|
|
2293
|
-
for (const [key, value] of Object.entries(initialState)) {
|
|
2294
|
-
registers.set(key, new LWWRegister(value, peerId));
|
|
2295
|
-
stateSignals[key] = signal(value);
|
|
2296
|
-
}
|
|
2297
|
-
const state = {};
|
|
2298
|
-
for (const key of Object.keys(initialState)) {
|
|
2299
|
-
const original = stateSignals[key];
|
|
2300
|
-
const register = registers.get(key);
|
|
2301
|
-
const proxy = (() => original());
|
|
2302
|
-
proxy.set = (value) => {
|
|
2303
|
-
register.set(value, peerId);
|
|
2304
|
-
original.set(value);
|
|
2305
|
-
transport.send({
|
|
2306
|
-
type: "set",
|
|
2307
|
-
key,
|
|
2308
|
-
value,
|
|
2309
|
-
timestamp: register.timestamp,
|
|
2310
|
-
peerId
|
|
2311
|
-
});
|
|
2312
|
-
};
|
|
2313
|
-
proxy.update = (fn) => {
|
|
2314
|
-
proxy.set(fn(original()));
|
|
2315
|
-
};
|
|
2316
|
-
proxy.peek = () => original.peek();
|
|
2317
|
-
state[key] = proxy;
|
|
2318
|
-
}
|
|
2319
|
-
const peers = signal([]);
|
|
2320
|
-
const connected = signal(false);
|
|
2321
|
-
const presence = signal({});
|
|
2322
|
-
const peerPresenceMap = signal(/* @__PURE__ */ new Map());
|
|
2323
|
-
const unsubOps = transport.onReceive((op) => {
|
|
2324
|
-
if (op.type === "set" && registers.has(op.key)) {
|
|
2325
|
-
const register = registers.get(op.key);
|
|
2326
|
-
const merged = register.merge({
|
|
2327
|
-
value: op.value,
|
|
2328
|
-
timestamp: op.timestamp,
|
|
2329
|
-
peerId: op.peerId
|
|
2330
|
-
});
|
|
2331
|
-
if (merged) {
|
|
2332
|
-
stateSignals[op.key].set(op.value);
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2336
|
-
const unsubPresence = transport.onPresence?.((remotePeerId, data) => {
|
|
2337
|
-
peerPresenceMap.update((map) => {
|
|
2338
|
-
const next = new Map(map);
|
|
2339
|
-
next.set(remotePeerId, data);
|
|
2340
|
-
return next;
|
|
2341
|
-
});
|
|
2342
|
-
});
|
|
2343
|
-
return {
|
|
2344
|
-
state,
|
|
2345
|
-
peers: () => peers(),
|
|
2346
|
-
presence,
|
|
2347
|
-
peerPresence: () => peerPresenceMap(),
|
|
2348
|
-
peerId,
|
|
2349
|
-
connected: () => connected(),
|
|
2350
|
-
connect() {
|
|
2351
|
-
transport.connect();
|
|
2352
|
-
connected.set(true);
|
|
2353
|
-
},
|
|
2354
|
-
disconnect() {
|
|
2355
|
-
transport.disconnect();
|
|
2356
|
-
connected.set(false);
|
|
2357
|
-
},
|
|
2358
|
-
dispose() {
|
|
2359
|
-
unsubOps();
|
|
2360
|
-
unsubPresence?.();
|
|
2361
|
-
transport.disconnect();
|
|
2362
|
-
}
|
|
2363
|
-
};
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
|
-
// src/offline.ts
|
|
2367
|
-
async function openDB(name, version = 1) {
|
|
2368
|
-
return new Promise((resolve, reject) => {
|
|
2369
|
-
const request = indexedDB.open(name, version);
|
|
2370
|
-
request.onupgradeneeded = () => {
|
|
2371
|
-
const db = request.result;
|
|
2372
|
-
if (!db.objectStoreNames.contains("items")) {
|
|
2373
|
-
db.createObjectStore("items");
|
|
2374
|
-
}
|
|
2375
|
-
if (!db.objectStoreNames.contains("pending")) {
|
|
2376
|
-
db.createObjectStore("pending", { autoIncrement: true });
|
|
2377
|
-
}
|
|
2378
|
-
};
|
|
2379
|
-
request.onsuccess = () => resolve(request.result);
|
|
2380
|
-
request.onerror = () => reject(request.error);
|
|
2381
|
-
});
|
|
2382
|
-
}
|
|
2383
|
-
async function idbGetAll(db, store) {
|
|
2384
|
-
return new Promise((resolve, reject) => {
|
|
2385
|
-
const tx = db.transaction(store, "readonly");
|
|
2386
|
-
const req = tx.objectStore(store).getAll();
|
|
2387
|
-
req.onsuccess = () => resolve(req.result);
|
|
2388
|
-
req.onerror = () => reject(req.error);
|
|
2389
|
-
});
|
|
2390
|
-
}
|
|
2391
|
-
async function idbPut(db, store, key, value) {
|
|
2392
|
-
return new Promise((resolve, reject) => {
|
|
2393
|
-
const tx = db.transaction(store, "readwrite");
|
|
2394
|
-
tx.objectStore(store).put(value, key);
|
|
2395
|
-
tx.oncomplete = () => resolve();
|
|
2396
|
-
tx.onerror = () => reject(tx.error);
|
|
2397
|
-
});
|
|
2398
|
-
}
|
|
2399
|
-
async function idbDelete(db, store, key) {
|
|
2400
|
-
return new Promise((resolve, reject) => {
|
|
2401
|
-
const tx = db.transaction(store, "readwrite");
|
|
2402
|
-
tx.objectStore(store).delete(key);
|
|
2403
|
-
tx.oncomplete = () => resolve();
|
|
2404
|
-
tx.onerror = () => reject(tx.error);
|
|
2405
|
-
});
|
|
2406
|
-
}
|
|
2407
|
-
async function idbClear(db, store) {
|
|
2408
|
-
return new Promise((resolve, reject) => {
|
|
2409
|
-
const tx = db.transaction(store, "readwrite");
|
|
2410
|
-
tx.objectStore(store).clear();
|
|
2411
|
-
tx.oncomplete = () => resolve();
|
|
2412
|
-
tx.onerror = () => reject(tx.error);
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
function createOfflineStore(name, options = {}) {
|
|
2416
|
-
const keyField = options.keyField ?? "id";
|
|
2417
|
-
const items = signal([]);
|
|
2418
|
-
const pendingOps = signal([]);
|
|
2419
|
-
const syncing = signal(false);
|
|
2420
|
-
const online = signal(typeof navigator !== "undefined" ? navigator.onLine : true);
|
|
2421
|
-
const pending = computed(() => pendingOps().length);
|
|
2422
|
-
let db = null;
|
|
2423
|
-
let syncTimer = null;
|
|
2424
|
-
let disposed = false;
|
|
2425
|
-
if (typeof window !== "undefined") {
|
|
2426
|
-
window.addEventListener("online", () => {
|
|
2427
|
-
online.set(true);
|
|
2428
|
-
syncNow();
|
|
2429
|
-
});
|
|
2430
|
-
window.addEventListener("offline", () => online.set(false));
|
|
2431
|
-
}
|
|
2432
|
-
async function init() {
|
|
2433
|
-
if (typeof indexedDB === "undefined") return;
|
|
2434
|
-
try {
|
|
2435
|
-
db = await openDB(`akash-offline-${name}`, options.version ?? 1);
|
|
2436
|
-
const stored = await idbGetAll(db, "items");
|
|
2437
|
-
items.set(stored);
|
|
2438
|
-
const ops = await idbGetAll(db, "pending");
|
|
2439
|
-
pendingOps.set(ops);
|
|
2440
|
-
} catch {
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
init();
|
|
2444
|
-
if (options.sync) {
|
|
2445
|
-
const interval = options.sync.interval ?? 3e4;
|
|
2446
|
-
syncTimer = setInterval(() => {
|
|
2447
|
-
if (online() && pending() > 0 && !syncing()) {
|
|
2448
|
-
syncNow();
|
|
2449
|
-
}
|
|
2450
|
-
}, interval);
|
|
2451
|
-
}
|
|
2452
|
-
function getKey(item) {
|
|
2453
|
-
return String(item[keyField]);
|
|
2454
|
-
}
|
|
2455
|
-
function put(item) {
|
|
2456
|
-
const key = getKey(item);
|
|
2457
|
-
items.update((list) => {
|
|
2458
|
-
const idx = list.findIndex((i) => getKey(i) === key);
|
|
2459
|
-
if (idx !== -1) {
|
|
2460
|
-
const next = [...list];
|
|
2461
|
-
next[idx] = item;
|
|
2462
|
-
return next;
|
|
2463
|
-
}
|
|
2464
|
-
return [...list, item];
|
|
2465
|
-
});
|
|
2466
|
-
queueOp({ type: "put", key, value: item, timestamp: Date.now() });
|
|
2467
|
-
if (db) idbPut(db, "items", key, item);
|
|
2468
|
-
}
|
|
2469
|
-
function remove(key) {
|
|
2470
|
-
items.update((list) => list.filter((i) => getKey(i) !== key));
|
|
2471
|
-
queueOp({ type: "delete", key, timestamp: Date.now() });
|
|
2472
|
-
if (db) idbDelete(db, "items", key);
|
|
2473
|
-
}
|
|
2474
|
-
function queueOp(op) {
|
|
2475
|
-
pendingOps.update((ops) => [...ops, op]);
|
|
2476
|
-
if (db) {
|
|
2477
|
-
const tx = db.transaction("pending", "readwrite");
|
|
2478
|
-
tx.objectStore("pending").add(op);
|
|
2479
|
-
}
|
|
2480
|
-
}
|
|
2481
|
-
async function syncNow() {
|
|
2482
|
-
if (!options.sync || syncing() || disposed) return;
|
|
2483
|
-
const ops = pendingOps();
|
|
2484
|
-
if (ops.length === 0) return;
|
|
2485
|
-
syncing.set(true);
|
|
2486
|
-
const fetchFn = options.sync.fetch ?? globalThis.fetch.bind(globalThis);
|
|
2487
|
-
try {
|
|
2488
|
-
const response = await fetchFn(options.sync.url, {
|
|
2489
|
-
method: "POST",
|
|
2490
|
-
headers: {
|
|
2491
|
-
"Content-Type": "application/json",
|
|
2492
|
-
...options.sync.headers
|
|
2493
|
-
},
|
|
2494
|
-
body: JSON.stringify({ ops })
|
|
2495
|
-
});
|
|
2496
|
-
if (response.ok) {
|
|
2497
|
-
pendingOps.set([]);
|
|
2498
|
-
if (db) await idbClear(db, "pending");
|
|
2499
|
-
const serverResponse = await fetchFn(options.sync.url, {
|
|
2500
|
-
headers: options.sync.headers
|
|
2501
|
-
});
|
|
2502
|
-
if (serverResponse.ok) {
|
|
2503
|
-
const serverItems = await serverResponse.json();
|
|
2504
|
-
items.set(serverItems);
|
|
2505
|
-
if (db) {
|
|
2506
|
-
await idbClear(db, "items");
|
|
2507
|
-
for (const item of serverItems) {
|
|
2508
|
-
await idbPut(db, "items", getKey(item), item);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
} catch {
|
|
2514
|
-
} finally {
|
|
2515
|
-
syncing.set(false);
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
return {
|
|
2519
|
-
items: () => items(),
|
|
2520
|
-
get(key) {
|
|
2521
|
-
return items().find((i) => getKey(i) === key);
|
|
2522
|
-
},
|
|
2523
|
-
put,
|
|
2524
|
-
add: put,
|
|
2525
|
-
update(key, partial) {
|
|
2526
|
-
const existing = items().find((i) => getKey(i) === key);
|
|
2527
|
-
if (existing) put({ ...existing, ...partial });
|
|
2528
|
-
},
|
|
2529
|
-
remove,
|
|
2530
|
-
clear() {
|
|
2531
|
-
items.set([]);
|
|
2532
|
-
pendingOps.set([]);
|
|
2533
|
-
if (db) {
|
|
2534
|
-
idbClear(db, "items");
|
|
2535
|
-
idbClear(db, "pending");
|
|
2536
|
-
}
|
|
2537
|
-
},
|
|
2538
|
-
pending,
|
|
2539
|
-
syncing: () => syncing(),
|
|
2540
|
-
online: () => online(),
|
|
2541
|
-
sync: syncNow,
|
|
2542
|
-
dispose() {
|
|
2543
|
-
disposed = true;
|
|
2544
|
-
if (syncTimer) clearInterval(syncTimer);
|
|
2545
|
-
db?.close();
|
|
2546
|
-
}
|
|
2547
|
-
};
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
// src/pipes.ts
|
|
2551
|
-
function pipe(value, transform, ...args) {
|
|
2552
|
-
return transform(value, ...args);
|
|
2553
|
-
}
|
|
2554
|
-
function chain(...pipes) {
|
|
2555
|
-
return (value, ...args) => {
|
|
2556
|
-
let result = value;
|
|
2557
|
-
for (const p of pipes) {
|
|
2558
|
-
result = p(result, ...args);
|
|
2559
|
-
}
|
|
2560
|
-
return result;
|
|
2561
|
-
};
|
|
2562
|
-
}
|
|
2563
|
-
function definePipe(fn) {
|
|
2564
|
-
return fn;
|
|
2565
|
-
}
|
|
2566
|
-
var uppercase = (value) => String(value).toUpperCase();
|
|
2567
|
-
var lowercase = (value) => String(value).toLowerCase();
|
|
2568
|
-
var capitalize = (value) => {
|
|
2569
|
-
const s = String(value);
|
|
2570
|
-
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
2571
|
-
};
|
|
2572
|
-
var titleCase = (value) => {
|
|
2573
|
-
return String(value).replace(/\b\w/g, (c) => c.toUpperCase());
|
|
2574
|
-
};
|
|
2575
|
-
var trim = (value) => String(value).trim();
|
|
2576
|
-
var truncate = (value, maxLength = 50, suffix = "...") => {
|
|
2577
|
-
const s = String(value);
|
|
2578
|
-
if (s.length <= maxLength) return s;
|
|
2579
|
-
return s.slice(0, maxLength - suffix.length) + suffix;
|
|
2580
|
-
};
|
|
2581
|
-
var date = (value, format = "medium", locale) => {
|
|
2582
|
-
const d = value instanceof Date ? value : new Date(value);
|
|
2583
|
-
if (isNaN(d.getTime())) return String(value);
|
|
2584
|
-
if (format === "iso") return d.toISOString();
|
|
2585
|
-
const loc = locale ?? "en-US";
|
|
2586
|
-
const options = {
|
|
2587
|
-
short: { year: "2-digit", month: "numeric", day: "numeric" },
|
|
2588
|
-
medium: { year: "numeric", month: "numeric", day: "numeric" },
|
|
2589
|
-
long: { year: "numeric", month: "long", day: "numeric" },
|
|
2590
|
-
full: { weekday: "long", year: "numeric", month: "long", day: "numeric" },
|
|
2591
|
-
time: { hour: "numeric", minute: "2-digit" }
|
|
2592
|
-
};
|
|
2593
|
-
return new Intl.DateTimeFormat(loc, options[format]).format(d);
|
|
2594
|
-
};
|
|
2595
|
-
var currency = (value, currencyCode = "USD", locale) => {
|
|
2596
|
-
return new Intl.NumberFormat(locale ?? "en-US", {
|
|
2597
|
-
style: "currency",
|
|
2598
|
-
currency: currencyCode
|
|
2599
|
-
}).format(Number(value));
|
|
2600
|
-
};
|
|
2601
|
-
var number = (value, digitsInfo, locale) => {
|
|
2602
|
-
const opts = {};
|
|
2603
|
-
if (digitsInfo) {
|
|
2604
|
-
const [min, max] = digitsInfo.split("-").map(Number);
|
|
2605
|
-
opts.minimumFractionDigits = min;
|
|
2606
|
-
opts.maximumFractionDigits = max ?? min;
|
|
2607
|
-
}
|
|
2608
|
-
return new Intl.NumberFormat(locale ?? "en-US", opts).format(Number(value));
|
|
2609
|
-
};
|
|
2610
|
-
var percent = (value, decimals = 0, locale) => {
|
|
2611
|
-
return new Intl.NumberFormat(locale ?? "en-US", {
|
|
2612
|
-
style: "percent",
|
|
2613
|
-
minimumFractionDigits: decimals,
|
|
2614
|
-
maximumFractionDigits: decimals
|
|
2615
|
-
}).format(Number(value));
|
|
2616
|
-
};
|
|
2617
|
-
var json = (value, indent = 2) => {
|
|
2618
|
-
return JSON.stringify(value, null, indent);
|
|
2619
|
-
};
|
|
2620
|
-
var plural = (value, singular, pluralForm) => {
|
|
2621
|
-
const p = pluralForm ?? `${singular}s`;
|
|
2622
|
-
return `${value} ${value === 1 ? singular : p}`;
|
|
2623
|
-
};
|
|
2624
|
-
var relativeTime = (value, locale) => {
|
|
2625
|
-
const d = value instanceof Date ? value.getTime() : Number(value);
|
|
2626
|
-
const diff = d - Date.now();
|
|
2627
|
-
const absDiff = Math.abs(diff);
|
|
2628
|
-
const units = [
|
|
2629
|
-
[6e4, "second"],
|
|
2630
|
-
[36e5, "minute"],
|
|
2631
|
-
[864e5, "hour"],
|
|
2632
|
-
[2592e6, "day"],
|
|
2633
|
-
[31536e6, "month"],
|
|
2634
|
-
[Infinity, "year"]
|
|
2635
|
-
];
|
|
2636
|
-
const divisors = {
|
|
2637
|
-
second: 1e3,
|
|
2638
|
-
minute: 6e4,
|
|
2639
|
-
hour: 36e5,
|
|
2640
|
-
day: 864e5,
|
|
2641
|
-
month: 2592e6,
|
|
2642
|
-
year: 31536e6
|
|
2643
|
-
};
|
|
2644
|
-
let unit = "second";
|
|
2645
|
-
for (const [threshold, u] of units) {
|
|
2646
|
-
if (absDiff < threshold) {
|
|
2647
|
-
unit = u;
|
|
2648
|
-
break;
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
const n = Math.round(diff / divisors[unit]);
|
|
2652
|
-
if (typeof Intl !== "undefined" && Intl.RelativeTimeFormat) {
|
|
2653
|
-
return new Intl.RelativeTimeFormat(locale ?? "en", { numeric: "auto" }).format(n, unit);
|
|
2654
|
-
}
|
|
2655
|
-
const abs = Math.abs(n);
|
|
2656
|
-
const suffix = n < 0 ? "ago" : "from now";
|
|
2657
|
-
return `${abs} ${unit}${abs !== 1 ? "s" : ""} ${suffix}`;
|
|
2658
|
-
};
|
|
2659
|
-
|
|
2660
|
-
// src/directive.ts
|
|
2661
|
-
function defineDirective(hooks) {
|
|
2662
|
-
return { _type: "directive", hooks };
|
|
2663
|
-
}
|
|
2664
|
-
function directiveFromFn(fn) {
|
|
2665
|
-
return defineDirective({
|
|
2666
|
-
mounted(el, binding) {
|
|
2667
|
-
const cleanup = fn(el, binding);
|
|
2668
|
-
if (typeof cleanup === "function") {
|
|
2669
|
-
el.__directiveCleanup = cleanup;
|
|
2670
|
-
}
|
|
2671
|
-
},
|
|
2672
|
-
unmounted(el) {
|
|
2673
|
-
el.__directiveCleanup?.();
|
|
2674
|
-
}
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
var DIRECTIVE_KEY = /* @__PURE__ */ Symbol("akash.directives");
|
|
2678
|
-
function applyDirective(el, directive, value, options) {
|
|
2679
|
-
const binding = {
|
|
2680
|
-
value,
|
|
2681
|
-
arg: options?.arg,
|
|
2682
|
-
modifiers: options?.modifiers
|
|
2683
|
-
};
|
|
2684
|
-
const states = el[DIRECTIVE_KEY] ?? [];
|
|
2685
|
-
states.push({ directive, binding });
|
|
2686
|
-
el[DIRECTIVE_KEY] = states;
|
|
2687
|
-
directive.hooks.mounted?.(el, binding);
|
|
2688
|
-
}
|
|
2689
|
-
function updateDirective(el, directive, newValue) {
|
|
2690
|
-
const states = el[DIRECTIVE_KEY] ?? [];
|
|
2691
|
-
const state = states.find((s) => s.directive === directive);
|
|
2692
|
-
if (state) {
|
|
2693
|
-
const oldValue = state.binding.value;
|
|
2694
|
-
state.binding = { ...state.binding, value: newValue, oldValue };
|
|
2695
|
-
directive.hooks.updated?.(el, state.binding);
|
|
2696
|
-
}
|
|
2697
|
-
}
|
|
2698
|
-
function removeDirectives(el) {
|
|
2699
|
-
const states = el[DIRECTIVE_KEY] ?? [];
|
|
2700
|
-
for (const state of states) {
|
|
2701
|
-
state.directive.hooks.unmounted?.(el, state.binding);
|
|
2702
|
-
}
|
|
2703
|
-
delete el[DIRECTIVE_KEY];
|
|
2704
|
-
}
|
|
2705
|
-
var vAutoFocus = defineDirective({
|
|
2706
|
-
mounted(el) {
|
|
2707
|
-
requestAnimationFrame(() => el.focus());
|
|
2708
|
-
}
|
|
2709
|
-
});
|
|
2710
|
-
var vClickOutside = defineDirective({
|
|
2711
|
-
mounted(el, { value: handler }) {
|
|
2712
|
-
const listener = (e) => {
|
|
2713
|
-
if (!el.contains(e.target)) handler();
|
|
2714
|
-
};
|
|
2715
|
-
document.addEventListener("click", listener, true);
|
|
2716
|
-
el.__vClickOutside = listener;
|
|
2717
|
-
},
|
|
2718
|
-
unmounted(el) {
|
|
2719
|
-
document.removeEventListener("click", el.__vClickOutside, true);
|
|
2720
|
-
delete el.__vClickOutside;
|
|
2721
|
-
}
|
|
2722
|
-
});
|
|
2723
|
-
var vLongPress = defineDirective({
|
|
2724
|
-
mounted(el, { value }) {
|
|
2725
|
-
let timer = null;
|
|
2726
|
-
const duration = value.duration ?? 500;
|
|
2727
|
-
const start = () => {
|
|
2728
|
-
timer = setTimeout(value.handler, duration);
|
|
2729
|
-
};
|
|
2730
|
-
const cancel = () => {
|
|
2731
|
-
if (timer) {
|
|
2732
|
-
clearTimeout(timer);
|
|
2733
|
-
timer = null;
|
|
2734
|
-
}
|
|
2735
|
-
};
|
|
2736
|
-
el.addEventListener("pointerdown", start);
|
|
2737
|
-
el.addEventListener("pointerup", cancel);
|
|
2738
|
-
el.addEventListener("pointerleave", cancel);
|
|
2739
|
-
el.__vLongPress = { start, cancel };
|
|
2740
|
-
},
|
|
2741
|
-
unmounted(el) {
|
|
2742
|
-
const fns = el.__vLongPress;
|
|
2743
|
-
if (fns) {
|
|
2744
|
-
el.removeEventListener("pointerdown", fns.start);
|
|
2745
|
-
el.removeEventListener("pointerup", fns.cancel);
|
|
2746
|
-
el.removeEventListener("pointerleave", fns.cancel);
|
|
2747
|
-
}
|
|
2748
|
-
}
|
|
2749
|
-
});
|
|
2750
|
-
var vIntersect = defineDirective({
|
|
2751
|
-
mounted(el, { value: callback }) {
|
|
2752
|
-
const observer = new IntersectionObserver((entries2) => {
|
|
2753
|
-
callback(entries2[0].isIntersecting);
|
|
2754
|
-
});
|
|
2755
|
-
observer.observe(el);
|
|
2756
|
-
el.__vIntersect = observer;
|
|
2757
|
-
},
|
|
2758
|
-
unmounted(el) {
|
|
2759
|
-
el.__vIntersect?.disconnect();
|
|
2760
|
-
}
|
|
2761
|
-
});
|
|
2762
|
-
var vResize = defineDirective({
|
|
2763
|
-
mounted(el, { value: callback }) {
|
|
2764
|
-
const observer = new ResizeObserver((entries2) => {
|
|
2765
|
-
callback(entries2[0]);
|
|
2766
|
-
});
|
|
2767
|
-
observer.observe(el);
|
|
2768
|
-
el.__vResize = observer;
|
|
2769
|
-
},
|
|
2770
|
-
unmounted(el) {
|
|
2771
|
-
el.__vResize?.disconnect();
|
|
2772
|
-
}
|
|
2773
|
-
});
|
|
2774
|
-
|
|
2775
|
-
// src/pwa.ts
|
|
2776
|
-
function registerServiceWorker(swUrl, options = {}) {
|
|
2777
|
-
const registered = signal(false);
|
|
2778
|
-
const updateAvailable = signal(false);
|
|
2779
|
-
const offline = signal(!navigator.onLine);
|
|
2780
|
-
let registration = null;
|
|
2781
|
-
window.addEventListener("online", () => offline.set(false));
|
|
2782
|
-
window.addEventListener("offline", () => offline.set(true));
|
|
2783
|
-
const ready = new Promise((resolve, reject) => {
|
|
2784
|
-
if (!("serviceWorker" in navigator)) {
|
|
2785
|
-
reject(new Error("Service workers not supported"));
|
|
2786
|
-
return;
|
|
2787
|
-
}
|
|
2788
|
-
navigator.serviceWorker.register(swUrl, { scope: options.scope }).then((reg) => {
|
|
2789
|
-
registration = reg;
|
|
2790
|
-
registered.set(true);
|
|
2791
|
-
options.onReady?.(reg);
|
|
2792
|
-
resolve(reg);
|
|
2793
|
-
reg.addEventListener("updatefound", () => {
|
|
2794
|
-
const newWorker = reg.installing;
|
|
2795
|
-
if (!newWorker) return;
|
|
2796
|
-
newWorker.addEventListener("statechange", () => {
|
|
2797
|
-
if (newWorker.state === "installed" && navigator.serviceWorker.controller) {
|
|
2798
|
-
updateAvailable.set(true);
|
|
2799
|
-
options.onUpdate?.(reg);
|
|
2800
|
-
if (options.autoReload) {
|
|
2801
|
-
newWorker.postMessage({ type: "SKIP_WAITING" });
|
|
2802
|
-
window.location.reload();
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
});
|
|
2806
|
-
});
|
|
2807
|
-
}).catch((err) => {
|
|
2808
|
-
options.onError?.(err);
|
|
2809
|
-
reject(err);
|
|
2810
|
-
});
|
|
2811
|
-
});
|
|
2812
|
-
return {
|
|
2813
|
-
registered: () => registered(),
|
|
2814
|
-
updateAvailable: () => updateAvailable(),
|
|
2815
|
-
offline: () => offline(),
|
|
2816
|
-
ready,
|
|
2817
|
-
async update() {
|
|
2818
|
-
if (registration) {
|
|
2819
|
-
await registration.update();
|
|
2820
|
-
}
|
|
2821
|
-
},
|
|
2822
|
-
skipWaiting() {
|
|
2823
|
-
if (registration?.waiting) {
|
|
2824
|
-
registration.waiting.postMessage({ type: "SKIP_WAITING" });
|
|
2825
|
-
window.location.reload();
|
|
2826
|
-
}
|
|
2827
|
-
},
|
|
2828
|
-
async unregister() {
|
|
2829
|
-
if (registration) {
|
|
2830
|
-
return registration.unregister();
|
|
2831
|
-
}
|
|
2832
|
-
return false;
|
|
2833
|
-
}
|
|
2834
|
-
};
|
|
2835
|
-
}
|
|
2836
|
-
function generateSWScript(routes) {
|
|
2837
|
-
let script = `// Auto-generated service worker by AkashJS
|
|
2838
|
-
const CACHE_VERSION = 'v1';
|
|
2839
|
-
|
|
2840
|
-
self.addEventListener('install', (event) => {
|
|
2841
|
-
self.skipWaiting();
|
|
2842
|
-
});
|
|
2843
|
-
|
|
2844
|
-
self.addEventListener('activate', (event) => {
|
|
2845
|
-
event.waitUntil(clients.claim());
|
|
2846
|
-
});
|
|
2847
|
-
|
|
2848
|
-
self.addEventListener('message', (event) => {
|
|
2849
|
-
if (event.data?.type === 'SKIP_WAITING') {
|
|
2850
|
-
self.skipWaiting();
|
|
2851
|
-
}
|
|
2852
|
-
});
|
|
2853
|
-
|
|
2854
|
-
self.addEventListener('fetch', (event) => {
|
|
2855
|
-
const url = new URL(event.request.url);
|
|
2856
|
-
`;
|
|
2857
|
-
for (const route of routes) {
|
|
2858
|
-
const pattern = route.match instanceof RegExp ? route.match.toString() : `new RegExp(${JSON.stringify(route.match.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))})`;
|
|
2859
|
-
const cacheName = route.cacheName ?? "akash-cache";
|
|
2860
|
-
script += `
|
|
2861
|
-
if (${pattern}.test(url.pathname)) {
|
|
2862
|
-
event.respondWith(${generateStrategyCode(route.strategy, cacheName)});
|
|
2863
|
-
return;
|
|
2864
|
-
}
|
|
2865
|
-
`;
|
|
2866
|
-
}
|
|
2867
|
-
script += `
|
|
2868
|
-
// Default: network-first
|
|
2869
|
-
event.respondWith(
|
|
2870
|
-
fetch(event.request).catch(() => caches.match(event.request))
|
|
2871
|
-
);
|
|
2872
|
-
});
|
|
2873
|
-
`;
|
|
2874
|
-
return script;
|
|
2875
|
-
}
|
|
2876
|
-
function generateStrategyCode(strategy, cacheName) {
|
|
2877
|
-
switch (strategy) {
|
|
2878
|
-
case "cache-first":
|
|
2879
|
-
return `caches.match(event.request).then(cached => cached || fetch(event.request).then(response => { const clone = response.clone(); caches.open('${cacheName}').then(cache => cache.put(event.request, clone)); return response; }))`;
|
|
2880
|
-
case "network-first":
|
|
2881
|
-
return `fetch(event.request).then(response => { const clone = response.clone(); caches.open('${cacheName}').then(cache => cache.put(event.request, clone)); return response; }).catch(() => caches.match(event.request))`;
|
|
2882
|
-
case "stale-while-revalidate":
|
|
2883
|
-
return `caches.match(event.request).then(cached => { const fetchPromise = fetch(event.request).then(response => { caches.open('${cacheName}').then(cache => cache.put(event.request, response.clone())); return response; }); return cached || fetchPromise; })`;
|
|
2884
|
-
case "network-only":
|
|
2885
|
-
return `fetch(event.request)`;
|
|
2886
|
-
case "cache-only":
|
|
2887
|
-
return `caches.match(event.request)`;
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
async function subscribePush(registration, vapidPublicKey) {
|
|
2891
|
-
const permission = await Notification.requestPermission();
|
|
2892
|
-
if (permission !== "granted") return null;
|
|
2893
|
-
const subscription = await registration.pushManager.subscribe({
|
|
2894
|
-
userVisibleOnly: true,
|
|
2895
|
-
applicationServerKey: urlBase64ToUint8Array(vapidPublicKey)
|
|
2896
|
-
});
|
|
2897
|
-
return subscription;
|
|
2898
|
-
}
|
|
2899
|
-
function urlBase64ToUint8Array(base64String) {
|
|
2900
|
-
const padding = "=".repeat((4 - base64String.length % 4) % 4);
|
|
2901
|
-
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
|
2902
|
-
const rawData = atob(base64);
|
|
2903
|
-
return Uint8Array.from(rawData, (char) => char.charCodeAt(0));
|
|
2904
|
-
}
|
|
2905
|
-
|
|
2906
|
-
// src/web-component.ts
|
|
2907
|
-
function defineCustomElement(tagName, component, options = {}) {
|
|
2908
|
-
const { props = [], shadow = true, styles } = options;
|
|
2909
|
-
class AkashElement extends HTMLElement {
|
|
2910
|
-
static get observedAttributes() {
|
|
2911
|
-
return props;
|
|
2912
|
-
}
|
|
2913
|
-
_root;
|
|
2914
|
-
_mounted = false;
|
|
2915
|
-
_props = {};
|
|
2916
|
-
constructor() {
|
|
2917
|
-
super();
|
|
2918
|
-
this._root = shadow ? this.attachShadow({ mode: "open" }) : this;
|
|
2919
|
-
}
|
|
2920
|
-
connectedCallback() {
|
|
2921
|
-
for (const prop of props) {
|
|
2922
|
-
const attr = this.getAttribute(prop);
|
|
2923
|
-
if (attr !== null) {
|
|
2924
|
-
this._props[prop] = parseAttributeValue(attr);
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
this._render();
|
|
2928
|
-
this._mounted = true;
|
|
2929
|
-
}
|
|
2930
|
-
disconnectedCallback() {
|
|
2931
|
-
while (this._root.firstChild) {
|
|
2932
|
-
this._root.removeChild(this._root.firstChild);
|
|
2933
|
-
}
|
|
2934
|
-
this._mounted = false;
|
|
2935
|
-
}
|
|
2936
|
-
attributeChangedCallback(name, _oldValue, newValue) {
|
|
2937
|
-
this._props[name] = newValue !== null ? parseAttributeValue(newValue) : void 0;
|
|
2938
|
-
if (this._mounted) {
|
|
2939
|
-
this._render();
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
_render() {
|
|
2943
|
-
while (this._root.firstChild) {
|
|
2944
|
-
this._root.removeChild(this._root.firstChild);
|
|
2945
|
-
}
|
|
2946
|
-
if (shadow && styles) {
|
|
2947
|
-
const styleEl = document.createElement("style");
|
|
2948
|
-
styleEl.textContent = styles;
|
|
2949
|
-
this._root.appendChild(styleEl);
|
|
2950
|
-
}
|
|
2951
|
-
const node = component(this._props);
|
|
2952
|
-
this._root.appendChild(node);
|
|
2953
|
-
}
|
|
2954
|
-
// Allow programmatic prop setting
|
|
2955
|
-
setProps(newProps) {
|
|
2956
|
-
Object.assign(this._props, newProps);
|
|
2957
|
-
if (this._mounted) this._render();
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
if (typeof customElements !== "undefined" && !customElements.get(tagName)) {
|
|
2961
|
-
if (options.extends) {
|
|
2962
|
-
customElements.define(tagName, AkashElement, { extends: options.extends });
|
|
2963
|
-
} else {
|
|
2964
|
-
customElements.define(tagName, AkashElement);
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
return AkashElement;
|
|
2968
|
-
}
|
|
2969
|
-
function toCustomElement(component, options = {}) {
|
|
2970
|
-
const { props = [], shadow = true, styles } = options;
|
|
2971
|
-
return class extends HTMLElement {
|
|
2972
|
-
static get observedAttributes() {
|
|
2973
|
-
return props;
|
|
2974
|
-
}
|
|
2975
|
-
_root;
|
|
2976
|
-
_mounted = false;
|
|
2977
|
-
_props = {};
|
|
2978
|
-
constructor() {
|
|
2979
|
-
super();
|
|
2980
|
-
this._root = shadow ? this.attachShadow({ mode: "open" }) : this;
|
|
2981
|
-
}
|
|
2982
|
-
connectedCallback() {
|
|
2983
|
-
for (const prop of props) {
|
|
2984
|
-
const attr = this.getAttribute(prop);
|
|
2985
|
-
if (attr !== null) this._props[prop] = parseAttributeValue(attr);
|
|
2986
|
-
}
|
|
2987
|
-
this._render();
|
|
2988
|
-
this._mounted = true;
|
|
2989
|
-
}
|
|
2990
|
-
disconnectedCallback() {
|
|
2991
|
-
while (this._root.firstChild) this._root.removeChild(this._root.firstChild);
|
|
2992
|
-
this._mounted = false;
|
|
2993
|
-
}
|
|
2994
|
-
attributeChangedCallback(name, _old, val) {
|
|
2995
|
-
this._props[name] = val !== null ? parseAttributeValue(val) : void 0;
|
|
2996
|
-
if (this._mounted) this._render();
|
|
2997
|
-
}
|
|
2998
|
-
_render() {
|
|
2999
|
-
while (this._root.firstChild) this._root.removeChild(this._root.firstChild);
|
|
3000
|
-
if (shadow && styles) {
|
|
3001
|
-
const s = document.createElement("style");
|
|
3002
|
-
s.textContent = styles;
|
|
3003
|
-
this._root.appendChild(s);
|
|
3004
|
-
}
|
|
3005
|
-
this._root.appendChild(component(this._props));
|
|
3006
|
-
}
|
|
3007
|
-
};
|
|
3008
|
-
}
|
|
3009
|
-
function parseAttributeValue(value) {
|
|
3010
|
-
try {
|
|
3011
|
-
return JSON.parse(value);
|
|
3012
|
-
} catch {
|
|
3013
|
-
return value;
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
// src/ssg.ts
|
|
3018
|
-
var DEFAULT_TEMPLATE = `<!DOCTYPE html>
|
|
16
|
+
`.trim()}var Y=[];function Jt(){let e=Y;return Y=[],e}function Yt(e){let t="",n=e.reduce((o,i)=>i.title??o,""),r=e.reduce((o,i)=>i.titleTemplate??o,"");if(n){let o=r?r.replace("%s",n):n;t+=`<title>${o}</title>
|
|
17
|
+
`;}for(let o of e)for(let i of o.meta??[])t+=" <meta",i.name&&(t+=` name="${i.name}"`),i.property&&(t+=` property="${i.property}"`),i.httpEquiv&&(t+=` http-equiv="${i.httpEquiv}"`),t+=` content="${i.content}"`,t+=` />
|
|
18
|
+
`;for(let o of e)for(let i of o.link??[])t+=` <link rel="${i.rel}" href="${i.href}"`,i.type&&(t+=` type="${i.type}"`),t+=` />
|
|
19
|
+
`;return t}var J="data-akash-head";function j(e$1){let t=typeof e$1=="function"?e$1:()=>e$1;if(typeof document>"u"){Y.push(t());return}let n=[],r=e(()=>{let o=t();for(let i of n)i.remove();if(n.length=0,o.title){let i=o.titleTemplate?o.titleTemplate.replace("%s",o.title):o.title;document.title=i;}for(let i of o.meta??[]){let s=document.createElement("meta");s.setAttribute(J,""),i.name&&s.setAttribute("name",i.name),i.property&&s.setAttribute("property",i.property),i.httpEquiv&&s.setAttribute("http-equiv",i.httpEquiv),s.setAttribute("content",i.content),document.head.appendChild(s),n.push(s);}for(let i of o.link??[]){let s=document.createElement("link");s.setAttribute(J,""),s.setAttribute("rel",i.rel),s.setAttribute("href",i.href),i.type&&s.setAttribute("type",i.type),document.head.appendChild(s),n.push(s);}for(let i of o.script??[]){let s=document.createElement("script");s.setAttribute(J,""),i.src&&s.setAttribute("src",i.src),i.type&&s.setAttribute("type",i.type),i.async&&s.setAttribute("async",""),i.defer&&s.setAttribute("defer",""),i.innerHTML&&(s.textContent=i.innerHTML),document.head.appendChild(s),n.push(s);}if(o.htmlAttrs)for(let[i,s]of Object.entries(o.htmlAttrs))document.documentElement.setAttribute(i,s);if(o.bodyAttrs)for(let[i,s]of Object.entries(o.bodyAttrs))document.body.setAttribute(i,s);});try{v(()=>{r();for(let o of n)o.remove();});}catch{}}function Xt(e){return e}function Zt(e,t){let n=[],r=[],o=[],i={},s=null,a=null,l={provide(d,c){f(d,c);},onError(d){r.push(d);},onBeforeMount(d){o.push(d);},config:i},u={use(d){return n.push(d),u},config(d,c){return i[d]=c,u},mount(d){if(a=typeof d=="string"?document.querySelector(d):d,!a)throw new Error(`[AkashJS] Mount target not found: ${d}`);for(let c of n)c.setup(l);for(let c of o)c();try{s=e(t??{}),a.appendChild(s);}catch(c){let f=c instanceof Error?c:new Error(String(c));if(r.length>0)for(let p of r)p(f);else throw f}},unmount(){s&&a&&(a.removeChild(s),s=null);}};return u}function en(e,t){let n=c(0),r=c(t?.immediate!==false),o=null;function i(){s(),o=setInterval(()=>n.update(a=>a+1),e);}function s(){o&&(clearInterval(o),o=null);}return r()&&i(),{count:(()=>n()),isActive:(()=>r()),pause(){r.set(false),s();},resume(){r.set(true),i();},reset(){n.set(0);},dispose(){s();}}}function tn(e){let t=c(false),n=null;function r(){o(),t.set(false),n=setTimeout(()=>t.set(true),e);}function o(){n&&(clearTimeout(n),n=null);}return r(),{ready:(()=>t()),restart(){r();},dispose(){o();}}}function nn(e$1,t){let n=c(e$1()),r=null;return e(()=>{let o=e$1();r&&clearTimeout(r),r=setTimeout(()=>n.set(o),t);}),(()=>n())}function rn(e$1,t){let n=c(e$1()),r=0,o=null;return e(()=>{let i=e$1(),s=Date.now(),a=s-r;a>=t?(n.set(i),r=s):(o&&clearTimeout(o),o=setTimeout(()=>{n.set(i),r=Date.now();},t-a));}),(()=>n())}function on(e=0){let t=c(e);return {count:(()=>t()),inc(n=1){t.update(r=>r+n);},dec(n=1){t.update(r=>r-n);},set(n){t.set(n);},reset(){t.set(e);}}}function sn(e=false){let t=c(e);return {value:(()=>t()),toggle(){t.update(n=>!n);},setTrue(){t.set(true);},setFalse(){t.set(false);}}}function an(e$1){let t,n=c(void 0);return e(()=>{let r=e$1();n.set(t),t=r;}),(()=>n())}function ln(e){if(typeof window>"u")return(()=>false);let t=window.matchMedia(e),n=c(t.matches),r=o=>n.set(o.matches);return t.addEventListener("change",r),(()=>n())}var cn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536};function un(e=cn){let t=Object.entries(e).sort((s,a)=>s[1]-a[1]),n=c(typeof window<"u"?window.innerWidth:1024);if(typeof window<"u"){let s=()=>n.set(window.innerWidth);window.addEventListener("resize",s,{passive:true});}function r(){let s=n(),a="";for(let[l,u]of t)s>=u&&(a=l);return a||t[0]?.[0]||""}function o(s){let a=e[s];return a!==void 0&&n()>=a}function i(s){let a=e[s];return a!==void 0&&n()<a}return {current:r,gte:o,lt:i,width:(()=>n())}}function dn(e$1,t,n="local"){let r=typeof window<"u"?n==="local"?localStorage:sessionStorage:null,o=t;if(r)try{let s=r.getItem(e$1);s!==null&&(o=JSON.parse(s));}catch{}let i=c(o);return r&&(e(()=>{let s=i();try{r.setItem(e$1,JSON.stringify(s));}catch{}}),typeof window<"u"&&window.addEventListener("storage",s=>{if(s.key===e$1&&s.newValue!==null)try{i.set(JSON.parse(s.newValue));}catch{}})),i}function pn(e){let t=c(""),n=c(false),r=e?.timeout??2e3,o=null;async function i(s){typeof navigator>"u"||!navigator.clipboard||(await navigator.clipboard.writeText(s),t.set(s),n.set(true),o&&clearTimeout(o),o=setTimeout(()=>n.set(false),r));}return {text:(()=>t()),copied:(()=>n()),copy:i}}function fn(){if(typeof window>"u")return(()=>true);let e=c(navigator.onLine);return window.addEventListener("online",()=>e.set(true)),window.addEventListener("offline",()=>e.set(false)),(()=>e())}function mn(e){let t=c({latitude:null,longitude:null,accuracy:null,error:null,loading:true});return typeof navigator<"u"&&navigator.geolocation?navigator.geolocation.watchPosition(n=>{t.set({latitude:n.coords.latitude,longitude:n.coords.longitude,accuracy:n.coords.accuracy,error:null,loading:false});},n=>{t.set({latitude:null,longitude:null,accuracy:null,error:n,loading:false});},e):t.set({...t(),loading:false}),(()=>t())}function gn(){let e=c(typeof window<"u"?window.innerWidth:0),t=c(typeof window<"u"?window.innerHeight:0);return typeof window<"u"&&window.addEventListener("resize",()=>{e.set(window.innerWidth),t.set(window.innerHeight);},{passive:true}),{width:(()=>e()),height:(()=>t())}}function yn(e,t,n={}){if(typeof document>"u")return ()=>{};let{events:r=["pointerdown"],ignore:o=[],active:i=true}=n,s=i;function a(){return typeof e=="function"?e():e}function l(c){let f=c.target;if(!f)return false;for(let p of o)if(typeof p=="string"){if(f.closest(p))return true}else if(p===f||p.contains(f))return true;return false}function u(c){if(!s)return;let f=a();if(!f)return;let p=c.target;f===p||f.contains(p)||l(c)||t(c);}for(let c of r)document.addEventListener(c,u,{passive:true,capture:true});let d=()=>{for(let c of r)document.removeEventListener(c,u,{capture:true});};return d.enable=()=>{s=true;},d.disable=()=>{s=false;},d}var hn=y(e=>{let t=null,n=null;function r(){let o=e.props.target;return o?typeof o=="string"?document.querySelector(o)??document.body:o:document.body}return v(()=>{n&&t&&t.removeChild(n);}),()=>{t=r();let o=e.children();return n=s(o),t.appendChild(n),document.createComment("portal")}});var Tn=0;function vn(e={}){let{maxVisible:t=5,defaultDuration:n=3e3,position:r="top-right"}=e,o=c([]),i=new Map;function s(d,c,f){let p=`toast-${++Tn}`,T=f?.duration??n,h=f?.dismissible??true,m={id:p,type:d,message:c,duration:T,dismissible:h,createdAt:Date.now()};if(o.update(y=>{let b=[...y,m];if(b.length>t){let k=b.shift();u(k.id);}return b}),T>0){let y=setTimeout(()=>a(p),T);i.set(p,y);}return p}function a(d){u(d),o.update(c=>c.filter(f=>f.id!==d));}function l(){for(let[d]of i)u(d);o.set([]);}function u(d){let c=i.get(d);c&&(clearTimeout(c),i.delete(d));}return {toasts:(()=>o()),position:r,success:(d,c)=>s("success",d,c),error:(d,c)=>s("error",d,c),info:(d,c)=>s("info",d,c),warning:(d,c)=>s("warning",d,c),add:s,dismiss:a,dismissAll:l}}function bn(e$1={}){let{themes:t={light:{},dark:{}},storageKey:n="akash-theme",attribute:r="data-theme",syncSystem:o=true}=e$1,i=Object.keys(t);function s(){return typeof window>"u"?e$1.defaultTheme??"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function a(){if(typeof window<"u"&&n){let c=localStorage.getItem(n);if(c&&i.includes(c))return c}return e$1.defaultTheme??s()}let l=c(a()),u=d(()=>l()==="dark");function d$1(c){if(typeof document>"u")return;document.documentElement.setAttribute(r,c);let f=t[c];if(f)for(let[p,T]of Object.entries(f))document.documentElement.style.setProperty(p,T);document.documentElement.classList.remove(...i),document.documentElement.classList.add(c);}return e(()=>{let c=l();d$1(c),typeof window<"u"&&n&&localStorage.setItem(n,c);}),o&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f=>{localStorage.getItem(n)||l.set(f.matches?"dark":"light");}),{current:()=>l(),isDark:u,set(c){i.includes(c)&&l.set(c);},toggle(){l.set(u()?"light":"dark");},setSystem(){typeof window<"u"&&n&&localStorage.removeItem(n),l.set(s());},themes:i}}function X(e,t,n,r,o=3){let i=Math.floor(e/n),s=Math.ceil(t/n),a=Math.max(0,i-o),l=Math.min(r,i+s+o);return {start:a,end:l,totalHeight:r*n,offsetTop:a*n}}function wn(e){let t=c(0),n=c(e.containerHeight??400),r=e.overscan??3,o=d(()=>X(t(),n(),e.itemHeight,e.items().length,r)),i=d(()=>{let l=o();return e.items().slice(l.start,l.end).map((u,d)=>({item:u,index:l.start+d}))});function s(l){let u=l.target;t.set(u.scrollTop);}function a(l){n.set(l);}return {range:o,visibleItems:i,onScroll:s,setContainerHeight:a,scrollTop:(()=>t())}}var xn=y(e=>{let{itemHeight:t,containerHeight:n,overscan:r=3}=e.props,o=c(0);return ()=>{let i=e.props.each,s$1=n??400,a=X(o(),s$1,t,i.length,r),l=document.createElement("div");l.style.height=`${s$1}px`,l.style.overflow="auto",l.style.position="relative",l.addEventListener("scroll",()=>{o.set(l.scrollTop);},{passive:true});let u=document.createElement("div");u.style.height=`${a.totalHeight}px`,u.style.position="relative";let d=document.createElement("div");d.style.position="absolute",d.style.top=`${a.offsetTop}px`,d.style.left="0",d.style.right="0";for(let c=a.start;c<a.end;c++){let f=i[c];if(!f)continue;let p=s(e.props.children(f,c));p instanceof HTMLElement&&(p.style.height=`${t}px`),d.appendChild(p);}return u.appendChild(d),l.appendChild(u),l}});function Sn(e){let t=typeof e=="function"?{loader:e}:e,{loader:n,loading:r,error:o,timeout:i,delay:s$1=200}=t,a=null,l=null,u=null;function d(){return l||(l=n().then(c=>{a=c.default;}).catch(c=>{u=c instanceof Error?c:new Error(String(c));}),l)}return y(c$1=>{let f=c("loading"),p=c(false);d().then(()=>{u?f.set("error"):f.set("ready");});let T=null;s$1>0?T=setTimeout(()=>p.set(true),s$1):p.set(true);let h=null;return i&&(h=setTimeout(()=>{f()==="loading"&&(u=new Error(`Async component timed out after ${i}ms`),f.set("error"));},i)),()=>{let m=f();return m!=="loading"&&(T&&clearTimeout(T),h&&clearTimeout(h)),m==="ready"&&a?a(c$1.props):m==="error"&&o&&u?s(o(u)):m==="loading"&&p()&&r?s(r()):document.createComment("async-loading")}})}function pe(e){let t=e.length;if(t===0)return [];let n=[],r=new Array(t).fill(-1),o=[];for(let a=0;a<t;a++){let l=e[a];if(l===-1)continue;let u=0,d=n.length;for(;u<d;){let c=u+d>>1;n[c]<l?u=c+1:d=c;}n[u]=l,o[u]=a,u>0&&(r[a]=o[u-1]);}let i=new Array(n.length),s=o[n.length-1];for(let a=n.length-1;a>=0;a--)i[a]=s,s=r[s];return i}function fe(e,t){let n=[],r=new Map;for(let a=0;a<e.length;a++)r.set(e[a],a);let o=new Array(t.length);for(let a=0;a<t.length;a++)o[a]=r.get(t[a])??-1;let i=new Set(t);for(let a=0;a<e.length;a++)i.has(e[a])||n.push({type:"remove",oldIndex:a});let s=new Set(pe(o));for(let a=0;a<t.length;a++)o[a]===-1?n.push({type:"insert",newIndex:a}):s.has(a)||n.push({type:"move",newIndex:a,oldIndex:o[a]});return n}function En(e,t){let n=fe(e,t),r=0,o=0,i=0;for(let s of n)s.type==="insert"?r++:s.type==="move"?o++:i++;return {inserts:r,moves:o,removes:i}}var M=false,D=new Map,me=0;function kn(){M=true;}function Pn(){M=false,D.clear();}function Cn(){return M}function An(e){if(!M)return -1;let t=++me;return D.set(t,{id:t,createdAt:Date.now(),stackTrace:Mn(),componentName:e??null,disposed:false}),t}function Rn(e){if(!M||e===-1)return;let t=D.get(e);t&&(t.disposed=true,D.delete(e));}function Ln(){return Array.from(D.values())}function ge(e=3e4){if(!M)return [];let t=Date.now(),n=[];for(let r of D.values())!r.disposed&&t-r.createdAt>e&&n.push({effectId:r.id,age:t-r.createdAt,componentName:r.componentName,stackTrace:r.stackTrace});return n}function On(e=3e4){let t=ge(e);if(t.length!==0){console.warn(`[AkashJS] ${t.length} potential effect leak(s) detected:`);for(let n of t){let r=n.componentName?` in ${n.componentName}`:"";console.warn(` Effect #${n.effectId}${r} \u2014 active for ${(n.age/1e3).toFixed(1)}s`),n.stackTrace&&console.warn(` Created at:
|
|
20
|
+
${n.stackTrace}`);}}}function Dn(){return {enabled:M,activeCount:D.size,totalTracked:me}}function Mn(){try{let t=new Error().stack;return t?t.split(`
|
|
21
|
+
`).slice(3,8).join(`
|
|
22
|
+
`):null}catch{return null}}var V=false,ee=[],Z=0;function Hn(){V=true,ee=[],Z=performance.now();}function In(){V=false;let e=performance.now();return {entries:[...ee],totalDuration:e-Z,startTime:Z,endTime:e}}function jn(){return V}function B(e,t,n){V&&ee.push({type:e,name:t,duration:n,timestamp:performance.now()});}function ye(e){let t=e.entries.filter(a=>a.type==="render"),n=e.entries.filter(a=>a.type==="effect"),r=e.entries.filter(a=>a.type==="signal-update"),o=e.entries.filter(a=>a.type==="computed"),i=a=>a.length>0?a.reduce((l,u)=>l+u.duration,0)/a.length:0,s=a=>a.length>0?a.reduce((l,u)=>u.duration>l.duration?u:l):null;return {totalRenders:t.length,totalEffects:n.length,totalSignalUpdates:r.length,totalComputedEvals:o.length,avgRenderTime:i(t),avgEffectTime:i(n),slowestRender:s(t),slowestEffect:s(n)}}function Fn(e,t){let n=performance.now(),r=t(),o=performance.now()-n;return B("render",e,o),{result:r,duration:o}}async function Nn(e,t){let n=performance.now(),r=await t(),o=performance.now()-n;return B("render",e,o),{result:r,duration:o}}function _n(e){let t=0,n=0;return {start(){t=performance.now();},stop(){n=performance.now()-t,B("render",e,n);},get duration(){return n}}}function $n(e){let t=ye(e),n=`
|
|
23
|
+
Performance Profile
|
|
24
|
+
`;return n+=" "+"\u2500".repeat(50)+`
|
|
25
|
+
`,n+=` Duration: ${e.totalDuration.toFixed(1)} ms
|
|
26
|
+
`,n+=` Renders: ${t.totalRenders} (avg ${t.avgRenderTime.toFixed(2)} ms)
|
|
27
|
+
`,n+=` Effects: ${t.totalEffects} (avg ${t.avgEffectTime.toFixed(2)} ms)
|
|
28
|
+
`,n+=` Signal updates: ${t.totalSignalUpdates}
|
|
29
|
+
`,n+=` Computed evals: ${t.totalComputedEvals}
|
|
30
|
+
`,t.slowestRender&&(n+=` Slowest render: ${t.slowestRender.name} (${t.slowestRender.duration.toFixed(2)} ms)
|
|
31
|
+
`),t.slowestEffect&&(n+=` Slowest effect: ${t.slowestEffect.name} (${t.slowestEffect.duration.toFixed(2)} ms)
|
|
32
|
+
`),n+=" "+"\u2500".repeat(50)+`
|
|
33
|
+
`,n}var Kn=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])',"[contenteditable]"].join(", ");function Vn(e,t={}){let{initialFocus:n,returnFocus:r=true,escapeDeactivates:o=true,allowOutsideClick:i=false,onDeactivate:s}=t,a=c(false),l=null;function u(){return typeof e=="function"?e():e}function d(){let h=u();return h?Array.from(h.querySelectorAll(Kn)):[]}function c$1(h){if(h.key==="Escape"&&o){h.preventDefault(),T(),s?.();return}if(h.key!=="Tab")return;let m=d();if(m.length===0)return;let y=m[0],b=m[m.length-1];h.shiftKey?document.activeElement===y&&(h.preventDefault(),b.focus()):document.activeElement===b&&(h.preventDefault(),y.focus());}function f(h){if(!a()||i)return;let m=u();if(!m)return;let y=h.relatedTarget;if(y&&!m.contains(y)){let b=d();b.length>0&&b[0].focus();}}function p(){if(a())return;a.set(true),l=document.activeElement,document.addEventListener("keydown",c$1,true);let h=u();h&&h.addEventListener("focusout",f),requestAnimationFrame(()=>{if(n)(typeof n=="string"?u()?.querySelector(n):n)?.focus();else {let m=d();m.length>0&&m[0].focus();}});}function T(){if(!a())return;a.set(false),document.removeEventListener("keydown",c$1,true);let h=u();h&&h.removeEventListener("focusout",f),r&&l&&(l.focus(),l=null);}return {activate:p,deactivate:T,active:()=>a()}}var q=null;function Bn(){if(q&&document.body.contains(q))return q;let e=document.createElement("div");return e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText=["position: absolute","width: 1px","height: 1px","padding: 0","margin: -1px","overflow: hidden","clip: rect(0,0,0,0)","white-space: nowrap","border: 0"].join("; "),document.body.appendChild(e),q=e,e}function qn(){return (e,t="polite")=>{if(typeof document>"u")return;let n=Bn();n.setAttribute("aria-live",t),n.textContent="",requestAnimationFrame(()=>{n.textContent=e;});}}function Wn(){let e=[],t=new Set,n=false;function r(s){for(let a of e)if(!(a.scope&&!t.has(a.scope))&&zn(s,a.key)){a.preventDefault!==false&&s.preventDefault(),a.handler(s);return}}function o(){n||typeof document>"u"||(document.addEventListener("keydown",r),n=true);}function i(s,a,l){let u={key:s,handler:a,scope:l?.scope,description:l?.description??"",preventDefault:l?.preventDefault};return e.push(u),o(),()=>{let d=e.indexOf(u);d!==-1&&e.splice(d,1);}}return {bind:i,enableScope(s){t.add(s);},disableScope(s){t.delete(s);},getBindings(){return e.map(s=>({key:Un(s.key),description:s.description??"",scope:s.scope}))},dispose(){e.length=0,typeof document<"u"&&document.removeEventListener("keydown",r),n=false;}}}function zn(e,t){let n=t.toLowerCase().split("+"),r=n.pop(),o=n.includes("mod"),i=n.includes("ctrl"),s=n.includes("shift"),a=n.includes("alt"),u=typeof navigator<"u"&&navigator.platform?.includes("Mac")?e.metaKey:e.ctrlKey;return o&&!u||i&&!e.ctrlKey||s&&!e.shiftKey||a&&!e.altKey?false:e.key.toLowerCase()===r||e.code.toLowerCase()===r}function Un(e){let t=typeof navigator<"u"&&navigator.platform?.includes("Mac");return e.replace(/mod/gi,t?"\u2318":"Ctrl").replace(/shift/gi,t?"\u21E7":"Shift").replace(/alt/gi,t?"\u2325":"Alt").replace(/\+/g,t?"":"+")}var Gn=y(e=>{let t=c(false),n=c(false);return ()=>{let{src:r,alt:o,width:i,height:s,loading:a="lazy",srcset:l,sizes:u,placeholder:d,blurDataUrl:c,class:f,fallbackSrc:p,onLoad:T,onError:h}=e.props,m=document.createElement("div");if(m.style.position="relative",m.style.display="inline-block",m.style.overflow="hidden",i&&(m.style.width=`${i}px`),s&&(m.style.height=`${s}px`),d==="blur"&&c&&!t()){let b=document.createElement("img");b.src=c,b.alt="",b.setAttribute("aria-hidden","true"),b.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;filter:blur(20px);transform:scale(1.1);",m.appendChild(b);}let y=document.createElement("img");if(y.alt=o,y.loading=a,n()&&p?y.src=p:y.src=r,l&&(y.srcset=l),u&&(y.sizes=u),i&&(y.width=i),s&&(y.height=s),f&&(y.className=f),y.style.display="block",y.style.width="100%",y.style.height="auto",y.addEventListener("load",()=>{t.set(true),T?.();}),y.addEventListener("error",b=>{n.set(true),h?.(b);}),a==="lazy"&&typeof IntersectionObserver<"u"){y.setAttribute("data-src",y.src);let b=y.src;y.removeAttribute("src");let k=new IntersectionObserver(v=>{v[0].isIntersecting&&(y.src=b,k.disconnect());},{rootMargin:"200px"});requestAnimationFrame(()=>{y.parentElement?k.observe(y):y.src=b;});}return m.appendChild(y),m}});function Qn(e){let{onLoadMore:t,hasMore:n,rootMargin:r="200px",threshold:o=0}=e,i=c(false),s=c(false),a=null,l=null,u=false;async function d(){if(!(i()||s()||u)){if(!n()){s.set(true);return}i.set(true);try{await t(),n()||s.set(!0);}finally{i.set(false);}}}function c$1(p){typeof IntersectionObserver>"u"||(a=new IntersectionObserver(T=>{T[0]?.isIntersecting&&d();},{rootMargin:r,threshold:o}),a.observe(p));}function f(){return l||(l=document.createElement("div"),l.setAttribute("data-akash-sentinel",""),l.style.height="1px",l.setAttribute("aria-hidden","true"),requestAnimationFrame(()=>{l&&!u&&c$1(l);}),l)}return {sentinel:f,loading:()=>i(),done:()=>s(),reset(){s.set(false),i.set(false);},dispose(){u=true,a?.disconnect(),a=null;}}}function he(...e){let t=[];for(let n of e)if(n){if(typeof n=="string")t.push(n);else if(Array.isArray(n)){let r=he(...n);r&&t.push(r);}else if(typeof n=="object")for(let[r,o]of Object.entries(n))o&&t.push(r);}return t.join(" ")}function Jn(e){let t=[];for(let[n,r]of Object.entries(e)){if(r==null)continue;let o=te(n),i=typeof r=="number"&&!Te.has(n)?`${r}px`:String(r);t.push(`${o}: ${i}`);}return t.join("; ")}function Yn(e,t){for(let[n,r]of Object.entries(t))if(r==null)e.style.removeProperty(te(n));else {let o=typeof r=="number"&&!Te.has(n)?`${r}px`:String(r);e.style.setProperty(te(n),o);}}function te(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}var Te=new Set(["animationIterationCount","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","fillOpacity","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","fontWeight","gridColumn","gridRow","lineClamp","lineHeight","opacity","order","orphans","tabSize","widows","zIndex","zoom"]);function Xn(e){let{data:t,columns:n,pageSize:r=0,initialSort:o}=e,i=c(o??{column:null,direction:null}),s=c(""),a=c(1),l=c(Object.fromEntries(n.map(v=>[v.key,v.visible!==false]))),u=d(()=>{let v=l();return n.filter(x=>v[x.key])}),d$1=d(()=>{let v=s().toLowerCase().trim();if(!v)return t();let x=n.filter(P=>P.filterable);return x.length===0?t():t().filter(P=>x.some(A=>{let R=ne(P,A.key);return String(R).toLowerCase().includes(v)}))}),c$1=d(()=>{let{column:v,direction:x}=i(),P=[...d$1()];if(!v||!x)return P;let A=n.find(R=>R.key===v);return A?P.sort((R,ie)=>{if(A.compare){let ae=A.compare(R,ie);return x==="desc"?-ae:ae}let Fe=ne(R,v),Ne=ne(ie,v),se=Zn(Fe,Ne);return x==="desc"?-se:se}):P}),f=d(()=>d$1().length),p=d(()=>r<=0?1:Math.max(1,Math.ceil(f()/r))),T=d(()=>{let v=c$1();if(r<=0)return v;let x=(a()-1)*r;return v.slice(x,x+r)});function h(v){let x=i();x.column===v?x.direction==="asc"?i.set({column:v,direction:"desc"}):x.direction==="desc"?i.set({column:null,direction:null}):i.set({column:v,direction:"asc"}):i.set({column:v,direction:"asc"}),a.set(1);}function m(v){s.set(v),a.set(1);}function y(v){l.update(x=>({...x,[v]:!x[v]}));}function b(v){l.update(x=>({...x,[v]:true}));}function k(v){l.update(x=>({...x,[v]:false}));}return {rows:T,allRows:c$1,totalRows:f,visibleColumns:u,sortState:()=>i(),filterText:()=>s(),page:()=>a(),totalPages:p,sort:h,filter:m,toggleColumn:y,showColumn:b,hideColumn:k,nextPage(){a()<p()&&a.update(v=>v+1);},prevPage(){a()>1&&a.update(v=>v-1);},goToPage(v){a.set(Math.max(1,Math.min(v,p())));},reset(){i.set({column:null,direction:null}),s.set(""),a.set(1);}}}function ne(e,t){return t.split(".").reduce((n,r)=>n?.[r],e)}function Zn(e,t){return e==null&&t==null?0:e==null?-1:t==null?1:typeof e=="number"&&typeof t=="number"?e-t:String(e).localeCompare(String(t))}function ve(e){let t=Array.isArray(e)?e:[e];for(let n of t){let r={"@context":"https://schema.org",...n};j({script:[{type:"application/ld+json",innerHTML:JSON.stringify(r)}]});}}function be(e){let t=[{property:"og:title",content:e.title}];e.description&&t.push({property:"og:description",content:e.description}),e.image&&t.push({property:"og:image",content:e.image}),e.url&&t.push({property:"og:url",content:e.url}),e.type&&t.push({property:"og:type",content:e.type}),e.siteName&&t.push({property:"og:site_name",content:e.siteName}),e.locale&&t.push({property:"og:locale",content:e.locale}),j({meta:t});}function we(e){let t=[{name:"twitter:title",content:e.title}];e.card&&t.push({name:"twitter:card",content:e.card}),e.description&&t.push({name:"twitter:description",content:e.description}),e.image&&t.push({name:"twitter:image",content:e.image}),e.site&&t.push({name:"twitter:site",content:e.site}),e.creator&&t.push({name:"twitter:creator",content:e.creator}),j({meta:t});}function er(e){let t=[];e.description&&t.push({name:"description",content:e.description}),e.robots&&t.push({name:"robots",content:e.robots});let n=[];e.canonical&&n.push({rel:"canonical",href:e.canonical}),j({title:e.title,meta:t,link:n}),e.openGraph&&be(e.openGraph),e.twitter&&we(e.twitter),e.structuredData&&ve(e.structuredData);}function tr(e,t){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
34
|
+
`;n+=`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
35
|
+
`;for(let r of t)n+=` <url>
|
|
36
|
+
`,n+=` <loc>${e}${r.url}</loc>
|
|
37
|
+
`,r.lastmod&&(n+=` <lastmod>${r.lastmod}</lastmod>
|
|
38
|
+
`),r.changefreq&&(n+=` <changefreq>${r.changefreq}</changefreq>
|
|
39
|
+
`),r.priority!=null&&(n+=` <priority>${r.priority}</priority>
|
|
40
|
+
`),n+=` </url>
|
|
41
|
+
`;return n+=`</urlset>
|
|
42
|
+
`,n}function nr(e,t,...n){return t(e,...n)}function rr(...e){return (t,...n)=>{let r=t;for(let o of e)r=o(r,...n);return r}}function or(e){return e}var ir=e=>String(e).toUpperCase(),sr=e=>String(e).toLowerCase(),ar=e=>{let t=String(e);return t.charAt(0).toUpperCase()+t.slice(1)},lr=e=>String(e).replace(/\b\w/g,t=>t.toUpperCase()),cr=e=>String(e).trim(),ur=(e,t=50,n="...")=>{let r=String(e);return r.length<=t?r:r.slice(0,t-n.length)+n},dr=(e,t="medium",n)=>{let r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return String(e);if(t==="iso")return r.toISOString();let o=n??"en-US",i={short:{year:"2-digit",month:"numeric",day:"numeric"},medium:{year:"numeric",month:"numeric",day:"numeric"},long:{year:"numeric",month:"long",day:"numeric"},full:{weekday:"long",year:"numeric",month:"long",day:"numeric"},time:{hour:"numeric",minute:"2-digit"}};return new Intl.DateTimeFormat(o,i[t]).format(r)},pr=(e,t="USD",n)=>new Intl.NumberFormat(n??"en-US",{style:"currency",currency:t}).format(Number(e)),fr=(e,t,n)=>{let r={};if(t){let[o,i]=t.split("-").map(Number);r.minimumFractionDigits=o,r.maximumFractionDigits=i??o;}return new Intl.NumberFormat(n??"en-US",r).format(Number(e))},mr=(e,t=0,n)=>new Intl.NumberFormat(n??"en-US",{style:"percent",minimumFractionDigits:t,maximumFractionDigits:t}).format(Number(e)),gr=(e,t=2)=>JSON.stringify(e,null,t),yr=(e,t,n)=>{let r=n??`${t}s`;return `${e} ${e===1?t:r}`},hr=(e,t)=>{let r=(e instanceof Date?e.getTime():Number(e))-Date.now(),o=Math.abs(r),i=[[6e4,"second"],[36e5,"minute"],[864e5,"hour"],[2592e6,"day"],[31536e6,"month"],[1/0,"year"]],s={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},a="second";for(let[c,f]of i)if(o<c){a=f;break}let l=Math.round(r/s[a]);if(typeof Intl<"u"&&Intl.RelativeTimeFormat)return new Intl.RelativeTimeFormat(t??"en",{numeric:"auto"}).format(l,a);let u=Math.abs(l),d=l<0?"ago":"from now";return `${u} ${a}${u!==1?"s":""} ${d}`};function H(e){return {_type:"directive",hooks:e}}function Tr(e){return H({mounted(t,n){let r=e(t,n);typeof r=="function"&&(t.__directiveCleanup=r);},unmounted(t){t.__directiveCleanup?.();}})}var _=Symbol("akash.directives");function vr(e,t,n,r){let o={value:n,arg:r?.arg,modifiers:r?.modifiers},i=e[_]??[];i.push({directive:t,binding:o}),e[_]=i,t.hooks.mounted?.(e,o);}function br(e,t,n){let o=(e[_]??[]).find(i=>i.directive===t);if(o){let i=o.binding.value;o.binding={...o.binding,value:n,oldValue:i},t.hooks.updated?.(e,o.binding);}}function wr(e){let t=e[_]??[];for(let n of t)n.directive.hooks.unmounted?.(e,n.binding);delete e[_];}var xr=H({mounted(e){requestAnimationFrame(()=>e.focus());}}),Sr=H({mounted(e,{value:t}){let n=r=>{e.contains(r.target)||t();};document.addEventListener("click",n,true),e.__vClickOutside=n;},unmounted(e){document.removeEventListener("click",e.__vClickOutside,true),delete e.__vClickOutside;}}),Er=H({mounted(e,{value:t}){let n=null,r=t.duration??500,o=()=>{n=setTimeout(t.handler,r);},i=()=>{n&&(clearTimeout(n),n=null);};e.addEventListener("pointerdown",o),e.addEventListener("pointerup",i),e.addEventListener("pointerleave",i),e.__vLongPress={start:o,cancel:i};},unmounted(e){let t=e.__vLongPress;t&&(e.removeEventListener("pointerdown",t.start),e.removeEventListener("pointerup",t.cancel),e.removeEventListener("pointerleave",t.cancel));}}),kr=H({mounted(e,{value:t}){let n=new IntersectionObserver(r=>{t(r[0].isIntersecting);});n.observe(e),e.__vIntersect=n;},unmounted(e){e.__vIntersect?.disconnect();}}),Pr=H({mounted(e,{value:t}){let n=new ResizeObserver(r=>{t(r[0]);});n.observe(e),e.__vResize=n;},unmounted(e){e.__vResize?.disconnect();}});function Cr(e,t,n={}){let{props:r=[],shadow:o=true,styles:i}=n;class s extends HTMLElement{static get observedAttributes(){return r}_root;_mounted=false;_props={};constructor(){super(),this._root=o?this.attachShadow({mode:"open"}):this;}connectedCallback(){for(let l of r){let u=this.getAttribute(l);u!==null&&(this._props[l]=W(u));}this._render(),this._mounted=true;}disconnectedCallback(){for(;this._root.firstChild;)this._root.removeChild(this._root.firstChild);this._mounted=false;}attributeChangedCallback(l,u,d){this._props[l]=d!==null?W(d):void 0,this._mounted&&this._render();}_render(){for(;this._root.firstChild;)this._root.removeChild(this._root.firstChild);if(o&&i){let u=document.createElement("style");u.textContent=i,this._root.appendChild(u);}let l=t(this._props);this._root.appendChild(l);}setProps(l){Object.assign(this._props,l),this._mounted&&this._render();}}return typeof customElements<"u"&&!customElements.get(e)&&(n.extends?customElements.define(e,s,{extends:n.extends}):customElements.define(e,s)),s}function Ar(e,t={}){let{props:n=[],shadow:r=true,styles:o}=t;return class extends HTMLElement{static get observedAttributes(){return n}_root;_mounted=false;_props={};constructor(){super(),this._root=r?this.attachShadow({mode:"open"}):this;}connectedCallback(){for(let i of n){let s=this.getAttribute(i);s!==null&&(this._props[i]=W(s));}this._render(),this._mounted=true;}disconnectedCallback(){for(;this._root.firstChild;)this._root.removeChild(this._root.firstChild);this._mounted=false;}attributeChangedCallback(i,s,a){this._props[i]=a!==null?W(a):void 0,this._mounted&&this._render();}_render(){for(;this._root.firstChild;)this._root.removeChild(this._root.firstChild);if(r&&o){let i=document.createElement("style");i.textContent=o,this._root.appendChild(i);}this._root.appendChild(e(this._props));}}}function W(e){try{return JSON.parse(e)}catch{return e}}var Rr=`<!DOCTYPE html>
|
|
3019
43
|
<html lang="en">
|
|
3020
44
|
<head>
|
|
3021
45
|
<meta charset="UTF-8">
|
|
@@ -3026,1575 +50,23 @@ var DEFAULT_TEMPLATE = `<!DOCTYPE html>
|
|
|
3026
50
|
<div id="app">{{content}}</div>
|
|
3027
51
|
{{scripts}}
|
|
3028
52
|
</body>
|
|
3029
|
-
</html>`;
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
onError: onError2,
|
|
3038
|
-
concurrency = 5
|
|
3039
|
-
} = options;
|
|
3040
|
-
const start = Date.now();
|
|
3041
|
-
const routes = typeof routesInput === "function" ? await routesInput() : routesInput;
|
|
3042
|
-
const result = {
|
|
3043
|
-
rendered: [],
|
|
3044
|
-
errors: [],
|
|
3045
|
-
duration: 0
|
|
3046
|
-
};
|
|
3047
|
-
for (let i = 0; i < routes.length; i += concurrency) {
|
|
3048
|
-
const batch2 = routes.slice(i, i + concurrency);
|
|
3049
|
-
await Promise.all(batch2.map(async (url) => {
|
|
3050
|
-
try {
|
|
3051
|
-
const content = await render(url);
|
|
3052
|
-
const html = template.replace("{{content}}", content).replace("{{head}}", "").replace("{{scripts}}", "");
|
|
3053
|
-
const filePath = urlToFilePath(url);
|
|
3054
|
-
result.rendered.push({
|
|
3055
|
-
url,
|
|
3056
|
-
file: `${outDir}/${filePath}`,
|
|
3057
|
-
size: new Blob([html]).size
|
|
3058
|
-
});
|
|
3059
|
-
onPage?.(url, html);
|
|
3060
|
-
} catch (err) {
|
|
3061
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
3062
|
-
result.errors.push({ url, error: error.message });
|
|
3063
|
-
onError2?.(url, error);
|
|
3064
|
-
}
|
|
3065
|
-
}));
|
|
3066
|
-
}
|
|
3067
|
-
result.duration = Date.now() - start;
|
|
3068
|
-
return result;
|
|
3069
|
-
}
|
|
3070
|
-
function discoverStaticRoutes(routeManifest) {
|
|
3071
|
-
return routeManifest.filter((r) => !r.path.includes(":") && !r.path.includes("*")).map((r) => r.path);
|
|
3072
|
-
}
|
|
3073
|
-
function generatePaths(pattern, params) {
|
|
3074
|
-
return params.map((p) => {
|
|
3075
|
-
let path = pattern;
|
|
3076
|
-
for (const [key, value] of Object.entries(p)) {
|
|
3077
|
-
path = path.replace(`:${key}`, value);
|
|
3078
|
-
}
|
|
3079
|
-
return path;
|
|
3080
|
-
});
|
|
3081
|
-
}
|
|
3082
|
-
function urlToFilePath(url) {
|
|
3083
|
-
const clean = url.replace(/^\//, "").replace(/\/$/, "");
|
|
3084
|
-
if (!clean) return "index.html";
|
|
3085
|
-
return `${clean}/index.html`;
|
|
3086
|
-
}
|
|
3087
|
-
function sitemapFromResults(baseUrl, results) {
|
|
3088
|
-
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
3089
|
-
xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n';
|
|
3090
|
-
for (const page of results.rendered) {
|
|
3091
|
-
xml += ` <url>
|
|
3092
|
-
`;
|
|
3093
|
-
xml += ` <loc>${baseUrl}${page.url}</loc>
|
|
3094
|
-
`;
|
|
3095
|
-
xml += ` <lastmod>${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}</lastmod>
|
|
3096
|
-
`;
|
|
3097
|
-
xml += ` </url>
|
|
3098
|
-
`;
|
|
3099
|
-
}
|
|
3100
|
-
xml += "</urlset>\n";
|
|
3101
|
-
return xml;
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
// src/switch.ts
|
|
3105
|
-
function renderSwitch(parent, anchor, expression, cases) {
|
|
3106
|
-
let currentNodes = [];
|
|
3107
|
-
const dispose = effect(
|
|
3108
|
-
() => {
|
|
3109
|
-
const value = String(expression());
|
|
3110
|
-
for (const node of currentNodes) {
|
|
3111
|
-
if (node.parentNode) node.parentNode.removeChild(node);
|
|
3112
|
-
}
|
|
3113
|
-
currentNodes = [];
|
|
3114
|
-
const branch = cases[value] ?? cases._default;
|
|
3115
|
-
if (branch) {
|
|
3116
|
-
const node = branch();
|
|
3117
|
-
const nodes = node instanceof DocumentFragment ? Array.from(node.childNodes) : [node];
|
|
3118
|
-
for (const n of nodes) {
|
|
3119
|
-
parent.insertBefore(n, anchor);
|
|
3120
|
-
}
|
|
3121
|
-
currentNodes = nodes;
|
|
3122
|
-
}
|
|
3123
|
-
},
|
|
3124
|
-
{ render: true }
|
|
3125
|
-
);
|
|
3126
|
-
return () => {
|
|
3127
|
-
dispose();
|
|
3128
|
-
for (const node of currentNodes) {
|
|
3129
|
-
if (node.parentNode) node.parentNode.removeChild(node);
|
|
3130
|
-
}
|
|
3131
|
-
};
|
|
3132
|
-
}
|
|
3133
|
-
var Switch = defineComponent((ctx) => {
|
|
3134
|
-
return () => {
|
|
3135
|
-
const container = document.createElement("div");
|
|
3136
|
-
container.style.display = "contents";
|
|
3137
|
-
const anchor = document.createComment("switch");
|
|
3138
|
-
container.appendChild(anchor);
|
|
3139
|
-
const casesMap = { ...ctx.props.cases };
|
|
3140
|
-
if (ctx.props.fallback) {
|
|
3141
|
-
casesMap._default = () => nodeToDOM(ctx.props.fallback());
|
|
3142
|
-
}
|
|
3143
|
-
renderSwitch(
|
|
3144
|
-
container,
|
|
3145
|
-
anchor,
|
|
3146
|
-
() => ctx.props.on,
|
|
3147
|
-
Object.fromEntries(
|
|
3148
|
-
Object.entries(casesMap).map(([k, v]) => [
|
|
3149
|
-
k,
|
|
3150
|
-
() => nodeToDOM(v())
|
|
3151
|
-
])
|
|
3152
|
-
)
|
|
3153
|
-
);
|
|
3154
|
-
return container;
|
|
3155
|
-
};
|
|
3156
|
-
});
|
|
3157
|
-
function match(value, cases) {
|
|
3158
|
-
const key = String(value);
|
|
3159
|
-
const branch = cases[key] ?? cases._;
|
|
3160
|
-
return branch ? branch(value) : void 0;
|
|
3161
|
-
}
|
|
3162
|
-
|
|
3163
|
-
// src/di.ts
|
|
3164
|
-
var providerIdCounter = 0;
|
|
3165
|
-
function defineProvider(config) {
|
|
3166
|
-
return {
|
|
3167
|
-
_type: "provider",
|
|
3168
|
-
factory: config.factory,
|
|
3169
|
-
providedIn: config.providedIn,
|
|
3170
|
-
multi: config.multi,
|
|
3171
|
-
_id: /* @__PURE__ */ Symbol(`provider-${++providerIdCounter}`)
|
|
3172
|
-
};
|
|
3173
|
-
}
|
|
3174
|
-
var rootInstances = /* @__PURE__ */ new Map();
|
|
3175
|
-
function createInjector(providers = [], parent) {
|
|
3176
|
-
const instances = /* @__PURE__ */ new Map();
|
|
3177
|
-
const multiInstances = /* @__PURE__ */ new Map();
|
|
3178
|
-
const registrations = /* @__PURE__ */ new Map();
|
|
3179
|
-
for (const reg of providers) {
|
|
3180
|
-
registrations.set(reg.provide._id, reg);
|
|
3181
|
-
}
|
|
3182
|
-
const injector = {
|
|
3183
|
-
get(provider) {
|
|
3184
|
-
const id = provider._id;
|
|
3185
|
-
if (provider.multi) {
|
|
3186
|
-
if (multiInstances.has(id)) return multiInstances.get(id);
|
|
3187
|
-
const values = [];
|
|
3188
|
-
const reg2 = registrations.get(id);
|
|
3189
|
-
if (reg2?.useFactory) values.push(reg2.useFactory());
|
|
3190
|
-
else if (reg2?.useValue !== void 0) values.push(reg2.useValue);
|
|
3191
|
-
if (parent?.has(provider)) {
|
|
3192
|
-
const parentValues = parent.get(provider);
|
|
3193
|
-
if (Array.isArray(parentValues)) values.push(...parentValues);
|
|
3194
|
-
}
|
|
3195
|
-
multiInstances.set(id, values);
|
|
3196
|
-
return values;
|
|
3197
|
-
}
|
|
3198
|
-
if (instances.has(id)) return instances.get(id);
|
|
3199
|
-
if (provider.providedIn === "root" && rootInstances.has(id)) {
|
|
3200
|
-
return rootInstances.get(id);
|
|
3201
|
-
}
|
|
3202
|
-
const reg = registrations.get(id);
|
|
3203
|
-
if (reg) {
|
|
3204
|
-
const instance2 = resolveRegistration(reg, injector);
|
|
3205
|
-
instances.set(id, instance2);
|
|
3206
|
-
return instance2;
|
|
3207
|
-
}
|
|
3208
|
-
if (parent) {
|
|
3209
|
-
return parent.get(provider);
|
|
3210
|
-
}
|
|
3211
|
-
const instance = provider.factory();
|
|
3212
|
-
if (provider.providedIn === "root") {
|
|
3213
|
-
rootInstances.set(id, instance);
|
|
3214
|
-
} else {
|
|
3215
|
-
instances.set(id, instance);
|
|
3216
|
-
}
|
|
3217
|
-
return instance;
|
|
3218
|
-
},
|
|
3219
|
-
has(provider) {
|
|
3220
|
-
if (instances.has(provider._id)) return true;
|
|
3221
|
-
if (registrations.has(provider._id)) return true;
|
|
3222
|
-
if (provider.providedIn === "root" && rootInstances.has(provider._id)) return true;
|
|
3223
|
-
if (parent) return parent.has(provider);
|
|
3224
|
-
return false;
|
|
3225
|
-
},
|
|
3226
|
-
createChild(childProviders) {
|
|
3227
|
-
return createInjector(childProviders ?? [], injector);
|
|
3228
|
-
},
|
|
3229
|
-
dispose() {
|
|
3230
|
-
instances.clear();
|
|
3231
|
-
multiInstances.clear();
|
|
3232
|
-
}
|
|
3233
|
-
};
|
|
3234
|
-
return injector;
|
|
3235
|
-
}
|
|
3236
|
-
function resolveRegistration(reg, injector) {
|
|
3237
|
-
if (reg.useValue !== void 0) return reg.useValue;
|
|
3238
|
-
if (reg.useFactory) return reg.useFactory();
|
|
3239
|
-
if (reg.useExisting) return injector.get(reg.useExisting);
|
|
3240
|
-
return reg.provide.factory();
|
|
3241
|
-
}
|
|
3242
|
-
function injectProvider(provider) {
|
|
3243
|
-
{
|
|
3244
|
-
if (provider.providedIn === "root") {
|
|
3245
|
-
if (rootInstances.has(provider._id)) {
|
|
3246
|
-
return rootInstances.get(provider._id);
|
|
3247
|
-
}
|
|
3248
|
-
const instance = provider.factory();
|
|
3249
|
-
rootInstances.set(provider._id, instance);
|
|
3250
|
-
return instance;
|
|
3251
|
-
}
|
|
3252
|
-
return provider.factory();
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
function clearProviders() {
|
|
3256
|
-
rootInstances.clear();
|
|
3257
|
-
}
|
|
3258
|
-
|
|
3259
|
-
// src/animate.ts
|
|
3260
|
-
function animate(el, properties, options = {}) {
|
|
3261
|
-
const {
|
|
3262
|
-
duration = 300,
|
|
3263
|
-
easing = "ease",
|
|
3264
|
-
delay = 0,
|
|
3265
|
-
iterations = 1,
|
|
3266
|
-
direction = "normal",
|
|
3267
|
-
fill = "forwards",
|
|
3268
|
-
onComplete
|
|
3269
|
-
} = options;
|
|
3270
|
-
const keyframes2 = [{}, {}];
|
|
3271
|
-
for (const [prop, value] of Object.entries(properties)) {
|
|
3272
|
-
const cssProperty = prop === "y" ? "translateY" : prop === "x" ? "translateX" : prop;
|
|
3273
|
-
if (Array.isArray(value)) {
|
|
3274
|
-
const [from, to] = value;
|
|
3275
|
-
if (cssProperty === "translateY" || cssProperty === "translateX") {
|
|
3276
|
-
keyframes2[0].transform = `${cssProperty}(${typeof from === "number" ? from + "px" : from})`;
|
|
3277
|
-
keyframes2[1].transform = `${cssProperty}(${typeof to === "number" ? to + "px" : to})`;
|
|
3278
|
-
} else {
|
|
3279
|
-
keyframes2[0][cssProperty] = from;
|
|
3280
|
-
keyframes2[1][cssProperty] = to;
|
|
3281
|
-
}
|
|
3282
|
-
} else {
|
|
3283
|
-
keyframes2[1][cssProperty] = value;
|
|
3284
|
-
}
|
|
3285
|
-
}
|
|
3286
|
-
const animation = el.animate(keyframes2, {
|
|
3287
|
-
duration,
|
|
3288
|
-
easing,
|
|
3289
|
-
delay,
|
|
3290
|
-
iterations,
|
|
3291
|
-
direction,
|
|
3292
|
-
fill
|
|
3293
|
-
});
|
|
3294
|
-
const finished = new Promise((resolve) => {
|
|
3295
|
-
animation.onfinish = () => {
|
|
3296
|
-
onComplete?.();
|
|
3297
|
-
resolve();
|
|
3298
|
-
};
|
|
3299
|
-
});
|
|
3300
|
-
return {
|
|
3301
|
-
play: () => animation.play(),
|
|
3302
|
-
pause: () => animation.pause(),
|
|
3303
|
-
cancel: () => animation.cancel(),
|
|
3304
|
-
reverse: () => animation.reverse(),
|
|
3305
|
-
finished
|
|
3306
|
-
};
|
|
3307
|
-
}
|
|
3308
|
-
function animateStagger(selector, properties, options = {}) {
|
|
3309
|
-
const { stagger = 50, from = "start", ...animOptions } = options;
|
|
3310
|
-
const elements = typeof selector === "string" ? Array.from(document.querySelectorAll(selector)) : selector;
|
|
3311
|
-
const controls = [];
|
|
3312
|
-
const count = elements.length;
|
|
3313
|
-
elements.forEach((el, i) => {
|
|
3314
|
-
let delay = animOptions.delay ?? 0;
|
|
3315
|
-
switch (from) {
|
|
3316
|
-
case "start":
|
|
3317
|
-
delay += i * stagger;
|
|
3318
|
-
break;
|
|
3319
|
-
case "end":
|
|
3320
|
-
delay += (count - 1 - i) * stagger;
|
|
3321
|
-
break;
|
|
3322
|
-
case "center":
|
|
3323
|
-
delay += Math.abs(Math.floor(count / 2) - i) * stagger;
|
|
3324
|
-
break;
|
|
3325
|
-
}
|
|
3326
|
-
controls.push(animate(el, properties, { ...animOptions, delay }));
|
|
3327
|
-
});
|
|
3328
|
-
return controls;
|
|
3329
|
-
}
|
|
3330
|
-
async function animateSequence(steps) {
|
|
3331
|
-
for (const [el, props, opts] of steps) {
|
|
3332
|
-
const ctrl = animate(el, props, opts);
|
|
3333
|
-
await ctrl.finished;
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
async function animateGroup(steps) {
|
|
3337
|
-
const controls = steps.map(([el, props, opts]) => animate(el, props, opts));
|
|
3338
|
-
await Promise.all(controls.map((c) => c.finished));
|
|
3339
|
-
}
|
|
3340
|
-
function animateSpring(el, target, options = {}) {
|
|
3341
|
-
const {
|
|
3342
|
-
stiffness = 100,
|
|
3343
|
-
damping = 10,
|
|
3344
|
-
mass = 1,
|
|
3345
|
-
threshold = 0.01,
|
|
3346
|
-
onComplete
|
|
3347
|
-
} = options;
|
|
3348
|
-
const current = {};
|
|
3349
|
-
const velocity = {};
|
|
3350
|
-
const computed5 = window.getComputedStyle(el);
|
|
3351
|
-
for (const prop of Object.keys(target)) {
|
|
3352
|
-
current[prop] = parseFloat(computed5.getPropertyValue(prop)) || 0;
|
|
3353
|
-
velocity[prop] = 0;
|
|
3354
|
-
}
|
|
3355
|
-
let animating = true;
|
|
3356
|
-
let rafId = 0;
|
|
3357
|
-
let resolveFinished;
|
|
3358
|
-
const finished = new Promise((resolve) => {
|
|
3359
|
-
resolveFinished = resolve;
|
|
3360
|
-
});
|
|
3361
|
-
function step() {
|
|
3362
|
-
if (!animating) return;
|
|
3363
|
-
let allSettled = true;
|
|
3364
|
-
const dt = 1 / 60;
|
|
3365
|
-
for (const prop of Object.keys(target)) {
|
|
3366
|
-
const displacement = current[prop] - target[prop];
|
|
3367
|
-
const springForce = -stiffness * displacement;
|
|
3368
|
-
const dampingForce = -damping * velocity[prop];
|
|
3369
|
-
const acceleration = (springForce + dampingForce) / mass;
|
|
3370
|
-
velocity[prop] += acceleration * dt;
|
|
3371
|
-
current[prop] += velocity[prop] * dt;
|
|
3372
|
-
if (Math.abs(velocity[prop]) > threshold || Math.abs(displacement) > threshold) {
|
|
3373
|
-
allSettled = false;
|
|
3374
|
-
}
|
|
3375
|
-
}
|
|
3376
|
-
applySpringValues(el, current);
|
|
3377
|
-
if (allSettled) {
|
|
3378
|
-
for (const prop of Object.keys(target)) {
|
|
3379
|
-
current[prop] = target[prop];
|
|
3380
|
-
}
|
|
3381
|
-
applySpringValues(el, current);
|
|
3382
|
-
animating = false;
|
|
3383
|
-
onComplete?.();
|
|
3384
|
-
resolveFinished();
|
|
3385
|
-
} else {
|
|
3386
|
-
rafId = requestAnimationFrame(step);
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
rafId = requestAnimationFrame(step);
|
|
3390
|
-
return {
|
|
3391
|
-
play() {
|
|
3392
|
-
if (!animating) {
|
|
3393
|
-
animating = true;
|
|
3394
|
-
step();
|
|
3395
|
-
}
|
|
3396
|
-
},
|
|
3397
|
-
pause() {
|
|
3398
|
-
animating = false;
|
|
3399
|
-
cancelAnimationFrame(rafId);
|
|
3400
|
-
},
|
|
3401
|
-
cancel() {
|
|
3402
|
-
animating = false;
|
|
3403
|
-
cancelAnimationFrame(rafId);
|
|
3404
|
-
},
|
|
3405
|
-
reverse() {
|
|
3406
|
-
for (const prop of Object.keys(target)) {
|
|
3407
|
-
velocity[prop] = -velocity[prop];
|
|
3408
|
-
}
|
|
3409
|
-
},
|
|
3410
|
-
finished
|
|
3411
|
-
};
|
|
3412
|
-
}
|
|
3413
|
-
function applySpringValues(el, values) {
|
|
3414
|
-
const transforms = [];
|
|
3415
|
-
for (const [prop, value] of Object.entries(values)) {
|
|
3416
|
-
switch (prop) {
|
|
3417
|
-
case "x":
|
|
3418
|
-
transforms.push(`translateX(${value}px)`);
|
|
3419
|
-
break;
|
|
3420
|
-
case "y":
|
|
3421
|
-
transforms.push(`translateY(${value}px)`);
|
|
3422
|
-
break;
|
|
3423
|
-
case "scale":
|
|
3424
|
-
transforms.push(`scale(${value})`);
|
|
3425
|
-
break;
|
|
3426
|
-
case "rotate":
|
|
3427
|
-
transforms.push(`rotate(${value}deg)`);
|
|
3428
|
-
break;
|
|
3429
|
-
case "opacity":
|
|
3430
|
-
el.style.opacity = String(value);
|
|
3431
|
-
break;
|
|
3432
|
-
default:
|
|
3433
|
-
el.style.setProperty(prop, String(value));
|
|
3434
|
-
break;
|
|
3435
|
-
}
|
|
3436
|
-
}
|
|
3437
|
-
if (transforms.length > 0) {
|
|
3438
|
-
el.style.transform = transforms.join(" ");
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
function keyframes(frames) {
|
|
3442
|
-
return frames;
|
|
3443
|
-
}
|
|
3444
|
-
function defineStates(states, defaultOptions = {}) {
|
|
3445
|
-
return {
|
|
3446
|
-
states,
|
|
3447
|
-
transitionTo(el, stateName, options) {
|
|
3448
|
-
const target = states[stateName];
|
|
3449
|
-
if (!target) throw new Error(`Unknown animation state: ${stateName}`);
|
|
3450
|
-
const props = {};
|
|
3451
|
-
for (const [key, value] of Object.entries(target)) {
|
|
3452
|
-
props[key] = value;
|
|
3453
|
-
}
|
|
3454
|
-
return animate(el, props, { ...defaultOptions, ...options });
|
|
3455
|
-
}
|
|
3456
|
-
};
|
|
3457
|
-
}
|
|
3458
|
-
|
|
3459
|
-
// src/defer.ts
|
|
3460
|
-
function defer(loader, options = {}) {
|
|
3461
|
-
const {
|
|
3462
|
-
trigger = "viewport",
|
|
3463
|
-
loading: loadingFn,
|
|
3464
|
-
error: errorFn,
|
|
3465
|
-
prefetch = false,
|
|
3466
|
-
minLoadTime = 0,
|
|
3467
|
-
rootMargin = "200px"
|
|
3468
|
-
} = options;
|
|
3469
|
-
let resolvedComp = null;
|
|
3470
|
-
let loadPromise = null;
|
|
3471
|
-
let loadError = null;
|
|
3472
|
-
function startLoad() {
|
|
3473
|
-
if (loadPromise) return loadPromise;
|
|
3474
|
-
const start = Date.now();
|
|
3475
|
-
loadPromise = loader().then(async (mod) => {
|
|
3476
|
-
const elapsed = Date.now() - start;
|
|
3477
|
-
if (minLoadTime > 0 && elapsed < minLoadTime) {
|
|
3478
|
-
await new Promise((r) => setTimeout(r, minLoadTime - elapsed));
|
|
3479
|
-
}
|
|
3480
|
-
resolvedComp = mod.default;
|
|
3481
|
-
}).catch((err) => {
|
|
3482
|
-
loadError = err instanceof Error ? err : new Error(String(err));
|
|
3483
|
-
});
|
|
3484
|
-
return loadPromise;
|
|
3485
|
-
}
|
|
3486
|
-
if (prefetch) startLoad();
|
|
3487
|
-
return defineComponent((ctx) => {
|
|
3488
|
-
const state = signal("idle");
|
|
3489
|
-
async function triggerLoad() {
|
|
3490
|
-
if (state() !== "idle") return;
|
|
3491
|
-
state.set("loading");
|
|
3492
|
-
await startLoad();
|
|
3493
|
-
state.set(loadError ? "error" : "ready");
|
|
3494
|
-
}
|
|
3495
|
-
return () => {
|
|
3496
|
-
const container = document.createElement("div");
|
|
3497
|
-
container.style.display = "contents";
|
|
3498
|
-
const s = state();
|
|
3499
|
-
if (s === "ready" && resolvedComp) {
|
|
3500
|
-
container.appendChild(resolvedComp(ctx.props));
|
|
3501
|
-
return container;
|
|
3502
|
-
}
|
|
3503
|
-
if (s === "error" && errorFn && loadError) {
|
|
3504
|
-
container.appendChild(nodeToDOM(errorFn(loadError)));
|
|
3505
|
-
return container;
|
|
3506
|
-
}
|
|
3507
|
-
if (loadingFn && s === "loading") {
|
|
3508
|
-
container.appendChild(nodeToDOM(loadingFn()));
|
|
3509
|
-
}
|
|
3510
|
-
if (s === "idle") {
|
|
3511
|
-
setupTrigger(container, trigger, triggerLoad, rootMargin).then((cleanup) => {
|
|
3512
|
-
});
|
|
3513
|
-
}
|
|
3514
|
-
return container;
|
|
3515
|
-
};
|
|
3516
|
-
});
|
|
3517
|
-
}
|
|
3518
|
-
async function setupTrigger(el, trigger, load, rootMargin) {
|
|
3519
|
-
if (trigger === "immediate") {
|
|
3520
|
-
load();
|
|
3521
|
-
return () => {
|
|
3522
|
-
};
|
|
3523
|
-
}
|
|
3524
|
-
if (trigger === "viewport") {
|
|
3525
|
-
return setupViewportTrigger(el, load, rootMargin);
|
|
3526
|
-
}
|
|
3527
|
-
if (trigger === "interaction" || trigger === "hover") {
|
|
3528
|
-
return setupInteractionTrigger(el, load, trigger);
|
|
3529
|
-
}
|
|
3530
|
-
if (trigger === "idle") {
|
|
3531
|
-
return setupIdleTrigger(load);
|
|
3532
|
-
}
|
|
3533
|
-
if (typeof trigger === "object" && trigger.type === "timer") {
|
|
3534
|
-
return setupTimerTrigger(load, trigger.delay);
|
|
3535
|
-
}
|
|
3536
|
-
if (typeof trigger === "object" && trigger.type === "custom") {
|
|
3537
|
-
return setupCustomTrigger(load, trigger.condition);
|
|
3538
|
-
}
|
|
3539
|
-
load();
|
|
3540
|
-
return () => {
|
|
3541
|
-
};
|
|
3542
|
-
}
|
|
3543
|
-
function setupViewportTrigger(el, load, rootMargin) {
|
|
3544
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
3545
|
-
load();
|
|
3546
|
-
return () => {
|
|
3547
|
-
};
|
|
3548
|
-
}
|
|
3549
|
-
const observer = new IntersectionObserver(
|
|
3550
|
-
(entries2) => {
|
|
3551
|
-
if (entries2[0]?.isIntersecting) {
|
|
3552
|
-
observer.disconnect();
|
|
3553
|
-
load();
|
|
3554
|
-
}
|
|
3555
|
-
},
|
|
3556
|
-
{ rootMargin }
|
|
3557
|
-
);
|
|
3558
|
-
requestAnimationFrame(() => observer.observe(el));
|
|
3559
|
-
return () => observer.disconnect();
|
|
3560
|
-
}
|
|
3561
|
-
function setupInteractionTrigger(el, load, type) {
|
|
3562
|
-
const events = type === "hover" ? ["mouseenter", "focusin"] : ["click", "mouseenter", "focusin", "touchstart"];
|
|
3563
|
-
const handler = () => {
|
|
3564
|
-
for (const event of events) {
|
|
3565
|
-
el.removeEventListener(event, handler);
|
|
3566
|
-
}
|
|
3567
|
-
load();
|
|
3568
|
-
};
|
|
3569
|
-
for (const event of events) {
|
|
3570
|
-
el.addEventListener(event, handler, { once: true, passive: true });
|
|
3571
|
-
}
|
|
3572
|
-
return () => {
|
|
3573
|
-
for (const event of events) {
|
|
3574
|
-
el.removeEventListener(event, handler);
|
|
3575
|
-
}
|
|
3576
|
-
};
|
|
3577
|
-
}
|
|
3578
|
-
function setupIdleTrigger(load) {
|
|
3579
|
-
if (typeof requestIdleCallback !== "undefined") {
|
|
3580
|
-
const id = requestIdleCallback(() => load());
|
|
3581
|
-
return () => cancelIdleCallback(id);
|
|
3582
|
-
}
|
|
3583
|
-
const timer = setTimeout(load, 200);
|
|
3584
|
-
return () => clearTimeout(timer);
|
|
3585
|
-
}
|
|
3586
|
-
function setupTimerTrigger(load, delay) {
|
|
3587
|
-
const timer = setTimeout(load, delay);
|
|
3588
|
-
return () => clearTimeout(timer);
|
|
3589
|
-
}
|
|
3590
|
-
function setupCustomTrigger(load, condition) {
|
|
3591
|
-
const check = () => {
|
|
3592
|
-
if (condition()) load();
|
|
3593
|
-
else requestAnimationFrame(check);
|
|
3594
|
-
};
|
|
3595
|
-
requestAnimationFrame(check);
|
|
3596
|
-
return () => {
|
|
3597
|
-
};
|
|
3598
|
-
}
|
|
3599
|
-
|
|
3600
|
-
// src/view-transition.ts
|
|
3601
|
-
function supportsViewTransitions() {
|
|
3602
|
-
return typeof document !== "undefined" && "startViewTransition" in document;
|
|
3603
|
-
}
|
|
3604
|
-
function startViewTransition(updateCallback, options = {}) {
|
|
3605
|
-
const { className, onBefore, onAfter, fallback = "instant" } = options;
|
|
3606
|
-
onBefore?.();
|
|
3607
|
-
if (supportsViewTransitions()) {
|
|
3608
|
-
if (className) document.documentElement.classList.add(className);
|
|
3609
|
-
const transition = document.startViewTransition(async () => {
|
|
3610
|
-
await updateCallback();
|
|
3611
|
-
});
|
|
3612
|
-
const finished = transition.finished.then(() => {
|
|
3613
|
-
if (className) document.documentElement.classList.remove(className);
|
|
3614
|
-
onAfter?.();
|
|
3615
|
-
});
|
|
3616
|
-
return {
|
|
3617
|
-
finished,
|
|
3618
|
-
updateCallbackDone: transition.updateCallbackDone,
|
|
3619
|
-
ready: transition.ready,
|
|
3620
|
-
skipTransition: () => transition.skipTransition()
|
|
3621
|
-
};
|
|
3622
|
-
}
|
|
3623
|
-
if (fallback === "fade") {
|
|
3624
|
-
return fadeTransition(updateCallback, options);
|
|
3625
|
-
}
|
|
3626
|
-
const result = updateCallback();
|
|
3627
|
-
const done = result instanceof Promise ? result : Promise.resolve();
|
|
3628
|
-
onAfter?.();
|
|
3629
|
-
return {
|
|
3630
|
-
finished: done,
|
|
3631
|
-
updateCallbackDone: done,
|
|
3632
|
-
ready: Promise.resolve(),
|
|
3633
|
-
skipTransition: () => {
|
|
3634
|
-
}
|
|
3635
|
-
};
|
|
3636
|
-
}
|
|
3637
|
-
function viewTransitionCSS(config = {}) {
|
|
3638
|
-
const {
|
|
3639
|
-
duration = "0.25s",
|
|
3640
|
-
easing = "ease",
|
|
3641
|
-
oldAnimation,
|
|
3642
|
-
newAnimation
|
|
3643
|
-
} = config;
|
|
3644
|
-
let css2 = `::view-transition-old(root),
|
|
53
|
+
</html>`;async function Lr(e){let{routes:t,render:n,outDir:r="dist",template:o=Rr,onPage:i,onError:s,concurrency:a=5}=e,l=Date.now(),u=typeof t=="function"?await t():t,d={rendered:[],errors:[],duration:0};for(let c=0;c<u.length;c+=a){let f=u.slice(c,c+a);await Promise.all(f.map(async p=>{try{let T=await n(p),h=o.replace("{{content}}",T).replace("{{head}}","").replace("{{scripts}}",""),m=xe(p);d.rendered.push({url:p,file:`${r}/${m}`,size:new Blob([h]).size}),i?.(p,h);}catch(T){let h=T instanceof Error?T:new Error(String(T));d.errors.push({url:p,error:h.message}),s?.(p,h);}}));}return d.duration=Date.now()-l,d}function Or(e){return e.filter(t=>!t.path.includes(":")&&!t.path.includes("*")).map(t=>t.path)}function Dr(e,t){return t.map(n=>{let r=e;for(let[o,i]of Object.entries(n))r=r.replace(`:${o}`,i);return r})}function xe(e){let t=e.replace(/^\//,"").replace(/\/$/,"");return t?`${t}/index.html`:"index.html"}function Mr(e,t){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
54
|
+
`;n+=`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
55
|
+
`;for(let r of t.rendered)n+=` <url>
|
|
56
|
+
`,n+=` <loc>${e}${r.url}</loc>
|
|
57
|
+
`,n+=` <lastmod>${new Date().toISOString().split("T")[0]}</lastmod>
|
|
58
|
+
`,n+=` </url>
|
|
59
|
+
`;return n+=`</urlset>
|
|
60
|
+
`,n}function Se(e$1,t,n,r){let o=[],i=e(()=>{let s=String(n());for(let l of o)l.parentNode&&l.parentNode.removeChild(l);o=[];let a=r[s]??r._default;if(a){let l=a(),u=l instanceof DocumentFragment?Array.from(l.childNodes):[l];for(let d of u)e$1.insertBefore(d,t);o=u;}},{render:true});return ()=>{i();for(let s of o)s.parentNode&&s.parentNode.removeChild(s);}}var Hr=y(e=>()=>{let t=document.createElement("div");t.style.display="contents";let n=document.createComment("switch");t.appendChild(n);let r={...e.props.cases};return e.props.fallback&&(r._default=()=>s(e.props.fallback())),Se(t,n,()=>e.props.on,Object.fromEntries(Object.entries(r).map(([o,i])=>[o,()=>s(i())]))),t});function Ir(e,t){let n=String(e),r=t[n]??t._;return r?r(e):void 0}var jr=0;function Fr(e){return {_type:"provider",factory:e.factory,providedIn:e.providedIn,multi:e.multi,_id:Symbol(`provider-${++jr}`)}}var O=new Map;function ke(e=[],t){let n=new Map,r=new Map,o=new Map;for(let s of e)o.set(s.provide._id,s);let i={get(s){let a=s._id;if(s.multi){if(r.has(a))return r.get(a);let d=[],c=o.get(a);if(c?.useFactory?d.push(c.useFactory()):c?.useValue!==void 0&&d.push(c.useValue),t?.has(s)){let f=t.get(s);Array.isArray(f)&&d.push(...f);}return r.set(a,d),d}if(n.has(a))return n.get(a);if(s.providedIn==="root"&&O.has(a))return O.get(a);let l=o.get(a);if(l){let d=Nr(l,i);return n.set(a,d),d}if(t)return t.get(s);let u=s.factory();return s.providedIn==="root"?O.set(a,u):n.set(a,u),u},has(s){return n.has(s._id)||o.has(s._id)||s.providedIn==="root"&&O.has(s._id)?true:t?t.has(s):false},createChild(s){return ke(s??[],i)},dispose(){n.clear(),r.clear();}};return i}function Nr(e,t){return e.useValue!==void 0?e.useValue:e.useFactory?e.useFactory():e.useExisting?t.get(e.useExisting):e.provide.factory()}function _r(e){{if(e.providedIn==="root"){if(O.has(e._id))return O.get(e._id);let t=e.factory();return O.set(e._id,t),t}return e.factory()}}function $r(){O.clear();}function Kr(e,t={}){let{trigger:n="viewport",loading:r,error:o,prefetch:i=false,minLoadTime:s$1=0,rootMargin:a="200px"}=t,l=null,u=null,d=null;function c$1(){if(u)return u;let f=Date.now();return u=e().then(async p=>{let T=Date.now()-f;s$1>0&&T<s$1&&await new Promise(h=>setTimeout(h,s$1-T)),l=p.default;}).catch(p=>{d=p instanceof Error?p:new Error(String(p));}),u}return i&&c$1(),y(f=>{let p=c("idle");async function h(){p()==="idle"&&(p.set("loading"),await c$1(),p.set(d?"error":"ready"));}return ()=>{let m=document.createElement("div");m.style.display="contents";let y=p();return y==="ready"&&l?(m.appendChild(l(f.props)),m):y==="error"&&o&&d?(m.appendChild(s(o(d))),m):(r&&y==="loading"&&m.appendChild(s(r())),y==="idle"&&Vr(m,n,h,a).then(b=>{}),m)}})}async function Vr(e,t,n,r){return t==="immediate"?(n(),()=>{}):t==="viewport"?Br(e,n,r):t==="interaction"||t==="hover"?qr(e,n,t):t==="idle"?Wr(n):typeof t=="object"&&t.type==="timer"?zr(n,t.delay):typeof t=="object"&&t.type==="custom"?Ur(n,t.condition):(n(),()=>{})}function Br(e,t,n){if(typeof IntersectionObserver>"u")return t(),()=>{};let r=new IntersectionObserver(o=>{o[0]?.isIntersecting&&(r.disconnect(),t());},{rootMargin:n});return requestAnimationFrame(()=>r.observe(e)),()=>r.disconnect()}function qr(e,t,n){let r=n==="hover"?["mouseenter","focusin"]:["click","mouseenter","focusin","touchstart"],o=()=>{for(let i of r)e.removeEventListener(i,o);t();};for(let i of r)e.addEventListener(i,o,{once:true,passive:true});return ()=>{for(let i of r)e.removeEventListener(i,o);}}function Wr(e){if(typeof requestIdleCallback<"u"){let n=requestIdleCallback(()=>e());return ()=>cancelIdleCallback(n)}let t=setTimeout(e,200);return ()=>clearTimeout(t)}function zr(e,t){let n=setTimeout(e,t);return ()=>clearTimeout(n)}function Ur(e,t){let n=()=>{t()?e():requestAnimationFrame(n);};return requestAnimationFrame(n),()=>{}}function Pe(){return typeof document<"u"&&"startViewTransition"in document}function Gr(e,t={}){let{className:n,onBefore:r,onAfter:o,fallback:i="instant"}=t;if(r?.(),Pe()){n&&document.documentElement.classList.add(n);let l=document.startViewTransition(async()=>{await e();});return {finished:l.finished.then(()=>{n&&document.documentElement.classList.remove(n),o?.();}),updateCallbackDone:l.updateCallbackDone,ready:l.ready,skipTransition:()=>l.skipTransition()}}if(i==="fade")return Yr(e,t);let s=e(),a=s instanceof Promise?s:Promise.resolve();return o?.(),{finished:a,updateCallbackDone:a,ready:Promise.resolve(),skipTransition:()=>{}}}function Qr(e={}){let{duration:t="0.25s",easing:n="ease",oldAnimation:r,newAnimation:o}=e,i=`::view-transition-old(root),
|
|
3645
61
|
::view-transition-new(root) {
|
|
3646
|
-
`;
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
css2 += `}
|
|
3652
|
-
`;
|
|
3653
|
-
if (oldAnimation) {
|
|
3654
|
-
css2 += `::view-transition-old(root) {
|
|
3655
|
-
animation-name: ${oldAnimation};
|
|
3656
|
-
}
|
|
3657
|
-
`;
|
|
3658
|
-
}
|
|
3659
|
-
if (newAnimation) {
|
|
3660
|
-
css2 += `::view-transition-new(root) {
|
|
3661
|
-
animation-name: ${newAnimation};
|
|
3662
|
-
}
|
|
3663
|
-
`;
|
|
3664
|
-
}
|
|
3665
|
-
return css2;
|
|
3666
|
-
}
|
|
3667
|
-
function assignTransitionName(el, name) {
|
|
3668
|
-
el.style.viewTransitionName = name;
|
|
3669
|
-
}
|
|
3670
|
-
function fadeTransition(updateCallback, options) {
|
|
3671
|
-
const el = document.documentElement;
|
|
3672
|
-
const finished = new Promise(async (resolve) => {
|
|
3673
|
-
el.style.transition = "opacity 0.15s ease";
|
|
3674
|
-
el.style.opacity = "0";
|
|
3675
|
-
await new Promise((r) => setTimeout(r, 150));
|
|
3676
|
-
await updateCallback();
|
|
3677
|
-
el.style.opacity = "1";
|
|
3678
|
-
await new Promise((r) => setTimeout(r, 150));
|
|
3679
|
-
el.style.transition = "";
|
|
3680
|
-
el.style.opacity = "";
|
|
3681
|
-
options.onAfter?.();
|
|
3682
|
-
resolve();
|
|
3683
|
-
});
|
|
3684
|
-
return {
|
|
3685
|
-
finished,
|
|
3686
|
-
updateCallbackDone: finished,
|
|
3687
|
-
ready: Promise.resolve(),
|
|
3688
|
-
skipTransition: () => {
|
|
3689
|
-
el.style.transition = "";
|
|
3690
|
-
el.style.opacity = "";
|
|
3691
|
-
}
|
|
3692
|
-
};
|
|
3693
|
-
}
|
|
3694
|
-
|
|
3695
|
-
// src/query-state.ts
|
|
3696
|
-
function defaultSerialize(value) {
|
|
3697
|
-
if (Array.isArray(value)) return value.join(",");
|
|
3698
|
-
if (typeof value === "boolean") return value ? "true" : "false";
|
|
3699
|
-
return String(value);
|
|
3700
|
-
}
|
|
3701
|
-
function defaultDeserialize(raw, defaultValue) {
|
|
3702
|
-
if (typeof defaultValue === "number") return Number(raw);
|
|
3703
|
-
if (typeof defaultValue === "boolean") return raw === "true" || raw === "1";
|
|
3704
|
-
if (Array.isArray(defaultValue)) {
|
|
3705
|
-
return raw ? raw.split(",") : [];
|
|
3706
|
-
}
|
|
3707
|
-
return raw;
|
|
3708
|
-
}
|
|
3709
|
-
function getSearchParams() {
|
|
3710
|
-
if (typeof window === "undefined") return new URLSearchParams();
|
|
3711
|
-
return new URLSearchParams(window.location.search);
|
|
3712
|
-
}
|
|
3713
|
-
function updateURL(params, mode) {
|
|
3714
|
-
if (typeof window === "undefined") return;
|
|
3715
|
-
const search = params.toString();
|
|
3716
|
-
const url = search ? `${window.location.pathname}?${search}${window.location.hash}` : `${window.location.pathname}${window.location.hash}`;
|
|
3717
|
-
if (mode === "push") {
|
|
3718
|
-
window.history.pushState(null, "", url);
|
|
3719
|
-
} else {
|
|
3720
|
-
window.history.replaceState(null, "", url);
|
|
3721
|
-
}
|
|
3722
|
-
}
|
|
3723
|
-
var activeStates = /* @__PURE__ */ new Map();
|
|
3724
|
-
var popstateListening = false;
|
|
3725
|
-
function ensurePopstateListener() {
|
|
3726
|
-
if (popstateListening || typeof window === "undefined") return;
|
|
3727
|
-
popstateListening = true;
|
|
3728
|
-
window.addEventListener("popstate", () => {
|
|
3729
|
-
const params = getSearchParams();
|
|
3730
|
-
batch(() => {
|
|
3731
|
-
for (const [key, state] of activeStates) {
|
|
3732
|
-
const raw = params.get(key);
|
|
3733
|
-
const value = raw !== null ? state.deserialize(raw) : state.defaultValue;
|
|
3734
|
-
state.signal.set(value);
|
|
3735
|
-
}
|
|
3736
|
-
});
|
|
3737
|
-
});
|
|
3738
|
-
}
|
|
3739
|
-
function useQueryState(key, defaultValue, options = {}) {
|
|
3740
|
-
const {
|
|
3741
|
-
serialize = (v) => defaultSerialize(v),
|
|
3742
|
-
deserialize = (raw2) => defaultDeserialize(raw2, defaultValue),
|
|
3743
|
-
history: historyMode = "replace",
|
|
3744
|
-
debounce: debounceMs = 0,
|
|
3745
|
-
removeDefault = true
|
|
3746
|
-
} = options;
|
|
3747
|
-
const params = getSearchParams();
|
|
3748
|
-
const raw = params.get(key);
|
|
3749
|
-
const initialValue = raw !== null ? deserialize(raw) : defaultValue;
|
|
3750
|
-
const state = signal(initialValue);
|
|
3751
|
-
activeStates.set(key, { signal: state, deserialize, defaultValue });
|
|
3752
|
-
ensurePopstateListener();
|
|
3753
|
-
let debounceTimer = null;
|
|
3754
|
-
const originalSet = state.set;
|
|
3755
|
-
state.set = (value) => {
|
|
3756
|
-
originalSet(value);
|
|
3757
|
-
const doUpdate = () => {
|
|
3758
|
-
const currentParams = getSearchParams();
|
|
3759
|
-
if (removeDefault && value === defaultValue) {
|
|
3760
|
-
currentParams.delete(key);
|
|
3761
|
-
} else {
|
|
3762
|
-
currentParams.set(key, serialize(value));
|
|
3763
|
-
}
|
|
3764
|
-
updateURL(currentParams, historyMode);
|
|
3765
|
-
};
|
|
3766
|
-
if (debounceMs > 0) {
|
|
3767
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
3768
|
-
debounceTimer = setTimeout(doUpdate, debounceMs);
|
|
3769
|
-
} else {
|
|
3770
|
-
doUpdate();
|
|
3771
|
-
}
|
|
3772
|
-
};
|
|
3773
|
-
state.update;
|
|
3774
|
-
state.update = (fn) => {
|
|
3775
|
-
state.set(fn(state()));
|
|
3776
|
-
};
|
|
3777
|
-
return state;
|
|
3778
|
-
}
|
|
3779
|
-
function useQueryStates(schema, options) {
|
|
3780
|
-
const result = {};
|
|
3781
|
-
for (const [key, config] of Object.entries(schema)) {
|
|
3782
|
-
result[key] = useQueryState(key, config.default, {
|
|
3783
|
-
serialize: config.serialize,
|
|
3784
|
-
deserialize: config.deserialize,
|
|
3785
|
-
history: options?.history
|
|
3786
|
-
});
|
|
3787
|
-
}
|
|
3788
|
-
return result;
|
|
3789
|
-
}
|
|
3790
|
-
function clearQueryState() {
|
|
3791
|
-
if (typeof window === "undefined") return;
|
|
3792
|
-
const url = `${window.location.pathname}${window.location.hash}`;
|
|
3793
|
-
window.history.replaceState(null, "", url);
|
|
3794
|
-
batch(() => {
|
|
3795
|
-
for (const [, state] of activeStates) {
|
|
3796
|
-
state.signal.set(state.defaultValue);
|
|
3797
|
-
}
|
|
3798
|
-
});
|
|
3799
|
-
}
|
|
3800
|
-
function getQueryParams() {
|
|
3801
|
-
const params = getSearchParams();
|
|
3802
|
-
const result = {};
|
|
3803
|
-
params.forEach((value, key) => {
|
|
3804
|
-
result[key] = value;
|
|
3805
|
-
});
|
|
3806
|
-
return result;
|
|
3807
|
-
}
|
|
3808
|
-
function removeQueryState(key) {
|
|
3809
|
-
activeStates.delete(key);
|
|
3810
|
-
}
|
|
3811
|
-
function resetQueryState() {
|
|
3812
|
-
activeStates.clear();
|
|
3813
|
-
}
|
|
3814
|
-
|
|
3815
|
-
// src/tweened.ts
|
|
3816
|
-
var easings = {
|
|
3817
|
-
linear: (t) => t,
|
|
3818
|
-
cubicIn: (t) => t * t * t,
|
|
3819
|
-
cubicOut: (t) => 1 - Math.pow(1 - t, 3),
|
|
3820
|
-
cubicInOut: (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2,
|
|
3821
|
-
quadIn: (t) => t * t,
|
|
3822
|
-
quadOut: (t) => 1 - (1 - t) * (1 - t),
|
|
3823
|
-
quintOut: (t) => 1 - Math.pow(1 - t, 5),
|
|
3824
|
-
bounceOut: (t) => {
|
|
3825
|
-
if (t < 1 / 2.75) return 7.5625 * t * t;
|
|
3826
|
-
if (t < 2 / 2.75) return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;
|
|
3827
|
-
if (t < 2.5 / 2.75) return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375;
|
|
3828
|
-
return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
|
|
3829
|
-
},
|
|
3830
|
-
elasticOut: (t) => {
|
|
3831
|
-
if (t === 0 || t === 1) return t;
|
|
3832
|
-
return Math.pow(2, -10 * t) * Math.sin((t - 0.1) * 5 * Math.PI) + 1;
|
|
3833
|
-
}
|
|
3834
|
-
};
|
|
3835
|
-
function defaultInterpolate(from, to, t) {
|
|
3836
|
-
if (typeof from === "number" && typeof to === "number") {
|
|
3837
|
-
return from + (to - from) * t;
|
|
3838
|
-
}
|
|
3839
|
-
return t < 0.5 ? from : to;
|
|
3840
|
-
}
|
|
3841
|
-
function tweened(initialValue, options = {}) {
|
|
3842
|
-
const {
|
|
3843
|
-
duration = 400,
|
|
3844
|
-
easing = easings.cubicOut,
|
|
3845
|
-
interpolate = defaultInterpolate,
|
|
3846
|
-
delay = 0
|
|
3847
|
-
} = options;
|
|
3848
|
-
const current = signal(initialValue);
|
|
3849
|
-
const targetValue = signal(initialValue);
|
|
3850
|
-
let rafId = 0;
|
|
3851
|
-
let running = false;
|
|
3852
|
-
const read = (() => current());
|
|
3853
|
-
read.set = (value, overrides) => {
|
|
3854
|
-
const dur = overrides?.duration ?? duration;
|
|
3855
|
-
const ease = overrides?.easing ?? easing;
|
|
3856
|
-
const interp = overrides?.interpolate ?? interpolate;
|
|
3857
|
-
const del = overrides?.delay ?? delay;
|
|
3858
|
-
const from = current();
|
|
3859
|
-
targetValue.set(value);
|
|
3860
|
-
if (dur === 0) {
|
|
3861
|
-
current.set(value);
|
|
3862
|
-
return Promise.resolve();
|
|
3863
|
-
}
|
|
3864
|
-
if (running) {
|
|
3865
|
-
cancelAnimationFrame(rafId);
|
|
3866
|
-
running = false;
|
|
3867
|
-
}
|
|
3868
|
-
return new Promise((resolve) => {
|
|
3869
|
-
const start = performance.now() + del;
|
|
3870
|
-
running = true;
|
|
3871
|
-
function tick(now) {
|
|
3872
|
-
if (!running) {
|
|
3873
|
-
resolve();
|
|
3874
|
-
return;
|
|
3875
|
-
}
|
|
3876
|
-
const elapsed = now - start;
|
|
3877
|
-
if (elapsed < 0) {
|
|
3878
|
-
rafId = requestAnimationFrame(tick);
|
|
3879
|
-
return;
|
|
3880
|
-
}
|
|
3881
|
-
const t = Math.min(elapsed / dur, 1);
|
|
3882
|
-
const easedT = ease(t);
|
|
3883
|
-
current.set(interp(from, value, easedT));
|
|
3884
|
-
if (t < 1) {
|
|
3885
|
-
rafId = requestAnimationFrame(tick);
|
|
3886
|
-
} else {
|
|
3887
|
-
running = false;
|
|
3888
|
-
resolve();
|
|
3889
|
-
}
|
|
3890
|
-
}
|
|
3891
|
-
rafId = requestAnimationFrame(tick);
|
|
3892
|
-
});
|
|
3893
|
-
};
|
|
3894
|
-
read.setImmediate = (value) => {
|
|
3895
|
-
if (running) {
|
|
3896
|
-
cancelAnimationFrame(rafId);
|
|
3897
|
-
running = false;
|
|
3898
|
-
}
|
|
3899
|
-
current.set(value);
|
|
3900
|
-
targetValue.set(value);
|
|
3901
|
-
};
|
|
3902
|
-
read.target = () => targetValue();
|
|
3903
|
-
return read;
|
|
3904
|
-
}
|
|
3905
|
-
|
|
3906
|
-
// src/flip.ts
|
|
3907
|
-
function createFlip(container, options = {}) {
|
|
3908
|
-
const {
|
|
3909
|
-
duration = 300,
|
|
3910
|
-
easing = "cubic-bezier(0.2, 0, 0, 1)",
|
|
3911
|
-
delay = 0,
|
|
3912
|
-
selector,
|
|
3913
|
-
keyAttribute = "data-key",
|
|
3914
|
-
onComplete
|
|
3915
|
-
} = options;
|
|
3916
|
-
let firstPositions = /* @__PURE__ */ new Map();
|
|
3917
|
-
function getElements() {
|
|
3918
|
-
if (selector) {
|
|
3919
|
-
return Array.from(container.querySelectorAll(selector));
|
|
3920
|
-
}
|
|
3921
|
-
return Array.from(container.children);
|
|
3922
|
-
}
|
|
3923
|
-
function getKey(el) {
|
|
3924
|
-
return el.getAttribute(keyAttribute) ?? el.id ?? "";
|
|
3925
|
-
}
|
|
3926
|
-
function measure() {
|
|
3927
|
-
firstPositions = /* @__PURE__ */ new Map();
|
|
3928
|
-
for (const el of getElements()) {
|
|
3929
|
-
const key = getKey(el);
|
|
3930
|
-
if (key) {
|
|
3931
|
-
const rect = el.getBoundingClientRect();
|
|
3932
|
-
firstPositions.set(key, {
|
|
3933
|
-
left: rect.left,
|
|
3934
|
-
top: rect.top,
|
|
3935
|
-
width: rect.width,
|
|
3936
|
-
height: rect.height
|
|
3937
|
-
});
|
|
3938
|
-
}
|
|
3939
|
-
}
|
|
3940
|
-
}
|
|
3941
|
-
function animate2() {
|
|
3942
|
-
const elements = getElements();
|
|
3943
|
-
const animations = [];
|
|
3944
|
-
for (const el of elements) {
|
|
3945
|
-
const key = getKey(el);
|
|
3946
|
-
const first = firstPositions.get(key);
|
|
3947
|
-
if (!first) continue;
|
|
3948
|
-
const last = el.getBoundingClientRect();
|
|
3949
|
-
const dx = first.left - last.left;
|
|
3950
|
-
const dy = first.top - last.top;
|
|
3951
|
-
const dw = first.width / (last.width || 1);
|
|
3952
|
-
const dh = first.height / (last.height || 1);
|
|
3953
|
-
if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5 && Math.abs(dw - 1) < 0.01 && Math.abs(dh - 1) < 0.01) {
|
|
3954
|
-
continue;
|
|
3955
|
-
}
|
|
3956
|
-
const animation = el.animate(
|
|
3957
|
-
[
|
|
3958
|
-
{
|
|
3959
|
-
transform: `translate(${dx}px, ${dy}px) scale(${dw}, ${dh})`
|
|
3960
|
-
},
|
|
3961
|
-
{
|
|
3962
|
-
transform: "translate(0, 0) scale(1, 1)"
|
|
3963
|
-
}
|
|
3964
|
-
],
|
|
3965
|
-
{
|
|
3966
|
-
duration,
|
|
3967
|
-
easing,
|
|
3968
|
-
delay,
|
|
3969
|
-
fill: "both"
|
|
3970
|
-
}
|
|
3971
|
-
);
|
|
3972
|
-
animations.push(animation);
|
|
3973
|
-
}
|
|
3974
|
-
const currentKeys = new Set(elements.map(getKey));
|
|
3975
|
-
for (const [key, rect] of firstPositions) {
|
|
3976
|
-
if (!currentKeys.has(key)) ;
|
|
3977
|
-
}
|
|
3978
|
-
firstPositions.clear();
|
|
3979
|
-
return new Promise((resolve) => {
|
|
3980
|
-
if (animations.length === 0) {
|
|
3981
|
-
onComplete?.();
|
|
3982
|
-
resolve();
|
|
3983
|
-
return;
|
|
3984
|
-
}
|
|
3985
|
-
Promise.all(animations.map((a) => a.finished)).then(() => {
|
|
3986
|
-
for (const a of animations) {
|
|
3987
|
-
a.cancel();
|
|
3988
|
-
}
|
|
3989
|
-
onComplete?.();
|
|
3990
|
-
resolve();
|
|
3991
|
-
});
|
|
3992
|
-
});
|
|
3993
|
-
}
|
|
3994
|
-
return {
|
|
3995
|
-
measure,
|
|
3996
|
-
animate: animate2,
|
|
3997
|
-
async flip(update) {
|
|
3998
|
-
measure();
|
|
3999
|
-
update();
|
|
4000
|
-
await new Promise((r) => requestAnimationFrame(r));
|
|
4001
|
-
return animate2();
|
|
4002
|
-
}
|
|
4003
|
-
};
|
|
4004
|
-
}
|
|
4005
|
-
async function flip(container, update, options) {
|
|
4006
|
-
const ctrl = createFlip(container, options);
|
|
4007
|
-
return ctrl.flip(update);
|
|
4008
|
-
}
|
|
4009
|
-
|
|
4010
|
-
// src/await-block.ts
|
|
4011
|
-
var Await = defineComponent((ctx) => {
|
|
4012
|
-
const state = signal({ status: "pending" });
|
|
4013
|
-
let currentPromise = ctx.props.promise;
|
|
4014
|
-
ctx.props.promise.then((value) => {
|
|
4015
|
-
if (ctx.props.promise === currentPromise) {
|
|
4016
|
-
state.set({ status: "resolved", value });
|
|
4017
|
-
}
|
|
4018
|
-
}).catch((err) => {
|
|
4019
|
-
if (ctx.props.promise === currentPromise) {
|
|
4020
|
-
state.set({
|
|
4021
|
-
status: "rejected",
|
|
4022
|
-
error: err instanceof Error ? err : new Error(String(err))
|
|
4023
|
-
});
|
|
4024
|
-
}
|
|
4025
|
-
});
|
|
4026
|
-
return () => {
|
|
4027
|
-
const s = state();
|
|
4028
|
-
switch (s.status) {
|
|
4029
|
-
case "pending":
|
|
4030
|
-
return ctx.props.pending ? nodeToDOM(ctx.props.pending()) : document.createComment("await-pending");
|
|
4031
|
-
case "resolved":
|
|
4032
|
-
return nodeToDOM(ctx.props.then(s.value));
|
|
4033
|
-
case "rejected":
|
|
4034
|
-
return ctx.props.catch ? nodeToDOM(ctx.props.catch(s.error)) : document.createComment("await-error");
|
|
4035
|
-
}
|
|
4036
|
-
};
|
|
4037
|
-
});
|
|
4038
|
-
function awaitSignal(promise) {
|
|
4039
|
-
const state = signal({ status: "pending" });
|
|
4040
|
-
promise.then((value) => state.set({ status: "resolved", value })).catch((error) => state.set({
|
|
4041
|
-
status: "rejected",
|
|
4042
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
4043
|
-
}));
|
|
4044
|
-
return () => state();
|
|
4045
|
-
}
|
|
4046
|
-
|
|
4047
|
-
// src/event-modifiers.ts
|
|
4048
|
-
function withModifiers(handler, modifiers) {
|
|
4049
|
-
return (e) => {
|
|
4050
|
-
if (modifiers.self && e.target !== e.currentTarget) return;
|
|
4051
|
-
if (modifiers.preventDefault) e.preventDefault();
|
|
4052
|
-
if (modifiers.stopPropagation) e.stopPropagation();
|
|
4053
|
-
if (modifiers.stopImmediatePropagation) e.stopImmediatePropagation?.();
|
|
4054
|
-
handler(e);
|
|
4055
|
-
};
|
|
62
|
+
`;return i+=` animation-duration: ${t};
|
|
63
|
+
`,i+=` animation-timing-function: ${n};
|
|
64
|
+
`,i+=`}
|
|
65
|
+
`,r&&(i+=`::view-transition-old(root) {
|
|
66
|
+
animation-name: ${r};
|
|
4056
67
|
}
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
const listenerOptions = {
|
|
4060
|
-
once: modifiers.once,
|
|
4061
|
-
capture: modifiers.capture,
|
|
4062
|
-
passive: modifiers.passive
|
|
4063
|
-
};
|
|
4064
|
-
el.addEventListener(event, wrapped, listenerOptions);
|
|
4065
|
-
return () => el.removeEventListener(event, wrapped, listenerOptions);
|
|
68
|
+
`),o&&(i+=`::view-transition-new(root) {
|
|
69
|
+
animation-name: ${o};
|
|
4066
70
|
}
|
|
4067
|
-
function bindDimensions(el) {
|
|
4068
|
-
const width = signal(el.clientWidth);
|
|
4069
|
-
const height = signal(el.clientHeight);
|
|
4070
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
4071
|
-
const observer = new ResizeObserver((entries2) => {
|
|
4072
|
-
const entry = entries2[0];
|
|
4073
|
-
if (entry) {
|
|
4074
|
-
width.set(entry.contentRect.width);
|
|
4075
|
-
height.set(entry.contentRect.height);
|
|
4076
|
-
}
|
|
4077
|
-
});
|
|
4078
|
-
observer.observe(el);
|
|
4079
|
-
}
|
|
4080
|
-
return {
|
|
4081
|
-
width: () => width(),
|
|
4082
|
-
height: () => height()
|
|
4083
|
-
};
|
|
4084
|
-
}
|
|
4085
|
-
function bindScroll(el) {
|
|
4086
|
-
const target = el ?? (typeof window !== "undefined" ? window : null);
|
|
4087
|
-
const scrollX = signal(el ? el.scrollLeft : window?.scrollX ?? 0);
|
|
4088
|
-
const scrollY = signal(el ? el.scrollTop : window?.scrollY ?? 0);
|
|
4089
|
-
if (target) {
|
|
4090
|
-
const handler = () => {
|
|
4091
|
-
if (el) {
|
|
4092
|
-
scrollX.set(el.scrollLeft);
|
|
4093
|
-
scrollY.set(el.scrollTop);
|
|
4094
|
-
} else {
|
|
4095
|
-
scrollX.set(window.scrollX);
|
|
4096
|
-
scrollY.set(window.scrollY);
|
|
4097
|
-
}
|
|
4098
|
-
};
|
|
4099
|
-
target.addEventListener("scroll", handler, { passive: true });
|
|
4100
|
-
}
|
|
4101
|
-
const originalSetY = scrollY.set;
|
|
4102
|
-
scrollY.set = (value) => {
|
|
4103
|
-
originalSetY(value);
|
|
4104
|
-
if (el) el.scrollTop = value;
|
|
4105
|
-
else window?.scrollTo(window.scrollX, value);
|
|
4106
|
-
};
|
|
4107
|
-
const originalSetX = scrollX.set;
|
|
4108
|
-
scrollX.set = (value) => {
|
|
4109
|
-
originalSetX(value);
|
|
4110
|
-
if (el) el.scrollLeft = value;
|
|
4111
|
-
else window?.scrollTo(value, window.scrollY);
|
|
4112
|
-
};
|
|
4113
|
-
return { scrollX, scrollY };
|
|
4114
|
-
}
|
|
4115
|
-
function bindElement() {
|
|
4116
|
-
return signal(null);
|
|
4117
|
-
}
|
|
4118
|
-
function bindGroup(name) {
|
|
4119
|
-
return signal(null);
|
|
4120
|
-
}
|
|
4121
|
-
function bindGroupItem(el, group, value) {
|
|
4122
|
-
el.name = typeof value === "string" ? value : "";
|
|
4123
|
-
el.addEventListener("change", () => {
|
|
4124
|
-
if (el.checked) group.set(value);
|
|
4125
|
-
});
|
|
4126
|
-
effect(() => {
|
|
4127
|
-
el.checked = group() === value;
|
|
4128
|
-
});
|
|
4129
|
-
}
|
|
4130
|
-
function bindClass(el, className, condition) {
|
|
4131
|
-
return effect(() => {
|
|
4132
|
-
if (condition()) {
|
|
4133
|
-
el.classList.add(className);
|
|
4134
|
-
} else {
|
|
4135
|
-
el.classList.remove(className);
|
|
4136
|
-
}
|
|
4137
|
-
});
|
|
4138
|
-
}
|
|
4139
|
-
function bindClasses(el, classes) {
|
|
4140
|
-
const disposers = Object.entries(classes).map(
|
|
4141
|
-
([cls, condition]) => bindClass(el, cls, condition)
|
|
4142
|
-
);
|
|
4143
|
-
return () => disposers.forEach((d) => d());
|
|
4144
|
-
}
|
|
4145
|
-
function bindStyle(el, property, value) {
|
|
4146
|
-
const kebab = property.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
4147
|
-
return effect(() => {
|
|
4148
|
-
const v = value();
|
|
4149
|
-
if (v == null) {
|
|
4150
|
-
el.style.removeProperty(kebab);
|
|
4151
|
-
} else {
|
|
4152
|
-
el.style.setProperty(kebab, typeof v === "number" ? `${v}px` : String(v));
|
|
4153
|
-
}
|
|
4154
|
-
});
|
|
4155
|
-
}
|
|
4156
|
-
function bindStyles(el, styles) {
|
|
4157
|
-
const disposers = Object.entries(styles).map(
|
|
4158
|
-
([prop, valueFn]) => bindStyle(el, prop, valueFn)
|
|
4159
|
-
);
|
|
4160
|
-
return () => disposers.forEach((d) => d());
|
|
4161
|
-
}
|
|
4162
|
-
|
|
4163
|
-
// src/snippets.ts
|
|
4164
|
-
function defineSnippet(render) {
|
|
4165
|
-
return render;
|
|
4166
|
-
}
|
|
4167
|
-
function inspect(...args) {
|
|
4168
|
-
let options = {};
|
|
4169
|
-
const sources = [];
|
|
4170
|
-
for (const arg of args) {
|
|
4171
|
-
if (typeof arg === "function") {
|
|
4172
|
-
sources.push(arg);
|
|
4173
|
-
} else if (typeof arg === "object" && arg !== null) {
|
|
4174
|
-
options = arg;
|
|
4175
|
-
}
|
|
4176
|
-
}
|
|
4177
|
-
const {
|
|
4178
|
-
label = "inspect",
|
|
4179
|
-
level = "log",
|
|
4180
|
-
logger,
|
|
4181
|
-
when
|
|
4182
|
-
} = options;
|
|
4183
|
-
return effect(() => {
|
|
4184
|
-
if (when && !when()) return;
|
|
4185
|
-
const values = sources.map((s) => s());
|
|
4186
|
-
if (logger) {
|
|
4187
|
-
logger(label, ...values);
|
|
4188
|
-
} else {
|
|
4189
|
-
console[level](`[${label}]`, ...values);
|
|
4190
|
-
}
|
|
4191
|
-
});
|
|
4192
|
-
}
|
|
4193
|
-
function defineFormAction(url, options = {}) {
|
|
4194
|
-
const {
|
|
4195
|
-
method = "POST",
|
|
4196
|
-
headers = {},
|
|
4197
|
-
onSuccess,
|
|
4198
|
-
onError: onError2,
|
|
4199
|
-
fetch: customFetch = globalThis.fetch.bind(globalThis)
|
|
4200
|
-
} = options;
|
|
4201
|
-
const submitting = signal(false);
|
|
4202
|
-
const result = signal(null);
|
|
4203
|
-
const error = signal(null);
|
|
4204
|
-
async function submit(data) {
|
|
4205
|
-
submitting.set(true);
|
|
4206
|
-
error.set(null);
|
|
4207
|
-
try {
|
|
4208
|
-
const response = await customFetch(url, {
|
|
4209
|
-
method,
|
|
4210
|
-
headers: { "Content-Type": "application/json", ...headers },
|
|
4211
|
-
body: JSON.stringify(data)
|
|
4212
|
-
});
|
|
4213
|
-
if (!response.ok) {
|
|
4214
|
-
throw new Error(`Form action failed: ${response.status}`);
|
|
4215
|
-
}
|
|
4216
|
-
const res = await response.json();
|
|
4217
|
-
result.set(res);
|
|
4218
|
-
submitting.set(false);
|
|
4219
|
-
onSuccess?.(res);
|
|
4220
|
-
return res;
|
|
4221
|
-
} catch (err) {
|
|
4222
|
-
const e = err instanceof Error ? err : new Error(String(err));
|
|
4223
|
-
error.set(e);
|
|
4224
|
-
submitting.set(false);
|
|
4225
|
-
onError2?.(e);
|
|
4226
|
-
throw e;
|
|
4227
|
-
}
|
|
4228
|
-
}
|
|
4229
|
-
return {
|
|
4230
|
-
url,
|
|
4231
|
-
method,
|
|
4232
|
-
submitting: () => submitting(),
|
|
4233
|
-
result: () => result(),
|
|
4234
|
-
error: () => error(),
|
|
4235
|
-
handle(extraData) {
|
|
4236
|
-
return (e) => {
|
|
4237
|
-
e.preventDefault();
|
|
4238
|
-
const form = e.target;
|
|
4239
|
-
const formData = new FormData(form);
|
|
4240
|
-
const data = { ...extraData };
|
|
4241
|
-
formData.forEach((value, key) => {
|
|
4242
|
-
data[key] = value;
|
|
4243
|
-
});
|
|
4244
|
-
submit(data);
|
|
4245
|
-
};
|
|
4246
|
-
},
|
|
4247
|
-
submit
|
|
4248
|
-
};
|
|
4249
|
-
}
|
|
4250
|
-
function enableSnapshots(config = {}) {
|
|
4251
|
-
if (typeof window === "undefined") return () => {
|
|
4252
|
-
};
|
|
4253
|
-
const { keyPrefix = "akash-snapshot", capture = ["scroll", "forms"] } = config;
|
|
4254
|
-
function captureSnapshot() {
|
|
4255
|
-
const snapshot = {
|
|
4256
|
-
scrollX: window.scrollX,
|
|
4257
|
-
scrollY: window.scrollY,
|
|
4258
|
-
forms: {},
|
|
4259
|
-
timestamp: Date.now()
|
|
4260
|
-
};
|
|
4261
|
-
if (capture.includes("forms")) {
|
|
4262
|
-
document.querySelectorAll("form[id]").forEach((form) => {
|
|
4263
|
-
const formEl = form;
|
|
4264
|
-
const data = {};
|
|
4265
|
-
new FormData(formEl).forEach((value, key) => {
|
|
4266
|
-
data[key] = String(value);
|
|
4267
|
-
});
|
|
4268
|
-
snapshot.forms[formEl.id] = data;
|
|
4269
|
-
});
|
|
4270
|
-
}
|
|
4271
|
-
return snapshot;
|
|
4272
|
-
}
|
|
4273
|
-
function restoreSnapshot(snapshot) {
|
|
4274
|
-
if (capture.includes("scroll")) {
|
|
4275
|
-
requestAnimationFrame(() => {
|
|
4276
|
-
window.scrollTo(snapshot.scrollX, snapshot.scrollY);
|
|
4277
|
-
});
|
|
4278
|
-
}
|
|
4279
|
-
if (capture.includes("forms")) {
|
|
4280
|
-
for (const [formId, data] of Object.entries(snapshot.forms)) {
|
|
4281
|
-
const form = document.getElementById(formId);
|
|
4282
|
-
if (!form) continue;
|
|
4283
|
-
for (const [key, value] of Object.entries(data)) {
|
|
4284
|
-
const input = form.elements.namedItem(key);
|
|
4285
|
-
if (input) input.value = value;
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4288
|
-
}
|
|
4289
|
-
}
|
|
4290
|
-
const saveKey = () => `${keyPrefix}-${window.location.pathname}`;
|
|
4291
|
-
function save() {
|
|
4292
|
-
try {
|
|
4293
|
-
const snapshot = captureSnapshot();
|
|
4294
|
-
sessionStorage.setItem(saveKey(), JSON.stringify(snapshot));
|
|
4295
|
-
} catch {
|
|
4296
|
-
}
|
|
4297
|
-
}
|
|
4298
|
-
function restore() {
|
|
4299
|
-
try {
|
|
4300
|
-
const raw = sessionStorage.getItem(saveKey());
|
|
4301
|
-
if (raw) {
|
|
4302
|
-
const snapshot = JSON.parse(raw);
|
|
4303
|
-
if (Date.now() - snapshot.timestamp < 30 * 60 * 1e3) {
|
|
4304
|
-
restoreSnapshot(snapshot);
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
|
-
} catch {
|
|
4308
|
-
}
|
|
4309
|
-
}
|
|
4310
|
-
window.addEventListener("beforeunload", save);
|
|
4311
|
-
window.addEventListener("popstate", () => {
|
|
4312
|
-
requestAnimationFrame(restore);
|
|
4313
|
-
});
|
|
4314
|
-
if (performance.getEntriesByType("navigation")[0]?.type === "back_forward") {
|
|
4315
|
-
requestAnimationFrame(restore);
|
|
4316
|
-
}
|
|
4317
|
-
return () => {
|
|
4318
|
-
window.removeEventListener("beforeunload", save);
|
|
4319
|
-
};
|
|
4320
|
-
}
|
|
4321
|
-
|
|
4322
|
-
// src/watch.ts
|
|
4323
|
-
function watch(source, callback, options = {}) {
|
|
4324
|
-
const { immediate = false, once = false, debounce: debounceMs, deep = false } = options;
|
|
4325
|
-
const isMulti = Array.isArray(source);
|
|
4326
|
-
const sources = isMulti ? source : [source];
|
|
4327
|
-
let oldValues = sources.map(() => void 0);
|
|
4328
|
-
let isFirst = true;
|
|
4329
|
-
let debounceTimer = null;
|
|
4330
|
-
let disposed = false;
|
|
4331
|
-
let disposeEffect = null;
|
|
4332
|
-
const dispose = () => {
|
|
4333
|
-
disposed = true;
|
|
4334
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
4335
|
-
disposeEffect?.();
|
|
4336
|
-
};
|
|
4337
|
-
disposeEffect = effect(() => {
|
|
4338
|
-
const newValues = sources.map((s) => s());
|
|
4339
|
-
if (isFirst) {
|
|
4340
|
-
isFirst = false;
|
|
4341
|
-
oldValues = deep ? newValues.map(deepClone) : [...newValues];
|
|
4342
|
-
if (immediate) {
|
|
4343
|
-
fireCallback(newValues, sources.map(() => void 0));
|
|
4344
|
-
}
|
|
4345
|
-
return;
|
|
4346
|
-
}
|
|
4347
|
-
const changed = deep ? newValues.some((v, i) => !deepEqual(v, oldValues[i])) : newValues.some((v, i) => !Object.is(v, oldValues[i]));
|
|
4348
|
-
if (!changed) return;
|
|
4349
|
-
const prevValues = [...oldValues];
|
|
4350
|
-
oldValues = deep ? newValues.map(deepClone) : [...newValues];
|
|
4351
|
-
fireCallback(newValues, prevValues);
|
|
4352
|
-
});
|
|
4353
|
-
function fireCallback(newVals, oldVals) {
|
|
4354
|
-
if (disposed) return;
|
|
4355
|
-
const doCall = () => {
|
|
4356
|
-
if (isMulti) {
|
|
4357
|
-
callback(newVals, oldVals);
|
|
4358
|
-
} else {
|
|
4359
|
-
callback(newVals[0], oldVals[0]);
|
|
4360
|
-
}
|
|
4361
|
-
if (once) {
|
|
4362
|
-
disposed = true;
|
|
4363
|
-
dispose();
|
|
4364
|
-
}
|
|
4365
|
-
};
|
|
4366
|
-
if (debounceMs && debounceMs > 0) {
|
|
4367
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
4368
|
-
debounceTimer = setTimeout(doCall, debounceMs);
|
|
4369
|
-
} else {
|
|
4370
|
-
doCall();
|
|
4371
|
-
}
|
|
4372
|
-
}
|
|
4373
|
-
return dispose;
|
|
4374
|
-
}
|
|
4375
|
-
function watchOnce(source, callback) {
|
|
4376
|
-
return watch(source, callback, { once: true, immediate: true });
|
|
4377
|
-
}
|
|
4378
|
-
function watchDebounced(source, callback, ms) {
|
|
4379
|
-
return watch(source, callback, { debounce: ms });
|
|
4380
|
-
}
|
|
4381
|
-
function deepClone(value) {
|
|
4382
|
-
if (value === null || typeof value !== "object") return value;
|
|
4383
|
-
try {
|
|
4384
|
-
return JSON.parse(JSON.stringify(value));
|
|
4385
|
-
} catch {
|
|
4386
|
-
return value;
|
|
4387
|
-
}
|
|
4388
|
-
}
|
|
4389
|
-
function deepEqual(a, b) {
|
|
4390
|
-
if (Object.is(a, b)) return true;
|
|
4391
|
-
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
4392
|
-
try {
|
|
4393
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
4394
|
-
} catch {
|
|
4395
|
-
return false;
|
|
4396
|
-
}
|
|
4397
|
-
}
|
|
4398
|
-
|
|
4399
|
-
// src/deep-signal.ts
|
|
4400
|
-
var SIGNAL_KEY = /* @__PURE__ */ Symbol("deepSignal");
|
|
4401
|
-
var RAW_KEY = /* @__PURE__ */ Symbol("deepRaw");
|
|
4402
|
-
function deepSignal(initialValue) {
|
|
4403
|
-
const version = signal(0);
|
|
4404
|
-
const raw = JSON.parse(JSON.stringify(initialValue));
|
|
4405
|
-
function notify() {
|
|
4406
|
-
version.update((v) => v + 1);
|
|
4407
|
-
}
|
|
4408
|
-
function createProxy(target, path = []) {
|
|
4409
|
-
return new Proxy(target, {
|
|
4410
|
-
get(obj, prop, receiver) {
|
|
4411
|
-
if (prop === "$raw") return JSON.parse(JSON.stringify(raw));
|
|
4412
|
-
if (prop === "$signal") return () => {
|
|
4413
|
-
version();
|
|
4414
|
-
return JSON.parse(JSON.stringify(raw));
|
|
4415
|
-
};
|
|
4416
|
-
if (prop === SIGNAL_KEY) return version;
|
|
4417
|
-
if (prop === RAW_KEY) return raw;
|
|
4418
|
-
const value = Reflect.get(obj, prop, receiver);
|
|
4419
|
-
version();
|
|
4420
|
-
if (value !== null && typeof value === "object") {
|
|
4421
|
-
return createProxy(value, [...path, String(prop)]);
|
|
4422
|
-
}
|
|
4423
|
-
return value;
|
|
4424
|
-
},
|
|
4425
|
-
set(obj, prop, value) {
|
|
4426
|
-
const result = Reflect.set(obj, prop, value);
|
|
4427
|
-
notify();
|
|
4428
|
-
return result;
|
|
4429
|
-
},
|
|
4430
|
-
deleteProperty(obj, prop) {
|
|
4431
|
-
const result = Reflect.deleteProperty(obj, prop);
|
|
4432
|
-
notify();
|
|
4433
|
-
return result;
|
|
4434
|
-
}
|
|
4435
|
-
});
|
|
4436
|
-
}
|
|
4437
|
-
if (Array.isArray(raw)) {
|
|
4438
|
-
const arrayProxy = createProxy(raw);
|
|
4439
|
-
return arrayProxy;
|
|
4440
|
-
}
|
|
4441
|
-
return createProxy(raw);
|
|
4442
|
-
}
|
|
4443
|
-
function toRaw(proxy) {
|
|
4444
|
-
return proxy.$raw ?? proxy;
|
|
4445
|
-
}
|
|
4446
|
-
function isDeepSignal(value) {
|
|
4447
|
-
if (value === null || typeof value !== "object") return false;
|
|
4448
|
-
try {
|
|
4449
|
-
return value[SIGNAL_KEY] !== void 0;
|
|
4450
|
-
} catch {
|
|
4451
|
-
return false;
|
|
4452
|
-
}
|
|
4453
|
-
}
|
|
4454
|
-
|
|
4455
|
-
// src/machine.ts
|
|
4456
|
-
function createMachine(config) {
|
|
4457
|
-
const currentState = signal(config.initial);
|
|
4458
|
-
const contextData = signal(config.context ?? {});
|
|
4459
|
-
const stateHistory = signal([config.initial]);
|
|
4460
|
-
const done = computed(() => {
|
|
4461
|
-
const stateCfg = config.states[currentState()];
|
|
4462
|
-
return stateCfg?.type === "final";
|
|
4463
|
-
});
|
|
4464
|
-
const nextEvents = computed(() => {
|
|
4465
|
-
const stateCfg = config.states[currentState()];
|
|
4466
|
-
if (!stateCfg?.on) return [];
|
|
4467
|
-
return Object.keys(stateCfg.on);
|
|
4468
|
-
});
|
|
4469
|
-
const initialStateCfg = config.states[config.initial];
|
|
4470
|
-
if (initialStateCfg?.entry) {
|
|
4471
|
-
initialStateCfg.entry({ data: contextData(), event: "" });
|
|
4472
|
-
}
|
|
4473
|
-
function send(event) {
|
|
4474
|
-
if (done()) return;
|
|
4475
|
-
const state = currentState();
|
|
4476
|
-
const stateCfg = config.states[state];
|
|
4477
|
-
if (!stateCfg?.on) return;
|
|
4478
|
-
const transition = stateCfg.on[event];
|
|
4479
|
-
if (!transition) return;
|
|
4480
|
-
let target;
|
|
4481
|
-
let guard;
|
|
4482
|
-
let action;
|
|
4483
|
-
if (typeof transition === "string") {
|
|
4484
|
-
target = transition;
|
|
4485
|
-
} else {
|
|
4486
|
-
const t = transition;
|
|
4487
|
-
target = t.target;
|
|
4488
|
-
guard = t.guard;
|
|
4489
|
-
action = t.action;
|
|
4490
|
-
}
|
|
4491
|
-
const ctx = {
|
|
4492
|
-
data: contextData(),
|
|
4493
|
-
event
|
|
4494
|
-
};
|
|
4495
|
-
if (guard && !guard(ctx)) return;
|
|
4496
|
-
if (stateCfg.exit) {
|
|
4497
|
-
stateCfg.exit(ctx);
|
|
4498
|
-
}
|
|
4499
|
-
if (action) {
|
|
4500
|
-
action(ctx);
|
|
4501
|
-
}
|
|
4502
|
-
contextData.set(ctx.data);
|
|
4503
|
-
currentState.set(target);
|
|
4504
|
-
stateHistory.update((h) => [...h, target]);
|
|
4505
|
-
const targetCfg = config.states[target];
|
|
4506
|
-
if (targetCfg?.entry) {
|
|
4507
|
-
targetCfg.entry({ data: contextData(), event });
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4510
|
-
function can(event) {
|
|
4511
|
-
const stateCfg = config.states[currentState()];
|
|
4512
|
-
if (!stateCfg?.on) return false;
|
|
4513
|
-
const transition = stateCfg.on[event];
|
|
4514
|
-
if (!transition) return false;
|
|
4515
|
-
if (typeof transition !== "string") {
|
|
4516
|
-
const t = transition;
|
|
4517
|
-
if (t.guard) {
|
|
4518
|
-
return t.guard({ data: contextData(), event });
|
|
4519
|
-
}
|
|
4520
|
-
}
|
|
4521
|
-
return true;
|
|
4522
|
-
}
|
|
4523
|
-
return {
|
|
4524
|
-
state: () => currentState(),
|
|
4525
|
-
context: () => contextData(),
|
|
4526
|
-
send,
|
|
4527
|
-
matches: (state) => currentState() === state,
|
|
4528
|
-
done,
|
|
4529
|
-
reset() {
|
|
4530
|
-
currentState.set(config.initial);
|
|
4531
|
-
contextData.set(config.context ?? {});
|
|
4532
|
-
stateHistory.set([config.initial]);
|
|
4533
|
-
},
|
|
4534
|
-
history: () => stateHistory(),
|
|
4535
|
-
can,
|
|
4536
|
-
nextEvents
|
|
4537
|
-
};
|
|
4538
|
-
}
|
|
4539
|
-
|
|
4540
|
-
// src/event-bus.ts
|
|
4541
|
-
function createEventBus() {
|
|
4542
|
-
const listeners = /* @__PURE__ */ new Map();
|
|
4543
|
-
function getSet(event) {
|
|
4544
|
-
let set = listeners.get(event);
|
|
4545
|
-
if (!set) {
|
|
4546
|
-
set = /* @__PURE__ */ new Set();
|
|
4547
|
-
listeners.set(event, set);
|
|
4548
|
-
}
|
|
4549
|
-
return set;
|
|
4550
|
-
}
|
|
4551
|
-
return {
|
|
4552
|
-
on(event, handler) {
|
|
4553
|
-
getSet(event).add(handler);
|
|
4554
|
-
return () => getSet(event).delete(handler);
|
|
4555
|
-
},
|
|
4556
|
-
once(event, handler) {
|
|
4557
|
-
const wrapper = (data) => {
|
|
4558
|
-
getSet(event).delete(wrapper);
|
|
4559
|
-
handler(data);
|
|
4560
|
-
};
|
|
4561
|
-
getSet(event).add(wrapper);
|
|
4562
|
-
return () => getSet(event).delete(wrapper);
|
|
4563
|
-
},
|
|
4564
|
-
emit(event, data) {
|
|
4565
|
-
const set = listeners.get(event);
|
|
4566
|
-
if (set) {
|
|
4567
|
-
for (const handler of set) {
|
|
4568
|
-
handler(data);
|
|
4569
|
-
}
|
|
4570
|
-
}
|
|
4571
|
-
},
|
|
4572
|
-
off(event, handler) {
|
|
4573
|
-
getSet(event).delete(handler);
|
|
4574
|
-
},
|
|
4575
|
-
clear(event) {
|
|
4576
|
-
if (event) {
|
|
4577
|
-
listeners.delete(event);
|
|
4578
|
-
} else {
|
|
4579
|
-
listeners.clear();
|
|
4580
|
-
}
|
|
4581
|
-
},
|
|
4582
|
-
listenerCount(event) {
|
|
4583
|
-
return listeners.get(event)?.size ?? 0;
|
|
4584
|
-
},
|
|
4585
|
-
hasListeners(event) {
|
|
4586
|
-
return (listeners.get(event)?.size ?? 0) > 0;
|
|
4587
|
-
}
|
|
4588
|
-
};
|
|
4589
|
-
}
|
|
4590
|
-
var globalBus = null;
|
|
4591
|
-
function globalEventBus() {
|
|
4592
|
-
if (!globalBus) {
|
|
4593
|
-
globalBus = createEventBus();
|
|
4594
|
-
}
|
|
4595
|
-
return globalBus;
|
|
4596
|
-
}
|
|
4597
|
-
|
|
4598
|
-
export { Await, ErrorBoundary, HYDRATE_ATTR, Image, LWWRegister, Portal, Suspense, Switch, Transition, VirtualFor, animate, animateGroup, animateSequence, animateSpring, animateStagger, applyDirective, applyStyles, assignTransitionName, awaitSignal, bindClass, bindClasses, bindDimensions, bindElement, bindGroup, bindGroupItem, bindScroll, bindStyle, bindStyles, calculateRange, capitalize, chain, checkForLeaks, claimElement, claimText, clearProviders, clearQueryState, clearStores, collectSSRHead, countOps, createApp, createDataTable, createEventBus, createFlip, createInjector, createLocalTransport, createMachine, createOfflineStore, createSlots, createSync, createTimer, createToaster, createWebSocketTransport, css, currency, cx, date, deepSignal, defer, defineAsyncComponent, defineCustomElement, defineDirective, defineFormAction, definePipe, definePlugin, defineProvider, defineSnippet, defineStates, defineStore, directiveFromFn, disableLeakDetection, discoverStaticRoutes, easings, enableLeakDetection, enableSnapshots, enterTransition, escapeHtml, exitTransition, findHydrationBoundaries, flip, formatProfile, generatePaths, generateSWScript, generateSitemap, generateTransitionCSS, getActiveEffects, getLeakDetectionStats, getProfileSummary, getQueryParams, getSuspenseContext, getTransitionClasses, globalEventBus, hasSlot, hydrate, injectProvider, inspect, isDeepSignal, isHydrationActive, isLeakDetectionEnabled, isProfiling, isServerRendering, json, keyframes, longestIncreasingSubsequence, lowercase, match, measureAsync, measureSync, nodeToHtml, number, onEvent, percent, pipe, plural, prerender, progressiveHydrate, reconcileKeys, recordPerfEntry, registerPending, registerServiceWorker, relativeTime, removeDirectives, removeQueryState, renderHeadToString, renderNodes, renderSlot, renderSwitch, renderToStream, renderToString, renderToStringSync, reportLeaks, resetQueryState, sitemapFromResults, ssrElement, ssrRaw, ssrText, startProfiling, startViewTransition, stopProfiling, subscribePush, supportsViewTransitions, titleCase, toCustomElement, toRaw, trackEffect, trim, truncate, tweened, untrackEffect, updateDirective, uppercase, urlToFilePath, useAnnounce, useBreakpoint, useClickOutside, useClipboard, useCounter, useDebounce, useFocusTrap, useGeolocation, useHead, useInfiniteScroll, useInterval, useKeyboard, useMediaQuery, useOnline, useOpenGraph, usePrevious, useQueryState, useQueryStates, useSEO, useStorage, useStructuredData, useTheme, useThrottle, useTimeout, useToggle, useTwitterCard, useVirtualList, useWindowSize, vAutoFocus, vClickOutside, vIntersect, vLongPress, vResize, viewTransitionCSS, watch, watchDebounced, watchOnce, withModifiers };
|
|
4599
|
-
//# sourceMappingURL=index.js.map
|
|
71
|
+
`),i}function Jr(e,t){e.style.viewTransitionName=t;}function Yr(e,t){let n=document.documentElement,r=new Promise(async o=>{n.style.transition="opacity 0.15s ease",n.style.opacity="0",await new Promise(i=>setTimeout(i,150)),await e(),n.style.opacity="1",await new Promise(i=>setTimeout(i,150)),n.style.transition="",n.style.opacity="",t.onAfter?.(),o();});return {finished:r,updateCallbackDone:r,ready:Promise.resolve(),skipTransition:()=>{n.style.transition="",n.style.opacity="";}}}function Xr(e){return Array.isArray(e)?e.join(","):typeof e=="boolean"?e?"true":"false":String(e)}function Zr(e,t){return typeof t=="number"?Number(e):typeof t=="boolean"?e==="true"||e==="1":Array.isArray(t)?e?e.split(","):[]:e}function z(){return typeof window>"u"?new URLSearchParams:new URLSearchParams(window.location.search)}function eo(e,t){if(typeof window>"u")return;let n=e.toString(),r=n?`${window.location.pathname}?${n}${window.location.hash}`:`${window.location.pathname}${window.location.hash}`;t==="push"?window.history.pushState(null,"",r):window.history.replaceState(null,"",r);}var $=new Map,Ce=false;function to(){Ce||typeof window>"u"||(Ce=true,window.addEventListener("popstate",()=>{let e=z();a(()=>{for(let[t,n]of $){let r=e.get(t),o=r!==null?n.deserialize(r):n.defaultValue;n.signal.set(o);}});}));}function Ae(e,t,n={}){let{serialize:r=m=>Xr(m),deserialize:o=m=>Zr(m,t),history:i="replace",debounce:s=0,removeDefault:a=true}=n,u=z().get(e),d=u!==null?o(u):t,c$1=c(d);$.set(e,{signal:c$1,deserialize:o,defaultValue:t}),to();let f=null,p=false,T=c$1.set;c$1.set=m=>{if(T(m),p);let y=()=>{let b=z();a&&m===t?b.delete(e):b.set(e,r(m)),eo(b,i);};s>0?(f&&clearTimeout(f),f=setTimeout(y,s)):y();};c$1.update;return c$1.update=m=>{c$1.set(m(c$1()));},c$1}function no(e,t){let n={};for(let[r,o]of Object.entries(e))n[r]=Ae(r,o.default,{serialize:o.serialize,deserialize:o.deserialize,history:t?.history});return n}function ro(){if(typeof window>"u")return;let e=`${window.location.pathname}${window.location.hash}`;window.history.replaceState(null,"",e),a(()=>{for(let[,t]of $)t.signal.set(t.defaultValue);});}function oo(){let e=z(),t={};return e.forEach((n,r)=>{t[r]=n;}),t}function io(e){$.delete(e);}function so(){$.clear();}var Re={linear:e=>e,cubicIn:e=>e*e*e,cubicOut:e=>1-Math.pow(1-e,3),cubicInOut:e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,quadIn:e=>e*e,quadOut:e=>1-(1-e)*(1-e),quintOut:e=>1-Math.pow(1-e,5),bounceOut:e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,elasticOut:e=>e===0||e===1?e:Math.pow(2,-10*e)*Math.sin((e-.1)*5*Math.PI)+1};function ao(e,t,n){return typeof e=="number"&&typeof t=="number"?e+(t-e)*n:n<.5?e:t}function lo(e,t={}){let{duration:n=400,easing:r=Re.cubicOut,interpolate:o=ao,delay:i=0}=t,s=c(e),a=c(e),l=0,u=false,d=(()=>s());return d.set=(c,f)=>{let p=f?.duration??n,T=f?.easing??r,h=f?.interpolate??o,m=f?.delay??i,y=s();return a.set(c),p===0?(s.set(c),Promise.resolve()):(u&&(cancelAnimationFrame(l),u=false),new Promise(b=>{let k=performance.now()+m;u=true;function v(x){if(!u){b();return}let P=x-k;if(P<0){l=requestAnimationFrame(v);return}let A=Math.min(P/p,1),R=T(A);s.set(h(y,c,R)),A<1?l=requestAnimationFrame(v):(u=false,b());}l=requestAnimationFrame(v);}))},d.setImmediate=c=>{u&&(cancelAnimationFrame(l),u=false),s.set(c),a.set(c);},d.target=()=>a(),d}function Le(e,t={}){let{duration:n=300,easing:r="cubic-bezier(0.2, 0, 0, 1)",delay:o=0,selector:i,keyAttribute:s="data-key",onComplete:a}=t,l=new Map;function u(){return Array.from(i?e.querySelectorAll(i):e.children)}function d(p){return p.getAttribute(s)??p.id??""}function c(){l=new Map;for(let p of u()){let T=d(p);if(T){let h=p.getBoundingClientRect();l.set(T,{left:h.left,top:h.top,width:h.width,height:h.height});}}}function f(){let p=u(),T=[];for(let m of p){let y=d(m),b=l.get(y);if(!b)continue;let k=m.getBoundingClientRect(),v=b.left-k.left,x=b.top-k.top,P=b.width/(k.width||1),A=b.height/(k.height||1);if(Math.abs(v)<.5&&Math.abs(x)<.5&&Math.abs(P-1)<.01&&Math.abs(A-1)<.01)continue;let R=m.animate([{transform:`translate(${v}px, ${x}px) scale(${P}, ${A})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:n,easing:r,delay:o,fill:"both"});T.push(R);}let h=new Set(p.map(d));for(let[m,y]of l)h.has(m);return l.clear(),new Promise(m=>{if(T.length===0){a?.(),m();return}Promise.all(T.map(y=>y.finished)).then(()=>{for(let y of T)y.cancel();a?.(),m();});})}return {measure:c,animate:f,async flip(p){return c(),p(),await new Promise(T=>requestAnimationFrame(T)),f()}}}async function co(e,t,n){return Le(e,n).flip(t)}var uo=y(e=>{let t=c({status:"pending"}),n=e.props.promise;return e.props.promise.then(r=>{e.props.promise===n&&t.set({status:"resolved",value:r});}).catch(r=>{e.props.promise===n&&t.set({status:"rejected",error:r instanceof Error?r:new Error(String(r))});}),()=>{let r=t();switch(r.status){case "pending":return e.props.pending?s(e.props.pending()):document.createComment("await-pending");case "resolved":return s(e.props.then(r.value));case "rejected":return e.props.catch?s(e.props.catch(r.error)):document.createComment("await-error")}}});function po(e){let t=c({status:"pending"});return e.then(n=>t.set({status:"resolved",value:n})).catch(n=>t.set({status:"rejected",error:n instanceof Error?n:new Error(String(n))})),()=>t()}function Oe(e,t){return n=>{t.self&&n.target!==n.currentTarget||(t.preventDefault&&n.preventDefault(),t.stopPropagation&&n.stopPropagation(),t.stopImmediatePropagation&&n.stopImmediatePropagation?.(),e(n));}}function fo(e,t,n,r={}){let o=Oe(n,r),i={once:r.once,capture:r.capture,passive:r.passive};return e.addEventListener(t,o,i),()=>e.removeEventListener(t,o,i)}function mo(e){let t=c(e.clientWidth),n=c(e.clientHeight);return typeof ResizeObserver<"u"&&new ResizeObserver(o=>{let i=o[0];i&&(t.set(i.contentRect.width),n.set(i.contentRect.height));}).observe(e),{width:()=>t(),height:()=>n()}}function go(e){let t=e??(typeof window<"u"?window:null),n=c(e?e.scrollLeft:window?.scrollX??0),r=c(e?e.scrollTop:window?.scrollY??0);if(t){let s=()=>{e?(n.set(e.scrollLeft),r.set(e.scrollTop)):(n.set(window.scrollX),r.set(window.scrollY));};t.addEventListener("scroll",s,{passive:true});}let o=r.set;r.set=s=>{o(s),e?e.scrollTop=s:window?.scrollTo(window.scrollX,s);};let i=n.set;return n.set=s=>{i(s),e?e.scrollLeft=s:window?.scrollTo(s,window.scrollY);},{scrollX:n,scrollY:r}}function yo(){return c(null)}function ho(e){return c(null)}function To(e$1,t,n){e$1.name=typeof n=="string"?n:"",e$1.addEventListener("change",()=>{e$1.checked&&t.set(n);}),e(()=>{e$1.checked=t()===n;});}function De(e$1,t,n){return e(()=>{n()?e$1.classList.add(t):e$1.classList.remove(t);})}function vo(e,t){let n=Object.entries(t).map(([r,o])=>De(e,r,o));return ()=>n.forEach(r=>r())}function Me(e$1,t,n){let r=t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`);return e(()=>{let o=n();o==null?e$1.style.removeProperty(r):e$1.style.setProperty(r,typeof o=="number"?`${o}px`:String(o));})}function bo(e,t){let n=Object.entries(t).map(([r,o])=>Me(e,r,o));return ()=>n.forEach(r=>r())}function wo(e){return e}function xo(...e$1){let t={},n=[];for(let a of e$1)typeof a=="function"?n.push(a):typeof a=="object"&&a!==null&&(t=a);let{label:r="inspect",level:o="log",logger:i,when:s}=t;return e(()=>{if(s&&!s())return;let a=n.map(l=>l());i?i(r,...a):console[o](`[${r}]`,...a);})}function So(e,t={}){let{method:n="POST",headers:r={},onSuccess:o,onError:i,fetch:s=globalThis.fetch.bind(globalThis)}=t,a=c(false),l=c(null),u=c(null);async function d(c){a.set(true),u.set(null);try{let f=await s(e,{method:n,headers:{"Content-Type":"application/json",...r},body:JSON.stringify(c)});if(!f.ok)throw new Error(`Form action failed: ${f.status}`);let p=await f.json();return l.set(p),a.set(!1),o?.(p),p}catch(f){let p=f instanceof Error?f:new Error(String(f));throw u.set(p),a.set(false),i?.(p),p}}return {url:e,method:n,submitting:()=>a(),result:()=>l(),error:()=>u(),handle(c){return f=>{f.preventDefault();let p=f.target,T=new FormData(p),h={...c};T.forEach((m,y)=>{h[y]=m;}),d(h);}},submit:d}}function Eo(e={}){if(typeof window>"u")return ()=>{};let{keyPrefix:t="akash-snapshot",capture:n=["scroll","forms"]}=e;function r(){let l={scrollX:window.scrollX,scrollY:window.scrollY,forms:{},timestamp:Date.now()};return n.includes("forms")&&document.querySelectorAll("form[id]").forEach(u=>{let d=u,c={};new FormData(d).forEach((f,p)=>{c[p]=String(f);}),l.forms[d.id]=c;}),l}function o(l){if(n.includes("scroll")&&requestAnimationFrame(()=>{window.scrollTo(l.scrollX,l.scrollY);}),n.includes("forms"))for(let[u,d]of Object.entries(l.forms)){let c=document.getElementById(u);if(c)for(let[f,p]of Object.entries(d)){let T=c.elements.namedItem(f);T&&(T.value=p);}}}let i=()=>`${t}-${window.location.pathname}`;function s(){try{let l=r();sessionStorage.setItem(i(),JSON.stringify(l));}catch{}}function a(){try{let l=sessionStorage.getItem(i());if(l){let u=JSON.parse(l);Date.now()-u.timestamp<1800*1e3&&o(u);}}catch{}}return window.addEventListener("beforeunload",s),window.addEventListener("popstate",()=>{requestAnimationFrame(a);}),performance.getEntriesByType("navigation")[0]?.type==="back_forward"&&requestAnimationFrame(a),()=>{window.removeEventListener("beforeunload",s);}}function re(e$1,t,n={}){let{immediate:r=false,once:o=false,debounce:i,deep:s=false}=n,a=Array.isArray(e$1),l=a?e$1:[e$1],u=l.map(()=>{}),d=true,c=null,f=false,p=null,T=()=>{f=true,c&&clearTimeout(c),p?.();};p=e(()=>{let m=l.map(k=>k());if(d){d=false,u=s?m.map(He):[...m],r&&h(m,l.map(()=>{}));return}if(!(s?m.some((k,v)=>!Co(k,u[v])):m.some((k,v)=>!Object.is(k,u[v]))))return;let b=[...u];u=s?m.map(He):[...m],h(m,b);});function h(m,y){if(f)return;let b=()=>{a?t(m,y):t(m[0],y[0]),o&&(f=true,T());};i&&i>0?(c&&clearTimeout(c),c=setTimeout(b,i)):b();}return T}function ko(e,t){return re(e,t,{once:true,immediate:true})}function Po(e,t,n){return re(e,t,{debounce:n})}function He(e){if(e===null||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Co(e,t){if(Object.is(e,t))return true;if(e===null||t===null||typeof e!="object"||typeof t!="object")return false;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return false}}var Ie=Symbol("deepSignal"),Ao=Symbol("deepRaw");function Ro(e){let t=c(0),n=JSON.parse(JSON.stringify(e));function r(){t.update(i=>i+1);}function o(i,s=[]){return new Proxy(i,{get(a,l,u){if(l==="$raw")return JSON.parse(JSON.stringify(n));if(l==="$signal")return ()=>(t(),JSON.parse(JSON.stringify(n)));if(l===Ie)return t;if(l===Ao)return n;let d=Reflect.get(a,l,u);return t(),d!==null&&typeof d=="object"?o(d,[...s,String(l)]):d},set(a,l,u){let d=Reflect.set(a,l,u);return r(),d},deleteProperty(a,l){let u=Reflect.deleteProperty(a,l);return r(),u}})}return o(n)}function Lo(e){return e.$raw??e}function Oo(e){if(e===null||typeof e!="object")return false;try{return e[Ie]!==void 0}catch{return false}}function je(){let e=new Map;function t(n){let r=e.get(n);return r||(r=new Set,e.set(n,r)),r}return {on(n,r){return t(n).add(r),()=>t(n).delete(r)},once(n,r){let o=i=>{t(n).delete(o),r(i);};return t(n).add(o),()=>t(n).delete(o)},emit(n,r){let o=e.get(n);if(o)for(let i of o)i(r);},off(n,r){t(n).delete(r);},clear(n){n?e.delete(n):e.clear();},listenerCount(n){return e.get(n)?.size??0},hasListeners(n){return (e.get(n)?.size??0)>0}}}var oe=null;function Do(){return oe||(oe=je()),oe}export{uo as Await,Nt as ErrorBoundary,ce as HYDRATE_ATTR,Gn as Image,hn as Portal,Kt as Suspense,Hr as Switch,Gt as Transition,xn as VirtualFor,vr as applyDirective,Yn as applyStyles,Jr as assignTransitionName,po as awaitSignal,De as bindClass,vo as bindClasses,mo as bindDimensions,yo as bindElement,ho as bindGroup,To as bindGroupItem,go as bindScroll,Me as bindStyle,bo as bindStyles,X as calculateRange,ar as capitalize,rr as chain,ge as checkForLeaks,Bt as claimElement,qt as claimText,$r as clearProviders,ro as clearQueryState,Jt as collectSSRHead,En as countOps,Zt as createApp,Xn as createDataTable,je as createEventBus,Le as createFlip,ke as createInjector,Ft as createSlots,_n as createTimer,vn as createToaster,Jn as css,pr as currency,he as cx,dr as date,Ro as deepSignal,Kr as defer,Sn as defineAsyncComponent,Cr as defineCustomElement,H as defineDirective,So as defineFormAction,or as definePipe,Xt as definePlugin,Fr as defineProvider,wo as defineSnippet,Tr as directiveFromFn,Pn as disableLeakDetection,Or as discoverStaticRoutes,Re as easings,kn as enableLeakDetection,Eo as enableSnapshots,de as enterTransition,Ut as exitTransition,zt as findHydrationBoundaries,co as flip,$n as formatProfile,Dr as generatePaths,tr as generateSitemap,Qt as generateTransitionCSS,Ln as getActiveEffects,Dn as getLeakDetectionStats,ye as getProfileSummary,oo as getQueryParams,_t as getSuspenseContext,ue as getTransitionClasses,Do as globalEventBus,jt as hasSlot,Q as hydrate,_r as injectProvider,xo as inspect,Oo as isDeepSignal,Vt as isHydrationActive,Cn as isLeakDetectionEnabled,jn as isProfiling,gr as json,pe as longestIncreasingSubsequence,sr as lowercase,Ir as match,Nn as measureAsync,Fn as measureSync,fr as number,fo as onEvent,mr as percent,nr as pipe,yr as plural,Lr as prerender,Wt as progressiveHydrate,fe as reconcileKeys,B as recordPerfEntry,$t as registerPending,hr as relativeTime,wr as removeDirectives,io as removeQueryState,Yt as renderHeadToString,It as renderSlot,Se as renderSwitch,On as reportLeaks,so as resetQueryState,Mr as sitemapFromResults,Hn as startProfiling,Gr as startViewTransition,In as stopProfiling,Pe as supportsViewTransitions,lr as titleCase,Ar as toCustomElement,Lo as toRaw,An as trackEffect,cr as trim,ur as truncate,lo as tweened,Rn as untrackEffect,br as updateDirective,ir as uppercase,xe as urlToFilePath,qn as useAnnounce,un as useBreakpoint,yn as useClickOutside,pn as useClipboard,on as useCounter,nn as useDebounce,Vn as useFocusTrap,mn as useGeolocation,j as useHead,Qn as useInfiniteScroll,en as useInterval,Wn as useKeyboard,ln as useMediaQuery,fn as useOnline,be as useOpenGraph,an as usePrevious,Ae as useQueryState,no as useQueryStates,er as useSEO,dn as useStorage,ve as useStructuredData,bn as useTheme,rn as useThrottle,tn as useTimeout,sn as useToggle,we as useTwitterCard,wn as useVirtualList,gn as useWindowSize,xr as vAutoFocus,Sr as vClickOutside,kr as vIntersect,Er as vLongPress,Pr as vResize,Qr as viewTransitionCSS,re as watch,Po as watchDebounced,ko as watchOnce,Oe as withModifiers};//# sourceMappingURL=index.js.map
|
|
4600
72
|
//# sourceMappingURL=index.js.map
|