wherever-dev 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1264 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/protocol.d.ts +157 -0
  7. package/dist/protocol.d.ts.map +1 -0
  8. package/dist/protocol.js +2 -0
  9. package/dist/protocol.js.map +1 -0
  10. package/dist/session-pool.d.ts +119 -0
  11. package/dist/session-pool.d.ts.map +1 -0
  12. package/dist/session-pool.js +909 -0
  13. package/dist/session-pool.js.map +1 -0
  14. package/dist/session-types.d.ts +44 -0
  15. package/dist/session-types.d.ts.map +1 -0
  16. package/dist/session-types.js +2 -0
  17. package/dist/session-types.js.map +1 -0
  18. package/package.json +42 -0
  19. package/public/_app/env.js +1 -0
  20. package/public/_app/immutable/assets/0.DvZxoQjW.css +2754 -0
  21. package/public/_app/immutable/chunks/B5WJGjcR.js +23 -0
  22. package/public/_app/immutable/chunks/B5WJGjcR.js.map +1 -0
  23. package/public/_app/immutable/chunks/BEWoN05F.js +110 -0
  24. package/public/_app/immutable/chunks/BEWoN05F.js.map +1 -0
  25. package/public/_app/immutable/chunks/BqMutrfe.js +2129 -0
  26. package/public/_app/immutable/chunks/BqMutrfe.js.map +1 -0
  27. package/public/_app/immutable/chunks/DFxBx2vA.js +897 -0
  28. package/public/_app/immutable/chunks/DFxBx2vA.js.map +1 -0
  29. package/public/_app/immutable/chunks/DiYtJzYU.js +396 -0
  30. package/public/_app/immutable/chunks/DiYtJzYU.js.map +1 -0
  31. package/public/_app/immutable/chunks/_lppinj8.js +879 -0
  32. package/public/_app/immutable/chunks/_lppinj8.js.map +1 -0
  33. package/public/_app/immutable/chunks/rMw82gDs.js +3048 -0
  34. package/public/_app/immutable/chunks/rMw82gDs.js.map +1 -0
  35. package/public/_app/immutable/entry/app.BFki2czn.js +309 -0
  36. package/public/_app/immutable/entry/app.BFki2czn.js.map +1 -0
  37. package/public/_app/immutable/entry/start.BceUuq27.js +6 -0
  38. package/public/_app/immutable/entry/start.BceUuq27.js.map +1 -0
  39. package/public/_app/immutable/nodes/0.BzvDOlXz.js +546 -0
  40. package/public/_app/immutable/nodes/0.BzvDOlXz.js.map +1 -0
  41. package/public/_app/immutable/nodes/1.DMtW3tA5.js +24 -0
  42. package/public/_app/immutable/nodes/1.DMtW3tA5.js.map +1 -0
  43. package/public/_app/immutable/nodes/2.CnZp8abw.js +5152 -0
  44. package/public/_app/immutable/nodes/2.CnZp8abw.js.map +1 -0
  45. package/public/_app/version.json +1 -0
  46. package/public/icon.png +0 -0
  47. package/public/index.html +84 -0
  48. package/public/logo.svg +52 -0
  49. package/public/pwa/apple-touch-icon.png +0 -0
  50. package/public/pwa/favicon-192.png +0 -0
  51. package/public/pwa/favicon-512.png +0 -0
  52. package/public/pwa/favicon.ico +0 -0
  53. package/public/pwa/favicon.png +0 -0
  54. package/public/pwa/manifest.webmanifest +27 -0
  55. package/public/service-worker.js +305 -0
@@ -0,0 +1,879 @@
1
+ import { _ as create_text, Q as block, ap as hydrating, a$ as set_hydrate_node, aj as get_first_child, an as hydrate_next, ag as get, aP as read_hydration_instruction, p as HYDRATION_START_ELSE, b4 as skip_nodes, b0 as set_hydrating, ao as hydrate_node, d as COMMENT_NODE, m as HYDRATION_END, au as internal_set, a0 as current_batch, j as EFFECT_OFFSCREEN, U as branch, a9 as each_key_duplicate, b2 as should_defer_append, a7 as derived_safe_equal, ax as is_array, O as array_from, i as EACH_ITEM_REACTIVE, h as EACH_ITEM_IMMUTABLE, aF as mutable_source, b5 as source, E as EACH_INDEX_REACTIVE, D as DESTROYED, aT as resume_effect, aJ as pause_effect, I as INERT, b as BRANCH_EFFECT, W as clear_text_content, aE as move_effect, a8 as destroy_effect, ak as get_next_sibling, g as EACH_IS_CONTROLLED, aO as queue_micro_task, f as EACH_IS_ANIMATED, A as ATTRIBUTES_CACHE, N as NAMESPACE_HTML, al as get_prototype_of, F as FORM_RESET_HANDLER, M as add_form_reset_listener, s as LOADING_ATTR_SYMBOL, ai as get_descriptors, r as IS_XHTML, af as get$1, bi as writable } from "./rMw82gDs.js";
2
+ import { b as base, r as resolve_route, a as pushState, v as version } from "./BqMutrfe.js";
3
+ import { p as page } from "./B5WJGjcR.js";
4
+ function index(_, i) {
5
+ return i;
6
+ }
7
+ function pause_effects(state, to_destroy, controlled_anchor) {
8
+ var transitions = [];
9
+ var length = to_destroy.length;
10
+ var group;
11
+ var remaining = to_destroy.length;
12
+ for (var i = 0; i < length; i++) {
13
+ let effect = to_destroy[i];
14
+ pause_effect(
15
+ effect,
16
+ () => {
17
+ if (group) {
18
+ group.pending.delete(effect);
19
+ group.done.add(effect);
20
+ if (group.pending.size === 0) {
21
+ var groups = (
22
+ /** @type {Set<EachOutroGroup>} */
23
+ state.outrogroups
24
+ );
25
+ destroy_effects(state, array_from(group.done));
26
+ groups.delete(group);
27
+ if (groups.size === 0) {
28
+ state.outrogroups = null;
29
+ }
30
+ }
31
+ } else {
32
+ remaining -= 1;
33
+ }
34
+ },
35
+ false
36
+ );
37
+ }
38
+ if (remaining === 0) {
39
+ var fast_path = transitions.length === 0 && controlled_anchor !== null;
40
+ if (fast_path) {
41
+ var anchor = (
42
+ /** @type {Element} */
43
+ controlled_anchor
44
+ );
45
+ var parent_node = (
46
+ /** @type {Element} */
47
+ anchor.parentNode
48
+ );
49
+ clear_text_content(parent_node);
50
+ parent_node.append(anchor);
51
+ state.items.clear();
52
+ }
53
+ destroy_effects(state, to_destroy, !fast_path);
54
+ } else {
55
+ group = {
56
+ pending: new Set(to_destroy),
57
+ done: /* @__PURE__ */ new Set()
58
+ };
59
+ (state.outrogroups ??= /* @__PURE__ */ new Set()).add(group);
60
+ }
61
+ }
62
+ function destroy_effects(state, to_destroy, remove_dom = true) {
63
+ var preserved_effects;
64
+ if (state.pending.size > 0) {
65
+ preserved_effects = /* @__PURE__ */ new Set();
66
+ for (const keys of state.pending.values()) {
67
+ for (const key of keys) {
68
+ preserved_effects.add(
69
+ /** @type {EachItem} */
70
+ state.items.get(key).e
71
+ );
72
+ }
73
+ }
74
+ }
75
+ for (var i = 0; i < to_destroy.length; i++) {
76
+ var e = to_destroy[i];
77
+ if (preserved_effects?.has(e)) {
78
+ e.f |= EFFECT_OFFSCREEN;
79
+ const fragment = document.createDocumentFragment();
80
+ move_effect(e, fragment);
81
+ } else {
82
+ destroy_effect(to_destroy[i], remove_dom);
83
+ }
84
+ }
85
+ }
86
+ var offscreen_anchor;
87
+ function each(node, flags, get_collection, get_key, render_fn, fallback_fn = null) {
88
+ var anchor = node;
89
+ var items = /* @__PURE__ */ new Map();
90
+ var is_controlled = (flags & EACH_IS_CONTROLLED) !== 0;
91
+ if (is_controlled) {
92
+ var parent_node = (
93
+ /** @type {Element} */
94
+ node
95
+ );
96
+ anchor = hydrating ? set_hydrate_node(get_first_child(parent_node)) : parent_node.appendChild(create_text());
97
+ }
98
+ if (hydrating) {
99
+ hydrate_next();
100
+ }
101
+ var fallback = null;
102
+ var each_array = derived_safe_equal(() => {
103
+ var collection = get_collection();
104
+ return is_array(collection) ? collection : collection == null ? [] : array_from(collection);
105
+ });
106
+ var array;
107
+ var pending = /* @__PURE__ */ new Map();
108
+ var first_run = true;
109
+ function commit(batch) {
110
+ if ((state.effect.f & DESTROYED) !== 0) {
111
+ return;
112
+ }
113
+ state.pending.delete(batch);
114
+ state.fallback = fallback;
115
+ reconcile(state, array, anchor, flags, get_key);
116
+ if (fallback !== null) {
117
+ if (array.length === 0) {
118
+ if ((fallback.f & EFFECT_OFFSCREEN) === 0) {
119
+ resume_effect(fallback);
120
+ } else {
121
+ fallback.f ^= EFFECT_OFFSCREEN;
122
+ move(fallback, null, anchor);
123
+ }
124
+ } else {
125
+ pause_effect(fallback, () => {
126
+ fallback = null;
127
+ });
128
+ }
129
+ }
130
+ }
131
+ function discard(batch) {
132
+ state.pending.delete(batch);
133
+ }
134
+ var effect = block(() => {
135
+ array = /** @type {V[]} */
136
+ get(each_array);
137
+ var length = array.length;
138
+ let mismatch = false;
139
+ if (hydrating) {
140
+ var is_else = read_hydration_instruction(anchor) === HYDRATION_START_ELSE;
141
+ if (is_else !== (length === 0)) {
142
+ anchor = skip_nodes();
143
+ set_hydrate_node(anchor);
144
+ set_hydrating(false);
145
+ mismatch = true;
146
+ }
147
+ }
148
+ var keys = /* @__PURE__ */ new Set();
149
+ var batch = (
150
+ /** @type {Batch} */
151
+ current_batch
152
+ );
153
+ var defer = should_defer_append();
154
+ for (var index2 = 0; index2 < length; index2 += 1) {
155
+ if (hydrating && hydrate_node.nodeType === COMMENT_NODE && /** @type {Comment} */
156
+ hydrate_node.data === HYDRATION_END) {
157
+ anchor = /** @type {Comment} */
158
+ hydrate_node;
159
+ mismatch = true;
160
+ set_hydrating(false);
161
+ }
162
+ var value = array[index2];
163
+ var key = get_key(value, index2);
164
+ var item = first_run ? null : items.get(key);
165
+ if (item) {
166
+ if (item.v) internal_set(item.v, value);
167
+ if (item.i) internal_set(item.i, index2);
168
+ if (defer) {
169
+ batch.unskip_effect(item.e);
170
+ }
171
+ } else {
172
+ item = create_item(
173
+ items,
174
+ first_run ? anchor : offscreen_anchor ??= create_text(),
175
+ value,
176
+ key,
177
+ index2,
178
+ render_fn,
179
+ flags,
180
+ get_collection
181
+ );
182
+ if (!first_run) {
183
+ item.e.f |= EFFECT_OFFSCREEN;
184
+ }
185
+ items.set(key, item);
186
+ }
187
+ keys.add(key);
188
+ }
189
+ if (length === 0 && fallback_fn && !fallback) {
190
+ if (first_run) {
191
+ fallback = branch(() => fallback_fn(anchor));
192
+ } else {
193
+ fallback = branch(() => fallback_fn(offscreen_anchor ??= create_text()));
194
+ fallback.f |= EFFECT_OFFSCREEN;
195
+ }
196
+ }
197
+ if (length > keys.size) {
198
+ {
199
+ each_key_duplicate();
200
+ }
201
+ }
202
+ if (hydrating && length > 0) {
203
+ set_hydrate_node(skip_nodes());
204
+ }
205
+ if (!first_run) {
206
+ pending.set(batch, keys);
207
+ if (defer) {
208
+ for (const [key2, item2] of items) {
209
+ if (!keys.has(key2)) {
210
+ batch.skip_effect(item2.e);
211
+ }
212
+ }
213
+ batch.oncommit(commit);
214
+ batch.ondiscard(discard);
215
+ } else {
216
+ commit(batch);
217
+ }
218
+ }
219
+ if (mismatch) {
220
+ set_hydrating(true);
221
+ }
222
+ get(each_array);
223
+ });
224
+ var state = { effect, items, pending, outrogroups: null, fallback };
225
+ first_run = false;
226
+ if (hydrating) {
227
+ anchor = hydrate_node;
228
+ }
229
+ }
230
+ function skip_to_branch(effect) {
231
+ while (effect !== null && (effect.f & BRANCH_EFFECT) === 0) {
232
+ effect = effect.next;
233
+ }
234
+ return effect;
235
+ }
236
+ function reconcile(state, array, anchor, flags, get_key) {
237
+ var is_animated = (flags & EACH_IS_ANIMATED) !== 0;
238
+ var length = array.length;
239
+ var items = state.items;
240
+ var current = skip_to_branch(state.effect.first);
241
+ var seen;
242
+ var prev = null;
243
+ var to_animate;
244
+ var matched = [];
245
+ var stashed = [];
246
+ var value;
247
+ var key;
248
+ var effect;
249
+ var i;
250
+ if (is_animated) {
251
+ for (i = 0; i < length; i += 1) {
252
+ value = array[i];
253
+ key = get_key(value, i);
254
+ effect = /** @type {EachItem} */
255
+ items.get(key).e;
256
+ if ((effect.f & EFFECT_OFFSCREEN) === 0) {
257
+ effect.nodes?.a?.measure();
258
+ (to_animate ??= /* @__PURE__ */ new Set()).add(effect);
259
+ }
260
+ }
261
+ }
262
+ for (i = 0; i < length; i += 1) {
263
+ value = array[i];
264
+ key = get_key(value, i);
265
+ effect = /** @type {EachItem} */
266
+ items.get(key).e;
267
+ if (state.outrogroups !== null) {
268
+ for (const group of state.outrogroups) {
269
+ group.pending.delete(effect);
270
+ group.done.delete(effect);
271
+ }
272
+ }
273
+ if ((effect.f & INERT) !== 0) {
274
+ resume_effect(effect);
275
+ if (is_animated) {
276
+ effect.nodes?.a?.unfix();
277
+ (to_animate ??= /* @__PURE__ */ new Set()).delete(effect);
278
+ }
279
+ }
280
+ if ((effect.f & EFFECT_OFFSCREEN) !== 0) {
281
+ effect.f ^= EFFECT_OFFSCREEN;
282
+ if (effect === current) {
283
+ move(effect, null, anchor);
284
+ } else {
285
+ var next = prev ? prev.next : current;
286
+ if (effect === state.effect.last) {
287
+ state.effect.last = effect.prev;
288
+ }
289
+ if (effect.prev) effect.prev.next = effect.next;
290
+ if (effect.next) effect.next.prev = effect.prev;
291
+ link(state, prev, effect);
292
+ link(state, effect, next);
293
+ move(effect, next, anchor);
294
+ prev = effect;
295
+ matched = [];
296
+ stashed = [];
297
+ current = skip_to_branch(prev.next);
298
+ continue;
299
+ }
300
+ }
301
+ if (effect !== current) {
302
+ if (seen !== void 0 && seen.has(effect)) {
303
+ if (matched.length < stashed.length) {
304
+ var start = stashed[0];
305
+ var j;
306
+ prev = start.prev;
307
+ var a = matched[0];
308
+ var b = matched[matched.length - 1];
309
+ for (j = 0; j < matched.length; j += 1) {
310
+ move(matched[j], start, anchor);
311
+ }
312
+ for (j = 0; j < stashed.length; j += 1) {
313
+ seen.delete(stashed[j]);
314
+ }
315
+ link(state, a.prev, b.next);
316
+ link(state, prev, a);
317
+ link(state, b, start);
318
+ current = start;
319
+ prev = b;
320
+ i -= 1;
321
+ matched = [];
322
+ stashed = [];
323
+ } else {
324
+ seen.delete(effect);
325
+ move(effect, current, anchor);
326
+ link(state, effect.prev, effect.next);
327
+ link(state, effect, prev === null ? state.effect.first : prev.next);
328
+ link(state, prev, effect);
329
+ prev = effect;
330
+ }
331
+ continue;
332
+ }
333
+ matched = [];
334
+ stashed = [];
335
+ while (current !== null && current !== effect) {
336
+ (seen ??= /* @__PURE__ */ new Set()).add(current);
337
+ stashed.push(current);
338
+ current = skip_to_branch(current.next);
339
+ }
340
+ if (current === null) {
341
+ continue;
342
+ }
343
+ }
344
+ if ((effect.f & EFFECT_OFFSCREEN) === 0) {
345
+ matched.push(effect);
346
+ }
347
+ prev = effect;
348
+ current = skip_to_branch(effect.next);
349
+ }
350
+ if (state.outrogroups !== null) {
351
+ for (const group of state.outrogroups) {
352
+ if (group.pending.size === 0) {
353
+ destroy_effects(state, array_from(group.done));
354
+ state.outrogroups?.delete(group);
355
+ }
356
+ }
357
+ if (state.outrogroups.size === 0) {
358
+ state.outrogroups = null;
359
+ }
360
+ }
361
+ if (current !== null || seen !== void 0) {
362
+ var to_destroy = [];
363
+ if (seen !== void 0) {
364
+ for (effect of seen) {
365
+ if ((effect.f & INERT) === 0) {
366
+ to_destroy.push(effect);
367
+ }
368
+ }
369
+ }
370
+ while (current !== null) {
371
+ if ((current.f & INERT) === 0 && current !== state.fallback) {
372
+ to_destroy.push(current);
373
+ }
374
+ current = skip_to_branch(current.next);
375
+ }
376
+ var destroy_length = to_destroy.length;
377
+ if (destroy_length > 0) {
378
+ var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
379
+ if (is_animated) {
380
+ for (i = 0; i < destroy_length; i += 1) {
381
+ to_destroy[i].nodes?.a?.measure();
382
+ }
383
+ for (i = 0; i < destroy_length; i += 1) {
384
+ to_destroy[i].nodes?.a?.fix();
385
+ }
386
+ }
387
+ pause_effects(state, to_destroy, controlled_anchor);
388
+ }
389
+ }
390
+ if (is_animated) {
391
+ queue_micro_task(() => {
392
+ if (to_animate === void 0) return;
393
+ for (effect of to_animate) {
394
+ effect.nodes?.a?.apply();
395
+ }
396
+ });
397
+ }
398
+ }
399
+ function create_item(items, anchor, value, key, index2, render_fn, flags, get_collection) {
400
+ var v = (flags & EACH_ITEM_REACTIVE) !== 0 ? (flags & EACH_ITEM_IMMUTABLE) === 0 ? mutable_source(value, false, false) : source(value) : null;
401
+ var i = (flags & EACH_INDEX_REACTIVE) !== 0 ? source(index2) : null;
402
+ return {
403
+ v,
404
+ i,
405
+ e: branch(() => {
406
+ render_fn(anchor, v ?? value, i ?? index2, get_collection);
407
+ return () => {
408
+ items.delete(key);
409
+ };
410
+ })
411
+ };
412
+ }
413
+ function move(effect, next, anchor) {
414
+ if (!effect.nodes) return;
415
+ var node = effect.nodes.start;
416
+ var end = effect.nodes.end;
417
+ var dest = next && (next.f & EFFECT_OFFSCREEN) === 0 ? (
418
+ /** @type {EffectNodes} */
419
+ next.nodes.start
420
+ ) : anchor;
421
+ while (node !== null) {
422
+ var next_node = (
423
+ /** @type {TemplateNode} */
424
+ get_next_sibling(node)
425
+ );
426
+ dest.before(node);
427
+ if (node === end) {
428
+ return;
429
+ }
430
+ node = next_node;
431
+ }
432
+ }
433
+ function link(state, prev, next) {
434
+ if (prev === null) {
435
+ state.effect.first = next;
436
+ } else {
437
+ prev.next = next;
438
+ }
439
+ if (next === null) {
440
+ state.effect.last = prev;
441
+ } else {
442
+ next.prev = prev;
443
+ }
444
+ }
445
+ const IS_CUSTOM_ELEMENT = /* @__PURE__ */ Symbol("is custom element");
446
+ const IS_HTML = /* @__PURE__ */ Symbol("is html");
447
+ const LINK_TAG = IS_XHTML ? "link" : "LINK";
448
+ const PROGRESS_TAG = IS_XHTML ? "progress" : "PROGRESS";
449
+ function remove_input_defaults(input) {
450
+ if (!hydrating) return;
451
+ var already_removed = false;
452
+ var remove_defaults = () => {
453
+ if (already_removed) return;
454
+ already_removed = true;
455
+ if (input.hasAttribute("value")) {
456
+ var value = input.value;
457
+ set_attribute(input, "value", null);
458
+ input.value = value;
459
+ }
460
+ if (input.hasAttribute("checked")) {
461
+ var checked = input.checked;
462
+ set_attribute(input, "checked", null);
463
+ input.checked = checked;
464
+ }
465
+ };
466
+ input[FORM_RESET_HANDLER] = remove_defaults;
467
+ queue_micro_task(remove_defaults);
468
+ add_form_reset_listener();
469
+ }
470
+ function set_value(element, value) {
471
+ var attributes = get_attributes(element);
472
+ if (attributes.value === (attributes.value = // treat null and undefined the same for the initial value
473
+ value ?? void 0) || // @ts-expect-error
474
+ // `progress` elements always need their value set when it's `0`
475
+ element.value === value && (value !== 0 || element.nodeName !== PROGRESS_TAG)) {
476
+ return;
477
+ }
478
+ element.value = value ?? "";
479
+ }
480
+ function set_checked(element, checked) {
481
+ var attributes = get_attributes(element);
482
+ if (attributes.checked === (attributes.checked = // treat null and undefined the same for the initial value
483
+ checked ?? void 0)) {
484
+ return;
485
+ }
486
+ element.checked = checked;
487
+ }
488
+ function set_attribute(element, attribute, value, skip_warning) {
489
+ var attributes = get_attributes(element);
490
+ if (hydrating) {
491
+ attributes[attribute] = element.getAttribute(attribute);
492
+ if (attribute === "src" || attribute === "srcset" || attribute === "href" && element.nodeName === LINK_TAG) {
493
+ return;
494
+ }
495
+ }
496
+ if (attributes[attribute] === (attributes[attribute] = value)) return;
497
+ if (attribute === "loading") {
498
+ element[LOADING_ATTR_SYMBOL] = value;
499
+ }
500
+ if (value == null) {
501
+ element.removeAttribute(attribute);
502
+ } else if (typeof value !== "string" && get_setters(element).includes(attribute)) {
503
+ element[attribute] = value;
504
+ } else {
505
+ element.setAttribute(attribute, value);
506
+ }
507
+ }
508
+ function get_attributes(element) {
509
+ return (
510
+ /** @type {Record<string | symbol, unknown>} **/
511
+ /** @type {any} */
512
+ element[ATTRIBUTES_CACHE] ??= {
513
+ [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
514
+ [IS_HTML]: element.namespaceURI === NAMESPACE_HTML
515
+ }
516
+ );
517
+ }
518
+ var setters_cache = /* @__PURE__ */ new Map();
519
+ function get_setters(element) {
520
+ var cache_key = element.getAttribute("is") || element.nodeName;
521
+ var setters = setters_cache.get(cache_key);
522
+ if (setters) return setters;
523
+ setters_cache.set(cache_key, setters = []);
524
+ var descriptors;
525
+ var proto = element;
526
+ var element_proto = Element.prototype;
527
+ while (element_proto !== proto) {
528
+ descriptors = get_descriptors(proto);
529
+ for (var key in descriptors) {
530
+ if (descriptors[key].set && // better safe than sorry, we don't want spread attributes to mess with HTML content
531
+ key !== "innerHTML" && key !== "textContent" && key !== "innerText") {
532
+ setters.push(key);
533
+ }
534
+ }
535
+ proto = get_prototype_of(proto);
536
+ }
537
+ return setters;
538
+ }
539
+ const pathname_prefix = "";
540
+ function resolve(...args) {
541
+ if (!args[0].startsWith("/")) {
542
+ throw new Error(
543
+ `Cannot use \`resolve(...)\` with a non-absolute pathname or route ID (got "${args[0]}"). \`resolve\` is only for internal pathnames and route IDs; external URLs should be used directly.`
544
+ );
545
+ }
546
+ return base + pathname_prefix + resolve_route(
547
+ args[0],
548
+ /** @type {Record<string, string>} */
549
+ args[1]
550
+ );
551
+ }
552
+ const noop = () => {
553
+ }, noopLogger = { assert: noop, error: noop, warn: noop, info: noop, log: noop, debug: noop, dir: noop, table: noop, trace: noop, write: noop, time: noop, timeEnd: noop, timeLog: noop };
554
+ function _getFactory() {
555
+ return null === globalThis || void 0 === globalThis ? void 0 : globalThis._logFactory;
556
+ }
557
+ function logs(o, n) {
558
+ const r = _getFactory();
559
+ return r ? r(o, { decoration: null == n ? void 0 : n.decoration }) : noopLogger;
560
+ }
561
+ function handleAutomaticUpdate(registration, intervals) {
562
+ let lastFocusTime = performance.now();
563
+ function wakeup(evt) {
564
+ const timePassed = performance.now();
565
+ if (timePassed - lastFocusTime > intervals.idle) {
566
+ registration.update();
567
+ }
568
+ lastFocusTime = timePassed;
569
+ }
570
+ ["focus", "pointerdown"].forEach(
571
+ (evt) => window.addEventListener(evt, wakeup)
572
+ );
573
+ return setInterval(() => registration.update(), intervals.checks);
574
+ }
575
+ function listenForWaitingServiceWorker(registration, callback) {
576
+ function awaitStateChange() {
577
+ if (registration.installing) {
578
+ registration.installing.addEventListener("statechange", function() {
579
+ if (this.state === "installed") callback(registration);
580
+ });
581
+ }
582
+ }
583
+ if (!registration) {
584
+ return;
585
+ }
586
+ if (registration.waiting) {
587
+ return callback(registration);
588
+ }
589
+ if (registration.installing) {
590
+ awaitStateChange();
591
+ } else {
592
+ registration.addEventListener("updatefound", awaitStateChange);
593
+ }
594
+ }
595
+ function createNotificationsService() {
596
+ let lastId = 1;
597
+ const store = writable([]);
598
+ function add(notification) {
599
+ store.update((notifications2) => [
600
+ ...notifications2,
601
+ { ...notification, id: ++lastId }
602
+ ]);
603
+ }
604
+ function remove(id) {
605
+ store.update(
606
+ (notifications2) => notifications2.filter((notification) => notification.id !== id)
607
+ );
608
+ }
609
+ function onClick(id) {
610
+ const notification = get$1(store).find((v) => v.id == id);
611
+ remove(id);
612
+ if (notification?.type === "push-notification") {
613
+ if (notification.data.options.data?.navigate) {
614
+ pushState(notification.data.options.data.navigate, page.state);
615
+ }
616
+ }
617
+ }
618
+ return { subscribe: store.subscribe, add, remove, onClick };
619
+ }
620
+ const notifications = createNotificationsService();
621
+ const logger = logs("service-worker");
622
+ function updateLoggingForWorker(worker) {
623
+ if (worker) {
624
+ if (logger.enabled) {
625
+ logger.debug(
626
+ `enabling logging for service worker, level: ${logger.level}`
627
+ );
628
+ } else {
629
+ logger.debug(
630
+ `disabling logging for service worker, level: ${logger.level}`
631
+ );
632
+ }
633
+ worker.postMessage({
634
+ type: "debug",
635
+ level: logger.level,
636
+ enabled: logger.enabled
637
+ });
638
+ }
639
+ }
640
+ const IDLE_DELAY_MS = 3 * 60 * 1e3;
641
+ const CHECK_DELAY_MS = 30 * 60 * 1e3;
642
+ function createServiceWorker() {
643
+ const store = writable(void 0);
644
+ function pingServideWorker(state = "active") {
645
+ sendMessage(
646
+ {
647
+ type: "ping"
648
+ },
649
+ state
650
+ );
651
+ }
652
+ function sendMessage(message, state = "active") {
653
+ const $serviceWorker = get$1(store);
654
+ if (!$serviceWorker) {
655
+ throw new Error(`not loaded`);
656
+ }
657
+ if ($serviceWorker.notSupported) {
658
+ throw new Error(`not supported`);
659
+ }
660
+ if ($serviceWorker.registering) {
661
+ throw new Error(`is registering...`);
662
+ }
663
+ const registration = $serviceWorker.registration;
664
+ if (!registration) {
665
+ throw new Error(`no registration`);
666
+ }
667
+ if (!registration[state]) {
668
+ throw new Error(`no registration in state: ${state}`);
669
+ }
670
+ registration[state].postMessage(message);
671
+ }
672
+ function skipWaiting() {
673
+ logger.log(`accepting update...`);
674
+ const $serviceWorker = get$1(store);
675
+ if (!$serviceWorker) {
676
+ throw new Error(`not loaded`);
677
+ }
678
+ if ($serviceWorker.notSupported) {
679
+ throw new Error(`not supported`);
680
+ }
681
+ if ($serviceWorker.registering) {
682
+ throw new Error(`is registering...`);
683
+ }
684
+ if ($serviceWorker.updateAvailable && $serviceWorker.registration) {
685
+ const registration = $serviceWorker.registration;
686
+ if (!registration) {
687
+ throw new Error(`no registration`);
688
+ }
689
+ if (registration.waiting) {
690
+ logger.log(`was waiting, skipping...`);
691
+ registration.waiting.postMessage("skipWaiting");
692
+ } else {
693
+ logger.log(`was not waiting, should we reload?`);
694
+ logger.error(`not waiting..., todo reload?`);
695
+ }
696
+ {
697
+ logger.log(`update store`);
698
+ store.set({
699
+ notSupported: false,
700
+ updateAvailable: false,
701
+ registration: $serviceWorker.registration,
702
+ registering: $serviceWorker.registering
703
+ });
704
+ }
705
+ }
706
+ }
707
+ function skip() {
708
+ const $serviceWorker = get$1(store);
709
+ if (!$serviceWorker) {
710
+ throw new Error(`not loaded`);
711
+ }
712
+ if ($serviceWorker.notSupported) {
713
+ throw new Error(`not supported`);
714
+ }
715
+ if ($serviceWorker.registering) {
716
+ throw new Error(`is registering...`);
717
+ }
718
+ store.set({
719
+ notSupported: false,
720
+ updateAvailable: false,
721
+ registration: $serviceWorker.registration,
722
+ registering: $serviceWorker.registering
723
+ });
724
+ }
725
+ function register() {
726
+ if (typeof navigator !== "undefined" && "serviceWorker" in navigator) {
727
+ store.set({ notSupported: false, registering: true });
728
+ let refreshing = false;
729
+ navigator.serviceWorker.addEventListener("controllerchange", () => {
730
+ if (refreshing) {
731
+ return;
732
+ }
733
+ refreshing = true;
734
+ window.location.reload();
735
+ });
736
+ navigator.serviceWorker.onmessage = (event) => {
737
+ if (event.data && event.data.type === "notification") {
738
+ console.log(event);
739
+ notifications.add({
740
+ type: "push-notification",
741
+ data: event.data.notification
742
+ });
743
+ }
744
+ };
745
+ const swLocation = resolve(`/service-worker.js`);
746
+ navigator.serviceWorker.register(swLocation, {
747
+ type: "classic"
748
+ }).then((registration) => {
749
+ try {
750
+ handleAutomaticUpdate(registration, {
751
+ idle: IDLE_DELAY_MS,
752
+ checks: CHECK_DELAY_MS
753
+ });
754
+ } catch (e) {
755
+ }
756
+ store.set({
757
+ notSupported: false,
758
+ updateAvailable: false,
759
+ registration,
760
+ registering: false
761
+ });
762
+ updateLoggingForWorker(registration.installing);
763
+ updateLoggingForWorker(registration.waiting);
764
+ updateLoggingForWorker(registration.active);
765
+ listenForWaitingServiceWorker(registration, () => {
766
+ store.set({
767
+ notSupported: false,
768
+ updateAvailable: true,
769
+ registration,
770
+ registering: false
771
+ });
772
+ });
773
+ }).catch((e) => {
774
+ console.error(e);
775
+ store.set({
776
+ registering: false,
777
+ notSupported: false,
778
+ updateAvailable: false,
779
+ registration: void 0,
780
+ error: {
781
+ message: `failed to register service-worker`,
782
+ cause: e.message || e
783
+ }
784
+ });
785
+ logger.error("Failed to register service worker", e);
786
+ });
787
+ } else {
788
+ if (typeof window !== "undefined") {
789
+ store.set({ notSupported: true });
790
+ }
791
+ }
792
+ }
793
+ return {
794
+ subscribe: store.subscribe,
795
+ set: store.set,
796
+ // TODO remove and move handler logic in here
797
+ get registration() {
798
+ const $serviceWorker = get$1(store);
799
+ if ($serviceWorker && "registration" in $serviceWorker) {
800
+ return $serviceWorker.registration;
801
+ } else {
802
+ return void 0;
803
+ }
804
+ },
805
+ get updateAvailable() {
806
+ const $serviceWorker = get$1(store);
807
+ if ($serviceWorker && "updateAvailable" in $serviceWorker) {
808
+ return $serviceWorker.updateAvailable;
809
+ } else {
810
+ return false;
811
+ }
812
+ },
813
+ register,
814
+ pingServideWorker,
815
+ sendMessage,
816
+ skipWaiting,
817
+ skip
818
+ };
819
+ }
820
+ function getParamsFromURL(url) {
821
+ if (!url) {
822
+ return { params: {}, pathname: "" };
823
+ }
824
+ const obj = {};
825
+ const hash = url.lastIndexOf("#");
826
+ let cleanedUrl = url;
827
+ if (hash !== -1) {
828
+ cleanedUrl = cleanedUrl.slice(0, hash);
829
+ }
830
+ const question = cleanedUrl.indexOf("?");
831
+ if (question !== -1) {
832
+ cleanedUrl.slice(question + 1).split("&").forEach((piece) => {
833
+ const [key, val = ""] = piece.split("=");
834
+ obj[decodeURIComponent(key)] = val === "" ? "true" : decodeURIComponent(val);
835
+ });
836
+ }
837
+ let pathname = cleanedUrl.slice(0, question) || "";
838
+ if (pathname && !pathname.endsWith("/")) {
839
+ pathname += "/";
840
+ }
841
+ return { params: obj, pathname };
842
+ }
843
+ function getParamsFromLocation() {
844
+ if (typeof window === "undefined") {
845
+ return { params: {} };
846
+ }
847
+ return getParamsFromURL(window.location.href);
848
+ }
849
+ function getHashParamsFromLocation(str) {
850
+ if (typeof window === "undefined") {
851
+ return {};
852
+ }
853
+ const url = window.location.hash;
854
+ const obj = {};
855
+ const hash = url.lastIndexOf("#");
856
+ if (hash !== -1) {
857
+ url.slice(hash + 1).split("&").forEach((piece) => {
858
+ const [key, val = ""] = piece.split("=");
859
+ obj[decodeURIComponent(key)] = decodeURIComponent(val);
860
+ });
861
+ }
862
+ return obj;
863
+ }
864
+ const serviceWorker = createServiceWorker();
865
+ getHashParamsFromLocation();
866
+ const { params } = getParamsFromLocation();
867
+ console.log(`VERSION: ${version}`);
868
+ export {
869
+ resolve as a,
870
+ set_attribute as b,
871
+ set_checked as c,
872
+ set_value as d,
873
+ each as e,
874
+ index as i,
875
+ notifications as n,
876
+ remove_input_defaults as r,
877
+ serviceWorker as s
878
+ };
879
+ //# sourceMappingURL=_lppinj8.js.map