@cognolo/runtime 0.4.2
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/LICENSE +9 -0
- package/README.md +56 -0
- package/dist/agent.d.ts +290 -0
- package/dist/agent.js +245 -0
- package/dist/bundle.d.ts +192 -0
- package/dist/bundle.js +133 -0
- package/dist/cloud.d.ts +301 -0
- package/dist/cloud.js +383 -0
- package/dist/compact.d.ts +58 -0
- package/dist/compact.js +138 -0
- package/dist/context.d.ts +169 -0
- package/dist/context.js +144 -0
- package/dist/gate.d.ts +106 -0
- package/dist/gate.js +82 -0
- package/dist/guard.d.ts +15 -0
- package/dist/guard.js +26 -0
- package/dist/help.d.ts +44 -0
- package/dist/help.js +79 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +25 -0
- package/dist/init-cli.d.ts +40 -0
- package/dist/init-cli.js +317 -0
- package/dist/links.d.ts +39 -0
- package/dist/links.js +89 -0
- package/dist/look.d.ts +462 -0
- package/dist/look.js +362 -0
- package/dist/models.d.ts +79 -0
- package/dist/models.js +145 -0
- package/dist/outside.d.ts +102 -0
- package/dist/outside.js +204 -0
- package/dist/page.d.ts +59 -0
- package/dist/page.js +158 -0
- package/dist/passkey-browser.d.ts +40 -0
- package/dist/passkey-browser.js +48 -0
- package/dist/passkey.d.ts +64 -0
- package/dist/passkey.js +130 -0
- package/dist/pictures.d.ts +23 -0
- package/dist/pictures.js +58 -0
- package/dist/propose.d.ts +36 -0
- package/dist/propose.js +178 -0
- package/dist/rate.d.ts +97 -0
- package/dist/rate.js +147 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +7 -0
- package/dist/react/labels.d.ts +167 -0
- package/dist/react/labels.js +114 -0
- package/dist/react/logic.d.ts +77 -0
- package/dist/react/logic.js +140 -0
- package/dist/react/page-view.d.ts +3 -0
- package/dist/react/page-view.js +308 -0
- package/dist/react/panel.d.ts +179 -0
- package/dist/react/panel.js +749 -0
- package/dist/react/use-chat.d.ts +96 -0
- package/dist/react/use-chat.js +252 -0
- package/dist/research.d.ts +109 -0
- package/dist/research.js +207 -0
- package/dist/route.d.ts +405 -0
- package/dist/route.js +1493 -0
- package/dist/search.d.ts +70 -0
- package/dist/search.js +112 -0
- package/dist/sensitive.d.ts +54 -0
- package/dist/sensitive.js +209 -0
- package/dist/setup.d.ts +93 -0
- package/dist/setup.js +658 -0
- package/dist/store-sql.d.ts +52 -0
- package/dist/store-sql.js +150 -0
- package/dist/store.d.ts +166 -0
- package/dist/store.js +201 -0
- package/dist/text.d.ts +9 -0
- package/dist/text.js +21 -0
- package/dist/tool.d.ts +66 -0
- package/dist/tool.js +36 -0
- package/dist/trust.d.ts +13 -0
- package/dist/trust.js +18 -0
- package/dist/version.d.ts +40 -0
- package/dist/version.js +133 -0
- package/dist/webmcp-browser.d.ts +20 -0
- package/dist/webmcp-browser.js +61 -0
- package/dist/workflow.d.ts +253 -0
- package/dist/workflow.js +310 -0
- package/docs/store.md +330 -0
- package/package.json +71 -0
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { DEFAULT_LABELS, fill, withLabels } from "./labels.js";
|
|
5
|
+
import { badgeText, clampRect, LAYOUTS, creditSeen, decisionsFor, draftOf, editFrom, isProduction, PAGE_THEME_ATTRS, pageScheme, shrinkPicture } from "./logic.js";
|
|
6
|
+
import { useCognoloChat } from "./use-chat.js";
|
|
7
|
+
import { OUTSIDE_WAITING_EVENT } from "../webmcp-browser.js";
|
|
8
|
+
export const OUTSIDE_ASKED = "Asked by your own AI, not by the assistant. Check it before you approve: it runs only with your passkey.";
|
|
9
|
+
const OUTSIDE_ENDED = { ran: "Done.", failed: "It was approved, but it didn't work.", declined: "Declined. Nothing changed.", expired: "It expired. Nothing changed.", refused: "Not run: the app's checks refused it." };
|
|
10
|
+
import { nudgeAccent, APPROVAL_IDS, brandTheme, lookPalette, APPROVALS, GREEN_IDS, greenParts, CARD_SURFACE, cleanLogo, contrast, HEX, looksLikeStatus, RICH_IDS, RICH_THEMES, strengthOf, textOn, THEME_IDS, THEMES } from "../look.js";
|
|
11
|
+
import { HIDDEN as HIDDEN_TEXT, outsideHref, safeHref } from "../links.js";
|
|
12
|
+
import { looksSensitive } from "../sensitive.js";
|
|
13
|
+
const CSS = `
|
|
14
|
+
.cog-root{color-scheme:light;--a:var(--cognolo-accent,#4f46e5);--bg:var(--cognolo-bg,#fff);--fg:var(--cognolo-fg,#0f172a);--muted:var(--cognolo-muted,#55607a);--cs:var(--cognolo-bg,#fff);--line:var(--cognolo-border,#e2e8f0);--soft:var(--cognolo-soft,#f1f5f9);--ok:var(--cognolo-ok,#15803d);--warn:var(--cognolo-warn,#b45309);--bad:var(--cognolo-danger,#b91c1c);--okt:var(--cognolo-ok-text,var(--ok));--badt:var(--cognolo-danger-text,var(--bad));--r:var(--cognolo-radius,10px);--rs:var(--cognolo-radius-small,8px);--lk:var(--cognolo-link,var(--a));--at:var(--cognolo-accent-text,#fff);--onfill:#fff;--waitc:#fcd34d;--waitp:18%;--irrt:#b91c1c;--cfs:14px;font:var(--cfs)/1.45 var(--cognolo-font,system-ui,sans-serif);color:var(--fg)}
|
|
15
|
+
/* Large text: every size in the panel is worked out from --cfs, so they all grow together and never compound. */
|
|
16
|
+
.cog-root[data-text=large]{--cfs:16px}
|
|
17
|
+
.cog-root *{box-sizing:border-box}
|
|
18
|
+
.cog-root button{font:inherit;cursor:pointer}
|
|
19
|
+
.cog-root button:disabled{opacity:.45;cursor:default}
|
|
20
|
+
/* Hover: a light wash on plain buttons, a slightly darker fill on filled ones (same colour family, so a button never changes meaning). */
|
|
21
|
+
.cog-btn:not(:disabled):not([aria-pressed=true]):not(.cog-yes):hover,.cog-eg button:not(:disabled):hover,.cog-toggle:not(.cog-floating):hover{background:color-mix(in srgb,var(--fg) 7%,var(--bg))}
|
|
22
|
+
.cog-btn[aria-pressed=true]:not(:disabled):hover,.cog-yes:not(:disabled):hover,.cog-send:not(:disabled):hover,.cog-floating:hover{box-shadow:inset 0 0 0 99px rgb(0 0 0/.12)}
|
|
23
|
+
.cog-x:hover{background:var(--soft);color:var(--fg)}
|
|
24
|
+
@media (prefers-reduced-motion:no-preference){.cog-root button{transition:background-color .12s,box-shadow .12s}}
|
|
25
|
+
.cog-toggle{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--bg);color:var(--fg);border-radius:999px;padding:6px 12px;font-weight:600}
|
|
26
|
+
.cog-floating{position:fixed;right:20px;bottom:20px;z-index:2147483000;background:var(--a);color:var(--at);border-color:transparent;box-shadow:0 6px 20px rgba(0,0,0,.25)}
|
|
27
|
+
.cog-floating.cog-left{right:auto;left:20px}
|
|
28
|
+
.cog-panel{position:fixed;top:0;right:0;bottom:0;z-index:2147483001;display:flex;flex-direction:column;width:100%;max-width:var(--cognolo-width,26rem);background:var(--bg);border-left:1px solid var(--line);box-shadow:-8px 0 30px rgba(0,0,0,.15)}
|
|
29
|
+
.cog-panel.cog-left{right:auto;left:0;border-left:0;border-right:1px solid var(--line);box-shadow:8px 0 30px rgba(0,0,0,.15)}
|
|
30
|
+
/* Card: a chat card in a bottom corner, about half the screen high, above the floating button when there is one. Window: placed
|
|
31
|
+
by the person (the --cog-* variables), kept on screen by clampRect. Both are bounded by the screen, and only the message
|
|
32
|
+
list scrolls, so the decision bar and the approval buttons stay in view. The owner's corners round the outer box. */
|
|
33
|
+
.cog-panel[data-layout=card],.cog-panel[data-layout=window]{border:1px solid var(--line);border-radius:var(--r);overflow:hidden;box-shadow:0 12px 40px rgba(0,0,0,.22)}
|
|
34
|
+
.cog-panel[data-layout=card]{top:auto;right:20px;bottom:20px;width:min(var(--cognolo-width,26rem),calc(100vw - 40px));max-width:none;height:min(max(50vh,420px),calc(100vh - 40px))}
|
|
35
|
+
.cog-panel.cog-left[data-layout=card]{right:auto;left:20px}
|
|
36
|
+
.cog-floating~.cog-panel[data-layout=card]{bottom:84px;height:min(max(50vh,420px),calc(100vh - 104px))}
|
|
37
|
+
.cog-panel[data-layout=window]{top:var(--cog-y,auto);left:var(--cog-x,auto);right:var(--cog-r,24px);bottom:var(--cog-b,24px);width:var(--cog-w,min(26rem,calc(100vw - 16px)));height:var(--cog-h,min(600px,calc(100vh - 16px)));max-width:calc(100vw - 16px);max-height:calc(100vh - 16px)}
|
|
38
|
+
.cog-panel.cog-left[data-layout=window]{left:var(--cog-x,24px);right:var(--cog-r,auto)}
|
|
39
|
+
.cog-panel[data-layout=window] .cog-head{cursor:move;user-select:none;touch-action:none}
|
|
40
|
+
.cog-move{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin-inline-start:-6px;padding:0;background:none;border:0;border-radius:var(--rs);color:var(--muted);cursor:move}
|
|
41
|
+
.cog-move:hover{background:var(--soft);color:var(--fg)}
|
|
42
|
+
.cog-root[data-header] .cog-move{color:var(--ht)}
|
|
43
|
+
.cog-grip{position:absolute;right:0;bottom:0;width:18px;height:18px;padding:0;background:none;border:0;cursor:nwse-resize;touch-action:none;color:var(--muted)}
|
|
44
|
+
.cog-grip::before{content:"";position:absolute;right:4px;bottom:4px;width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;opacity:.6}
|
|
45
|
+
/* On a phone the card and the window fill the screen. Raised above every card and window rule (left, above the floating
|
|
46
|
+
button) so none of them wins here; docked keeps its own phone behaviour, as before layouts. */
|
|
47
|
+
@media (max-width:640px){.cog-root .cog-panel.cog-panel:is([data-layout=card],[data-layout=window]){top:0;left:0;right:0;bottom:0;width:auto;height:auto;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none}.cog-root .cog-panel .cog-move,.cog-root .cog-panel .cog-grip{display:none}.cog-root .cog-panel[data-layout=window] .cog-head{cursor:auto;user-select:auto;touch-action:auto}}
|
|
48
|
+
.cog-head{display:flex;align-items:center;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}
|
|
49
|
+
.cog-head h2{margin:0;font-size:calc(var(--cfs) * 16 / 14)}
|
|
50
|
+
.cog-logo{display:block;flex:none;height:28px;width:auto;max-width:96px;object-fit:contain;border-radius:4px}
|
|
51
|
+
.cog-ai{display:block;font-size:calc(var(--cfs) * 11 / 14);font-weight:400;color:var(--muted)}
|
|
52
|
+
.cog-root :focus-visible{outline:2px solid var(--a);outline-offset:2px}
|
|
53
|
+
.cog-root[data-header=accent]{--hb:var(--a);--ht:var(--at)}
|
|
54
|
+
.cog-root[data-header] .cog-head{background:var(--hb);color:var(--ht);border-bottom-color:transparent}
|
|
55
|
+
.cog-root[data-header] .cog-head :focus-visible{outline-color:var(--ht)}
|
|
56
|
+
.cog-root[data-header] .cog-ai,.cog-root[data-header] .cog-link,.cog-root[data-header] .cog-x{color:var(--ht)}
|
|
57
|
+
.cog-root[data-font=app]{font-family:inherit}
|
|
58
|
+
.cog-root[data-font=serif]{font-family:Georgia,Cambria,"Times New Roman",serif}
|
|
59
|
+
.cog-root[data-density=compact] .cog-log{padding:10px 12px;gap:6px}
|
|
60
|
+
.cog-root[data-density=compact] .cog-msg{padding:5px 10px}
|
|
61
|
+
.cog-root[data-density=compact] .cog-head{padding:8px 12px}
|
|
62
|
+
.cog-root[data-density=compact] .cog-form{padding:8px 12px}
|
|
63
|
+
.cog-root[data-radius=square]{--r:2px;--rs:2px}
|
|
64
|
+
.cog-root[data-radius=slight]{--r:6px;--rs:5px}
|
|
65
|
+
.cog-root[data-radius=soft]{--r:14px;--rs:12px}
|
|
66
|
+
.cog-root[data-radius=round]{--r:20px;--rs:999px}
|
|
67
|
+
.cog-link{margin-inline-start:auto;background:none;border:0;color:var(--muted);text-decoration:underline;font-size:calc(var(--cfs) * 12 / 14)}
|
|
68
|
+
.cog-x{background:none;border:0;color:var(--muted);font-size:calc(var(--cfs) * 16 / 14);padding:2px 8px;border-radius:var(--rs)}
|
|
69
|
+
.cog-badge{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:6px 16px;border-bottom:1px solid var(--line);background:var(--soft);font-size:calc(var(--cfs) * 12 / 14);color:var(--muted)}
|
|
70
|
+
.cog-badge b{padding:1px 8px;border-radius:999px;background:var(--fg);color:var(--bg);font-weight:600}
|
|
71
|
+
.cog-badge b.cog-nonprod{background:var(--warn);color:var(--onfill)}
|
|
72
|
+
.cog-log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px}
|
|
73
|
+
.cog-intro{color:var(--muted)}
|
|
74
|
+
.cog-eg{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
|
|
75
|
+
.cog-eg button{border:1px solid var(--line);background:var(--bg);color:var(--fg);border-radius:999px;padding:4px 10px;font-size:calc(var(--cfs) * 12 / 14)}
|
|
76
|
+
.cog-msg{margin:0;white-space:pre-wrap;border-radius:var(--r);padding:8px 12px;max-width:85%;width:fit-content;overflow-wrap:anywhere}
|
|
77
|
+
.cog-user{align-self:flex-end;background:var(--a);color:var(--at)}
|
|
78
|
+
/* Under a message, shown on hover or keyboard focus (always on touch screens): when it was sent, and a copy button. */
|
|
79
|
+
.cog-meta{display:flex;align-items:center;gap:6px;margin-top:-4px;font-size:calc(var(--cfs) * 11 / 14);color:var(--muted);opacity:0;transition:opacity .15s}
|
|
80
|
+
.cog-meta-mine{align-self:flex-end}
|
|
81
|
+
.cog-meta-bot{align-self:flex-start}
|
|
82
|
+
.cog-msg:hover+.cog-meta,.cog-meta:hover,.cog-meta:focus-within{opacity:1}
|
|
83
|
+
@media (hover:none){.cog-meta{opacity:1}}
|
|
84
|
+
.cog-copy{display:inline-flex;align-items:center;gap:3px;border:0;background:none;color:inherit;font:inherit;padding:2px 4px;border-radius:var(--rs);cursor:pointer}
|
|
85
|
+
.cog-copy:hover{color:var(--fg);background:var(--soft)}
|
|
86
|
+
/* The usage ring at the end of the badge row, and what it opens below the row: the business's allowance, for everyone. */
|
|
87
|
+
.cog-ring{margin-inline-start:auto;display:inline-flex;align-items:center;gap:4px;border:0;background:none;color:var(--muted);font:inherit;padding:2px 4px;border-radius:var(--rs)}
|
|
88
|
+
.cog-ring:hover,.cog-ring[aria-expanded=true]{background:var(--bg);color:var(--fg)}
|
|
89
|
+
.cog-ring circle{fill:none;stroke-width:2.5}
|
|
90
|
+
.cog-ring .cog-ring-bg{stroke:var(--line)}
|
|
91
|
+
.cog-ring .cog-ring-fg{stroke:var(--a);stroke-linecap:round}
|
|
92
|
+
.cog-ring[data-level=near] .cog-ring-fg{stroke:var(--warn)}
|
|
93
|
+
.cog-ring[data-level=full] .cog-ring-fg{stroke:var(--bad)}
|
|
94
|
+
.cog-usage{padding:10px 16px 12px;border-bottom:1px solid var(--line);background:var(--soft);font-size:calc(var(--cfs) * 12 / 14);display:grid;gap:8px}
|
|
95
|
+
.cog-usage h3{margin:0;font-size:calc(var(--cfs) * 13 / 14)}
|
|
96
|
+
.cog-usage p{margin:0;color:var(--muted)}
|
|
97
|
+
.cog-use{display:grid;grid-template-columns:1fr auto;gap:3px 8px;align-items:center}
|
|
98
|
+
.cog-use b{font-weight:600}
|
|
99
|
+
.cog-use span{color:var(--muted)}
|
|
100
|
+
.cog-usebar{grid-column:1/-1;display:block;width:100%;height:6px;border-radius:999px;overflow:hidden}
|
|
101
|
+
.cog-usebar .cog-ring-bg{fill:var(--line)}.cog-usebar .cog-ring-fg{fill:var(--a)}
|
|
102
|
+
.cog-usebar[data-level=near] .cog-ring-fg{fill:var(--warn)}
|
|
103
|
+
.cog-usebar[data-level=full] .cog-ring-fg{fill:var(--bad)}
|
|
104
|
+
.cog-bot{align-self:flex-start;background:var(--soft)}
|
|
105
|
+
/* Chat bubbles: round, with the corner nearest the speaker tucked in like a message tail, and a tighter gap. */
|
|
106
|
+
.cog-root[data-messages=bubbles] .cog-msg{border-radius:18px;padding:8px 14px}
|
|
107
|
+
.cog-root[data-messages=bubbles] .cog-user{position:relative;border-end-end-radius:10px}
|
|
108
|
+
.cog-root[data-messages=bubbles] .cog-bot{position:relative;border-end-start-radius:10px}
|
|
109
|
+
/* The tail, like a phone message: the bubble's side sweeps out to a point, and its underside scoops up then back down into the bubble's rounded corner. A clipped block in the bubble's own colour, so it needs no background behind it and loads nothing. The user's is drawn; the assistant's is its mirror. */
|
|
110
|
+
.cog-root[data-messages=bubbles] .cog-user::after,.cog-root[data-messages=bubbles] .cog-bot::after{content:"";position:absolute;bottom:0;width:14px;height:18px;pointer-events:none;clip-path:path("M0 0L5 0C5 8 7.5 13.5 14 16.8C14.4 17 14.2 17.6 13.6 17.6C9.5 17.8 6 17 2 14.5L0 12Z")}
|
|
111
|
+
.cog-root[data-messages=bubbles] .cog-user::after{right:-9px;background:var(--a)}
|
|
112
|
+
.cog-root[dir=rtl][data-messages=bubbles] .cog-user::after{right:auto;left:-9px;transform:scaleX(-1)}
|
|
113
|
+
.cog-root[dir=rtl][data-messages=bubbles] .cog-bot::after{left:auto;right:-9px;transform:none}
|
|
114
|
+
.cog-root[data-messages=bubbles] .cog-bot::after{left:-9px;background:var(--soft);transform:scaleX(-1)}
|
|
115
|
+
.cog-root[data-messages=bubbles] .cog-log{gap:8px}
|
|
116
|
+
.cog-suggest{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;padding:8px 10px;border:1px solid var(--line);border-radius:var(--rs);background:var(--soft)}
|
|
117
|
+
.cog-suggest q{font-style:italic}
|
|
118
|
+
.cog-bot ul,.cog-bot ol{margin:4px 0;padding-inline-start:20px;white-space:normal}
|
|
119
|
+
.cog-bot li+li{margin-top:2px}
|
|
120
|
+
.cog-line{display:block}
|
|
121
|
+
.cog-refs{list-style:none;margin:2px 0 0;padding:0 0 0 14px;display:flex;flex-wrap:wrap;gap:4px 10px;font-size:calc(var(--cfs) * 12 / 14)}
|
|
122
|
+
.cog-refs a{color:var(--lk);text-decoration:underline;text-underline-offset:2px;overflow-wrap:anywhere}
|
|
123
|
+
.cog-refs-more{margin:2px 0 0 14px}
|
|
124
|
+
.cog-refs-under{margin:-4px 0 0;max-width:85%}
|
|
125
|
+
.cog-refs-under .cog-refs{padding-inline-start:12px}
|
|
126
|
+
.cog-mark{margin-inline-start:2px;text-decoration:none;font-size:.85em;color:var(--lk)}
|
|
127
|
+
.cog-mark:hover,.cog-mark:focus-visible{text-decoration:underline}
|
|
128
|
+
.cog-named{color:var(--lk);text-decoration:underline;text-underline-offset:2px;font-size:inherit;margin-inline-start:0}
|
|
129
|
+
.cog-named span{margin-inline-start:2px;font-size:.85em}
|
|
130
|
+
.cog-recent{gap:2px!important}
|
|
131
|
+
.cog-recent button{display:flex;width:100%;justify-content:space-between;gap:8px;text-align:left;border:0;background:none;color:var(--fg);padding:6px 8px;border-radius:var(--r);font:inherit}
|
|
132
|
+
.cog-recent button:hover{background:var(--soft)}
|
|
133
|
+
.cog-recent span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
134
|
+
.cog-recent time{flex:none;font-size:calc(var(--cfs) * 12 / 14);color:var(--muted)}
|
|
135
|
+
.cog-note{margin:0;font-size:calc(var(--cfs) * 12 / 14);color:var(--muted)}
|
|
136
|
+
.cog-kv dt{display:inline;font-weight:600}.cog-kv dd{display:inline;margin:0;word-break:break-word}
|
|
137
|
+
.cog-bad{color:var(--badt)}
|
|
138
|
+
.cog-card{border:1px solid var(--line);border-radius:var(--r);padding:10px 12px}
|
|
139
|
+
.cog-card.cog-wait{border-color:var(--warn);background:color-mix(in srgb,var(--waitc) var(--waitp),var(--cs))}
|
|
140
|
+
.cog-card.cog-irr{border:2px solid var(--badt);background:color-mix(in srgb,#fca5a5 18%,var(--cs))}
|
|
141
|
+
.cog-irrl{color:var(--irrt);font-weight:800}
|
|
142
|
+
.cog-card h3{margin:0;font-size:calc(var(--cfs) * 11 / 14);font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--muted)}
|
|
143
|
+
.cog-card p{margin:4px 0 0}
|
|
144
|
+
.cog-row{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
|
|
145
|
+
.cog-btn{border:1px solid var(--line);background:var(--bg);color:var(--fg);border-radius:var(--rs);padding:4px 10px;font-size:calc(var(--cfs) * 12 / 14);font-weight:600}
|
|
146
|
+
.cog-btn[aria-pressed=true],.cog-yes{background:var(--ok);border-color:var(--okb,var(--ok));color:var(--okon,var(--onfill))}
|
|
147
|
+
.cog-btn.cog-no[aria-pressed=true]{background:var(--muted);border-color:var(--muted);color:var(--bg)}
|
|
148
|
+
.cog-btn[data-approve][aria-pressed=true]::before{content:"✓ "}
|
|
149
|
+
.cog-btn[data-decline][aria-pressed=true]::before{content:"✕ "}
|
|
150
|
+
.cog-state{font-size:calc(var(--cfs) * 12 / 14);font-weight:600;color:var(--muted)}
|
|
151
|
+
.cog-state.cog-ok{color:var(--okt)}
|
|
152
|
+
.cog-edit{display:grid;gap:6px;margin-top:8px}
|
|
153
|
+
.cog-edit label{display:grid;gap:2px;font-size:calc(var(--cfs) * 12 / 14);color:var(--muted)}
|
|
154
|
+
.cog-edit input:not([type=checkbox]),.cog-edit textarea,.cog-in{border:1px solid var(--line);background:var(--bg);color:var(--fg);border-radius:var(--rs);padding:6px 8px;font:inherit}
|
|
155
|
+
.cog-bar{padding:10px 16px;border-top:1px solid var(--line);background:color-mix(in srgb,var(--waitc) var(--waitp),var(--cs))}
|
|
156
|
+
.cog-bar p{margin:0 0 6px;font-size:calc(var(--cfs) * 12 / 14)}
|
|
157
|
+
.cog-form{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--line)}
|
|
158
|
+
.cog-in{min-width:0;flex:1}
|
|
159
|
+
.cog-send{background:var(--a);color:var(--at);border:0;border-radius:var(--rs);padding:6px 12px;font-weight:600}
|
|
160
|
+
.cog-attach{background:none;border:1px solid var(--line);border-radius:var(--rs);padding:6px 9px;color:var(--fg)}
|
|
161
|
+
.cog-picrow{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:0 16px 6px;font-size:calc(var(--cfs) * 12 / 14);color:var(--muted)}
|
|
162
|
+
.cog-picrow button{background:var(--soft);border:1px solid var(--line);border-radius:999px;padding:1px 8px;color:var(--fg)}
|
|
163
|
+
.cog-pics{font-size:calc(var(--cfs) * 12 / 14);opacity:.8}
|
|
164
|
+
.cog-dot{display:inline-block;flex:none;width:8px;height:8px;border-radius:50%}.cog-dot-ok{background:#22c55e}.cog-dot-old{background:#f59e0b}.cog-dot-limited{background:#ef4444}
|
|
165
|
+
.cog-limited{margin:0;padding:8px 16px;border-top:1px solid var(--line);background:color-mix(in srgb,var(--waitc) var(--waitp),var(--cs));font-size:calc(var(--cfs) * 12 / 14)}
|
|
166
|
+
.cog-err{margin:0;border:1px solid color-mix(in srgb,var(--bad) 35%,var(--bg));background:color-mix(in srgb,var(--bad) 10%,var(--bg));color:var(--badt);border-radius:var(--rs);padding:6px 10px;font-size:calc(var(--cfs) * 12 / 14)}
|
|
167
|
+
.cog-credit{display:flex;align-items:center;justify-content:center;gap:5px;padding:6px 16px;border-top:1px solid var(--line);font-size:calc(var(--cfs) * 11 / 14);color:var(--muted);text-decoration:none}
|
|
168
|
+
.cog-credit:hover{color:var(--fg)}
|
|
169
|
+
.cog-p0{margin:0}
|
|
170
|
+
.cog-wfs{display:grid;gap:8px;margin-top:14px}
|
|
171
|
+
.cog-wfh{margin:0;font-size:inherit;font-weight:600;color:var(--fg)}
|
|
172
|
+
.cog-wfs ul{list-style:none;margin:0;padding:0;display:grid;gap:8px}
|
|
173
|
+
.cog-from{display:inline-block;margin:2px 0 0;padding:1px 6px;border-radius:999px;font-size:calc(var(--cfs) * 11 / 14);background:color-mix(in srgb,var(--fg) 8%,transparent);color:var(--muted)}
|
|
174
|
+
.cog-note .cog-from{margin-inline-start:6px}
|
|
175
|
+
.cog-wfs .cog-card p{margin:4px 0 0}
|
|
176
|
+
.cog-more{margin-top:6px;font-size:calc(var(--cfs) * 12 / 14)}
|
|
177
|
+
.cog-more summary{cursor:pointer;color:var(--muted)}
|
|
178
|
+
.cog-more p{white-space:pre-wrap;margin-top:4px}
|
|
179
|
+
.cog-row.cog-r0{margin-top:0}
|
|
180
|
+
@media (prefers-color-scheme:dark){.cog-root[data-scheme=auto]{color-scheme:dark;--a:var(--cognolo-accent,#6366f1);--bg:var(--cognolo-bg,#1f1f1f);--fg:var(--cognolo-fg,#e5e5e5);--muted:var(--cognolo-muted,#b4b4b4);--cs:var(--cognolo-bg,#1f1f1f);--line:var(--cognolo-border,#3a3a3a);--soft:var(--cognolo-soft,#2a2a2a);--ok:var(--cognolo-ok,#4ade80);--warn:var(--cognolo-warn,#f59e0b);--onfill:#000;--irrt:#fca5a5;--okt:var(--cognolo-ok-text,#4ade80);--badt:var(--cognolo-danger-text,#f87171);--lk:var(--cognolo-link,#a5b4fc)}}
|
|
181
|
+
.cog-root[data-scheme=dark]{color-scheme:dark;--a:var(--cognolo-accent,#6366f1);--bg:var(--cognolo-bg,#1f1f1f);--fg:var(--cognolo-fg,#e5e5e5);--muted:var(--cognolo-muted,#b4b4b4);--cs:var(--cognolo-bg,#1f1f1f);--line:var(--cognolo-border,#3a3a3a);--soft:var(--cognolo-soft,#2a2a2a);--ok:var(--cognolo-ok,#4ade80);--warn:var(--cognolo-warn,#f59e0b);--onfill:#000;--irrt:#fca5a5;--okt:var(--cognolo-ok-text,#4ade80);--badt:var(--cognolo-danger-text,#f87171);--lk:var(--cognolo-link,#a5b4fc)}
|
|
182
|
+
`;
|
|
183
|
+
function usePageScheme(on) {
|
|
184
|
+
const [s, setS] = useState("light");
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (!on || typeof document === "undefined")
|
|
187
|
+
return;
|
|
188
|
+
const read = () => setS(pageScheme(document) ?? "light");
|
|
189
|
+
read();
|
|
190
|
+
const mo = new MutationObserver(read);
|
|
191
|
+
for (const el of [document.documentElement, document.body])
|
|
192
|
+
if (el)
|
|
193
|
+
mo.observe(el, { attributes: true, attributeFilter: PAGE_THEME_ATTRS });
|
|
194
|
+
const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
195
|
+
mq?.addEventListener?.("change", read);
|
|
196
|
+
return () => { mo.disconnect(); mq?.removeEventListener?.("change", read); };
|
|
197
|
+
}, [on]);
|
|
198
|
+
return s;
|
|
199
|
+
}
|
|
200
|
+
function lookAttrs(l) {
|
|
201
|
+
const out = {};
|
|
202
|
+
if (!l)
|
|
203
|
+
return out;
|
|
204
|
+
if (l.radius && ["square", "slight", "soft", "round"].includes(l.radius))
|
|
205
|
+
out["data-radius"] = l.radius;
|
|
206
|
+
if (l.theme && THEME_IDS.includes(l.theme))
|
|
207
|
+
out["data-theme"] = l.theme;
|
|
208
|
+
if (l.brand && brandTheme(l.brand))
|
|
209
|
+
out["data-theme"] = "brand";
|
|
210
|
+
const rich = !!out["data-theme"] && RICH_IDS.includes(out["data-theme"]);
|
|
211
|
+
if (rich && l.intensity === "rich")
|
|
212
|
+
out["data-intensity"] = "rich";
|
|
213
|
+
if (rich && strengthOf(l, "dark") === "rich")
|
|
214
|
+
out["data-intensity-dark"] = "rich";
|
|
215
|
+
if (l.approval && l.approval !== "standard" && APPROVAL_IDS.includes(l.approval) && out["data-theme"] !== "contrast")
|
|
216
|
+
out["data-approval"] = l.approval;
|
|
217
|
+
if (l.approveGreen && GREEN_IDS.includes(l.approveGreen) && out["data-theme"] !== "contrast")
|
|
218
|
+
out["data-green"] = l.approveGreen;
|
|
219
|
+
if (l.header === "accent")
|
|
220
|
+
out["data-header"] = "accent";
|
|
221
|
+
if (l.header === "color" && l.headerColor && HEX.test(l.headerColor))
|
|
222
|
+
out["data-header"] = "color";
|
|
223
|
+
if (l.font === "app" || l.font === "serif")
|
|
224
|
+
out["data-font"] = l.font;
|
|
225
|
+
if (l.density === "compact")
|
|
226
|
+
out["data-density"] = "compact";
|
|
227
|
+
if (l.messages === "bubbles")
|
|
228
|
+
out["data-messages"] = "bubbles";
|
|
229
|
+
if (l.text === "large")
|
|
230
|
+
out["data-text"] = "large";
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
233
|
+
const themeVars = (p, s) => `--bg:${p.bg};--fg:${p.fg};--muted:${p.muted};--soft:${p.soft};--line:${p.line};--cs:${CARD_SURFACE[s]};--a:var(--cognolo-accent,${p.accent});--at:var(--cognolo-accent-text,${textOn(p.accent)});--lk:var(--cognolo-link,${p.accent});`;
|
|
234
|
+
const approvalVars = (id, s) => `--ok:var(--cognolo-ok,${APPROVALS[id].ok[s]});--waitc:${APPROVALS[id].wait};--waitp:${APPROVALS[id].tint[s]}%;`;
|
|
235
|
+
const greenVars = (id, sc) => { const g = greenParts(id, sc); return `--ok:var(--cognolo-ok,${g.fill});--okon:${g.ink};--okb:${g.edge};`; };
|
|
236
|
+
const GREEN_CSS = GREEN_IDS.map((id) => `.cog-root.cog-root[data-green=${id}][data-scheme=light]{${greenVars(id, "light")}}@media (prefers-color-scheme:light){.cog-root.cog-root[data-green=${id}][data-scheme=auto]{${greenVars(id, "light")}}}.cog-root.cog-root[data-green=${id}][data-scheme=dark]{${greenVars(id, "dark")}}@media (prefers-color-scheme:dark){.cog-root.cog-root[data-green=${id}][data-scheme=auto]{${greenVars(id, "dark")}}}`).join("\n");
|
|
237
|
+
const APPROVAL_CSS = APPROVAL_IDS.filter((id) => id !== "standard").map((id) => `.cog-root[data-approval=${id}][data-scheme=light]{${approvalVars(id, "light")}}@media (prefers-color-scheme:light){.cog-root[data-approval=${id}][data-scheme=auto]{${approvalVars(id, "light")}}}.cog-root[data-approval=${id}][data-scheme=dark]{${approvalVars(id, "dark")}}@media (prefers-color-scheme:dark){.cog-root[data-approval=${id}][data-scheme=auto]{${approvalVars(id, "dark")}}}`).join("\n");
|
|
238
|
+
const RICH_CSS = RICH_IDS.map((id) => `.cog-root[data-theme=${id}][data-intensity=rich][data-scheme=light]{${themeVars(RICH_THEMES[id].light, "light")}}@media (prefers-color-scheme:light){.cog-root[data-theme=${id}][data-intensity=rich][data-scheme=auto]{${themeVars(RICH_THEMES[id].light, "light")}}}.cog-root[data-theme=${id}][data-intensity-dark=rich][data-scheme=dark]{color-scheme:dark;${themeVars(RICH_THEMES[id].dark, "dark")}}@media (prefers-color-scheme:dark){.cog-root[data-theme=${id}][data-intensity-dark=rich][data-scheme=auto]{color-scheme:dark;${themeVars(RICH_THEMES[id].dark, "dark")}}}`).join("\n");
|
|
239
|
+
export const THEME_CSS = THEME_IDS.map((id) => `.cog-root[data-theme=${id}]{${themeVars(THEMES[id].light, "light")}}.cog-root[data-theme=${id}][data-scheme=dark]{color-scheme:dark;${themeVars(THEMES[id].dark, "dark")}}@media (prefers-color-scheme:dark){.cog-root[data-theme=${id}][data-scheme=auto]{color-scheme:dark;${themeVars(THEMES[id].dark, "dark")}}}`).join("\n") + "\n" + RICH_CSS + "\n" + APPROVAL_CSS + "\n" + GREEN_CSS;
|
|
240
|
+
export function brandCss(look) {
|
|
241
|
+
const t = look?.brand ? brandTheme(look.brand) : null;
|
|
242
|
+
if (!t)
|
|
243
|
+
return "";
|
|
244
|
+
return `.cog-root[data-theme=brand]{${themeVars(t.light, "light")}}.cog-root[data-theme=brand][data-scheme=dark]{color-scheme:dark;${themeVars(t.dark, "dark")}}@media (prefers-color-scheme:dark){.cog-root[data-theme=brand][data-scheme=auto]{color-scheme:dark;${themeVars(t.dark, "dark")}}}`;
|
|
245
|
+
}
|
|
246
|
+
export function headerCss(look) {
|
|
247
|
+
const ok = (v) => !!v && HEX.test(v) && !looksLikeStatus(v);
|
|
248
|
+
const c = look?.header === "color" ? look.headerColor : undefined;
|
|
249
|
+
if (!ok(c))
|
|
250
|
+
return "";
|
|
251
|
+
const base = `.cog-root.cog-root[data-header=color]{--hb:${c};--ht:${textOn(c)}}`;
|
|
252
|
+
const d = look?.headerColorDark;
|
|
253
|
+
if (!ok(d))
|
|
254
|
+
return base;
|
|
255
|
+
const dark = `--hb:${d};--ht:${textOn(d)}`;
|
|
256
|
+
return `${base}.cog-root.cog-root[data-header=color][data-scheme=dark]{${dark}}@media (prefers-color-scheme:dark){.cog-root.cog-root[data-header=color][data-scheme=auto]{${dark}}}`;
|
|
257
|
+
}
|
|
258
|
+
export function accentCss(look, scheme = "auto") {
|
|
259
|
+
const l = typeof look === "string" ? { accent: look } : look ?? {};
|
|
260
|
+
const vars = (asked, s) => {
|
|
261
|
+
const p = lookPalette(l, s);
|
|
262
|
+
const hex = asked && HEX.test(asked) ? nudgeAccent(asked, p) : null;
|
|
263
|
+
if (!hex)
|
|
264
|
+
return "";
|
|
265
|
+
return `--a:${hex};--at:${textOn(hex)};--lk:${contrast(hex, p.soft) >= 4.5 && contrast(hex, p.bg) >= 4.5 ? hex : `var(--cognolo-link,${p.accent})`};`;
|
|
266
|
+
};
|
|
267
|
+
const light = scheme !== "dark" ? vars(l.accent, "light") : "";
|
|
268
|
+
const dark = scheme !== "light" ? vars(l.accentDark ?? l.accent, "dark") : "";
|
|
269
|
+
const R = ".cog-root.cog-root.cog-root.cog-root";
|
|
270
|
+
return `${light ? `${R}[data-scheme=light]{${light}}@media (prefers-color-scheme:light){${R}[data-scheme=auto]{${light}}}` : ""}${dark ? `${R}[data-scheme=dark]{${dark}}@media (prefers-color-scheme:dark){${R}[data-scheme=auto]{${dark}}}` : ""}`;
|
|
271
|
+
}
|
|
272
|
+
export function CognoloTheme({ colorScheme = "page", nonce, className, style, cloudLook, dir, children }) {
|
|
273
|
+
const asked = cloudLook?.scheme ?? colorScheme;
|
|
274
|
+
const page = usePageScheme(asked === "page");
|
|
275
|
+
const scheme = asked === "page" ? page : asked;
|
|
276
|
+
return (_jsxs("span", { className: className ? `cog-root ${className}` : "cog-root", style: style, "data-scheme": scheme, ...(dir ? { dir } : {}), ...lookAttrs(cloudLook), children: [_jsx("style", { nonce: nonce, children: CSS + THEME_CSS + brandCss(cloudLook) + accentCss(cloudLook, scheme) + headerCss(cloudLook) }), children] }));
|
|
277
|
+
}
|
|
278
|
+
const MARK = _jsx("svg", { viewBox: "0 0 100 100", width: "13", height: "13", "aria-hidden": "true", className: "cog-mark-logo", children: _jsx("path", { d: "M80.74,72.34 A38,38 0 0 1 73.91,79.53 L77.63,88.02 A47,47 0 0 1 69.12,92.94 L63.62,85.48 A38,38 0 0 1 55.94,87.53 L54.91,96.74 A47,47 0 0 1 45.09,96.74 L44.06,87.53 A38,38 0 0 1 36.38,85.48 L30.88,92.94 A47,47 0 0 1 22.37,88.02 L26.09,79.53 A38,38 0 0 1 20.47,73.91 L11.98,77.63 A47,47 0 0 1 7.06,69.12 L14.52,63.62 A38,38 0 0 1 12.47,55.94 L3.26,54.91 A47,47 0 0 1 3.26,45.09 L12.47,44.06 A38,38 0 0 1 14.52,36.38 L7.06,30.88 A47,47 0 0 1 11.98,22.37 L20.47,26.09 A38,38 0 0 1 26.09,20.47 L22.37,11.98 A47,47 0 0 1 30.88,7.06 L36.38,14.52 A38,38 0 0 1 44.06,12.47 L45.09,3.26 A47,47 0 0 1 54.91,3.26 L55.94,12.47 A38,38 0 0 1 63.62,14.52 L69.12,7.06 A47,47 0 0 1 77.63,11.98 L73.91,20.47 A38,38 0 0 1 80.74,27.66 L66.99,37.66 A21,21 0 1 0 66.99,62.34 Z", fill: "currentColor", stroke: "currentColor", strokeWidth: "2.2", strokeLinejoin: "round" }) });
|
|
279
|
+
const SPARKLE = _jsx("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M12 3l1.9 4.6L18.5 9.5l-4.6 1.9L12 16l-1.9-4.6L5.5 9.5l4.6-1.9z" }) });
|
|
280
|
+
export function CognoloAssistant({ buttonLabel, icon, buttonClassName, floating, defaultOpen, colorScheme, nonce, className, style, title = "Assistant", side: sideAsked, dir: dirAsked, ...rest }) {
|
|
281
|
+
const [pageDir, setPageDir] = useState("ltr");
|
|
282
|
+
useEffect(() => { try {
|
|
283
|
+
setPageDir(getComputedStyle(document.documentElement).direction === "rtl" ? "rtl" : "ltr");
|
|
284
|
+
}
|
|
285
|
+
catch { } }, []);
|
|
286
|
+
const dir = dirAsked ?? (pageDir === "rtl" ? "rtl" : undefined);
|
|
287
|
+
const side = sideAsked ?? (dir === "rtl" ? "left" : undefined);
|
|
288
|
+
const { endpoint, storageKey, onApproved, labels, ...panel } = rest;
|
|
289
|
+
const chat = useCognoloChat({ endpoint, storageKey, onApproved, labels });
|
|
290
|
+
const [open, setOpen] = useState(!!defaultOpen);
|
|
291
|
+
const toggle = useRef(null);
|
|
292
|
+
const wasOpen = useRef(open);
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
if (typeof window === "undefined")
|
|
295
|
+
return;
|
|
296
|
+
const on = () => setOpen(true);
|
|
297
|
+
window.addEventListener(OUTSIDE_WAITING_EVENT, on);
|
|
298
|
+
return () => window.removeEventListener(OUTSIDE_WAITING_EVENT, on);
|
|
299
|
+
}, []);
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
if (wasOpen.current && !open)
|
|
302
|
+
toggle.current?.focus();
|
|
303
|
+
wasOpen.current = open;
|
|
304
|
+
}, [open]);
|
|
305
|
+
return (_jsxs(CognoloTheme, { colorScheme: colorScheme, nonce: nonce, className: className, style: style, cloudLook: chat.look, dir: dir, children: [_jsxs("button", { ref: toggle, type: "button", className: `cog-toggle${floating ? " cog-floating" : ""}${floating && side === "left" ? " cog-left" : ""}${buttonClassName ? ` ${buttonClassName}` : ""}`, onClick: () => setOpen((o) => !o), "aria-expanded": open, "data-cognolo-toggle": true, children: [icon === undefined ? SPARKLE : icon, _jsx("span", { dir: "auto", children: chat.look?.launcher ?? buttonLabel ?? title })] }), open && _jsx(ChatView, { chat: chat, ...panel, title: title, side: side, labels: labels, onClose: () => setOpen(false), autoFocus: true })] }));
|
|
306
|
+
}
|
|
307
|
+
const GRIP = _jsxs("svg", { viewBox: "0 0 12 12", width: "12", height: "12", fill: "currentColor", "aria-hidden": "true", children: [_jsx("circle", { cx: "3", cy: "3", r: "1.2" }), _jsx("circle", { cx: "9", cy: "3", r: "1.2" }), _jsx("circle", { cx: "3", cy: "9", r: "1.2" }), _jsx("circle", { cx: "9", cy: "9", r: "1.2" }), _jsx("circle", { cx: "3", cy: "6", r: "1.2" }), _jsx("circle", { cx: "9", cy: "6", r: "1.2" })] });
|
|
308
|
+
const WINDOW_KEY = "cognolo:window";
|
|
309
|
+
const STEP = 16;
|
|
310
|
+
const isControl = (t) => t instanceof Element && !t.closest("[data-cognolo-move]") && !!t.closest("button,a,input,textarea,select,[contenteditable]");
|
|
311
|
+
const onPhone = () => typeof window !== "undefined" && !!window.matchMedia?.("(max-width: 640px)").matches;
|
|
312
|
+
function useWindowRect(on, side) {
|
|
313
|
+
const [rect, setRect] = useState(null);
|
|
314
|
+
const fit = (r) => clampRect(r, window.innerWidth, window.innerHeight, side);
|
|
315
|
+
useEffect(() => {
|
|
316
|
+
if (!on) {
|
|
317
|
+
setRect(null);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
let saved = null;
|
|
321
|
+
try {
|
|
322
|
+
saved = JSON.parse(localStorage.getItem(WINDOW_KEY) ?? "null");
|
|
323
|
+
}
|
|
324
|
+
catch { }
|
|
325
|
+
setRect(fit(saved));
|
|
326
|
+
const onResize = () => setRect((r) => fit(r));
|
|
327
|
+
window.addEventListener("resize", onResize);
|
|
328
|
+
return () => window.removeEventListener("resize", onResize);
|
|
329
|
+
}, [on, side]);
|
|
330
|
+
useEffect(() => {
|
|
331
|
+
if (!rect)
|
|
332
|
+
return;
|
|
333
|
+
const t = setTimeout(() => { try {
|
|
334
|
+
localStorage.setItem(WINDOW_KEY, JSON.stringify(rect));
|
|
335
|
+
}
|
|
336
|
+
catch { } }, 300);
|
|
337
|
+
return () => clearTimeout(t);
|
|
338
|
+
}, [rect]);
|
|
339
|
+
const track = (e, change) => {
|
|
340
|
+
if (!rect || e.button !== 0 || onPhone())
|
|
341
|
+
return;
|
|
342
|
+
const start = rect, x0 = e.clientX, y0 = e.clientY, el = e.currentTarget;
|
|
343
|
+
e.preventDefault();
|
|
344
|
+
try {
|
|
345
|
+
el.setPointerCapture(e.pointerId);
|
|
346
|
+
}
|
|
347
|
+
catch { }
|
|
348
|
+
const stop = new AbortController();
|
|
349
|
+
const opts = { signal: stop.signal };
|
|
350
|
+
el.addEventListener("pointermove", ((m) => setRect(fit({ ...start, ...change(start, m.clientX - x0, m.clientY - y0) }))), opts);
|
|
351
|
+
for (const end of ["pointerup", "pointercancel", "lostpointercapture"])
|
|
352
|
+
el.addEventListener(end, () => stop.abort(), opts);
|
|
353
|
+
};
|
|
354
|
+
const arrows = (e, resize) => {
|
|
355
|
+
const d = { ArrowLeft: [-STEP, 0], ArrowRight: [STEP, 0], ArrowUp: [0, -STEP], ArrowDown: [0, STEP] }[e.key];
|
|
356
|
+
if (!d || !rect)
|
|
357
|
+
return;
|
|
358
|
+
e.preventDefault();
|
|
359
|
+
setRect((r) => r && fit(resize ? { ...r, w: r.w + d[0], h: r.h + d[1] } : { ...r, x: r.x + d[0], y: r.y + d[1] }));
|
|
360
|
+
};
|
|
361
|
+
return {
|
|
362
|
+
rect,
|
|
363
|
+
vars: rect ? { "--cog-x": `${rect.x}px`, "--cog-y": `${rect.y}px`, "--cog-w": `${rect.w}px`, "--cog-h": `${rect.h}px`, "--cog-r": "auto", "--cog-b": "auto" } : null,
|
|
364
|
+
dragStart: (e) => { if (!isControl(e.target))
|
|
365
|
+
track(e, (s, dx, dy) => ({ x: s.x + dx, y: s.y + dy })); },
|
|
366
|
+
resizeStart: (e) => track(e, (s, dx, dy) => ({ w: s.w + dx, h: s.h + dy })),
|
|
367
|
+
moveKey: (e) => arrows(e, e.shiftKey),
|
|
368
|
+
resizeKey: (e) => arrows(e, true),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
export function ChatView({ chat, title = "Assistant", intro, examples, side, layout, width, panelClassName, panelStyle, labels, render, onNavigate, draftMessage, onClose, autoFocus }) {
|
|
372
|
+
const L = withLabels(labels);
|
|
373
|
+
const [text, setText] = useState(draftMessage ?? "");
|
|
374
|
+
const [pics, setPics] = useState([]);
|
|
375
|
+
const [picFailed, setPicFailed] = useState(false);
|
|
376
|
+
const [shrinking, setShrinking] = useState(0);
|
|
377
|
+
const picInput = useRef(null);
|
|
378
|
+
const addPictures = async (files) => {
|
|
379
|
+
setPicFailed(false);
|
|
380
|
+
const list = [...files];
|
|
381
|
+
const take = list.slice(0, Math.max(0, 4 - pics.length));
|
|
382
|
+
if (take.length < list.length)
|
|
383
|
+
setPicFailed(true);
|
|
384
|
+
setShrinking((n) => n + 1);
|
|
385
|
+
try {
|
|
386
|
+
for (const f of take) {
|
|
387
|
+
const url = await shrinkPicture(f);
|
|
388
|
+
if (url)
|
|
389
|
+
setPics((p) => (p.length < 4 ? [...p, url] : p));
|
|
390
|
+
else
|
|
391
|
+
setPicFailed(true);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
finally {
|
|
395
|
+
setShrinking((n) => n - 1);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
const dragsImage = (items) => [...(items ?? [])].some((x) => x.kind === "file" && x.type.startsWith("image/"));
|
|
399
|
+
const imagesIn = (list) => [...(list ?? [])].map((x) => (x instanceof File ? x : x.getAsFile())).filter((f) => !!f && f.type.startsWith("image/"));
|
|
400
|
+
const input = useRef(null);
|
|
401
|
+
const [choice, setChoice] = useState({});
|
|
402
|
+
const [edits, setEdits] = useState({});
|
|
403
|
+
const log = useRef(null);
|
|
404
|
+
const { transcript, pending, busy, error, badge } = chat;
|
|
405
|
+
const waiting = transcript.filter((e) => e.t === "proposal" && e.status === "waiting");
|
|
406
|
+
const byId = new Map(pending.map((p) => [p.toolUseId, p]));
|
|
407
|
+
const refsBelow = groupRefs(transcript);
|
|
408
|
+
for (const p of linkable(chat.pages))
|
|
409
|
+
if (p.id.startsWith("page:") && !refsBelow.byId.has(p.id))
|
|
410
|
+
refsBelow.byId.set(p.id, p);
|
|
411
|
+
const go = (ev, href) => {
|
|
412
|
+
if (!onNavigate || ev.button !== 0 || ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey)
|
|
413
|
+
return;
|
|
414
|
+
ev.preventDefault();
|
|
415
|
+
onNavigate(href);
|
|
416
|
+
if (typeof window !== "undefined" && window.matchMedia?.("(max-width: 640px)").matches)
|
|
417
|
+
onClose?.();
|
|
418
|
+
};
|
|
419
|
+
const credit = useRef(null);
|
|
420
|
+
const showCredit = !badge?.whiteLabel;
|
|
421
|
+
const badgeKnown = !!badge;
|
|
422
|
+
useEffect(() => {
|
|
423
|
+
if (!badgeKnown || !showCredit)
|
|
424
|
+
return;
|
|
425
|
+
const t = setTimeout(() => chat.reportCredit(creditSeen(credit.current) ? "shown" : "hidden"), 1000);
|
|
426
|
+
return () => clearTimeout(t);
|
|
427
|
+
}, [badgeKnown, showCredit]);
|
|
428
|
+
useEffect(() => { if (autoFocus)
|
|
429
|
+
input.current?.focus(); }, [autoFocus]);
|
|
430
|
+
useEffect(() => { const l = log.current; if (l)
|
|
431
|
+
l.scrollTop = l.scrollHeight; }, [transcript.length, busy]);
|
|
432
|
+
useEffect(() => {
|
|
433
|
+
if (!onClose)
|
|
434
|
+
return;
|
|
435
|
+
const key = (e) => { if (e.key === "Escape")
|
|
436
|
+
onClose(); };
|
|
437
|
+
window.addEventListener("keydown", key);
|
|
438
|
+
return () => window.removeEventListener("keydown", key);
|
|
439
|
+
}, [onClose]);
|
|
440
|
+
useEffect(() => { setChoice({}); setEdits({}); }, [transcript.length, busy]);
|
|
441
|
+
useEffect(() => {
|
|
442
|
+
chat.wake?.();
|
|
443
|
+
const back = () => { if (document.visibilityState === "visible")
|
|
444
|
+
chat.wake?.(); };
|
|
445
|
+
document.addEventListener("visibilitychange", back);
|
|
446
|
+
return () => document.removeEventListener("visibilitychange", back);
|
|
447
|
+
}, []);
|
|
448
|
+
const submit = (e) => {
|
|
449
|
+
e.preventDefault();
|
|
450
|
+
const m = text.trim();
|
|
451
|
+
if (!m || busy || shrinking)
|
|
452
|
+
return;
|
|
453
|
+
setText("");
|
|
454
|
+
const p = chat.picturesOn ? pics : [];
|
|
455
|
+
setPics([]);
|
|
456
|
+
setPicFailed(false);
|
|
457
|
+
void chat.send(m, p);
|
|
458
|
+
};
|
|
459
|
+
const decide = (all) => void chat.decide(decisionsFor(waiting.map((w) => w.id), { all, choice, edits }));
|
|
460
|
+
const outside = chat.outside ?? null;
|
|
461
|
+
const oneClick = waiting.length === 1 && (!!outside || (!render?.proposal && !render?.decisionBar));
|
|
462
|
+
const cl = chat.look;
|
|
463
|
+
const shownTitle = cl?.title ?? title;
|
|
464
|
+
const isLayout = (v) => LAYOUTS.includes(v);
|
|
465
|
+
const lay = isLayout(cl?.layout) ? cl.layout : isLayout(layout) ? layout : "docked";
|
|
466
|
+
const win = useWindowRect(lay === "window", side);
|
|
467
|
+
const panelStyleAll = width !== undefined || panelStyle || win.rect ? { ...(width !== undefined ? { "--cognolo-width": typeof width === "number" ? `${width}px` : width } : null), ...(win.rect ? win.vars : null), ...panelStyle } : undefined;
|
|
468
|
+
return (_jsxs("aside", { className: `cog-panel${side === "left" ? " cog-left" : ""}${panelClassName ? ` ${panelClassName}` : ""}`, style: panelStyleAll, role: "dialog", "aria-label": shownTitle, "data-cognolo-panel": true, "data-cognolo-hide": true, "data-layout": lay, children: [_jsxs("header", { className: "cog-head", onPointerDown: lay === "window" ? win.dragStart : undefined, children: [lay === "window" && _jsx("button", { type: "button", className: "cog-move", "aria-label": L.moveWindow, title: L.moveWindow, onKeyDown: win.moveKey, "data-cognolo-move": true, children: GRIP }), (badge?.logo || badge?.whiteLabel) && cleanLogo(cl?.logo) && _jsx("img", { className: "cog-logo", src: cl.logo, alt: "", "data-cognolo-logo": true }), _jsxs("h2", { children: [_jsx("span", { dir: "auto", children: shownTitle }), _jsx("span", { className: "cog-ai", "data-cognolo-ai": true, children: L.aiLine.trim() || DEFAULT_LABELS.aiLine })] }), _jsx("button", { type: "button", className: "cog-link", onClick: chat.restart, "data-cognolo-new": true, children: L.newChat }), onClose && _jsx("button", { type: "button", className: "cog-x", onClick: onClose, "aria-label": fill(L.close, { title: shownTitle }), children: "\u2715" })] }), badge && _jsx(BadgeBar, { badge: badge, L: L }), _jsxs("div", { ref: log, className: "cog-log", "data-cognolo-log": true, children: [transcript.length === 0 && (_jsxs("div", { className: "cog-intro", children: [cl?.greeting ? _jsx("p", { className: "cog-p0", dir: "auto", children: cl.greeting }) : _jsx("p", { className: "cog-p0", children: intro ?? L.intro }), Array.isArray(cl?.examples) && cl.examples.length
|
|
469
|
+
? _jsx("div", { className: "cog-eg", "data-cognolo-examples": "cloud", children: cl.examples.map((x) => _jsx("button", { type: "button", dir: "auto", onClick: () => { setText(x); input.current?.focus(); }, children: x }, x)) })
|
|
470
|
+
: examples && examples.length > 0 && _jsx("div", { className: "cog-eg", children: examples.map((x) => _jsx("button", { type: "button", disabled: busy, onClick: () => void chat.send(x), children: x }, x)) }), chat.workflows.length > 0 && (_jsxs("div", { className: "cog-wfs", "data-cognolo-workflows": true, children: [_jsx("h2", { className: "cog-wfh", id: "cog-wfh", children: L.workflows }), _jsx("ul", { "aria-labelledby": "cog-wfh", children: chat.workflows.map((w) => (_jsxs("li", { className: "cog-card", "data-workflow-offer": w.id, "data-from": w.from, children: [_jsx("h3", { children: w.name }), _jsx("span", { className: "cog-from", "data-origin": w.from, children: w.from === "admin" ? L.fromAdmin : L.yours }), w.summary && _jsx("p", { children: w.summary }), _jsx("p", { className: "cog-note", children: w.risk }), w.instructions && _jsxs("details", { className: "cog-more", children: [_jsx("summary", { children: L.readInstructions }), _jsx("p", { className: "cog-p0", children: w.instructions })] }), w.ready
|
|
471
|
+
? _jsx("div", { className: "cog-row", children: _jsx("button", { type: "button", className: "cog-btn", disabled: busy, onClick: () => void chat.runWorkflow(w.id), "aria-label": `${L.startWorkflow}: ${w.name}`, "data-start-workflow": true, children: L.startWorkflow }) })
|
|
472
|
+
: _jsx("p", { className: "cog-note cog-bad", "data-workflow-why": true, children: w.why })] }, w.id))) })] })), chat.recent.length > 0 && (_jsxs("div", { className: "cog-wfs", "data-cognolo-recent": true, children: [_jsx("h2", { className: "cog-wfh", id: "cog-recent", children: L.recent }), _jsx("ul", { "aria-labelledby": "cog-recent", className: "cog-recent", children: chat.recent.map((c) => (_jsx("li", { children: _jsxs("button", { type: "button", disabled: busy, onClick: () => void chat.openConversation(c.id), "data-open-conversation": c.id, children: [_jsx("span", { children: c.title }), _jsx("time", { dateTime: c.at, children: when(c.at) })] }) }, c.id))) })] }))] })), transcript.map((e, i) => {
|
|
473
|
+
if (e.t === "user" || e.t === "assistant") {
|
|
474
|
+
const mine = render?.message?.(e);
|
|
475
|
+
if (mine !== undefined)
|
|
476
|
+
return _jsx(Fragment, { children: mine }, i);
|
|
477
|
+
return e.t === "user"
|
|
478
|
+
? _jsxs(Fragment, { children: [_jsxs("p", { className: "cog-msg cog-user", "data-msg": e.t, children: [e.text, e.pics ? _jsxs("span", { className: "cog-pics", "data-cognolo-pics": true, children: [" \u00B7 ", e.pics === 1 ? L.pictureCount : fill(L.picturesCount, { n: e.pics })] }) : null] }), _jsx(MessageMeta, { text: e.text, at: e.at, mine: true, labels: L })] }, i)
|
|
479
|
+
: _jsxs(Fragment, { children: [_jsx("div", { className: "cog-msg cog-bot", "data-msg": e.t, children: rich(e.text, { refs: refsBelow.byId, go }) }), _jsx(MessageMeta, { text: plainReply(e.text), labels: L }), refList(refsBelow.below.get(i) ?? [], L, go, true), e.ask === "open" && chat.askAllow && _jsx("p", { className: "cog-note", "data-cognolo-ask": true, children: _jsx("button", { type: "button", className: "cog-link", disabled: busy, onClick: () => void chat.askAllow(), children: L.askAllow }) }), e.ask === "sent" && _jsx("p", { className: "cog-note", "data-cognolo-asked": true, children: L.askSent }), e.suggest?.state === "open" && chat.sendSuggestion && _jsxs("div", { className: "cog-note cog-suggest", "data-cognolo-suggest": true, children: [_jsxs("p", { className: "cog-p0", children: [L.suggestAsk, " ", _jsx("q", { dir: "auto", children: e.suggest.line }), " ", L.suggestNothing] }), _jsx("button", { type: "button", className: "cog-btn", disabled: busy, onClick: () => void chat.sendSuggestion(), children: L.suggestSend })] }), e.suggest?.state === "sent" && _jsx("p", { className: "cog-note", "data-cognolo-suggested": true, children: L.suggestSent })] }, i);
|
|
480
|
+
}
|
|
481
|
+
if (e.t === "proposal") {
|
|
482
|
+
const view = {
|
|
483
|
+
entry: e, pending: byId.get(e.id), waiting: e.status === "waiting", choice: choice[e.id], edited: e.id in edits, busy, labels: L, confirming: !!chat.confirming?.includes(e.id), needsPasskey: !!e.passkey && chat.passkey?.mode === "passkey",
|
|
484
|
+
actions: {
|
|
485
|
+
approve: () => setChoice((c) => ({ ...c, [e.id]: "approve" })),
|
|
486
|
+
decline: () => setChoice((c) => ({ ...c, [e.id]: "decline" })),
|
|
487
|
+
edit: (input) => { setEdits((x) => ({ ...x, [e.id]: input })); setChoice((c) => ({ ...c, [e.id]: "approve" })); },
|
|
488
|
+
},
|
|
489
|
+
};
|
|
490
|
+
const mine = outside ? undefined : render?.proposal?.(view);
|
|
491
|
+
if (mine !== undefined)
|
|
492
|
+
return _jsx(Fragment, { children: mine }, i);
|
|
493
|
+
if (oneClick && view.waiting) {
|
|
494
|
+
const sending = { ...view, actions: { ...view.actions, approve: () => { if (!busy)
|
|
495
|
+
decide("approve"); }, decline: () => { if (!busy)
|
|
496
|
+
decide("decline"); } } };
|
|
497
|
+
return _jsx(Card, { view: sending, sends: true, outside: !!outside }, i);
|
|
498
|
+
}
|
|
499
|
+
return _jsx(Card, { view: view, outside: !!outside }, i);
|
|
500
|
+
}
|
|
501
|
+
if (e.t === "shortened")
|
|
502
|
+
return _jsx("p", { className: "cog-note", "data-cognolo-shortened": true, children: L.shortened }, i);
|
|
503
|
+
if (e.t === "step")
|
|
504
|
+
return _jsx("p", { className: "cog-note", "data-step": e.kind, children: e.kind === "end" ? (e.name === "Finished" ? L.stepsDone : e.name) : _jsxs(_Fragment, { children: [L.step.replace("{n}", String(e.n)), " ", _jsx("b", { children: e.name }), e.round ? ` · ${L.round.replace("{n}", String(e.round))}` : "", e.kind === "lookup" ? ` · ${L.lookupStep}` : "", e.kind === "check" ? ` · ${L.stepWaits}` : ""] }) }, i);
|
|
505
|
+
if (e.t === "path")
|
|
506
|
+
return _jsx("p", { className: "cog-note", "data-path": e.by, children: (e.by === "person" ? L.pathByPerson : L.pathByAssistant).replace("{label}", e.label) }, i);
|
|
507
|
+
if (e.t === "workflow")
|
|
508
|
+
return _jsxs("p", { className: "cog-note", "data-workflow": true, "data-from": e.from, children: [L.workflowStarted, " ", _jsx("b", { children: e.name }), e.from === "admin" && _jsx("span", { className: "cog-from", "data-origin": "admin", children: L.fromAdmin })] }, i);
|
|
509
|
+
const mine = render?.activity?.(e);
|
|
510
|
+
if (mine !== undefined)
|
|
511
|
+
return _jsx(Fragment, { children: mine }, i);
|
|
512
|
+
if (e.t === "activity") {
|
|
513
|
+
const line = _jsxs("p", { className: `cog-note${e.ok ? "" : " cog-bad"}`, "data-activity": true, children: [e.ok ? "✓" : "!", " ", _jsx("b", { children: e.title }), " \u00B7 ", e.summary] });
|
|
514
|
+
const links = refsBelow.absorbed.has(i) ? [] : linkable(e.refs);
|
|
515
|
+
return _jsxs(Fragment, { children: [line, refList(links, L, go), webList(e.web, L)] }, i);
|
|
516
|
+
}
|
|
517
|
+
if (e.t === "noted")
|
|
518
|
+
return _jsxs("p", { className: "cog-note", "data-noted": true, children: [L.noted, " ", _jsx("b", { children: e.title }), " \u00B7 ", e.preview] }, i);
|
|
519
|
+
return _jsxs("p", { className: "cog-note cog-bad", "data-refused": true, children: [L.refused, " ", _jsx("b", { children: e.title }), " \u00B7 ", e.reason] }, i);
|
|
520
|
+
}), busy && _jsx("p", { className: "cog-note", "aria-live": "polite", "data-cognolo-busy": true, children: L.working }), error && _jsx("p", { role: "alert", className: "cog-err", "data-cognolo-error": true, children: error })] }), waiting.length === 0 && chat.run?.hold && !chat.run.finished && (_jsx("div", { className: "cog-bar", "data-continue-bar": true, children: chat.run.hold === "choose" && chat.run.options?.length ? (_jsxs(_Fragment, { children: [_jsx("p", { children: L.pickPath }), _jsx("div", { className: "cog-row cog-r0", children: chat.run.options.map((x) => _jsx("button", { type: "button", className: "cog-btn", disabled: busy, onClick: () => void chat.continueRun(x), "data-path-choice": true, children: x }, x)) })] })) : _jsx("button", { type: "button", className: "cog-btn cog-yes", disabled: busy, onClick: () => void chat.continueRun(), "data-continue": true, children: L.continueRun }) })), chat.passkey?.mode === "passkey" && (chat.passkey.wanted || transcript.some((x) => x.t === "proposal" && x.status === "waiting" && x.passkey)) && (chat.passkey.keys.length
|
|
521
|
+
? _jsxs("p", { className: "cog-note", "data-passkey-keys": true, children: [fill(L.passkeyYours, { list: chat.passkey.keys.map((k) => new Date(k.createdAt).toLocaleDateString(undefined, { day: "numeric", month: "short", year: "numeric" })).join(", ") }), " ", _jsx("button", { type: "button", className: "cog-link", disabled: busy, onClick: () => void chat.setUpPasskey?.(), children: L.passkeyAdd })] })
|
|
522
|
+
: chat.passkey.held
|
|
523
|
+
? _jsx("p", { className: "cog-note", "data-passkey-held": true, children: L.passkeyHeld })
|
|
524
|
+
: _jsx("div", { className: "cog-row", "data-passkey-setup": true, children: _jsx("button", { type: "button", className: "cog-btn", disabled: busy, onClick: () => void chat.setUpPasskey?.(), children: L.passkeySetUp }) })), waiting.length > 0 && !oneClick && (() => {
|
|
525
|
+
const ready = waiting.every((w) => choice[w.id]);
|
|
526
|
+
const mine = render?.decisionBar?.({
|
|
527
|
+
count: waiting.length, busy, canConfirm: ready,
|
|
528
|
+
approveAll: () => { if (!busy)
|
|
529
|
+
decide("approve"); },
|
|
530
|
+
confirmChoices: () => { if (!busy && ready)
|
|
531
|
+
decide(); },
|
|
532
|
+
declineAll: () => { if (!busy)
|
|
533
|
+
decide("decline"); },
|
|
534
|
+
});
|
|
535
|
+
if (mine || mine === 0)
|
|
536
|
+
return _jsx("div", { className: "cog-bar", "data-decision-bar": true, "data-custom": true, children: mine });
|
|
537
|
+
return (_jsxs("div", { className: "cog-bar", "data-decision-bar": true, children: [_jsx("p", { children: waiting.length === 1 ? L.waitingOne : fill(L.waitingMany, { n: waiting.length }) }), _jsxs("div", { className: "cog-row cog-r0", children: [waiting.length > 1 && _jsx("button", { type: "button", className: "cog-btn cog-yes", disabled: busy, onClick: () => decide("approve"), "data-approve-all": true, children: L.approveAll }), waiting.length > 1 && _jsx("button", { type: "button", className: "cog-btn", disabled: busy || !waiting.every((w) => choice[w.id]), onClick: () => decide(), "data-confirm-choices": true, children: L.confirmChoices }), waiting.length === 1 && _jsx("button", { type: "button", className: "cog-btn cog-yes", disabled: busy, onClick: () => decide("approve"), "data-approve-one": true, children: L.approve }), _jsx("button", { type: "button", className: "cog-btn", disabled: busy, onClick: () => decide("decline"), "data-decline-all": true, children: waiting.length === 1 ? L.decline : L.declineAll })] })] }));
|
|
538
|
+
})(), badge?.limited && _jsx("p", { className: "cog-limited", role: "status", "data-cognolo-limited": true, children: L.unreachable }), badge?.notice && _jsx("p", { className: "cog-limited", role: "status", "data-cognolo-notice": true, children: badge.notice }), chat.picturesOn && (pics.length > 0 || picFailed) && (_jsxs("div", { className: "cog-picrow", "data-cognolo-picrow": true, children: [pics.map((_, k) => _jsxs("button", { type: "button", "aria-label": `${L.removePicture} ${k + 1}`, onClick: () => setPics((p) => p.filter((_x, j) => j !== k)), children: [L.picture, " ", k + 1, " \u00D7"] }, k)), picFailed && _jsx("span", { role: "alert", children: L.pictureFailed }), pics.length > 0 && _jsx("span", { role: "status", children: L.pictureNote })] })), looksSensitive(text) && _jsx("p", { className: "cog-picrow", role: "status", "data-cognolo-sensitive": true, children: L.sensitiveTyped }), outside && outside.status !== "waiting" && _jsxs("p", { className: "cog-note", "data-cognolo-outside": outside.status, children: [OUTSIDE_ENDED[outside.status], " ", _jsx("button", { type: "button", className: "cog-link", onClick: chat.restart, children: L.newChat })] }), !outside && _jsxs("form", { className: "cog-form", onSubmit: submit, onDragOver: (e) => { if (chat.picturesOn && dragsImage(e.dataTransfer?.items))
|
|
539
|
+
e.preventDefault(); }, onDrop: (e) => { const f = chat.picturesOn ? imagesIn(e.dataTransfer?.files) : []; if (f.length) {
|
|
540
|
+
e.preventDefault();
|
|
541
|
+
void addPictures(f);
|
|
542
|
+
} }, children: [chat.picturesOn && _jsxs(_Fragment, { children: [_jsx("input", { ref: picInput, type: "file", accept: "image/png,image/jpeg,image/webp", multiple: true, hidden: true, onChange: (e) => { void addPictures(e.target.files ?? []); e.target.value = ""; } }), _jsx("button", { type: "button", className: "cog-attach", disabled: busy || pics.length >= 4, "aria-label": L.addPicture, title: `${L.addPicture}. ${L.pictureNote}`, onClick: () => picInput.current?.click(), "data-cognolo-attach": true, children: "\uFF0B" })] }), _jsx("input", { ref: input, onFocus: () => chat.wake?.(), onPaste: (e) => { const f = chat.picturesOn && !e.clipboardData?.getData("text/plain") ? imagesIn(e.clipboardData?.files) : []; if (f.length) {
|
|
543
|
+
e.preventDefault();
|
|
544
|
+
void addPictures(f);
|
|
545
|
+
} }, className: "cog-in", value: text, onChange: (e) => setText(e.target.value), placeholder: waiting.length ? L.placeholderWaiting : cl?.placeholder ?? L.placeholder, dir: "auto", "aria-label": L.messageBox, "data-cognolo-input": true }), _jsx("button", { className: "cog-send", disabled: busy || !text.trim() || shrinking > 0, "data-cognolo-send": true, children: L.send })] }), showCredit && _jsxs("a", { ref: credit, className: "cog-credit", href: "https://cognolo.com", target: "_blank", rel: "noopener", "data-cognolo-credit": true, children: [MARK, "Powered by Cognolo"] }), lay === "window" && _jsx("button", { type: "button", className: "cog-grip", "aria-label": L.resizeWindow, title: L.resizeWindow, onPointerDown: win.resizeStart, onKeyDown: win.resizeKey, "data-cognolo-resize": true })] }));
|
|
546
|
+
}
|
|
547
|
+
function inputLines(input) {
|
|
548
|
+
const cut = (x) => { const y = x.replace(HIDDEN_TEXT, " "); return y.length > 200 ? `${y.slice(0, 199)}…` : y; };
|
|
549
|
+
const val = (v) => cut(typeof v === "string" ? v : JSON.stringify(v) ?? String(v));
|
|
550
|
+
if (input && typeof input === "object" && !Array.isArray(input))
|
|
551
|
+
return Object.entries(input).slice(0, 20).map(([k, v]) => [cut(k), val(v)]);
|
|
552
|
+
return [["input", val(input)]];
|
|
553
|
+
}
|
|
554
|
+
export function ProposalCard({ view }) {
|
|
555
|
+
return _jsx(Card, { view: view });
|
|
556
|
+
}
|
|
557
|
+
function Card({ view, sends, outside }) {
|
|
558
|
+
const { entry: e, pending: p, choice: pick, edited, labels: L, actions } = view;
|
|
559
|
+
const [editing, setEditing] = useState(false);
|
|
560
|
+
const draft = p && !outside ? draftOf(p.input) : null;
|
|
561
|
+
const [settled, setSettled] = useState(!outside);
|
|
562
|
+
useEffect(() => { if (!outside)
|
|
563
|
+
return; setSettled(false); const t = setTimeout(() => setSettled(true), 1500); return () => clearTimeout(t); }, [outside, e.id]);
|
|
564
|
+
return (_jsxs("div", { className: `cog-card${view.waiting ? (e.risk === "irreversible" ? " cog-irr" : " cog-wait") : ""}`, "data-proposal": e.id, "data-status": e.status, children: [_jsxs("h3", { children: [e.title, e.risk === "irreversible" && _jsxs("span", { className: "cog-irrl", children: [" \u00B7 ", L.cannotBeUndone] })] }), outside && _jsx("p", { className: "cog-state", "data-outside-asked": true, children: _jsx("strong", { children: OUTSIDE_ASKED }) }), _jsx("p", { children: e.preview }), outside && p && _jsx("dl", { className: "cog-note cog-kv", "data-outside-input": true, children: inputLines(p.input).map(([k, v]) => _jsxs("div", { children: [_jsxs("dt", { children: [k, ":"] }), " ", _jsx("dd", { children: v })] }, k)) }), e.editedPreview && _jsxs("p", { "data-edited": true, children: [_jsx("b", { children: L.changedByYou }), " ", e.editedPreview] }), view.waiting && view.needsPasskey && (view.confirming
|
|
565
|
+
? _jsx("p", { className: "cog-state", role: "status", "data-passkey-confirm": true, children: _jsx("strong", { children: fill(edited ? L.passkeyConfirmEdited : L.passkeyConfirm, { what: e.preview }) }) })
|
|
566
|
+
: _jsx("p", { className: "cog-note", "data-passkey": true, children: L.passkeyLine })), !view.waiting ? _jsx("p", { className: `cog-state${e.status === "approved" ? " cog-ok" : ""}`, children: e.status === "approved" ? (e.editedPreview ? L.approvedEdited : L.approved) : L.declined }) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "cog-row", children: [sends ? _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "cog-btn cog-yes", disabled: view.busy || editing || !settled, onClick: actions.approve, "data-approve": true, "data-sends": true, children: L.approve }), _jsx("button", { type: "button", className: "cog-btn cog-no", disabled: view.busy, onClick: actions.decline, "data-decline": true, "data-sends": true, children: L.decline })] }) : _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "cog-btn", "aria-pressed": pick === "approve", disabled: !settled, onClick: actions.approve, "data-approve": true, children: L.approve }), _jsx("button", { type: "button", className: "cog-btn cog-no", "aria-pressed": pick === "decline", onClick: actions.decline, "data-decline": true, children: L.decline })] }), draft && _jsx("button", { type: "button", className: "cog-btn", onClick: () => setEditing((x) => !x), "aria-expanded": editing, "data-edit": true, children: edited ? L.changeAgain : L.change })] }), edited && !editing && _jsx("p", { className: "cog-state cog-ok", "data-edit-saved": true, children: L.willRunEdited }), sends && _jsx("p", { className: "cog-state", "data-waiting-line": true, children: L.waitingOne }), draft && editing && p && _jsx(EditForm, { original: p.input, draft: draft, L: L, onSave: (input) => { actions.edit(input); setEditing(false); }, onCancel: () => setEditing(false) })] }))] }));
|
|
567
|
+
}
|
|
568
|
+
function ago(d, L) {
|
|
569
|
+
const s = (Date.now() - d.getTime()) / 1000;
|
|
570
|
+
if (s < 60)
|
|
571
|
+
return L.justNow;
|
|
572
|
+
const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: "auto" });
|
|
573
|
+
if (s < 3600)
|
|
574
|
+
return rtf.format(-Math.floor(s / 60), "minute");
|
|
575
|
+
if (s < 86400)
|
|
576
|
+
return rtf.format(-Math.floor(s / 3600), "hour");
|
|
577
|
+
if (s < 7 * 86400)
|
|
578
|
+
return rtf.format(-Math.floor(s / 86400), "day");
|
|
579
|
+
return d.toLocaleDateString([], { month: "short", day: "numeric", ...(d.getFullYear() === new Date().getFullYear() ? {} : { year: "numeric" }) });
|
|
580
|
+
}
|
|
581
|
+
export const plainReply = (text) => text.replace(/ ?\[\[[^\]\n]{1,80}\]\]/g, "");
|
|
582
|
+
function MessageMeta({ text, at, mine, labels: L }) {
|
|
583
|
+
const [copied, setCopied] = useState(false);
|
|
584
|
+
const [, tick] = useState(0);
|
|
585
|
+
const d = at ? new Date(at) : null;
|
|
586
|
+
const dated = !!d && !Number.isNaN(d.getTime());
|
|
587
|
+
useEffect(() => { if (!dated)
|
|
588
|
+
return; const t = setInterval(() => tick((n) => n + 1), 60_000); return () => clearInterval(t); }, [dated]);
|
|
589
|
+
const copy = () => { void navigator.clipboard?.writeText(text).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1500); }, () => { }); };
|
|
590
|
+
return (_jsxs("div", { className: `cog-meta ${mine ? "cog-meta-mine" : "cog-meta-bot"}`, "data-cognolo-meta": true, children: [dated && _jsx("time", { dateTime: at, title: d.toLocaleString([], { dateStyle: "medium", timeStyle: "short" }), children: ago(d, L) }), _jsx("button", { type: "button", className: "cog-copy", onClick: copy, "aria-label": copied ? L.copied : L.copy, title: copied ? L.copied : L.copy, children: copied
|
|
591
|
+
? _jsx("svg", { width: "13", height: "13", viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "M3 8.5l3 3 7-7", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
592
|
+
: _jsxs("svg", { width: "13", height: "13", viewBox: "0 0 16 16", "aria-hidden": "true", children: [_jsx("rect", { x: "5", y: "5", width: "8.5", height: "8.5", rx: "1.8", fill: "none", stroke: "currentColor", strokeWidth: "1.4" }), _jsx("path", { d: "M10.5 3.2V3a1.5 1.5 0 0 0-1.5-1.5H3.8A1.8 1.8 0 0 0 2 3.3V9a1.5 1.5 0 0 0 1.5 1.5h.2", fill: "none", stroke: "currentColor", strokeWidth: "1.4" })] }) })] }));
|
|
593
|
+
}
|
|
594
|
+
const when = (at) => {
|
|
595
|
+
const d = new Date(at);
|
|
596
|
+
if (Number.isNaN(d.getTime()))
|
|
597
|
+
return "";
|
|
598
|
+
return d.toDateString() === new Date().toDateString() ? d.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : d.toLocaleDateString([], { month: "short", day: "numeric" });
|
|
599
|
+
};
|
|
600
|
+
function webList(web, L) {
|
|
601
|
+
const links = (web ?? []).map(outsideHref).filter((h) => !!h).slice(0, 5);
|
|
602
|
+
if (!links.length)
|
|
603
|
+
return null;
|
|
604
|
+
const site = (h) => { const s = new URL(h).hostname; return s.length > 40 ? `…${s.slice(-39)}` : s; };
|
|
605
|
+
return (_jsxs("div", { "data-refs": "web", children: [_jsx("p", { className: "cog-note cog-refs-more", children: L.fromWeb }), _jsx("ul", { className: "cog-refs", children: links.map((h) => _jsx("li", { children: _jsxs("a", { href: h, target: "_blank", rel: "noopener noreferrer nofollow", referrerPolicy: "no-referrer", "aria-label": fill(L.opensOutside, { site: new URL(h).hostname }), children: [site(h), " ", _jsx("span", { "aria-hidden": "true", children: "\u2197" })] }) }, h)) })] }));
|
|
606
|
+
}
|
|
607
|
+
const linkable = (refs) => (refs ?? []).filter((r) => !!safeHref(r.href));
|
|
608
|
+
function groupRefs(transcript) {
|
|
609
|
+
const below = new Map();
|
|
610
|
+
const absorbed = new Set();
|
|
611
|
+
const byId = new Map();
|
|
612
|
+
let waiting = [];
|
|
613
|
+
transcript.forEach((e, i) => {
|
|
614
|
+
if (e.t === "activity") {
|
|
615
|
+
const l = linkable(e.refs);
|
|
616
|
+
for (const r of l)
|
|
617
|
+
if (!byId.has(r.id))
|
|
618
|
+
byId.set(r.id, r);
|
|
619
|
+
if (l.length)
|
|
620
|
+
waiting.push(i);
|
|
621
|
+
}
|
|
622
|
+
else if (e.t === "assistant" && waiting.length) {
|
|
623
|
+
const seen = new Set();
|
|
624
|
+
below.set(i, waiting.flatMap((k) => linkable(transcript[k].refs)).filter((r) => !seen.has(`${r.kind}:${r.id}`) && !!seen.add(`${r.kind}:${r.id}`)));
|
|
625
|
+
waiting.forEach((k) => absorbed.add(k));
|
|
626
|
+
waiting = [];
|
|
627
|
+
}
|
|
628
|
+
else if (e.t === "user" || e.t === "step" || e.t === "workflow")
|
|
629
|
+
waiting = [];
|
|
630
|
+
});
|
|
631
|
+
return { below, absorbed, byId };
|
|
632
|
+
}
|
|
633
|
+
function refList(links, L, go, under = false) {
|
|
634
|
+
if (!links.length)
|
|
635
|
+
return null;
|
|
636
|
+
const chip = (r) => _jsx("li", { children: _jsx("a", { href: r.href, "data-ref": r.kind, onClick: (ev) => go(ev, r.href), children: r.label }) }, `${r.kind}:${r.id}`);
|
|
637
|
+
return (_jsxs("div", { className: under ? "cog-refs-under" : undefined, "data-refs": under ? "answer" : "activity", children: [_jsx("ul", { className: "cog-refs", children: links.slice(0, 3).map(chip) }), links.length > 3 && _jsxs("details", { className: "cog-more cog-refs-more", children: [_jsx("summary", { children: fill(L.moreLinks, { n: String(links.length - 3) }) }), _jsx("ul", { className: "cog-refs", children: links.slice(3).map(chip) })] })] }));
|
|
638
|
+
}
|
|
639
|
+
const LIST = /^\s*(?:[-*•]|(\d+)[.)])\s+(.*)$/;
|
|
640
|
+
const RECORD_MARK = /\s?\[\[((?:page:)?[A-Za-z0-9_-]{1,64})\]\]/g;
|
|
641
|
+
const words = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
642
|
+
function nameAt(before, label) {
|
|
643
|
+
const end = before.trimEnd();
|
|
644
|
+
const L = ` ${words(label)} `;
|
|
645
|
+
const starts = [...end.matchAll(/\S+/g)].map((m) => m.index);
|
|
646
|
+
for (let k = Math.min(6, starts.length); k >= 1; k--) {
|
|
647
|
+
const from = starts[starts.length - k];
|
|
648
|
+
const w = words(end.slice(from));
|
|
649
|
+
if (w.length >= 2 && L.includes(` ${w} `))
|
|
650
|
+
return from;
|
|
651
|
+
}
|
|
652
|
+
return -1;
|
|
653
|
+
}
|
|
654
|
+
const markLink = (r, o, key, name) => (_jsxs("a", { className: name ? "cog-mark cog-named" : "cog-mark", href: r.href, "data-ref": r.kind, title: r.label, ...(name ? {} : { "aria-label": r.label }), onClick: (ev) => o.go?.(ev, r.href), children: [name, _jsx("span", { "aria-hidden": "true", children: "\u2197" })] }, key));
|
|
655
|
+
function marks(s, o, key) {
|
|
656
|
+
const out = [];
|
|
657
|
+
let last = 0;
|
|
658
|
+
for (const m of s.matchAll(RECORD_MARK)) {
|
|
659
|
+
const before = s.slice(last, m.index);
|
|
660
|
+
last = m.index + m[0].length;
|
|
661
|
+
const r = o.refs?.get(m[1]);
|
|
662
|
+
if (!r) {
|
|
663
|
+
out.push(before);
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
const at = nameAt(before, r.label);
|
|
667
|
+
if (at < 0) {
|
|
668
|
+
out.push(before, markLink(r, o, `${key}-${m.index}`));
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
out.push(before.slice(0, at), markLink(r, o, `${key}-${m.index}`, before.trimEnd().slice(at)));
|
|
672
|
+
}
|
|
673
|
+
out.push(s.slice(last));
|
|
674
|
+
return out;
|
|
675
|
+
}
|
|
676
|
+
function inline(s, o = {}) {
|
|
677
|
+
const parts = s.split(/\*\*(.+?)\*\*/g);
|
|
678
|
+
const out = [];
|
|
679
|
+
for (let i = 0; i < parts.length; i++) {
|
|
680
|
+
const next = i % 2 && parts[i + 1] !== undefined ? /^\s?\[\[((?:page:)?[A-Za-z0-9_-]{1,64})\]\]/.exec(parts[i + 1]) : null;
|
|
681
|
+
const r = next ? o.refs?.get(next[1]) : undefined;
|
|
682
|
+
if (r && next && nameAt(parts[i], r.label) === 0) {
|
|
683
|
+
out.push(_jsx("b", { children: markLink(r, o, `n${i}`, parts[i]) }, i));
|
|
684
|
+
parts[i + 1] = parts[i + 1].slice(next[0].length);
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
out.push(i % 2 ? _jsx("b", { children: marks(parts[i], o, `b${i}`) }, i) : _jsx(Fragment, { children: marks(parts[i], o, `t${i}`) }, i));
|
|
688
|
+
}
|
|
689
|
+
return out;
|
|
690
|
+
}
|
|
691
|
+
export function rich(text, o = {}) {
|
|
692
|
+
const out = [];
|
|
693
|
+
const lines = text.split("\n");
|
|
694
|
+
for (let i = 0; i < lines.length;) {
|
|
695
|
+
const m = LIST.exec(lines[i]);
|
|
696
|
+
if (m) {
|
|
697
|
+
const ordered = !!m[1];
|
|
698
|
+
const items = [];
|
|
699
|
+
for (let x; i < lines.length && (x = LIST.exec(lines[i])) && !!x[1] === ordered; i++)
|
|
700
|
+
items.push(x[2]);
|
|
701
|
+
const lis = items.map((t, k) => _jsx("li", { children: inline(t, o) }, k));
|
|
702
|
+
out.push(ordered ? _jsx("ol", { children: lis }, out.length) : _jsx("ul", { children: lis }, out.length));
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
const chunk = [];
|
|
706
|
+
for (; i < lines.length && !LIST.exec(lines[i]); i++)
|
|
707
|
+
chunk.push(lines[i].replace(/^#{1,6}\s+(.*)$/, "**$1**"));
|
|
708
|
+
const t = chunk.join("\n").replace(/^\n+|\n+$/g, "");
|
|
709
|
+
if (t)
|
|
710
|
+
out.push(_jsx("span", { className: "cog-line", children: inline(t, o) }, out.length));
|
|
711
|
+
}
|
|
712
|
+
return out;
|
|
713
|
+
}
|
|
714
|
+
const levelOf = (pct, stops) => (pct >= 100 ? (stops ? "full" : "near") : pct >= 80 ? "near" : "ok");
|
|
715
|
+
function UseRow({ name, use, stops, L }) {
|
|
716
|
+
const shown = Math.min(100, use.pct);
|
|
717
|
+
return (_jsxs("div", { className: "cog-use", children: [_jsx("b", { children: name }), _jsx("span", { children: fill(L.usageOf, { pct: use.pct, of: use.of.toLocaleString() }) }), _jsxs("svg", { className: "cog-usebar", viewBox: "0 0 100 6", preserveAspectRatio: "none", role: "meter", "aria-label": name, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": shown, "aria-valuetext": fill(L.usageOf, { pct: use.pct, of: use.of.toLocaleString() }), "data-level": levelOf(use.pct, stops), children: [_jsx("rect", { className: "cog-ring-bg", width: "100", height: "6" }), _jsx("rect", { className: "cog-ring-fg", width: shown, height: "6" })] })] }));
|
|
718
|
+
}
|
|
719
|
+
function BadgeBar({ badge, L }) {
|
|
720
|
+
const [open, setOpen] = useState(false);
|
|
721
|
+
const detailsId = useId();
|
|
722
|
+
const resets = badge.meter ? new Date(`${badge.meter.resets}T00:00:00Z`) : null;
|
|
723
|
+
const m = badge.meter && resets && !Number.isNaN(resets.getTime()) && resets.getTime() > Date.now() ? badge.meter : undefined;
|
|
724
|
+
const uses = m ? [[L.usageToday, m.today], [L.usageQuestions, m.questions], [L.usageActions, m.actions]].filter((x) => !!x[1]) : [];
|
|
725
|
+
const lead = uses.reduce((best, x) => (!best || x[1].pct > best[1].pct ? x : best), null);
|
|
726
|
+
const C = 2 * Math.PI * 6;
|
|
727
|
+
const esc = (e) => { if (e.key === "Escape" && open) {
|
|
728
|
+
e.stopPropagation();
|
|
729
|
+
setOpen(false);
|
|
730
|
+
} };
|
|
731
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "cog-badge", "data-cognolo-badge": true, children: [badge.state && !isProduction(badge.env) && (() => { const tip = fill(badge.state === "ok" ? L.statusOk : badge.state === "old" ? L.statusOld : L.statusLimited, { time: badge.checkedAt ? new Date(badge.checkedAt).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "-" }); return _jsx("i", { className: `cog-dot cog-dot-${badge.state}`, role: "img", "aria-label": tip, title: tip, "data-cognolo-status": badge.state }); })(), _jsx("b", { className: isProduction(badge.env) ? "" : "cog-nonprod", children: badge.env }), _jsx("span", { children: badgeText({ ...badge, env: "" }, L.rulesVersion) }), m && lead && (_jsxs("button", { type: "button", className: "cog-ring", "data-cognolo-usage": true, "data-level": levelOf(lead[1].pct, m.stops), "aria-expanded": open, "aria-controls": detailsId, "aria-label": fill(L.usageRing, { name: lead[0], pct: lead[1].pct }), onClick: () => setOpen((o) => !o), onKeyDown: esc, children: [_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": "true", children: [_jsx("circle", { className: "cog-ring-bg", cx: "8", cy: "8", r: "6" }), _jsx("circle", { className: "cog-ring-fg", cx: "8", cy: "8", r: "6", strokeDasharray: `${(C * Math.min(100, lead[1].pct)) / 100} ${C}`, transform: "rotate(-90 8 8)" })] }), _jsxs("span", { "aria-hidden": "true", children: [Math.min(999, lead[1].pct), "%"] })] }))] }), m && open && (_jsxs("div", { className: "cog-usage", id: detailsId, "data-cognolo-usage-details": true, children: [_jsx("h3", { children: L.usageTitle }), _jsx(UseRow, { name: L.usageQuestions, use: m.questions, stops: m.stops, L: L }), m.today && _jsx(UseRow, { name: L.usageToday, use: m.today, stops: m.stops, L: L }), m.actions && _jsx(UseRow, { name: L.usageActions, use: m.actions, stops: m.stops, L: L }), _jsxs("p", { children: [m.testing ? L.usageSharedTest : fill(L.usageShared, { plan: m.plan }), " ", fill(L.usageResets, { date: resets.toLocaleDateString([], { month: "short", day: "numeric", timeZone: "UTC" }) }), m.today ? ` ${L.usageTodayResets}` : ""] }), _jsx("p", { children: m.testing ? L.usageStopsTest : m.stops ? L.usageStops : L.usageKeeps })] }))] }));
|
|
732
|
+
}
|
|
733
|
+
export function EditForm({ original, draft, L, onSave, onCancel }) {
|
|
734
|
+
const [d, setD] = useState(draft);
|
|
735
|
+
const [err, setErr] = useState(null);
|
|
736
|
+
const kinds = original;
|
|
737
|
+
const save = () => {
|
|
738
|
+
const r = editFrom(original, d, L);
|
|
739
|
+
if (r.ok)
|
|
740
|
+
onSave(r.input);
|
|
741
|
+
else
|
|
742
|
+
setErr(r.error);
|
|
743
|
+
};
|
|
744
|
+
return (_jsxs("div", { className: "cog-edit", "data-edit-form": true, children: [Object.keys(d).map((k) => {
|
|
745
|
+
const was = kinds[k];
|
|
746
|
+
const set = (v) => setD((x) => ({ ...x, [k]: v }));
|
|
747
|
+
return typeof was === "boolean" ? (_jsx("label", { children: _jsxs("span", { children: [_jsx("input", { type: "checkbox", checked: d[k] === true, onChange: (e) => set(e.target.checked) }), " ", k] }) }, k)) : typeof was === "string" || typeof was === "number" ? (_jsxs("label", { children: [k, _jsx("input", { type: typeof was === "number" ? "number" : "text", value: String(d[k]), onChange: (e) => set(e.target.value) })] }, k)) : (_jsxs("label", { children: [k, " ", L.jsonField, _jsx("textarea", { rows: 3, value: String(d[k]), onChange: (e) => set(e.target.value) })] }, k));
|
|
748
|
+
}), err && _jsx("p", { role: "alert", className: "cog-err", children: err }), _jsxs("div", { className: "cog-row cog-r0", children: [_jsx("button", { type: "button", className: "cog-btn cog-yes", onClick: save, "data-edit-save": true, children: L.useMyChanges }), _jsx("button", { type: "button", className: "cog-btn", onClick: onCancel, children: L.cancel })] })] }));
|
|
749
|
+
}
|