@fc3/mmcadi 0.1.49 → 0.1.50

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 (35) hide show
  1. package/dist/.last-compile-time +1 -1
  2. package/dist/.last-publish-time +1 -1
  3. package/dist/client.js +879 -55
  4. package/dist/src/client/helper/drag.d.ts +29 -0
  5. package/dist/src/client/helper/drag.js +350 -0
  6. package/dist/src/client/helper/drag.js.map +1 -0
  7. package/dist/src/client/helper/interaction.d.ts +47 -0
  8. package/dist/src/client/helper/interaction.js +739 -0
  9. package/dist/src/client/helper/interaction.js.map +1 -0
  10. package/dist/src/client/page/cursor.d.ts +1 -0
  11. package/dist/src/client/page/cursor.js +17 -19
  12. package/dist/src/client/page/cursor.js.map +1 -1
  13. package/dist/src/client/utility/get-index-path-for-element.d.ts +2 -0
  14. package/dist/src/client/utility/get-index-path-for-element.js +12 -0
  15. package/dist/src/client/utility/get-index-path-for-element.js.map +1 -0
  16. package/dist/src/common/utility/role-is-public.d.ts +3 -0
  17. package/dist/src/common/utility/role-is-public.js +13 -0
  18. package/dist/src/common/utility/role-is-public.js.map +1 -0
  19. package/dist/src/enum/action-type.d.ts +1 -0
  20. package/dist/src/enum/action-type.js +1 -0
  21. package/dist/src/enum/action-type.js.map +1 -1
  22. package/dist/src/index.d.ts +1 -0
  23. package/dist/src/index.js +3 -1
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/server/endpoint/action/create.d.ts +1 -0
  26. package/dist/src/server/endpoint/action/create.js +20 -1
  27. package/dist/src/server/endpoint/action/create.js.map +1 -1
  28. package/dist/src/server/operation/reposition-block.d.ts +15 -0
  29. package/dist/src/server/operation/reposition-block.js +108 -0
  30. package/dist/src/server/operation/reposition-block.js.map +1 -0
  31. package/dist/src/type/action/reposition-block.d.ts +8 -0
  32. package/dist/src/type/action/reposition-block.js +3 -0
  33. package/dist/src/type/action/reposition-block.js.map +1 -0
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -259,9 +259,9 @@
259
259
  };
260
260
  Object.defineProperty(exports, "__esModule", { value: true });
261
261
  var generic_1 = __importDefault(require_generic());
262
- var InvariantViolation12 = class extends generic_1.default {
262
+ var InvariantViolation14 = class extends generic_1.default {
263
263
  };
264
- exports.default = InvariantViolation12;
264
+ exports.default = InvariantViolation14;
265
265
  }
266
266
  });
267
267
 
@@ -1725,7 +1725,7 @@
1725
1725
  });
1726
1726
 
1727
1727
  // src/client/client.ts
1728
- var import_errors12 = __toESM(require_src2());
1728
+ var import_errors14 = __toESM(require_src2());
1729
1729
 
1730
1730
  // src/client/enum/page-type.ts
1731
1731
  var PageType = /* @__PURE__ */ ((PageType2) => {
@@ -2178,7 +2178,7 @@
2178
2178
  var select_block_type_default = SelectBlockTypePage;
2179
2179
 
2180
2180
  // src/client/page/cursor.ts
2181
- var import_errors7 = __toESM(require_src2());
2181
+ var import_errors9 = __toESM(require_src2());
2182
2182
  var import_array = __toESM(require_src3());
2183
2183
  var import_time = __toESM(require_src6());
2184
2184
 
@@ -2242,30 +2242,851 @@
2242
2242
  })(MediaReadyState || {});
2243
2243
  var media_ready_state_default = MediaReadyState;
2244
2244
 
2245
- // src/client/page/cursor.ts
2246
- function getAttributeForElement(element, attribute) {
2247
- const value = element.getAttribute(attribute);
2245
+ // src/client/helper/interaction.ts
2246
+ var import_errors8 = __toESM(require_src2());
2247
+
2248
+ // src/enum/action-type.ts
2249
+ var ActionType = /* @__PURE__ */ ((ActionType2) => {
2250
+ ActionType2["ADD_BLOCK"] = "add_block";
2251
+ ActionType2["DELETE_BLOCK"] = "delete_block";
2252
+ ActionType2["MOVE_BLOCK"] = "move_block";
2253
+ ActionType2["HIDE_BLOCK"] = "hide_block";
2254
+ ActionType2["PROMOTE_BLOCK"] = "promote_block";
2255
+ ActionType2["DEMOTE_BLOCK"] = "demote_block";
2256
+ ActionType2["REPOSITION_BLOCK"] = "reposition_block";
2257
+ ActionType2["EDIT_BLOCK"] = "edit_block";
2258
+ ActionType2["CREATE_PAGE"] = "create_page";
2259
+ ActionType2["COMPLETE_BLOCK"] = "complete_block";
2260
+ ActionType2["ADD_BLOCK_TO_PLAYLIST"] = "add_to_playlist";
2261
+ return ActionType2;
2262
+ })(ActionType || {});
2263
+ var action_type_default = ActionType;
2264
+
2265
+ // src/enum/emoji.ts
2266
+ var Emoji = /* @__PURE__ */ ((Emoji2) => {
2267
+ Emoji2["USER_PORTRAIT"] = "\u{1F464}";
2268
+ Emoji2["WARNING_SIGN"] = "\u26A0\uFE0F";
2269
+ Emoji2["BAR_CHART"] = "\u{1F4CA}";
2270
+ Emoji2["FOLDER"] = "\u{1F5C2}\uFE0F";
2271
+ Emoji2["FILE"] = "\u{1F4C4}";
2272
+ Emoji2["HOUSE"] = "\u{1F3E0}";
2273
+ Emoji2["NONE"] = "\u{1F6AB}";
2274
+ Emoji2["WHITE_SQUARE"] = "\u2B1C";
2275
+ Emoji2["GRID_GLOBE"] = "\u{1F310}";
2276
+ Emoji2["SATELLITE_DISH"] = "\u{1F4E1}";
2277
+ Emoji2["COMPLETED_CHECKMARK"] = "\u2705";
2278
+ Emoji2["RED_X"] = "\u274C";
2279
+ Emoji2["CLOCK"] = "\u{1F552}";
2280
+ Emoji2["SUNSHINE"] = "\u{1F506}";
2281
+ Emoji2["ALARM_CLOCK"] = "\u23F0";
2282
+ Emoji2["MAGNIFYING_GLASS"] = "\u{1F50E}";
2283
+ Emoji2["MAGIC_WAND"] = "\u{1FA84}";
2284
+ Emoji2["CALENDAR"] = "\u{1F4C5}";
2285
+ Emoji2["LOCKED"] = "\u{1F512}";
2286
+ Emoji2["UNLOCKED"] = "\u{1F513}";
2287
+ Emoji2["NORTHWEST_ARROW"] = "\u2196\uFE0F";
2288
+ Emoji2["RIGHT_ARROW"] = "\u27A1\uFE0F";
2289
+ Emoji2["LEFT_ARROW"] = "\u2B05\uFE0F";
2290
+ Emoji2["UP_ARROW"] = "\u2B06\uFE0F";
2291
+ Emoji2["UP_DOWN_ARROW"] = "\u2195\uFE0F";
2292
+ Emoji2["LEFT_ARROW_UNICODE"] = "\u25C4";
2293
+ Emoji2["UP_ARROW_UNICODE"] = "\u25B2";
2294
+ Emoji2["RIGHT_ARROW_UNICODE"] = "\u25BA";
2295
+ Emoji2["DOWN_ARROW_UNICODE"] = "\u25BC";
2296
+ Emoji2["BRICK"] = "\u{1F9F1}";
2297
+ Emoji2["RULER"] = "\u{1F4D0}";
2298
+ Emoji2["SWORD"] = "\u{1F5E1}\uFE0F";
2299
+ Emoji2["PEACE_SIGN"] = "\u270C\uFE0F";
2300
+ Emoji2["SIGN"] = "\u{1FAA7}";
2301
+ Emoji2["CONSTRUCTION"] = "\u{1F3D7}\uFE0F";
2302
+ Emoji2["CAMERA"] = "\u{1F4F7}";
2303
+ Emoji2["MOVIE_CAMERA"] = "\u{1F3A5}";
2304
+ Emoji2["PAINTING"] = "\u{1F5BC}\uFE0F";
2305
+ Emoji2["PALETTE"] = "\u{1F3A8}";
2306
+ Emoji2["MICROPHONE"] = "\u{1F399}\uFE0F";
2307
+ Emoji2["NOTEPAD"] = "\u{1F4DD}";
2308
+ Emoji2["GEAR"] = "\u2699\uFE0F";
2309
+ Emoji2["REPEAT"] = "\u{1F501}";
2310
+ Emoji2["SNOWMAN"] = "\u2603\uFE0F";
2311
+ Emoji2["SNOWFLAKE"] = "\u2744\uFE0F";
2312
+ Emoji2["SNOW_CLOUD"] = "\u{1F328}\uFE0F";
2313
+ Emoji2["SCARF"] = "\u{1F9E3}";
2314
+ Emoji2["GLOVES"] = "\u{1F9E4}";
2315
+ Emoji2["CANDLE"] = "\u{1F56F}\uFE0F";
2316
+ Emoji2["CHRISTMAS_TREE"] = "\u{1F384}";
2317
+ Emoji2["SOCKS"] = "\u{1F9E6}";
2318
+ Emoji2["COLD_FACE"] = "\u{1F976}";
2319
+ Emoji2["EYE"] = "\u{1F441}\uFE0F";
2320
+ Emoji2["CHAINS"] = "\u26D3\uFE0F";
2321
+ Emoji2["SPEAKER"] = "\u{1F50A}";
2322
+ Emoji2["COMPACT_DISK"] = "\u{1F4BF}";
2323
+ Emoji2["SEEDLING"] = "\u{1F331}";
2324
+ Emoji2["TULIP"] = "\u{1F337}";
2325
+ Emoji2["BEE"] = "\u{1F41D}";
2326
+ Emoji2["HATCHING_CHICK"] = "\u{1F423}";
2327
+ Emoji2["NEST_WITH_EGGS"] = "\u{1FABA}";
2328
+ Emoji2["BLOSSOM"] = "\u{1F33C}";
2329
+ Emoji2["UMBRELLA"] = "\u2614";
2330
+ Emoji2["RAINBOW"] = "\u{1F308}";
2331
+ Emoji2["PICNIC_BASKET"] = "\u{1F9FA}";
2332
+ Emoji2["SUN_WITH_FACE"] = "\u{1F31E}";
2333
+ Emoji2["BEACH_UMBRELLA"] = "\u{1F3D6}\uFE0F";
2334
+ Emoji2["WATERMELON"] = "\u{1F349}";
2335
+ Emoji2["SUNGLASSES"] = "\u{1F576}\uFE0F";
2336
+ Emoji2["ICE_CREAM"] = "\u{1F366}";
2337
+ Emoji2["SUNFLOWER"] = "\u{1F33B}";
2338
+ Emoji2["CAMPING"] = "\u{1F3D5}\uFE0F";
2339
+ Emoji2["JUICE_BOX"] = "\u{1F9C3}";
2340
+ Emoji2["PARASOL"] = "\u26F1\uFE0F";
2341
+ Emoji2["MAPLE_LEAF"] = "\u{1F341}";
2342
+ Emoji2["FALLEN_LEAF"] = "\u{1F342}";
2343
+ Emoji2["TURKEY"] = "\u{1F983}";
2344
+ Emoji2["JACK_O_LANTERN"] = "\u{1F383}";
2345
+ Emoji2["PIE"] = "\u{1F967}";
2346
+ Emoji2["LOG"] = "\u{1FAB5}";
2347
+ Emoji2["SPIDER_WEB"] = "\u{1F578}\uFE0F";
2348
+ Emoji2["BACKPACK"] = "\u{1F392}";
2349
+ Emoji2["CHESTNUT"] = "\u{1F330}";
2350
+ Emoji2["PLACARD"] = "\u{1FAA7}";
2351
+ Emoji2["RECEIPT"] = "\u{1F9FE}";
2352
+ Emoji2["DOCUMENT"] = "\u{1F4C4}";
2353
+ Emoji2["SPARKLES"] = "\u2728";
2354
+ Emoji2["BOOKS"] = "\u{1F4DA}";
2355
+ Emoji2["SHOPPING_BAGS"] = "\u{1F6CD}\uFE0F";
2356
+ Emoji2["LINK"] = "\u{1F517}";
2357
+ Emoji2["GREEN_ASTERISK"] = "\u2733\uFE0F";
2358
+ Emoji2["RADIO_BUTTON"] = "\u{1F518}";
2359
+ Emoji2["WINDOW"] = "\u{1FA9F}";
2360
+ Emoji2["MUSIC_NOTES"] = "\u{1F3B6}";
2361
+ Emoji2["INVISIBLE_FACE"] = "\u{1FAE5}";
2362
+ Emoji2["PLUS_SIGN"] = "\u2795";
2363
+ Emoji2["JOKER"] = "\u{1F0CF}";
2364
+ Emoji2["PLAY"] = "\u25B6\uFE0F";
2365
+ Emoji2["PAUSE"] = "\u23F8\uFE0F";
2366
+ return Emoji2;
2367
+ })(Emoji || {});
2368
+ var emoji_default = Emoji;
2369
+
2370
+ // src/client/utility/get-index-path-for-element.ts
2371
+ var import_errors7 = __toESM(require_src2());
2372
+ function getIndexPathForElement(element) {
2373
+ const value = element.getAttribute("data-index-path");
2248
2374
  if (value === null) {
2249
- throw new import_errors7.InvariantViolation(`
2250
- Tried to read ${attribute} for element, but it was not set
2251
- `);
2375
+ throw new import_errors7.InvariantViolation(
2376
+ "Tried to read data-index-path for element, but it was not set"
2377
+ );
2252
2378
  }
2253
2379
  return value;
2254
2380
  }
2255
- function getIndexPathForElement(element) {
2256
- return getAttributeForElement(element, "data-index-path");
2257
- }
2381
+ var get_index_path_for_element_default = getIndexPathForElement;
2382
+
2383
+ // src/client/helper/interaction.ts
2384
+ var InteractionHelper = class {
2385
+ constructor() {
2386
+ this.drag_active = false;
2387
+ this.drag_origin_block = null;
2388
+ this.drag_placeholder = null;
2389
+ this.drag_ghost = null;
2390
+ this.drag_start_y = null;
2391
+ this.drag_pointer_offset_y = null;
2392
+ this.drag_press_timer = null;
2393
+ this.swipe_active = false;
2394
+ this.swipe_block = null;
2395
+ this.swipe_start_x = null;
2396
+ this.swipe_start_y = null;
2397
+ this.swipe_content = null;
2398
+ this.swipe_menu_width = 0;
2399
+ this.open_swipe_block = null;
2400
+ this.open_swipe_content = null;
2401
+ }
2402
+ attach() {
2403
+ document.addEventListener("mousedown", (event) => {
2404
+ this.onPressStart(event);
2405
+ }, true);
2406
+ document.addEventListener("touchstart", (event) => {
2407
+ this.onPressStart(event);
2408
+ }, { capture: true, passive: false });
2409
+ document.addEventListener("mousemove", (event) => {
2410
+ this.onPointerMove(event);
2411
+ }, true);
2412
+ document.addEventListener("touchmove", (event) => {
2413
+ this.onPointerMove(event);
2414
+ }, { capture: true, passive: false });
2415
+ document.addEventListener("mouseup", (event) => {
2416
+ this.onPressEnd(event);
2417
+ }, true);
2418
+ document.addEventListener("touchend", (event) => {
2419
+ this.onPressEnd(event);
2420
+ }, true);
2421
+ document.addEventListener("touchstart", (event) => {
2422
+ this.onGlobalTouchStart(event);
2423
+ }, { capture: true, passive: true });
2424
+ document.addEventListener("dragstart", (event) => {
2425
+ this.onNativeDragStart(event);
2426
+ }, true);
2427
+ }
2428
+ isDragging() {
2429
+ return this.drag_active;
2430
+ }
2431
+ getBlockElements() {
2432
+ const elements = document.querySelectorAll("section.block");
2433
+ return Array.from(elements);
2434
+ }
2435
+ getSiblingBlocks(container, exclude) {
2436
+ const children = Array.from(container.children);
2437
+ return children.filter((element) => {
2438
+ if (element === exclude) {
2439
+ return false;
2440
+ }
2441
+ return element.classList.contains("block");
2442
+ });
2443
+ }
2444
+ onPressStart(event) {
2445
+ const target = event.target;
2446
+ if (target === null) {
2447
+ return;
2448
+ }
2449
+ if (target.closest("button, input, textarea, select, label, form")) {
2450
+ return;
2451
+ }
2452
+ const block = target.closest("section.block");
2453
+ if (block === null) {
2454
+ return;
2455
+ }
2456
+ if (event instanceof MouseEvent) {
2457
+ const anchor = target.closest("a[href]");
2458
+ if (anchor) {
2459
+ event.preventDefault();
2460
+ }
2461
+ }
2462
+ const touch_event = event;
2463
+ const is_touch = touch_event.type === "touchstart";
2464
+ const point = this.getEventPoint(event);
2465
+ if (point === null) {
2466
+ return;
2467
+ }
2468
+ this.drag_origin_block = block;
2469
+ this.drag_start_y = point.clientY;
2470
+ if (is_touch) {
2471
+ this.swipe_block = block;
2472
+ this.swipe_start_x = point.clientX;
2473
+ this.swipe_start_y = point.clientY;
2474
+ }
2475
+ const threshold_ms = is_touch ? 350 : 200;
2476
+ this.clearPressTimer();
2477
+ this.drag_press_timer = window.setTimeout(() => {
2478
+ this.beginDrag(point.clientY);
2479
+ }, threshold_ms);
2480
+ }
2481
+ onNativeDragStart(event) {
2482
+ const target = event.target;
2483
+ if (!target) {
2484
+ return;
2485
+ }
2486
+ if (target.closest("section.block")) {
2487
+ event.preventDefault();
2488
+ }
2489
+ }
2490
+ onPointerMove(event) {
2491
+ const point = this.getEventPoint(event);
2492
+ if (point === null) {
2493
+ return;
2494
+ }
2495
+ const touch_event = event;
2496
+ const { touches } = touch_event;
2497
+ const is_touch = touches !== void 0;
2498
+ if (is_touch && this.swipe_block) {
2499
+ if (this.swipe_start_x === null || this.swipe_start_y === null) {
2500
+ throw new import_errors8.InvariantViolation("Swipe start coordinates were not initialized");
2501
+ }
2502
+ const start_x = this.swipe_start_x;
2503
+ const start_y = this.swipe_start_y;
2504
+ const delta_x = point.clientX - start_x;
2505
+ const delta_y = point.clientY - start_y;
2506
+ if (!this.swipe_active) {
2507
+ const abs_x = Math.abs(delta_x);
2508
+ const abs_y = Math.abs(delta_y);
2509
+ if (abs_x > 12 && abs_x > abs_y) {
2510
+ this.clearPressTimer();
2511
+ this.closeOpenSwipeMenu(this.swipe_block);
2512
+ this.swipe_active = true;
2513
+ this.beginSwipe(this.swipe_block);
2514
+ }
2515
+ }
2516
+ if (this.swipe_active) {
2517
+ event.preventDefault();
2518
+ const content_element = this.swipe_content;
2519
+ const menu_width = this.swipe_menu_width;
2520
+ const translate_x = Math.max(-menu_width, Math.min(0, delta_x));
2521
+ content_element.style.transition = "";
2522
+ content_element.style.transform = `translateX(${translate_x}px)`;
2523
+ return;
2524
+ }
2525
+ }
2526
+ if (!this.drag_active && this.drag_origin_block && this.drag_start_y !== null) {
2527
+ const delta_y = Math.abs(point.clientY - this.drag_start_y);
2528
+ if (delta_y > 8 && this.drag_press_timer !== null) {
2529
+ this.beginDrag(point.clientY);
2530
+ }
2531
+ }
2532
+ if (!this.drag_active) {
2533
+ return;
2534
+ }
2535
+ event.preventDefault();
2536
+ const origin = this.drag_origin_block;
2537
+ let container = null;
2538
+ if (this.drag_placeholder !== null) {
2539
+ container = this.drag_placeholder.parentElement;
2540
+ }
2541
+ if (container === null && origin !== null) {
2542
+ container = origin.parentElement;
2543
+ }
2544
+ if (container === null) {
2545
+ return;
2546
+ }
2547
+ const blocks_before = this.getSiblingBlocks(container, origin);
2548
+ const preceding_rects = /* @__PURE__ */ new Map();
2549
+ blocks_before.forEach((element) => {
2550
+ const rect = element.getBoundingClientRect();
2551
+ preceding_rects.set(element, rect);
2552
+ });
2553
+ this.updatePlaceholderPosition(point.clientY);
2554
+ if (this.drag_ghost && this.drag_pointer_offset_y !== null) {
2555
+ const top_position = point.clientY - this.drag_pointer_offset_y;
2556
+ this.drag_ghost.style.top = `${top_position}px`;
2557
+ }
2558
+ const blocks_after = this.getSiblingBlocks(container, origin);
2559
+ this.animateWithFlip(preceding_rects, blocks_after);
2560
+ }
2561
+ onPressEnd(event) {
2562
+ this.clearPressTimer();
2563
+ if (this.swipe_active) {
2564
+ const content = this.swipe_content;
2565
+ const style = window.getComputedStyle(content);
2566
+ let current_x = 0;
2567
+ try {
2568
+ const css_matrix = new WebKitCSSMatrix(style.transform);
2569
+ current_x = css_matrix.m41;
2570
+ } catch {
2571
+ const translate_match = style.transform.match(/translateX\(([-0-9.]+)px\)/);
2572
+ if (translate_match) {
2573
+ current_x = parseFloat(translate_match[1]);
2574
+ }
2575
+ }
2576
+ const width = this.swipe_menu_width;
2577
+ const open = Math.abs(current_x) > width / 2;
2578
+ content.style.transition = "transform 150ms ease";
2579
+ content.style.transform = open ? `translateX(${-width}px)` : "translateX(0)";
2580
+ if (!open) {
2581
+ this.teardownSwipe();
2582
+ }
2583
+ if (open) {
2584
+ this.open_swipe_block = this.swipe_block;
2585
+ this.open_swipe_content = content;
2586
+ }
2587
+ this.swipe_active = false;
2588
+ return;
2589
+ }
2590
+ if (!this.drag_active) {
2591
+ this.resetDragState();
2592
+ return;
2593
+ }
2594
+ event.preventDefault();
2595
+ const origin = this.drag_origin_block;
2596
+ const placeholder = this.drag_placeholder;
2597
+ const source_index_path = get_index_path_for_element_default(origin);
2598
+ const target_index_path = this.computeTargetIndexPath(placeholder);
2599
+ this.cleanupDragElements();
2600
+ if (target_index_path === null || target_index_path === source_index_path) {
2601
+ this.resetDragState();
2602
+ return;
2603
+ }
2604
+ const editing = new URL(window.location.href).searchParams.get("editing") === "true";
2605
+ this.postReposition(source_index_path, target_index_path, editing).then((new_index_path) => {
2606
+ if (new_index_path) {
2607
+ const url = new URL(window.location.href);
2608
+ url.searchParams.set("index_path", new_index_path);
2609
+ history.replaceState({}, "", url.toString());
2610
+ }
2611
+ const blocks = this.getBlockElements();
2612
+ blocks.forEach((element) => {
2613
+ element.classList.remove("selected");
2614
+ });
2615
+ origin.classList.add("selected");
2616
+ this.updateTopLevelIndexPaths();
2617
+ }).finally(() => {
2618
+ this.resetDragState();
2619
+ });
2620
+ }
2621
+ beginSwipe(block) {
2622
+ const result = this.ensureSwipeUI(block);
2623
+ const target = result.target;
2624
+ const menu = result.menu;
2625
+ const menu_width = result.menu_width;
2626
+ this.swipe_content = target;
2627
+ this.swipe_menu_width = menu_width;
2628
+ if (menu) {
2629
+ menu.style.display = "flex";
2630
+ menu.style.opacity = "1";
2631
+ }
2632
+ }
2633
+ closeOpenSwipeMenu(except) {
2634
+ if (!this.open_swipe_content) {
2635
+ return;
2636
+ }
2637
+ if (except && this.open_swipe_block === except) {
2638
+ return;
2639
+ }
2640
+ const content = this.open_swipe_content;
2641
+ content.style.transition = "transform 150ms ease";
2642
+ content.style.transform = "translateX(0)";
2643
+ const clear_callback = () => {
2644
+ content.removeEventListener("transitionend", clear_callback);
2645
+ if (this.open_swipe_block) {
2646
+ const menu_element = this.getSwipeMenuFor(this.open_swipe_block);
2647
+ if (menu_element && menu_element.parentElement) {
2648
+ menu_element.parentElement.removeChild(menu_element);
2649
+ }
2650
+ }
2651
+ this.open_swipe_block = null;
2652
+ this.open_swipe_content = null;
2653
+ };
2654
+ content.addEventListener("transitionend", clear_callback);
2655
+ }
2656
+ teardownSwipe() {
2657
+ if (!this.swipe_block || !this.swipe_content) {
2658
+ this.resetSwipeState();
2659
+ return;
2660
+ }
2661
+ this.swipe_content.style.transition = "";
2662
+ this.swipe_content.style.transform = "translateX(0)";
2663
+ const menu = this.getSwipeMenuFor(this.swipe_block);
2664
+ if (menu && menu.parentElement) {
2665
+ menu.parentElement.removeChild(menu);
2666
+ }
2667
+ this.resetSwipeState();
2668
+ }
2669
+ onGlobalTouchStart(event) {
2670
+ if (!this.open_swipe_block || !this.open_swipe_content) {
2671
+ return;
2672
+ }
2673
+ const target = event.target;
2674
+ if (!target) {
2675
+ return;
2676
+ }
2677
+ const menu = this.getSwipeMenuFor(this.open_swipe_block);
2678
+ const closest_block = target.closest("section.block");
2679
+ const swipe_actions = target.closest(".swipe-actions");
2680
+ if (closest_block === this.open_swipe_block || swipe_actions === menu) {
2681
+ return;
2682
+ }
2683
+ this.closeOpenSwipeMenu();
2684
+ }
2685
+ getSwipeMenuFor(block) {
2686
+ const wrapper = block.closest("main .section-wrapper");
2687
+ if (!wrapper || !block.id) {
2688
+ return null;
2689
+ }
2690
+ return wrapper.querySelector(`.swipe-actions[data-for="${block.id}"]`);
2691
+ }
2692
+ resetSwipeState() {
2693
+ this.swipe_block = null;
2694
+ this.swipe_start_x = null;
2695
+ this.swipe_start_y = null;
2696
+ this.swipe_content = null;
2697
+ this.swipe_menu_width = 0;
2698
+ }
2699
+ ensureSwipeUI(block) {
2700
+ const target = block;
2701
+ target.style.willChange = "transform";
2702
+ target.style.transform = "translateX(0)";
2703
+ target.style.transition = "";
2704
+ target.style.position = target.style.position || "relative";
2705
+ target.style.zIndex = "1";
2706
+ const wrapper = block.closest("main .section-wrapper");
2707
+ let menu = null;
2708
+ if (wrapper) {
2709
+ if (getComputedStyle(wrapper).position === "static") {
2710
+ wrapper.style.position = "relative";
2711
+ }
2712
+ let existing = wrapper.querySelector(`.swipe-actions[data-for="${block.id}"]`);
2713
+ if (!existing) {
2714
+ existing = document.createElement("div");
2715
+ existing.className = "swipe-actions";
2716
+ existing.setAttribute("data-for", block.id);
2717
+ existing.style.position = "absolute";
2718
+ existing.style.right = "0";
2719
+ existing.style.display = "none";
2720
+ existing.style.opacity = "0";
2721
+ existing.style.gap = "8px";
2722
+ existing.style.alignItems = "stretch";
2723
+ existing.style.padding = "0 8px";
2724
+ existing.style.background = "transparent";
2725
+ existing.style.zIndex = "0";
2726
+ const edit_button = document.createElement("button");
2727
+ const delete_button = document.createElement("button");
2728
+ const add_button = document.createElement("button");
2729
+ edit_button.textContent = emoji_default.GEAR;
2730
+ edit_button.setAttribute("aria-label", "Edit");
2731
+ edit_button.style.background = "#f0ad4e";
2732
+ edit_button.style.color = "#000";
2733
+ edit_button.style.border = "none";
2734
+ edit_button.style.padding = "0";
2735
+ edit_button.style.fontSize = "20px";
2736
+ edit_button.style.width = "48px";
2737
+ edit_button.style.minWidth = "48px";
2738
+ edit_button.style.display = "flex";
2739
+ edit_button.style.alignItems = "center";
2740
+ edit_button.style.justifyContent = "center";
2741
+ edit_button.style.cursor = "pointer";
2742
+ delete_button.textContent = emoji_default.RED_X;
2743
+ delete_button.setAttribute("aria-label", "Delete");
2744
+ delete_button.style.background = "#e74c3c";
2745
+ delete_button.style.color = "#fff";
2746
+ delete_button.style.border = "none";
2747
+ delete_button.style.padding = "0";
2748
+ delete_button.style.fontSize = "20px";
2749
+ delete_button.style.width = "48px";
2750
+ delete_button.style.minWidth = "48px";
2751
+ delete_button.style.display = "flex";
2752
+ delete_button.style.alignItems = "center";
2753
+ delete_button.style.justifyContent = "center";
2754
+ delete_button.style.cursor = "pointer";
2755
+ add_button.textContent = emoji_default.PLUS_SIGN;
2756
+ add_button.setAttribute("aria-label", "Add After");
2757
+ add_button.style.background = "#27ae60";
2758
+ add_button.style.color = "#fff";
2759
+ add_button.style.border = "none";
2760
+ add_button.style.padding = "0";
2761
+ add_button.style.fontSize = "20px";
2762
+ add_button.style.width = "48px";
2763
+ add_button.style.minWidth = "48px";
2764
+ add_button.style.display = "flex";
2765
+ add_button.style.alignItems = "center";
2766
+ add_button.style.justifyContent = "center";
2767
+ add_button.style.cursor = "pointer";
2768
+ existing.appendChild(edit_button);
2769
+ existing.appendChild(delete_button);
2770
+ existing.appendChild(add_button);
2771
+ wrapper.appendChild(existing);
2772
+ const edit_handler = (event) => {
2773
+ event.preventDefault();
2774
+ event.stopPropagation();
2775
+ this.navigateToBlockLink(block, "edit");
2776
+ };
2777
+ const delete_handler = (event) => {
2778
+ event.preventDefault();
2779
+ event.stopPropagation();
2780
+ this.navigateToBlockLink(block, "delete");
2781
+ };
2782
+ const add_handler = (event) => {
2783
+ event.preventDefault();
2784
+ event.stopPropagation();
2785
+ this.navigateToAddAfter(block);
2786
+ };
2787
+ existing.addEventListener("touchstart", (event) => {
2788
+ event.stopPropagation();
2789
+ });
2790
+ existing.addEventListener("mousedown", (event) => {
2791
+ event.stopPropagation();
2792
+ });
2793
+ edit_button.addEventListener("click", edit_handler);
2794
+ edit_button.addEventListener("touchend", edit_handler);
2795
+ delete_button.addEventListener("click", delete_handler);
2796
+ delete_button.addEventListener("touchend", delete_handler);
2797
+ add_button.addEventListener("click", add_handler);
2798
+ add_button.addEventListener("touchend", add_handler);
2799
+ }
2800
+ menu = existing;
2801
+ const top = block.offsetTop;
2802
+ const height = block.offsetHeight;
2803
+ menu.style.top = `${top}px`;
2804
+ menu.style.height = `${height}px`;
2805
+ }
2806
+ let menu_width = 160;
2807
+ if (menu) {
2808
+ const prevDisplay = menu.style.display;
2809
+ const prevOpacity = menu.style.opacity;
2810
+ menu.style.display = "flex";
2811
+ menu.style.opacity = "0";
2812
+ menu_width = menu.offsetWidth || 160;
2813
+ menu.style.display = prevDisplay;
2814
+ menu.style.opacity = prevOpacity;
2815
+ }
2816
+ this.enforceTimeVisibility(block);
2817
+ return {
2818
+ target,
2819
+ menu,
2820
+ menu_width
2821
+ };
2822
+ }
2823
+ navigateToAddAfter(block) {
2824
+ const current = get_index_path_for_element_default(block);
2825
+ const parts = current.split(".").map((part) => {
2826
+ return parseInt(part, 10);
2827
+ });
2828
+ const has_invalid_number = parts.some((value) => {
2829
+ return isNaN(value);
2830
+ });
2831
+ if (parts.length === 0 || has_invalid_number) {
2832
+ throw new import_errors8.InvariantViolation("Invalid index_path for Add After");
2833
+ }
2834
+ const last = parts.pop();
2835
+ if (last === void 0) {
2836
+ throw new import_errors8.InvariantViolation("Unable to compute next index for Add After");
2837
+ }
2838
+ parts.push(last + 1);
2839
+ const index_path = parts.join(".");
2840
+ const url = new URL(window.location.href);
2841
+ const editing = url.searchParams.get("editing") === "true";
2842
+ const path = window.location.pathname;
2843
+ const actionUrl = new URL("/actions", window.location.origin);
2844
+ actionUrl.searchParams.set("path", path);
2845
+ actionUrl.searchParams.set("editing", String(editing));
2846
+ actionUrl.searchParams.set("action_type", "add_block");
2847
+ actionUrl.searchParams.set("index_path", index_path);
2848
+ window.location.href = actionUrl.toString();
2849
+ }
2850
+ enforceTimeVisibility(block) {
2851
+ const shows_time = block.classList.contains("with-time");
2852
+ const time_element = block.querySelector(":scope time");
2853
+ if (!time_element) {
2854
+ return;
2855
+ }
2856
+ if (!shows_time) {
2857
+ time_element.style.display = "none";
2858
+ } else {
2859
+ time_element.style.display = "";
2860
+ }
2861
+ }
2862
+ navigateToBlockLink(block, type) {
2863
+ const block_id = block.id;
2864
+ const link_id = `${block_id}-${type}`;
2865
+ const link_element = document.getElementById(link_id);
2866
+ if (!link_element) {
2867
+ return;
2868
+ }
2869
+ const href = link_element.getAttribute("href");
2870
+ if (href) {
2871
+ window.location.href = href;
2872
+ }
2873
+ }
2874
+ beginDrag(current_y) {
2875
+ if (this.drag_active) {
2876
+ return;
2877
+ }
2878
+ const block = this.drag_origin_block;
2879
+ if (!block) {
2880
+ return;
2881
+ }
2882
+ this.drag_active = true;
2883
+ document.body.style.userSelect = "none";
2884
+ document.body.style.cursor = "grabbing";
2885
+ const rect = block.getBoundingClientRect();
2886
+ const ghost = block.cloneNode(true);
2887
+ ghost.style.position = "fixed";
2888
+ ghost.style.top = `${rect.top}px`;
2889
+ ghost.style.left = `${rect.left}px`;
2890
+ ghost.style.width = `${rect.width}px`;
2891
+ ghost.style.pointerEvents = "none";
2892
+ ghost.style.opacity = "0.9";
2893
+ ghost.style.boxShadow = "0 8px 16px rgba(0,0,0,0.2)";
2894
+ ghost.style.zIndex = "9999";
2895
+ document.body.appendChild(ghost);
2896
+ this.drag_ghost = ghost;
2897
+ this.drag_pointer_offset_y = current_y - rect.top;
2898
+ const placeholder = document.createElement("div");
2899
+ placeholder.style.height = `${rect.height}px`;
2900
+ placeholder.style.margin = getComputedStyle(block).margin;
2901
+ placeholder.style.border = "2px dashed #888";
2902
+ placeholder.style.borderRadius = "4px";
2903
+ placeholder.style.boxSizing = "border-box";
2904
+ if (block.parentElement !== null) {
2905
+ block.parentElement.insertBefore(placeholder, block);
2906
+ }
2907
+ this.drag_placeholder = placeholder;
2908
+ block.style.display = "none";
2909
+ this.updatePlaceholderPosition(current_y);
2910
+ }
2911
+ updatePlaceholderPosition(cursor_y) {
2912
+ const placeholder = this.drag_placeholder;
2913
+ const origin = this.drag_origin_block;
2914
+ if (!placeholder || !origin) {
2915
+ return;
2916
+ }
2917
+ const container = placeholder.parentElement;
2918
+ const blocks = this.getSiblingBlocks(container, origin);
2919
+ let inserted = false;
2920
+ for (let i = 0; i < blocks.length; i++) {
2921
+ const element = blocks[i];
2922
+ const rect = element.getBoundingClientRect();
2923
+ const midpoint = rect.top + rect.height / 2;
2924
+ if (cursor_y < midpoint) {
2925
+ const parent = element.parentElement;
2926
+ if (parent) {
2927
+ parent.insertBefore(placeholder, element);
2928
+ }
2929
+ inserted = true;
2930
+ break;
2931
+ }
2932
+ }
2933
+ if (!inserted) {
2934
+ const last_element = blocks[blocks.length - 1];
2935
+ if (last_element) {
2936
+ const parent = last_element.parentElement;
2937
+ if (parent) {
2938
+ parent.appendChild(placeholder);
2939
+ }
2940
+ }
2941
+ }
2942
+ }
2943
+ animateWithFlip(preceding_rects, blocks_after) {
2944
+ blocks_after.forEach((element) => {
2945
+ const first = preceding_rects.get(element);
2946
+ if (!first) {
2947
+ return;
2948
+ }
2949
+ const last_rect = element.getBoundingClientRect();
2950
+ const delta_y = first.top - last_rect.top;
2951
+ if (delta_y === 0) {
2952
+ return;
2953
+ }
2954
+ element.style.transition = "";
2955
+ element.style.transform = `translateY(${delta_y}px)`;
2956
+ void element.getBoundingClientRect();
2957
+ element.style.transition = "transform 120ms ease";
2958
+ element.style.transform = "translateY(0)";
2959
+ const cleanup = () => {
2960
+ element.style.transition = "";
2961
+ element.style.transform = "";
2962
+ element.removeEventListener("transitionend", cleanup);
2963
+ };
2964
+ element.addEventListener("transitionend", cleanup);
2965
+ });
2966
+ }
2967
+ async postReposition(source_index_path, target_index_path, editing) {
2968
+ const form = new FormData();
2969
+ form.set("path", window.location.pathname);
2970
+ form.set("action_type", action_type_default.REPOSITION_BLOCK);
2971
+ form.set("source_index_path", source_index_path);
2972
+ form.set("target_index_path", target_index_path);
2973
+ const response = await fetch(`/actions?editing=${editing}`, {
2974
+ method: "POST",
2975
+ body: form,
2976
+ credentials: "same-origin",
2977
+ redirect: "follow"
2978
+ });
2979
+ try {
2980
+ const url_object = new URL(response.url, window.location.origin);
2981
+ return url_object.searchParams.get("index_path");
2982
+ } catch (_) {
2983
+ return null;
2984
+ }
2985
+ }
2986
+ computeTargetIndexPath(placeholder) {
2987
+ if (!placeholder) {
2988
+ return null;
2989
+ }
2990
+ const parent = placeholder.parentElement;
2991
+ if (!parent) {
2992
+ return null;
2993
+ }
2994
+ let index = 0;
2995
+ const children_elements = Array.from(parent.children);
2996
+ for (let i = 0; i < children_elements.length; i++) {
2997
+ const child_element = children_elements[i];
2998
+ if (child_element === placeholder) {
2999
+ break;
3000
+ }
3001
+ if (child_element.classList.contains("block")) {
3002
+ index += 1;
3003
+ }
3004
+ }
3005
+ return index.toString();
3006
+ }
3007
+ updateTopLevelIndexPaths() {
3008
+ const wrapper = document.querySelector("main .section-wrapper");
3009
+ let blocks;
3010
+ if (wrapper) {
3011
+ const node_list = wrapper.querySelectorAll(":scope > section.block");
3012
+ blocks = Array.from(node_list);
3013
+ } else {
3014
+ const node_list = document.querySelectorAll("main > section.block");
3015
+ blocks = Array.from(node_list);
3016
+ }
3017
+ for (let i = 0; i < blocks.length; i++) {
3018
+ blocks[i].setAttribute("data-index-path", i.toString());
3019
+ }
3020
+ }
3021
+ cleanupDragElements() {
3022
+ if (this.drag_ghost && this.drag_ghost.parentElement) {
3023
+ this.drag_ghost.parentElement.removeChild(this.drag_ghost);
3024
+ }
3025
+ if (this.drag_placeholder && this.drag_placeholder.parentElement) {
3026
+ if (this.drag_origin_block) {
3027
+ this.drag_placeholder.parentElement.insertBefore(this.drag_origin_block, this.drag_placeholder);
3028
+ }
3029
+ this.drag_placeholder.parentElement.removeChild(this.drag_placeholder);
3030
+ }
3031
+ if (this.drag_origin_block) {
3032
+ this.drag_origin_block.style.display = "";
3033
+ }
3034
+ this.drag_ghost = null;
3035
+ this.drag_placeholder = null;
3036
+ document.body.style.userSelect = "";
3037
+ document.body.style.cursor = "";
3038
+ }
3039
+ resetDragState() {
3040
+ this.cleanupDragElements();
3041
+ this.drag_active = false;
3042
+ this.drag_origin_block = null;
3043
+ this.drag_start_y = null;
3044
+ this.drag_pointer_offset_y = null;
3045
+ }
3046
+ clearPressTimer() {
3047
+ if (this.drag_press_timer !== null) {
3048
+ window.clearTimeout(this.drag_press_timer);
3049
+ this.drag_press_timer = null;
3050
+ }
3051
+ }
3052
+ getEventPoint(event) {
3053
+ const touch_event = event;
3054
+ const has_touches = touch_event.touches !== void 0;
3055
+ if (has_touches) {
3056
+ const primary_touch = touch_event.touches[0] || touch_event.changedTouches[0];
3057
+ if (!primary_touch) {
3058
+ return null;
3059
+ }
3060
+ return {
3061
+ clientX: primary_touch.clientX,
3062
+ clientY: primary_touch.clientY
3063
+ };
3064
+ }
3065
+ const mouse_event = event;
3066
+ return {
3067
+ clientX: mouse_event.clientX,
3068
+ clientY: mouse_event.clientY
3069
+ };
3070
+ }
3071
+ };
3072
+ var interaction_default = InteractionHelper;
3073
+
3074
+ // src/client/page/cursor.ts
2258
3075
  var CursorPage = class extends page_default {
2259
3076
  constructor() {
2260
3077
  super();
2261
3078
  this.logged_in = false;
2262
3079
  this.queued_media = null;
2263
3080
  this.ready_media = [];
3081
+ this.drag_helper = new interaction_default();
2264
3082
  }
2265
3083
  initView() {
2266
3084
  this.focusCurrentBlockElement();
2267
3085
  const meta_value = get_meta_value_default("logged_in");
2268
3086
  this.logged_in = meta_value === "true";
3087
+ if (this.isLoggedIn()) {
3088
+ this.drag_helper.attach();
3089
+ }
2269
3090
  }
2270
3091
  initEvents() {
2271
3092
  super.initEvents();
@@ -2283,6 +3104,9 @@
2283
3104
  });
2284
3105
  }
2285
3106
  handleGenericClick(event) {
3107
+ if (this.drag_helper.isDragging()) {
3108
+ return;
3109
+ }
2286
3110
  if (!this.hasActiveMedia()) {
2287
3111
  return;
2288
3112
  }
@@ -2396,13 +3220,13 @@
2396
3220
  const link_id = `${block_id}-add-to-playlist`;
2397
3221
  const link_element = document.getElementById(link_id);
2398
3222
  if (link_element === null) {
2399
- throw new import_errors7.InvariantViolation(`
3223
+ throw new import_errors9.InvariantViolation(`
2400
3224
  Unable to find playlist link element for block: ${block_id}
2401
3225
  `);
2402
3226
  }
2403
3227
  const href = link_element.getAttribute("href");
2404
3228
  if (href === null) {
2405
- throw new import_errors7.InvariantViolation(`
3229
+ throw new import_errors9.InvariantViolation(`
2406
3230
  Unable to find playlist link href for block: ${block_id}
2407
3231
  `);
2408
3232
  }
@@ -2430,7 +3254,7 @@
2430
3254
  const form_id = `${block_id}-promote`;
2431
3255
  const form_element = document.getElementById(form_id);
2432
3256
  if (form_element === null) {
2433
- throw new import_errors7.InvariantViolation(`
3257
+ throw new import_errors9.InvariantViolation(`
2434
3258
  Unable to find promotion form element for block: ${block_id}
2435
3259
  `);
2436
3260
  }
@@ -2448,7 +3272,7 @@
2448
3272
  const form_id = `${block_id}-demote`;
2449
3273
  const form_element = document.getElementById(form_id);
2450
3274
  if (form_element === null) {
2451
- throw new import_errors7.InvariantViolation(`
3275
+ throw new import_errors9.InvariantViolation(`
2452
3276
  Unable to find demotion form element for block: ${block_id}
2453
3277
  `);
2454
3278
  }
@@ -2487,7 +3311,7 @@
2487
3311
  const block_elements = this.getBlockElements();
2488
3312
  let found = false;
2489
3313
  block_elements.forEach((block_element) => {
2490
- const sibling_path = getIndexPathForElement(block_element);
3314
+ const sibling_path = get_index_path_for_element_default(block_element);
2491
3315
  const is_match = sibling_path === index_path;
2492
3316
  block_element.classList.toggle("selected", is_match);
2493
3317
  if (is_match) {
@@ -2495,7 +3319,7 @@
2495
3319
  }
2496
3320
  });
2497
3321
  if (!found) {
2498
- throw new import_errors7.InvariantViolation(`
3322
+ throw new import_errors9.InvariantViolation(`
2499
3323
  Tried to navigate to element at index path ${index_path},
2500
3324
  but matching element was not found
2501
3325
  `);
@@ -2535,7 +3359,7 @@
2535
3359
  if (element === null) {
2536
3360
  return "0";
2537
3361
  }
2538
- return getIndexPathForElement(element);
3362
+ return get_index_path_for_element_default(element);
2539
3363
  }
2540
3364
  getCurrentBlockNumericIndex() {
2541
3365
  const index = this.getCurrentBlockIndex();
@@ -2564,7 +3388,7 @@
2564
3388
  return null;
2565
3389
  }
2566
3390
  const element = block_elements.find((element2) => {
2567
- const attribute = getIndexPathForElement(element2);
3391
+ const attribute = get_index_path_for_element_default(element2);
2568
3392
  return attribute === index_path;
2569
3393
  });
2570
3394
  return element || null;
@@ -2575,7 +3399,7 @@
2575
3399
  if (first_block === void 0) {
2576
3400
  return null;
2577
3401
  }
2578
- return getIndexPathForElement(first_block);
3402
+ return get_index_path_for_element_default(first_block);
2579
3403
  }
2580
3404
  getLastBlockIndex() {
2581
3405
  const blocks = this.getBlockElements();
@@ -2583,7 +3407,7 @@
2583
3407
  if (last_block === void 0) {
2584
3408
  return null;
2585
3409
  }
2586
- return getIndexPathForElement(last_block);
3410
+ return get_index_path_for_element_default(last_block);
2587
3411
  }
2588
3412
  getNextBlockIndex() {
2589
3413
  const current_block = this.getCurrentBlockElement();
@@ -2593,7 +3417,7 @@
2593
3417
  if (next_block === void 0) {
2594
3418
  return null;
2595
3419
  }
2596
- return getIndexPathForElement(next_block);
3420
+ return get_index_path_for_element_default(next_block);
2597
3421
  }
2598
3422
  getPreviousBlockIndex() {
2599
3423
  const current_block = this.getCurrentBlockElement();
@@ -2612,14 +3436,14 @@
2612
3436
  }
2613
3437
  const attribute = block_element.getAttribute("data-block-type");
2614
3438
  if (attribute === null) {
2615
- throw new import_errors7.InvariantViolation(`
3439
+ throw new import_errors9.InvariantViolation(`
2616
3440
  Tried to activate current block, but it did not have a block type
2617
3441
  `);
2618
3442
  }
2619
3443
  const block_type = attribute;
2620
3444
  const block_types = Object.values(block_type_default);
2621
3445
  if (!block_types.includes(block_type)) {
2622
- throw new import_errors7.InvariantViolation(`
3446
+ throw new import_errors9.InvariantViolation(`
2623
3447
  Invalid block type: ${block_type}
2624
3448
  `);
2625
3449
  }
@@ -2640,7 +3464,7 @@
2640
3464
  const forms = block_element.getElementsByTagName("form");
2641
3465
  const form = forms[0];
2642
3466
  if (form === void 0) {
2643
- throw new import_errors7.InvariantViolation(`
3467
+ throw new import_errors9.InvariantViolation(`
2644
3468
  Tried to activate form for todo block, but it was not set
2645
3469
  `);
2646
3470
  }
@@ -2657,7 +3481,7 @@
2657
3481
  activateAudioBlock(block_element) {
2658
3482
  const audio_element = block_element.querySelectorAll("audio")[0];
2659
3483
  if (audio_element === void 0) {
2660
- throw new import_errors7.InvariantViolation(`
3484
+ throw new import_errors9.InvariantViolation(`
2661
3485
  Tried to read audio element for block, but it was not present
2662
3486
  `);
2663
3487
  }
@@ -2678,11 +3502,11 @@
2678
3502
  this.pauseActiveMedia();
2679
3503
  const media_block = element.closest("section.block");
2680
3504
  if (media_block === null) {
2681
- throw new import_errors7.InvariantViolation(`
3505
+ throw new import_errors9.InvariantViolation(`
2682
3506
  Tried to access closest block wrapper for media, but it was not found
2683
3507
  `);
2684
3508
  }
2685
- const index_path = getIndexPathForElement(media_block);
3509
+ const index_path = get_index_path_for_element_default(media_block);
2686
3510
  this.navigateToIndex(index_path);
2687
3511
  this.focusCurrentBlockElement();
2688
3512
  const persistent_element = document.getElementById("persistent-audio");
@@ -2692,27 +3516,27 @@
2692
3516
  const track_source = media_block.querySelector('[data-role="track_name"]');
2693
3517
  const artist_source = media_block.querySelector('[data-role="artist_name"]');
2694
3518
  if (persistent_audio === null) {
2695
- throw new import_errors7.InvariantViolation(`
3519
+ throw new import_errors9.InvariantViolation(`
2696
3520
  Tried to access persistent audio element, but it was not found
2697
3521
  `);
2698
3522
  }
2699
3523
  if (track_target === null) {
2700
- throw new import_errors7.InvariantViolation(`
3524
+ throw new import_errors9.InvariantViolation(`
2701
3525
  Tried to access persistent track name element, but it was not found
2702
3526
  `);
2703
3527
  }
2704
3528
  if (artist_target === null) {
2705
- throw new import_errors7.InvariantViolation(`
3529
+ throw new import_errors9.InvariantViolation(`
2706
3530
  Tried to access persistent artist name element, but it was not found
2707
3531
  `);
2708
3532
  }
2709
3533
  if (track_source === null) {
2710
- throw new import_errors7.InvariantViolation(`
3534
+ throw new import_errors9.InvariantViolation(`
2711
3535
  Tried to read track name source, but it was not found
2712
3536
  `);
2713
3537
  }
2714
3538
  if (artist_source === null) {
2715
- throw new import_errors7.InvariantViolation(`
3539
+ throw new import_errors9.InvariantViolation(`
2716
3540
  Tried to read artist name source, but it was not found
2717
3541
  `);
2718
3542
  }
@@ -2737,7 +3561,7 @@
2737
3561
  if (block !== null) {
2738
3562
  const duration_label = block.querySelector('[data-role="duration"]');
2739
3563
  if (duration_label === null) {
2740
- throw new import_errors7.InvariantViolation(`
3564
+ throw new import_errors9.InvariantViolation(`
2741
3565
  Tried to read duration label for media block, but it was not found
2742
3566
  `);
2743
3567
  }
@@ -2840,7 +3664,7 @@
2840
3664
  var create_block_default = CreateBlockPage;
2841
3665
 
2842
3666
  // src/client/page/edit-block.ts
2843
- var import_errors8 = __toESM(require_src2());
3667
+ var import_errors10 = __toESM(require_src2());
2844
3668
  var EditBlockPage = class extends page_default {
2845
3669
  initEvents() {
2846
3670
  super.initEvents();
@@ -2857,7 +3681,7 @@
2857
3681
  }
2858
3682
  }
2859
3683
  if (form === void 0) {
2860
- throw new import_errors8.InvariantViolation(`
3684
+ throw new import_errors10.InvariantViolation(`
2861
3685
  Tried to read form for textarea, but it was not set
2862
3686
  `);
2863
3687
  }
@@ -2873,7 +3697,7 @@
2873
3697
  var edit_block_default = EditBlockPage;
2874
3698
 
2875
3699
  // src/client/page/view-custom.ts
2876
- var import_errors9 = __toESM(require_src2());
3700
+ var import_errors11 = __toESM(require_src2());
2877
3701
  var ViewCustomPage = class extends cursor_default {
2878
3702
  handleKey(key_code) {
2879
3703
  switch (key_code) {
@@ -2903,13 +3727,13 @@
2903
3727
  const link_id = `${block_id}-edit`;
2904
3728
  const link_element = document.getElementById(link_id);
2905
3729
  if (link_element === null) {
2906
- throw new import_errors9.InvariantViolation(`
3730
+ throw new import_errors11.InvariantViolation(`
2907
3731
  Unable to find edit link element for block: ${block_id}
2908
3732
  `);
2909
3733
  }
2910
3734
  const href = link_element.getAttribute("href");
2911
3735
  if (href === null) {
2912
- throw new import_errors9.InvariantViolation(`
3736
+ throw new import_errors11.InvariantViolation(`
2913
3737
  Unable to find edit link href for block: ${block_id}
2914
3738
  `);
2915
3739
  }
@@ -2922,7 +3746,7 @@
2922
3746
  const current_path = this.getCurrentBlockIndex();
2923
3747
  const top_level_index = parseInt(current_path, 10);
2924
3748
  if (isNaN(top_level_index)) {
2925
- throw new import_errors9.InvariantViolation(`Invalid index path: ${current_path}`);
3749
+ throw new import_errors11.InvariantViolation(`Invalid index path: ${current_path}`);
2926
3750
  }
2927
3751
  const add_block_links = document.querySelectorAll('[data-role="add_block_link"]');
2928
3752
  const link_index = (() => {
@@ -2934,14 +3758,14 @@
2934
3758
  })();
2935
3759
  const link = add_block_links[link_index];
2936
3760
  if (link === void 0) {
2937
- throw new import_errors9.InvariantViolation(`
3761
+ throw new import_errors11.InvariantViolation(`
2938
3762
  Tried to read link at index ${link_index},
2939
3763
  but it was not found
2940
3764
  `);
2941
3765
  }
2942
3766
  const href = link.getAttribute("href");
2943
3767
  if (href === null) {
2944
- throw new import_errors9.InvariantViolation(`
3768
+ throw new import_errors11.InvariantViolation(`
2945
3769
  Tried to read href for link at index ${link_index},
2946
3770
  but it was not set
2947
3771
  `);
@@ -2960,13 +3784,13 @@
2960
3784
  const link_id = `${block_id}-move`;
2961
3785
  const link_element = document.getElementById(link_id);
2962
3786
  if (link_element === null) {
2963
- throw new import_errors9.InvariantViolation(`
3787
+ throw new import_errors11.InvariantViolation(`
2964
3788
  Unable to find move link element for block: ${block_id}
2965
3789
  `);
2966
3790
  }
2967
3791
  const href = link_element.getAttribute("href");
2968
3792
  if (href === null) {
2969
- throw new import_errors9.InvariantViolation(`
3793
+ throw new import_errors11.InvariantViolation(`
2970
3794
  Unable to find move link href for block: ${block_id}
2971
3795
  `);
2972
3796
  }
@@ -2987,13 +3811,13 @@
2987
3811
  const link_id = `${block_id}-hide`;
2988
3812
  const link_element = document.getElementById(link_id);
2989
3813
  if (link_element === null) {
2990
- throw new import_errors9.InvariantViolation(`
3814
+ throw new import_errors11.InvariantViolation(`
2991
3815
  Unable to find hide link element for block: ${block_id}
2992
3816
  `);
2993
3817
  }
2994
3818
  const href = link_element.getAttribute("href");
2995
3819
  if (href === null) {
2996
- throw new import_errors9.InvariantViolation(`
3820
+ throw new import_errors11.InvariantViolation(`
2997
3821
  Unable to find hide link href for block: ${block_id}
2998
3822
  `);
2999
3823
  }
@@ -3004,13 +3828,13 @@
3004
3828
  const link_id = `${block_id}-delete`;
3005
3829
  const link_element = document.getElementById(link_id);
3006
3830
  if (link_element === null) {
3007
- throw new import_errors9.InvariantViolation(`
3831
+ throw new import_errors11.InvariantViolation(`
3008
3832
  Unable to find deletion link element for block: ${block_id}
3009
3833
  `);
3010
3834
  }
3011
3835
  const href = link_element.getAttribute("href");
3012
3836
  if (href === null) {
3013
- throw new import_errors9.InvariantViolation(`
3837
+ throw new import_errors11.InvariantViolation(`
3014
3838
  Unable to find deletion link href for block: ${block_id}
3015
3839
  `);
3016
3840
  }
@@ -3039,7 +3863,7 @@
3039
3863
  var edit_custom_default = EditCustomPage;
3040
3864
 
3041
3865
  // src/client/page/confirm-delete-block.ts
3042
- var import_errors10 = __toESM(require_src2());
3866
+ var import_errors12 = __toESM(require_src2());
3043
3867
  var ConfirmDeleteBlockPage = class extends page_default {
3044
3868
  handleKey(key_code) {
3045
3869
  switch (key_code) {
@@ -3052,7 +3876,7 @@
3052
3876
  submitDeletionForm() {
3053
3877
  const element = document.getElementById("deletion-form");
3054
3878
  if (element === null) {
3055
- throw new import_errors10.InvariantViolation("Could not find deletion form element");
3879
+ throw new import_errors12.InvariantViolation("Could not find deletion form element");
3056
3880
  }
3057
3881
  const form = element;
3058
3882
  form.submit();
@@ -3061,7 +3885,7 @@
3061
3885
  var confirm_delete_block_default = ConfirmDeleteBlockPage;
3062
3886
 
3063
3887
  // src/client/page/confirm-hide-block.ts
3064
- var import_errors11 = __toESM(require_src2());
3888
+ var import_errors13 = __toESM(require_src2());
3065
3889
  var ConfirmHideBlockPage = class extends page_default {
3066
3890
  handleKey(key_code) {
3067
3891
  switch (key_code) {
@@ -3074,7 +3898,7 @@
3074
3898
  submitHideForm() {
3075
3899
  const element = document.getElementById("hide-form");
3076
3900
  if (element === null) {
3077
- throw new import_errors11.InvariantViolation("Could not find hide form element");
3901
+ throw new import_errors13.InvariantViolation("Could not find hide form element");
3078
3902
  }
3079
3903
  const form = element;
3080
3904
  form.submit();
@@ -3167,7 +3991,7 @@
3167
3991
  const page_type = meta_value;
3168
3992
  const page_types = Object.values(page_type_default);
3169
3993
  if (!page_types.includes(page_type)) {
3170
- throw new import_errors12.InvariantViolation(`
3994
+ throw new import_errors14.InvariantViolation(`
3171
3995
  Invalid page type: ${page_type}
3172
3996
  `);
3173
3997
  }