@inkandswitch/patchwork-pkg-base 0.0.103 → 0.0.105

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.
@@ -1 +1 @@
1
- automerge:2xqDXSFJN2sgoBiuiZpFfdhfnZZ6
1
+ automerge:pW693NUXNtYLMaCeYJPjHfNRyGp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkandswitch/patchwork-pkg-base",
3
- "version": "0.0.103",
3
+ "version": "0.0.105",
4
4
  "type": "module",
5
5
  "description": "Base packages for the Patchwork system",
6
6
  "repository": {
@@ -41,6 +41,7 @@ const STYLES = `
41
41
  box-sizing: border-box;
42
42
  overflow: hidden;
43
43
  user-select: none;
44
+ outline: none;
44
45
  }
45
46
  .patternwitch * { box-sizing: border-box; }
46
47
 
@@ -319,6 +320,8 @@ const TOOL_CURSORS = Object.fromEntries(
319
320
  export default function PatternWitchTool(handle, element) {
320
321
  const root = document.createElement("div");
321
322
  root.className = "patternwitch";
323
+ // Focusable, so keyboard shortcuts only fire while you're in this tool.
324
+ root.tabIndex = -1;
322
325
  const style = document.createElement("style");
323
326
  style.textContent = STYLES;
324
327
  element.append(style, root);
@@ -327,52 +330,108 @@ export default function PatternWitchTool(handle, element) {
327
330
  let activeColor = 0;
328
331
  let activeTool = "draw"; // "draw" | "fill"
329
332
  let showSettings = false;
330
- const history = []; // stack of pixel snapshots for undo (local)
331
- const HISTORY_MAX = 40;
333
+ const HISTORY_MAX = 200;
332
334
 
333
335
  // ---- helpers ----
334
336
  const getDoc = () => handle.doc();
335
337
  const clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
336
338
  const snapshot = () => getDoc().pixels.map((row) => row.slice());
337
339
 
338
- function pushHistory(pixels = snapshot()) {
339
- history.push(pixels);
340
+ // ============================================================
341
+ // Undo: commands, not snapshots
342
+ // ============================================================
343
+ // An op makes a change to the doc and returns the op that reverses it (or
344
+ // null if it changed nothing). Undoing an op returns the op that redoes it,
345
+ // so the same shape runs both ways.
346
+ //
347
+ // Inverses only touch what this user did, and they check before they write:
348
+ // a cell a peer has painted since is left alone. So undo stays local while
349
+ // someone else is drawing on the same canvas.
350
+ const history = []; // inverse ops, for undo (local)
351
+ const future = []; // inverse-of-inverse ops, for redo (local)
352
+
353
+ function run(op) {
354
+ const inverse = op();
355
+ if (!inverse) return;
356
+ history.push(inverse);
340
357
  if (history.length > HISTORY_MAX) history.shift();
358
+ future.length = 0; // a new edit forks history; the old future is gone
359
+ }
360
+
361
+ function undo() {
362
+ const op = history.pop();
363
+ if (!op) return;
364
+ const redoOp = op();
365
+ if (redoOp) future.push(redoOp);
341
366
  }
342
367
 
343
- // Write a whole grid cell by cell, so concurrent edits from peers merge
344
- // instead of fighting over replaced rows.
345
- function writePixels(next) {
368
+ function redo() {
369
+ const op = future.pop();
370
+ if (!op) return;
371
+ const undoOp = op();
372
+ if (undoOp) history.push(undoOp);
373
+ }
374
+
375
+ // Run several ops as one; the inverse runs their inverses backwards.
376
+ const sequence = (ops) => () => {
377
+ const inverses = ops.map((op) => op()).filter(Boolean).reverse();
378
+ return inverses.length ? sequence(inverses) : null;
379
+ };
380
+
381
+ // Set cells, each [x, y, to, expected?]. With `expected`, a cell is only
382
+ // written if it still holds that value, which is how inverses avoid
383
+ // clobbering peers. Cell by cell, never whole rows: replacing rows makes
384
+ // concurrent edits merge as list insertions, shifting pixels sideways.
385
+ function paintOp(cells) {
386
+ const done = [];
346
387
  handle.change((d) => {
347
- if (d.height !== next.length || d.width !== next[0].length) {
348
- d.height = next.length;
349
- d.width = next[0].length;
350
- d.pixels = next;
351
- return;
388
+ for (const [x, y, to, expected] of cells) {
389
+ if (y >= d.height || x >= d.width) continue;
390
+ const current = d.pixels[y][x];
391
+ if (expected !== undefined && current !== expected) continue;
392
+ if (current === to) continue;
393
+ d.pixels[y][x] = to;
394
+ done.push([x, y, current, to]);
352
395
  }
353
- for (let y = 0; y < d.height; y++)
354
- for (let x = 0; x < d.width; x++)
355
- if (d.pixels[y][x] !== next[y][x]) d.pixels[y][x] = next[y][x];
356
396
  });
397
+ return done.length ? () => paintOp(done) : null;
357
398
  }
358
399
 
359
- // Resize the grid, preserving overlapping pixels.
360
- function resize(newW, newH, record = true) {
400
+ // Every cell where `next` differs from the doc, as paintOp cells.
401
+ function diffCells(next) {
402
+ const { pixels } = getDoc();
403
+ const cells = [];
404
+ for (let y = 0; y < next.length; y++)
405
+ for (let x = 0; x < next[y].length; x++)
406
+ if (pixels[y][x] !== next[y][x]) cells.push([x, y, next[y][x]]);
407
+ return cells;
408
+ }
409
+
410
+ // Resize in place (trim / extend rows and columns) so cells inside both
411
+ // sizes are never rewritten and peers' paint there survives. The inverse
412
+ // resizes back and restores the cropped cells, unless something has since
413
+ // been painted over the blank space they come back into.
414
+ function resizeOp(newW, newH) {
361
415
  newW = clamp(Math.round(newW), MIN_SIZE, MAX_SIZE);
362
416
  newH = clamp(Math.round(newH), MIN_SIZE, MAX_SIZE);
363
- const doc = getDoc();
364
- if (newW === doc.width && newH === doc.height) return;
365
- if (record) pushHistory();
366
- const old = doc.pixels;
367
- const next = makePixels(newW, newH, 0);
368
- for (let y = 0; y < Math.min(newH, doc.height); y++)
369
- for (let x = 0; x < Math.min(newW, doc.width); x++)
370
- next[y][x] = old[y][x];
417
+ const { width: oldW, height: oldH } = getDoc();
418
+ if (newW === oldW && newH === oldH) return null;
419
+ const cropped = [];
371
420
  handle.change((d) => {
421
+ for (let y = 0; y < oldH; y++)
422
+ for (let x = y < newH ? newW : 0; x < oldW; x++)
423
+ if (d.pixels[y][x] !== 0) cropped.push([x, y, d.pixels[y][x], 0]);
424
+ if (oldH > newH) d.pixels.splice(newH, oldH - newH);
425
+ for (let y = 0; y < Math.min(oldH, newH); y++) {
426
+ const row = d.pixels[y];
427
+ if (oldW > newW) row.splice(newW, oldW - newW);
428
+ else if (newW > oldW) row.push(...new Array(newW - oldW).fill(0));
429
+ }
430
+ for (let y = oldH; y < newH; y++) d.pixels.push(new Array(newW).fill(0));
372
431
  d.width = newW;
373
432
  d.height = newH;
374
- d.pixels = next;
375
433
  });
434
+ return sequence([() => resizeOp(oldW, oldH), () => paintOp(cropped)]);
376
435
  }
377
436
 
378
437
  function floodFill(sx, sy, target) {
@@ -380,7 +439,6 @@ export default function PatternWitchTool(handle, element) {
380
439
  const { width, height } = doc;
381
440
  const from = doc.pixels[sy][sx];
382
441
  if (from === target) return;
383
- const before = snapshot();
384
442
  const grid = snapshot();
385
443
  const stack = [[sx, sy]];
386
444
  while (stack.length) {
@@ -390,19 +448,14 @@ export default function PatternWitchTool(handle, element) {
390
448
  grid[y][x] = target;
391
449
  stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
392
450
  }
393
- pushHistory(before);
394
- writePixels(grid);
395
- }
396
-
397
- function undo() {
398
- if (!history.length) return;
399
- writePixels(history.pop());
451
+ const cells = diffCells(grid);
452
+ run(() => paintOp(cells));
400
453
  }
401
454
 
402
455
  function clearAll() {
403
- const doc = getDoc();
404
- pushHistory();
405
- writePixels(makePixels(doc.width, doc.height, activeColor));
456
+ const { width, height } = getDoc();
457
+ const cells = diffCells(makePixels(width, height, activeColor));
458
+ run(() => paintOp(cells));
406
459
  }
407
460
 
408
461
  // ============================================================
@@ -411,11 +464,11 @@ export default function PatternWitchTool(handle, element) {
411
464
  root.innerHTML = `
412
465
  <div class="toolbar">
413
466
  <div class="tool-group">
414
- <button class="btn" data-tool="draw" title="Draw">${icon("pencil")}</button>
415
- <button class="btn" data-tool="fill" title="Fill">${icon("fill")}</button>
467
+ <button class="btn" data-tool="draw" title="Brush (B)">${icon("pencil")}</button>
468
+ <button class="btn" data-tool="fill" title="Fill (F)">${icon("fill")}</button>
416
469
  </div>
417
470
  <div class="tool-group">
418
- <button class="btn" data-act="undo" title="Undo">${icon("undo")}</button>
471
+ <button class="btn" data-act="undo" title="Undo (⌘Z)">${icon("undo")}</button>
419
472
  <button class="btn" data-act="clear" data-danger title="Clear all">${icon("trash")}</button>
420
473
  </div>
421
474
  <div class="spacer"></div>
@@ -532,7 +585,6 @@ export default function PatternWitchTool(handle, element) {
532
585
  let painting = false;
533
586
  let strokeCells = null; // Map<"x,y", colour> of pending changes
534
587
  let lastCell = null; // last painted cell in the current stroke
535
- let strokeBefore = null; // pixels as they were when the stroke started
536
588
 
537
589
  function paintCell(x, y) {
538
590
  const k = `${x},${y}`;
@@ -566,21 +618,15 @@ export default function PatternWitchTool(handle, element) {
566
618
  }
567
619
  }
568
620
 
569
- // Commit cell by cell: replacing whole rows makes concurrent edits merge as
570
- // list insertions, which shifts pixels sideways and duplicates them.
571
621
  function commitStroke() {
572
- const cells = strokeCells;
573
- const before = strokeBefore;
622
+ const pending = strokeCells;
574
623
  strokeCells = null;
575
- strokeBefore = null;
576
- if (!cells || cells.size === 0) return;
577
- pushHistory(before);
578
- handle.change((d) => {
579
- for (const [k, color] of cells) {
580
- const [x, y] = k.split(",").map(Number);
581
- if (y < d.height && x < d.width) d.pixels[y][x] = color;
582
- }
624
+ if (!pending || pending.size === 0) return;
625
+ const cells = [...pending].map(([k, color]) => {
626
+ const [x, y] = k.split(",").map(Number);
627
+ return [x, y, color];
583
628
  });
629
+ run(() => paintOp(cells));
584
630
  }
585
631
 
586
632
  canvas.addEventListener("pointerdown", (e) => {
@@ -593,7 +639,6 @@ export default function PatternWitchTool(handle, element) {
593
639
  }
594
640
  painting = true;
595
641
  strokeCells = new Map();
596
- strokeBefore = snapshot();
597
642
  canvas.setPointerCapture(e.pointerId);
598
643
  paintCell(c.x, c.y);
599
644
  lastCell = c;
@@ -622,11 +667,48 @@ export default function PatternWitchTool(handle, element) {
622
667
  // Toolbar / actions
623
668
  // ============================================================
624
669
  root.querySelectorAll("[data-tool]").forEach((el) => {
625
- el.addEventListener("click", () => {
626
- activeTool = el.dataset.tool;
627
- renderToolbar();
628
- });
670
+ el.addEventListener("click", () => setTool(el.dataset.tool));
671
+ });
672
+ function setTool(tool) {
673
+ activeTool = tool;
674
+ renderToolbar();
675
+ }
676
+
677
+ // Shortcuts, scoped to this tool: the listener is on our root, which only
678
+ // sees keys while focus is inside it. Text-ish inputs in the settings modal
679
+ // keep their own keys.
680
+ root.addEventListener("keydown", (e) => {
681
+ if (e.target.closest("input, textarea, select, [contenteditable]")) return;
682
+ const key = e.key.toLowerCase();
683
+ const mod = e.metaKey || e.ctrlKey;
684
+ if (mod && !e.altKey && key === "z") {
685
+ e.preventDefault();
686
+ e.stopPropagation();
687
+ if (e.shiftKey) redo();
688
+ else undo();
689
+ return;
690
+ }
691
+ if (mod || e.altKey || e.shiftKey) return;
692
+ if (key === "b") setTool("draw");
693
+ else if (key === "f") setTool("fill");
694
+ else if (/^[0-9]$/.test(key)) {
695
+ // 1–9 then 0, like the number row: 1 is the first colour, 0 the tenth.
696
+ const i = key === "0" ? 9 : Number(key) - 1;
697
+ if (i >= getDoc().palette.length) return;
698
+ activeColor = i;
699
+ renderPalette();
700
+ } else return;
701
+ e.preventDefault();
702
+ e.stopPropagation();
703
+ });
704
+
705
+ // Clicking anywhere in the tool (including the canvas) takes focus, so the
706
+ // shortcuts work straight after painting.
707
+ root.addEventListener("pointerdown", (e) => {
708
+ if (e.target.closest("input")) return;
709
+ root.focus({ preventScroll: true });
629
710
  });
711
+
630
712
  root.querySelector('[data-act="undo"]').addEventListener("click", undo);
631
713
  root.querySelector('[data-act="clear"]').addEventListener("click", clearAll);
632
714
  root.querySelector('[data-act="settings"]').addEventListener("click", () => {
@@ -647,17 +729,19 @@ export default function PatternWitchTool(handle, element) {
647
729
  const rect = canvas.getBoundingClientRect();
648
730
  const step = Math.max(4, rect.width / doc.width); // px per cell
649
731
  grip.setPointerCapture(e.pointerId);
650
- pushHistory(); // one undo entry for the whole drag
732
+ const steps = []; // each step's inverse; one undo entry for the whole drag
651
733
 
652
734
  const onMove = (ev) => {
653
735
  const dW = Math.round((ev.clientX - startX) / step);
654
736
  const dH = Math.round((ev.clientY - startY) / step);
655
- resize(startW + dW, startH + dH, false);
737
+ const inverse = resizeOp(startW + dW, startH + dH);
738
+ if (inverse) steps.push(inverse);
656
739
  };
657
740
  const onUp = (ev) => {
658
741
  grip.releasePointerCapture(ev.pointerId);
659
742
  grip.removeEventListener("pointermove", onMove);
660
743
  grip.removeEventListener("pointerup", onUp);
744
+ if (steps.length) run(() => sequence(steps.reverse()));
661
745
  };
662
746
  grip.addEventListener("pointermove", onMove);
663
747
  grip.addEventListener("pointerup", onUp);
@@ -744,10 +828,9 @@ export default function PatternWitchTool(handle, element) {
744
828
  });
745
829
 
746
830
  modal.querySelector("[data-apply-size]").addEventListener("click", () => {
747
- resize(
748
- Number(modal.querySelector('[data-dim="w"]').value),
749
- Number(modal.querySelector('[data-dim="h"]').value),
750
- );
831
+ const w = Number(modal.querySelector('[data-dim="w"]').value);
832
+ const h = Number(modal.querySelector('[data-dim="h"]').value);
833
+ run(() => resizeOp(w, h));
751
834
  });
752
835
 
753
836
  modal.querySelector("[data-close]").addEventListener("click", () => {
@@ -759,21 +842,49 @@ export default function PatternWitchTool(handle, element) {
759
842
  modalMount.append(backdrop);
760
843
  }
761
844
 
762
- // Remove a palette colour and remap pixels that referenced it.
763
845
  function removeColor(index) {
764
- pushHistory();
846
+ run(() => removeColorOp(index));
847
+ }
848
+
849
+ // Remove a palette colour and remap pixels that referenced it: its own
850
+ // pixels become colour 0, and higher indices shift down by one.
851
+ function removeColorOp(index) {
852
+ const hex = getDoc().palette[index];
853
+ const orphans = new Set(); // "x,y" of pixels that were this colour
765
854
  handle.change((d) => {
766
855
  d.palette.splice(index, 1);
767
856
  const max = d.palette.length - 1;
768
857
  for (let y = 0; y < d.height; y++)
769
858
  for (let x = 0; x < d.width; x++) {
770
859
  let v = d.pixels[y][x];
771
- if (v === index) v = 0;
772
- else if (v > index) v = v - 1;
860
+ if (v === index) {
861
+ orphans.add(`${x},${y}`);
862
+ v = 0;
863
+ } else if (v > index) v = v - 1;
773
864
  v = clamp(v, 0, max);
774
865
  if (d.pixels[y][x] !== v) d.pixels[y][x] = v;
775
866
  }
776
867
  });
868
+ return () => insertColorOp(index, hex, orphans);
869
+ }
870
+
871
+ // Inverse of removeColorOp. Every index at or above `index` shifts back up,
872
+ // including pixels peers painted in the meantime, since those were painted
873
+ // against the shorter palette. Orphans get their colour back if they're
874
+ // still colour 0; one a peer has repainted keeps the peer's colour.
875
+ function insertColorOp(index, hex, orphans) {
876
+ handle.change((d) => {
877
+ d.palette.splice(index, 0, hex);
878
+ for (let y = 0; y < d.height; y++)
879
+ for (let x = 0; x < d.width; x++) {
880
+ const v = d.pixels[y][x];
881
+ let next = v;
882
+ if (v === 0 && orphans.has(`${x},${y}`)) next = index;
883
+ else if (v >= index) next = v + 1;
884
+ if (next !== v) d.pixels[y][x] = next;
885
+ }
886
+ });
887
+ return () => removeColorOp(index);
777
888
  }
778
889
 
779
890
  // ============================================================
@@ -0,0 +1,2 @@
1
+ import{r as a,s as b}from"./chunk-LNR6ATYD.js";import"./chunk-FW4363Y4.js";export{a as IsolatedDocumentArea,b as mountIsolationRoot};
2
+ //# sourceMappingURL=IsolatedDocumentArea-7EWDRVFG.js.map
@@ -1,2 +1,2 @@
1
- import{a as M,b as ce,c as H,d as U}from"./chunk-YERFWP5I.js";import{a as Ie,b as B,c as j,d as te,e as re,f as oe,g as ne,h as ie,i as ae,j as le,k as se,l as P,m as F,n as W,o as de,p as ue,q as me,r as fe}from"./chunk-MSZ7JVNB.js";import{b as Ue}from"./chunk-FW4363Y4.js";import{template as _}from"solid-js/web";import{delegateEvents as et}from"solid-js/web";import{memo as tt}from"solid-js/web";import{setStyleProperty as rt}from"solid-js/web";import{setAttribute as Y}from"solid-js/web";import{effect as R}from"solid-js/web";import{getOwner as k}from"solid-js/web";import{use as C}from"solid-js/web";import{insert as v}from"solid-js/web";import{createComponent as m}from"solid-js/web";import"@inkandswitch/patchwork-elements";import{subscribe as ft}from"@inkandswitch/patchwork-providers";import{template as q}from"solid-js/web";import{delegateEvents as Re}from"solid-js/web";import{memo as Le}from"solid-js/web";import{insert as pe}from"solid-js/web";import{createComponent as I}from"solid-js/web";import{For as Pe,Show as z}from"solid-js";var Ae=q("<div class=threepane-widgets>"),xe=q("<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list"),Oe=q("<div class=threepane-widget>");function he(e){let l=()=>{let o=e.rootFolderUrl(),a=e.configHandle();!o||!a||a.change(r=>{r.sidebar.widgets.push([H,o])})};return(()=>{var o=Ae();return pe(o,I(z,{get when(){return e.ready()},get children(){return I(z,{get when(){return e.widgets().length},get fallback(){return I(z,{get when(){return Le(()=>!!e.rootFolderUrl())()&&e.configHandle()},get children(){var a=xe(),r=a.firstChild;return r.$$click=l,a}})},get children(){return I(Pe,{get each(){return e.widgets()},children:a=>(()=>{var r=Oe();return pe(r,I(W,{slot:a})),r})()})}})}})),o})()}Re(["click"]);import{template as we}from"solid-js/web";import{setAttribute as Fe}from"solid-js/web";import{effect as We}from"solid-js/web";import{insert as ge}from"solid-js/web";import{createComponent as K}from"solid-js/web";import{For as Ne,Show as Ve}from"solid-js";var Me=we("<div class=frame-tray>"),He=we("<div class=frame-tray__item>");function ve(e){return K(Ve,{get when(){return e.slots().length},get children(){var l=Me();return ge(l,K(Ne,{get each(){return F(e.slots())},children:o=>(()=>{var a=He();return ge(a,K(W,{slot:o})),We(()=>Fe(a,"data-tray-id",P(o))),a})()})),l}})}import{createEffect as V,createMemo as pt,createSignal as b,onCleanup as L,onMount as ke,Show as S}from"solid-js";import{render as ht}from"solid-js/web";import{createDocOfDatatype2 as je}from"@inkandswitch/patchwork-plugins";import{getRegistry as Be}from"@inkandswitch/patchwork-plugins";function N(e){return Be("patchwork:datatype").loadWhenReady(e)}var ze=new Set(["document-title","spacer"]);function _e(e){return e?[[H,e]]:[]}function qe(e,l){if(!((e.version??0)>=1)){if(e.sidebar||(e.sidebar={widgets:[]}),l&&!e.sidebar.widgets?.length&&(e.sidebar.widgets=_e(l)),!e.tray)e.tray=M.slice();else{let o=F(e.tray);o.length!==e.tray.length&&(e.tray=o);let a=new Set(e.tray.map(r=>P(r)));for(let r of M)a.has(r)||(e.tray.push(r),a.add(r))}e.doctitle?.tools?.length||(e.doctitle={...e.doctitle,tools:ce.slice()}),!(!e.sidebar.widgets?.length&&!l)&&(e.version=1)}}async function ye(e,l){let o=e.doc()?.rootFolderUrl,a=e.doc()?.tools?.threepane;if(a){let i=await l.find(a);if((i.doc()?.version??0)>=1)return;i.change(u=>qe(u,o));return}let r=await N("threepane:config");if(!r){console.warn("frame: threepane:config datatype never registered");return}if(e.doc()?.tools?.threepane)return;let t=e.doc(),n=(t?.documentToolbarToolIds??[]).filter(i=>!ze.has(i)),s=await je(r,l);s.change(i=>{n.length&&(i.doctitle.tools=n),i.sidebar.widgets=_e(t?.rootFolderUrl),i.tray||(i.tray=M.slice()),t?.rootFolderUrl?i.version=1:delete i.version}),e.change(i=>{i.tools||(i.tools={}),i.tools.threepane||(i.tools.threepane=s.url)})}var Se=Ue(Ie(),1);import{createDocOfDatatype2 as Ke}from"@inkandswitch/patchwork-plugins";var g=(0,Se.default)("patchwork:threepane:examples");async function $e(e,l){let o=e.doc();if(!o?.rootFolderUrl){g("skipped \u2014 account has no rootFolderUrl");return}if(o.exampleDocsSeededAt){g("skipped \u2014 already ran for this account at",new Date(o.exampleDocsSeededAt).toISOString());return}g("claiming marker on account",e.url),e.change(d=>{d.exampleDocsSeededAt||(d.exampleDocsSeededAt=Date.now())});let a=await l.find(o.rootFolderUrl),r=a.doc()?.docs?.length??0;if(r){g(`skipped \u2014 root folder already has ${r} doc(s); only fresh accounts are seeded`);return}let t=window.location.hostname.includes("gaios"),n=t?[]:await Ye();if(g(t?"gaios examples":"bundle init scripts:",n),!t&&!n.length){g("skipped \u2014 no static module bundles to ask");return}let s=await N("folder");if(!s){g("folder datatype never registered; giving up");return}let i=await Ke(s,l,d=>{d.title="Examples"});if(t){let{seedGaiosExamples:d}=await import("./gaiosExamples-YDNQB35L.js");await d(l,i)}for(let d of n)try{await(await import(d)).default?.(l,i),g("ran init script",d)}catch(c){g("init script unavailable or failed",d,c)}let u=i.doc()?.docs?.length??0;if(!u){g("no bundle contributed any documents");return}a.change(d=>{d.docs.unshift({name:"Examples",type:"folder",url:i.url})}),g(`seeded ${u} document(s) into Examples folder`,i.url)}var be="https://patchwork-tools.netlify.app/init.js",De="https://patchwork-base.netlify.app/init.js";function Ge(){return document.documentElement.getAttribute("data-examples")==="site"}async function Ye(){let e=Ge(),l=window.patchwork?.packages;if(!l?.urls)return e?[]:[De,be];await l.doneLoading;let o=Object.values(l.urls).filter(r=>typeof r=="string"&&!r.startsWith("automerge:")).map(r=>new URL("init.js",new URL(r,document.baseURI)).href);if(e)return[...new Set(o)];let a=o.length?[]:[De];return[...new Set([...o,...a,be])]}import{createEffect as Xe,createMemo as Je,createSignal as Qe,onCleanup as Ze}from"solid-js";function G(e){let[l,o]=Qe(0);return Xe(()=>{let a=e();if(!a)return;let r=()=>o(t=>t+1);a.on("change",r),Ze(()=>a.off("change",r))}),Je(()=>(l(),e()?.doc()))}var ot=_("<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider><patchwork-view component=patchwork-worker-provider>",!0,!1,!1),nt=_("<div style=display:contents>"),it=_("<div class=main-area>"),at=_("<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>",!0,!1,!1),lt=_('<button type=button class="frame__sidebar-toggle frame__left-toggle">'),st=_("<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings"),ct=_("<div class=frame__tray-dock>"),dt=_('<button type=button class="threepane-account-bar__button threepane-account-bar__avatar"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>',!0,!1,!1),ut=_("<button type=button class=threepane-account-bar__button>Packages"),mt=_('<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox="0 0 24 24"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d="M9 3v18">'),X=(e,l)=>{let[o,a]=b(!1);return V(()=>{let r=l();if(!r)return;a(!1);let t=n=>{n.detail?.componentId===e&&a(!0)};r.addEventListener("patchwork:mounted",t),L(()=>r.removeEventListener("patchwork:mounted",t))}),o};function J(e,l){e.dispatchEvent(new CustomEvent("patchwork:open-document",{detail:l,bubbles:!0,composed:!0}))}function gt({handle:e,repo:l,...o}){me();let a=e.url,[r,t]=b(),n=X("patchwork-account-provider",r),[s,i]=b(),u=X("patchwork-tool-storage-provider",s),[d,c]=b(),f=X("patchwork-selected-doc-provider",d),p=pt(()=>f()&&n()&&u());return(()=>{var w=ot(),E=w.firstChild,Q=E.firstChild,A=E.nextSibling,h=A.firstChild,D=h.firstChild,$=D.firstChild,T=$.firstChild;return v(E,m(S,{get when(){return o.isolation},get children(){return[" ","isolation is highly experimental. if things are broken, switch back to wild west."]}}),null),C(c,h),h._$owner=k(),C(t,D),D.docUrl=a,D._$owner=k(),C(i,$),$.docUrl=a,$._$owner=k(),T._$owner=k(),v(T,m(S,{get when(){return p()},get children(){return m(wt,{handle:e,repo:l,get isolation(){return o.isolation}})}})),w})()}function wt(e){let l=B(()=>e.handle.url,{repo:e.repo});(async()=>{await ye(e.handle,e.repo),await $e(e.handle,e.repo)})().catch(y=>{console.error("frame: account bootstrap failed",y)});let o=G(l),a=e.handle.url,r=()=>o()?.tools?.threepane,t=B(()=>r(),{repo:e.repo}),n=G(t),s=()=>n()?.doctitle?.tools,i=()=>n()?.sidebar?.widgets??[],u=()=>n()?.tray??[],d=()=>o()?.rootFolderUrl,c=ie(),f=ae("left",{isCollapsed:c.isSidebarCollapsed,setCollapsed:c.setIsSidebarCollapsed,setWidth:c.setLeftSidebarWidth}),p,[w,E]=b(null),[Q,A]=b(null);ke(()=>{let y=ft(p,{type:"patchwork:selected-view"},x=>E(x));L(y)});let h=()=>w()?.url,D=()=>w()?.toolId??void 0,$=()=>oe(j.rightWidth,re),T=()=>ne(j.rightCollapsed),[Ce,Z]=b(),Ee=le(Ce,h),[ee,Te]=b(!1);return V(()=>{ee()||(e.isolation||!h()||Ee())&&Te(!0)}),(()=>{var y=nt(),x=p;return typeof x=="function"?C(x,y):p=y,v(y,m(_t,{accountDocUrl:a,sidebarState:c,sidebarResize:f,sidebarWidgets:i,traySlots:u,configHandle:t,rootFolderUrl:d,widgetsReady:ee,contactUrl:()=>o()?.contactUrl,moduleSettingsUrl:()=>o()?.moduleSettingsUrl,get isolation(){return e.isolation},onInterceptOpen:A,get children(){return m(S,{get when(){return h()},get fallback(){return(()=>{var O=it();return v(O,m(de,{viewKey:h,selectedDocUrl:h,toolId:D,ref:Z})),O})()},get children(){return m(S,{get when(){return e.isolation},get fallback(){return m(ue,{setMainDocElement:Z,selectedDocUrl:h,selectedToolId:D,doctitleSlots:s,get isLeftCollapsed(){return c.isSidebarCollapsed},initialRightWidth:$,initialRightCollapsed:T})},get children(){return m(fe,{get contactUrl(){return o()?.contactUrl},selectedDocUrl:h,selectedToolId:D,doctitleSlots:s,get isLeftCollapsed(){return c.isSidebarCollapsed},initialRightWidth:$,initialRightCollapsed:T})}})}})}}),null),v(y,m(S,{get when(){return Q()},children:O=>m(vt,{get view(){return O()},onClose:()=>A(null)})}),null),y})()}function vt(e){let[l,o]=b(e.view.toolId??void 0);V(()=>o(e.view.toolId??void 0));let a;return ke(()=>{let r=s=>{s.key==="Escape"&&e.onClose()};window.addEventListener("keydown",r),L(()=>window.removeEventListener("keydown",r));let t=a;if(!t)return;let n=s=>{let{url:i,toolId:u}=s.detail;i&&(s.stopPropagation(),o(u??void 0))};t.addEventListener("patchwork:open-document",n),L(()=>t.removeEventListener("patchwork:open-document",n))}),(()=>{var r=at(),t=r.firstChild,n=t.firstChild,s=n.firstChild,i=n.nextSibling,u=i.firstChild;r.$$click=()=>e.onClose(),t.$$click=c=>c.stopPropagation();var d=a;return typeof d=="function"?C(d,t):a=t,s._$owner=k(),u._$owner=k(),R(c=>{var f=e.view.url,p=e.view.url,w=l();return f!==c.e&&(s.docUrl=c.e=f),p!==c.t&&(u.docUrl=c.t=p),w!==c.a&&(u.toolId=c.a=w),c},{e:void 0,t:void 0,a:void 0}),r})()}function _t(e){let l=e.sidebarState.isSidebarCollapsed,o=()=>e.traySlots().length>0,a,r;return V(()=>{if(l())return;let t=a;if(!t)return;let n=r,s=i=>{let{url:u,toolId:d}=i.detail;if(e.isolation&&u&&n&&i.composedPath().includes(n)){i.stopPropagation(),e.onInterceptOpen?.({url:u,toolId:d??null});return}t.getBoundingClientRect().width<=window.innerWidth*.75||(e.sidebarState.setIsSidebarCollapsed(!0),window.dispatchEvent(new CustomEvent(te)))};t.addEventListener("patchwork:open-document",s),L(()=>t.removeEventListener("patchwork:open-document",s))}),[(()=>{var t=lt();return t.$$click=()=>e.sidebarState.setIsSidebarCollapsed(n=>!n),v(t,m(yt,{})),R(n=>{var s=l()?"Show sidebar":"Hide sidebar",i=l()?"Show sidebar":"Hide sidebar",u=!l();return s!==n.e&&Y(t,"title",n.e=s),i!==n.t&&Y(t,"aria-label",n.t=i),u!==n.a&&Y(t,"aria-pressed",n.a=u),n},{e:void 0,t:void 0,a:void 0}),t})(),m(se,{side:"left",isCollapsed:l,get width(){return e.sidebarState.leftSidebarWidth},get onMouseDown(){return e.sidebarResize.handleMouseDown},get onToggleClick(){return e.sidebarResize.handleToggleClick},get children(){var t=st(),n=t.firstChild,s=n.firstChild,i=s.firstChild,u=a;typeof u=="function"?C(u,t):a=t,v(t,m(he,{get widgets(){return e.sidebarWidgets},get configHandle(){return e.configHandle},get rootFolderUrl(){return e.rootFolderUrl},get ready(){return e.widgetsReady}}),n);var d=r;return typeof d=="function"?C(d,n):r=n,v(s,m(S,{get when(){return e.contactUrl()},children:c=>(()=>{var f=dt(),p=f.firstChild;return f.$$click=w=>J(w.currentTarget,{url:e.accountDocUrl,toolId:"account-picker"}),p._$owner=k(),R(()=>p.docUrl=c()),f})()}),i),v(s,m(S,{get when(){return e.moduleSettingsUrl()},children:c=>(()=>{var f=ut();return f.$$click=p=>J(p.currentTarget,{url:c(),toolId:"packages"}),f})()}),i),i.$$click=c=>J(c.currentTarget,{url:e.accountDocUrl,toolId:"frame-configurator"}),R(()=>t.classList.toggle("threepane-sidebar--has-tray",!!o())),t}}),m(S,{get when(){return o()},get children(){var t=ct();return v(t,m(ve,{get slots(){return e.traySlots}})),R(n=>{var s=!!l(),i=`${e.sidebarState.leftSidebarWidth()}px`;return s!==n.e&&t.classList.toggle("frame__tray-dock--collapsed",n.e=s),i!==n.t&&rt(t,"width",n.t=i),n},{e:void 0,t:void 0}),t}}),tt(()=>e.children)]}function yt(){return mt()}function Dr(e){return(l,o)=>ht(()=>m(gt,{handle:l,get repo(){return o.repo},isolation:e}),o)}et(["click"]);export{_t as FrameLayout,gt as PatchworkFrame,Dr as renderPatchworkFrame};
2
- //# sourceMappingURL=PatchworkFrame-UNWWAISP.js.map
1
+ import{a as M,b as ce,c as H,d as U}from"./chunk-YERFWP5I.js";import{a as Ie,b as B,c as j,d as te,e as re,f as oe,g as ne,h as ie,i as ae,j as le,k as se,l as P,m as F,n as W,o as de,p as ue,q as me,r as fe}from"./chunk-LNR6ATYD.js";import{b as Ue}from"./chunk-FW4363Y4.js";import{template as _}from"solid-js/web";import{delegateEvents as et}from"solid-js/web";import{memo as tt}from"solid-js/web";import{setStyleProperty as rt}from"solid-js/web";import{setAttribute as Y}from"solid-js/web";import{effect as R}from"solid-js/web";import{getOwner as k}from"solid-js/web";import{use as C}from"solid-js/web";import{insert as v}from"solid-js/web";import{createComponent as m}from"solid-js/web";import"@inkandswitch/patchwork-elements";import{subscribe as ft}from"@inkandswitch/patchwork-providers";import{template as q}from"solid-js/web";import{delegateEvents as Re}from"solid-js/web";import{memo as Le}from"solid-js/web";import{insert as pe}from"solid-js/web";import{createComponent as I}from"solid-js/web";import{For as Pe,Show as z}from"solid-js";var Ae=q("<div class=threepane-widgets>"),xe=q("<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list"),Oe=q("<div class=threepane-widget>");function he(e){let l=()=>{let o=e.rootFolderUrl(),a=e.configHandle();!o||!a||a.change(r=>{r.sidebar.widgets.push([H,o])})};return(()=>{var o=Ae();return pe(o,I(z,{get when(){return e.ready()},get children(){return I(z,{get when(){return e.widgets().length},get fallback(){return I(z,{get when(){return Le(()=>!!e.rootFolderUrl())()&&e.configHandle()},get children(){var a=xe(),r=a.firstChild;return r.$$click=l,a}})},get children(){return I(Pe,{get each(){return e.widgets()},children:a=>(()=>{var r=Oe();return pe(r,I(W,{slot:a})),r})()})}})}})),o})()}Re(["click"]);import{template as we}from"solid-js/web";import{setAttribute as Fe}from"solid-js/web";import{effect as We}from"solid-js/web";import{insert as ge}from"solid-js/web";import{createComponent as K}from"solid-js/web";import{For as Ne,Show as Ve}from"solid-js";var Me=we("<div class=frame-tray>"),He=we("<div class=frame-tray__item>");function ve(e){return K(Ve,{get when(){return e.slots().length},get children(){var l=Me();return ge(l,K(Ne,{get each(){return F(e.slots())},children:o=>(()=>{var a=He();return ge(a,K(W,{slot:o})),We(()=>Fe(a,"data-tray-id",P(o))),a})()})),l}})}import{createEffect as V,createMemo as pt,createSignal as b,onCleanup as L,onMount as ke,Show as S}from"solid-js";import{render as ht}from"solid-js/web";import{createDocOfDatatype2 as je}from"@inkandswitch/patchwork-plugins";import{getRegistry as Be}from"@inkandswitch/patchwork-plugins";function N(e){return Be("patchwork:datatype").loadWhenReady(e)}var ze=new Set(["document-title","spacer"]);function _e(e){return e?[[H,e]]:[]}function qe(e,l){if(!((e.version??0)>=1)){if(e.sidebar||(e.sidebar={widgets:[]}),l&&!e.sidebar.widgets?.length&&(e.sidebar.widgets=_e(l)),!e.tray)e.tray=M.slice();else{let o=F(e.tray);o.length!==e.tray.length&&(e.tray=o);let a=new Set(e.tray.map(r=>P(r)));for(let r of M)a.has(r)||(e.tray.push(r),a.add(r))}e.doctitle?.tools?.length||(e.doctitle={...e.doctitle,tools:ce.slice()}),!(!e.sidebar.widgets?.length&&!l)&&(e.version=1)}}async function ye(e,l){let o=e.doc()?.rootFolderUrl,a=e.doc()?.tools?.threepane;if(a){let i=await l.find(a);if((i.doc()?.version??0)>=1)return;i.change(u=>qe(u,o));return}let r=await N("threepane:config");if(!r){console.warn("frame: threepane:config datatype never registered");return}if(e.doc()?.tools?.threepane)return;let t=e.doc(),n=(t?.documentToolbarToolIds??[]).filter(i=>!ze.has(i)),s=await je(r,l);s.change(i=>{n.length&&(i.doctitle.tools=n),i.sidebar.widgets=_e(t?.rootFolderUrl),i.tray||(i.tray=M.slice()),t?.rootFolderUrl?i.version=1:delete i.version}),e.change(i=>{i.tools||(i.tools={}),i.tools.threepane||(i.tools.threepane=s.url)})}var Se=Ue(Ie(),1);import{createDocOfDatatype2 as Ke}from"@inkandswitch/patchwork-plugins";var g=(0,Se.default)("patchwork:threepane:examples");async function $e(e,l){let o=e.doc();if(!o?.rootFolderUrl){g("skipped \u2014 account has no rootFolderUrl");return}if(o.exampleDocsSeededAt){g("skipped \u2014 already ran for this account at",new Date(o.exampleDocsSeededAt).toISOString());return}g("claiming marker on account",e.url),e.change(d=>{d.exampleDocsSeededAt||(d.exampleDocsSeededAt=Date.now())});let a=await l.find(o.rootFolderUrl),r=a.doc()?.docs?.length??0;if(r){g(`skipped \u2014 root folder already has ${r} doc(s); only fresh accounts are seeded`);return}let t=window.location.hostname.includes("gaios"),n=t?[]:await Ye();if(g(t?"gaios examples":"bundle init scripts:",n),!t&&!n.length){g("skipped \u2014 no static module bundles to ask");return}let s=await N("folder");if(!s){g("folder datatype never registered; giving up");return}let i=await Ke(s,l,d=>{d.title="Examples"});if(t){let{seedGaiosExamples:d}=await import("./gaiosExamples-YDNQB35L.js");await d(l,i)}for(let d of n)try{await(await import(d)).default?.(l,i),g("ran init script",d)}catch(c){g("init script unavailable or failed",d,c)}let u=i.doc()?.docs?.length??0;if(!u){g("no bundle contributed any documents");return}a.change(d=>{d.docs.unshift({name:"Examples",type:"folder",url:i.url})}),g(`seeded ${u} document(s) into Examples folder`,i.url)}var be="https://patchwork-tools.netlify.app/init.js",De="https://patchwork-base.netlify.app/init.js";function Ge(){return document.documentElement.getAttribute("data-examples")==="site"}async function Ye(){let e=Ge(),l=window.patchwork?.packages;if(!l?.urls)return e?[]:[De,be];await l.doneLoading;let o=Object.values(l.urls).filter(r=>typeof r=="string"&&!r.startsWith("automerge:")).map(r=>new URL("init.js",new URL(r,document.baseURI)).href);if(e)return[...new Set(o)];let a=o.length?[]:[De];return[...new Set([...o,...a,be])]}import{createEffect as Xe,createMemo as Je,createSignal as Qe,onCleanup as Ze}from"solid-js";function G(e){let[l,o]=Qe(0);return Xe(()=>{let a=e();if(!a)return;let r=()=>o(t=>t+1);a.on("change",r),Ze(()=>a.off("change",r))}),Je(()=>(l(),e()?.doc()))}var ot=_("<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider><patchwork-view component=patchwork-worker-provider>",!0,!1,!1),nt=_("<div style=display:contents>"),it=_("<div class=main-area>"),at=_("<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>",!0,!1,!1),lt=_('<button type=button class="frame__sidebar-toggle frame__left-toggle">'),st=_("<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings"),ct=_("<div class=frame__tray-dock>"),dt=_('<button type=button class="threepane-account-bar__button threepane-account-bar__avatar"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>',!0,!1,!1),ut=_("<button type=button class=threepane-account-bar__button>Packages"),mt=_('<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox="0 0 24 24"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d="M9 3v18">'),X=(e,l)=>{let[o,a]=b(!1);return V(()=>{let r=l();if(!r)return;a(!1);let t=n=>{n.detail?.componentId===e&&a(!0)};r.addEventListener("patchwork:mounted",t),L(()=>r.removeEventListener("patchwork:mounted",t))}),o};function J(e,l){e.dispatchEvent(new CustomEvent("patchwork:open-document",{detail:l,bubbles:!0,composed:!0}))}function gt({handle:e,repo:l,...o}){me();let a=e.url,[r,t]=b(),n=X("patchwork-account-provider",r),[s,i]=b(),u=X("patchwork-tool-storage-provider",s),[d,c]=b(),f=X("patchwork-selected-doc-provider",d),p=pt(()=>f()&&n()&&u());return(()=>{var w=ot(),E=w.firstChild,Q=E.firstChild,A=E.nextSibling,h=A.firstChild,D=h.firstChild,$=D.firstChild,T=$.firstChild;return v(E,m(S,{get when(){return o.isolation},get children(){return[" ","isolation is highly experimental. if things are broken, switch back to wild west."]}}),null),C(c,h),h._$owner=k(),C(t,D),D.docUrl=a,D._$owner=k(),C(i,$),$.docUrl=a,$._$owner=k(),T._$owner=k(),v(T,m(S,{get when(){return p()},get children(){return m(wt,{handle:e,repo:l,get isolation(){return o.isolation}})}})),w})()}function wt(e){let l=B(()=>e.handle.url,{repo:e.repo});(async()=>{await ye(e.handle,e.repo),await $e(e.handle,e.repo)})().catch(y=>{console.error("frame: account bootstrap failed",y)});let o=G(l),a=e.handle.url,r=()=>o()?.tools?.threepane,t=B(()=>r(),{repo:e.repo}),n=G(t),s=()=>n()?.doctitle?.tools,i=()=>n()?.sidebar?.widgets??[],u=()=>n()?.tray??[],d=()=>o()?.rootFolderUrl,c=ie(),f=ae("left",{isCollapsed:c.isSidebarCollapsed,setCollapsed:c.setIsSidebarCollapsed,setWidth:c.setLeftSidebarWidth}),p,[w,E]=b(null),[Q,A]=b(null);ke(()=>{let y=ft(p,{type:"patchwork:selected-view"},x=>E(x));L(y)});let h=()=>w()?.url,D=()=>w()?.toolId??void 0,$=()=>oe(j.rightWidth,re),T=()=>ne(j.rightCollapsed),[Ce,Z]=b(),Ee=le(Ce,h),[ee,Te]=b(!1);return V(()=>{ee()||(e.isolation||!h()||Ee())&&Te(!0)}),(()=>{var y=nt(),x=p;return typeof x=="function"?C(x,y):p=y,v(y,m(_t,{accountDocUrl:a,sidebarState:c,sidebarResize:f,sidebarWidgets:i,traySlots:u,configHandle:t,rootFolderUrl:d,widgetsReady:ee,contactUrl:()=>o()?.contactUrl,moduleSettingsUrl:()=>o()?.moduleSettingsUrl,get isolation(){return e.isolation},onInterceptOpen:A,get children(){return m(S,{get when(){return h()},get fallback(){return(()=>{var O=it();return v(O,m(de,{viewKey:h,selectedDocUrl:h,toolId:D,ref:Z})),O})()},get children(){return m(S,{get when(){return e.isolation},get fallback(){return m(ue,{setMainDocElement:Z,selectedDocUrl:h,selectedToolId:D,doctitleSlots:s,get isLeftCollapsed(){return c.isSidebarCollapsed},initialRightWidth:$,initialRightCollapsed:T})},get children(){return m(fe,{get contactUrl(){return o()?.contactUrl},selectedDocUrl:h,selectedToolId:D,doctitleSlots:s,get isLeftCollapsed(){return c.isSidebarCollapsed},initialRightWidth:$,initialRightCollapsed:T})}})}})}}),null),v(y,m(S,{get when(){return Q()},children:O=>m(vt,{get view(){return O()},onClose:()=>A(null)})}),null),y})()}function vt(e){let[l,o]=b(e.view.toolId??void 0);V(()=>o(e.view.toolId??void 0));let a;return ke(()=>{let r=s=>{s.key==="Escape"&&e.onClose()};window.addEventListener("keydown",r),L(()=>window.removeEventListener("keydown",r));let t=a;if(!t)return;let n=s=>{let{url:i,toolId:u}=s.detail;i&&(s.stopPropagation(),o(u??void 0))};t.addEventListener("patchwork:open-document",n),L(()=>t.removeEventListener("patchwork:open-document",n))}),(()=>{var r=at(),t=r.firstChild,n=t.firstChild,s=n.firstChild,i=n.nextSibling,u=i.firstChild;r.$$click=()=>e.onClose(),t.$$click=c=>c.stopPropagation();var d=a;return typeof d=="function"?C(d,t):a=t,s._$owner=k(),u._$owner=k(),R(c=>{var f=e.view.url,p=e.view.url,w=l();return f!==c.e&&(s.docUrl=c.e=f),p!==c.t&&(u.docUrl=c.t=p),w!==c.a&&(u.toolId=c.a=w),c},{e:void 0,t:void 0,a:void 0}),r})()}function _t(e){let l=e.sidebarState.isSidebarCollapsed,o=()=>e.traySlots().length>0,a,r;return V(()=>{if(l())return;let t=a;if(!t)return;let n=r,s=i=>{let{url:u,toolId:d}=i.detail;if(e.isolation&&u&&n&&i.composedPath().includes(n)){i.stopPropagation(),e.onInterceptOpen?.({url:u,toolId:d??null});return}t.getBoundingClientRect().width<=window.innerWidth*.75||(e.sidebarState.setIsSidebarCollapsed(!0),window.dispatchEvent(new CustomEvent(te)))};t.addEventListener("patchwork:open-document",s),L(()=>t.removeEventListener("patchwork:open-document",s))}),[(()=>{var t=lt();return t.$$click=()=>e.sidebarState.setIsSidebarCollapsed(n=>!n),v(t,m(yt,{})),R(n=>{var s=l()?"Show sidebar":"Hide sidebar",i=l()?"Show sidebar":"Hide sidebar",u=!l();return s!==n.e&&Y(t,"title",n.e=s),i!==n.t&&Y(t,"aria-label",n.t=i),u!==n.a&&Y(t,"aria-pressed",n.a=u),n},{e:void 0,t:void 0,a:void 0}),t})(),m(se,{side:"left",isCollapsed:l,get width(){return e.sidebarState.leftSidebarWidth},get onMouseDown(){return e.sidebarResize.handleMouseDown},get onToggleClick(){return e.sidebarResize.handleToggleClick},get children(){var t=st(),n=t.firstChild,s=n.firstChild,i=s.firstChild,u=a;typeof u=="function"?C(u,t):a=t,v(t,m(he,{get widgets(){return e.sidebarWidgets},get configHandle(){return e.configHandle},get rootFolderUrl(){return e.rootFolderUrl},get ready(){return e.widgetsReady}}),n);var d=r;return typeof d=="function"?C(d,n):r=n,v(s,m(S,{get when(){return e.contactUrl()},children:c=>(()=>{var f=dt(),p=f.firstChild;return f.$$click=w=>J(w.currentTarget,{url:e.accountDocUrl,toolId:"account-picker"}),p._$owner=k(),R(()=>p.docUrl=c()),f})()}),i),v(s,m(S,{get when(){return e.moduleSettingsUrl()},children:c=>(()=>{var f=ut();return f.$$click=p=>J(p.currentTarget,{url:c(),toolId:"packages"}),f})()}),i),i.$$click=c=>J(c.currentTarget,{url:e.accountDocUrl,toolId:"frame-configurator"}),R(()=>t.classList.toggle("threepane-sidebar--has-tray",!!o())),t}}),m(S,{get when(){return o()},get children(){var t=ct();return v(t,m(ve,{get slots(){return e.traySlots}})),R(n=>{var s=!!l(),i=`${e.sidebarState.leftSidebarWidth()}px`;return s!==n.e&&t.classList.toggle("frame__tray-dock--collapsed",n.e=s),i!==n.t&&rt(t,"width",n.t=i),n},{e:void 0,t:void 0}),t}}),tt(()=>e.children)]}function yt(){return mt()}function Dr(e){return(l,o)=>ht(()=>m(gt,{handle:l,get repo(){return o.repo},isolation:e}),o)}et(["click"]);export{_t as FrameLayout,gt as PatchworkFrame,Dr as renderPatchworkFrame};
2
+ //# sourceMappingURL=PatchworkFrame-BGA6G6TI.js.map