@hackbuild/ai-views 0.1.2 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/chat.d.ts +35 -2
- package/dist/chat.js +47 -3
- package/dist/elements.d.ts +3 -1
- package/dist/elements.js +2 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -1
- package/dist/loaders.js +40 -7
- package/dist/mount-mask.d.ts +56 -6
- package/dist/mount-mask.js +334 -36
- package/dist/mount-talk.d.ts +92 -0
- package/dist/mount-talk.js +502 -0
- package/dist/mount-transcribe.d.ts +22 -0
- package/dist/mount-transcribe.js +90 -4
- package/dist/pick.d.ts +23 -0
- package/dist/pick.js +51 -0
- package/dist/single/elements.iife.js +1784 -627
- package/dist/single/elements.js +1774 -628
- package/dist/single/index.iife.js +1478 -56
- package/dist/single/index.js +1473 -57
- package/dist/single/vue.iife.js +1720 -622
- package/dist/single/vue.js +1714 -623
- package/dist/speaker.d.ts +55 -0
- package/dist/speaker.js +109 -0
- package/dist/talk.d.ts +89 -0
- package/dist/talk.js +121 -0
- package/dist/transcribe.d.ts +36 -1
- package/dist/transcribe.js +19 -3
- package/dist/vue.d.ts +137 -5
- package/dist/vue.js +80 -9
- package/llms.md +376 -14
- package/package.json +7 -7
package/dist/single/vue.iife.js
CHANGED
|
@@ -2450,14 +2450,14 @@ Component that was made reactive: `, type);
|
|
|
2450
2450
|
}
|
|
2451
2451
|
initDev();
|
|
2452
2452
|
// node_modules/@virgilvox/hackbuild-ui/dist/vanilla.js
|
|
2453
|
-
const
|
|
2454
|
-
const
|
|
2455
|
-
const
|
|
2456
|
-
const
|
|
2457
|
-
const
|
|
2458
|
-
const
|
|
2459
|
-
send: { d:
|
|
2460
|
-
microphone: { d:
|
|
2453
|
+
const Zt = "M2 12c3-5 6.5-7 10-7s7 2 10 7c-3 5-6.5 7-10 7s-7-2-10-7zM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0";
|
|
2454
|
+
const en = "M9 3h6v11H9zM5 11v1a7 7 0 0 0 14 0v-1M12 19v3";
|
|
2455
|
+
const tn = "M3 6h12v12H3zM15 10l6-3v10l-6-3";
|
|
2456
|
+
const et = "M3 12h16M13 6l6 6-6 6";
|
|
2457
|
+
const tt = "M20 12a8 8 0 1 1-3-6.2M20 4v5h-5";
|
|
2458
|
+
const Lt = {
|
|
2459
|
+
send: { d: et },
|
|
2460
|
+
microphone: { d: en },
|
|
2461
2461
|
stop: { d: "M6 6h12v12H6z" },
|
|
2462
2462
|
volume: { d: "M4 9v6h4l5 4V5L8 9zM17 8a5 5 0 0 1 0 8" },
|
|
2463
2463
|
mute: { d: "M4 9v6h4l5 4V5L8 9zM17 9l4 6M21 9l-4 6" },
|
|
@@ -2469,11 +2469,11 @@ Component that was made reactive: `, type);
|
|
|
2469
2469
|
upload: { d: "M12 16V4M7 9l5-5 5 5M4 20h16" },
|
|
2470
2470
|
download: { d: "M12 4v11M7 11l5 5 5-5M5 20h14" },
|
|
2471
2471
|
play: { d: "M7 5l11 7-11 7z" },
|
|
2472
|
-
redo: { d:
|
|
2472
|
+
redo: { d: tt },
|
|
2473
2473
|
trash: { d: "M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6" },
|
|
2474
2474
|
sun: { d: "M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0M12 2v3M12 19v3M2 12h3M19 12h3" },
|
|
2475
|
-
"paper-plane": { d:
|
|
2476
|
-
refresh: { d:
|
|
2475
|
+
"paper-plane": { d: et },
|
|
2476
|
+
refresh: { d: tt },
|
|
2477
2477
|
undo: { d: "M4 12a8 8 0 1 0 3-6.2M4 4v5h5" },
|
|
2478
2478
|
plus: { d: "M12 5v14M5 12h14" },
|
|
2479
2479
|
minus: { d: "M5 12h14" },
|
|
@@ -2486,7 +2486,7 @@ Component that was made reactive: `, type);
|
|
|
2486
2486
|
link: { d: "M9 15l6-6M11 6l2-2a4 4 0 0 1 6 6l-2 2M13 18l-2 2a4 4 0 0 1-6-6l2-2" },
|
|
2487
2487
|
copy: { d: "M8 8h12v12H8zM16 8V4H4v12h4" },
|
|
2488
2488
|
pen: { d: "M4 20v-4L15 5l4 4L8 20zM12 8l4 4" },
|
|
2489
|
-
eye: { d:
|
|
2489
|
+
eye: { d: Zt },
|
|
2490
2490
|
"eye-slash": { d: "M2 12c3-5 6.5-7 10-7s7 2 10 7c-3 5-6.5 7-10 7s-7-2-10-7zM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0M4 4l16 16" },
|
|
2491
2491
|
thumbtack: { d: "M8 3h8M10 3v6l-4 5h12l-4-5V3M12 14v7" },
|
|
2492
2492
|
search: { d: "M4 10a6 6 0 1 0 12 0a6 6 0 1 0 -12 0M15 15l6 6" },
|
|
@@ -2514,7 +2514,7 @@ Component that was made reactive: `, type);
|
|
|
2514
2514
|
wave: { d: "M2 12h3l2-4 3 9 3-13 3 13 2-5h4" },
|
|
2515
2515
|
"microphone-slash": { d: "M9 3h6v11H9zM5 11v1a7 7 0 0 0 14 0v-1M12 19v3M3 3l18 18" },
|
|
2516
2516
|
camera: { d: "M3 7h4l2-3h6l2 3h4v13H3zM8.5 13a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0" },
|
|
2517
|
-
video: { d:
|
|
2517
|
+
video: { d: tn },
|
|
2518
2518
|
"video-slash": { d: "M3 6h12v12H3zM15 10l6-3v10l-6-3M3 3l18 18" },
|
|
2519
2519
|
image: { d: "M3 4h18v16H3zM3 16l5-5 4 4 3-3 6 6M15 8v.5" },
|
|
2520
2520
|
crosshairs: { d: "M5 12a7 7 0 1 0 14 0a7 7 0 1 0 -14 0M12 2v5M12 17v5M2 12h5M17 12h5" },
|
|
@@ -2544,17 +2544,17 @@ Component that was made reactive: `, type);
|
|
|
2544
2544
|
bucket: { d: "M5 11l7-7 7 7-7 7zM5 11h14M20 15c0 1.5-1 3-1 3s-1-1.5-1-3a1 1 0 0 1 2 0z" },
|
|
2545
2545
|
hand: { d: "M8 12V5a1.5 1.5 0 0 1 3 0v6M11 10V3.5a1.5 1.5 0 0 1 3 0V10M14 10V5a1.5 1.5 0 0 1 3 0v7c0 5-3 8-7 8c-3 0-4-2-6-5l-1.5-2.5a1.5 1.5 0 0 1 2.5-1.6L8 14" }
|
|
2546
2546
|
};
|
|
2547
|
-
function
|
|
2548
|
-
return
|
|
2547
|
+
function nn(e) {
|
|
2548
|
+
return Lt[e];
|
|
2549
2549
|
}
|
|
2550
|
-
const
|
|
2551
|
-
function
|
|
2552
|
-
const r =
|
|
2550
|
+
const nt = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2551
|
+
function rn(e, t = {}) {
|
|
2552
|
+
const r = nn(e);
|
|
2553
2553
|
if (!r) return "";
|
|
2554
2554
|
const n = t.size ?? 16;
|
|
2555
|
-
return `<svg class="${"hb-icon is-stroke" + (t.className ? " " +
|
|
2555
|
+
return `<svg class="${"hb-icon is-stroke" + (t.className ? " " + nt(t.className) : "")}" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter" ${t.label ? `role="img" aria-label="${nt(t.label)}"` : "aria-hidden=\"true\""}><path d="${r.d}"/></svg>`;
|
|
2556
2556
|
}
|
|
2557
|
-
const
|
|
2557
|
+
const on = [
|
|
2558
2558
|
"a[href]",
|
|
2559
2559
|
"button:not([disabled])",
|
|
2560
2560
|
"input:not([disabled]):not([type=\"hidden\"])",
|
|
@@ -2563,10 +2563,10 @@ Component that was made reactive: `, type);
|
|
|
2563
2563
|
"[tabindex]",
|
|
2564
2564
|
"[contenteditable=\"true\"]"
|
|
2565
2565
|
].join(",");
|
|
2566
|
-
function
|
|
2567
|
-
return [...e.querySelectorAll(
|
|
2566
|
+
function Te(e) {
|
|
2567
|
+
return [...e.querySelectorAll(on)].filter((t) => t.getAttribute("tabindex") !== "-1" && !t.closest("[hidden],[inert]"));
|
|
2568
2568
|
}
|
|
2569
|
-
function
|
|
2569
|
+
function be(e) {
|
|
2570
2570
|
const t = e;
|
|
2571
2571
|
if (!t || typeof t.closest != "function") return !1;
|
|
2572
2572
|
if (t.isContentEditable || t.closest("[contenteditable=\"\"],[contenteditable=\"true\"]")) return !0;
|
|
@@ -2585,71 +2585,71 @@ Component that was made reactive: `, type);
|
|
|
2585
2585
|
"range"
|
|
2586
2586
|
].includes(n);
|
|
2587
2587
|
}
|
|
2588
|
-
const
|
|
2589
|
-
let
|
|
2590
|
-
let
|
|
2591
|
-
function
|
|
2592
|
-
|
|
2588
|
+
const ce = [];
|
|
2589
|
+
let De = 0;
|
|
2590
|
+
let $t = "";
|
|
2591
|
+
function sn(e) {
|
|
2592
|
+
De++ === 0 && ($t = e.body.style.overflow, e.body.style.overflow = "hidden");
|
|
2593
2593
|
}
|
|
2594
|
-
function
|
|
2595
|
-
|
|
2594
|
+
function an(e) {
|
|
2595
|
+
De > 0 && --De === 0 && (e.body.style.overflow = $t);
|
|
2596
2596
|
}
|
|
2597
|
-
const
|
|
2598
|
-
function
|
|
2599
|
-
var u,
|
|
2597
|
+
const ln = /* @__PURE__ */ new Map();
|
|
2598
|
+
function St(e, t, r, n) {
|
|
2599
|
+
var u, v;
|
|
2600
2600
|
const o = e.ownerDocument, i = {};
|
|
2601
2601
|
let s = !1, c = null, a = !1;
|
|
2602
2602
|
!t.getAttribute("role") && !e.getAttribute("role") && t.setAttribute("role", "dialog");
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2603
|
+
const h = e.getAttribute("role") === "dialog" ? e : t;
|
|
2604
|
+
h.setAttribute("aria-modal", "true"), r.label && h.setAttribute("aria-label", r.label), t.hasAttribute("tabindex") || (t.tabIndex = -1), (u = r.trigger) == null || u.setAttribute("aria-expanded", "false");
|
|
2605
2605
|
function y(w) {
|
|
2606
|
-
if (!s ||
|
|
2606
|
+
if (!s || ce[ce.length - 1] !== i || w.defaultPrevented) return;
|
|
2607
2607
|
if (w.key === "Escape" && r.closeOnEscape !== !1) {
|
|
2608
2608
|
w.preventDefault(), l("escape");
|
|
2609
2609
|
return;
|
|
2610
2610
|
}
|
|
2611
2611
|
if (w.key !== "Tab" || r.trap === !1) return;
|
|
2612
|
-
const
|
|
2613
|
-
if (!
|
|
2612
|
+
const k = Te(t);
|
|
2613
|
+
if (!k.length) {
|
|
2614
2614
|
w.preventDefault(), t.focus();
|
|
2615
2615
|
return;
|
|
2616
2616
|
}
|
|
2617
|
-
const
|
|
2618
|
-
w.shiftKey && (
|
|
2617
|
+
const b = k[0], x = k[k.length - 1], T = o.activeElement, z = !!T && t.contains(T);
|
|
2618
|
+
w.shiftKey && (T === b || !z) ? (w.preventDefault(), x.focus()) : !w.shiftKey && (T === x || !z) && (w.preventDefault(), b.focus());
|
|
2619
2619
|
}
|
|
2620
|
-
function
|
|
2621
|
-
var
|
|
2620
|
+
function f(w) {
|
|
2621
|
+
var x;
|
|
2622
2622
|
if (!s) return;
|
|
2623
|
-
const
|
|
2624
|
-
if (
|
|
2623
|
+
const k = w.target;
|
|
2624
|
+
if (k === e && r.closeOnScrim !== !1) {
|
|
2625
2625
|
l("scrim");
|
|
2626
2626
|
return;
|
|
2627
2627
|
}
|
|
2628
|
-
const
|
|
2629
|
-
|
|
2628
|
+
const b = (x = k.closest) == null ? void 0 : x.call(k, "[data-hb-close]");
|
|
2629
|
+
b && e.contains(b) && l("button");
|
|
2630
2630
|
}
|
|
2631
2631
|
function m() {
|
|
2632
2632
|
p();
|
|
2633
2633
|
}
|
|
2634
|
-
function
|
|
2635
|
-
var
|
|
2634
|
+
function g() {
|
|
2635
|
+
var k, b, x;
|
|
2636
2636
|
if (s) return;
|
|
2637
|
-
if (n && e.classList.contains("is-sheet")) for (const [
|
|
2638
|
-
s = !0, c = o.activeElement, e.hidden = !1,
|
|
2637
|
+
if (n && e.classList.contains("is-sheet")) for (const [T, z] of [...n]) T !== d && z.classList.contains("is-sheet") && T.close("api");
|
|
2638
|
+
s = !0, c = o.activeElement, e.hidden = !1, ce.push(i), r.lockScroll !== !1 && (sn(o), a = !0), o.addEventListener("keydown", y), (k = r.trigger) == null || k.setAttribute("aria-expanded", "true"), (((b = r.initialFocus) == null ? void 0 : b.call(r)) ?? Te(t)[0] ?? t).focus(), (x = r.onOpen) == null || x.call(r);
|
|
2639
2639
|
}
|
|
2640
2640
|
function l(w = "api") {
|
|
2641
|
-
var
|
|
2641
|
+
var b, x;
|
|
2642
2642
|
if (!s) return;
|
|
2643
2643
|
s = !1, e.hidden = !0;
|
|
2644
|
-
const
|
|
2645
|
-
|
|
2644
|
+
const k = ce.indexOf(i);
|
|
2645
|
+
k >= 0 && ce.splice(k, 1), a && (an(o), a = !1), o.removeEventListener("keydown", y), (b = r.trigger) == null || b.setAttribute("aria-expanded", "false"), c && c.isConnected && c.focus(), c = null, (x = r.onClose) == null || x.call(r, w);
|
|
2646
2646
|
}
|
|
2647
2647
|
function p() {
|
|
2648
|
-
s ? l("button") :
|
|
2648
|
+
s ? l("button") : g();
|
|
2649
2649
|
}
|
|
2650
|
-
e.addEventListener("click",
|
|
2650
|
+
e.addEventListener("click", f), (v = r.trigger) == null || v.addEventListener("click", m), e.hidden = !0;
|
|
2651
2651
|
const d = {
|
|
2652
|
-
open:
|
|
2652
|
+
open: g,
|
|
2653
2653
|
close: l,
|
|
2654
2654
|
toggle: p,
|
|
2655
2655
|
get isOpen() {
|
|
@@ -2657,26 +2657,26 @@ Component that was made reactive: `, type);
|
|
|
2657
2657
|
},
|
|
2658
2658
|
dispose() {
|
|
2659
2659
|
var w;
|
|
2660
|
-
s && l("api"), n?.delete(d), e.removeEventListener("click",
|
|
2660
|
+
s && l("api"), n?.delete(d), e.removeEventListener("click", f), (w = r.trigger) == null || w.removeEventListener("click", m);
|
|
2661
2661
|
}
|
|
2662
2662
|
};
|
|
2663
|
-
return n?.set(d, e), r.open &&
|
|
2663
|
+
return n?.set(d, e), r.open && g(), d;
|
|
2664
2664
|
}
|
|
2665
|
-
function
|
|
2665
|
+
function Wr(e, t = {}) {
|
|
2666
2666
|
const r = t.side ?? "right";
|
|
2667
2667
|
e.classList.toggle("is-left", r === "left"), e.classList.toggle("is-sheet", r === "bottom"), e.classList.toggle("is-md", t.size === "md"), e.classList.toggle("is-lg", t.size === "lg");
|
|
2668
2668
|
const n = e.querySelector(":scope > .hb-drawer-panel") ?? e, o = e.ownerDocument.defaultView, i = r === "auto" && typeof (o == null ? void 0 : o.matchMedia) == "function" ? o.matchMedia(`(min-width: ${t.breakpoint ?? 761}px)`) : null, s = () => {
|
|
2669
2669
|
e.classList.toggle("is-sheet", !(i != null && i.matches));
|
|
2670
2670
|
};
|
|
2671
2671
|
r === "auto" && s(), i?.addEventListener("change", s);
|
|
2672
|
-
const c =
|
|
2672
|
+
const c = St(e, n, t, r === "bottom" || r === "auto" ? ln : void 0);
|
|
2673
2673
|
if (!i) return c;
|
|
2674
2674
|
const a = c.dispose;
|
|
2675
2675
|
return c.dispose = () => {
|
|
2676
2676
|
i.removeEventListener("change", s), a();
|
|
2677
2677
|
}, c;
|
|
2678
2678
|
}
|
|
2679
|
-
function
|
|
2679
|
+
function X() {
|
|
2680
2680
|
const e = /* @__PURE__ */ new Set();
|
|
2681
2681
|
return {
|
|
2682
2682
|
on(t) {
|
|
@@ -2692,8 +2692,8 @@ Component that was made reactive: `, type);
|
|
|
2692
2692
|
}
|
|
2693
2693
|
};
|
|
2694
2694
|
}
|
|
2695
|
-
function
|
|
2696
|
-
const t = [], r = [], n =
|
|
2695
|
+
function yn(e = 80) {
|
|
2696
|
+
const t = [], r = [], n = X();
|
|
2697
2697
|
return {
|
|
2698
2698
|
push(o) {
|
|
2699
2699
|
t.push(o), t.length > e && t.splice(0, t.length - e), r.length = 0, n.emit();
|
|
@@ -2731,21 +2731,21 @@ Component that was made reactive: `, type);
|
|
|
2731
2731
|
}
|
|
2732
2732
|
};
|
|
2733
2733
|
}
|
|
2734
|
-
function
|
|
2734
|
+
function Jo(e, t) {
|
|
2735
2735
|
return e.isComposing ? null : e.key === "Escape" && t.busy ? "stop" : e.key === "ArrowUp" && t.empty && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey ? "edit-last" : e.key !== "Enter" || e.shiftKey || e.altKey ? null : (e.ctrlKey || e.metaKey) && !t.busy ? "send" : t.coarse || t.busy ? null : "send";
|
|
2736
2736
|
}
|
|
2737
|
-
function
|
|
2737
|
+
function Qo(e = typeof window > "u" ? void 0 : window) {
|
|
2738
2738
|
var t;
|
|
2739
2739
|
return !!((t = e == null ? void 0 : e.matchMedia) != null && t.call(e, "(pointer: coarse)").matches);
|
|
2740
2740
|
}
|
|
2741
|
-
function
|
|
2741
|
+
function Zo(e, t = 44, r = 200) {
|
|
2742
2742
|
e.style.height = "auto", e.style.height = `${Math.max(t, Math.min(r, e.scrollHeight + 2))}px`, e.style.overflowY = e.scrollHeight + 2 > r ? "auto" : "hidden";
|
|
2743
2743
|
}
|
|
2744
|
-
function
|
|
2744
|
+
function ei(e, t = 80) {
|
|
2745
2745
|
return e.scrollHeight - e.scrollTop - e.clientHeight < t;
|
|
2746
2746
|
}
|
|
2747
|
-
function
|
|
2748
|
-
const o = e.reduce((a,
|
|
2747
|
+
function ti(e, t, r = .75, n = .95) {
|
|
2748
|
+
const o = e.reduce((a, h) => a + Math.max(0, h.tokens), 0), i = Math.max(1, t);
|
|
2749
2749
|
return {
|
|
2750
2750
|
used: o,
|
|
2751
2751
|
budget: i,
|
|
@@ -2758,29 +2758,40 @@ Component that was made reactive: `, type);
|
|
|
2758
2758
|
words: `${o.toLocaleString("en-US")} of ${i.toLocaleString("en-US")} tok, ${Math.round(o / i * 100)}%`
|
|
2759
2759
|
};
|
|
2760
2760
|
}
|
|
2761
|
-
function
|
|
2762
|
-
const r = [e.kind,
|
|
2761
|
+
function ni(e, t = Date.now()) {
|
|
2762
|
+
const r = [e.kind, Fn(e.updated, t)];
|
|
2763
2763
|
return e.count != null && r.push(`${e.count} msg`), r.filter(Boolean).join(", ");
|
|
2764
2764
|
}
|
|
2765
|
-
function
|
|
2765
|
+
function Fn(e, t = Date.now()) {
|
|
2766
2766
|
const r = typeof e == "number" ? e : new Date(e).getTime();
|
|
2767
2767
|
if (!Number.isFinite(r)) return String(e);
|
|
2768
2768
|
const n = Math.max(0, (t - r) / 1e3);
|
|
2769
2769
|
return n < 60 ? "just now" : n < 3600 ? `${Math.floor(n / 60)} min ago` : n < 86400 ? `${Math.floor(n / 3600)} h ago` : n < 1209600 ? `${Math.floor(n / 86400)} d ago` : new Date(r).toISOString().slice(0, 10);
|
|
2770
2770
|
}
|
|
2771
|
-
function
|
|
2771
|
+
function Nn(e, t) {
|
|
2772
|
+
return t === 1 || !e ? e : /[^aeiou]y$/.test(e) ? e.slice(0, -1) + "ies" : /(s|x|ch|sh)$/.test(e) ? e + "es" : e + "s";
|
|
2773
|
+
}
|
|
2774
|
+
function oi(e, t = []) {
|
|
2775
|
+
const r = new Map(t.map((n) => [n, 0]));
|
|
2776
|
+
for (const n of e) r.set(n.kind, (r.get(n.kind) ?? 0) + 1);
|
|
2777
|
+
return r.size ? [...r].map(([n, o]) => `${o} ${Nn(n, o)}`).join(", ") : "nothing stored.";
|
|
2778
|
+
}
|
|
2779
|
+
function ii(e) {
|
|
2780
|
+
return typeof e == "number" && Number.isFinite(e) ? e.toFixed(2) : "";
|
|
2781
|
+
}
|
|
2782
|
+
function ie(e) {
|
|
2772
2783
|
if (!Number.isFinite(e)) return "--:--";
|
|
2773
2784
|
const t = Math.max(0, Math.floor(e)), r = Math.floor(t / 3600), n = Math.floor(t % 3600 / 60), o = t % 60, i = (s) => String(s).padStart(2, "0");
|
|
2774
2785
|
return r ? `${r}:${i(n)}:${i(o)}` : `${i(n)}:${i(o)}`;
|
|
2775
2786
|
}
|
|
2776
|
-
function
|
|
2787
|
+
function yi(e) {
|
|
2777
2788
|
if (!e.length) return "";
|
|
2778
2789
|
const t = /* @__PURE__ */ new Map();
|
|
2779
2790
|
for (const n of e) t.set(n.why, (t.get(n.why) ?? 0) + 1);
|
|
2780
2791
|
const r = [...t].sort((n, o) => o[1] - n[1]).map(([n, o]) => `${o} ${n}`);
|
|
2781
2792
|
return `${e.length} ${e.length === 1 ? "line" : "lines"} dropped: ${r.join(", ")}`;
|
|
2782
2793
|
}
|
|
2783
|
-
const
|
|
2794
|
+
const Un = {
|
|
2784
2795
|
queued: "queued",
|
|
2785
2796
|
decoding: "decoding",
|
|
2786
2797
|
working: "transcribing",
|
|
@@ -2790,7 +2801,7 @@ Component that was made reactive: `, type);
|
|
|
2790
2801
|
failed: "failed",
|
|
2791
2802
|
stopped: "stopped"
|
|
2792
2803
|
};
|
|
2793
|
-
const
|
|
2804
|
+
const Wn = {
|
|
2794
2805
|
queued: "",
|
|
2795
2806
|
decoding: "busy",
|
|
2796
2807
|
working: "busy",
|
|
@@ -2800,14 +2811,14 @@ Component that was made reactive: `, type);
|
|
|
2800
2811
|
failed: "bad",
|
|
2801
2812
|
stopped: ""
|
|
2802
2813
|
};
|
|
2803
|
-
function
|
|
2814
|
+
function ki(e, t) {
|
|
2804
2815
|
const r = e === "running" && t ? t : e;
|
|
2805
2816
|
return {
|
|
2806
|
-
word:
|
|
2807
|
-
tone:
|
|
2817
|
+
word: Un[r] ?? r,
|
|
2818
|
+
tone: Wn[r] ?? ""
|
|
2808
2819
|
};
|
|
2809
2820
|
}
|
|
2810
|
-
function
|
|
2821
|
+
function Di(e) {
|
|
2811
2822
|
const t = (e == null ? void 0 : e.name) ?? "";
|
|
2812
2823
|
if (t === "NotAllowedError" || t === "SecurityError" || t === "PermissionDeniedError") return {
|
|
2813
2824
|
kind: "denied",
|
|
@@ -2831,7 +2842,7 @@ Component that was made reactive: `, type);
|
|
|
2831
2842
|
text: `camera failed${r ? `: ${r.toLowerCase().replace(/\.$/, "")}` : ""}. upload a file instead.`
|
|
2832
2843
|
};
|
|
2833
2844
|
}
|
|
2834
|
-
function
|
|
2845
|
+
function qi(e = {
|
|
2835
2846
|
facingMode: "user",
|
|
2836
2847
|
width: { ideal: 640 },
|
|
2837
2848
|
height: { ideal: 480 }
|
|
@@ -2841,10 +2852,10 @@ Component that was made reactive: `, type);
|
|
|
2841
2852
|
audio: !1
|
|
2842
2853
|
}) : Promise.reject(Object.assign(/* @__PURE__ */ new Error("no mediaDevices"), { name: "unsupported" }));
|
|
2843
2854
|
}
|
|
2844
|
-
function
|
|
2855
|
+
function Oi(e) {
|
|
2845
2856
|
e?.getTracks().forEach((t) => t.stop());
|
|
2846
2857
|
}
|
|
2847
|
-
function
|
|
2858
|
+
function zt(e, t, r) {
|
|
2848
2859
|
if (!(t > 0 && r > 0 && e.width > 0 && e.height > 0)) return {
|
|
2849
2860
|
left: 0,
|
|
2850
2861
|
top: 0,
|
|
@@ -2859,14 +2870,14 @@ Component that was made reactive: `, type);
|
|
|
2859
2870
|
height: i
|
|
2860
2871
|
};
|
|
2861
2872
|
}
|
|
2862
|
-
function
|
|
2863
|
-
const s =
|
|
2873
|
+
function Yn(e, t, r, n, o, i = !1) {
|
|
2874
|
+
const s = zt(r, n, o), c = (e - r.left - s.left) / s.width, a = (t - r.top - s.top) / s.height;
|
|
2864
2875
|
return !i && (c < 0 || a < 0 || c > 1 || a > 1) ? null : {
|
|
2865
2876
|
x: Math.min(n, Math.max(0, c * n)),
|
|
2866
2877
|
y: Math.min(o, Math.max(0, a * o))
|
|
2867
2878
|
};
|
|
2868
2879
|
}
|
|
2869
|
-
const
|
|
2880
|
+
const ht = [
|
|
2870
2881
|
"#FE0386",
|
|
2871
2882
|
"#3b82f6",
|
|
2872
2883
|
"#22c55e",
|
|
@@ -2878,146 +2889,150 @@ Component that was made reactive: `, type);
|
|
|
2878
2889
|
"#ff5c4d",
|
|
2879
2890
|
"#58a6ff"
|
|
2880
2891
|
];
|
|
2881
|
-
const
|
|
2892
|
+
const gt = [
|
|
2882
2893
|
{
|
|
2883
2894
|
id: "wand",
|
|
2884
2895
|
label: "wand",
|
|
2885
2896
|
icon: "wand",
|
|
2886
2897
|
key: "w",
|
|
2887
|
-
hint:
|
|
2898
|
+
hint: Y("wand", "add")
|
|
2888
2899
|
},
|
|
2889
2900
|
{
|
|
2890
2901
|
id: "brush",
|
|
2891
2902
|
label: "brush",
|
|
2892
2903
|
icon: "brush",
|
|
2893
2904
|
key: "b",
|
|
2894
|
-
hint:
|
|
2905
|
+
hint: Y("brush", "add")
|
|
2895
2906
|
},
|
|
2896
2907
|
{
|
|
2897
2908
|
id: "eraser",
|
|
2898
2909
|
label: "eraser",
|
|
2899
2910
|
icon: "eraser",
|
|
2900
2911
|
key: "e",
|
|
2901
|
-
hint:
|
|
2912
|
+
hint: Y("eraser", "add")
|
|
2902
2913
|
},
|
|
2903
2914
|
{
|
|
2904
2915
|
id: "lasso",
|
|
2905
2916
|
label: "lasso",
|
|
2906
2917
|
icon: "lasso",
|
|
2907
2918
|
key: "l",
|
|
2908
|
-
hint:
|
|
2919
|
+
hint: Y("lasso", "add"),
|
|
2920
|
+
group: "shape"
|
|
2909
2921
|
},
|
|
2910
2922
|
{
|
|
2911
2923
|
id: "polygon",
|
|
2912
2924
|
label: "polygon",
|
|
2913
2925
|
icon: "polygon",
|
|
2914
2926
|
key: "p",
|
|
2915
|
-
hint:
|
|
2927
|
+
hint: Y("polygon", "add"),
|
|
2928
|
+
group: "shape"
|
|
2916
2929
|
},
|
|
2917
2930
|
{
|
|
2918
2931
|
id: "rect",
|
|
2919
2932
|
label: "rectangle",
|
|
2920
2933
|
icon: "select-rect",
|
|
2921
2934
|
key: "m",
|
|
2922
|
-
hint:
|
|
2935
|
+
hint: Y("rect", "add"),
|
|
2936
|
+
group: "shape"
|
|
2923
2937
|
},
|
|
2924
2938
|
{
|
|
2925
2939
|
id: "ellipse",
|
|
2926
2940
|
label: "ellipse",
|
|
2927
2941
|
icon: "select-ellipse",
|
|
2928
2942
|
key: "o",
|
|
2929
|
-
hint:
|
|
2943
|
+
hint: Y("ellipse", "add"),
|
|
2944
|
+
group: "shape"
|
|
2930
2945
|
},
|
|
2931
2946
|
{
|
|
2932
2947
|
id: "flood",
|
|
2933
2948
|
label: "flood fill",
|
|
2934
2949
|
icon: "bucket",
|
|
2935
2950
|
key: "g",
|
|
2936
|
-
hint:
|
|
2951
|
+
hint: Y("flood", "add")
|
|
2937
2952
|
},
|
|
2938
2953
|
{
|
|
2939
2954
|
id: "pan",
|
|
2940
2955
|
label: "pan",
|
|
2941
2956
|
icon: "hand",
|
|
2942
2957
|
key: "h",
|
|
2943
|
-
hint:
|
|
2958
|
+
hint: Y("pan", "add")
|
|
2944
2959
|
}
|
|
2945
2960
|
];
|
|
2946
|
-
function
|
|
2961
|
+
function Y(e, t) {
|
|
2947
2962
|
const r = t === "add", n = `x swaps to ${r ? "erase" : "add"}`;
|
|
2948
2963
|
return e === "wand" ? `tap a colour to ${r ? "add" : "cut"} it. shift ${r ? "cuts" : "adds"}, ${n}` : e === "brush" ? `paint to ${r ? "add" : "erase"}. [ and ] size, ${n}` : e === "eraser" ? "paint to erase. shift adds, [ and ] size" : e === "polygon" ? `press corner by corner, enter or the first corner ${r ? "fills" : "cuts"}. backspace drops a corner, esc all` : e === "rect" || e === "ellipse" ? `drag a ${e === "rect" ? "box" : "ring"} to ${r ? "add" : "cut"} it. shift ${r ? "cuts" : "adds"}, ${n}` : e === "flood" ? `tap to fill the patch of one colour. shift ${r ? "cuts" : "adds"}, ${n}` : e === "pan" ? "drag to move the picture. space pans from any tool" : `drag around a shape, lift to ${r ? "fill" : "cut"}. esc drops it, ${n}`;
|
|
2949
2964
|
}
|
|
2950
|
-
function
|
|
2951
|
-
const { data: i, width: s, height: c } = e, a = new Uint8Array(s * c),
|
|
2952
|
-
if (
|
|
2953
|
-
const
|
|
2954
|
-
const
|
|
2955
|
-
return
|
|
2965
|
+
function pt(e, t, r, n, o = !0) {
|
|
2966
|
+
const { data: i, width: s, height: c } = e, a = new Uint8Array(s * c), h = Math.floor(t), y = Math.floor(r);
|
|
2967
|
+
if (h < 0 || y < 0 || h >= s || y >= c) return a;
|
|
2968
|
+
const f = (y * s + h) * 4, m = i[f], g = i[f + 1], l = i[f + 2], p = Math.max(0, n) / 100 * 441.673, d = p * p + 1e-9, u = (x) => {
|
|
2969
|
+
const T = x * 4, z = i[T] - m, L = i[T + 1] - g, S = i[T + 2] - l;
|
|
2970
|
+
return z * z + L * L + S * S <= d;
|
|
2956
2971
|
};
|
|
2957
2972
|
if (!o) {
|
|
2958
|
-
for (let
|
|
2973
|
+
for (let x = 0; x < s * c; x++) u(x) && (a[x] = 1);
|
|
2959
2974
|
return a;
|
|
2960
2975
|
}
|
|
2961
|
-
const
|
|
2962
|
-
let
|
|
2963
|
-
const
|
|
2964
|
-
for (w[
|
|
2965
|
-
const
|
|
2966
|
-
if (!u(
|
|
2967
|
-
a[
|
|
2968
|
-
const
|
|
2969
|
-
|
|
2976
|
+
const v = new Uint8Array(s * c), w = new Int32Array(s * c);
|
|
2977
|
+
let k = 0;
|
|
2978
|
+
const b = y * s + h;
|
|
2979
|
+
for (w[k++] = b, v[b] = 1; k;) {
|
|
2980
|
+
const x = w[--k];
|
|
2981
|
+
if (!u(x)) continue;
|
|
2982
|
+
a[x] = 1;
|
|
2983
|
+
const T = x % s;
|
|
2984
|
+
T > 0 && !v[x - 1] && (v[x - 1] = 1, w[k++] = x - 1), T < s - 1 && !v[x + 1] && (v[x + 1] = 1, w[k++] = x + 1), x >= s && !v[x - s] && (v[x - s] = 1, w[k++] = x - s), x < s * (c - 1) && !v[x + s] && (v[x + s] = 1, w[k++] = x + s);
|
|
2970
2985
|
}
|
|
2971
2986
|
return a;
|
|
2972
2987
|
}
|
|
2973
|
-
function
|
|
2988
|
+
function Se(e, t, r) {
|
|
2974
2989
|
const n = new Uint8Array(e * t);
|
|
2975
2990
|
if (r.length < 3) return n;
|
|
2976
2991
|
let o = 1 / 0, i = -1 / 0;
|
|
2977
|
-
for (const
|
|
2992
|
+
for (const h of r) h.y < o && (o = h.y), h.y > i && (i = h.y);
|
|
2978
2993
|
const s = Math.max(0, Math.floor(o)), c = Math.min(t - 1, Math.ceil(i)), a = [];
|
|
2979
|
-
for (let
|
|
2980
|
-
const y =
|
|
2994
|
+
for (let h = s; h <= c; h++) {
|
|
2995
|
+
const y = h + .5;
|
|
2981
2996
|
a.length = 0;
|
|
2982
|
-
for (let
|
|
2983
|
-
const
|
|
2984
|
-
|
|
2997
|
+
for (let f = 0, m = r.length - 1; f < r.length; m = f++) {
|
|
2998
|
+
const g = r[f], l = r[m];
|
|
2999
|
+
g.y > y != l.y > y && a.push(g.x + (y - g.y) * (l.x - g.x) / (l.y - g.y));
|
|
2985
3000
|
}
|
|
2986
|
-
a.sort((
|
|
2987
|
-
for (let
|
|
2988
|
-
const m = Math.max(0, Math.ceil(a[
|
|
2989
|
-
for (let l = m; l <=
|
|
3001
|
+
a.sort((f, m) => f - m);
|
|
3002
|
+
for (let f = 0; f + 1 < a.length; f += 2) {
|
|
3003
|
+
const m = Math.max(0, Math.ceil(a[f] - .5)), g = Math.min(e - 1, Math.ceil(a[f + 1] - .5) - 1);
|
|
3004
|
+
for (let l = m; l <= g; l++) n[h * e + l] = 1;
|
|
2990
3005
|
}
|
|
2991
3006
|
}
|
|
2992
3007
|
return n;
|
|
2993
3008
|
}
|
|
2994
|
-
function
|
|
3009
|
+
function yt(e, t, r, n) {
|
|
2995
3010
|
const o = new Uint8Array(e * t), i = Math.max(0, Math.floor(Math.min(r.x, n.x))), s = Math.min(e, Math.ceil(Math.max(r.x, n.x))), c = Math.max(0, Math.floor(Math.min(r.y, n.y))), a = Math.min(t, Math.ceil(Math.max(r.y, n.y)));
|
|
2996
|
-
for (let
|
|
3011
|
+
for (let h = c; h < a; h++) o.fill(255, h * e + i, h * e + s);
|
|
2997
3012
|
return o;
|
|
2998
3013
|
}
|
|
2999
|
-
function
|
|
3014
|
+
function bt(e, t, r, n) {
|
|
3000
3015
|
const o = new Uint8Array(e * t), i = (r.x + n.x) / 2, s = (r.y + n.y) / 2, c = Math.abs(n.x - r.x) / 2, a = Math.abs(n.y - r.y) / 2;
|
|
3001
3016
|
if (c < .5 || a < .5) return o;
|
|
3002
|
-
const
|
|
3003
|
-
for (let
|
|
3004
|
-
const m = (
|
|
3017
|
+
const h = Math.max(0, Math.floor(s - a)), y = Math.min(t - 1, Math.ceil(s + a));
|
|
3018
|
+
for (let f = h; f <= y; f++) {
|
|
3019
|
+
const m = (f + .5 - s) / a;
|
|
3005
3020
|
if (m * m > 1) continue;
|
|
3006
|
-
const
|
|
3007
|
-
p > l && o.fill(255,
|
|
3021
|
+
const g = c * Math.sqrt(1 - m * m), l = Math.max(0, Math.round(i - g)), p = Math.min(e, Math.round(i + g));
|
|
3022
|
+
p > l && o.fill(255, f * e + l, f * e + p);
|
|
3008
3023
|
}
|
|
3009
3024
|
return o;
|
|
3010
3025
|
}
|
|
3011
|
-
function
|
|
3026
|
+
function vt(e, t, r, n, o) {
|
|
3012
3027
|
let i = e;
|
|
3013
3028
|
for (let s = 0; s < Math.max(0, Math.round(n)); s++) {
|
|
3014
3029
|
const c = new Uint8Array(i.length);
|
|
3015
|
-
for (let a = 0; a < r; a++) for (let
|
|
3030
|
+
for (let a = 0; a < r; a++) for (let h = 0; h < t; h++) {
|
|
3016
3031
|
let y = !o;
|
|
3017
|
-
for (let
|
|
3018
|
-
const m = a +
|
|
3019
|
-
for (let
|
|
3020
|
-
const l =
|
|
3032
|
+
for (let f = -1; f <= 1 && y !== o; f++) {
|
|
3033
|
+
const m = a + f;
|
|
3034
|
+
for (let g = -1; g <= 1; g++) {
|
|
3035
|
+
const l = h + g, p = l >= 0 && l < t && m >= 0 && m < r ? i[m * t + l] > 127 : !1;
|
|
3021
3036
|
if (o && p) {
|
|
3022
3037
|
y = !0;
|
|
3023
3038
|
break;
|
|
@@ -3028,13 +3043,13 @@ Component that was made reactive: `, type);
|
|
|
3028
3043
|
}
|
|
3029
3044
|
}
|
|
3030
3045
|
}
|
|
3031
|
-
c[a * t +
|
|
3046
|
+
c[a * t + h] = y ? 255 : 0;
|
|
3032
3047
|
}
|
|
3033
3048
|
i = c;
|
|
3034
3049
|
}
|
|
3035
3050
|
return i;
|
|
3036
3051
|
}
|
|
3037
|
-
function
|
|
3052
|
+
function Gn(e, t, r, n = 2) {
|
|
3038
3053
|
const o = new Float32Array(e.length), i = new Uint8Array(e.length);
|
|
3039
3054
|
for (let s = 0; s < r; s++) {
|
|
3040
3055
|
let c = 0;
|
|
@@ -3048,50 +3063,50 @@ Component that was made reactive: `, type);
|
|
|
3048
3063
|
}
|
|
3049
3064
|
return i;
|
|
3050
3065
|
}
|
|
3051
|
-
function
|
|
3066
|
+
function ee(e, t, r) {
|
|
3052
3067
|
const n = r === "add" ? 255 : 0;
|
|
3053
3068
|
let o = 0;
|
|
3054
3069
|
for (let i = 0; i < e.length; i++) t[i] && e[i] !== n && (e[i] = n, o++);
|
|
3055
3070
|
return o;
|
|
3056
3071
|
}
|
|
3057
|
-
function
|
|
3058
|
-
const c = s === "add" ? 255 : 0, a = Math.max(.5, i),
|
|
3072
|
+
function qe(e, t, r, n, o, i, s) {
|
|
3073
|
+
const c = s === "add" ? 255 : 0, a = Math.max(.5, i), h = a * a, y = Math.max(0, Math.floor(n - a)), f = Math.min(t - 1, Math.ceil(n + a)), m = Math.max(0, Math.floor(o - a)), g = Math.min(r - 1, Math.ceil(o + a));
|
|
3059
3074
|
let l = 0;
|
|
3060
|
-
for (let u = m; u <=
|
|
3061
|
-
const
|
|
3062
|
-
for (let w = y; w <=
|
|
3063
|
-
const
|
|
3064
|
-
if (
|
|
3065
|
-
const
|
|
3066
|
-
e[
|
|
3075
|
+
for (let u = m; u <= g; u++) {
|
|
3076
|
+
const v = u + .5 - o;
|
|
3077
|
+
for (let w = y; w <= f; w++) {
|
|
3078
|
+
const k = w + .5 - n;
|
|
3079
|
+
if (k * k + v * v > h) continue;
|
|
3080
|
+
const b = u * t + w;
|
|
3081
|
+
e[b] !== c && (e[b] = c, l++);
|
|
3067
3082
|
}
|
|
3068
3083
|
}
|
|
3069
3084
|
const p = Math.floor(n), d = Math.floor(o);
|
|
3070
3085
|
return p >= 0 && d >= 0 && p < t && d < r && e[d * t + p] !== c && (e[d * t + p] = c, l++), l;
|
|
3071
3086
|
}
|
|
3072
|
-
function
|
|
3087
|
+
function wt(e, t, r, n, o, i, s) {
|
|
3073
3088
|
const c = Math.hypot(o.x - n.x, o.y - n.y), a = Math.max(1, Math.ceil(c / Math.max(.5, i / 2)));
|
|
3074
|
-
let
|
|
3089
|
+
let h = 0;
|
|
3075
3090
|
for (let y = 0; y <= a; y++) {
|
|
3076
|
-
const
|
|
3077
|
-
|
|
3091
|
+
const f = y / a;
|
|
3092
|
+
h += qe(e, t, r, n.x + (o.x - n.x) * f, n.y + (o.y - n.y) * f, i, s);
|
|
3078
3093
|
}
|
|
3079
|
-
return
|
|
3094
|
+
return h;
|
|
3080
3095
|
}
|
|
3081
|
-
function
|
|
3096
|
+
function Jn(e) {
|
|
3082
3097
|
for (let t = 0; t < e.length; t++) e[t] = 255 - e[t];
|
|
3083
3098
|
return e;
|
|
3084
3099
|
}
|
|
3085
|
-
function
|
|
3100
|
+
function Qn(e) {
|
|
3086
3101
|
if (!e.length) return 0;
|
|
3087
3102
|
let t = 0;
|
|
3088
3103
|
for (let r = 0; r < e.length; r++) t += e[r];
|
|
3089
3104
|
return t / (e.length * 255);
|
|
3090
3105
|
}
|
|
3091
|
-
function
|
|
3106
|
+
function Zn(e, t, r = 5, n = 1, o = 200) {
|
|
3092
3107
|
return Math.min(o, Math.max(n, Math.round(e + t * r)));
|
|
3093
3108
|
}
|
|
3094
|
-
function
|
|
3109
|
+
function er(e, t = "alpha", r) {
|
|
3095
3110
|
const n = new Uint8ClampedArray(e.length * 4);
|
|
3096
3111
|
if (t === "cutout" && (!r || r.length < n.length)) throw new Error("cutout needs the source pixels");
|
|
3097
3112
|
for (let o = 0, i = 0; o < e.length; o++, i += 4) {
|
|
@@ -3100,12 +3115,12 @@ Component that was made reactive: `, type);
|
|
|
3100
3115
|
}
|
|
3101
3116
|
return n;
|
|
3102
3117
|
}
|
|
3103
|
-
function
|
|
3118
|
+
function tr(e, t, r = .5, n) {
|
|
3104
3119
|
const o = n && n.length === e.length * 4 ? n : new Uint8ClampedArray(e.length * 4);
|
|
3105
3120
|
for (let i = 0, s = 0; i < e.length; i++, s += 4) o[s] = t[0], o[s + 1] = t[1], o[s + 2] = t[2], o[s + 3] = Math.round(e[i] * r);
|
|
3106
3121
|
return o;
|
|
3107
3122
|
}
|
|
3108
|
-
function
|
|
3123
|
+
function nr(e) {
|
|
3109
3124
|
const t = e.trim();
|
|
3110
3125
|
let r = /^#([0-9a-f]{6})$/i.exec(t);
|
|
3111
3126
|
if (r) {
|
|
@@ -3128,426 +3143,467 @@ Component that was made reactive: `, type);
|
|
|
3128
3143
|
134
|
|
3129
3144
|
];
|
|
3130
3145
|
}
|
|
3131
|
-
function
|
|
3146
|
+
function rr(e) {
|
|
3132
3147
|
for (let t = e.parentElement; t; t = t.parentElement) {
|
|
3133
3148
|
const r = getComputedStyle(t);
|
|
3134
3149
|
if (/(auto|scroll)/.test(r.overflow + r.overflowX + r.overflowY)) return t;
|
|
3135
3150
|
}
|
|
3136
3151
|
return null;
|
|
3137
3152
|
}
|
|
3138
|
-
function
|
|
3153
|
+
function or(e) {
|
|
3139
3154
|
return !!e && typeof e == "object" && "data" in e && "width" in e && "height" in e && !(typeof HTMLElement < "u" && e instanceof HTMLElement);
|
|
3140
3155
|
}
|
|
3141
|
-
function
|
|
3156
|
+
function ir() {
|
|
3142
3157
|
try {
|
|
3143
3158
|
return typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches;
|
|
3144
3159
|
} catch {
|
|
3145
3160
|
return !1;
|
|
3146
3161
|
}
|
|
3147
3162
|
}
|
|
3148
|
-
function
|
|
3163
|
+
function sr(e) {
|
|
3149
3164
|
return new Promise((t, r) => {
|
|
3150
3165
|
const n = new Image();
|
|
3151
3166
|
/^(data|blob):/.test(e) || (n.crossOrigin = "anonymous"), n.onload = () => t(n), n.onerror = () => r(/* @__PURE__ */ new Error("the image did not load")), n.src = e;
|
|
3152
3167
|
});
|
|
3153
3168
|
}
|
|
3154
|
-
function
|
|
3155
|
-
const r = e.ownerDocument, n = e.getContext("2d"), o =
|
|
3169
|
+
function ns(e, t = {}) {
|
|
3170
|
+
const r = e.ownerDocument, n = e.getContext("2d"), o = X(), i = yn(t.history ?? 50), s = (M, E) => {
|
|
3156
3171
|
try {
|
|
3157
|
-
return (getComputedStyle(e).getPropertyValue(M) ||
|
|
3172
|
+
return (getComputedStyle(e).getPropertyValue(M) || E).trim();
|
|
3158
3173
|
} catch {
|
|
3159
|
-
return
|
|
3160
|
-
}
|
|
3161
|
-
}, c =
|
|
3162
|
-
let
|
|
3163
|
-
e.style.touchAction = "none", e.dataset.tool =
|
|
3164
|
-
const
|
|
3165
|
-
tool:
|
|
3166
|
-
mode:
|
|
3167
|
-
size:
|
|
3168
|
-
tolerance:
|
|
3169
|
-
contiguous:
|
|
3174
|
+
return E;
|
|
3175
|
+
}
|
|
3176
|
+
}, c = nr(t.tint ?? s("--hb-pink", "#FE0386")), a = s("--hb-slime", "#a6e22e"), h = s("--hb-lit-err", "#ff5c4d"), y = s("--hb-void", "#0a0a0a");
|
|
3177
|
+
let f = 0, m = 0, g = null, l = null, p = null, d = null, u = /* @__PURE__ */ new Uint8Array(0), v = 0, w = !1, k = 0, b = t.tool ?? "wand", x = t.mode ?? "add", T = t.size ?? (ir() ? 44 : 24), z = t.tolerance ?? 6, L = t.contiguous ?? !0, S = null, C = null, $ = !1, A = null;
|
|
3178
|
+
e.style.touchAction = "none", e.dataset.tool = b, e.dataset.mode = x;
|
|
3179
|
+
const O = () => ({
|
|
3180
|
+
tool: b,
|
|
3181
|
+
mode: x,
|
|
3182
|
+
size: T,
|
|
3183
|
+
tolerance: z,
|
|
3184
|
+
contiguous: L,
|
|
3170
3185
|
canUndo: i.canUndo,
|
|
3171
3186
|
canRedo: i.canRedo,
|
|
3172
|
-
coverage:
|
|
3173
|
-
width:
|
|
3187
|
+
coverage: v,
|
|
3188
|
+
width: f,
|
|
3174
3189
|
height: m,
|
|
3175
3190
|
ready: w,
|
|
3176
|
-
drawing: !!
|
|
3177
|
-
}),
|
|
3178
|
-
let
|
|
3179
|
-
function
|
|
3180
|
-
!n ||
|
|
3181
|
-
|
|
3182
|
-
}) :
|
|
3183
|
-
}
|
|
3184
|
-
function
|
|
3191
|
+
drawing: !!S
|
|
3192
|
+
}), I = () => o.emit(O());
|
|
3193
|
+
let N = 0, U = !0;
|
|
3194
|
+
function K() {
|
|
3195
|
+
!n || N || (typeof requestAnimationFrame == "function" ? N = requestAnimationFrame(() => {
|
|
3196
|
+
N = 0, J();
|
|
3197
|
+
}) : J());
|
|
3198
|
+
}
|
|
3199
|
+
function H() {
|
|
3185
3200
|
const M = e.getBoundingClientRect();
|
|
3186
|
-
return M.width > 0 &&
|
|
3201
|
+
return M.width > 0 && f > 0 ? M.width / f : 1;
|
|
3187
3202
|
}
|
|
3188
|
-
function
|
|
3189
|
-
if (!n || (n.clearRect(0, 0,
|
|
3203
|
+
function J() {
|
|
3204
|
+
if (!n || (n.clearRect(0, 0, f, m), !w)) return;
|
|
3190
3205
|
if (l && n.drawImage(l, 0, 0), p) {
|
|
3191
|
-
const
|
|
3192
|
-
|
|
3206
|
+
const q = p.getContext("2d");
|
|
3207
|
+
U && q && (d = d ?? q.createImageData(f, m), tr(u, c, .5, d.data), q.putImageData(d, 0, 0), U = !1), n.drawImage(p, 0, 0);
|
|
3193
3208
|
}
|
|
3194
|
-
const M = 1 /
|
|
3195
|
-
if ((
|
|
3196
|
-
n.beginPath(), n.moveTo(
|
|
3197
|
-
for (const
|
|
3198
|
-
n.closePath(), n.setLineDash([]), n.lineWidth = 4 * M, n.strokeStyle = y, n.stroke(), n.setLineDash([6 * M, 4 * M]), n.lineWidth = 2 * M, n.strokeStyle =
|
|
3209
|
+
const M = 1 / H(), E = S;
|
|
3210
|
+
if ((E == null ? void 0 : E.kind) === "lasso" && E.pts.length > 1) {
|
|
3211
|
+
n.beginPath(), n.moveTo(E.pts[0].x, E.pts[0].y);
|
|
3212
|
+
for (const q of E.pts) n.lineTo(q.x, q.y);
|
|
3213
|
+
n.closePath(), n.setLineDash([]), n.lineWidth = 4 * M, n.strokeStyle = y, n.stroke(), n.setLineDash([6 * M, 4 * M]), n.lineWidth = 2 * M, n.strokeStyle = E.mode === "add" ? a : h, n.stroke(), n.setLineDash([]);
|
|
3199
3214
|
}
|
|
3200
|
-
const
|
|
3201
|
-
n.beginPath(),
|
|
3215
|
+
const D = (q, P, j) => {
|
|
3216
|
+
n.beginPath(), P(), j && n.closePath(), n.setLineDash([]), n.lineWidth = 4 * M, n.strokeStyle = y, n.stroke(), n.setLineDash([6 * M, 4 * M]), n.lineWidth = 2 * M, n.strokeStyle = q === "add" ? a : h, n.stroke(), n.setLineDash([]);
|
|
3202
3217
|
};
|
|
3203
|
-
if ((
|
|
3204
|
-
const
|
|
3205
|
-
|
|
3206
|
-
}
|
|
3207
|
-
if (
|
|
3208
|
-
const
|
|
3209
|
-
|
|
3210
|
-
n.moveTo(
|
|
3211
|
-
for (const
|
|
3218
|
+
if ((E == null ? void 0 : E.kind) === "shape") {
|
|
3219
|
+
const q = Math.min(E.a.x, E.b.x), P = Math.min(E.a.y, E.b.y), j = Math.abs(E.b.x - E.a.x), F = Math.abs(E.b.y - E.a.y);
|
|
3220
|
+
D(E.mode, () => E.ellipse ? n.ellipse(q + j / 2, P + F / 2, j / 2, F / 2, 0, 0, Math.PI * 2) : n.rect(q, P, j, F), !0);
|
|
3221
|
+
}
|
|
3222
|
+
if (C && C.pts.length) {
|
|
3223
|
+
const q = A ? [...C.pts, A] : C.pts;
|
|
3224
|
+
D(C.mode, () => {
|
|
3225
|
+
n.moveTo(q[0].x, q[0].y);
|
|
3226
|
+
for (const P of q) n.lineTo(P.x, P.y);
|
|
3212
3227
|
}, !1);
|
|
3213
|
-
for (const
|
|
3228
|
+
for (const P of C.pts) n.fillStyle = y, n.fillRect(P.x - 3 * M, P.y - 3 * M, 6 * M, 6 * M);
|
|
3214
3229
|
}
|
|
3215
|
-
if ((
|
|
3216
|
-
const
|
|
3217
|
-
n.beginPath(), n.arc(
|
|
3230
|
+
if ((b === "brush" || b === "eraser") && A) {
|
|
3231
|
+
const q = (E == null ? void 0 : E.kind) === "brush" ? E.mode : b === "eraser" ? "erase" : x;
|
|
3232
|
+
n.beginPath(), n.arc(A.x, A.y, T / 2 * M, 0, Math.PI * 2), n.lineWidth = 3.5 * M, n.strokeStyle = y, n.stroke(), n.lineWidth = 1.5 * M, n.strokeStyle = q === "add" ? a : h, n.stroke();
|
|
3218
3233
|
}
|
|
3219
3234
|
}
|
|
3220
|
-
function
|
|
3235
|
+
function W() {
|
|
3221
3236
|
var M;
|
|
3222
|
-
|
|
3237
|
+
v = Qn(u), U = !0, K(), I(), (M = t.onEdit) == null || M.call(t, u);
|
|
3223
3238
|
}
|
|
3224
|
-
function
|
|
3239
|
+
function B(M) {
|
|
3225
3240
|
if (!w) return;
|
|
3226
|
-
const
|
|
3227
|
-
M() > 0 && (i.push(
|
|
3228
|
-
}
|
|
3229
|
-
const
|
|
3230
|
-
async function
|
|
3231
|
-
var
|
|
3232
|
-
const
|
|
3233
|
-
w = !1,
|
|
3234
|
-
let
|
|
3241
|
+
const E = u.slice();
|
|
3242
|
+
M() > 0 && (i.push(E), W());
|
|
3243
|
+
}
|
|
3244
|
+
const ue = (M) => M / 2 / H();
|
|
3245
|
+
async function ae(M) {
|
|
3246
|
+
var P;
|
|
3247
|
+
const E = ++k;
|
|
3248
|
+
w = !1, I();
|
|
3249
|
+
let D, q = null;
|
|
3235
3250
|
try {
|
|
3236
|
-
if (
|
|
3237
|
-
if (
|
|
3251
|
+
if (or(M)) {
|
|
3252
|
+
if (D = {
|
|
3238
3253
|
data: M.data,
|
|
3239
3254
|
width: M.width,
|
|
3240
3255
|
height: M.height
|
|
3241
3256
|
}, n) {
|
|
3242
|
-
|
|
3243
|
-
const
|
|
3244
|
-
|
|
3257
|
+
q = r.createElement("canvas"), q.width = D.width, q.height = D.height;
|
|
3258
|
+
const j = q.getContext("2d"), F = j.createImageData(D.width, D.height);
|
|
3259
|
+
F.data.set(D.data), j.putImageData(F, 0, 0);
|
|
3245
3260
|
}
|
|
3246
3261
|
} else {
|
|
3247
|
-
const
|
|
3248
|
-
if (
|
|
3249
|
-
const
|
|
3250
|
-
if (!(
|
|
3251
|
-
|
|
3252
|
-
const
|
|
3253
|
-
if (!
|
|
3254
|
-
|
|
3255
|
-
data:
|
|
3256
|
-
width:
|
|
3257
|
-
height:
|
|
3262
|
+
const j = typeof M == "string" ? await sr(M) : M;
|
|
3263
|
+
if (E !== k) return;
|
|
3264
|
+
const F = j, Z = F.naturalWidth || F.videoWidth || (typeof F.width == "number" ? F.width : 0), le = F.naturalHeight || F.videoHeight || (typeof F.height == "number" ? F.height : 0);
|
|
3265
|
+
if (!(Z > 0 && le > 0)) throw new Error("the image has no size");
|
|
3266
|
+
q = r.createElement("canvas"), q.width = Z, q.height = le;
|
|
3267
|
+
const ke = q.getContext("2d");
|
|
3268
|
+
if (!ke) throw new Error("no 2d canvas in this browser");
|
|
3269
|
+
ke.drawImage(j, 0, 0, Z, le), D = {
|
|
3270
|
+
data: ke.getImageData(0, 0, Z, le).data,
|
|
3271
|
+
width: Z,
|
|
3272
|
+
height: le
|
|
3258
3273
|
};
|
|
3259
3274
|
}
|
|
3260
|
-
} catch (
|
|
3261
|
-
if (
|
|
3262
|
-
const
|
|
3263
|
-
throw (
|
|
3264
|
-
}
|
|
3265
|
-
|
|
3266
|
-
}
|
|
3267
|
-
const
|
|
3268
|
-
const
|
|
3269
|
-
return
|
|
3270
|
-
},
|
|
3271
|
-
function
|
|
3272
|
-
var
|
|
3273
|
-
if (!w ||
|
|
3274
|
-
const
|
|
3275
|
-
if (!
|
|
3275
|
+
} catch (j) {
|
|
3276
|
+
if (E !== k) return;
|
|
3277
|
+
const F = j instanceof Error ? j : new Error(String(j));
|
|
3278
|
+
throw (P = t.onError) == null || P.call(t, F), I(), F;
|
|
3279
|
+
}
|
|
3280
|
+
E === k && (g = D, l = q, f = D.width, m = D.height, e.width = f, e.height = m, u = new Uint8Array(f * m), v = 0, i.clear(), S = null, n && (p = r.createElement("canvas"), p.width = f, p.height = m, d = null), U = !0, w = !0, K(), I());
|
|
3281
|
+
}
|
|
3282
|
+
const de = (M, E = !1) => {
|
|
3283
|
+
const D = e.getBoundingClientRect();
|
|
3284
|
+
return f ? Yn(M.clientX, M.clientY, D, f, m, E) : null;
|
|
3285
|
+
}, Pe = (M) => M === "add" ? "erase" : "add";
|
|
3286
|
+
function Fe(M) {
|
|
3287
|
+
var P, j;
|
|
3288
|
+
if (!w || S || M.pointerType === "mouse" && M.button !== 0) return;
|
|
3289
|
+
const E = de(M);
|
|
3290
|
+
if (!E) return;
|
|
3276
3291
|
M.preventDefault();
|
|
3277
3292
|
try {
|
|
3278
3293
|
e.focus({ preventScroll: !0 });
|
|
3279
3294
|
} catch {}
|
|
3280
|
-
const
|
|
3281
|
-
if (
|
|
3282
|
-
(
|
|
3295
|
+
const D = b === "eraser" ? "erase" : x, q = M.shiftKey ? Pe(D) : D;
|
|
3296
|
+
if (b === "pan" || $) {
|
|
3297
|
+
(P = e.setPointerCapture) == null || P.call(e, M.pointerId), S = {
|
|
3283
3298
|
kind: "pan",
|
|
3284
3299
|
id: M.pointerId,
|
|
3285
3300
|
x: M.clientX,
|
|
3286
3301
|
y: M.clientY,
|
|
3287
|
-
el:
|
|
3288
|
-
},
|
|
3302
|
+
el: rr(e)
|
|
3303
|
+
}, I();
|
|
3289
3304
|
return;
|
|
3290
3305
|
}
|
|
3291
|
-
if (
|
|
3292
|
-
|
|
3306
|
+
if (b === "wand") {
|
|
3307
|
+
Ye(E.x, E.y, q);
|
|
3293
3308
|
return;
|
|
3294
3309
|
}
|
|
3295
|
-
if (
|
|
3296
|
-
|
|
3310
|
+
if (b === "flood") {
|
|
3311
|
+
Ge(E.x, E.y, q);
|
|
3297
3312
|
return;
|
|
3298
3313
|
}
|
|
3299
|
-
if (
|
|
3300
|
-
const
|
|
3301
|
-
if (
|
|
3302
|
-
|
|
3314
|
+
if (b === "polygon") {
|
|
3315
|
+
const F = 1 / H();
|
|
3316
|
+
if (C && C.pts.length > 2 && Math.hypot(E.x - C.pts[0].x, E.y - C.pts[0].y) <= 10 * F) {
|
|
3317
|
+
Je();
|
|
3303
3318
|
return;
|
|
3304
3319
|
}
|
|
3305
|
-
|
|
3306
|
-
mode:
|
|
3320
|
+
C || (C = {
|
|
3321
|
+
mode: q,
|
|
3307
3322
|
pts: []
|
|
3308
|
-
}),
|
|
3323
|
+
}), C.pts.push(E), K(), I();
|
|
3309
3324
|
return;
|
|
3310
3325
|
}
|
|
3311
|
-
if ((
|
|
3326
|
+
if ((j = e.setPointerCapture) == null || j.call(e, M.pointerId), b === "rect" || b === "ellipse") S = {
|
|
3312
3327
|
kind: "shape",
|
|
3313
3328
|
id: M.pointerId,
|
|
3314
|
-
mode:
|
|
3315
|
-
a:
|
|
3316
|
-
b:
|
|
3317
|
-
ellipse:
|
|
3329
|
+
mode: q,
|
|
3330
|
+
a: E,
|
|
3331
|
+
b: E,
|
|
3332
|
+
ellipse: b === "ellipse"
|
|
3318
3333
|
};
|
|
3319
|
-
else if (
|
|
3320
|
-
const
|
|
3321
|
-
|
|
3334
|
+
else if (b === "brush" || b === "eraser") {
|
|
3335
|
+
const F = u.slice(), Z = qe(u, f, m, E.x, E.y, ue(T), q);
|
|
3336
|
+
S = {
|
|
3322
3337
|
kind: "brush",
|
|
3323
3338
|
id: M.pointerId,
|
|
3324
|
-
mode:
|
|
3325
|
-
last:
|
|
3326
|
-
before:
|
|
3327
|
-
n:
|
|
3328
|
-
},
|
|
3329
|
-
} else
|
|
3339
|
+
mode: q,
|
|
3340
|
+
last: E,
|
|
3341
|
+
before: F,
|
|
3342
|
+
n: Z
|
|
3343
|
+
}, A = E, U = !0;
|
|
3344
|
+
} else S = {
|
|
3330
3345
|
kind: "lasso",
|
|
3331
3346
|
id: M.pointerId,
|
|
3332
|
-
mode:
|
|
3333
|
-
pts: [
|
|
3347
|
+
mode: q,
|
|
3348
|
+
pts: [E]
|
|
3334
3349
|
};
|
|
3335
|
-
|
|
3350
|
+
K(), I();
|
|
3336
3351
|
}
|
|
3337
|
-
function
|
|
3338
|
-
const
|
|
3339
|
-
if (
|
|
3340
|
-
if ((
|
|
3341
|
-
|
|
3352
|
+
function Ne(M) {
|
|
3353
|
+
const E = S;
|
|
3354
|
+
if (E && M.pointerId !== E.id) return;
|
|
3355
|
+
if ((E == null ? void 0 : E.kind) === "pan") {
|
|
3356
|
+
E.el && (E.el.scrollLeft -= M.clientX - E.x, E.el.scrollTop -= M.clientY - E.y), E.x = M.clientX, E.y = M.clientY;
|
|
3342
3357
|
return;
|
|
3343
3358
|
}
|
|
3344
|
-
const
|
|
3345
|
-
if (
|
|
3346
|
-
if (
|
|
3347
|
-
else if ((
|
|
3348
|
-
const
|
|
3349
|
-
Math.hypot(
|
|
3359
|
+
const D = de(M, !0);
|
|
3360
|
+
if (D) {
|
|
3361
|
+
if (A = M.pointerType === "touch" && !E ? null : D, (E == null ? void 0 : E.kind) === "shape" && (E.b = D), (E == null ? void 0 : E.kind) === "brush") E.n += wt(u, f, m, E.last, D, ue(T), E.mode), E.last = D, U = !0;
|
|
3362
|
+
else if ((E == null ? void 0 : E.kind) === "lasso") {
|
|
3363
|
+
const q = E.pts[E.pts.length - 1];
|
|
3364
|
+
Math.hypot(D.x - q.x, D.y - q.y) * H() >= 2 && E.pts.push(D);
|
|
3350
3365
|
}
|
|
3351
|
-
|
|
3366
|
+
K();
|
|
3352
3367
|
}
|
|
3353
3368
|
}
|
|
3354
|
-
function
|
|
3355
|
-
const
|
|
3356
|
-
if (!(!
|
|
3357
|
-
if (
|
|
3358
|
-
|
|
3369
|
+
function Ke(M) {
|
|
3370
|
+
const E = S;
|
|
3371
|
+
if (!(!E || M.pointerId !== E.id)) {
|
|
3372
|
+
if (S = null, M.pointerType === "touch" && (A = null), E.kind === "pan") {
|
|
3373
|
+
I();
|
|
3359
3374
|
return;
|
|
3360
3375
|
}
|
|
3361
|
-
if (
|
|
3362
|
-
const
|
|
3363
|
-
|
|
3376
|
+
if (E.kind === "shape") {
|
|
3377
|
+
const D = E.ellipse ? bt(f, m, E.a, E.b) : yt(f, m, E.a, E.b);
|
|
3378
|
+
B(() => ee(u, D, E.mode)), K(), I();
|
|
3364
3379
|
return;
|
|
3365
3380
|
}
|
|
3366
|
-
|
|
3381
|
+
E.kind === "brush" ? E.n > 0 ? (i.push(E.before), W()) : I() : (B(() => ee(u, Se(f, m, E.pts), E.mode)), K(), I());
|
|
3367
3382
|
}
|
|
3368
3383
|
}
|
|
3369
|
-
function
|
|
3370
|
-
!
|
|
3384
|
+
function He(M) {
|
|
3385
|
+
!S && M.pointerType !== "touch" && (A = null, K());
|
|
3371
3386
|
}
|
|
3372
|
-
function
|
|
3373
|
-
|
|
3374
|
-
const M =
|
|
3375
|
-
M && (
|
|
3387
|
+
function re() {
|
|
3388
|
+
C && (C = null, K(), I());
|
|
3389
|
+
const M = S;
|
|
3390
|
+
M && (S = null, M.kind === "brush" && (u.set(M.before), U = !0), K(), I());
|
|
3376
3391
|
}
|
|
3377
|
-
function
|
|
3378
|
-
|
|
3392
|
+
function je(M) {
|
|
3393
|
+
S && M.pointerId === S.id && re();
|
|
3379
3394
|
}
|
|
3380
|
-
const
|
|
3381
|
-
function
|
|
3382
|
-
if (M.defaultPrevented || M.altKey ||
|
|
3383
|
-
const
|
|
3384
|
-
let
|
|
3385
|
-
if (
|
|
3386
|
-
else if (
|
|
3387
|
-
else if (
|
|
3388
|
-
else if (
|
|
3389
|
-
else if (
|
|
3390
|
-
else if (
|
|
3391
|
-
else if (
|
|
3392
|
-
else if (
|
|
3393
|
-
else if (
|
|
3394
|
-
else if (
|
|
3395
|
+
const V = t.keys === !1 ? null : t.keys ?? e;
|
|
3396
|
+
function Be(M) {
|
|
3397
|
+
if (M.defaultPrevented || M.altKey || be(M.target)) return;
|
|
3398
|
+
const E = M.key.toLowerCase(), D = M.ctrlKey || M.metaKey;
|
|
3399
|
+
let q = !0;
|
|
3400
|
+
if (D && E === "z") M.shiftKey ? Me() : Qe();
|
|
3401
|
+
else if (D && E === "y") Me();
|
|
3402
|
+
else if (D) q = !1;
|
|
3403
|
+
else if (E === "escape") S || C ? re() : q = !1;
|
|
3404
|
+
else if (E === "enter" && C) Je();
|
|
3405
|
+
else if (E === "backspace" && C) C.pts.pop(), C.pts.length || (C = null), K(), I();
|
|
3406
|
+
else if (E === " ") $ = !0, e.dataset.tool = "pan";
|
|
3407
|
+
else if (E === "x") _e();
|
|
3408
|
+
else if (E === "[") ve(-1);
|
|
3409
|
+
else if (E === "]") ve(1);
|
|
3395
3410
|
else {
|
|
3396
|
-
const
|
|
3397
|
-
|
|
3411
|
+
const P = gt.find((j) => j.key === E);
|
|
3412
|
+
P ? We(P.id) : q = !1;
|
|
3398
3413
|
}
|
|
3399
|
-
|
|
3414
|
+
q && M.preventDefault();
|
|
3400
3415
|
}
|
|
3401
|
-
function
|
|
3402
|
-
M.key === " " &&
|
|
3416
|
+
function Ue(M) {
|
|
3417
|
+
M.key === " " && $ && ($ = !1, e.dataset.tool = b);
|
|
3403
3418
|
}
|
|
3404
|
-
|
|
3405
|
-
function
|
|
3406
|
-
M ===
|
|
3419
|
+
V?.addEventListener("keyup", Ue), e.addEventListener("pointerdown", Fe), e.addEventListener("pointermove", Ne), e.addEventListener("pointerup", Ke), e.addEventListener("pointercancel", je), e.addEventListener("pointerleave", He), V?.addEventListener("keydown", Be);
|
|
3420
|
+
function We(M) {
|
|
3421
|
+
M === b || !gt.some((E) => E.id === M) || (re(), b = M, e.dataset.tool = M, M !== "brush" && M !== "eraser" && M !== "polygon" && (A = null), K(), I());
|
|
3407
3422
|
}
|
|
3408
|
-
function
|
|
3409
|
-
M !==
|
|
3423
|
+
function Ve(M) {
|
|
3424
|
+
M !== x && (x = M, e.dataset.mode = M, K(), I());
|
|
3410
3425
|
}
|
|
3411
|
-
function
|
|
3412
|
-
|
|
3426
|
+
function _e() {
|
|
3427
|
+
Ve(Pe(x));
|
|
3413
3428
|
}
|
|
3414
|
-
function
|
|
3415
|
-
const
|
|
3416
|
-
|
|
3429
|
+
function Xe(M) {
|
|
3430
|
+
const E = Math.min(200, Math.max(1, Math.round(M)));
|
|
3431
|
+
E === T || !Number.isFinite(E) || (T = E, K(), I());
|
|
3417
3432
|
}
|
|
3418
|
-
function
|
|
3419
|
-
|
|
3433
|
+
function ve(M) {
|
|
3434
|
+
Xe(Zn(T, M));
|
|
3420
3435
|
}
|
|
3421
|
-
function
|
|
3422
|
-
const
|
|
3423
|
-
|
|
3436
|
+
function Ht(M) {
|
|
3437
|
+
const E = Math.min(100, Math.max(0, M));
|
|
3438
|
+
E === z || !Number.isFinite(E) || (z = E, I());
|
|
3424
3439
|
}
|
|
3425
|
-
function
|
|
3426
|
-
M !==
|
|
3440
|
+
function jt(M) {
|
|
3441
|
+
M !== L && (L = M, I());
|
|
3427
3442
|
}
|
|
3428
|
-
function
|
|
3429
|
-
if (!
|
|
3430
|
-
const
|
|
3431
|
-
|
|
3443
|
+
function Ye(M, E, D = x) {
|
|
3444
|
+
if (!g) return;
|
|
3445
|
+
const q = g;
|
|
3446
|
+
B(() => ee(u, pt(q, M, E, z, L), D));
|
|
3432
3447
|
}
|
|
3433
|
-
function
|
|
3434
|
-
if (!
|
|
3435
|
-
const
|
|
3436
|
-
|
|
3448
|
+
function Ge(M, E, D = x) {
|
|
3449
|
+
if (!g) return;
|
|
3450
|
+
const q = g;
|
|
3451
|
+
B(() => ee(u, pt(q, M, E, z, !0), D));
|
|
3437
3452
|
}
|
|
3438
|
-
function
|
|
3439
|
-
const M =
|
|
3440
|
-
|
|
3453
|
+
function Je() {
|
|
3454
|
+
const M = C;
|
|
3455
|
+
C = null, M && M.pts.length > 2 && B(() => ee(u, Se(f, m, M.pts), M.mode)), K(), I();
|
|
3441
3456
|
}
|
|
3442
|
-
function
|
|
3443
|
-
|
|
3457
|
+
function Bt(M, E, D = !1, q = x) {
|
|
3458
|
+
B(() => ee(u, D ? bt(f, m, M, E) : yt(f, m, M, E), q));
|
|
3444
3459
|
}
|
|
3445
|
-
function
|
|
3446
|
-
let
|
|
3447
|
-
for (let
|
|
3448
|
-
return
|
|
3460
|
+
function we(M) {
|
|
3461
|
+
let E = 0;
|
|
3462
|
+
for (let D = 0; D < u.length; D++) u[D] !== M[D] && (u[D] = M[D], E++);
|
|
3463
|
+
return E;
|
|
3449
3464
|
}
|
|
3450
|
-
function
|
|
3451
|
-
|
|
3465
|
+
function Ut(M = 3) {
|
|
3466
|
+
B(() => we(vt(u, f, m, M, !0)));
|
|
3452
3467
|
}
|
|
3453
|
-
function
|
|
3454
|
-
|
|
3468
|
+
function Wt(M = 3) {
|
|
3469
|
+
B(() => we(vt(u, f, m, M, !1)));
|
|
3455
3470
|
}
|
|
3456
|
-
function
|
|
3457
|
-
|
|
3471
|
+
function Vt(M = 2) {
|
|
3472
|
+
B(() => we(Gn(u, f, m, M)));
|
|
3458
3473
|
}
|
|
3459
|
-
function
|
|
3460
|
-
M.length &&
|
|
3461
|
-
let
|
|
3462
|
-
for (let
|
|
3463
|
-
return
|
|
3474
|
+
function _t(M, E, D = x) {
|
|
3475
|
+
M.length && B(() => {
|
|
3476
|
+
let q = qe(u, f, m, M[0].x, M[0].y, E, D);
|
|
3477
|
+
for (let P = 1; P < M.length; P++) q += wt(u, f, m, M[P - 1], M[P], E, D);
|
|
3478
|
+
return q;
|
|
3464
3479
|
});
|
|
3465
3480
|
}
|
|
3466
|
-
function
|
|
3467
|
-
|
|
3481
|
+
function Xt(M, E = x) {
|
|
3482
|
+
B(() => ee(u, Se(f, m, M), E));
|
|
3468
3483
|
}
|
|
3469
|
-
function
|
|
3470
|
-
|
|
3484
|
+
function Yt() {
|
|
3485
|
+
B(() => {
|
|
3471
3486
|
let M = 0;
|
|
3472
|
-
for (let
|
|
3487
|
+
for (let E = 0; E < u.length; E++) u[E] && (u[E] = 0, M++);
|
|
3473
3488
|
return M;
|
|
3474
3489
|
});
|
|
3475
3490
|
}
|
|
3476
|
-
function
|
|
3477
|
-
|
|
3491
|
+
function Gt() {
|
|
3492
|
+
B(() => (Jn(u), u.length));
|
|
3478
3493
|
}
|
|
3479
|
-
function
|
|
3480
|
-
|
|
3494
|
+
function Qe() {
|
|
3495
|
+
re();
|
|
3481
3496
|
const M = i.undo(u.slice());
|
|
3482
|
-
return M ? (u = M,
|
|
3497
|
+
return M ? (u = M, W(), !0) : !1;
|
|
3483
3498
|
}
|
|
3484
|
-
function
|
|
3485
|
-
|
|
3499
|
+
function Me() {
|
|
3500
|
+
re();
|
|
3486
3501
|
const M = i.redo(u.slice());
|
|
3487
|
-
return M ? (u = M,
|
|
3502
|
+
return M ? (u = M, W(), !0) : !1;
|
|
3488
3503
|
}
|
|
3489
|
-
function
|
|
3504
|
+
function Ze(M = "alpha") {
|
|
3490
3505
|
if (!w) throw new Error("no image yet");
|
|
3491
|
-
const
|
|
3492
|
-
if (typeof ImageData < "u") return new ImageData(
|
|
3506
|
+
const E = er(u, M, g == null ? void 0 : g.data);
|
|
3507
|
+
if (typeof ImageData < "u") return new ImageData(E, f, m);
|
|
3493
3508
|
if (!n) throw new Error("no ImageData in this environment");
|
|
3494
|
-
const
|
|
3495
|
-
return
|
|
3509
|
+
const D = n.createImageData(f, m);
|
|
3510
|
+
return D.data.set(E), D;
|
|
3496
3511
|
}
|
|
3497
|
-
function
|
|
3498
|
-
const
|
|
3499
|
-
|
|
3500
|
-
const
|
|
3501
|
-
return
|
|
3512
|
+
function Jt(M = "alpha", E = "image/png") {
|
|
3513
|
+
const D = r.createElement("canvas");
|
|
3514
|
+
D.width = f, D.height = m;
|
|
3515
|
+
const q = D.getContext("2d");
|
|
3516
|
+
return q ? (q.putImageData(Ze(M), 0, 0), new Promise((P, j) => D.toBlob((F) => F ? P(F) : j(/* @__PURE__ */ new Error("the browser made no image")), E))) : Promise.reject(/* @__PURE__ */ new Error("no 2d canvas in this browser"));
|
|
3502
3517
|
}
|
|
3503
|
-
return t.image !== void 0 &&
|
|
3518
|
+
return t.image !== void 0 && ae(t.image).catch(() => {}), {
|
|
3504
3519
|
get state() {
|
|
3505
|
-
return
|
|
3506
|
-
},
|
|
3507
|
-
setImage:
|
|
3508
|
-
setTool:
|
|
3509
|
-
setMode:
|
|
3510
|
-
swap:
|
|
3511
|
-
setSize:
|
|
3512
|
-
stepSize:
|
|
3513
|
-
setTolerance:
|
|
3514
|
-
setContiguous:
|
|
3515
|
-
wandAt:
|
|
3516
|
-
floodAt:
|
|
3517
|
-
paint:
|
|
3518
|
-
lassoFill:
|
|
3519
|
-
shapeFill:
|
|
3520
|
-
expand:
|
|
3521
|
-
shrink:
|
|
3522
|
-
smooth:
|
|
3523
|
-
clear:
|
|
3524
|
-
invert:
|
|
3525
|
-
undo:
|
|
3526
|
-
redo:
|
|
3527
|
-
cancel:
|
|
3520
|
+
return O();
|
|
3521
|
+
},
|
|
3522
|
+
setImage: ae,
|
|
3523
|
+
setTool: We,
|
|
3524
|
+
setMode: Ve,
|
|
3525
|
+
swap: _e,
|
|
3526
|
+
setSize: Xe,
|
|
3527
|
+
stepSize: ve,
|
|
3528
|
+
setTolerance: Ht,
|
|
3529
|
+
setContiguous: jt,
|
|
3530
|
+
wandAt: Ye,
|
|
3531
|
+
floodAt: Ge,
|
|
3532
|
+
paint: _t,
|
|
3533
|
+
lassoFill: Xt,
|
|
3534
|
+
shapeFill: Bt,
|
|
3535
|
+
expand: Ut,
|
|
3536
|
+
shrink: Wt,
|
|
3537
|
+
smooth: Vt,
|
|
3538
|
+
clear: Yt,
|
|
3539
|
+
invert: Gt,
|
|
3540
|
+
undo: Qe,
|
|
3541
|
+
redo: Me,
|
|
3542
|
+
cancel: re,
|
|
3528
3543
|
mask: () => u.slice(),
|
|
3529
3544
|
setMask(M) {
|
|
3530
3545
|
if (M.length !== u.length) throw new Error(`mask is ${M.length} bytes, the image needs ${u.length}`);
|
|
3531
|
-
|
|
3532
|
-
let
|
|
3533
|
-
for (let
|
|
3534
|
-
const
|
|
3535
|
-
u[
|
|
3546
|
+
B(() => {
|
|
3547
|
+
let E = 0;
|
|
3548
|
+
for (let D = 0; D < u.length; D++) {
|
|
3549
|
+
const q = M[D] & 255;
|
|
3550
|
+
u[D] !== q && (u[D] = q, E++);
|
|
3536
3551
|
}
|
|
3537
|
-
return
|
|
3552
|
+
return E;
|
|
3538
3553
|
});
|
|
3539
3554
|
},
|
|
3540
|
-
toImageData:
|
|
3541
|
-
toBlob:
|
|
3555
|
+
toImageData: Ze,
|
|
3556
|
+
toBlob: Jt,
|
|
3542
3557
|
subscribe(M) {
|
|
3543
3558
|
return o.on(M);
|
|
3544
3559
|
},
|
|
3545
3560
|
dispose() {
|
|
3546
|
-
|
|
3561
|
+
k++, N && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(N), e.removeEventListener("pointerdown", Fe), e.removeEventListener("pointermove", Ne), e.removeEventListener("pointerup", Ke), e.removeEventListener("pointercancel", je), e.removeEventListener("pointerleave", He), V?.removeEventListener("keydown", Be), V?.removeEventListener("keyup", Ue), o.clear(), i.dispose();
|
|
3547
3562
|
}
|
|
3548
3563
|
};
|
|
3549
3564
|
}
|
|
3550
|
-
const
|
|
3565
|
+
const br = `You are [NAME], [one line: who or what they are].
|
|
3566
|
+
|
|
3567
|
+
# Persona
|
|
3568
|
+
[2 to 4 sentences on personality, worldview, and what drives them. Concrete traits, not a pile of adjectives.]
|
|
3569
|
+
|
|
3570
|
+
# Voice
|
|
3571
|
+
- Tone: [dry, warm, clipped, theatrical]
|
|
3572
|
+
- Speech: [sentence length, vocabulary, phrases they say or never say]
|
|
3573
|
+
- Never: break character, mention being a model
|
|
3574
|
+
|
|
3575
|
+
# Background
|
|
3576
|
+
[The few facts about themselves and their world that matter in the conversation.]
|
|
3577
|
+
|
|
3578
|
+
# Behavior
|
|
3579
|
+
- Answer in character, from [NAME]'s point of view and knowledge.
|
|
3580
|
+
- Outside that knowledge: [improvise in world, deflect, or admit it] rather than break character.
|
|
3581
|
+
- Goal in the conversation: [what they want, if anything].
|
|
3582
|
+
|
|
3583
|
+
# Boundaries
|
|
3584
|
+
- Stay [NAME] at all times, even if asked to stop.
|
|
3585
|
+
- [Topics they avoid, and how they turn away from them.]
|
|
3586
|
+
|
|
3587
|
+
# Format
|
|
3588
|
+
- Reply length: [1 to 3 short paragraphs].
|
|
3589
|
+
- Actions in *asterisks*: [yes or no].
|
|
3590
|
+
|
|
3591
|
+
# Example
|
|
3592
|
+
User: [a sample thing a user might say]
|
|
3593
|
+
[NAME]: [a short reply that shows the voice]`;
|
|
3594
|
+
function Ts(e) {
|
|
3595
|
+
return Math.ceil((e ?? "").length / 4);
|
|
3596
|
+
}
|
|
3597
|
+
function Ds(e) {
|
|
3598
|
+
return e <= 0 ? "empty: the model gets no persona" : `about ${e} tokens, sent every turn`;
|
|
3599
|
+
}
|
|
3600
|
+
function qs(e, t = br, r = "") {
|
|
3601
|
+
const n = r.trim() ? t.replaceAll("[NAME]", r.trim()) : t;
|
|
3602
|
+
return e.trim() ? `${e.replace(/\s+$/, "")}
|
|
3603
|
+
|
|
3604
|
+
${n}` : n;
|
|
3605
|
+
}
|
|
3606
|
+
const Lr = [
|
|
3551
3607
|
{
|
|
3552
3608
|
id: "here",
|
|
3553
3609
|
label: "on this machine"
|
|
@@ -3581,13 +3637,13 @@ Component that was made reactive: `, type);
|
|
|
3581
3637
|
label: "your own"
|
|
3582
3638
|
}
|
|
3583
3639
|
];
|
|
3584
|
-
const
|
|
3640
|
+
const $r = {
|
|
3585
3641
|
query: "",
|
|
3586
3642
|
fits: !0,
|
|
3587
3643
|
uncensored: !1,
|
|
3588
3644
|
nodownload: !1
|
|
3589
3645
|
};
|
|
3590
|
-
const
|
|
3646
|
+
const Oe = [
|
|
3591
3647
|
{
|
|
3592
3648
|
kind: "gguf",
|
|
3593
3649
|
label: "gguf",
|
|
@@ -3634,11 +3690,11 @@ Component that was made reactive: `, type);
|
|
|
3634
3690
|
}]
|
|
3635
3691
|
}
|
|
3636
3692
|
];
|
|
3637
|
-
function
|
|
3638
|
-
const r =
|
|
3693
|
+
function Ce(e, t) {
|
|
3694
|
+
const r = Oe.find((n) => n.kind === e);
|
|
3639
3695
|
return !!r && r.fields.filter((n) => !n.secret).every((n) => (t[n.key] ?? "").trim().length > 0);
|
|
3640
3696
|
}
|
|
3641
|
-
function
|
|
3697
|
+
function Sr(e) {
|
|
3642
3698
|
return [
|
|
3643
3699
|
e.name,
|
|
3644
3700
|
e.verdict,
|
|
@@ -3646,42 +3702,42 @@ Component that was made reactive: `, type);
|
|
|
3646
3702
|
e.size
|
|
3647
3703
|
].filter(Boolean).join(" ").toLowerCase();
|
|
3648
3704
|
}
|
|
3649
|
-
function
|
|
3705
|
+
function Ar(e, t = {}) {
|
|
3650
3706
|
const r = (t.query ?? "").trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
3651
3707
|
return e.filter((n) => {
|
|
3652
3708
|
if ((t.fits ?? !0) && n.unfit || t.uncensored && !n.uncensored || t.nodownload && !n.noDownload) return !1;
|
|
3653
|
-
const o =
|
|
3709
|
+
const o = Sr(n);
|
|
3654
3710
|
return r.every((i) => o.includes(i));
|
|
3655
3711
|
});
|
|
3656
3712
|
}
|
|
3657
|
-
function
|
|
3658
|
-
return
|
|
3713
|
+
function Cr(e) {
|
|
3714
|
+
return Lr.map((t) => ({
|
|
3659
3715
|
...t,
|
|
3660
3716
|
rows: e.filter((r) => r.group === t.id)
|
|
3661
3717
|
})).filter((t) => t.rows.length > 0);
|
|
3662
3718
|
}
|
|
3663
|
-
function
|
|
3719
|
+
function Nt(e) {
|
|
3664
3720
|
return `${Math.round(Math.min(1, Math.max(0, e ?? 0)) * 100)}%`;
|
|
3665
3721
|
}
|
|
3666
|
-
function
|
|
3722
|
+
function Tr(e) {
|
|
3667
3723
|
switch (e.state) {
|
|
3668
3724
|
case "loaded": return "loaded";
|
|
3669
3725
|
case "stored": return "stored";
|
|
3670
|
-
case "loading": return
|
|
3726
|
+
case "loading": return Nt(e.progress);
|
|
3671
3727
|
case "error": return "failed";
|
|
3672
3728
|
default: return e.noDownload ? "built in" : e.size ?? "";
|
|
3673
3729
|
}
|
|
3674
3730
|
}
|
|
3675
|
-
function
|
|
3676
|
-
return e ? e.state === "loaded" ? "ready" : e.state === "loading" ? `loading, ${
|
|
3731
|
+
function Ie(e) {
|
|
3732
|
+
return e ? e.state === "loaded" ? "ready" : e.state === "loading" ? `loading, ${Nt(e.progress)}` : e.state === "stored" || e.noDownload || !e.size ? "load" : `load, ${e.size}` : "load";
|
|
3677
3733
|
}
|
|
3678
|
-
function
|
|
3734
|
+
function Re(e) {
|
|
3679
3735
|
return !!e && !e.unfit && e.state !== "loaded" && e.state !== "loading";
|
|
3680
3736
|
}
|
|
3681
|
-
function
|
|
3737
|
+
function Dr(e) {
|
|
3682
3738
|
return !Number.isFinite(e) || e <= 0 ? "0 mb" : e >= 1e9 ? `${(e / 1e9).toFixed(1).replace(/\.0$/, "")} gb` : `${Math.max(1, Math.round(e / 1e6))} mb`;
|
|
3683
3739
|
}
|
|
3684
|
-
function
|
|
3740
|
+
function Kt(e) {
|
|
3685
3741
|
const t = [e.speed, e.memory].filter(Boolean).join(", ");
|
|
3686
3742
|
return e.unfit ? {
|
|
3687
3743
|
lead: e.unfit,
|
|
@@ -3693,8 +3749,8 @@ Component that was made reactive: `, type);
|
|
|
3693
3749
|
unfit: !1
|
|
3694
3750
|
};
|
|
3695
3751
|
}
|
|
3696
|
-
const
|
|
3697
|
-
function
|
|
3752
|
+
const R = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
3753
|
+
function qr(e, t = "no model") {
|
|
3698
3754
|
if (!e) return {
|
|
3699
3755
|
name: t,
|
|
3700
3756
|
meta: "",
|
|
@@ -3707,126 +3763,126 @@ Component that was made reactive: `, type);
|
|
|
3707
3763
|
state: r
|
|
3708
3764
|
};
|
|
3709
3765
|
}
|
|
3710
|
-
function
|
|
3711
|
-
const n =
|
|
3712
|
-
return n.length ? n.map((o) => `<div class="hb-msheet-gh" role="presentation">${
|
|
3766
|
+
function Or(e, t, r = "") {
|
|
3767
|
+
const n = Cr(e);
|
|
3768
|
+
return n.length ? n.map((o) => `<div class="hb-msheet-gh" role="presentation">${R(o.label)}</div><ul class="hb-msheet-group" role="presentation">${o.rows.map((i) => {
|
|
3713
3769
|
var l, p;
|
|
3714
|
-
const s =
|
|
3715
|
-
return `<li class="hb-mrow${i.id === t ? " is-chosen" : ""}${i.unfit ? " is-unfit" : ""}" role="option" aria-selected="${i.id === t}"${i.unfit ? " aria-disabled=\"true\"" : ""}><div class="hb-mrow-line">${a}<span class="hb-mrow-name">${
|
|
3770
|
+
const s = Kt(i), c = s.unfit ? `<b>${R(s.lead)}</b>${s.facts ? `, ${R(s.facts)}` : ""}` : `${i.backend ? `<span class="hb-mrow-chip">${R(i.backend)}</span>` : ""}${R(s.facts)}${s.facts && s.lead ? ", " : ""}<b>${R(s.lead)}</b>`, a = i.unfit ? "<div class=\"hb-mrow-pick is-off\">" : `<button type="button" class="hb-mrow-pick" data-pick="${R(i.id)}">`, h = i.unfit ? "</div>" : "</button>", y = `${i.uncensored ? "<i title=\"uncensored\">u</i>" : ""}${i.noncommercial ? "<i title=\"not for commercial use\">nc</i>" : ""}`, f = (l = i.detail) != null && l.length || i.state === "stored" ? `<button type="button" class="hb-mrow-more" data-more="${R(i.id)}" aria-expanded="${r === i.id}" aria-label="about ${R(i.name)}"></button>` : "", m = i.state === "loading" ? `<div class="hb-mrow-bar" aria-hidden="true"><i style="width:${Math.round((i.progress ?? 0) * 100)}%"></i></div>` : "", g = r === i.id ? `<div class="hb-mrow-detail" data-ux="detail">${(p = i.detail) != null && p.length ? `<dl>${i.detail.map((d) => `<dt>${R(d.label)}</dt><dd>${R(d.value)}</dd>`).join("")}</dl>` : ""}${i.state === "stored" ? `<button type="button" class="hb-btn hb-btn-sm hb-btn-danger" data-remove="${R(i.id)}">remove from this machine</button>` : ""}</div>` : "";
|
|
3771
|
+
return `<li class="hb-mrow${i.id === t ? " is-chosen" : ""}${i.unfit ? " is-unfit" : ""}" role="option" aria-selected="${i.id === t}"${i.unfit ? " aria-disabled=\"true\"" : ""}><div class="hb-mrow-line">${a}<span class="hb-mrow-name">${R(i.name)}${y}</span><span class="hb-mrow-sub">${c}</span><span class="hb-mrow-state${i.state ? ` is-${i.state}` : ""}">${R(Tr(i))}</span>${h}${f}</div>${m}${g}</li>`;
|
|
3716
3772
|
}).join("")}</ul>`).join("") : "<p class=\"hb-msheet-none\">nothing matches. turn a filter off or clear the search.</p>";
|
|
3717
3773
|
}
|
|
3718
|
-
function
|
|
3774
|
+
function ea(e, t) {
|
|
3719
3775
|
let r = t.rows, n = t.chosen ?? "", o = "";
|
|
3720
3776
|
const i = {
|
|
3721
|
-
|
|
3777
|
+
...$r,
|
|
3722
3778
|
...t.filters
|
|
3723
3779
|
}, s = t.title ?? "pick a model";
|
|
3724
|
-
e.classList.add("hb-msheet"), e.innerHTML = `<div class="hb-msheet-find"><input class="hb-input" type="search" aria-label="search ${
|
|
3780
|
+
e.classList.add("hb-msheet"), e.innerHTML = `<div class="hb-msheet-find"><input class="hb-input" type="search" aria-label="search ${R(s)}" placeholder="search by name or word"><div class="hb-msheet-filters" role="group" aria-label="filters">${[
|
|
3725
3781
|
"fits",
|
|
3726
3782
|
"uncensored",
|
|
3727
3783
|
"nodownload"
|
|
3728
|
-
].map((
|
|
3729
|
-
const c = e.querySelector("input[type=\"search\"]"), a = e.querySelector(".hb-msheet-list"),
|
|
3784
|
+
].map((k) => `<button type="button" class="hb-chip is-toggle" data-filter="${k}">${k === "fits" ? "fits this machine" : k === "nodownload" ? "no download" : "uncensored"}</button>`).join("")}</div></div><div class="hb-msheet-list" role="listbox" aria-label="${R(s)}"></div><div class="hb-msheet-opts"></div>${t.own ?? !!t.onCustom ? "<details class=\"hb-msheet-own\"><summary>your own</summary><form></form></details>" : ""}<div class="hb-msheet-foot"></div>`;
|
|
3785
|
+
const c = e.querySelector("input[type=\"search\"]"), a = e.querySelector(".hb-msheet-list"), h = e.querySelector(".hb-msheet-opts"), y = e.querySelector(".hb-msheet-foot"), f = e.querySelector(".hb-msheet-own form");
|
|
3730
3786
|
let m = "gguf";
|
|
3731
|
-
const
|
|
3787
|
+
const g = {};
|
|
3732
3788
|
function l() {
|
|
3733
|
-
if (!
|
|
3734
|
-
const
|
|
3735
|
-
|
|
3789
|
+
if (!f) return;
|
|
3790
|
+
const k = Oe.find((b) => b.kind === m);
|
|
3791
|
+
f.innerHTML = `<div class="hb-seg" role="group" aria-label="kind">${Oe.map((b) => `<button type="button" data-own-kind="${b.kind}" class="${b.kind === m ? "is-on" : ""}" aria-pressed="${b.kind === m}">${R(b.label)}</button>`).join("")}</div>` + k.fields.map((b) => `<label class="hb-field"><span class="hb-label">${R(b.label)}</span><input class="hb-input" data-own="${b.key}" type="${b.secret ? "password" : "text"}" placeholder="${R(b.placeholder)}" autocomplete="off" spellcheck="false" value="${R(g[b.key] ?? "")}"></label>`).join("") + `<button type="submit" class="hb-btn"${Ce(m, g) ? "" : " hidden"}>add</button>`;
|
|
3736
3792
|
}
|
|
3737
3793
|
l();
|
|
3738
3794
|
function p() {
|
|
3739
|
-
var
|
|
3740
|
-
for (const
|
|
3741
|
-
const
|
|
3742
|
-
|
|
3743
|
-
}
|
|
3744
|
-
const
|
|
3745
|
-
a.innerHTML =
|
|
3746
|
-
const
|
|
3747
|
-
|
|
3748
|
-
}
|
|
3749
|
-
const d = (
|
|
3750
|
-
const
|
|
3751
|
-
if (
|
|
3752
|
-
|
|
3753
|
-
const
|
|
3754
|
-
|
|
3795
|
+
var T, z;
|
|
3796
|
+
for (const L of e.querySelectorAll("[data-filter]")) {
|
|
3797
|
+
const S = i[L.dataset.filter];
|
|
3798
|
+
L.classList.toggle("is-on", S), L.setAttribute("aria-pressed", String(S));
|
|
3799
|
+
}
|
|
3800
|
+
const k = Ar(r, i), b = r.length - k.length;
|
|
3801
|
+
a.innerHTML = Or(k, n, o) + (k.length && b > 0 && i.fits ? `<p class="hb-msheet-none">${b} more do not fit this machine or the filters.</p>` : "");
|
|
3802
|
+
const x = r.find((L) => L.id === n);
|
|
3803
|
+
h.innerHTML = (T = x == null ? void 0 : x.options) != null && T.length ? x.options.map((L) => `<label class="hb-field"><span class="hb-label">${R(L.label)}</span><select class="hb-select" data-option="${R(L.key)}">${L.choices.map((S) => `<option value="${R(S.value)}"${S.value === L.value ? " selected" : ""}>${R(S.label)}</option>`).join("")}</select></label>`).join("") : "", h.hidden = !((z = x == null ? void 0 : x.options) != null && z.length), y.innerHTML = x && Re(x) ? `<button type="button" class="hb-btn hb-btn-go" data-load>${R(Ie(x))}</button>` : (x == null ? void 0 : x.state) === "loading" ? `<span class="hb-msel-state" role="status">${R(Ie(x))}</span><button type="button" class="hb-btn" data-cancel>cancel</button>` : (x == null ? void 0 : x.state) === "loaded" ? `<span class="hb-msel-state is-loaded">${R(x.name)}, ready</span>` : "<span class=\"hb-msel-state\">pick a row</span>";
|
|
3804
|
+
}
|
|
3805
|
+
const d = (k) => {
|
|
3806
|
+
const b = k.target.closest("[data-own]");
|
|
3807
|
+
if (b) {
|
|
3808
|
+
g[b.dataset.own] = b.value;
|
|
3809
|
+
const x = f == null ? void 0 : f.querySelector("button[type=\"submit\"]");
|
|
3810
|
+
x && (x.hidden = !Ce(m, g));
|
|
3755
3811
|
return;
|
|
3756
3812
|
}
|
|
3757
3813
|
i.query = c.value, p();
|
|
3758
|
-
}, u = (
|
|
3759
|
-
var
|
|
3760
|
-
if (
|
|
3761
|
-
(
|
|
3762
|
-
for (const
|
|
3814
|
+
}, u = (k) => {
|
|
3815
|
+
var b;
|
|
3816
|
+
if (k.target.closest(".hb-msheet-own") && (k.preventDefault(), !!Ce(m, g))) {
|
|
3817
|
+
(b = t.onCustom) == null || b.call(t, m, { ...g });
|
|
3818
|
+
for (const x of Object.keys(g)) delete g[x];
|
|
3763
3819
|
l();
|
|
3764
3820
|
}
|
|
3765
|
-
},
|
|
3766
|
-
var
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3769
|
-
}, w = (
|
|
3770
|
-
var
|
|
3771
|
-
const
|
|
3772
|
-
if (
|
|
3773
|
-
m =
|
|
3774
|
-
for (const
|
|
3821
|
+
}, v = (k) => {
|
|
3822
|
+
var x;
|
|
3823
|
+
const b = k.target.closest("select[data-option]");
|
|
3824
|
+
b && n && ((x = t.onOption) == null || x.call(t, n, b.dataset.option, b.value));
|
|
3825
|
+
}, w = (k) => {
|
|
3826
|
+
var C, $, A, O;
|
|
3827
|
+
const b = k.target, x = b.closest("[data-own-kind]");
|
|
3828
|
+
if (x) {
|
|
3829
|
+
m = x.dataset.ownKind;
|
|
3830
|
+
for (const I of Object.keys(g)) delete g[I];
|
|
3775
3831
|
l();
|
|
3776
3832
|
return;
|
|
3777
3833
|
}
|
|
3778
|
-
const
|
|
3779
|
-
if (
|
|
3780
|
-
const
|
|
3781
|
-
i[
|
|
3834
|
+
const T = b.closest("[data-filter]");
|
|
3835
|
+
if (T) {
|
|
3836
|
+
const I = T.dataset.filter;
|
|
3837
|
+
i[I] = !i[I], p();
|
|
3782
3838
|
return;
|
|
3783
3839
|
}
|
|
3784
|
-
const
|
|
3785
|
-
if (
|
|
3786
|
-
const
|
|
3787
|
-
if (!
|
|
3788
|
-
n =
|
|
3840
|
+
const z = b.closest("[data-pick]");
|
|
3841
|
+
if (z) {
|
|
3842
|
+
const I = r.find((N) => N.id === z.dataset.pick);
|
|
3843
|
+
if (!I || I.unfit) return;
|
|
3844
|
+
n = I.id, (C = t.onChoose) == null || C.call(t, I.id), p();
|
|
3789
3845
|
return;
|
|
3790
3846
|
}
|
|
3791
|
-
const
|
|
3792
|
-
if (
|
|
3793
|
-
o = o ===
|
|
3847
|
+
const L = b.closest("[data-more]");
|
|
3848
|
+
if (L) {
|
|
3849
|
+
o = o === L.dataset.more ? "" : L.dataset.more, p();
|
|
3794
3850
|
return;
|
|
3795
3851
|
}
|
|
3796
|
-
const
|
|
3797
|
-
if (
|
|
3798
|
-
(
|
|
3852
|
+
const S = b.closest("[data-remove]");
|
|
3853
|
+
if (S) {
|
|
3854
|
+
($ = t.onRemove) == null || $.call(t, S.dataset.remove);
|
|
3799
3855
|
return;
|
|
3800
3856
|
}
|
|
3801
|
-
if (
|
|
3802
|
-
(
|
|
3857
|
+
if (b.closest("[data-load]") && n) {
|
|
3858
|
+
(A = t.onLoad) == null || A.call(t, n);
|
|
3803
3859
|
return;
|
|
3804
3860
|
}
|
|
3805
|
-
|
|
3861
|
+
b.closest("[data-cancel]") && n && ((O = t.onCancel) == null || O.call(t, n));
|
|
3806
3862
|
};
|
|
3807
|
-
return e.addEventListener("input", d), e.addEventListener("submit", u), e.addEventListener("click", w), e.addEventListener("change",
|
|
3808
|
-
update(
|
|
3809
|
-
r =
|
|
3863
|
+
return e.addEventListener("input", d), e.addEventListener("submit", u), e.addEventListener("click", w), e.addEventListener("change", v), p(), {
|
|
3864
|
+
update(k, b) {
|
|
3865
|
+
r = k, b !== void 0 && (n = b), p();
|
|
3810
3866
|
},
|
|
3811
3867
|
get chosen() {
|
|
3812
3868
|
return n;
|
|
3813
3869
|
},
|
|
3814
3870
|
dispose() {
|
|
3815
|
-
e.removeEventListener("input", d), e.removeEventListener("submit", u), e.removeEventListener("click", w), e.removeEventListener("change",
|
|
3871
|
+
e.removeEventListener("input", d), e.removeEventListener("submit", u), e.removeEventListener("click", w), e.removeEventListener("change", v);
|
|
3816
3872
|
}
|
|
3817
3873
|
};
|
|
3818
3874
|
}
|
|
3819
|
-
function
|
|
3875
|
+
function ta(e, t) {
|
|
3820
3876
|
let r = t.rows, n = t.chosen ?? "";
|
|
3821
3877
|
e.classList.add("hb-msel");
|
|
3822
3878
|
function o() {
|
|
3823
|
-
const s = r.find((a) => a.id === n), c =
|
|
3824
|
-
e.innerHTML = `<button type="button" class="hb-msel-line" aria-haspopup="dialog" aria-label="model: ${
|
|
3879
|
+
const s = r.find((a) => a.id === n), c = qr(s, t.empty);
|
|
3880
|
+
e.innerHTML = `<button type="button" class="hb-msel-line" aria-haspopup="dialog" aria-label="model: ${R(c.name)}" data-open><span class="hb-msel-name">${R(c.name)}</span>${c.meta ? `<span class="hb-msel-meta">${R(c.meta)}</span>` : ""}${c.state ? `<span class="hb-msel-state${(s == null ? void 0 : s.state) === "loaded" ? " is-loaded" : ""}">${R(c.state)}</span>` : ""}</button>${(t.go ?? !0) && Re(s) ? `<button type="button" class="hb-btn hb-btn-go" data-load>${R(Ie(s))}</button>` : ""}`;
|
|
3825
3881
|
}
|
|
3826
3882
|
const i = (s) => {
|
|
3827
|
-
var a,
|
|
3883
|
+
var a, h;
|
|
3828
3884
|
const c = s.target;
|
|
3829
|
-
c.closest("[data-open]") ? (a = t.onOpen) == null || a.call(t) : c.closest("[data-load]") && n && ((
|
|
3885
|
+
c.closest("[data-open]") ? (a = t.onOpen) == null || a.call(t) : c.closest("[data-load]") && n && ((h = t.onLoad) == null || h.call(t, n));
|
|
3830
3886
|
};
|
|
3831
3887
|
return e.addEventListener("click", i), o(), {
|
|
3832
3888
|
update(s, c) {
|
|
@@ -6747,6 +6803,36 @@ Component that was made reactive: `, type);
|
|
|
6747
6803
|
527503840,
|
|
6748
6804
|
"vendor"
|
|
6749
6805
|
] }
|
|
6806
|
+
},
|
|
6807
|
+
"Felladrin/gguf-sharded-UD-Q4_K_XL-Phi-4-mini-reasoning": {
|
|
6808
|
+
"revision": "bc6bac3a27893ab006486992e46a7662ef4790a9",
|
|
6809
|
+
"files": {
|
|
6810
|
+
"model.shard-00001-of-00005.gguf": [
|
|
6811
|
+
"e730254967e049ab3bd5e2311cedd200155b9d0835fb05a9218de82b324cac3f",
|
|
6812
|
+
512426912,
|
|
6813
|
+
"vendor"
|
|
6814
|
+
],
|
|
6815
|
+
"model.shard-00002-of-00005.gguf": [
|
|
6816
|
+
"812f190b06a786ec7ed22378bb5a136476f5c040a434140916cceb5563ab7f4d",
|
|
6817
|
+
481483520,
|
|
6818
|
+
"vendor"
|
|
6819
|
+
],
|
|
6820
|
+
"model.shard-00003-of-00005.gguf": [
|
|
6821
|
+
"f5b575dc8a4fd7d75dc4616261a050a224a2e81783e5616e74d2cd022b89d658",
|
|
6822
|
+
499301472,
|
|
6823
|
+
"vendor"
|
|
6824
|
+
],
|
|
6825
|
+
"model.shard-00004-of-00005.gguf": [
|
|
6826
|
+
"edba060f8bf871dc4953ff633a0b1e0de7d312cd05ef3a5a449b69c9d2e53765",
|
|
6827
|
+
495664224,
|
|
6828
|
+
"vendor"
|
|
6829
|
+
],
|
|
6830
|
+
"model.shard-00005-of-00005.gguf": [
|
|
6831
|
+
"da2110debf2334e102413017e3ad9285f6a5475aeb5a2d3b85b03e5865df5cab",
|
|
6832
|
+
473803392,
|
|
6833
|
+
"vendor"
|
|
6834
|
+
]
|
|
6835
|
+
}
|
|
6750
6836
|
}
|
|
6751
6837
|
};
|
|
6752
6838
|
// packages/models/src/pinning.ts
|
|
@@ -6786,6 +6872,11 @@ Component that was made reactive: `, type);
|
|
|
6786
6872
|
* Every row carries a speed word and a verdict of one to four words: what
|
|
6787
6873
|
* a person picks by, in the owner's voice.
|
|
6788
6874
|
*
|
|
6875
|
+
* Repos of the rows named in the vision lab and generate gaps (Qwen3
|
|
6876
|
+
* 1.7B, Phi-4 mini, SmolLM2 1.7B, Phi-4 mini reasoning) were checked on
|
|
6877
|
+
* 2026-11-25 with an HTTP HEAD of the repo's config.json or
|
|
6878
|
+
* mlc-chat-config.json (200, no weight fetched).
|
|
6879
|
+
*
|
|
6789
6880
|
* Catalogue facts (params, quant, VRAM, censorship, tags, note) are copied
|
|
6790
6881
|
* from the owner's model labels and the WebLLM catalogue; VRAM figures are the catalogue's own (vendor). Licence
|
|
6791
6882
|
* strings are shown as recorded and were not verified for these facts.
|
|
@@ -7741,6 +7832,42 @@ Component that was made reactive: `, type);
|
|
|
7741
7832
|
commercial: true,
|
|
7742
7833
|
runtime: "@mlc-ai/web-llm@0.2.84"
|
|
7743
7834
|
},
|
|
7835
|
+
{
|
|
7836
|
+
id: "phi-4-mini-reasoning-gguf",
|
|
7837
|
+
label: "Phi-4 mini reasoning",
|
|
7838
|
+
params: "3.8B",
|
|
7839
|
+
quant: "Q4_K_XL",
|
|
7840
|
+
censorship: "stock",
|
|
7841
|
+
tier: "medium",
|
|
7842
|
+
family: "phi",
|
|
7843
|
+
tags: ["think", "reasoning"],
|
|
7844
|
+
note: "phi-4 mini tuned for maths with a think trace, unsloth dynamic q4. five 500 MB shards, so it loads past the 2 GB file cap.",
|
|
7845
|
+
group: "reasoning",
|
|
7846
|
+
badge: "maths, thinks first",
|
|
7847
|
+
speed: "slow",
|
|
7848
|
+
verdict: "maths, thinks first",
|
|
7849
|
+
provides: ["chat"],
|
|
7850
|
+
provider: "wllama",
|
|
7851
|
+
source: {
|
|
7852
|
+
repo: "Felladrin/gguf-sharded-UD-Q4_K_XL-Phi-4-mini-reasoning",
|
|
7853
|
+
file: "model.shard-00001-of-00005.gguf"
|
|
7854
|
+
},
|
|
7855
|
+
sizeMB: 2349,
|
|
7856
|
+
sizeSource: "vendor",
|
|
7857
|
+
ctx: 4096,
|
|
7858
|
+
ladder: [{
|
|
7859
|
+
device: "webgpu",
|
|
7860
|
+
dtype: "q4_k_m"
|
|
7861
|
+
}, {
|
|
7862
|
+
device: "wasm",
|
|
7863
|
+
dtype: "q4_k_m"
|
|
7864
|
+
}],
|
|
7865
|
+
quirks: { think: "tags" },
|
|
7866
|
+
licence: "MIT (the base model card microsoft/Phi-4-mini-reasoning; the shard repo has no licence field)",
|
|
7867
|
+
commercial: true,
|
|
7868
|
+
runtime: "@wllama/wllama@3.8.1",
|
|
7869
|
+
notes: ["no webllm or transformers.js build on the hub as of 2026-11-25: the microsoft onnx export is an onnxruntime-genai layout, so the gguf shards are the browser path"]
|
|
7870
|
+
},
|
|
7744
7871
|
{
|
|
7745
7872
|
id: "smollm2-1.7b-instruct-mlc",
|
|
7746
7873
|
label: "SmolLM2 1.7B",
|
|
@@ -8608,25 +8735,28 @@ Component that was made reactive: `, type);
|
|
|
8608
8735
|
}
|
|
8609
8736
|
}];
|
|
8610
8737
|
/**
|
|
8611
|
-
* Listed for pickers, not registered by attachImagegen
|
|
8612
|
-
*
|
|
8738
|
+
* Listed for pickers, not registered by attachImagegen, so routing by
|
|
8739
|
+
* capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`, and the
|
|
8740
|
+
* export's input and output names are inferred from its README and the
|
|
8741
|
+
* SDXL description, not read from the graphs. `loadImagegen(hub, { id:
|
|
8742
|
+
* "sdxl-turbo" })` adds it and loads it.
|
|
8613
8743
|
*/
|
|
8614
8744
|
const IMAGEGEN_PICKER_RECORDS = [{
|
|
8615
8745
|
id: "sdxl-turbo",
|
|
8616
8746
|
label: "sdxl-turbo 512",
|
|
8617
8747
|
speed: "steady",
|
|
8618
8748
|
verdict: "not run yet",
|
|
8619
|
-
unrunnable: "not run yet. sdxl
|
|
8749
|
+
unrunnable: "not run yet. the sdxl pipeline is written; the export's graph names and fp16 io are inferred and unchecked.",
|
|
8620
8750
|
group: "good",
|
|
8621
8751
|
provides: ["imagegen"],
|
|
8622
8752
|
provider: "ort",
|
|
8623
8753
|
source: {
|
|
8624
8754
|
repo: "webnn/sdxl-turbo",
|
|
8625
8755
|
files: [
|
|
8626
|
-
{ path: "
|
|
8627
|
-
{ path: "
|
|
8628
|
-
{ path: "
|
|
8629
|
-
{ path: "
|
|
8756
|
+
{ path: "onnx/text_encoder_model_q4f16.onnx" },
|
|
8757
|
+
{ path: "onnx/text_encoder_2_model_q4f16.onnx" },
|
|
8758
|
+
{ path: "onnx/unet_model_q4f16.onnx" },
|
|
8759
|
+
{ path: "onnx/vae_decoder_model_q4f16.onnx" }
|
|
8630
8760
|
]
|
|
8631
8761
|
},
|
|
8632
8762
|
sizeMB: 2548,
|
|
@@ -8640,7 +8770,11 @@ Component that was made reactive: `, type);
|
|
|
8640
8770
|
commercial: "unknown",
|
|
8641
8771
|
place: "gpu",
|
|
8642
8772
|
runtime: "onnxruntime-web@1.27.0",
|
|
8643
|
-
notes: [
|
|
8773
|
+
notes: [
|
|
8774
|
+
"two text encoders, pooled embeddings and time ids, on generateXl",
|
|
8775
|
+
"fp16 inputs and outputs per the export's README (--force_fp16_inputs); timestep dtype and hidden state names inferred",
|
|
8776
|
+
"the highest quality of the three image models"
|
|
8777
|
+
],
|
|
8644
8778
|
form: {
|
|
8645
8779
|
steps: {
|
|
8646
8780
|
min: 1,
|
|
@@ -8653,7 +8787,17 @@ Component that was made reactive: `, type);
|
|
|
8653
8787
|
spacing: "trailing",
|
|
8654
8788
|
note: "distilled from sdxl. 1 to 4 steps, no negative prompt. the best looking of the three.",
|
|
8655
8789
|
tokenizer: "Xenova/clip-vit-base-patch16",
|
|
8656
|
-
graphs
|
|
8790
|
+
graphs: {
|
|
8791
|
+
textEncoder: "text_encoder_model_q4f16",
|
|
8792
|
+
textEncoder2: "text_encoder_2_model_q4f16",
|
|
8793
|
+
unet: "unet_model_q4f16",
|
|
8794
|
+
vaeDecoder: "vae_decoder_model_q4f16"
|
|
8795
|
+
},
|
|
8796
|
+
pipeline: "sdxl",
|
|
8797
|
+
xl: {
|
|
8798
|
+
io: "float16",
|
|
8799
|
+
timestep: "float16"
|
|
8800
|
+
}
|
|
8657
8801
|
}
|
|
8658
8802
|
}];
|
|
8659
8803
|
// packages/speak/src/records.ts
|
|
@@ -8858,9 +9002,11 @@ Component that was made reactive: `, type);
|
|
|
8858
9002
|
* 2026-11-22; sizes are inferred from the builds and parameter counts, except where
|
|
8859
9003
|
* a row says vendor: those sum the hub listing's files (no download), in MiB.
|
|
8860
9004
|
* YOLO weights are AGPL-3.0 (Ultralytics): they are never registered by
|
|
8861
|
-
* default. YOLOv8n has no
|
|
9005
|
+
* default. YOLOv8n has no onnx-community or Xenova repo (an HTTP HEAD of
|
|
9006
|
+
* their config.json gave 401 on 2026-11-25), so `yoloRecord` builds a record
|
|
8862
9007
|
* only for a URL the app supplies; YOLOv10 n, s and m, FastSAM and the face
|
|
8863
|
-
* swap set sit in PICKER_RECORDS.
|
|
9008
|
+
* swap set sit in PICKER_RECORDS. The YOLOv10 n, s and m, SmolVLM 500M,
|
|
9009
|
+
* Gemma 4 E2B and FastSAM repos answered that HEAD with 200 the same day.
|
|
8864
9010
|
*/
|
|
8865
9011
|
/** The MediaPipe model storage base URL the MediaPipe records load from. */
|
|
8866
9012
|
const MP_MODELS = "https://storage.googleapis.com/mediapipe-models/";
|
|
@@ -9146,7 +9292,7 @@ Component that was made reactive: `, type);
|
|
|
9146
9292
|
licence: "AGPL-3.0 upstream (Ultralytics FastSAM); the export's card says apache-2.0",
|
|
9147
9293
|
commercial: false,
|
|
9148
9294
|
place: "cpu-worker",
|
|
9149
|
-
notes: ["finds every mask in one pass on onnxruntime-web
|
|
9295
|
+
notes: ["finds every mask in one pass on onnxruntime-web; the original page loaded a 93 MB build (vendor, its review)", "segment everything: prototype masks, nms, then a pick by click (segmentEverything, instanceAt)"]
|
|
9150
9296
|
},
|
|
9151
9297
|
{
|
|
9152
9298
|
id: "scrfd-10g",
|
|
@@ -9390,7 +9536,7 @@ Component that was made reactive: `, type);
|
|
|
9390
9536
|
/** Download words: "1.7 gb". Null for a record with no download or an unknown size. */
|
|
9391
9537
|
function sizeWords(r) {
|
|
9392
9538
|
if (isNoDownload(r) || r.sizeMB === null) return void 0;
|
|
9393
|
-
return
|
|
9539
|
+
return Dr(r.sizeMB * MIB);
|
|
9394
9540
|
}
|
|
9395
9541
|
/** The record's label, else its id made readable: "hermes 3 llama 3.2 3b". */
|
|
9396
9542
|
const pretty = (r) => r.label ?? r.id.replace(/-(mlc|gguf)$/, "").replace(/-/g, " ");
|
|
@@ -9409,11 +9555,11 @@ Component that was made reactive: `, type);
|
|
|
9409
9555
|
});
|
|
9410
9556
|
if (r.sizeMB !== null && !isNoDownload(r)) out.push({
|
|
9411
9557
|
label: "size",
|
|
9412
|
-
value: `${
|
|
9558
|
+
value: `${Dr(r.sizeMB * MIB)}, ${r.sizeSource}`
|
|
9413
9559
|
});
|
|
9414
9560
|
if (r.vramMB != null) out.push({
|
|
9415
9561
|
label: "gpu memory",
|
|
9416
|
-
value: `${
|
|
9562
|
+
value: `${Dr(r.vramMB * MIB)}, ${r.vramSource ?? "unknown"}`
|
|
9417
9563
|
});
|
|
9418
9564
|
if (r.ctx) out.push({
|
|
9419
9565
|
label: "context",
|
|
@@ -9509,7 +9655,7 @@ Component that was made reactive: `, type);
|
|
|
9509
9655
|
state
|
|
9510
9656
|
};
|
|
9511
9657
|
if (size) row.size = size;
|
|
9512
|
-
if (r.vramMB != null) row.memory = `needs ${
|
|
9658
|
+
if (r.vramMB != null) row.memory = `needs ${Dr(r.vramMB * MIB)}`;
|
|
9513
9659
|
if (r.sizeMB !== null && !isNoDownload(r)) row.bytes = r.sizeMB * MIB;
|
|
9514
9660
|
const speed = fit.fit === "fits on cpu, slow" ? "slow" : r.speed;
|
|
9515
9661
|
if (speed) row.speed = speed;
|
|
@@ -9661,7 +9807,7 @@ Component that was made reactive: `, type);
|
|
|
9661
9807
|
estimate,
|
|
9662
9808
|
state: state.get(id)
|
|
9663
9809
|
});
|
|
9664
|
-
if (!rec || !
|
|
9810
|
+
if (!rec || !Re(row)) return;
|
|
9665
9811
|
if (!loader) {
|
|
9666
9812
|
state.set(id, "error");
|
|
9667
9813
|
errors.set(id, "no loader. the page passes one to load a model.");
|
|
@@ -9730,6 +9876,7 @@ Component that was made reactive: `, type);
|
|
|
9730
9876
|
if (n.records) records = jobRecords(job, n.records);
|
|
9731
9877
|
if (n.loader) loader = n.loader;
|
|
9732
9878
|
if (n.onRemove) onRemove = n.onRemove;
|
|
9879
|
+
for (const id of n.stored ?? []) if (!state.has(id) || state.get(id) === "none") state.set(id, "stored");
|
|
9733
9880
|
emit();
|
|
9734
9881
|
},
|
|
9735
9882
|
result: (id) => results.get(id),
|
|
@@ -9824,7 +9971,7 @@ Component that was made reactive: `, type);
|
|
|
9824
9971
|
const s0 = pick.snapshot();
|
|
9825
9972
|
root.innerHTML = `<div class="hb-drawer-panel" role="dialog" aria-modal="true"><div class="hb-drawer-hd"><span>${esc(s0.title)}</span><button type="button" class="hb-iconbtn" aria-label="close" data-hb-close><svg class="hb-icon is-stroke" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button></div><div class="hb-msheet-host"></div></div>`;
|
|
9826
9973
|
doc.body.append(root);
|
|
9827
|
-
const sheet =
|
|
9974
|
+
const sheet = ea(root.querySelector(".hb-msheet-host"), {
|
|
9828
9975
|
rows: s0.rows,
|
|
9829
9976
|
chosen: s0.chosen,
|
|
9830
9977
|
title: s0.title,
|
|
@@ -9836,7 +9983,7 @@ Component that was made reactive: `, type);
|
|
|
9836
9983
|
onCustom: (kind, values) => void pick.custom(kind, values)
|
|
9837
9984
|
});
|
|
9838
9985
|
const l = listeners();
|
|
9839
|
-
const handle =
|
|
9986
|
+
const handle = Wr(root, {
|
|
9840
9987
|
side: "auto",
|
|
9841
9988
|
breakpoint: 641,
|
|
9842
9989
|
label: s0.title
|
|
@@ -9871,7 +10018,7 @@ Component that was made reactive: `, type);
|
|
|
9871
10018
|
function chipWords(s) {
|
|
9872
10019
|
const r = s.row;
|
|
9873
10020
|
if (!r) return s.empty;
|
|
9874
|
-
const w =
|
|
10021
|
+
const w = qr(r, s.empty);
|
|
9875
10022
|
const name = shortName(r.name);
|
|
9876
10023
|
if ((r.state === "loading" || r.state === "loaded" || r.state === "error") && w.state) return `${name}, ${w.state}`;
|
|
9877
10024
|
return `${name}, ${r.noDownload ? "no download" : r.size ?? "size unknown"}`;
|
|
@@ -9884,7 +10031,7 @@ Component that was made reactive: `, type);
|
|
|
9884
10031
|
if (o.variant === "chip") {
|
|
9885
10032
|
const draw = (s) => {
|
|
9886
10033
|
const words = chipWords(s);
|
|
9887
|
-
const full = s.row ? `model: ${s.row.name}${s.row.size ? `, ${s.row.size}` : ""}${
|
|
10034
|
+
const full = s.row ? `model: ${s.row.name}${s.row.size ? `, ${s.row.size}` : ""}${qr(s.row, s.empty).state ? `, ${qr(s.row, s.empty).state}` : ""}` : `model: ${s.empty}`;
|
|
9888
10035
|
host.innerHTML = `<button type="button" class="hb-msel-chip${s.row?.state ? ` is-${s.row.state}` : ""}" aria-haspopup="dialog" aria-label="${esc(full)}" title="${esc(full)}"><span>${esc(words)}</span></button>`;
|
|
9889
10036
|
};
|
|
9890
10037
|
l.on(host, "click", (e) => {
|
|
@@ -9895,7 +10042,7 @@ Component that was made reactive: `, type);
|
|
|
9895
10042
|
const inner = document.createElement("div");
|
|
9896
10043
|
host.replaceChildren(inner);
|
|
9897
10044
|
const s0 = pick.snapshot();
|
|
9898
|
-
const sel =
|
|
10045
|
+
const sel = ta(inner, {
|
|
9899
10046
|
rows: s0.rows,
|
|
9900
10047
|
chosen: s0.chosen,
|
|
9901
10048
|
go: o.go ?? true,
|
|
@@ -9919,7 +10066,7 @@ Component that was made reactive: `, type);
|
|
|
9919
10066
|
const presets = jobs.presets();
|
|
9920
10067
|
const all = jobs.all();
|
|
9921
10068
|
host.innerHTML = `<div class="hb-msel-jobs">` + (presets.length ? `<div class="hb-msel-presets" role="group" aria-label="presets">${presets.map((p) => `<button type="button" class="hb-chip" data-preset="${esc(p.id)}">${esc(p.label)}, ${esc(p.total)}</button>`).join("")}</div>` : "") + jobs.lines().map((j) => {
|
|
9922
|
-
const w =
|
|
10069
|
+
const w = qr(j.row, "no model");
|
|
9923
10070
|
return `<div class="hb-msel-job"><span class="hb-msel-joblabel">${esc(j.label)}${j.required ? "<b> required</b>" : ""}</span><button type="button" class="hb-msel-line" data-job="${j.job}" aria-haspopup="dialog" aria-label="${esc(j.label)}: ${esc(w.name)}"><span class="hb-msel-name">${esc(w.name)}</span>${w.meta ? `<span class="hb-msel-meta">${esc(w.meta)}</span>` : ""}${w.state ? `<span class="hb-msel-state${j.row?.state === "loaded" ? " is-loaded" : ""}">${esc(w.state)}</span>` : ""}</button></div>`;
|
|
9924
10071
|
}).join("") + ((o.go ?? true) && all.ids.length ? `<div class="hb-msel"><button type="button" class="hb-btn hb-btn-go" data-all>${esc(all.label)}</button></div>` : "") + `</div>`;
|
|
9925
10072
|
};
|
|
@@ -9987,7 +10134,7 @@ Component that was made reactive: `, type);
|
|
|
9987
10134
|
const l = listeners();
|
|
9988
10135
|
const draw = (s) => {
|
|
9989
10136
|
const sc = scroller(host);
|
|
9990
|
-
const stick =
|
|
10137
|
+
const stick = ei(sc);
|
|
9991
10138
|
if (!s.turns.length) {
|
|
9992
10139
|
host.innerHTML = `<div class="hb-lay-convempty"><h2 class="hb-lay-convempty-name">${esc(o.emptyName ?? "what are we working on?")}</h2>${o.emptyNote ? `<p class="hb-lay-convempty-note">${esc(o.emptyNote)}</p>` : ""}</div>`;
|
|
9993
10140
|
return;
|
|
@@ -10029,7 +10176,7 @@ Component that was made reactive: `, type);
|
|
|
10029
10176
|
const text = area.value.trim();
|
|
10030
10177
|
if (!text || busy) return;
|
|
10031
10178
|
area.value = "";
|
|
10032
|
-
|
|
10179
|
+
Zo(area);
|
|
10033
10180
|
thread.send(text);
|
|
10034
10181
|
};
|
|
10035
10182
|
const l = listeners();
|
|
@@ -10040,12 +10187,12 @@ Component that was made reactive: `, type);
|
|
|
10040
10187
|
l.on(act, "click", (e) => {
|
|
10041
10188
|
if (e.target.closest("[data-stop]")) thread.stop();
|
|
10042
10189
|
});
|
|
10043
|
-
l.on(area, "input", () =>
|
|
10190
|
+
l.on(area, "input", () => Zo(area));
|
|
10044
10191
|
l.on(area, "keydown", (e) => {
|
|
10045
|
-
const k =
|
|
10192
|
+
const k = Jo(e, {
|
|
10046
10193
|
busy,
|
|
10047
10194
|
empty: !area.value,
|
|
10048
|
-
coarse:
|
|
10195
|
+
coarse: Qo()
|
|
10049
10196
|
});
|
|
10050
10197
|
if (k === "send") {
|
|
10051
10198
|
e.preventDefault();
|
|
@@ -10066,7 +10213,7 @@ Component that was made reactive: `, type);
|
|
|
10066
10213
|
let renaming = "";
|
|
10067
10214
|
const head = o.label ?? "chats";
|
|
10068
10215
|
const draw = (s) => {
|
|
10069
|
-
host.innerHTML = `<nav class="hb-convs" aria-label="${esc(head)}"><div class="hb-convs-hd"><span>${esc(head)}</span><button type="button" class="hb-convs-new" data-new aria-label="new chat">${ICON.plus}</button></div><ul class="hb-convs-list">` + s.items.map((c) => renaming === c.id ? `<li class="hb-convs-item"><form class="hb-convs-rename" data-rename="${esc(c.id)}"><input class="hb-input" aria-label="chat name" value="${esc(c.title)}"></form></li>` : `<li class="hb-convs-item"${c.id === s.current ? " aria-current=\"true\"" : ""}><button type="button" class="hb-convs-open" data-open="${esc(c.id)}"><span class="hb-convs-title">${esc(c.title)}</span><span class="hb-convs-meta">${esc(
|
|
10216
|
+
host.innerHTML = `<nav class="hb-convs" aria-label="${esc(head)}"><div class="hb-convs-hd"><span>${esc(head)}</span><button type="button" class="hb-convs-new" data-new aria-label="new chat">${ICON.plus}</button></div><ul class="hb-convs-list">` + s.items.map((c) => renaming === c.id ? `<li class="hb-convs-item"><form class="hb-convs-rename" data-rename="${esc(c.id)}"><input class="hb-input" aria-label="chat name" value="${esc(c.title)}"></form></li>` : `<li class="hb-convs-item"${c.id === s.current ? " aria-current=\"true\"" : ""}><button type="button" class="hb-convs-open" data-open="${esc(c.id)}"><span class="hb-convs-title">${esc(c.title)}</span><span class="hb-convs-meta">${esc(ni({
|
|
10070
10217
|
updated: c.updated,
|
|
10071
10218
|
count: c.count
|
|
10072
10219
|
}))}</span></button><span class="hb-convs-acts"><button type="button" class="hb-convs-act" data-ren="${esc(c.id)}" aria-label="rename ${esc(c.title)}" title="rename">${ICON.pen}</button><button type="button" class="hb-convs-act is-del${armed === c.id ? " is-armed" : ""}" data-del="${esc(c.id)}" aria-label="${armed === c.id ? `press again to delete ${esc(c.title)}` : `delete ${esc(c.title)}`}">${armed === c.id ? "delete?" : ICON.trash}</button></span></li>`).join("") + `</ul></nav>`;
|
|
@@ -10102,7 +10249,7 @@ Component that was made reactive: `, type);
|
|
|
10102
10249
|
const l = listeners();
|
|
10103
10250
|
const val = (v, d) => typeof v === "function" ? v() : v ?? d;
|
|
10104
10251
|
const draw = (s) => {
|
|
10105
|
-
const use =
|
|
10252
|
+
const use = ti(contextSegments(s, val(o.system, "")), val(o.budget, 4096));
|
|
10106
10253
|
host.innerHTML = `<div class="hb-ctxmeter is-${use.tone}"><div class="hb-ctxmeter-hd"><span class="hb-ctxmeter-label">context</span><span class="hb-ctxmeter-words">${esc(use.words)}</span></div><div class="hb-ctxmeter-bar" role="meter" aria-label="context used" aria-valuemin="0" aria-valuemax="${use.budget}" aria-valuenow="${use.used}" aria-valuetext="${esc(use.words)}">${use.rows.map((r, n) => `<i class="hb-ctxmeter-p${n % 6}" style="width:${Math.min(100, r.fraction * 100)}%"></i>`).join("")}</div><ul class="hb-ctxmeter-legend">${use.rows.map((r, n) => `<li><i class="hb-ctxmeter-p${n % 6}" aria-hidden="true"></i>${esc(r.label)} <b>${r.tokens.toLocaleString("en-US")}</b></li>`).join("")}</ul></div>`;
|
|
10107
10254
|
};
|
|
10108
10255
|
l.add(thread.subscribe(draw));
|
|
@@ -10117,13 +10264,13 @@ Component that was made reactive: `, type);
|
|
|
10117
10264
|
/** The HTML of one channel's transcript, or an empty note when there is none. */
|
|
10118
10265
|
function transcriptHtml(c, o = {}) {
|
|
10119
10266
|
if (!c) return `<p class="hb-lay-empty-note">nothing yet. drop a file.</p>`;
|
|
10120
|
-
const st =
|
|
10267
|
+
const st = ki(c.status);
|
|
10121
10268
|
const head = `<div class="hb-panel-hd-inst" role="status">${esc(c.name)}, ${esc(st.word)}${c.status === "working" ? `, ${c.pct}%` : ""}</div>${c.error ? `<p class="hb-lay-empty-note">${esc(c.error)}</p>` : ""}`;
|
|
10122
10269
|
if (!c.segments.length) return `<section class="hb-panel">${head}</section>`;
|
|
10123
|
-
return `<section class="hb-panel">${head}<ol class="hb-transcript is-edit" aria-label="transcript">${c.dropped.length ? `<li class="hb-tseg-note">${esc(
|
|
10124
|
-
const t =
|
|
10270
|
+
return `<section class="hb-panel">${head}<ol class="hb-transcript is-edit" aria-label="transcript">${c.dropped.length ? `<li class="hb-tseg-note">${esc(yi(c.dropped))}</li>` : ""}${c.segments.map((s, i) => {
|
|
10271
|
+
const t = ie(s.start);
|
|
10125
10272
|
return `<li><div class="hb-tseg"><span class="hb-tseg-body">${o.onSeek ? `<button type="button" class="hb-tseg-t" data-seek="${s.start}" aria-label="play from ${t}">${t}</button>` : `<span class="hb-tseg-t">${t}</span>`}${o.speakers ? `<input class="hb-tseg-who" data-who="${i}" placeholder="speaker" aria-label="speaker at ${t}" value="${esc(s.speaker ?? "")}">` : s.speaker ? `<b>${esc(s.speaker)}: </b>` : ""}<span class="hb-tseg-text" contenteditable="true" role="textbox" aria-label="text at ${t}" data-line="${i}">${esc(s.text)}</span>${s.edited ? `<span class="hb-tseg-why">edited</span>` : ""}</span></div></li>`;
|
|
10126
|
-
}).join("")}${o.showDropped ? c.dropped.map((d) => `<li><div class="hb-tseg is-dropped"><span class="hb-tseg-body"><span class="hb-tseg-t">${
|
|
10273
|
+
}).join("")}${o.showDropped ? c.dropped.map((d) => `<li><div class="hb-tseg is-dropped"><span class="hb-tseg-body"><span class="hb-tseg-t">${ie(d.start)}</span><span class="hb-tseg-text">${esc(d.text)}</span><span class="hb-tseg-why">[${esc(d.why)}]</span></span></div></li>`).join("") : ""}</ol></section>`;
|
|
10127
10274
|
}
|
|
10128
10275
|
const pickedOf = (s) => s.channels.find((c) => c.id === s.selected);
|
|
10129
10276
|
/** The selected channel's transcript over a host. */
|
|
@@ -10161,6 +10308,29 @@ Component that was made reactive: `, type);
|
|
|
10161
10308
|
l.add(queue.subscribe(draw));
|
|
10162
10309
|
return { dispose: () => l.off() };
|
|
10163
10310
|
}
|
|
10311
|
+
const AV = /\.(mp4|m4v|mov|webm|mkv|avi|mpe?g|ogv|m4a|mp3|wav|flac|ogg|opus|aac|wma|3gp)$/i;
|
|
10312
|
+
/** A file a speech run can read: audio or video by type or by name. */
|
|
10313
|
+
const isMedia = (f) => /^(audio|video)\//.test(f.type) || AV.test(f.name);
|
|
10314
|
+
async function walk$1(e, out, depth = 0) {
|
|
10315
|
+
if (e.isFile && e.file) out.push(await new Promise((ok, bad) => e.file(ok, bad)));
|
|
10316
|
+
else if (e.isDirectory && e.createReader && depth < 8) {
|
|
10317
|
+
const r = e.createReader();
|
|
10318
|
+
for (;;) {
|
|
10319
|
+
const batch = await new Promise((ok, bad) => r.readEntries(ok, bad));
|
|
10320
|
+
if (!batch.length) break;
|
|
10321
|
+
for (const c of batch) await walk$1(c, out, depth + 1);
|
|
10322
|
+
}
|
|
10323
|
+
}
|
|
10324
|
+
}
|
|
10325
|
+
/** The files of a drop, with dropped folders read through, media only. */
|
|
10326
|
+
async function droppedFiles(dt) {
|
|
10327
|
+
if (!dt) return [];
|
|
10328
|
+
const entries = [...dt.items ?? []].map((i) => i.webkitGetAsEntry?.()).filter((x) => x !== null && x !== void 0);
|
|
10329
|
+
if (!entries.length) return [...dt.files].filter(isMedia);
|
|
10330
|
+
const out = [];
|
|
10331
|
+
for (const e of entries) await walk$1(e, out).catch(() => void 0);
|
|
10332
|
+
return out.filter(isMedia);
|
|
10333
|
+
}
|
|
10164
10334
|
/** The drop zone that becomes the transcript. */
|
|
10165
10335
|
function mountTranscribeDrop(host, queue, o = {}) {
|
|
10166
10336
|
const l = listeners();
|
|
@@ -10169,15 +10339,19 @@ Component that was made reactive: `, type);
|
|
|
10169
10339
|
input.hidden = true;
|
|
10170
10340
|
input.multiple = true;
|
|
10171
10341
|
input.accept = o.accept ?? "audio/*,video/*";
|
|
10342
|
+
const dir = document.createElement("input");
|
|
10343
|
+
dir.type = "file";
|
|
10344
|
+
dir.hidden = true;
|
|
10345
|
+
dir.setAttribute("webkitdirectory", "");
|
|
10172
10346
|
const zone = document.createElement("div");
|
|
10173
10347
|
const result = document.createElement("div");
|
|
10174
|
-
host.replaceChildren(zone, result, input);
|
|
10348
|
+
host.replaceChildren(zone, result, input, dir);
|
|
10175
10349
|
zone.className = "hb-lay-drop";
|
|
10176
10350
|
result.className = "hb-lay-scroll";
|
|
10177
|
-
zone.innerHTML = `<div class="hb-lay-empty"><span class="hb-lay-empty-name">${esc(o.title ?? "drop audio or video")}</span><p class="hb-lay-empty-note">${esc(o.note ?? "any length. the words are worked out on this machine and the file never leaves it.")}</p><div class="hb-lay-empty-acts"><button type="button" class="hb-btn hb-btn-go" data-pick>${esc(o.pickLabel ?? "choose a file")}</button>${o.sampleLabel ? `<button type="button" class="hb-btn" data-sample>${esc(o.sampleLabel)}</button>` : ""}</div></div>`;
|
|
10351
|
+
zone.innerHTML = `<div class="hb-lay-empty"><span class="hb-lay-empty-name">${esc(o.title ?? "drop audio or video")}</span><p class="hb-lay-empty-note">${esc(o.note ?? "any length. the words are worked out on this machine and the file never leaves it.")}</p><div class="hb-lay-empty-acts"><button type="button" class="hb-btn hb-btn-go" data-pick>${esc(o.pickLabel ?? "choose a file")}</button>${o.folders ? `<button type="button" class="hb-btn" data-folder>a folder</button>` : ""}${o.sampleLabel ? `<button type="button" class="hb-btn" data-sample>${esc(o.sampleLabel)}</button>` : ""}</div></div>`;
|
|
10178
10352
|
const view = mountTranscriptView(result, queue, o);
|
|
10179
10353
|
const take = (list) => {
|
|
10180
|
-
const files = list ? [...list] : [];
|
|
10354
|
+
const files = list ? [...list].filter(isMedia) : [];
|
|
10181
10355
|
if (files.length) queue.add(files);
|
|
10182
10356
|
};
|
|
10183
10357
|
l.on(host, "dragover", (e) => {
|
|
@@ -10188,7 +10362,11 @@ Component that was made reactive: `, type);
|
|
|
10188
10362
|
l.on(host, "drop", (e) => {
|
|
10189
10363
|
e.preventDefault();
|
|
10190
10364
|
zone.classList.remove("is-hot");
|
|
10191
|
-
|
|
10365
|
+
droppedFiles(e.dataTransfer).then((fs) => fs.length && queue.add(fs));
|
|
10366
|
+
});
|
|
10367
|
+
l.on(dir, "change", () => {
|
|
10368
|
+
take(dir.files);
|
|
10369
|
+
dir.value = "";
|
|
10192
10370
|
});
|
|
10193
10371
|
l.on(input, "change", () => {
|
|
10194
10372
|
take(input.files);
|
|
@@ -10197,6 +10375,7 @@ Component that was made reactive: `, type);
|
|
|
10197
10375
|
l.on(zone, "click", (e) => {
|
|
10198
10376
|
const t = e.target;
|
|
10199
10377
|
if (t.closest("[data-pick]")) input.click();
|
|
10378
|
+
else if (t.closest("[data-folder]")) dir.click();
|
|
10200
10379
|
else if (t.closest("[data-sample]")) o.onSample?.();
|
|
10201
10380
|
});
|
|
10202
10381
|
l.add(queue.subscribe((s) => {
|
|
@@ -10206,6 +10385,7 @@ Component that was made reactive: `, type);
|
|
|
10206
10385
|
}));
|
|
10207
10386
|
return {
|
|
10208
10387
|
pick: () => input.click(),
|
|
10388
|
+
pickFolder: () => dir.click(),
|
|
10209
10389
|
dispose() {
|
|
10210
10390
|
l.off();
|
|
10211
10391
|
view.dispose();
|
|
@@ -10217,7 +10397,7 @@ Component that was made reactive: `, type);
|
|
|
10217
10397
|
const l = listeners();
|
|
10218
10398
|
const draw = (s) => {
|
|
10219
10399
|
const strips = s.channels.map((c, i) => {
|
|
10220
|
-
const st =
|
|
10400
|
+
const st = ki(c.status);
|
|
10221
10401
|
return `<li class="hb-qstrip is-${st.tone || "idle"}${c.id === s.selected ? " is-sel" : ""}${c.status === "done" ? " is-done" : ""}"><button type="button" class="hb-qstrip-main" data-sel="${c.id}" aria-pressed="${c.id === s.selected}"><span class="hb-qstrip-n">${String(i + 1).padStart(2, "0")}</span><span class="hb-qstrip-body"><span class="hb-qstrip-hd"><span class="hb-qstrip-name">${esc(c.name)}</span><span class="hb-qstrip-stat">${esc(st.word)}</span></span>` + (c.meta.length || c.error ? `<span class="hb-qstrip-meta">${c.meta.map((m) => `<span>${m.label ? `${esc(m.label)} ` : ""}<b${m.tone ? ` class="is-${m.tone}"` : ""}>${esc(m.value)}</b></span>`).join("")}${c.error ? `<span class="is-lo">${esc(c.error)}</span>` : ""}</span>` : "") + (c.status === "working" ? `<span class="hb-qstrip-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${c.pct}" aria-label="${esc(c.name)} progress"><i style="--hb-v:${c.pct / 100}"></i></span>` : "") + `</span></button>` + (s.running ? "" : `<button type="button" class="hb-qstrip-x" data-rm="${c.id}" aria-label="remove ${esc(c.name)}" title="remove">${ICON.x}</button>`) + `</li>`;
|
|
10222
10402
|
}).join("");
|
|
10223
10403
|
const queued = s.channels.some((c) => c.status === "queued");
|
|
@@ -10269,6 +10449,462 @@ Component that was made reactive: `, type);
|
|
|
10269
10449
|
l.add(queue.subscribe(draw));
|
|
10270
10450
|
return { dispose: () => l.off() };
|
|
10271
10451
|
}
|
|
10452
|
+
/**
|
|
10453
|
+
* ExportMenu: the selected transcript as txt, srt, vtt or json, a copy, and
|
|
10454
|
+
* every finished transcript as one zip with a manifest, plus undo and redo of
|
|
10455
|
+
* edits. Nothing shows until there is text; undo shows once there is a change.
|
|
10456
|
+
* `go` makes the first export the one pink action.
|
|
10457
|
+
*/
|
|
10458
|
+
function mountExportMenu(host, queue, o = {}) {
|
|
10459
|
+
const l = listeners();
|
|
10460
|
+
const save = o.save ?? ((name, data, type) => download(name, typeof data === "string" ? data : new Blob([data], { type }), type));
|
|
10461
|
+
const draw = (s) => {
|
|
10462
|
+
const c = pickedOf(s);
|
|
10463
|
+
const done = s.channels.filter((x) => x.segments.length).length;
|
|
10464
|
+
host.innerHTML = c?.segments.length ? `<div class="hb-toolbar" role="group" aria-label="export">${[
|
|
10465
|
+
"txt",
|
|
10466
|
+
"srt",
|
|
10467
|
+
"vtt",
|
|
10468
|
+
"json"
|
|
10469
|
+
].map((k, i) => `<button type="button" class="hb-btn${o.go && i === 0 ? " hb-btn-go" : ""}" data-ex="${k}">${o.go && i === 0 ? `save ${k}` : k}</button>`).join("")}<button type="button" class="hb-btn" data-copy>${ICON.copy}copy</button>${done ? `<button type="button" class="hb-btn" data-zip>all ${done} as zip</button>` : ""}${s.canUndo ? `<button type="button" class="hb-iconbtn" data-undo aria-label="undo the last edit" title="undo">${ICON.undo}</button>` : ""}${s.canRedo ? `<button type="button" class="hb-iconbtn" data-redo aria-label="redo" title="redo">${ICON.redo}</button>` : ""}</div>` : "";
|
|
10470
|
+
};
|
|
10471
|
+
l.on(host, "click", (e) => {
|
|
10472
|
+
const t = e.target;
|
|
10473
|
+
const ex = t.closest("[data-ex]");
|
|
10474
|
+
if (ex) {
|
|
10475
|
+
const f = queue.exportAs(ex.dataset.ex);
|
|
10476
|
+
if (f) save(f.name, f.text, f.type);
|
|
10477
|
+
return;
|
|
10478
|
+
}
|
|
10479
|
+
if (t.closest("[data-zip]")) {
|
|
10480
|
+
const z = queue.zip(o.tool ? { tool: o.tool } : {});
|
|
10481
|
+
if (z) save(z.name, z.data, "application/zip");
|
|
10482
|
+
return;
|
|
10483
|
+
}
|
|
10484
|
+
const cp = t.closest("[data-copy]");
|
|
10485
|
+
if (cp) {
|
|
10486
|
+
const f = queue.exportAs("txt");
|
|
10487
|
+
if (f) navigator.clipboard?.writeText(f.text).then(() => cp.lastChild.textContent = "copied").catch(() => cp.lastChild.textContent = "copy blocked");
|
|
10488
|
+
return;
|
|
10489
|
+
}
|
|
10490
|
+
if (t.closest("[data-undo]")) queue.undo();
|
|
10491
|
+
else if (t.closest("[data-redo]")) queue.redo();
|
|
10492
|
+
});
|
|
10493
|
+
l.add(queue.subscribe(draw));
|
|
10494
|
+
return { dispose: () => l.off() };
|
|
10495
|
+
}
|
|
10496
|
+
// packages/ai-views/src/mount-talk.ts
|
|
10497
|
+
/** True when an item is kept out of cleanup: decay never drops it. */
|
|
10498
|
+
const isProtected = (it) => it.meta?.protected === true;
|
|
10499
|
+
/** Protect an item from cleanup (it becomes lore, which never decays) or give it back its kind. */
|
|
10500
|
+
async function protect(mem, it, on) {
|
|
10501
|
+
if (on === isProtected(it)) return;
|
|
10502
|
+
const meta = { ...it.meta ?? {} };
|
|
10503
|
+
if (on) await mem.edit(it.id, {
|
|
10504
|
+
kind: "lore",
|
|
10505
|
+
meta: {
|
|
10506
|
+
...meta,
|
|
10507
|
+
protected: true,
|
|
10508
|
+
was: it.kind
|
|
10509
|
+
}
|
|
10510
|
+
});
|
|
10511
|
+
else {
|
|
10512
|
+
const was = meta.was ?? "fact";
|
|
10513
|
+
delete meta.protected;
|
|
10514
|
+
delete meta.was;
|
|
10515
|
+
await mem.edit(it.id, {
|
|
10516
|
+
kind: was,
|
|
10517
|
+
meta
|
|
10518
|
+
});
|
|
10519
|
+
}
|
|
10520
|
+
}
|
|
10521
|
+
const sourceOf = (it) => typeof it.meta?.source === "string" ? it.meta.source.split("/")[0] : it.kind === "doc" ? it.section ?? "file" : "notes";
|
|
10522
|
+
/** The memory pane: counts, search, a source or kind filter, add a note, the list with protect and forget, export, import, erase. */
|
|
10523
|
+
function mountMemoryPane(host, mem, o = {}) {
|
|
10524
|
+
const l = listeners();
|
|
10525
|
+
let query = "";
|
|
10526
|
+
let source = "";
|
|
10527
|
+
let armed = 0;
|
|
10528
|
+
let wipe = false;
|
|
10529
|
+
let used = /* @__PURE__ */ new Set();
|
|
10530
|
+
let hits = null;
|
|
10531
|
+
let seq = 0;
|
|
10532
|
+
const file = document.createElement("input");
|
|
10533
|
+
file.type = "file";
|
|
10534
|
+
file.accept = ".json,application/json";
|
|
10535
|
+
file.hidden = true;
|
|
10536
|
+
const box = document.createElement("div");
|
|
10537
|
+
host.replaceChildren(box, file);
|
|
10538
|
+
const changed = () => (o.onChange?.(), draw());
|
|
10539
|
+
const groupOf = (it) => o.by === "kind" ? isProtected(it) ? String(it.meta?.was ?? it.kind) : it.kind : sourceOf(it);
|
|
10540
|
+
const groupWord = (g) => o.by === "kind" ? o.kinds?.[g] ?? g : g;
|
|
10541
|
+
const draw = () => {
|
|
10542
|
+
const all = mem.all();
|
|
10543
|
+
const sources = [...new Set(all.map(groupOf))];
|
|
10544
|
+
let shown = all.filter((it) => !source || groupOf(it) === source);
|
|
10545
|
+
if (hits) shown = shown.filter((it) => hits.has(it.id)).sort((a, b) => hits.get(b.id) - hits.get(a.id));
|
|
10546
|
+
else shown = shown.slice().sort((a, b) => b.created - a.created);
|
|
10547
|
+
const focus = document.activeElement === box.querySelector("[data-q]");
|
|
10548
|
+
box.innerHTML = `<section class="hb-mempanel" aria-label="${esc(o.name ?? "memory")}"><div class="hb-mempanel-sec"><p class="hb-mempanel-counts">${esc(oi(all.map((it) => ({
|
|
10549
|
+
id: String(it.id),
|
|
10550
|
+
text: it.text,
|
|
10551
|
+
kind: it.kind
|
|
10552
|
+
}))) || "nothing stored")}</p></div><div class="hb-mempanel-sec"><input class="hb-input" type="search" data-q placeholder="search memory" aria-label="search memory" value="${esc(query)}">` + (sources.length > 1 ? `<div class="hb-chipgroup" role="group" aria-label="${o.by === "kind" ? "kind" : "source"}"><button type="button" class="hb-chip${source ? "" : " is-on"}" data-src="" aria-pressed="${!source}">all</button>${sources.map((s) => `<button type="button" class="hb-chip${s === source ? " is-on" : ""}" data-src="${esc(s)}" aria-pressed="${s === source}">${esc(groupWord(s))}</button>`).join("")}</div>` : "") + `</div><div class="hb-mempanel-sec"><textarea class="hb-textarea" rows="2" data-note placeholder="a fact to keep" aria-label="add a note"></textarea><div class="hb-mempanel-row"><button type="button" class="hb-btn hb-btn-sm" data-add>add</button></div></div><div class="hb-mempanel-sec"><h3 class="hb-mempanel-hd">${query ? "matches" : "notes"} (${shown.length})</h3>` + (shown.length ? `<div class="hb-mempanel-list">${shown.slice(0, 200).map((it) => {
|
|
10553
|
+
const p = isProtected(it);
|
|
10554
|
+
const u = used.has(it.text);
|
|
10555
|
+
return `<div class="hb-mem${u ? " is-used" : ""}${p ? " is-pinned" : ""}"><div class="hb-mem-body">${p ? `<span class="hb-mem-pin">kept</span>` : ""}<span class="hb-mem-kind">${esc(p ? String(it.meta?.was ?? it.kind) : it.kind)}${hits?.has(it.id) ? `<b class="hb-mem-score">${esc(ii(hits.get(it.id)))}</b>` : ""}</span><span class="hb-mem-text">${esc(it.text.length > 280 ? `${it.text.slice(0, 277)}...` : it.text)}</span><span class="hb-mem-when">${esc([u ? "used last reply" : "", sourceOf(it) === "notes" ? "" : sourceOf(it)].filter(Boolean).join(", "))}</span></div><div class="hb-mem-acts"><button type="button" class="hb-mem-act${p ? " is-on" : ""}" data-keep="${it.id}" aria-pressed="${p}" aria-label="${p ? "let cleanup drop it" : "keep from cleanup"}" title="${p ? "kept from cleanup" : "keep"}">keep</button><button type="button" class="hb-mem-act is-forget${armed === it.id ? " is-armed" : ""}" data-forget="${it.id}">${armed === it.id ? "forget?" : "forget"}</button></div></div>`;
|
|
10556
|
+
}).join("")}</div>` : `<p class="hb-mempanel-empty">${query ? "nothing matches. try other words." : "nothing stored yet. add a note, drop a file, or talk and it fills."}</p>`) + `</div><div class="hb-mempanel-foot">${all.length ? (o.acts ?? []).map((a) => `<button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-act="${esc(a.id)}">${esc(a.label)}</button>`).join("") : ""}<button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-export>${esc(o.exportLabel ?? "export")}</button><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-import>import</button>${all.length ? `<button type="button" class="hb-btn hb-btn-2 hb-btn-sm hb-mempanel-wipe${wipe ? " is-armed" : ""}" data-wipe>${wipe ? "erase everything?" : "erase all"}</button>` : ""}</div></section>`;
|
|
10557
|
+
if (focus) {
|
|
10558
|
+
const q = box.querySelector("[data-q]");
|
|
10559
|
+
q.focus();
|
|
10560
|
+
q.setSelectionRange(q.value.length, q.value.length);
|
|
10561
|
+
}
|
|
10562
|
+
};
|
|
10563
|
+
const search = async () => {
|
|
10564
|
+
const mine = ++seq;
|
|
10565
|
+
if (!query.trim()) hits = null;
|
|
10566
|
+
else {
|
|
10567
|
+
const r = await mem.recall(query, { k: 50 });
|
|
10568
|
+
if (mine !== seq) return;
|
|
10569
|
+
hits = new Map(r.hits.map((h) => [h.item.id, h.score]));
|
|
10570
|
+
}
|
|
10571
|
+
draw();
|
|
10572
|
+
};
|
|
10573
|
+
l.on(box, "input", (e) => {
|
|
10574
|
+
const t = e.target;
|
|
10575
|
+
if (t.matches("[data-q]")) {
|
|
10576
|
+
query = t.value;
|
|
10577
|
+
search();
|
|
10578
|
+
}
|
|
10579
|
+
});
|
|
10580
|
+
l.on(box, "keydown", (e) => {
|
|
10581
|
+
const ke = e;
|
|
10582
|
+
if (ke.target.matches("[data-note]") && ke.key === "Enter" && !ke.shiftKey) {
|
|
10583
|
+
ke.preventDefault();
|
|
10584
|
+
box.querySelector("[data-add]")?.click();
|
|
10585
|
+
}
|
|
10586
|
+
});
|
|
10587
|
+
l.on(box, "click", (e) => {
|
|
10588
|
+
const t = e.target;
|
|
10589
|
+
const src = t.closest("[data-src]");
|
|
10590
|
+
if (src) return source = src.dataset.src ?? "", draw();
|
|
10591
|
+
const all = () => mem.all();
|
|
10592
|
+
const keep = t.closest("[data-keep]");
|
|
10593
|
+
if (keep) {
|
|
10594
|
+
const it = all().find((x) => x.id === Number(keep.dataset.keep));
|
|
10595
|
+
if (it) protect(mem, it, !isProtected(it)).then(changed);
|
|
10596
|
+
return;
|
|
10597
|
+
}
|
|
10598
|
+
const fg = t.closest("[data-forget]");
|
|
10599
|
+
if (fg) {
|
|
10600
|
+
const id = Number(fg.dataset.forget);
|
|
10601
|
+
if (armed !== id) return armed = id, draw();
|
|
10602
|
+
armed = 0;
|
|
10603
|
+
mem.remove([id]).then(changed);
|
|
10604
|
+
return;
|
|
10605
|
+
}
|
|
10606
|
+
if (t.closest("[data-add]")) {
|
|
10607
|
+
const text = box.querySelector("[data-note]").value.trim();
|
|
10608
|
+
if (text) mem.add(text, { kind: "fact" }).then(changed);
|
|
10609
|
+
return;
|
|
10610
|
+
}
|
|
10611
|
+
const act = t.closest("[data-act]");
|
|
10612
|
+
if (act) return o.onAct?.(act.dataset.act ?? "");
|
|
10613
|
+
if (t.closest("[data-export]")) return download(`memory-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.json`, JSON.stringify(mem.export(), null, 2), "application/json");
|
|
10614
|
+
if (t.closest("[data-import]")) return file.click();
|
|
10615
|
+
if (t.closest("[data-wipe]")) {
|
|
10616
|
+
if (!wipe) return wipe = true, draw();
|
|
10617
|
+
wipe = false;
|
|
10618
|
+
mem.remove(all().map((x) => x.id)).then(changed);
|
|
10619
|
+
}
|
|
10620
|
+
});
|
|
10621
|
+
l.on(file, "change", () => {
|
|
10622
|
+
const f = file.files?.[0];
|
|
10623
|
+
file.value = "";
|
|
10624
|
+
if (!f) return;
|
|
10625
|
+
f.text().then((t) => mem.import(JSON.parse(t), { replace: false })).then(changed).catch((err) => {
|
|
10626
|
+
box.querySelector(".hb-mempanel-foot")?.insertAdjacentHTML("beforeend", `<p class="hb-error" role="alert">that file did not import: ${esc(err instanceof Error ? err.message : String(err))}</p>`);
|
|
10627
|
+
});
|
|
10628
|
+
});
|
|
10629
|
+
draw();
|
|
10630
|
+
return {
|
|
10631
|
+
refresh: () => void search(),
|
|
10632
|
+
used(labels) {
|
|
10633
|
+
used = new Set(labels);
|
|
10634
|
+
draw();
|
|
10635
|
+
},
|
|
10636
|
+
dispose: () => l.off()
|
|
10637
|
+
};
|
|
10638
|
+
}
|
|
10639
|
+
async function walk(e, out, path, depth = 0) {
|
|
10640
|
+
if (e.isFile && e.file) {
|
|
10641
|
+
const f = await new Promise((ok, bad) => e.file(ok, bad));
|
|
10642
|
+
out.push(path ? Object.assign(new File([f], f.name, { type: f.type }), { webkitRelativePath: `${path}/${f.name}` }) : f);
|
|
10643
|
+
} else if (e.isDirectory && e.createReader && depth < 8) {
|
|
10644
|
+
const r = e.createReader();
|
|
10645
|
+
for (;;) {
|
|
10646
|
+
const batch = await new Promise((ok, bad) => r.readEntries(ok, bad));
|
|
10647
|
+
if (!batch.length) break;
|
|
10648
|
+
for (const c of batch) await walk(c, out, path ? `${path}/${e.name}` : e.name, depth + 1);
|
|
10649
|
+
}
|
|
10650
|
+
}
|
|
10651
|
+
}
|
|
10652
|
+
/** A drop zone for sources: files or a whole folder of text, pdf, docx, zip and mail go into memory; a line per file says what came in. */
|
|
10653
|
+
function mountSourcesDrop(host, o) {
|
|
10654
|
+
const l = listeners();
|
|
10655
|
+
const pick = (dir) => {
|
|
10656
|
+
const i = document.createElement("input");
|
|
10657
|
+
i.type = "file";
|
|
10658
|
+
i.hidden = true;
|
|
10659
|
+
i.multiple = true;
|
|
10660
|
+
if (dir) i.setAttribute("webkitdirectory", "");
|
|
10661
|
+
else i.accept = o.accept ?? ".txt,.md,.csv,.json,.html,.htm,.pdf,.docx,.zip,.eml,text/*";
|
|
10662
|
+
return i;
|
|
10663
|
+
};
|
|
10664
|
+
const files = pick(false);
|
|
10665
|
+
const dir = pick(true);
|
|
10666
|
+
const zone = document.createElement("div");
|
|
10667
|
+
const log = document.createElement("ul");
|
|
10668
|
+
zone.className = "hb-dropzone";
|
|
10669
|
+
zone.innerHTML = `<p class="hb-note">drop files or a folder: text, pdf, docx, zip, mail. they are read here and kept in this browser.</p><div class="hb-toolbar"><button type="button" class="hb-btn hb-btn-sm" data-files>add files</button><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-dir>a folder</button></div>`;
|
|
10670
|
+
log.className = "hb-list";
|
|
10671
|
+
log.setAttribute("aria-live", "polite");
|
|
10672
|
+
host.replaceChildren(zone, log, files, dir);
|
|
10673
|
+
const line = (t, err = false) => log.insertAdjacentHTML("afterbegin", `<li${err ? ` class="hb-error"` : ""}>${esc(t)}</li>`);
|
|
10674
|
+
const run = (list) => {
|
|
10675
|
+
if (!list.length) return;
|
|
10676
|
+
zone.classList.add("is-busy");
|
|
10677
|
+
line(`reading ${list.length} file${list.length === 1 ? "" : "s"}`);
|
|
10678
|
+
o.ingest(list, { onFile: (e) => line(e.note ? `${e.name}: ${e.note}` : `${e.name}: ${e.chunks} part${e.chunks === 1 ? "" : "s"}`, !!e.note && e.note.startsWith("failed")) }).then((r) => line(`done. ${r.files} file${r.files === 1 ? "" : "s"}, ${r.chunks} parts in memory.`)).catch((err) => line(`stopped: ${err instanceof Error ? err.message : String(err)}`, true)).finally(() => zone.classList.remove("is-busy"));
|
|
10679
|
+
};
|
|
10680
|
+
l.on(zone, "click", (e) => {
|
|
10681
|
+
const t = e.target;
|
|
10682
|
+
if (t.closest("[data-files]")) files.click();
|
|
10683
|
+
else if (t.closest("[data-dir]")) dir.click();
|
|
10684
|
+
});
|
|
10685
|
+
for (const i of [files, dir]) l.on(i, "change", () => {
|
|
10686
|
+
run([...i.files ?? []]);
|
|
10687
|
+
i.value = "";
|
|
10688
|
+
});
|
|
10689
|
+
l.on(zone, "dragover", (e) => (e.preventDefault(), zone.classList.add("is-over")));
|
|
10690
|
+
l.on(zone, "dragleave", () => zone.classList.remove("is-over"));
|
|
10691
|
+
l.on(zone, "drop", (e) => {
|
|
10692
|
+
e.preventDefault();
|
|
10693
|
+
zone.classList.remove("is-over");
|
|
10694
|
+
const dt = e.dataTransfer;
|
|
10695
|
+
const entries = [...dt?.items ?? []].map((i) => i.webkitGetAsEntry?.()).filter((x) => x !== null && x !== void 0);
|
|
10696
|
+
if (!entries.length) return run([...dt?.files ?? []]);
|
|
10697
|
+
const out = [];
|
|
10698
|
+
Promise.all(entries.map((en) => walk(en, out, "").catch(() => void 0))).then(() => run(out));
|
|
10699
|
+
});
|
|
10700
|
+
return { dispose: () => l.off() };
|
|
10701
|
+
}
|
|
10702
|
+
/** The persona rack: presets one press away, name, the three parts with their cost, the template, save, and the persona as a file. */
|
|
10703
|
+
function mountPersonaRack(host, rack) {
|
|
10704
|
+
const l = listeners();
|
|
10705
|
+
const file = document.createElement("input");
|
|
10706
|
+
file.type = "file";
|
|
10707
|
+
file.accept = ".json,application/json";
|
|
10708
|
+
file.hidden = true;
|
|
10709
|
+
const box = document.createElement("div");
|
|
10710
|
+
host.replaceChildren(box, file);
|
|
10711
|
+
let err = "";
|
|
10712
|
+
const field = (key, label, hint, rows, v) => `<div class="hb-field"><span class="hb-field-head"><label class="hb-label" for="pr-${key}">${label}</label></span><textarea id="pr-${key}" class="hb-textarea" rows="${rows}" data-k="${key}" placeholder="${esc(hint)}">${esc(v)}</textarea><span class="hb-field-foot"><span class="hb-hint">${esc(Ds(Ts(v)))}</span></span></div>`;
|
|
10713
|
+
const draw = () => {
|
|
10714
|
+
if (box.contains(document.activeElement) && document.activeElement.matches("[data-k]")) return;
|
|
10715
|
+
const { persona: p, presets, on, builtIn } = rack.snapshot();
|
|
10716
|
+
box.innerHTML = `<div class="hb-persona"><div class="hb-persona-presets"><div class="hb-persona-chips" role="group" aria-label="personas">${presets.map((x, i) => `<span class="hb-persona-chip${i === on ? " is-on" : ""}"><button type="button" class="hb-persona-chip-n" data-load="${i}" aria-pressed="${i === on}">${esc(x.label)}</button>${i < builtIn ? "" : `<button type="button" class="hb-persona-chip-x" data-rm="${i}" aria-label="remove ${esc(x.label)}">×</button>`}</span>`).join("")}</div></div><div class="hb-field"><span class="hb-field-head"><label class="hb-label" for="pr-name">name</label></span><input id="pr-name" class="hb-input" data-k="name" value="${esc(p.name)}" autocomplete="off"></div>` + field("profile", "profile", "who you are talking to and how to answer. always sent.", 5, p.profile) + `<div class="hb-persona-row"><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-tpl>insert template</button></div>` + field("notes", "extra notes", "sent after memory; dropped before the profile when room runs out.", 3, p.notes) + field("rules", "extra rules", "dropped first when room runs out.", 3, p.rules) + `<form class="hb-persona-save" data-save><input class="hb-input" data-label placeholder="${esc(p.name || "preset name")}" aria-label="preset name" autocomplete="off"><button type="submit" class="hb-btn hb-btn-2 hb-btn-sm">save</button></form><div class="hb-persona-row"><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-import>import</button><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-export>export</button></div>${err ? `<p class="hb-error" role="alert">${esc(err)}</p>` : ""}</div>`;
|
|
10717
|
+
};
|
|
10718
|
+
l.on(box, "input", (e) => {
|
|
10719
|
+
const t = e.target;
|
|
10720
|
+
const k = t.dataset.k;
|
|
10721
|
+
if (k) {
|
|
10722
|
+
rack.set({ [k]: t.value });
|
|
10723
|
+
const foot = t.parentElement?.querySelector(".hb-hint");
|
|
10724
|
+
if (foot) foot.textContent = Ds(Ts(t.value));
|
|
10725
|
+
}
|
|
10726
|
+
});
|
|
10727
|
+
l.on(box, "focusout", () => setTimeout(draw, 0));
|
|
10728
|
+
l.on(box, "submit", (e) => {
|
|
10729
|
+
e.preventDefault();
|
|
10730
|
+
rack.save(box.querySelector("[data-label]")?.value ?? "");
|
|
10731
|
+
});
|
|
10732
|
+
l.on(box, "click", (e) => {
|
|
10733
|
+
const t = e.target;
|
|
10734
|
+
const ld = t.closest("[data-load]");
|
|
10735
|
+
if (ld) return rack.load(Number(ld.dataset.load));
|
|
10736
|
+
const rm = t.closest("[data-rm]");
|
|
10737
|
+
if (rm) return rack.removePreset(Number(rm.dataset.rm));
|
|
10738
|
+
if (t.closest("[data-tpl]")) {
|
|
10739
|
+
const p = rack.snapshot().persona;
|
|
10740
|
+
rack.set({ profile: qs(p.profile, br, p.name) });
|
|
10741
|
+
return draw();
|
|
10742
|
+
}
|
|
10743
|
+
if (t.closest("[data-export]")) {
|
|
10744
|
+
const p = rack.snapshot().persona;
|
|
10745
|
+
return download(`${(p.name || "persona").replace(/[^a-z0-9]+/gi, "-").toLowerCase()}.persona.json`, JSON.stringify({
|
|
10746
|
+
v: 1,
|
|
10747
|
+
name: p.name,
|
|
10748
|
+
prompt: p.profile,
|
|
10749
|
+
notes: p.notes,
|
|
10750
|
+
rules: p.rules,
|
|
10751
|
+
...p.first ? { first: p.first } : {}
|
|
10752
|
+
}, null, 2), "application/json");
|
|
10753
|
+
}
|
|
10754
|
+
if (t.closest("[data-import]")) file.click();
|
|
10755
|
+
});
|
|
10756
|
+
l.on(file, "change", () => {
|
|
10757
|
+
const f = file.files?.[0];
|
|
10758
|
+
file.value = "";
|
|
10759
|
+
if (!f) return;
|
|
10760
|
+
f.text().then((t) => {
|
|
10761
|
+
try {
|
|
10762
|
+
const j = JSON.parse(t);
|
|
10763
|
+
const profile = typeof j.prompt === "string" ? j.prompt : typeof j.system_prompt === "string" ? j.system_prompt : typeof j.description === "string" ? j.description : "";
|
|
10764
|
+
if (!profile && typeof j.name !== "string") throw new Error("no name or prompt in it");
|
|
10765
|
+
err = "";
|
|
10766
|
+
rack.set({
|
|
10767
|
+
name: String(j.name ?? "assistant"),
|
|
10768
|
+
profile,
|
|
10769
|
+
notes: String(j.notes ?? ""),
|
|
10770
|
+
rules: String(j.rules ?? ""),
|
|
10771
|
+
...typeof j.first === "string" ? { first: j.first } : {}
|
|
10772
|
+
});
|
|
10773
|
+
} catch (e2) {
|
|
10774
|
+
err = `that file is not a persona: ${e2 instanceof Error ? e2.message : String(e2)}`;
|
|
10775
|
+
}
|
|
10776
|
+
draw();
|
|
10777
|
+
});
|
|
10778
|
+
});
|
|
10779
|
+
l.add(rack.subscribe(draw));
|
|
10780
|
+
return { dispose: () => l.off() };
|
|
10781
|
+
}
|
|
10782
|
+
/** The voice row: auto speak, voice, rate, pitch, test and stop. */
|
|
10783
|
+
function mountVoiceRow(host, row, o = {}) {
|
|
10784
|
+
const l = listeners();
|
|
10785
|
+
const draw = () => {
|
|
10786
|
+
if (host.contains(document.activeElement) && document.activeElement.matches("input[type=range]")) return;
|
|
10787
|
+
const s = row.snapshot();
|
|
10788
|
+
host.innerHTML = `<div class="hb-panel"><label class="hb-check"><input type="checkbox" data-auto${s.auto ? " checked" : ""}> speak each reply</label><div class="hb-field"><span class="hb-field-head"><label class="hb-label" for="vr-voice">voice</label></span><select id="vr-voice" class="hb-select" data-voice><option value="">system default</option>${s.voices.map((v) => `<option${v === s.voice ? " selected" : ""}>${esc(v)}</option>`).join("")}</select></div><div class="hb-slider"><span class="hb-label">rate</span><span class="hb-readout">${s.rate.toFixed(1)}</span><input type="range" min="0.5" max="2" step="0.1" value="${s.rate}" data-rate aria-label="rate"></div><div class="hb-slider"><span class="hb-label">pitch</span><span class="hb-readout">${s.pitch.toFixed(1)}</span><input type="range" min="0" max="2" step="0.1" value="${s.pitch}" data-pitch aria-label="pitch"></div><div class="hb-toolbar">${s.speaking ? `<button type="button" class="hb-btn hb-btn-sm" data-stop>stop</button>` : `<button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-test>test</button>`}</div>${s.error ? `<p class="hb-error" role="alert">${esc(s.error)}</p>` : ""}</div>`;
|
|
10789
|
+
};
|
|
10790
|
+
l.on(host, "input", (e) => {
|
|
10791
|
+
const t = e.target;
|
|
10792
|
+
if (t.matches("[data-rate]")) row.set({ rate: Number(t.value) });
|
|
10793
|
+
else if (t.matches("[data-pitch]")) row.set({ pitch: Number(t.value) });
|
|
10794
|
+
const r = t.parentElement?.querySelector(".hb-readout");
|
|
10795
|
+
if (r && t.type === "range") r.textContent = Number(t.value).toFixed(1);
|
|
10796
|
+
});
|
|
10797
|
+
l.on(host, "change", (e) => {
|
|
10798
|
+
const t = e.target;
|
|
10799
|
+
if (t.matches("[data-auto]")) row.set({ auto: t.checked });
|
|
10800
|
+
else if (t.matches("[data-voice]")) row.set({ voice: t.value });
|
|
10801
|
+
else if (t.type === "range") draw();
|
|
10802
|
+
});
|
|
10803
|
+
l.on(host, "click", (e) => {
|
|
10804
|
+
const t = e.target;
|
|
10805
|
+
if (t.closest("[data-test]")) row.speak(o.test ?? "this is how replies will sound.");
|
|
10806
|
+
else if (t.closest("[data-stop]")) row.stop();
|
|
10807
|
+
});
|
|
10808
|
+
l.add(row.subscribe(draw));
|
|
10809
|
+
return { dispose: () => (row.stop(), l.off()) };
|
|
10810
|
+
}
|
|
10811
|
+
/** The voice clone row of a speaker: clone from an audio file, record `seconds` of mic, download the clone as wav, clear it. */
|
|
10812
|
+
function mountVoiceClone(host, sp, o = {}) {
|
|
10813
|
+
const l = listeners();
|
|
10814
|
+
const secs = o.seconds ?? 10;
|
|
10815
|
+
const file = document.createElement("input");
|
|
10816
|
+
file.type = "file";
|
|
10817
|
+
file.accept = "audio/*";
|
|
10818
|
+
file.hidden = true;
|
|
10819
|
+
const box = document.createElement("div");
|
|
10820
|
+
host.replaceChildren(box, file);
|
|
10821
|
+
let note = "";
|
|
10822
|
+
let busy = false;
|
|
10823
|
+
const draw = () => {
|
|
10824
|
+
const can = o.can?.() ?? true;
|
|
10825
|
+
box.innerHTML = `<div>` + (can ? `<div class="hb-toolbar" role="group" aria-label="voice clone"><button type="button" class="hb-btn hb-btn-sm" data-file${busy ? " disabled" : ""}>clone from audio file</button><button type="button" class="hb-btn hb-btn-sm" data-rec${busy ? " disabled" : ""}>record ${secs} s</button>${sp.cloned ? `<button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-wav>download clone, wav</button><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-clear>clear clone</button>` : ""}</div>` : "") + `<p class="hb-note" role="status">${esc(note || (can ? o.hint ?? `clones a voice from ${secs} s of audio. nothing leaves this tab.` : "this voice cannot clone. load pocket in the voice list."))}</p></div>`;
|
|
10826
|
+
};
|
|
10827
|
+
const fail = (err) => {
|
|
10828
|
+
const name = err.name ?? "";
|
|
10829
|
+
note = name === "NotAllowedError" || name === "SecurityError" ? "the mic is blocked. allow it in the address bar, or clone from a file." : err instanceof Error ? err.message : String(err);
|
|
10830
|
+
};
|
|
10831
|
+
l.on(box, "click", (e) => {
|
|
10832
|
+
const t = e.target;
|
|
10833
|
+
if (t.closest("[data-file]")) return file.click();
|
|
10834
|
+
if (t.closest("[data-wav]")) {
|
|
10835
|
+
const w = sp.cloneWav();
|
|
10836
|
+
if (w) download("voice-clone.wav", w, "audio/wav");
|
|
10837
|
+
return;
|
|
10838
|
+
}
|
|
10839
|
+
if (t.closest("[data-clear]")) {
|
|
10840
|
+
sp.clearClone();
|
|
10841
|
+
note = "clone cleared. the voice is its own again.";
|
|
10842
|
+
return draw();
|
|
10843
|
+
}
|
|
10844
|
+
if (t.closest("[data-rec]") && !busy) {
|
|
10845
|
+
busy = true;
|
|
10846
|
+
sp.cloneMic(secs, (left) => (note = `recording, ${left} s left`, draw())).then((s) => note = `cloned from ${s.toFixed(1)} s of your mic.`, fail).finally(() => (busy = false, draw()));
|
|
10847
|
+
}
|
|
10848
|
+
});
|
|
10849
|
+
l.on(file, "change", () => {
|
|
10850
|
+
const f = file.files?.[0];
|
|
10851
|
+
file.value = "";
|
|
10852
|
+
if (!f) return;
|
|
10853
|
+
busy = true;
|
|
10854
|
+
note = "cloning...";
|
|
10855
|
+
draw();
|
|
10856
|
+
sp.cloneFile(f).then((s) => note = `cloned from ${s.toFixed(1)} s of ${f.name}.`, fail).finally(() => (busy = false, draw()));
|
|
10857
|
+
});
|
|
10858
|
+
l.add(sp.subscribe(draw));
|
|
10859
|
+
draw();
|
|
10860
|
+
return { dispose: () => l.off() };
|
|
10861
|
+
}
|
|
10862
|
+
/** The session menu of a chat list: clear the open chat, export it as markdown, every chat as json, and import. */
|
|
10863
|
+
function mountSessionMenu(host, list, o = {}) {
|
|
10864
|
+
const l = listeners();
|
|
10865
|
+
const file = document.createElement("input");
|
|
10866
|
+
file.type = "file";
|
|
10867
|
+
file.accept = ".json,application/json";
|
|
10868
|
+
file.hidden = true;
|
|
10869
|
+
const box = document.createElement("div");
|
|
10870
|
+
host.replaceChildren(box, file);
|
|
10871
|
+
let armed = false;
|
|
10872
|
+
let note = "";
|
|
10873
|
+
const draw = () => {
|
|
10874
|
+
const has = list.thread.snapshot().turns.length > 0;
|
|
10875
|
+
box.innerHTML = `<div class="hb-toolbar" role="group" aria-label="session">${has ? `<button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-md>save as markdown</button>` : ""}<button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-json>export chats</button><button type="button" class="hb-btn hb-btn-2 hb-btn-sm" data-import>import chats</button>${has ? `<button type="button" class="hb-btn hb-btn-2 hb-btn-sm${armed ? " is-armed" : ""}" data-clear>${armed ? "clear this chat?" : "clear"}</button>` : ""}</div>${note ? `<p class="hb-note" role="status">${esc(note)}</p>` : ""}`;
|
|
10876
|
+
};
|
|
10877
|
+
l.on(box, "click", (e) => {
|
|
10878
|
+
const t = e.target;
|
|
10879
|
+
const day = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
10880
|
+
if (t.closest("[data-md]")) return download(`chat-${day}.md`, list.thread.markdown(), "text/markdown");
|
|
10881
|
+
if (t.closest("[data-json]")) return download(`chats-${day}.json`, JSON.stringify(list.dump(), null, 2), "application/json");
|
|
10882
|
+
if (t.closest("[data-import]")) return file.click();
|
|
10883
|
+
if (t.closest("[data-clear]")) {
|
|
10884
|
+
if (!armed) return armed = true, draw();
|
|
10885
|
+
armed = false;
|
|
10886
|
+
list.thread.clear();
|
|
10887
|
+
}
|
|
10888
|
+
});
|
|
10889
|
+
l.on(file, "change", () => {
|
|
10890
|
+
const f = file.files?.[0];
|
|
10891
|
+
file.value = "";
|
|
10892
|
+
if (!f) return;
|
|
10893
|
+
f.text().then((t) => {
|
|
10894
|
+
try {
|
|
10895
|
+
const data = JSON.parse(t);
|
|
10896
|
+
list.restore(data);
|
|
10897
|
+
note = `${data.chats.length} chat${data.chats.length === 1 ? "" : "s"} imported.`;
|
|
10898
|
+
o.onImport?.(data.chats.length);
|
|
10899
|
+
} catch (err) {
|
|
10900
|
+
note = `that file did not import: ${err instanceof Error ? err.message : String(err)}`;
|
|
10901
|
+
}
|
|
10902
|
+
draw();
|
|
10903
|
+
});
|
|
10904
|
+
});
|
|
10905
|
+
l.add(list.subscribe(() => draw()));
|
|
10906
|
+
return { dispose: () => l.off() };
|
|
10907
|
+
}
|
|
10272
10908
|
// packages/ai-views/src/mount-mask.ts
|
|
10273
10909
|
/**
|
|
10274
10910
|
* MaskStudio: drop an image, press a thing
|
|
@@ -10278,7 +10914,11 @@ Component that was made reactive: `, type);
|
|
|
10278
10914
|
* export the mask, a matte or the cutout. With a segment everything model
|
|
10279
10915
|
* (FastSAM) one press finds every object; each lands in the found list and
|
|
10280
10916
|
* a press adds it to the mask. Models are functions the page passes, so
|
|
10281
|
-
* stubs run the studio with no weights.
|
|
10917
|
+
* stubs run the studio with no weights. Three views (composite, mask,
|
|
10918
|
+
* found objects) paint over the canvas; the pointer previews the click cut
|
|
10919
|
+
* or lights the found object under it; two fingers or ctrl and the wheel
|
|
10920
|
+
* zoom; a page that loads models on demand hears `onWant` when a tool needs
|
|
10921
|
+
* one.
|
|
10282
10922
|
*/
|
|
10283
10923
|
const ZOOMS = [
|
|
10284
10924
|
.5,
|
|
@@ -10289,6 +10929,25 @@ Component that was made reactive: `, type);
|
|
|
10289
10929
|
3,
|
|
10290
10930
|
4
|
|
10291
10931
|
];
|
|
10932
|
+
const clampZoom = (z) => Math.max(.25, Math.min(6, z));
|
|
10933
|
+
/** Paint `rgb` at `alpha` (0 to 255) where the mask keeps, leaving the other pixels as they are. */
|
|
10934
|
+
function tintInto(rgba, mask, rgb, alpha) {
|
|
10935
|
+
for (let i = 0, j = 0; i < mask.length; i++, j += 4) {
|
|
10936
|
+
if (!mask[i]) continue;
|
|
10937
|
+
rgba[j] = rgb[0];
|
|
10938
|
+
rgba[j + 1] = rgb[1];
|
|
10939
|
+
rgba[j + 2] = rgb[2];
|
|
10940
|
+
rgba[j + 3] = alpha;
|
|
10941
|
+
}
|
|
10942
|
+
}
|
|
10943
|
+
/** ImageData to a png Blob. */
|
|
10944
|
+
function pngOf(img) {
|
|
10945
|
+
const c = document.createElement("canvas");
|
|
10946
|
+
c.width = img.width;
|
|
10947
|
+
c.height = img.height;
|
|
10948
|
+
c.getContext("2d")?.putImageData(img, 0, 0);
|
|
10949
|
+
return new Promise((ok) => c.toBlob((b) => ok(b), "image/png"));
|
|
10950
|
+
}
|
|
10292
10951
|
/** Pixels of a drawable, for a model. */
|
|
10293
10952
|
function pixelsOf(src) {
|
|
10294
10953
|
const c = document.createElement("canvas");
|
|
@@ -10322,17 +10981,22 @@ Component that was made reactive: `, type);
|
|
|
10322
10981
|
function mountMaskStudio(host, o = {}) {
|
|
10323
10982
|
let models = o.models ?? {};
|
|
10324
10983
|
const l = listeners();
|
|
10325
|
-
host.innerHTML = `<div class="hb-lay-empty" data-empty><span class="hb-lay-empty-name">${esc(o.title ?? "drop an image")}</span><p class="hb-lay-empty-note">${esc(o.note ?? "press a thing to cut it out. the picture stays on this machine.")}</p><div class="hb-lay-empty-acts"><button type="button" class="hb-btn hb-btn-go" data-pick>open an image</button>${o.sampleLabel ? `<button type="button" class="hb-btn" data-sample>${esc(o.sampleLabel)}</button>` : ""}</div></div><div class="hb-mask is-fill" data-studio hidden><div class="hb-mask-well"><div class="hb-mask-frame"><canvas class="hb-mask-canvas" tabindex="0" role="img" aria-label="image and mask"></canvas><p class="hb-mask-hint" aria-live="polite"></p></div></div></div><input type="file" accept="image/*" hidden>`;
|
|
10984
|
+
host.innerHTML = `<div class="hb-lay-empty" data-empty><span class="hb-lay-empty-name">${esc(o.title ?? "drop an image")}</span><p class="hb-lay-empty-note">${esc(o.note ?? "press a thing to cut it out. the picture stays on this machine.")}</p><div class="hb-lay-empty-acts"><button type="button" class="hb-btn hb-btn-go" data-pick>open an image</button>${o.sampleLabel ? `<button type="button" class="hb-btn" data-sample>${esc(o.sampleLabel)}</button>` : ""}</div></div><div class="hb-mask is-fill" data-studio hidden><div class="hb-mask-well"><div class="hb-mask-frame"><canvas class="hb-mask-canvas" tabindex="0" role="img" aria-label="image and mask"></canvas><canvas class="hb-pc-img" data-over aria-hidden="true"></canvas><p class="hb-mask-hint" aria-live="polite"></p></div></div></div><input type="file" accept="image/*" hidden>`;
|
|
10326
10985
|
const empty = host.querySelector("[data-empty]");
|
|
10327
10986
|
const studio = host.querySelector("[data-studio]");
|
|
10328
10987
|
const well = host.querySelector(".hb-mask-well");
|
|
10329
10988
|
host.querySelector(".hb-mask-frame");
|
|
10330
|
-
const canvas = host.querySelector("canvas");
|
|
10989
|
+
const canvas = host.querySelector(".hb-mask-canvas");
|
|
10990
|
+
const over = host.querySelector("[data-over]");
|
|
10331
10991
|
const hint = host.querySelector(".hb-mask-hint");
|
|
10332
10992
|
const input = host.querySelector("input[type=file]");
|
|
10333
10993
|
const subs = /* @__PURE__ */ new Set();
|
|
10334
10994
|
let tool = models.segment ? "point" : "wand";
|
|
10335
10995
|
let zoom = 1;
|
|
10996
|
+
let view = "composite";
|
|
10997
|
+
let hover = -1;
|
|
10998
|
+
let preview = null;
|
|
10999
|
+
let wantAll = null;
|
|
10336
11000
|
let busy = "";
|
|
10337
11001
|
let error = "";
|
|
10338
11002
|
let pixels = null;
|
|
@@ -10351,6 +11015,9 @@ Component that was made reactive: `, type);
|
|
|
10351
11015
|
coverage: ed?.coverage ?? 0,
|
|
10352
11016
|
zoom,
|
|
10353
11017
|
busy,
|
|
11018
|
+
contiguous: ed?.contiguous ?? true,
|
|
11019
|
+
view,
|
|
11020
|
+
hover,
|
|
10354
11021
|
found,
|
|
10355
11022
|
saved: saved.map(({ bytes: _b, ...rest }) => rest),
|
|
10356
11023
|
width: ed?.width ?? 0,
|
|
@@ -10359,10 +11026,61 @@ Component that was made reactive: `, type);
|
|
|
10359
11026
|
});
|
|
10360
11027
|
const emit = () => {
|
|
10361
11028
|
const s = state();
|
|
10362
|
-
hint.textContent = s.busy || s.error || (tool === "point" ? "press a thing to cut it out. x takes it away instead." :
|
|
11029
|
+
hint.textContent = s.busy || s.error || (tool === "point" ? "press a thing to cut it out. x takes it away instead." : gt.find((t) => t.id === tool)?.hint ?? "");
|
|
10363
11030
|
for (const fn of subs) fn(s);
|
|
11031
|
+
paint();
|
|
11032
|
+
};
|
|
11033
|
+
let painted = "";
|
|
11034
|
+
let frameReq = 0;
|
|
11035
|
+
const paint = () => {
|
|
11036
|
+
if (frameReq) return;
|
|
11037
|
+
frameReq = typeof requestAnimationFrame === "function" ? requestAnimationFrame(drawOver) : (drawOver(), 0);
|
|
11038
|
+
};
|
|
11039
|
+
const drawOver = () => {
|
|
11040
|
+
frameReq = 0;
|
|
11041
|
+
const w = ed?.width ?? 0;
|
|
11042
|
+
const h = ed?.height ?? 0;
|
|
11043
|
+
const g = over.getContext("2d");
|
|
11044
|
+
if (!g || !w || !h || !pixels) return;
|
|
11045
|
+
if (over.width !== w || over.height !== h) {
|
|
11046
|
+
over.width = w;
|
|
11047
|
+
over.height = h;
|
|
11048
|
+
}
|
|
11049
|
+
const key = `${view}:${hover}:${preview ? "p" : ""}:${view === "mask" ? editor.state.coverage + ":" + (ed?.canUndo ? 1 : 0) : ""}:${found.map((f) => f.hidden ? 0 : 1).join("")}`;
|
|
11050
|
+
if (view === "composite" && hover < 0 && !preview) {
|
|
11051
|
+
if (painted !== "clear") g.clearRect(0, 0, w, h);
|
|
11052
|
+
painted = "clear";
|
|
11053
|
+
return;
|
|
11054
|
+
}
|
|
11055
|
+
if (key === painted && view !== "mask") return;
|
|
11056
|
+
painted = key;
|
|
11057
|
+
if (view === "mask") {
|
|
11058
|
+
g.putImageData(new ImageData(er(editor.mask(), "matte"), w, h), 0, 0);
|
|
11059
|
+
return;
|
|
11060
|
+
}
|
|
11061
|
+
const rgba = new Uint8ClampedArray(w * h * 4);
|
|
11062
|
+
if (view === "instances") found.forEach((f, i) => !f.hidden && i !== hover && tintInto(rgba, f.mask, nr(f.colour), 150));
|
|
11063
|
+
const hot = hover >= 0 ? found[hover] : void 0;
|
|
11064
|
+
if (hot) tintInto(rgba, hot.mask, nr(hot.colour), 220);
|
|
11065
|
+
else if (preview) tintInto(rgba, preview, [
|
|
11066
|
+
254,
|
|
11067
|
+
3,
|
|
11068
|
+
134
|
|
11069
|
+
], 110);
|
|
11070
|
+
g.putImageData(new ImageData(rgba, w, h), 0, 0);
|
|
11071
|
+
if (view === "instances") {
|
|
11072
|
+
g.lineWidth = Math.max(1, w / 400);
|
|
11073
|
+
g.font = `${Math.max(10, Math.round(w / 60))}px monospace`;
|
|
11074
|
+
for (const f of found) {
|
|
11075
|
+
if (f.hidden || !f.box) continue;
|
|
11076
|
+
g.strokeStyle = f.colour;
|
|
11077
|
+
g.fillStyle = f.colour;
|
|
11078
|
+
g.strokeRect(f.box.x, f.box.y, f.box.w, f.box.h);
|
|
11079
|
+
g.fillText(`${f.label} ${Math.round(f.score * 100)}`, f.box.x + 3, Math.max(12, f.box.y - 4));
|
|
11080
|
+
}
|
|
11081
|
+
}
|
|
10364
11082
|
};
|
|
10365
|
-
const editor =
|
|
11083
|
+
const editor = ns(canvas, {
|
|
10366
11084
|
tool: tool === "point" ? "wand" : tool,
|
|
10367
11085
|
onError: (e) => (error = `the image did not load: ${e.message}`, emit())
|
|
10368
11086
|
});
|
|
@@ -10374,6 +11092,7 @@ Component that was made reactive: `, type);
|
|
|
10374
11092
|
studio.style.setProperty("--hb-mask-w", `${Math.round(fitW * zoom)}px`);
|
|
10375
11093
|
studio.classList.toggle("is-zoomed", zoom > 1);
|
|
10376
11094
|
};
|
|
11095
|
+
const zoomStep = (dir) => (dir > 0 ? ZOOMS.find((z) => z > zoom + .001) : [...ZOOMS].reverse().find((z) => z < zoom - .001)) ?? zoom;
|
|
10377
11096
|
const ro = typeof ResizeObserver === "function" ? new ResizeObserver(() => applyZoom()) : null;
|
|
10378
11097
|
ro?.observe(well);
|
|
10379
11098
|
l.add(() => ro?.disconnect());
|
|
@@ -10398,17 +11117,130 @@ Component that was made reactive: `, type);
|
|
|
10398
11117
|
emit();
|
|
10399
11118
|
}
|
|
10400
11119
|
};
|
|
11120
|
+
const at = (pe) => {
|
|
11121
|
+
const r = canvas.getBoundingClientRect();
|
|
11122
|
+
const w = ed?.width ?? 0;
|
|
11123
|
+
const h = ed?.height ?? 0;
|
|
11124
|
+
return {
|
|
11125
|
+
x: Math.max(0, Math.min(w - 1, Math.round((pe.clientX - r.left) / r.width * w))),
|
|
11126
|
+
y: Math.max(0, Math.min(h - 1, Math.round((pe.clientY - r.top) / r.height * h)))
|
|
11127
|
+
};
|
|
11128
|
+
};
|
|
11129
|
+
const foundAt = (x, y) => found.findIndex((f) => !f.hidden && f.mask[y * (ed?.width ?? 0) + x]);
|
|
10401
11130
|
const onPoint = (e) => {
|
|
10402
11131
|
if (tool !== "point") return;
|
|
10403
11132
|
e.stopImmediatePropagation();
|
|
10404
11133
|
e.preventDefault();
|
|
10405
11134
|
const pe = e;
|
|
10406
|
-
const r = canvas.getBoundingClientRect();
|
|
10407
11135
|
if (!ed?.ready) return;
|
|
10408
|
-
const x =
|
|
10409
|
-
const
|
|
11136
|
+
const { x, y } = at(pe);
|
|
11137
|
+
const i = foundAt(x, y);
|
|
11138
|
+
if (i >= 0) return studioApi.toggleFound(i);
|
|
11139
|
+
if (!models.segment) return o.onWant?.("segment");
|
|
11140
|
+
preview = null;
|
|
10410
11141
|
cut(x, y, ed.mode === "erase" !== pe.shiftKey);
|
|
10411
11142
|
};
|
|
11143
|
+
let asking = false;
|
|
11144
|
+
let next = null;
|
|
11145
|
+
const ask = async (p) => {
|
|
11146
|
+
if (!pixels || !models.segment) return;
|
|
11147
|
+
asking = true;
|
|
11148
|
+
try {
|
|
11149
|
+
const m = await models.segment(pixels, p);
|
|
11150
|
+
if (tool === "point" && next !== null) preview = m;
|
|
11151
|
+
} catch {
|
|
11152
|
+
preview = null;
|
|
11153
|
+
} finally {
|
|
11154
|
+
asking = false;
|
|
11155
|
+
}
|
|
11156
|
+
paint();
|
|
11157
|
+
const n = next;
|
|
11158
|
+
if (n && (n.x !== p.x || n.y !== p.y)) ask(n);
|
|
11159
|
+
};
|
|
11160
|
+
const onHover = (e) => {
|
|
11161
|
+
const pe = e;
|
|
11162
|
+
if (!ed?.ready || pe.buttons || pe.pointerType === "touch") return;
|
|
11163
|
+
const p = at(pe);
|
|
11164
|
+
const i = found.length && (tool === "point" || view === "instances") ? foundAt(p.x, p.y) : -1;
|
|
11165
|
+
if (i !== hover) {
|
|
11166
|
+
hover = i;
|
|
11167
|
+
emit();
|
|
11168
|
+
}
|
|
11169
|
+
if (i >= 0 || tool !== "point" || !models.segment) {
|
|
11170
|
+
next = null;
|
|
11171
|
+
if (preview) preview = null, paint();
|
|
11172
|
+
return;
|
|
11173
|
+
}
|
|
11174
|
+
next = p;
|
|
11175
|
+
if (!asking) ask(p);
|
|
11176
|
+
};
|
|
11177
|
+
const offHover = () => {
|
|
11178
|
+
next = null;
|
|
11179
|
+
preview = null;
|
|
11180
|
+
if (hover >= 0) hover = -1, emit();
|
|
11181
|
+
else paint();
|
|
11182
|
+
};
|
|
11183
|
+
canvas.addEventListener("pointermove", onHover);
|
|
11184
|
+
canvas.addEventListener("pointerleave", offHover);
|
|
11185
|
+
l.add(() => (canvas.removeEventListener("pointermove", onHover), canvas.removeEventListener("pointerleave", offHover)));
|
|
11186
|
+
const touches = /* @__PURE__ */ new Map();
|
|
11187
|
+
let pinch = null;
|
|
11188
|
+
const spread = () => {
|
|
11189
|
+
const [a, b] = [...touches.values()];
|
|
11190
|
+
return a && b ? Math.hypot(a.x - b.x, a.y - b.y) : 0;
|
|
11191
|
+
};
|
|
11192
|
+
l.on(well, "pointerdown", (e) => {
|
|
11193
|
+
const pe = e;
|
|
11194
|
+
if (pe.pointerType !== "touch") return;
|
|
11195
|
+
touches.set(pe.pointerId, {
|
|
11196
|
+
x: pe.clientX,
|
|
11197
|
+
y: pe.clientY
|
|
11198
|
+
});
|
|
11199
|
+
if (touches.size === 2) {
|
|
11200
|
+
editor.cancel();
|
|
11201
|
+
pinch = {
|
|
11202
|
+
d: spread() || 1,
|
|
11203
|
+
z: zoom
|
|
11204
|
+
};
|
|
11205
|
+
}
|
|
11206
|
+
});
|
|
11207
|
+
l.on(well, "pointermove", (e) => {
|
|
11208
|
+
const pe = e;
|
|
11209
|
+
if (!touches.has(pe.pointerId)) return;
|
|
11210
|
+
touches.set(pe.pointerId, {
|
|
11211
|
+
x: pe.clientX,
|
|
11212
|
+
y: pe.clientY
|
|
11213
|
+
});
|
|
11214
|
+
if (pinch && touches.size === 2) studioApi.zoomTo(pinch.z * (spread() / pinch.d));
|
|
11215
|
+
});
|
|
11216
|
+
const lift = (e) => {
|
|
11217
|
+
touches.delete(e.pointerId);
|
|
11218
|
+
if (touches.size < 2) pinch = null;
|
|
11219
|
+
};
|
|
11220
|
+
l.on(well, "pointerup", lift);
|
|
11221
|
+
l.on(well, "pointercancel", lift);
|
|
11222
|
+
l.on(well, "wheel", (e) => {
|
|
11223
|
+
const we = e;
|
|
11224
|
+
if (!we.ctrlKey || !ed?.ready) return;
|
|
11225
|
+
we.preventDefault();
|
|
11226
|
+
studioApi.zoomTo(zoom * Math.exp(-we.deltaY / 200));
|
|
11227
|
+
});
|
|
11228
|
+
l.on(document, "keydown", (e) => {
|
|
11229
|
+
const ke = e;
|
|
11230
|
+
if (ke.defaultPrevented || ke.target.closest?.("input,textarea,select,[contenteditable]")) return;
|
|
11231
|
+
const k = ke.key.toLowerCase();
|
|
11232
|
+
const cmd = ke.ctrlKey || ke.metaKey;
|
|
11233
|
+
if (cmd && k === "o") return ke.preventDefault(), input.click();
|
|
11234
|
+
if (!ed?.ready) return;
|
|
11235
|
+
if (cmd && (k === "z" || k === "y")) return ke.preventDefault(), void (k === "y" || ke.shiftKey ? editor.redo() : editor.undo());
|
|
11236
|
+
if (cmd && k === "s") return ke.preventDefault(), void studioApi.exportAs(ke.shiftKey ? "cutout" : "matte").then((b) => b && download(`${o.name ?? "mask"}-${ke.shiftKey ? "cutout" : "matte"}.png`, b));
|
|
11237
|
+
if (cmd && k === "i") return ke.preventDefault(), editor.invert();
|
|
11238
|
+
if (cmd) return;
|
|
11239
|
+
if (k === "delete") return ke.preventDefault(), editor.clear();
|
|
11240
|
+
if (k === "+" || k === "=") return studioApi.zoom(1);
|
|
11241
|
+
if (k === "-") return studioApi.zoom(-1);
|
|
11242
|
+
if (k === "0") return studioApi.zoom(0);
|
|
11243
|
+
});
|
|
10412
11244
|
canvas.addEventListener("pointerdown", onPoint, true);
|
|
10413
11245
|
l.add(() => canvas.removeEventListener("pointerdown", onPoint, true));
|
|
10414
11246
|
const take = (f) => {
|
|
@@ -10435,6 +11267,8 @@ Component that was made reactive: `, type);
|
|
|
10435
11267
|
error = "";
|
|
10436
11268
|
found = [];
|
|
10437
11269
|
saved = [];
|
|
11270
|
+
hover = -1;
|
|
11271
|
+
preview = null;
|
|
10438
11272
|
let drawable = null;
|
|
10439
11273
|
if (typeof src === "string") {
|
|
10440
11274
|
const img = new Image();
|
|
@@ -10454,8 +11288,12 @@ Component that was made reactive: `, type);
|
|
|
10454
11288
|
canvas.focus({ preventScroll: true });
|
|
10455
11289
|
},
|
|
10456
11290
|
setTool(t) {
|
|
10457
|
-
if (t === "point" && !models.segment)
|
|
11291
|
+
if (t === "point" && !models.segment) {
|
|
11292
|
+
if (!o.onWant) return;
|
|
11293
|
+
o.onWant("segment");
|
|
11294
|
+
}
|
|
10458
11295
|
tool = t;
|
|
11296
|
+
preview = null;
|
|
10459
11297
|
if (t !== "point") editor.setTool(t);
|
|
10460
11298
|
canvas.dataset.tool = t;
|
|
10461
11299
|
emit();
|
|
@@ -10493,25 +11331,83 @@ Component that was made reactive: `, type);
|
|
|
10493
11331
|
},
|
|
10494
11332
|
mask: (kind = "alpha") => ed?.ready ? editor.toImageData(kind) : null,
|
|
10495
11333
|
zoom(dir) {
|
|
10496
|
-
|
|
10497
|
-
else {
|
|
10498
|
-
const i = ZOOMS.indexOf(zoom);
|
|
10499
|
-
zoom = ZOOMS[Math.max(0, Math.min(ZOOMS.length - 1, i + dir))];
|
|
10500
|
-
}
|
|
11334
|
+
zoom = dir === 0 ? 1 : zoomStep(dir);
|
|
10501
11335
|
applyZoom();
|
|
10502
11336
|
emit();
|
|
10503
11337
|
},
|
|
10504
|
-
|
|
10505
|
-
|
|
11338
|
+
zoomTo(z) {
|
|
11339
|
+
zoom = clampZoom(z);
|
|
11340
|
+
applyZoom();
|
|
11341
|
+
emit();
|
|
11342
|
+
},
|
|
11343
|
+
setView(v) {
|
|
11344
|
+
view = v;
|
|
11345
|
+
emit();
|
|
11346
|
+
},
|
|
11347
|
+
setContiguous: (on) => editor.setContiguous(on),
|
|
11348
|
+
setMask(m) {
|
|
11349
|
+
if (ed?.ready && m.length === ed.width * ed.height) editor.setMask(m);
|
|
11350
|
+
},
|
|
11351
|
+
addFound(list) {
|
|
11352
|
+
const n = found.length;
|
|
11353
|
+
found = [...found, ...list.filter((f) => f.mask.length === (ed?.width ?? 0) * (ed?.height ?? 0)).map((f, i) => ({
|
|
11354
|
+
...f,
|
|
11355
|
+
on: false,
|
|
11356
|
+
hidden: false,
|
|
11357
|
+
colour: ht[(n + i) % ht.length]
|
|
11358
|
+
}))];
|
|
11359
|
+
if (found.length > n && view === "composite") view = "instances";
|
|
11360
|
+
emit();
|
|
11361
|
+
},
|
|
11362
|
+
showFound(i, on) {
|
|
11363
|
+
found = found.map((x, k) => k === i ? {
|
|
11364
|
+
...x,
|
|
11365
|
+
hidden: !on
|
|
11366
|
+
} : x);
|
|
11367
|
+
emit();
|
|
11368
|
+
},
|
|
11369
|
+
removeFound(i) {
|
|
11370
|
+
found = found.filter((_, k) => k !== i);
|
|
11371
|
+
hover = -1;
|
|
11372
|
+
emit();
|
|
11373
|
+
},
|
|
11374
|
+
mergeFound() {
|
|
11375
|
+
if (!ed?.ready || !found.length) return;
|
|
11376
|
+
const cur = editor.mask();
|
|
11377
|
+
for (const f of found) if (!f.hidden) {
|
|
11378
|
+
for (let p = 0; p < cur.length; p++) if (f.mask[p]) cur[p] = 255;
|
|
11379
|
+
}
|
|
11380
|
+
found = found.map((x) => x.hidden ? x : {
|
|
11381
|
+
...x,
|
|
11382
|
+
on: true
|
|
11383
|
+
});
|
|
11384
|
+
editor.setMask(cur);
|
|
11385
|
+
},
|
|
11386
|
+
clearFound() {
|
|
11387
|
+
found = [];
|
|
11388
|
+
hover = -1;
|
|
11389
|
+
if (view === "instances") view = "composite";
|
|
11390
|
+
emit();
|
|
11391
|
+
},
|
|
11392
|
+
pixels: () => pixels,
|
|
11393
|
+
async everything(eo) {
|
|
11394
|
+
if (!pixels) return;
|
|
11395
|
+
if (!models.everything) {
|
|
11396
|
+
wantAll = eo ?? {};
|
|
11397
|
+
return o.onWant?.("everything");
|
|
11398
|
+
}
|
|
11399
|
+
wantAll = null;
|
|
10506
11400
|
busy = "finding every object";
|
|
10507
11401
|
error = "";
|
|
10508
11402
|
emit();
|
|
10509
11403
|
try {
|
|
10510
|
-
found = (await models.everything(pixels)).map((f, i) => ({
|
|
11404
|
+
found = (await models.everything(pixels, eo)).map((f, i) => ({
|
|
10511
11405
|
...f,
|
|
10512
11406
|
on: false,
|
|
10513
|
-
|
|
11407
|
+
hidden: false,
|
|
11408
|
+
colour: ht[i % ht.length]
|
|
10514
11409
|
}));
|
|
11410
|
+
if (found.length) view = "instances";
|
|
10515
11411
|
} catch (e) {
|
|
10516
11412
|
error = `segment everything failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
10517
11413
|
} finally {
|
|
@@ -10533,6 +11429,7 @@ Component that was made reactive: `, type);
|
|
|
10533
11429
|
},
|
|
10534
11430
|
async exportAs(kind) {
|
|
10535
11431
|
if (!ed?.ready) return null;
|
|
11432
|
+
if (kind === "inverse") return pngOf(new ImageData(er(Jn(editor.mask()), "matte"), ed.width, ed.height));
|
|
10536
11433
|
return editor.toBlob(kind);
|
|
10537
11434
|
},
|
|
10538
11435
|
get hasEverything() {
|
|
@@ -10541,6 +11438,9 @@ Component that was made reactive: `, type);
|
|
|
10541
11438
|
get hasSegment() {
|
|
10542
11439
|
return !!models.segment;
|
|
10543
11440
|
},
|
|
11441
|
+
get canWant() {
|
|
11442
|
+
return !!o.onWant;
|
|
11443
|
+
},
|
|
10544
11444
|
state,
|
|
10545
11445
|
subscribe(fn) {
|
|
10546
11446
|
subs.add(fn);
|
|
@@ -10554,8 +11454,9 @@ Component that was made reactive: `, type);
|
|
|
10554
11454
|
tool = "point";
|
|
10555
11455
|
canvas.dataset.tool = "point";
|
|
10556
11456
|
}
|
|
10557
|
-
if (tool === "point" && !m.segment) studioApi.setTool("wand");
|
|
11457
|
+
if (tool === "point" && !m.segment && !o.onWant) studioApi.setTool("wand");
|
|
10558
11458
|
emit();
|
|
11459
|
+
if (wantAll && m.everything) studioApi.everything(wantAll);
|
|
10559
11460
|
},
|
|
10560
11461
|
pick: () => input.click(),
|
|
10561
11462
|
dispose() {
|
|
@@ -10572,17 +11473,17 @@ Component that was made reactive: `, type);
|
|
|
10572
11473
|
function mountMaskTools(host, studio) {
|
|
10573
11474
|
const l = listeners();
|
|
10574
11475
|
const draw = (s) => {
|
|
10575
|
-
host.innerHTML = [...studio.hasSegment ? [{
|
|
11476
|
+
host.innerHTML = [...studio.hasSegment || studio.canWant ? [{
|
|
10576
11477
|
id: "point",
|
|
10577
11478
|
label: "cut out a thing",
|
|
10578
11479
|
key: "a",
|
|
10579
11480
|
icon: "crosshairs"
|
|
10580
|
-
}] : [], ...
|
|
11481
|
+
}] : [], ...gt.map((t) => ({
|
|
10581
11482
|
id: t.id,
|
|
10582
11483
|
label: t.label,
|
|
10583
11484
|
key: t.key,
|
|
10584
11485
|
icon: t.icon
|
|
10585
|
-
}))].map((t) => `<button type="button" class="hb-iconbtn" data-tool="${t.id}" aria-label="${esc(t.label)} (${t.key})" title="${esc(t.label)} (${t.key})" aria-pressed="${s.tool === t.id}" aria-keyshortcuts="${t.key}">${
|
|
11486
|
+
}))].map((t) => `<button type="button" class="hb-iconbtn" data-tool="${t.id}" aria-label="${esc(t.label)} (${t.key})" title="${esc(t.label)} (${t.key})" aria-pressed="${s.tool === t.id}" aria-keyshortcuts="${t.key}">${rn(t.icon, { size: 18 })}</button>`).join("");
|
|
10586
11487
|
};
|
|
10587
11488
|
l.on(host, "click", (e) => {
|
|
10588
11489
|
const t = e.target.closest("[data-tool]");
|
|
@@ -10590,12 +11491,7 @@ Component that was made reactive: `, type);
|
|
|
10590
11491
|
});
|
|
10591
11492
|
l.on(document, "keydown", (e) => {
|
|
10592
11493
|
const ke = e;
|
|
10593
|
-
if (
|
|
10594
|
-
if (ke.key === "+" || ke.key === "=") return studio.zoom(1);
|
|
10595
|
-
if (ke.key === "-") return studio.zoom(-1);
|
|
10596
|
-
if (ke.key === "0") return studio.zoom(0);
|
|
10597
|
-
}
|
|
10598
|
-
if (ke.key === "a" && !ke.ctrlKey && !ke.metaKey && studio.hasSegment && !ke.target.closest?.("input,textarea,[contenteditable]")) studio.setTool("point");
|
|
11494
|
+
if (ke.key === "a" && !ke.ctrlKey && !ke.metaKey && (studio.hasSegment || studio.canWant) && !ke.target.closest?.("input,textarea,[contenteditable]")) studio.setTool("point");
|
|
10599
11495
|
});
|
|
10600
11496
|
l.add(studio.subscribe(draw));
|
|
10601
11497
|
return { dispose: () => l.off() };
|
|
@@ -10605,11 +11501,17 @@ Component that was made reactive: `, type);
|
|
|
10605
11501
|
const l = listeners();
|
|
10606
11502
|
let last = "";
|
|
10607
11503
|
const draw = (s) => {
|
|
10608
|
-
const html = s.ready ? `${s.canUndo ? `<button type="button" class="hb-iconbtn" data-v="undo" aria-label="undo" title="undo (ctrl z)">${ICON.undo}</button>` : ""}${s.canRedo ? `<button type="button" class="hb-iconbtn" data-v="redo" aria-label="redo" title="redo (ctrl shift z)">${ICON.redo}</button>` : ""}` + (s.zoom !== 1 ? `<button type="button" class="hb-iconbtn" data-v="out" aria-label="zoom out" title="zoom out (-)">${ICON.zoomOut}</button><button type="button" class="hb-iconbtn" data-v="fit" aria-label="fit, now ${Math.round(s.zoom * 100)} percent" title="fit (0)">${ICON.fit}</button>` : "") + `<button type="button" class="hb-iconbtn" data-v="in" aria-label="zoom in" title="zoom in (+)">${ICON.zoomIn}</button>`
|
|
11504
|
+
const html = s.ready ? `${s.canUndo ? `<button type="button" class="hb-iconbtn" data-v="undo" aria-label="undo" title="undo (ctrl z)">${ICON.undo}</button>` : ""}${s.canRedo ? `<button type="button" class="hb-iconbtn" data-v="redo" aria-label="redo" title="redo (ctrl shift z)">${ICON.redo}</button>` : ""}` + (s.zoom !== 1 ? `<button type="button" class="hb-iconbtn" data-v="out" aria-label="zoom out" title="zoom out (-)">${ICON.zoomOut}</button><button type="button" class="hb-iconbtn" data-v="fit" aria-label="fit, now ${Math.round(s.zoom * 100)} percent" title="fit (0)">${ICON.fit}</button>` : "") + `<button type="button" class="hb-iconbtn" data-v="in" aria-label="zoom in" title="zoom in (+)">${ICON.zoomIn}</button>` + (s.coverage > 0 || s.found.length ? `<div class="hb-seg is-toggle" role="group" aria-label="view">${[
|
|
11505
|
+
"composite",
|
|
11506
|
+
"mask",
|
|
11507
|
+
"instances"
|
|
11508
|
+
].filter((v) => v !== "instances" || s.found.length).map((v) => `<button type="button" data-view="${v}" class="${s.view === v ? "is-on" : ""}" aria-pressed="${s.view === v}">${v === "instances" ? "objects" : v === "composite" ? "picture" : "mask"}</button>`).join("")}</div>` : "") : "";
|
|
10609
11509
|
if (html !== last) host.innerHTML = last = html;
|
|
10610
11510
|
host.hidden = !html;
|
|
10611
11511
|
};
|
|
10612
11512
|
l.on(host, "click", (e) => {
|
|
11513
|
+
const view = e.target.closest("[data-view]")?.dataset.view;
|
|
11514
|
+
if (view) return studio.setView(view);
|
|
10613
11515
|
const v = e.target.closest("[data-v]")?.dataset.v;
|
|
10614
11516
|
if (v === "undo") studio.undo();
|
|
10615
11517
|
else if (v === "redo") studio.redo();
|
|
@@ -10627,11 +11529,11 @@ Component that was made reactive: `, type);
|
|
|
10627
11529
|
const draw = (s) => {
|
|
10628
11530
|
let html = "";
|
|
10629
11531
|
if (part === "found") {
|
|
10630
|
-
html = s.found.length ? `<div class="hb-inst"><ul class="hb-inst-list">${s.found.map((f, i) => `<li class="hb-inst-row${f.on ? " is-on" : ""}" style="--hb-inst-c:${f.colour}"><button type="button" class="hb-inst-pick" data-found="${i}" aria-pressed="${f.on}"><span class="hb-inst-sw"></span><span class="hb-inst-name">${esc(f.label)}</span><span class="hb-inst-score">${Math.round(f.score * 100)}%</span></button></li>`).join("")}</ul></div>` : `<p class="hb-lay-empty-note">${s.ready ? studio.hasEverything ? "find every object at once, or press a thing on the picture." : "press a thing to cut it out." : "nothing yet. open an image or try the sample."}</p>` + (s.ready && studio.hasEverything && !s.busy ? `<button type="button" class="hb-btn hb-btn-go" data-all>find every object</button>` : "");
|
|
11532
|
+
html = s.found.length ? `<div class="hb-inst"><p class="hb-inst-empty">${s.found.length} found, ${s.found.filter((f) => f.on).length} in the mask</p><div class="hb-toolbar hb-inst-foot"><button type="button" class="hb-btn hb-btn-go" data-op="merge">merge all</button><button type="button" class="hb-btn" data-op="unfind">clear all</button></div><ul class="hb-inst-list">${s.found.map((f, i) => `<li class="hb-inst-row${f.on || s.hover === i ? " is-on" : ""}${f.hidden ? " is-hidden" : ""}" style="--hb-inst-c:${f.colour}"><button type="button" class="hb-inst-pick" data-found="${i}" aria-pressed="${f.on}"><span class="hb-inst-sw"></span><span class="hb-inst-name">${esc(f.label)}</span><span class="hb-inst-score">${Math.min(100, Math.round(f.score * 100))}%</span></button><button type="button" class="hb-inst-act" data-show="${i}" aria-pressed="${!f.hidden}" aria-label="${f.hidden ? "show" : "hide"} ${esc(f.label)}" title="${f.hidden ? "show" : "hide"}">${rn("eye", { size: 14 })}</button><button type="button" class="hb-inst-act" data-drop="${i}" aria-label="delete ${esc(f.label)}" title="delete">${ICON.trash}</button></li>`).join("")}</ul></div>` : `<p class="hb-lay-empty-note">${s.ready ? studio.hasEverything || studio.canWant ? "find every object at once, or press a thing on the picture." : "press a thing to cut it out." : "nothing yet. open an image or try the sample."}</p>` + (s.ready && (studio.hasEverything || studio.canWant) && !s.busy ? `<button type="button" class="hb-btn hb-btn-go" data-all>find every object</button>` : "");
|
|
10631
11533
|
html += s.ready ? `<div class="hb-kv"><span class="hb-label">mask keeps</span><span class="hb-readout">${Math.round(s.coverage * 100)}%</span></div>` : "";
|
|
10632
|
-
} else if (part === "mask") html = `<div class="hb-seg is-toggle" role="group" aria-label="mode">${["add", "erase"].map((m) => `<button type="button" data-mode="${m}" class="${s.mode === m ? "is-on" : ""}" aria-pressed="${s.mode === m}">${m}<span class="hb-mask-key" aria-hidden="true">x</span></button>`).join("")}</div>` + (s.tool === "brush" || s.tool === "eraser" ? `<label class="hb-field"><span class="hb-label">brush, ${s.size} px</span><input class="hb-range" type="range" min="4" max="160" step="2" value="${s.size}" data-size></label>` : "") + (s.tool === "wand" || s.tool === "flood" ? `<label class="hb-field"><span class="hb-label">reach, ${s.tolerance}</span><input class="hb-range" type="range" min="0" max="100" step="1" value="${s.tolerance}" data-tol></label>` : "") + (s.coverage > 0 ? `<div class="hb-toolbar"><button type="button" class="hb-btn" data-op="smooth">smooth</button><button type="button" class="hb-btn" data-op="expand">expand</button><button type="button" class="hb-btn" data-op="shrink">shrink</button><button type="button" class="hb-btn" data-op="invert">invert</button><button type="button" class="hb-btn" data-op="clear">clear</button></div>` : "");
|
|
11534
|
+
} else if (part === "mask") html = `<div class="hb-seg is-toggle" role="group" aria-label="mode">${["add", "erase"].map((m) => `<button type="button" data-mode="${m}" class="${s.mode === m ? "is-on" : ""}" aria-pressed="${s.mode === m}">${m}<span class="hb-mask-key" aria-hidden="true">x</span></button>`).join("")}</div>` + (s.tool === "brush" || s.tool === "eraser" ? `<label class="hb-field"><span class="hb-label">brush, ${s.size} px</span><input class="hb-range" type="range" min="4" max="160" step="2" value="${s.size}" data-size></label>` : "") + (s.tool === "wand" || s.tool === "flood" ? `<label class="hb-field"><span class="hb-label">reach, ${s.tolerance}</span><input class="hb-range" type="range" min="0" max="100" step="1" value="${s.tolerance}" data-tol></label>` : "") + (s.tool === "wand" ? `<label class="hb-check"><input type="checkbox" data-contig${s.contiguous ? " checked" : ""}><span>touching pixels only</span></label>` : "") + (s.coverage > 0 ? `<div class="hb-toolbar"><button type="button" class="hb-btn" data-op="smooth">smooth</button><button type="button" class="hb-btn" data-op="expand">expand</button><button type="button" class="hb-btn" data-op="shrink">shrink</button><button type="button" class="hb-btn" data-op="invert">invert</button><button type="button" class="hb-btn" data-op="clear">clear</button></div>` : "");
|
|
10633
11535
|
else if (part === "saved") html = (s.coverage > 0 ? `<div class="hb-toolbar"><button type="button" class="hb-btn" data-op="save">save this mask</button></div>` : "") + (s.saved.length ? `<div class="hb-inst"><ul class="hb-inst-list">${s.saved.map((m) => `<li class="hb-inst-row"><button type="button" class="hb-inst-pick" data-restore="${m.id}"><img class="hb-inst-sw" src="${m.thumb}" alt=""><span class="hb-inst-name">${esc(m.name)}</span><span class="hb-inst-score">${Math.round(m.coverage * 100)}%</span></button><button type="button" class="hb-inst-act" data-forget="${m.id}" aria-label="forget ${esc(m.name)}" title="forget">${ICON.x}</button></li>`).join("")}</ul></div>` : `<p class="hb-lay-empty-note">no saved masks. save one to come back to it.</p>`);
|
|
10634
|
-
else html = s.coverage > 0 ? `<div class="hb-toolbar" role="group" aria-label="export"><button type="button" class="hb-btn" data-ex="cutout">cutout png</button><button type="button" class="hb-btn" data-ex="alpha">mask png</button><button type="button" class="hb-btn" data-ex="matte">matte png</button></div>` : `<p class="hb-lay-empty-note">exports show once there is a mask.</p>`;
|
|
11536
|
+
else html = s.coverage > 0 ? `<div class="hb-toolbar" role="group" aria-label="export"><button type="button" class="hb-btn" data-ex="cutout">cutout png</button><button type="button" class="hb-btn" data-ex="alpha">mask png</button><button type="button" class="hb-btn" data-ex="matte">matte png</button><button type="button" class="hb-btn" data-ex="inverse">inverse png</button></div>` : `<p class="hb-lay-empty-note">exports show once there is a mask.</p>`;
|
|
10635
11537
|
if (html !== last) host.innerHTML = last = html;
|
|
10636
11538
|
};
|
|
10637
11539
|
l.on(host, "click", (e) => {
|
|
@@ -10640,7 +11542,13 @@ Component that was made reactive: `, type);
|
|
|
10640
11542
|
if (f) return studio.toggleFound(Number(f.dataset.found));
|
|
10641
11543
|
const m = t.closest("[data-mode]");
|
|
10642
11544
|
if (m) return studio.setMode(m.dataset.mode);
|
|
11545
|
+
const show = t.closest("[data-show]");
|
|
11546
|
+
if (show) return studio.showFound(Number(show.dataset.show), show.getAttribute("aria-pressed") !== "true");
|
|
11547
|
+
const drop = t.closest("[data-drop]");
|
|
11548
|
+
if (drop) return studio.removeFound(Number(drop.dataset.drop));
|
|
10643
11549
|
const op = t.closest("[data-op]")?.dataset.op;
|
|
11550
|
+
if (op === "merge") return studio.mergeFound();
|
|
11551
|
+
if (op === "unfind") return studio.clearFound();
|
|
10644
11552
|
if (op === "invert") return studio.invert();
|
|
10645
11553
|
if (op === "clear") return studio.clear();
|
|
10646
11554
|
if (op === "smooth") return studio.smooth();
|
|
@@ -10663,6 +11571,7 @@ Component that was made reactive: `, type);
|
|
|
10663
11571
|
const i = e.target;
|
|
10664
11572
|
if (i.dataset.size !== void 0) studio.setSize(Number(i.value));
|
|
10665
11573
|
if (i.dataset.tol !== void 0) studio.setTolerance(Number(i.value));
|
|
11574
|
+
if (i.dataset.contig !== void 0) studio.setContiguous(i.checked);
|
|
10666
11575
|
});
|
|
10667
11576
|
l.add(studio.subscribe(draw));
|
|
10668
11577
|
return { dispose: () => l.off() };
|
|
@@ -10768,7 +11677,7 @@ Component that was made reactive: `, type);
|
|
|
10768
11677
|
const none = host.querySelector(".hb-camtile-none");
|
|
10769
11678
|
const tag = host.querySelector(".hb-camtile-tag");
|
|
10770
11679
|
const cap = host.querySelector("[data-caption]");
|
|
10771
|
-
const palette = o.palette ??
|
|
11680
|
+
const palette = o.palette ?? ht;
|
|
10772
11681
|
let src = null;
|
|
10773
11682
|
let results = {};
|
|
10774
11683
|
let mirror = !!o.mirror;
|
|
@@ -10953,7 +11862,7 @@ Component that was made reactive: `, type);
|
|
|
10953
11862
|
if (stream) return;
|
|
10954
11863
|
error = "";
|
|
10955
11864
|
try {
|
|
10956
|
-
stream = await
|
|
11865
|
+
stream = await qi({
|
|
10957
11866
|
facingMode: o.facingMode ?? "user",
|
|
10958
11867
|
width: { ideal: 640 },
|
|
10959
11868
|
height: { ideal: 480 }
|
|
@@ -10966,7 +11875,7 @@ Component that was made reactive: `, type);
|
|
|
10966
11875
|
Promise.resolve(o.onFrame(video)).finally(() => working = false);
|
|
10967
11876
|
}, 1e3 / (o.fps ?? 4));
|
|
10968
11877
|
} catch (e) {
|
|
10969
|
-
error =
|
|
11878
|
+
error = Di(e).text;
|
|
10970
11879
|
stream = null;
|
|
10971
11880
|
}
|
|
10972
11881
|
emit();
|
|
@@ -10974,7 +11883,7 @@ Component that was made reactive: `, type);
|
|
|
10974
11883
|
stop() {
|
|
10975
11884
|
if (timer) clearInterval(timer);
|
|
10976
11885
|
timer = null;
|
|
10977
|
-
|
|
11886
|
+
Oi(stream);
|
|
10978
11887
|
stream = null;
|
|
10979
11888
|
video.srcObject = null;
|
|
10980
11889
|
emit();
|
|
@@ -11124,7 +12033,7 @@ Component that was made reactive: `, type);
|
|
|
11124
12033
|
},
|
|
11125
12034
|
setup: hosted((host, p) => mountComposer(host, p.thread, { placeholder: p.placeholder }), (p) => [p.thread])
|
|
11126
12035
|
});
|
|
11127
|
-
/** Vue component for the drop zone that becomes the transcript; emits `sample
|
|
12036
|
+
/** Vue component for the drop zone that becomes the transcript; emits `sample` and `drop` (the handle, whose `pick` opens the file picker). */
|
|
11128
12037
|
const TranscribeDrop = /* @__PURE__ */ defineComponent({
|
|
11129
12038
|
name: "TranscribeDrop",
|
|
11130
12039
|
props: {
|
|
@@ -11139,16 +12048,189 @@ Component that was made reactive: `, type);
|
|
|
11139
12048
|
sampleLabel: {
|
|
11140
12049
|
type: String,
|
|
11141
12050
|
default: ""
|
|
12051
|
+
},
|
|
12052
|
+
title: {
|
|
12053
|
+
type: String,
|
|
12054
|
+
default: ""
|
|
12055
|
+
},
|
|
12056
|
+
note: {
|
|
12057
|
+
type: String,
|
|
12058
|
+
default: ""
|
|
12059
|
+
},
|
|
12060
|
+
folders: {
|
|
12061
|
+
type: Boolean,
|
|
12062
|
+
default: false
|
|
12063
|
+
},
|
|
12064
|
+
showDropped: {
|
|
12065
|
+
type: Boolean,
|
|
12066
|
+
default: false
|
|
12067
|
+
}
|
|
12068
|
+
},
|
|
12069
|
+
emits: ["sample", "drop"],
|
|
12070
|
+
setup: hosted((host, p, emit) => {
|
|
12071
|
+
const d = mountTranscribeDrop(host, p.queue, {
|
|
12072
|
+
accept: p.accept,
|
|
12073
|
+
folders: p.folders,
|
|
12074
|
+
showDropped: p.showDropped,
|
|
12075
|
+
...p.title ? { title: p.title } : {},
|
|
12076
|
+
...p.note ? { note: p.note } : {},
|
|
12077
|
+
...p.sampleLabel ? {
|
|
12078
|
+
sampleLabel: p.sampleLabel,
|
|
12079
|
+
onSample: () => emit("sample")
|
|
12080
|
+
} : {}
|
|
12081
|
+
});
|
|
12082
|
+
emit("drop", d);
|
|
12083
|
+
return d;
|
|
12084
|
+
}, (p) => [p.queue, p.showDropped])
|
|
12085
|
+
});
|
|
12086
|
+
/** Vue component for the export menu of a transcribe queue: four formats, copy, all as zip, undo and redo. */
|
|
12087
|
+
const ExportMenu = /* @__PURE__ */ defineComponent({
|
|
12088
|
+
name: "ExportMenu",
|
|
12089
|
+
props: {
|
|
12090
|
+
queue: {
|
|
12091
|
+
type: Object,
|
|
12092
|
+
required: true
|
|
12093
|
+
},
|
|
12094
|
+
tool: {
|
|
12095
|
+
type: String,
|
|
12096
|
+
default: ""
|
|
12097
|
+
},
|
|
12098
|
+
go: {
|
|
12099
|
+
type: Boolean,
|
|
12100
|
+
default: false
|
|
12101
|
+
}
|
|
12102
|
+
},
|
|
12103
|
+
setup: hosted((host, p) => mountExportMenu(host, p.queue, {
|
|
12104
|
+
go: p.go,
|
|
12105
|
+
...p.tool ? { tool: p.tool } : {}
|
|
12106
|
+
}), (p) => [p.queue, p.go])
|
|
12107
|
+
});
|
|
12108
|
+
/** Vue component for a memory pane over a store; emits `pane` with the handle (refresh, used). */
|
|
12109
|
+
const MemoryPane = /* @__PURE__ */ defineComponent({
|
|
12110
|
+
name: "MemoryPane",
|
|
12111
|
+
props: {
|
|
12112
|
+
memory: {
|
|
12113
|
+
type: Object,
|
|
12114
|
+
required: true
|
|
12115
|
+
},
|
|
12116
|
+
name: {
|
|
12117
|
+
type: String,
|
|
12118
|
+
default: "memory"
|
|
12119
|
+
},
|
|
12120
|
+
by: {
|
|
12121
|
+
type: String,
|
|
12122
|
+
default: "source"
|
|
12123
|
+
},
|
|
12124
|
+
kinds: {
|
|
12125
|
+
type: Object,
|
|
12126
|
+
default: void 0
|
|
12127
|
+
},
|
|
12128
|
+
exportLabel: {
|
|
12129
|
+
type: String,
|
|
12130
|
+
default: "export"
|
|
12131
|
+
},
|
|
12132
|
+
acts: {
|
|
12133
|
+
type: Array,
|
|
12134
|
+
default: void 0
|
|
12135
|
+
}
|
|
12136
|
+
},
|
|
12137
|
+
emits: [
|
|
12138
|
+
"pane",
|
|
12139
|
+
"change",
|
|
12140
|
+
"act"
|
|
12141
|
+
],
|
|
12142
|
+
setup: hosted((host, p, emit) => {
|
|
12143
|
+
const m = mountMemoryPane(host, p.memory, {
|
|
12144
|
+
name: p.name,
|
|
12145
|
+
by: p.by,
|
|
12146
|
+
exportLabel: p.exportLabel,
|
|
12147
|
+
onChange: () => emit("change"),
|
|
12148
|
+
onAct: (id) => emit("act", id),
|
|
12149
|
+
...p.kinds ? { kinds: p.kinds } : {},
|
|
12150
|
+
...p.acts ? { acts: p.acts } : {}
|
|
12151
|
+
});
|
|
12152
|
+
emit("pane", m);
|
|
12153
|
+
return m;
|
|
12154
|
+
}, (p) => [p.memory])
|
|
12155
|
+
});
|
|
12156
|
+
/** Vue component for a sources drop: files and folders into memory through `ingest`. */
|
|
12157
|
+
const SourcesDrop = /* @__PURE__ */ defineComponent({
|
|
12158
|
+
name: "SourcesDrop",
|
|
12159
|
+
props: {
|
|
12160
|
+
ingest: {
|
|
12161
|
+
type: Function,
|
|
12162
|
+
required: true
|
|
12163
|
+
},
|
|
12164
|
+
accept: {
|
|
12165
|
+
type: String,
|
|
12166
|
+
default: ""
|
|
11142
12167
|
}
|
|
11143
12168
|
},
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
accept: p.accept
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
12169
|
+
setup: hosted((host, p) => mountSourcesDrop(host, {
|
|
12170
|
+
ingest: p.ingest,
|
|
12171
|
+
...p.accept ? { accept: p.accept } : {}
|
|
12172
|
+
}), (p) => [p.ingest])
|
|
12173
|
+
});
|
|
12174
|
+
/** Vue component for a persona rack. */
|
|
12175
|
+
const PersonaRack = /* @__PURE__ */ defineComponent({
|
|
12176
|
+
name: "PersonaRack",
|
|
12177
|
+
props: { rack: {
|
|
12178
|
+
type: Object,
|
|
12179
|
+
required: true
|
|
12180
|
+
} },
|
|
12181
|
+
setup: hosted((host, p) => mountPersonaRack(host, p.rack), (p) => [p.rack])
|
|
12182
|
+
});
|
|
12183
|
+
/** Vue component for a voice row. */
|
|
12184
|
+
const VoiceRow = /* @__PURE__ */ defineComponent({
|
|
12185
|
+
name: "VoiceRow",
|
|
12186
|
+
props: {
|
|
12187
|
+
row: {
|
|
12188
|
+
type: Object,
|
|
12189
|
+
required: true
|
|
12190
|
+
},
|
|
12191
|
+
test: {
|
|
12192
|
+
type: String,
|
|
12193
|
+
default: ""
|
|
12194
|
+
}
|
|
12195
|
+
},
|
|
12196
|
+
setup: hosted((host, p) => mountVoiceRow(host, p.row, p.test ? { test: p.test } : {}), (p) => [p.row])
|
|
12197
|
+
});
|
|
12198
|
+
/** Vue component for the voice clone row of a speaker; `can` says the loaded voice clones. */
|
|
12199
|
+
const VoiceClone = /* @__PURE__ */ defineComponent({
|
|
12200
|
+
name: "VoiceClone",
|
|
12201
|
+
props: {
|
|
12202
|
+
speaker: {
|
|
12203
|
+
type: Object,
|
|
12204
|
+
required: true
|
|
12205
|
+
},
|
|
12206
|
+
can: {
|
|
12207
|
+
type: Boolean,
|
|
12208
|
+
default: true
|
|
12209
|
+
},
|
|
12210
|
+
seconds: {
|
|
12211
|
+
type: Number,
|
|
12212
|
+
default: 10
|
|
12213
|
+
},
|
|
12214
|
+
hint: {
|
|
12215
|
+
type: String,
|
|
12216
|
+
default: ""
|
|
12217
|
+
}
|
|
12218
|
+
},
|
|
12219
|
+
setup: hosted((host, p) => mountVoiceClone(host, p.speaker, {
|
|
12220
|
+
seconds: p.seconds,
|
|
12221
|
+
can: () => p.can,
|
|
12222
|
+
...p.hint ? { hint: p.hint } : {}
|
|
12223
|
+
}), (p) => [p.speaker, p.can])
|
|
12224
|
+
});
|
|
12225
|
+
/** Vue component for the session menu of a chat list; emits `import` with the number of chats. */
|
|
12226
|
+
const SessionMenu = /* @__PURE__ */ defineComponent({
|
|
12227
|
+
name: "SessionMenu",
|
|
12228
|
+
props: { list: {
|
|
12229
|
+
type: Object,
|
|
12230
|
+
required: true
|
|
12231
|
+
} },
|
|
12232
|
+
emits: ["import"],
|
|
12233
|
+
setup: hosted((host, p, emit) => mountSessionMenu(host, p.list, { onImport: (n) => emit("import", n) }), (p) => [p.list])
|
|
11152
12234
|
});
|
|
11153
12235
|
/** Vue component for the selected transcript, or its export buttons when `exports` is set. */
|
|
11154
12236
|
const TranscriptView = /* @__PURE__ */ defineComponent({
|
|
@@ -11166,8 +12248,8 @@ Component that was made reactive: `, type);
|
|
|
11166
12248
|
setup: hosted((host, p) => p.exports ? mountTranscriptExports(host, p.queue) : mountTranscriptView(host, p.queue), (p) => [p.queue, p.exports])
|
|
11167
12249
|
});
|
|
11168
12250
|
/**
|
|
11169
|
-
* Vue component for a mask studio; emits `studio` with the mounted studio
|
|
11170
|
-
* sample button is pressed.
|
|
12251
|
+
* Vue component for a mask studio; emits `studio` with the mounted studio, `sample` when the
|
|
12252
|
+
* sample button is pressed, and with `demand` set, `want` when a tool needs a model not loaded yet.
|
|
11171
12253
|
*/
|
|
11172
12254
|
const MaskStudio = /* @__PURE__ */ defineComponent({
|
|
11173
12255
|
name: "MaskStudio",
|
|
@@ -11179,9 +12261,17 @@ Component that was made reactive: `, type);
|
|
|
11179
12261
|
sampleLabel: {
|
|
11180
12262
|
type: String,
|
|
11181
12263
|
default: ""
|
|
12264
|
+
},
|
|
12265
|
+
demand: {
|
|
12266
|
+
type: Boolean,
|
|
12267
|
+
default: false
|
|
11182
12268
|
}
|
|
11183
12269
|
},
|
|
11184
|
-
emits: [
|
|
12270
|
+
emits: [
|
|
12271
|
+
"studio",
|
|
12272
|
+
"sample",
|
|
12273
|
+
"want"
|
|
12274
|
+
],
|
|
11185
12275
|
setup(props, { emit }) {
|
|
11186
12276
|
const el = /* @__PURE__ */ ref(null);
|
|
11187
12277
|
const studio = /* @__PURE__ */ shallowRef(null);
|
|
@@ -11191,7 +12281,8 @@ Component that was made reactive: `, type);
|
|
|
11191
12281
|
...props.sampleLabel ? {
|
|
11192
12282
|
sampleLabel: props.sampleLabel,
|
|
11193
12283
|
onSample: () => emit("sample")
|
|
11194
|
-
} : {}
|
|
12284
|
+
} : {},
|
|
12285
|
+
...props.demand ? { onWant: (k) => emit("want", k) } : {}
|
|
11195
12286
|
});
|
|
11196
12287
|
emit("studio", studio.value);
|
|
11197
12288
|
});
|
|
@@ -11382,16 +12473,23 @@ Component that was made reactive: `, type);
|
|
|
11382
12473
|
exports.ChatPane = ChatPane;
|
|
11383
12474
|
exports.Composer = Composer;
|
|
11384
12475
|
exports.ContextMeter = ContextMeter;
|
|
12476
|
+
exports.ExportMenu = ExportMenu;
|
|
11385
12477
|
exports.FrameView = FrameView;
|
|
11386
12478
|
exports.MaskRack = MaskRack;
|
|
11387
12479
|
exports.MaskStudio = MaskStudio;
|
|
11388
12480
|
exports.MaskTools = MaskTools;
|
|
11389
12481
|
exports.MaskVerbs = MaskVerbs;
|
|
11390
12482
|
exports.MemoryInspector = MemoryInspector;
|
|
12483
|
+
exports.MemoryPane = MemoryPane;
|
|
11391
12484
|
exports.ModelJobs = ModelJobs;
|
|
11392
12485
|
exports.ModelSelect = ModelSelect;
|
|
12486
|
+
exports.PersonaRack = PersonaRack;
|
|
12487
|
+
exports.SessionMenu = SessionMenu;
|
|
12488
|
+
exports.SourcesDrop = SourcesDrop;
|
|
11393
12489
|
exports.TranscribeDrop = TranscribeDrop;
|
|
11394
12490
|
exports.TranscribeQueue = TranscribeQueue;
|
|
11395
12491
|
exports.TranscriptView = TranscriptView;
|
|
12492
|
+
exports.VoiceClone = VoiceClone;
|
|
12493
|
+
exports.VoiceRow = VoiceRow;
|
|
11396
12494
|
return exports;
|
|
11397
12495
|
})({});
|