@celljs/ta-org 0.0.0-stage → 4.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +17 -0
- package/README.md +16 -2
- package/extension/index.mjs +465 -0
- package/host/index.mjs +1403 -0
- package/package.json +60 -3
- package/web/index.js +1895 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,1895 @@
|
|
|
1
|
+
// web-src/org-protocol.ts
|
|
2
|
+
var ROOT_DEPT = "all";
|
|
3
|
+
var ORG_MAX_DEPTS = 60;
|
|
4
|
+
var DEPT_ID = /^[a-z0-9][a-z0-9-]{0,23}$/;
|
|
5
|
+
var OrgUtil;
|
|
6
|
+
((OrgUtil) => {
|
|
7
|
+
function deptId(value) {
|
|
8
|
+
const id = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
9
|
+
return DEPT_ID.test(id) && id !== ROOT_DEPT ? id : undefined;
|
|
10
|
+
}
|
|
11
|
+
OrgUtil.deptId = deptId;
|
|
12
|
+
function doc(value, now) {
|
|
13
|
+
const doc2 = value;
|
|
14
|
+
if (doc2?.v !== 1 || !Array.isArray(doc2.depts) || !Array.isArray(doc2.places) || typeof doc2.at !== "number") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const ids = new Set([ROOT_DEPT]);
|
|
18
|
+
const depts = [{ id: ROOT_DEPT, name: "", parent: "", order: 0, leads: [] }];
|
|
19
|
+
for (const each of doc2.depts.slice(0, ORG_MAX_DEPTS)) {
|
|
20
|
+
const id = each?.id === ROOT_DEPT ? undefined : deptId(each?.id);
|
|
21
|
+
const name = typeof each?.name === "string" ? each.name.trim().slice(0, 40) : "";
|
|
22
|
+
if (!id || !name || ids.has(id)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
ids.add(id);
|
|
26
|
+
depts.push({
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
parent: typeof each.parent === "string" && ids.has(each.parent) ? each.parent : ROOT_DEPT,
|
|
30
|
+
order: Number.isFinite(each.order) ? Number(each.order) : depts.length,
|
|
31
|
+
leads: Array.isArray(each.leads) ? [...new Set(each.leads.filter((lead) => typeof lead === "string"))].slice(0, 20) : []
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const places = [];
|
|
35
|
+
const seen = new Set;
|
|
36
|
+
for (const each of doc2.places.slice(0, 500)) {
|
|
37
|
+
const member = typeof each?.member === "string" ? each.member : "";
|
|
38
|
+
if (!member || seen.has(member)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
seen.add(member);
|
|
42
|
+
const deptsIn = Array.isArray(each.depts) ? [...new Set(each.depts.filter((dept) => ids.has(dept)))].slice(0, 8) : [];
|
|
43
|
+
const manager = each.manager && typeof each.manager.name === "string" ? { ...typeof each.manager.id === "string" ? { id: each.manager.id } : {}, name: each.manager.name.slice(0, 40) } : undefined;
|
|
44
|
+
places.push({
|
|
45
|
+
member,
|
|
46
|
+
depts: deptsIn.length ? deptsIn : [ROOT_DEPT],
|
|
47
|
+
...manager ? { manager } : {},
|
|
48
|
+
at: typeof each.at === "number" ? each.at : now
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
v: 1,
|
|
53
|
+
...typeof doc2.name === "string" && doc2.name.trim() ? { name: doc2.name.trim().slice(0, 60) } : {},
|
|
54
|
+
...typeof doc2.about === "string" && doc2.about.trim() ? { about: doc2.about.trim().slice(0, 300) } : {},
|
|
55
|
+
depts,
|
|
56
|
+
places,
|
|
57
|
+
rules: OrgUtil.rules(doc2.rules),
|
|
58
|
+
at: doc2.at
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
OrgUtil.doc = doc;
|
|
62
|
+
function rules(value) {
|
|
63
|
+
const rules2 = value ?? {};
|
|
64
|
+
return {
|
|
65
|
+
...rules2.ask === false ? {} : { ask: true },
|
|
66
|
+
...rules2.review === false ? {} : { review: true },
|
|
67
|
+
...rules2.see === "dept" || rules2.see === "self" ? { see: rules2.see } : {},
|
|
68
|
+
...rules2.pin === true ? { pin: true } : {}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
OrgUtil.rules = rules;
|
|
72
|
+
function latest(docs, admin, members) {
|
|
73
|
+
const order = new Map(members.map((each, index) => [each.member, index]));
|
|
74
|
+
return docs.filter((each) => admin(members.find((member) => member.member === each.by) ?? { member: "" })).sort((a, b) => b.at - a.at || (order.get(b.by) ?? -1) - (order.get(a.by) ?? -1))[0];
|
|
75
|
+
}
|
|
76
|
+
OrgUtil.latest = latest;
|
|
77
|
+
function fold(docs, members) {
|
|
78
|
+
if (!docs.length) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const order = new Map(members.map((each, index) => [each.member, index]));
|
|
82
|
+
const sorted = [...docs].sort((a, b) => a.at - b.at || (order.get(a.by) ?? -1) - (order.get(b.by) ?? -1));
|
|
83
|
+
let out = sorted[0].body;
|
|
84
|
+
for (const { body } of sorted.slice(1)) {
|
|
85
|
+
const depts = new Map(out.depts.map((dept) => [dept.id, { dept, at: out.at }]));
|
|
86
|
+
for (const dept of body.depts) {
|
|
87
|
+
depts.set(dept.id, { dept, at: body.at });
|
|
88
|
+
}
|
|
89
|
+
const places = new Map(out.places.map((place) => [place.member, place]));
|
|
90
|
+
for (const place of body.places) {
|
|
91
|
+
const known = places.get(place.member);
|
|
92
|
+
if (!known || place.at >= known.at) {
|
|
93
|
+
places.set(place.member, place);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
out = {
|
|
97
|
+
v: 1,
|
|
98
|
+
...body.name !== undefined ? { name: body.name } : out.name !== undefined ? { name: out.name } : {},
|
|
99
|
+
...body.about !== undefined ? { about: body.about } : out.about !== undefined ? { about: out.about } : {},
|
|
100
|
+
depts: [...depts.values()].map(({ dept }) => dept),
|
|
101
|
+
places: [...places.values()],
|
|
102
|
+
rules: body.rules,
|
|
103
|
+
at: Math.max(out.at, body.at)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
OrgUtil.fold = fold;
|
|
109
|
+
function nest(depts, id, above = false) {
|
|
110
|
+
const under = new Set([id]);
|
|
111
|
+
let grew = true;
|
|
112
|
+
while (grew) {
|
|
113
|
+
grew = false;
|
|
114
|
+
for (const dept of depts) {
|
|
115
|
+
if (!under.has(dept.id) && under.has(dept.parent)) {
|
|
116
|
+
under.add(dept.id);
|
|
117
|
+
grew = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (!above) {
|
|
122
|
+
return [...under];
|
|
123
|
+
}
|
|
124
|
+
const all = new Set(under);
|
|
125
|
+
let parent = depts.find((dept) => dept.id === id)?.parent;
|
|
126
|
+
while (parent && !all.has(parent)) {
|
|
127
|
+
all.add(parent);
|
|
128
|
+
parent = depts.find((dept) => dept.id === parent)?.parent;
|
|
129
|
+
}
|
|
130
|
+
return [...all];
|
|
131
|
+
}
|
|
132
|
+
OrgUtil.nest = nest;
|
|
133
|
+
function sees(doc2, member) {
|
|
134
|
+
const see = doc2.rules.see ?? "all";
|
|
135
|
+
if (see === "all") {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const place = doc2.places.find((each) => each.member === member);
|
|
139
|
+
const mine = place?.depts ?? [ROOT_DEPT];
|
|
140
|
+
return new Set(see === "self" ? mine : mine.flatMap((dept) => [...OrgUtil.nest(doc2.depts, dept), ...OrgUtil.nest(doc2.depts, dept, true)]));
|
|
141
|
+
}
|
|
142
|
+
OrgUtil.sees = sees;
|
|
143
|
+
function leads(doc2, member) {
|
|
144
|
+
const found = new Set;
|
|
145
|
+
for (const dept of doc2.places.find((each) => each.member === member)?.depts ?? [ROOT_DEPT]) {
|
|
146
|
+
for (const id of OrgUtil.nest(doc2.depts, dept, true)) {
|
|
147
|
+
for (const lead of doc2.depts.find((each) => each.id === id)?.leads ?? []) {
|
|
148
|
+
if (lead !== member) {
|
|
149
|
+
found.add(lead);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return [...found];
|
|
155
|
+
}
|
|
156
|
+
OrgUtil.leads = leads;
|
|
157
|
+
function opens(scope2, me, depts) {
|
|
158
|
+
if (scope2.kind === "all") {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
if (scope2.kind === "people") {
|
|
162
|
+
return scope2.people.includes(me);
|
|
163
|
+
}
|
|
164
|
+
return depts.some((dept) => scope2.depts.includes(dept));
|
|
165
|
+
}
|
|
166
|
+
OrgUtil.opens = opens;
|
|
167
|
+
function scope(scope2) {
|
|
168
|
+
const value = scope2;
|
|
169
|
+
if (value?.kind === "depts" && Array.isArray(value.depts)) {
|
|
170
|
+
return { kind: "depts", depts: value.depts.filter((dept) => typeof dept === "string").slice(0, ORG_MAX_DEPTS) };
|
|
171
|
+
}
|
|
172
|
+
if (value?.kind === "people" && Array.isArray(value.people)) {
|
|
173
|
+
return { kind: "people", people: value.people.filter((person) => typeof person === "string").slice(0, 200) };
|
|
174
|
+
}
|
|
175
|
+
return { kind: "all" };
|
|
176
|
+
}
|
|
177
|
+
OrgUtil.scope = scope;
|
|
178
|
+
function card(value, now) {
|
|
179
|
+
const card2 = value;
|
|
180
|
+
const id = typeof card2?.id === "string" ? card2.id.trim() : "";
|
|
181
|
+
const name = typeof card2?.name === "string" ? card2.name.trim().slice(0, 60) : "";
|
|
182
|
+
if (!card2 || !id || !name) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
id,
|
|
187
|
+
name,
|
|
188
|
+
...typeof card2.about === "string" && card2.about.trim() ? { about: card2.about.trim().slice(0, 300) } : {},
|
|
189
|
+
scope: OrgUtil.scope(card2.scope),
|
|
190
|
+
at: typeof card2.at === "number" ? card2.at : now
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
OrgUtil.card = card;
|
|
194
|
+
function roleOf(room) {
|
|
195
|
+
if (room?.status !== "member") {
|
|
196
|
+
return "none";
|
|
197
|
+
}
|
|
198
|
+
return room.owner ? "owner" : room.admin ? "admin" : "member";
|
|
199
|
+
}
|
|
200
|
+
OrgUtil.roleOf = roleOf;
|
|
201
|
+
function manages(room) {
|
|
202
|
+
return !!room && (room.owner || room.admin === true);
|
|
203
|
+
}
|
|
204
|
+
OrgUtil.manages = manages;
|
|
205
|
+
})(OrgUtil ||= {});
|
|
206
|
+
|
|
207
|
+
// ../ta-protocol/esm/common/language.js
|
|
208
|
+
var TaLanguageUtil;
|
|
209
|
+
(function(TaLanguageUtil2) {
|
|
210
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
211
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
212
|
+
function of(tag) {
|
|
213
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
214
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
215
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
216
|
+
}
|
|
217
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
218
|
+
}
|
|
219
|
+
TaLanguageUtil2.of = of;
|
|
220
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
221
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
222
|
+
}
|
|
223
|
+
TaLanguageUtil2.server = server;
|
|
224
|
+
function pick(language, words) {
|
|
225
|
+
return words[of(language)];
|
|
226
|
+
}
|
|
227
|
+
TaLanguageUtil2.pick = pick;
|
|
228
|
+
function say(words) {
|
|
229
|
+
return words[server()];
|
|
230
|
+
}
|
|
231
|
+
TaLanguageUtil2.say = say;
|
|
232
|
+
function chinese(language) {
|
|
233
|
+
return of(language).startsWith("zh");
|
|
234
|
+
}
|
|
235
|
+
TaLanguageUtil2.chinese = chinese;
|
|
236
|
+
function cjk(language) {
|
|
237
|
+
return of(language) !== "en-US";
|
|
238
|
+
}
|
|
239
|
+
TaLanguageUtil2.cjk = cjk;
|
|
240
|
+
function list(language, items) {
|
|
241
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
242
|
+
}
|
|
243
|
+
TaLanguageUtil2.list = list;
|
|
244
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
245
|
+
|
|
246
|
+
// ../ta-web/esm/browser/state/store-steady.js
|
|
247
|
+
var StoreSteady;
|
|
248
|
+
(function(StoreSteady2) {
|
|
249
|
+
const unsteady = new Map;
|
|
250
|
+
let reported = 0;
|
|
251
|
+
function same(last, next) {
|
|
252
|
+
if (last && (Object.is(last.value, next) || shallowSame(last.value, next))) {
|
|
253
|
+
return last.value;
|
|
254
|
+
}
|
|
255
|
+
return next;
|
|
256
|
+
}
|
|
257
|
+
StoreSteady2.same = same;
|
|
258
|
+
function noticed(name) {
|
|
259
|
+
var _a;
|
|
260
|
+
const count = ((_a = unsteady.get(name)) !== null && _a !== undefined ? _a : 0) + 1;
|
|
261
|
+
unsteady.set(name, count);
|
|
262
|
+
publish();
|
|
263
|
+
if (count === 1 || count % 100 === 0) {
|
|
264
|
+
const now = Date.now();
|
|
265
|
+
if (now - reported > 5000) {
|
|
266
|
+
reported = now;
|
|
267
|
+
console.warn(`The store ${name} gives a new snapshot with the same in it (${count} times): keep one object while it holds the same (useStore of @celljs/ta-web).`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
StoreSteady2.noticed = noticed;
|
|
272
|
+
function take() {
|
|
273
|
+
const taken = Object.fromEntries(unsteady);
|
|
274
|
+
unsteady.clear();
|
|
275
|
+
publish();
|
|
276
|
+
return taken;
|
|
277
|
+
}
|
|
278
|
+
StoreSteady2.take = take;
|
|
279
|
+
function label(snapshot) {
|
|
280
|
+
const text = snapshot.toString().replace(/\s+/g, " ").trim();
|
|
281
|
+
return text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
282
|
+
}
|
|
283
|
+
StoreSteady2.label = label;
|
|
284
|
+
function read(kept, snapshot) {
|
|
285
|
+
const next = snapshot();
|
|
286
|
+
const last = kept.current;
|
|
287
|
+
if (last && Object.is(last.raw, next)) {
|
|
288
|
+
return last.value;
|
|
289
|
+
}
|
|
290
|
+
const value = same(last, next);
|
|
291
|
+
if (!Object.is(value, next) && !Object.is(snapshot(), next)) {
|
|
292
|
+
noticed(label(snapshot));
|
|
293
|
+
}
|
|
294
|
+
kept.current = { value, raw: next };
|
|
295
|
+
return value;
|
|
296
|
+
}
|
|
297
|
+
StoreSteady2.read = read;
|
|
298
|
+
function publish() {
|
|
299
|
+
const page = globalThis;
|
|
300
|
+
if (!page.__taUnsteadyStores) {
|
|
301
|
+
page.__taUnsteadyStores = new Map;
|
|
302
|
+
}
|
|
303
|
+
page.__taUnsteadyStores.set(unsteady, Object.fromEntries(unsteady));
|
|
304
|
+
}
|
|
305
|
+
function shallowSame(a, b) {
|
|
306
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
307
|
+
return a.length === b.length && a.every((item, index) => Object.is(item, b[index]));
|
|
308
|
+
}
|
|
309
|
+
if (isRecord(a) && isRecord(b)) {
|
|
310
|
+
const keys = Object.keys(a);
|
|
311
|
+
return keys.length === Object.keys(b).length && keys.every((key) => (key in b) && Object.is(a[key], b[key]));
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
function isRecord(value) {
|
|
316
|
+
if (value === null || typeof value !== "object") {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const prototype = Object.getPrototypeOf(value);
|
|
320
|
+
return prototype === Object.prototype || prototype === null;
|
|
321
|
+
}
|
|
322
|
+
})(StoreSteady || (StoreSteady = {}));
|
|
323
|
+
function useSteadyStore(react, subscribe, snapshot, server) {
|
|
324
|
+
const kept = react.useRef(undefined);
|
|
325
|
+
const read = () => StoreSteady.read(kept, snapshot);
|
|
326
|
+
return react.useSyncExternalStore(subscribe, read, server !== null && server !== undefined ? server : read);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// web-src/org-i18n.ts
|
|
330
|
+
var EN = {
|
|
331
|
+
title: "Directory",
|
|
332
|
+
summary: "An enterprise directory of the company’s own Ta: departments and leads, who comes in, the agents each publishes.",
|
|
333
|
+
empty: "No company yet",
|
|
334
|
+
emptyHint: "Make one for your company, or come in by the link an admin sent you.",
|
|
335
|
+
make: "Make one",
|
|
336
|
+
makeName: "Name of the company",
|
|
337
|
+
makePlaceholder: "e.g. Acme",
|
|
338
|
+
join: "Come in by a link",
|
|
339
|
+
joinPlaceholder: "The link an admin sent you",
|
|
340
|
+
joined: "Asked to come in: an admin of the company agrees.",
|
|
341
|
+
members: "{n} people",
|
|
342
|
+
tabPeople: "People",
|
|
343
|
+
tabAgents: "Agents",
|
|
344
|
+
tabAdmin: "Admin",
|
|
345
|
+
all: "Everyone",
|
|
346
|
+
none: "Not in a department",
|
|
347
|
+
invited: "Invited",
|
|
348
|
+
online: "Online",
|
|
349
|
+
lead: "Lead",
|
|
350
|
+
managerAxis: "Reports to",
|
|
351
|
+
department: "Department",
|
|
352
|
+
noProfile: "Nothing told yet",
|
|
353
|
+
card: "Card",
|
|
354
|
+
cardTitle: "Title",
|
|
355
|
+
cardAbout: "What you work on",
|
|
356
|
+
cardStaff: "Staff id",
|
|
357
|
+
cardMail: "Mail",
|
|
358
|
+
cardPhone: "Phone",
|
|
359
|
+
save: "Save",
|
|
360
|
+
saved: "Saved",
|
|
361
|
+
agentsEmpty: "No agent published yet",
|
|
362
|
+
agentsHint: "Publish an agent of yours and your colleagues see it here, and may pull it into a group chat.",
|
|
363
|
+
publish: "Publish an agent",
|
|
364
|
+
published: "Published",
|
|
365
|
+
unpublish: "Take it off",
|
|
366
|
+
waiting: "Waits for an admin",
|
|
367
|
+
scope: "Who sees it",
|
|
368
|
+
scopeAll: "Everyone",
|
|
369
|
+
scopeDepts: "Departments",
|
|
370
|
+
scopePeople: "People",
|
|
371
|
+
about: "What it does",
|
|
372
|
+
pull: "Pull into a group chat",
|
|
373
|
+
pulled: "Asked",
|
|
374
|
+
pulledWait: "Asks {name}, waiting for their yes",
|
|
375
|
+
answeredYes: "{name} agreed: it came into the group chat.",
|
|
376
|
+
answeredNo: "{name} said no.",
|
|
377
|
+
pullAsks: "Asked into group chats",
|
|
378
|
+
pullAsk: "{name} asks it into “{group}”: agree, and you come in with it",
|
|
379
|
+
hosted: "In your group chats",
|
|
380
|
+
recall: "Take it out",
|
|
381
|
+
doubts: "Your agents in group chats of this company",
|
|
382
|
+
review: "Agents to agree",
|
|
383
|
+
agree: "Agree",
|
|
384
|
+
refuse: "No",
|
|
385
|
+
request: "Asks to come in",
|
|
386
|
+
requests: "People asking to come in",
|
|
387
|
+
accept: "Let in",
|
|
388
|
+
decline: "No",
|
|
389
|
+
invite: "Invite colleagues",
|
|
390
|
+
inviteHint: "They come in on their word, once an admin agrees.",
|
|
391
|
+
inviteLink: "Send a link",
|
|
392
|
+
linkTitle: "Come into {name}",
|
|
393
|
+
linkGets: "Open it in Ta to ask to come in",
|
|
394
|
+
manage: "Admin",
|
|
395
|
+
companyName: "Name of the company",
|
|
396
|
+
settings: "Rules",
|
|
397
|
+
ask: "An admin agrees to each one who comes in",
|
|
398
|
+
askHint: "Off: one with the link comes in at once.",
|
|
399
|
+
reviewLabel: "An admin agrees to each agent published",
|
|
400
|
+
reviewHint: "Off: an agent is in the directory as soon as it is published.",
|
|
401
|
+
deptTop: "At the top",
|
|
402
|
+
deptUnderOf: "Under {name}",
|
|
403
|
+
cancel: "Cancel",
|
|
404
|
+
pinLabel: "Pin the directory to everyone’s navigation",
|
|
405
|
+
pinHint: "Each one may still take it out.",
|
|
406
|
+
see: "What members see",
|
|
407
|
+
seeAll: "Everyone, every department",
|
|
408
|
+
seeDept: "Theirs and those under it",
|
|
409
|
+
seeSelf: "Themselves only",
|
|
410
|
+
depts: "Departments",
|
|
411
|
+
deptName: "Name of the department",
|
|
412
|
+
deptUnder: "Under",
|
|
413
|
+
addDept: "Add a department",
|
|
414
|
+
place: "Department and manager",
|
|
415
|
+
placeOf: "Where {name} sits",
|
|
416
|
+
deptsOf: "Departments, one each line",
|
|
417
|
+
managerOf: "Reports to",
|
|
418
|
+
nobody: "Nobody",
|
|
419
|
+
out: "Take out",
|
|
420
|
+
outAsk: "Take {name} out of the company?",
|
|
421
|
+
outHint: "Their card and agents go; what they did in group chats stays.",
|
|
422
|
+
leave: "Leave",
|
|
423
|
+
leaveAsk: "Leave {name}?",
|
|
424
|
+
oldApp: "Update Ta to use the directory.",
|
|
425
|
+
oldServer: "Update Ta on the computer to use the directory.",
|
|
426
|
+
busy: "A moment…",
|
|
427
|
+
copy: "Copy",
|
|
428
|
+
done: "Done",
|
|
429
|
+
pending: "Waiting",
|
|
430
|
+
others: "Everyone else",
|
|
431
|
+
me: "You",
|
|
432
|
+
owner: "Owner",
|
|
433
|
+
admin: "Admin",
|
|
434
|
+
member: "Member",
|
|
435
|
+
companyDepts: "Departments",
|
|
436
|
+
noneYet: "None yet",
|
|
437
|
+
noGroup: "No group chat you lead yet",
|
|
438
|
+
pickGroup: "The group chat",
|
|
439
|
+
askPull: "Ask {name} to bring {agent} into the group chat? They come in with it, as a member.",
|
|
440
|
+
pullAsked: "Asked {name}. Once they agree in their own Ta, they and {agent} come into the group chat."
|
|
441
|
+
};
|
|
442
|
+
var ZH = {
|
|
443
|
+
title: "通讯录",
|
|
444
|
+
summary: "企业通讯录,就跑在公司的 Ta 之间:部门与负责人、谁进来、每人发布的智能体。",
|
|
445
|
+
empty: "还没有公司",
|
|
446
|
+
emptyHint: "为你的公司建一个,或者用管理员发你的链接进来。",
|
|
447
|
+
make: "建一个",
|
|
448
|
+
makeName: "公司叫什么",
|
|
449
|
+
makePlaceholder: "例如:某某科技",
|
|
450
|
+
join: "用链接进来",
|
|
451
|
+
joinPlaceholder: "管理员发你的链接",
|
|
452
|
+
joined: "已申请进来:公司管理员同意后就到了。",
|
|
453
|
+
members: "{n} 人",
|
|
454
|
+
tabPeople: "同事",
|
|
455
|
+
tabAgents: "智能体",
|
|
456
|
+
tabAdmin: "管理",
|
|
457
|
+
all: "所有人",
|
|
458
|
+
none: "没有分部门",
|
|
459
|
+
invited: "已邀请",
|
|
460
|
+
online: "在线",
|
|
461
|
+
lead: "负责人",
|
|
462
|
+
managerAxis: "汇报给",
|
|
463
|
+
department: "部门",
|
|
464
|
+
noProfile: "还没写",
|
|
465
|
+
card: "我的名片",
|
|
466
|
+
cardTitle: "职位",
|
|
467
|
+
cardAbout: "在做什么",
|
|
468
|
+
cardStaff: "工号",
|
|
469
|
+
cardMail: "邮箱",
|
|
470
|
+
cardPhone: "电话",
|
|
471
|
+
save: "保存",
|
|
472
|
+
saved: "已保存",
|
|
473
|
+
agentsEmpty: "还没有智能体",
|
|
474
|
+
agentsHint: "发布一个自己的智能体,同事就能在这里看到,并把它拉进群聊一起干活。",
|
|
475
|
+
publish: "发布一个智能体",
|
|
476
|
+
published: "已发布",
|
|
477
|
+
unpublish: "撤下",
|
|
478
|
+
waiting: "等管理员同意",
|
|
479
|
+
scope: "谁看得见",
|
|
480
|
+
scopeAll: "所有人",
|
|
481
|
+
scopeDepts: "部门",
|
|
482
|
+
scopePeople: "指定的人",
|
|
483
|
+
about: "它是做什么的",
|
|
484
|
+
pull: "拉进群聊",
|
|
485
|
+
pulled: "已询问",
|
|
486
|
+
pulledWait: "已问 {name},等对方同意",
|
|
487
|
+
answeredYes: "{name} 同意了,已进群",
|
|
488
|
+
answeredNo: "{name} 没有同意。",
|
|
489
|
+
pullAsks: "想拉你的智能体进群",
|
|
490
|
+
pullAsk: "{name} 想把它拉进「{group}」,同意后你和它一起进群",
|
|
491
|
+
hosted: "在你拉的群聊里",
|
|
492
|
+
recall: "撤出群聊",
|
|
493
|
+
doubts: "你的智能体在这家公司的群聊里",
|
|
494
|
+
review: "待同意的智能体",
|
|
495
|
+
agree: "同意",
|
|
496
|
+
refuse: "不同意",
|
|
497
|
+
request: "申请进来",
|
|
498
|
+
requests: "申请进来的人",
|
|
499
|
+
accept: "让他进来",
|
|
500
|
+
decline: "不同意",
|
|
501
|
+
invite: "邀请同事",
|
|
502
|
+
inviteHint: "同事在 Ta 里打开链接申请加入,管理员同意后就进来了。",
|
|
503
|
+
inviteLink: "发链接",
|
|
504
|
+
linkTitle: "进「{name}」",
|
|
505
|
+
linkGets: "在 Ta 里打开,申请进来",
|
|
506
|
+
manage: "管理",
|
|
507
|
+
companyName: "公司名",
|
|
508
|
+
settings: "规则",
|
|
509
|
+
ask: "进来的人由管理员同意",
|
|
510
|
+
askHint: "关掉:拿着链接的人直接进来。",
|
|
511
|
+
reviewLabel: "发布的智能体由管理员同意",
|
|
512
|
+
reviewHint: "关掉:发布后马上出现在通讯录里。",
|
|
513
|
+
deptTop: "放在最上层",
|
|
514
|
+
deptUnderOf: "放在「{name}」下",
|
|
515
|
+
cancel: "取消",
|
|
516
|
+
pinLabel: "同事默认把通讯录固定到导航栏",
|
|
517
|
+
pinHint: "每个人仍可自己取消固定。",
|
|
518
|
+
see: "成员能看到",
|
|
519
|
+
seeAll: "所有人、所有部门",
|
|
520
|
+
seeDept: "自己所在的部门和下级",
|
|
521
|
+
seeSelf: "只有自己",
|
|
522
|
+
depts: "部门",
|
|
523
|
+
deptName: "部门名",
|
|
524
|
+
deptUnder: "上级部门",
|
|
525
|
+
addDept: "加一个部门",
|
|
526
|
+
place: "调部门、换上级",
|
|
527
|
+
placeOf: "{name} 在哪里",
|
|
528
|
+
deptsOf: "部门,一行一个",
|
|
529
|
+
managerOf: "向谁汇报",
|
|
530
|
+
nobody: "不设",
|
|
531
|
+
out: "移出",
|
|
532
|
+
outAsk: "把 {name} 移出公司?",
|
|
533
|
+
outHint: "他的名片和智能体一起撤下;他在群聊里做过的事留着。",
|
|
534
|
+
leave: "离开",
|
|
535
|
+
leaveAsk: "离开「{name}」?",
|
|
536
|
+
oldApp: "先更新 Ta 再用通讯录。",
|
|
537
|
+
oldServer: "请先更新电脑上的 Ta 再使用通讯录。",
|
|
538
|
+
busy: "稍等…",
|
|
539
|
+
copy: "复制",
|
|
540
|
+
done: "完成",
|
|
541
|
+
pending: "等待中",
|
|
542
|
+
others: "其他",
|
|
543
|
+
me: "你",
|
|
544
|
+
owner: "主管理员",
|
|
545
|
+
admin: "管理员",
|
|
546
|
+
member: "成员",
|
|
547
|
+
companyDepts: "部门",
|
|
548
|
+
noneYet: "还没有",
|
|
549
|
+
noGroup: "还没有你带的群聊",
|
|
550
|
+
pickGroup: "群聊",
|
|
551
|
+
askPull: "问一下 {name},把 {agent} 拉进群聊?对方会连人带智能体一起进群。",
|
|
552
|
+
pullAsked: "已问 {name}。对方在自己的 Ta 里同意后,本人和 {agent} 一起进群。"
|
|
553
|
+
};
|
|
554
|
+
var TW = {
|
|
555
|
+
...ZH,
|
|
556
|
+
pullAsked: "已問 {name}。對方在自己的 Ta 裡同意後,本人和 {agent} 一起進群。",
|
|
557
|
+
askPull: "問一下 {name},把 {agent} 拉進群聊?對方會連人帶智慧體一起進群。",
|
|
558
|
+
noGroup: "還沒有你帶的群聊",
|
|
559
|
+
copy: "複製",
|
|
560
|
+
nobody: "不設",
|
|
561
|
+
noneYet: "還沒有",
|
|
562
|
+
companyDepts: "部門",
|
|
563
|
+
doubts: "你的智慧體在這家公司的群聊裡",
|
|
564
|
+
cardPhone: "電話",
|
|
565
|
+
cardMail: "信箱",
|
|
566
|
+
noProfile: "還沒寫",
|
|
567
|
+
online: "線上",
|
|
568
|
+
title: "通訊錄",
|
|
569
|
+
summary: "企業通訊錄,跑在公司的 Ta 之間:部門與負責人、誰進來、每人發佈的智慧體。",
|
|
570
|
+
empty: "還沒有公司",
|
|
571
|
+
emptyHint: "為你的公司建一個,或者用管理員發你的連結進來。",
|
|
572
|
+
make: "建一個",
|
|
573
|
+
makeName: "公司叫什麼",
|
|
574
|
+
makePlaceholder: "例如:某某科技",
|
|
575
|
+
join: "用連結進來",
|
|
576
|
+
joinPlaceholder: "管理員發你的連結",
|
|
577
|
+
joined: "已申請進來:公司管理員同意後就到了。",
|
|
578
|
+
members: "{n} 人",
|
|
579
|
+
tabPeople: "同事",
|
|
580
|
+
tabAgents: "智慧體",
|
|
581
|
+
tabAdmin: "管理",
|
|
582
|
+
none: "沒有分部門",
|
|
583
|
+
invited: "已邀請",
|
|
584
|
+
lead: "負責人",
|
|
585
|
+
managerAxis: "匯報給",
|
|
586
|
+
department: "部門",
|
|
587
|
+
card: "我的名片",
|
|
588
|
+
cardTitle: "職位",
|
|
589
|
+
cardAbout: "在做什麼",
|
|
590
|
+
cardStaff: "工號",
|
|
591
|
+
save: "儲存",
|
|
592
|
+
saved: "已儲存",
|
|
593
|
+
agentsEmpty: "還沒有智慧體",
|
|
594
|
+
agentsHint: "發佈一個自己的智慧體,同事就能在這裡看到,並把它拉進群聊一起做事。",
|
|
595
|
+
publish: "發佈一個智慧體",
|
|
596
|
+
published: "已發佈",
|
|
597
|
+
unpublish: "撤下",
|
|
598
|
+
waiting: "等管理員同意",
|
|
599
|
+
scope: "誰看得見",
|
|
600
|
+
scopeDepts: "部門",
|
|
601
|
+
scopePeople: "指定的人",
|
|
602
|
+
about: "它是做什麼的",
|
|
603
|
+
pull: "拉進群聊",
|
|
604
|
+
pulled: "已詢問",
|
|
605
|
+
pulledWait: "已問 {name},等對方同意",
|
|
606
|
+
answeredYes: "{name} 同意了,已進群",
|
|
607
|
+
answeredNo: "{name} 沒有同意。",
|
|
608
|
+
pullAsks: "想拉你的智慧體進群",
|
|
609
|
+
pullAsk: "{name} 想把它拉進「{group}」,同意後你和它一起進群",
|
|
610
|
+
hosted: "在你拉的群聊裡",
|
|
611
|
+
recall: "撤出群聊",
|
|
612
|
+
review: "待同意的智慧體",
|
|
613
|
+
agree: "同意",
|
|
614
|
+
request: "申請進來",
|
|
615
|
+
requests: "申請進來的人",
|
|
616
|
+
accept: "讓他進來",
|
|
617
|
+
decline: "不同意",
|
|
618
|
+
invite: "邀請同事",
|
|
619
|
+
inviteHint: "同事在 Ta 裡打開連結申請加入,管理員同意後就進來了。",
|
|
620
|
+
inviteLink: "發連結",
|
|
621
|
+
linkTitle: "進「{name}」",
|
|
622
|
+
linkGets: "在 Ta 裡打開,申請進來",
|
|
623
|
+
companyName: "公司名",
|
|
624
|
+
settings: "規則",
|
|
625
|
+
ask: "進來的人由管理員同意",
|
|
626
|
+
askHint: "關掉:拿著連結的人直接進來。",
|
|
627
|
+
reviewLabel: "發佈的智慧體由管理員同意",
|
|
628
|
+
reviewHint: "關掉:發佈後馬上出現在通訊錄裡。",
|
|
629
|
+
deptTop: "放在最上層",
|
|
630
|
+
deptUnderOf: "放在「{name}」下",
|
|
631
|
+
cancel: "取消",
|
|
632
|
+
pinLabel: "同事預設把通訊錄固定到導覽列",
|
|
633
|
+
pinHint: "每個人仍可自己取消固定。",
|
|
634
|
+
see: "成員能看到",
|
|
635
|
+
seeAll: "所有人、所有部門",
|
|
636
|
+
seeDept: "自己所在的部門和下級",
|
|
637
|
+
seeSelf: "只有自己",
|
|
638
|
+
depts: "部門",
|
|
639
|
+
deptName: "部門名",
|
|
640
|
+
deptUnder: "上級部門",
|
|
641
|
+
addDept: "加一個部門",
|
|
642
|
+
place: "調部門、換上級",
|
|
643
|
+
placeOf: "{name} 在哪裡",
|
|
644
|
+
deptsOf: "部門,一行一個",
|
|
645
|
+
managerOf: "向誰匯報",
|
|
646
|
+
out: "移出",
|
|
647
|
+
outAsk: "把 {name} 移出公司?",
|
|
648
|
+
outHint: "他的名片和智慧體一起撤下;他在群聊裡做過的事留著。",
|
|
649
|
+
leave: "離開",
|
|
650
|
+
leaveAsk: "離開「{name}」?",
|
|
651
|
+
oldApp: "先更新 Ta 再用通訊錄。",
|
|
652
|
+
oldServer: "請先更新電腦上的 Ta 再使用通訊錄。",
|
|
653
|
+
remove: "移出",
|
|
654
|
+
me: "你",
|
|
655
|
+
owner: "主管理員",
|
|
656
|
+
admin: "管理員",
|
|
657
|
+
member: "成員"
|
|
658
|
+
};
|
|
659
|
+
var JA = {
|
|
660
|
+
title: "名簿",
|
|
661
|
+
summary: "会社の Ta の間で動く企業名簿:部署と責任者、参加、各自が公開するエージェント。",
|
|
662
|
+
empty: "まだ会社がありません",
|
|
663
|
+
emptyHint: "会社のものを作るか、管理者から届いたリンクで参加します。",
|
|
664
|
+
make: "作る",
|
|
665
|
+
makeName: "会社の名前",
|
|
666
|
+
makePlaceholder: "例:株式会社サンプル",
|
|
667
|
+
join: "リンクで参加",
|
|
668
|
+
joinPlaceholder: "管理者から届いたリンク",
|
|
669
|
+
joined: "参加を申請しました:会社の管理者が承認すると入れます。",
|
|
670
|
+
members: "{n} 人",
|
|
671
|
+
tabPeople: "メンバー",
|
|
672
|
+
tabAgents: "エージェント",
|
|
673
|
+
tabAdmin: "管理",
|
|
674
|
+
all: "全員",
|
|
675
|
+
none: "部署なし",
|
|
676
|
+
invited: "招待済み",
|
|
677
|
+
online: "オンライン",
|
|
678
|
+
lead: "責任者",
|
|
679
|
+
managerAxis: "報告先",
|
|
680
|
+
department: "部署",
|
|
681
|
+
noProfile: "まだ空欄",
|
|
682
|
+
card: "自分のカード",
|
|
683
|
+
cardTitle: "役職",
|
|
684
|
+
cardAbout: "していること",
|
|
685
|
+
cardStaff: "社員番号",
|
|
686
|
+
cardMail: "メール",
|
|
687
|
+
cardPhone: "電話",
|
|
688
|
+
save: "保存",
|
|
689
|
+
saved: "保存しました",
|
|
690
|
+
agentsEmpty: "まだエージェントがありません",
|
|
691
|
+
agentsHint: "自分のエージェントを公開すると、同僚がここで見つけ、グループチャットに招けます。",
|
|
692
|
+
publish: "エージェントを公開",
|
|
693
|
+
published: "公開済み",
|
|
694
|
+
unpublish: "公開をやめる",
|
|
695
|
+
waiting: "管理者の承認待ち",
|
|
696
|
+
scope: "見える人",
|
|
697
|
+
scopeAll: "全員",
|
|
698
|
+
scopeDepts: "部署",
|
|
699
|
+
scopePeople: "指定した人",
|
|
700
|
+
about: "何をするか",
|
|
701
|
+
pull: "グループチャットへ招く",
|
|
702
|
+
pulled: "依頼済み",
|
|
703
|
+
pulledWait: "{name} に依頼し、返事を待っています",
|
|
704
|
+
answeredYes: "{name} が同意しました:グループチャットにいます。",
|
|
705
|
+
answeredNo: "{name} は断りました。",
|
|
706
|
+
pullAsks: "グループチャットへの招待",
|
|
707
|
+
pullAsk: "{name} さんが「{group}」に招こうとしています。同意するとあなたも一緒に入ります",
|
|
708
|
+
hosted: "あなたが招いたグループチャット",
|
|
709
|
+
doubts: "この会社のグループチャットにいる自分のエージェント",
|
|
710
|
+
recall: "グループチャットから外す",
|
|
711
|
+
review: "承認待ちのエージェント",
|
|
712
|
+
agree: "承認",
|
|
713
|
+
refuse: "却下",
|
|
714
|
+
request: "参加を申請",
|
|
715
|
+
requests: "参加を申請している人",
|
|
716
|
+
accept: "入れる",
|
|
717
|
+
decline: "しない",
|
|
718
|
+
invite: "同僚を招待",
|
|
719
|
+
inviteHint: "本人が同意し、管理者が承認すると入れます。",
|
|
720
|
+
inviteLink: "リンクを送る",
|
|
721
|
+
linkTitle: "「{name}」へ",
|
|
722
|
+
linkGets: "Ta で開いて参加を申請",
|
|
723
|
+
manage: "管理",
|
|
724
|
+
companyName: "会社名",
|
|
725
|
+
settings: "ルール",
|
|
726
|
+
ask: "参加は管理者が承認する",
|
|
727
|
+
askHint: "オフ:リンクを持つ人はすぐ入れます。",
|
|
728
|
+
reviewLabel: "公開したエージェントは管理者が承認する",
|
|
729
|
+
reviewHint: "オフ:公開するとすぐ名簿に出ます。",
|
|
730
|
+
deptTop: "最上位に置く",
|
|
731
|
+
deptUnderOf: "「{name}」の下に置く",
|
|
732
|
+
cancel: "キャンセル",
|
|
733
|
+
pinLabel: "全員のナビゲーションに名簿を固定",
|
|
734
|
+
pinHint: "各自で外すこともできます。",
|
|
735
|
+
see: "メンバーが見える範囲",
|
|
736
|
+
seeAll: "全員・全部署",
|
|
737
|
+
seeDept: "自分の部署とその下",
|
|
738
|
+
seeSelf: "自分のみ",
|
|
739
|
+
depts: "部署",
|
|
740
|
+
deptName: "部署名",
|
|
741
|
+
deptUnder: "上位の部署",
|
|
742
|
+
addDept: "部署を追加",
|
|
743
|
+
place: "部署と上長を変更",
|
|
744
|
+
placeOf: "{name} の所属",
|
|
745
|
+
deptsOf: "部署を1行ずつ",
|
|
746
|
+
managerOf: "報告先",
|
|
747
|
+
nobody: "なし",
|
|
748
|
+
out: "外す",
|
|
749
|
+
outAsk: "{name} を会社から外しますか。",
|
|
750
|
+
outHint: "カードとエージェントも外れます。グループチャットでの発言は残ります。",
|
|
751
|
+
leave: "退出",
|
|
752
|
+
leaveAsk: "「{name}」を退出しますか。",
|
|
753
|
+
oldApp: "名簿を使うには Ta を更新してください。",
|
|
754
|
+
oldServer: "コンピュータの Ta を更新してから名簿を使ってください。",
|
|
755
|
+
busy: "少々…",
|
|
756
|
+
copy: "コピー",
|
|
757
|
+
done: "完了",
|
|
758
|
+
pending: "待機中",
|
|
759
|
+
others: "その他",
|
|
760
|
+
me: "あなた",
|
|
761
|
+
owner: "オーナー",
|
|
762
|
+
admin: "管理者",
|
|
763
|
+
member: "メンバー",
|
|
764
|
+
companyDepts: "部署",
|
|
765
|
+
noneYet: "まだなし",
|
|
766
|
+
noGroup: "あなたが率いるグループチャットはまだありません",
|
|
767
|
+
pickGroup: "グループチャット",
|
|
768
|
+
askPull: "{name} に頼んで {agent} をグループチャットへ招きますか。本人もメンバーとして入ります。",
|
|
769
|
+
pullAsked: "{name} に依頼しました。本人の Ta で同意すると、本人と {agent} が入ります。"
|
|
770
|
+
};
|
|
771
|
+
var OrgWords = {
|
|
772
|
+
"en-US": EN,
|
|
773
|
+
"zh-CN": ZH,
|
|
774
|
+
"zh-TW": { ...EN, ...TW },
|
|
775
|
+
"ja-JP": JA
|
|
776
|
+
};
|
|
777
|
+
var OrgText;
|
|
778
|
+
((OrgText) => {
|
|
779
|
+
function of(language) {
|
|
780
|
+
const key = language === "zh-CN" || language === "zh-TW" || language === "ja-JP" ? language : "en-US";
|
|
781
|
+
return OrgWords[key];
|
|
782
|
+
}
|
|
783
|
+
OrgText.of = of;
|
|
784
|
+
function format(text, values = {}) {
|
|
785
|
+
return text.replace(/\{(\w+)\}/g, (all, name) => values[name] === undefined ? all : String(values[name]));
|
|
786
|
+
}
|
|
787
|
+
OrgText.format = format;
|
|
788
|
+
})(OrgText ||= {});
|
|
789
|
+
|
|
790
|
+
// web-src/react.ts
|
|
791
|
+
var React;
|
|
792
|
+
function bind(react) {
|
|
793
|
+
React = react;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// web-src/page.tsx
|
|
797
|
+
var pi;
|
|
798
|
+
function bindPage(api) {
|
|
799
|
+
pi = api;
|
|
800
|
+
}
|
|
801
|
+
function t(key, values = {}) {
|
|
802
|
+
return OrgText.format(OrgText.of(pi.ui.language)[key], values);
|
|
803
|
+
}
|
|
804
|
+
function icon(name) {
|
|
805
|
+
return pi.ui.icons[name] ?? pi.ui.icons.Users;
|
|
806
|
+
}
|
|
807
|
+
function message(error) {
|
|
808
|
+
return error instanceof Error ? error.message : String(error);
|
|
809
|
+
}
|
|
810
|
+
async function call(request) {
|
|
811
|
+
try {
|
|
812
|
+
return await pi.callHost("org", request);
|
|
813
|
+
} catch (error) {
|
|
814
|
+
const text = message(error);
|
|
815
|
+
throw new Error(/no method|no host|not found/i.test(text) ? t("oldServer") : text);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
async function read(request = {}) {
|
|
819
|
+
try {
|
|
820
|
+
return await pi.callHost("view", request);
|
|
821
|
+
} catch (error) {
|
|
822
|
+
const text = message(error);
|
|
823
|
+
throw new Error(/no method|no host|not found/i.test(text) ? t("oldServer") : text);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
class OrgBook {
|
|
828
|
+
state = { orgs: [], loading: true };
|
|
829
|
+
listeners = new Set;
|
|
830
|
+
timer;
|
|
831
|
+
again;
|
|
832
|
+
pinning = new Set;
|
|
833
|
+
get = () => this.state;
|
|
834
|
+
subscribe = (listener) => {
|
|
835
|
+
this.listeners.add(listener);
|
|
836
|
+
return () => this.listeners.delete(listener);
|
|
837
|
+
};
|
|
838
|
+
start() {
|
|
839
|
+
const stops = [
|
|
840
|
+
pi.onRoomEvent?.(() => this.soon(), { messages: false, state: ["org:", "profile:", "agent:", "listings", "ask:", "pull:", "pull-ok:", "wrap:"] }),
|
|
841
|
+
pi.onHostChanged?.((topics) => topics.includes("org") ? this.soon() : undefined)
|
|
842
|
+
];
|
|
843
|
+
this.load(this.state.room);
|
|
844
|
+
return () => {
|
|
845
|
+
for (const stop of stops) {
|
|
846
|
+
stop?.();
|
|
847
|
+
}
|
|
848
|
+
clearTimeout(this.timer);
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
soon(room) {
|
|
852
|
+
if (room) {
|
|
853
|
+
this.again = { room };
|
|
854
|
+
}
|
|
855
|
+
if (this.timer) {
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
this.timer = setTimeout(() => {
|
|
859
|
+
this.timer = undefined;
|
|
860
|
+
const next = this.again?.room ?? this.state.room;
|
|
861
|
+
this.again = undefined;
|
|
862
|
+
this.load(next);
|
|
863
|
+
}, 120);
|
|
864
|
+
}
|
|
865
|
+
async load(room) {
|
|
866
|
+
try {
|
|
867
|
+
const found = await read(room ? { room } : {});
|
|
868
|
+
this.pin(found.orgs);
|
|
869
|
+
this.set({ orgs: found.orgs, ...found.org ? { org: found.org } : {}, ...found.org ? { room: found.org.room } : {}, loading: false });
|
|
870
|
+
} catch (error) {
|
|
871
|
+
this.set({ ...this.state, loading: false, error: message(error) });
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
pin(orgs) {
|
|
875
|
+
const asking = orgs.filter((each) => each.pin && !this.pinning.has(each.id));
|
|
876
|
+
if (!asking.length || !pi.ui.pinPage) {
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
pi.ui.pinPage("org", true);
|
|
880
|
+
for (const each of asking) {
|
|
881
|
+
this.pinning.add(each.id);
|
|
882
|
+
call({ kind: "pinned", room: each.id }).catch(() => {
|
|
883
|
+
return;
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
set(next) {
|
|
888
|
+
this.state = next;
|
|
889
|
+
for (const listener of this.listeners) {
|
|
890
|
+
listener();
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
var book = new OrgBook;
|
|
895
|
+
function useState() {
|
|
896
|
+
return useSteadyStore(React, book.subscribe, book.get);
|
|
897
|
+
}
|
|
898
|
+
function Face(props) {
|
|
899
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Face, {
|
|
900
|
+
seed: props.member,
|
|
901
|
+
look: props.look,
|
|
902
|
+
size: props.size ?? 40,
|
|
903
|
+
online: props.online
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
function Busy(props) {
|
|
907
|
+
const [busy, run] = pi.ui.useBusy();
|
|
908
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
909
|
+
type: "button",
|
|
910
|
+
className: `ta-button${props.primary ? " ta-button-primary" : ""}${props.small ? " tor-small" : ""}${props.danger ? " tor-danger" : ""}${busy ? " ta-busy" : ""}`,
|
|
911
|
+
disabled: props.disabled || busy,
|
|
912
|
+
onClick: () => void run(() => props.onClick()).then(() => book.load(book.get().room)).catch((error) => pi.ui.notify(message(error), "error"))
|
|
913
|
+
}, props.children);
|
|
914
|
+
}
|
|
915
|
+
function Field(props) {
|
|
916
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
917
|
+
className: "ta-form-item"
|
|
918
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
919
|
+
className: "ta-form-label"
|
|
920
|
+
}, props.label), props.children, props.hint ? /* @__PURE__ */ React.createElement("span", {
|
|
921
|
+
className: "tor-quiet tor-small"
|
|
922
|
+
}, props.hint) : null);
|
|
923
|
+
}
|
|
924
|
+
function Text(props) {
|
|
925
|
+
if (props.multiline) {
|
|
926
|
+
return /* @__PURE__ */ React.createElement("textarea", {
|
|
927
|
+
className: "ta-input",
|
|
928
|
+
rows: 3,
|
|
929
|
+
value: props.value,
|
|
930
|
+
placeholder: props.placeholder,
|
|
931
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
return /* @__PURE__ */ React.createElement("input", {
|
|
935
|
+
className: "ta-input",
|
|
936
|
+
value: props.value,
|
|
937
|
+
placeholder: props.placeholder,
|
|
938
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// web-src/org-admin.tsx
|
|
943
|
+
function OrgAdmin({ org }) {
|
|
944
|
+
const owner = org.role === "owner";
|
|
945
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, org.waiting.length ? /* @__PURE__ */ React.createElement("div", {
|
|
946
|
+
className: "tor-section"
|
|
947
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("requests")), /* @__PURE__ */ React.createElement("ul", {
|
|
948
|
+
className: "tor-card"
|
|
949
|
+
}, org.waiting.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
950
|
+
key: each.ask,
|
|
951
|
+
className: "tor-row",
|
|
952
|
+
style: { cursor: "default" }
|
|
953
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
954
|
+
member: each.id,
|
|
955
|
+
name: each.name,
|
|
956
|
+
size: 36
|
|
957
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
958
|
+
className: "tor-row-text"
|
|
959
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
960
|
+
className: "tor-row-name"
|
|
961
|
+
}, each.name), /* @__PURE__ */ React.createElement("span", {
|
|
962
|
+
className: "tor-row-line"
|
|
963
|
+
}, t("request"))), /* @__PURE__ */ React.createElement("span", {
|
|
964
|
+
className: "tor-actions"
|
|
965
|
+
}, /* @__PURE__ */ React.createElement(Busy, {
|
|
966
|
+
small: true,
|
|
967
|
+
onClick: () => call({ kind: "answer", room: org.room, ask: each.ask, accept: false })
|
|
968
|
+
}, t("decline")), /* @__PURE__ */ React.createElement(Busy, {
|
|
969
|
+
small: true,
|
|
970
|
+
primary: true,
|
|
971
|
+
onClick: () => call({ kind: "answer", room: org.room, ask: each.ask, accept: true })
|
|
972
|
+
}, t("agree"))))))) : null, org.review.length ? /* @__PURE__ */ React.createElement("div", {
|
|
973
|
+
className: "tor-section"
|
|
974
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("review")), /* @__PURE__ */ React.createElement("ul", {
|
|
975
|
+
className: "tor-card"
|
|
976
|
+
}, org.review.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
977
|
+
key: `${each.member}/${each.card.id}`,
|
|
978
|
+
className: "tor-row",
|
|
979
|
+
style: { cursor: "default" }
|
|
980
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
981
|
+
member: each.member,
|
|
982
|
+
name: each.memberName,
|
|
983
|
+
size: 36
|
|
984
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
985
|
+
className: "tor-row-text"
|
|
986
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
987
|
+
className: "tor-row-head"
|
|
988
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
989
|
+
className: "tor-row-name"
|
|
990
|
+
}, each.card.name)), /* @__PURE__ */ React.createElement("span", {
|
|
991
|
+
className: "tor-row-line"
|
|
992
|
+
}, each.card.about || each.memberName)), /* @__PURE__ */ React.createElement("span", {
|
|
993
|
+
className: "tor-actions"
|
|
994
|
+
}, /* @__PURE__ */ React.createElement(Busy, {
|
|
995
|
+
small: true,
|
|
996
|
+
onClick: () => call({ kind: "listing", room: org.room, member: each.member, agent: each.card.id, ok: false })
|
|
997
|
+
}, t("refuse")), /* @__PURE__ */ React.createElement(Busy, {
|
|
998
|
+
small: true,
|
|
999
|
+
primary: true,
|
|
1000
|
+
onClick: () => call({ kind: "listing", room: org.room, member: each.member, agent: each.card.id, ok: true })
|
|
1001
|
+
}, t("agree"))))))) : null, /* @__PURE__ */ React.createElement(Departments, {
|
|
1002
|
+
org
|
|
1003
|
+
}), owner ? /* @__PURE__ */ React.createElement(Settings, {
|
|
1004
|
+
org
|
|
1005
|
+
}) : null, /* @__PURE__ */ React.createElement(Invite, {
|
|
1006
|
+
org
|
|
1007
|
+
}), owner ? null : /* @__PURE__ */ React.createElement(Busy, {
|
|
1008
|
+
danger: true,
|
|
1009
|
+
onClick: () => leaveOrg(org)
|
|
1010
|
+
}, t("leave")));
|
|
1011
|
+
}
|
|
1012
|
+
function count(org, dept) {
|
|
1013
|
+
const under = new Set(OrgUtil.nest(org.depts, dept));
|
|
1014
|
+
return org.people.filter((person) => person.in && person.depts.some((each) => under.has(each.id))).length;
|
|
1015
|
+
}
|
|
1016
|
+
async function leaveOrg(org) {
|
|
1017
|
+
if (await pi.ui.confirm(t("leave"), t("leaveAsk", { name: org.title }), { danger: true, confirmLabel: t("leave") })) {
|
|
1018
|
+
await call({ kind: "leave", room: org.room });
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function Departments({ org }) {
|
|
1022
|
+
const [adding, setAdding] = React.useState(false);
|
|
1023
|
+
const [name, setName] = React.useState("");
|
|
1024
|
+
const [under, setUnder] = React.useState("all");
|
|
1025
|
+
const tree = ordered(org.depts);
|
|
1026
|
+
const add = async () => {
|
|
1027
|
+
const id = name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
1028
|
+
await call({ kind: "dept", room: org.room, id: id || `dept-${org.depts.length}`, name: name.trim(), parent: under });
|
|
1029
|
+
setName("");
|
|
1030
|
+
setAdding(false);
|
|
1031
|
+
};
|
|
1032
|
+
const Plus = icon("Plus");
|
|
1033
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1034
|
+
className: "tor-section"
|
|
1035
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("depts")), /* @__PURE__ */ React.createElement("div", {
|
|
1036
|
+
className: "tor-card tor-tree"
|
|
1037
|
+
}, tree.map(({ dept, depth }) => /* @__PURE__ */ React.createElement("div", {
|
|
1038
|
+
key: dept.id,
|
|
1039
|
+
style: { paddingLeft: depth * 18 }
|
|
1040
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1041
|
+
className: "tor-tree-name"
|
|
1042
|
+
}, dept.name, /* @__PURE__ */ React.createElement("span", {
|
|
1043
|
+
className: "tor-quiet"
|
|
1044
|
+
}, " ", count(org, dept.id))), dept.leads.length ? /* @__PURE__ */ React.createElement("span", {
|
|
1045
|
+
className: "tor-quiet tor-small"
|
|
1046
|
+
}, t("lead"), " ", dept.leads.map((member) => org.people.find((person) => person.member === member)?.name ?? member).join("、")) : null)), adding ? /* @__PURE__ */ React.createElement("div", {
|
|
1047
|
+
className: "tor-tree-form"
|
|
1048
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1049
|
+
value: name,
|
|
1050
|
+
onChange: setName,
|
|
1051
|
+
placeholder: t("deptName")
|
|
1052
|
+
}), /* @__PURE__ */ React.createElement("select", {
|
|
1053
|
+
className: "ta-input",
|
|
1054
|
+
value: under,
|
|
1055
|
+
"aria-label": t("deptUnder"),
|
|
1056
|
+
onChange: (event) => setUnder(event.target.value)
|
|
1057
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
1058
|
+
value: "all"
|
|
1059
|
+
}, t("deptTop")), tree.map(({ dept, depth }) => /* @__PURE__ */ React.createElement("option", {
|
|
1060
|
+
key: dept.id,
|
|
1061
|
+
value: dept.id
|
|
1062
|
+
}, `${" ".repeat(depth)}${t("deptUnderOf", { name: dept.name })}`))), /* @__PURE__ */ React.createElement("span", {
|
|
1063
|
+
className: "tor-actions"
|
|
1064
|
+
}, /* @__PURE__ */ React.createElement(Busy, {
|
|
1065
|
+
small: true,
|
|
1066
|
+
onClick: () => setAdding(false)
|
|
1067
|
+
}, t("cancel")), /* @__PURE__ */ React.createElement(Busy, {
|
|
1068
|
+
small: true,
|
|
1069
|
+
primary: true,
|
|
1070
|
+
onClick: add,
|
|
1071
|
+
disabled: !name.trim()
|
|
1072
|
+
}, t("addDept")))) : /* @__PURE__ */ React.createElement("button", {
|
|
1073
|
+
type: "button",
|
|
1074
|
+
className: "tor-tree-add",
|
|
1075
|
+
onClick: () => setAdding(true)
|
|
1076
|
+
}, /* @__PURE__ */ React.createElement(Plus, {
|
|
1077
|
+
size: 15
|
|
1078
|
+
}), t("addDept"))));
|
|
1079
|
+
}
|
|
1080
|
+
function ordered(depts) {
|
|
1081
|
+
const found = [];
|
|
1082
|
+
const walk = (parent, depth) => {
|
|
1083
|
+
for (const dept of depts.filter((each) => each.parent === parent && each.id !== "all").sort((x, y) => x.order - y.order)) {
|
|
1084
|
+
found.push({ dept, depth });
|
|
1085
|
+
if (depth < 6) {
|
|
1086
|
+
walk(dept.id, depth + 1);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
walk("all", 0);
|
|
1091
|
+
return found;
|
|
1092
|
+
}
|
|
1093
|
+
function Settings({ org }) {
|
|
1094
|
+
const rules = org.rules;
|
|
1095
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
1096
|
+
const save = (next) => call({ kind: "save", room: org.room, rules: next });
|
|
1097
|
+
const see = rules.see ?? "all";
|
|
1098
|
+
const seeWords = { all: t("seeAll"), dept: t("seeDept"), self: t("seeSelf") };
|
|
1099
|
+
const Chevron = icon("ChevronDown");
|
|
1100
|
+
const toggles = [
|
|
1101
|
+
{ key: "ask", label: t("ask"), hint: t("askHint") },
|
|
1102
|
+
{ key: "review", label: t("reviewLabel"), hint: t("reviewHint") },
|
|
1103
|
+
{ key: "pin", label: t("pinLabel"), hint: t("pinHint") }
|
|
1104
|
+
];
|
|
1105
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1106
|
+
className: "tor-section"
|
|
1107
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("settings")), /* @__PURE__ */ React.createElement("div", {
|
|
1108
|
+
className: "tor-card"
|
|
1109
|
+
}, toggles.map((each) => /* @__PURE__ */ React.createElement("div", {
|
|
1110
|
+
key: each.key,
|
|
1111
|
+
className: "tor-switch"
|
|
1112
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1113
|
+
className: "tor-switch-text"
|
|
1114
|
+
}, /* @__PURE__ */ React.createElement("span", null, each.label), /* @__PURE__ */ React.createElement("span", {
|
|
1115
|
+
className: "tor-quiet tor-small"
|
|
1116
|
+
}, each.hint)), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
1117
|
+
checked: !!rules[each.key],
|
|
1118
|
+
label: each.label,
|
|
1119
|
+
onChange: (next) => save({ [each.key]: next })
|
|
1120
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
1121
|
+
className: "tor-switch"
|
|
1122
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1123
|
+
className: "tor-switch-text"
|
|
1124
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("see"))), /* @__PURE__ */ React.createElement("button", {
|
|
1125
|
+
type: "button",
|
|
1126
|
+
className: "tor-choice",
|
|
1127
|
+
onClick: (event) => openMenu(event, [
|
|
1128
|
+
["all", "dept", "self"].map((key) => ({
|
|
1129
|
+
key,
|
|
1130
|
+
label: seeWords[key],
|
|
1131
|
+
checked: key === see,
|
|
1132
|
+
run: () => void save({ see: key })
|
|
1133
|
+
}))
|
|
1134
|
+
])
|
|
1135
|
+
}, seeWords[see], /* @__PURE__ */ React.createElement(Chevron, {
|
|
1136
|
+
size: 14
|
|
1137
|
+
})))), menu);
|
|
1138
|
+
}
|
|
1139
|
+
function Invite({ org }) {
|
|
1140
|
+
const [making, setMaking] = React.useState(false);
|
|
1141
|
+
const [open, setOpen] = React.useState(false);
|
|
1142
|
+
const [link, setLink] = React.useState();
|
|
1143
|
+
const [error, setError] = React.useState();
|
|
1144
|
+
const make = async () => {
|
|
1145
|
+
setMaking(true);
|
|
1146
|
+
setOpen(true);
|
|
1147
|
+
setError(undefined);
|
|
1148
|
+
try {
|
|
1149
|
+
const made = await pi.rooms?.invite(org.room, { days: 30 });
|
|
1150
|
+
setLink(made?.link);
|
|
1151
|
+
} catch (failure) {
|
|
1152
|
+
setError(message(failure));
|
|
1153
|
+
}
|
|
1154
|
+
setMaking(false);
|
|
1155
|
+
};
|
|
1156
|
+
const Sheet = pi.ui.ShareSheet;
|
|
1157
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, Sheet && open && (link || error) ? /* @__PURE__ */ React.createElement(Sheet, {
|
|
1158
|
+
title: t("linkTitle", { name: org.title }),
|
|
1159
|
+
link,
|
|
1160
|
+
error,
|
|
1161
|
+
name: org.title,
|
|
1162
|
+
gets: t("linkGets"),
|
|
1163
|
+
invite: t("linkTitle", { name: org.title }),
|
|
1164
|
+
notes: [t("inviteHint")],
|
|
1165
|
+
onClose: () => setOpen(false)
|
|
1166
|
+
}) : /* @__PURE__ */ React.createElement("div", {
|
|
1167
|
+
className: "tor-section"
|
|
1168
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1169
|
+
className: "tor-card"
|
|
1170
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1171
|
+
className: "tor-switch"
|
|
1172
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1173
|
+
className: "tor-switch-text"
|
|
1174
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("invite")), /* @__PURE__ */ React.createElement("span", {
|
|
1175
|
+
className: "tor-quiet tor-small"
|
|
1176
|
+
}, t("inviteHint"))), /* @__PURE__ */ React.createElement(Busy, {
|
|
1177
|
+
small: true,
|
|
1178
|
+
onClick: make,
|
|
1179
|
+
disabled: making
|
|
1180
|
+
}, t("inviteLink"))))));
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
// web-src/org-agents.tsx
|
|
1184
|
+
function OrgAgents({ org }) {
|
|
1185
|
+
const [publish, setPublish] = React.useState(false);
|
|
1186
|
+
const mine = org.agents.filter((each) => each.mine);
|
|
1187
|
+
const others = org.agents.filter((each) => !each.mine);
|
|
1188
|
+
const asked = org.pulled.filter((each) => !org.answers.some((answer) => answer.owner === each.member && answer.agent === each.agent && answer.room === each.room));
|
|
1189
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, org.pulls.length ? /* @__PURE__ */ React.createElement("div", {
|
|
1190
|
+
className: "tor-section"
|
|
1191
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("pullAsks")), /* @__PURE__ */ React.createElement("ul", {
|
|
1192
|
+
className: "tor-card"
|
|
1193
|
+
}, org.pulls.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
1194
|
+
key: `${each.by}/${each.agent}/${each.room}`,
|
|
1195
|
+
className: "tor-row",
|
|
1196
|
+
style: { cursor: "default" }
|
|
1197
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1198
|
+
className: "tor-row-text"
|
|
1199
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1200
|
+
className: "tor-row-name"
|
|
1201
|
+
}, each.agentName), /* @__PURE__ */ React.createElement("span", {
|
|
1202
|
+
className: "tor-row-line",
|
|
1203
|
+
style: { whiteSpace: "normal" }
|
|
1204
|
+
}, t("pullAsk", { name: each.byName || each.by, group: each.title }))), /* @__PURE__ */ React.createElement("span", {
|
|
1205
|
+
className: "tor-actions"
|
|
1206
|
+
}, /* @__PURE__ */ React.createElement(Busy, {
|
|
1207
|
+
small: true,
|
|
1208
|
+
onClick: () => answer(org, each, false)
|
|
1209
|
+
}, t("refuse")), /* @__PURE__ */ React.createElement(Busy, {
|
|
1210
|
+
small: true,
|
|
1211
|
+
primary: true,
|
|
1212
|
+
onClick: () => answer(org, each, true)
|
|
1213
|
+
}, t("agree"))))))) : null, asked.length || org.answers.length ? /* @__PURE__ */ React.createElement("div", {
|
|
1214
|
+
className: "tor-section"
|
|
1215
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("pull")), /* @__PURE__ */ React.createElement("ul", {
|
|
1216
|
+
className: "tor-card"
|
|
1217
|
+
}, asked.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
1218
|
+
key: `${each.member}/${each.agent}/${each.room}`,
|
|
1219
|
+
className: "tor-row",
|
|
1220
|
+
style: { cursor: "default" }
|
|
1221
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1222
|
+
className: "tor-row-text"
|
|
1223
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1224
|
+
className: "tor-row-name"
|
|
1225
|
+
}, each.agentName), /* @__PURE__ */ React.createElement("span", {
|
|
1226
|
+
className: "tor-row-line"
|
|
1227
|
+
}, t("pulledWait", { name: each.memberName }))), /* @__PURE__ */ React.createElement("span", {
|
|
1228
|
+
className: "tor-row-side"
|
|
1229
|
+
}, each.title))), org.answers.slice(-5).map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
1230
|
+
key: `${each.owner}/${each.agent}/${each.room}`,
|
|
1231
|
+
className: "tor-row",
|
|
1232
|
+
style: { cursor: "default" }
|
|
1233
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1234
|
+
className: "tor-row-text"
|
|
1235
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1236
|
+
className: "tor-row-name"
|
|
1237
|
+
}, each.agentName ?? agentName(org, each.agent)), /* @__PURE__ */ React.createElement("span", {
|
|
1238
|
+
className: "tor-row-line"
|
|
1239
|
+
}, each.ok ? t("answeredYes", { name: each.memberName }) : t("answeredNo", { name: each.memberName }))), each.title ? /* @__PURE__ */ React.createElement("span", {
|
|
1240
|
+
className: "tor-row-side"
|
|
1241
|
+
}, each.title) : null)))) : null, org.hosted.length ? /* @__PURE__ */ React.createElement("div", {
|
|
1242
|
+
className: "tor-section"
|
|
1243
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("doubts")), /* @__PURE__ */ React.createElement("ul", {
|
|
1244
|
+
className: "tor-card"
|
|
1245
|
+
}, org.hosted.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
1246
|
+
key: `${each.agent}/${each.room}`,
|
|
1247
|
+
className: "tor-row",
|
|
1248
|
+
style: { cursor: "default" }
|
|
1249
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1250
|
+
className: "tor-row-text"
|
|
1251
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1252
|
+
className: "tor-row-name"
|
|
1253
|
+
}, agentName(org, each.agent)), /* @__PURE__ */ React.createElement("span", {
|
|
1254
|
+
className: "tor-row-line"
|
|
1255
|
+
}, each.title ?? groupTitle(each.room))), /* @__PURE__ */ React.createElement(Busy, {
|
|
1256
|
+
small: true,
|
|
1257
|
+
onClick: () => call({ kind: "unpull", room: org.room, member: each.agent, agent: each.agent, group: each.room })
|
|
1258
|
+
}, t("recall")))))) : null, /* @__PURE__ */ React.createElement("div", {
|
|
1259
|
+
className: "tor-section"
|
|
1260
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("tabAgents")), others.length ? /* @__PURE__ */ React.createElement("ul", {
|
|
1261
|
+
className: "tor-card"
|
|
1262
|
+
}, others.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
1263
|
+
key: `${each.member}/${each.card.id}`,
|
|
1264
|
+
className: "tor-row",
|
|
1265
|
+
onClick: () => each.pullable ? void pull(org, each) : undefined,
|
|
1266
|
+
onKeyDown: (event) => each.pullable && (event.key === "Enter" || event.key === " ") ? void pull(org, each) : undefined,
|
|
1267
|
+
role: each.pullable ? "button" : undefined,
|
|
1268
|
+
tabIndex: each.pullable ? 0 : undefined
|
|
1269
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1270
|
+
member: each.member,
|
|
1271
|
+
name: each.memberName,
|
|
1272
|
+
size: 40
|
|
1273
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1274
|
+
className: "tor-row-text"
|
|
1275
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1276
|
+
className: "tor-row-head"
|
|
1277
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1278
|
+
className: "tor-row-name"
|
|
1279
|
+
}, each.card.name), each.listing === "wait" ? /* @__PURE__ */ React.createElement("span", {
|
|
1280
|
+
className: "tor-tag tor-tag-warn"
|
|
1281
|
+
}, t("waiting")) : null), /* @__PURE__ */ React.createElement("span", {
|
|
1282
|
+
className: "tor-row-line"
|
|
1283
|
+
}, each.card.about || `${each.memberName} · ${scopeWords(org, each)}`)), each.pullable ? /* @__PURE__ */ React.createElement("span", {
|
|
1284
|
+
className: "tor-row-side"
|
|
1285
|
+
}, t("pull")) : null))) : /* @__PURE__ */ React.createElement("div", {
|
|
1286
|
+
className: "tor-empty"
|
|
1287
|
+
}, /* @__PURE__ */ React.createElement("h2", null, t("agentsEmpty")), /* @__PURE__ */ React.createElement("p", null, t("agentsHint"))), /* @__PURE__ */ React.createElement("button", {
|
|
1288
|
+
type: "button",
|
|
1289
|
+
className: "tor-wide",
|
|
1290
|
+
onClick: () => setPublish(!publish)
|
|
1291
|
+
}, t("publish")), publish ? /* @__PURE__ */ React.createElement(Publish, {
|
|
1292
|
+
org,
|
|
1293
|
+
close: () => setPublish(false)
|
|
1294
|
+
}) : null), mine.length ? /* @__PURE__ */ React.createElement("div", {
|
|
1295
|
+
className: "tor-section"
|
|
1296
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("published")), /* @__PURE__ */ React.createElement("ul", {
|
|
1297
|
+
className: "tor-card"
|
|
1298
|
+
}, mine.map((each) => /* @__PURE__ */ React.createElement("li", {
|
|
1299
|
+
key: each.card.id,
|
|
1300
|
+
className: "tor-row"
|
|
1301
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1302
|
+
className: "tor-row-text"
|
|
1303
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1304
|
+
className: "tor-row-head"
|
|
1305
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1306
|
+
className: "tor-row-name"
|
|
1307
|
+
}, each.card.name), each.listing === "wait" ? /* @__PURE__ */ React.createElement("span", {
|
|
1308
|
+
className: "tor-tag tor-tag-warn"
|
|
1309
|
+
}, t("waiting")) : null, each.listing === "ok" ? /* @__PURE__ */ React.createElement("span", {
|
|
1310
|
+
className: "tor-tag tor-tag-good"
|
|
1311
|
+
}, t("published")) : null), /* @__PURE__ */ React.createElement("span", {
|
|
1312
|
+
className: "tor-row-line"
|
|
1313
|
+
}, scopeWords(org, each))), /* @__PURE__ */ React.createElement(Busy, {
|
|
1314
|
+
small: true,
|
|
1315
|
+
danger: true,
|
|
1316
|
+
onClick: () => call({ kind: "unpublish", room: org.room, agent: each.card.id })
|
|
1317
|
+
}, t("unpublish")))))) : null);
|
|
1318
|
+
}
|
|
1319
|
+
function scopeWords(org, agent) {
|
|
1320
|
+
if (agent.card.scope.kind === "all") {
|
|
1321
|
+
return t("scopeAll");
|
|
1322
|
+
}
|
|
1323
|
+
if (agent.card.scope.kind === "people") {
|
|
1324
|
+
const names2 = agent.card.scope.people.map((member) => org.people.find((each) => each.member === member)?.name ?? member);
|
|
1325
|
+
return `${t("scopePeople")}: ${names2.slice(0, 3).join("、")}`;
|
|
1326
|
+
}
|
|
1327
|
+
const names = agent.card.scope.depts.map((dept) => org.depts.find((each) => each.id === dept)?.name ?? dept);
|
|
1328
|
+
return `${t("scopeDepts")}: ${names.slice(0, 3).join("、")}`;
|
|
1329
|
+
}
|
|
1330
|
+
function Publish({ org, close }) {
|
|
1331
|
+
const [agents, setAgents] = React.useState([]);
|
|
1332
|
+
const [id, setId] = React.useState("");
|
|
1333
|
+
const [about, setAbout] = React.useState("");
|
|
1334
|
+
const [scope, setScope] = React.useState("all");
|
|
1335
|
+
React.useEffect(() => {
|
|
1336
|
+
pi.callHost("agents").then((list) => setAgents(list)).catch((error) => pi.ui.notify(message(error), "error"));
|
|
1337
|
+
}, []);
|
|
1338
|
+
const save = async () => {
|
|
1339
|
+
if (!id) {
|
|
1340
|
+
pi.ui.notify(t("publish"), "warning");
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
const card = agents.find((each) => each.id === id);
|
|
1344
|
+
await call({
|
|
1345
|
+
kind: "publish",
|
|
1346
|
+
room: org.room,
|
|
1347
|
+
card: {
|
|
1348
|
+
id,
|
|
1349
|
+
name: card?.name ?? id,
|
|
1350
|
+
about,
|
|
1351
|
+
scope: scope === "all" ? { kind: "all" } : scope === "depts" ? { kind: "depts", depts: [] } : { kind: "people", people: [] }
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
close();
|
|
1355
|
+
};
|
|
1356
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1357
|
+
className: "tor-card",
|
|
1358
|
+
style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }
|
|
1359
|
+
}, /* @__PURE__ */ React.createElement(Field, {
|
|
1360
|
+
label: t("tabAgents"),
|
|
1361
|
+
hint: agents.length ? undefined : t("agentsEmpty")
|
|
1362
|
+
}, /* @__PURE__ */ React.createElement("select", {
|
|
1363
|
+
className: "ta-input",
|
|
1364
|
+
value: id,
|
|
1365
|
+
onChange: (event) => setId(event.target.value)
|
|
1366
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
1367
|
+
value: ""
|
|
1368
|
+
}, "—"), agents.map((each) => /* @__PURE__ */ React.createElement("option", {
|
|
1369
|
+
key: each.id,
|
|
1370
|
+
value: each.id
|
|
1371
|
+
}, each.name)))), /* @__PURE__ */ React.createElement(Field, {
|
|
1372
|
+
label: t("about")
|
|
1373
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1374
|
+
value: about,
|
|
1375
|
+
onChange: setAbout,
|
|
1376
|
+
multiline: true
|
|
1377
|
+
})), /* @__PURE__ */ React.createElement(Field, {
|
|
1378
|
+
label: t("scope")
|
|
1379
|
+
}, /* @__PURE__ */ React.createElement("select", {
|
|
1380
|
+
className: "ta-input",
|
|
1381
|
+
value: scope,
|
|
1382
|
+
onChange: (event) => setScope(event.target.value)
|
|
1383
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
1384
|
+
value: "all"
|
|
1385
|
+
}, t("scopeAll")), /* @__PURE__ */ React.createElement("option", {
|
|
1386
|
+
value: "depts"
|
|
1387
|
+
}, t("scopeDepts")), /* @__PURE__ */ React.createElement("option", {
|
|
1388
|
+
value: "people"
|
|
1389
|
+
}, t("scopePeople")))), /* @__PURE__ */ React.createElement(Busy, {
|
|
1390
|
+
primary: true,
|
|
1391
|
+
onClick: save,
|
|
1392
|
+
disabled: !id
|
|
1393
|
+
}, t("publish")));
|
|
1394
|
+
}
|
|
1395
|
+
async function pull(org, agent) {
|
|
1396
|
+
const groups = await pi.callHost("groups").catch((error) => {
|
|
1397
|
+
pi.ui.notify(message(error), "error");
|
|
1398
|
+
return [];
|
|
1399
|
+
});
|
|
1400
|
+
const mine = groups.filter((each) => each.mine);
|
|
1401
|
+
if (!mine.length) {
|
|
1402
|
+
pi.ui.notify(t("noGroup"), "warning");
|
|
1403
|
+
return;
|
|
1404
|
+
}
|
|
1405
|
+
const yes = await pi.ui.confirm(t("pull"), t("askPull", { name: agent.memberName, agent: agent.card.name }));
|
|
1406
|
+
if (!yes) {
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
const first = mine.length === 1 ? mine[0] : mine.find((each) => each.title.toLowerCase().includes(org.title.toLowerCase())) ?? mine[0];
|
|
1410
|
+
const chosen = mine.length === 1 ? first : mine[await pickGroup(mine)];
|
|
1411
|
+
if (!chosen) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
await call({ kind: "pull", room: org.room, member: agent.member, agent: agent.card.id, group: chosen.id });
|
|
1415
|
+
pi.ui.notify(t("pullAsked", { name: agent.memberName, agent: agent.card.name }), "info");
|
|
1416
|
+
book.load(org.room);
|
|
1417
|
+
}
|
|
1418
|
+
async function answer(org, ask, ok) {
|
|
1419
|
+
await call({ kind: "pullAnswer", org: org.room, ask, ok });
|
|
1420
|
+
await book.load(org.room);
|
|
1421
|
+
}
|
|
1422
|
+
function agentName(org, agent) {
|
|
1423
|
+
return org.agents.find((each) => each.card.id === agent)?.card.name ?? agent;
|
|
1424
|
+
}
|
|
1425
|
+
function groupTitle(room) {
|
|
1426
|
+
return room.length > 12 ? `${room.slice(0, 6)}…` : room;
|
|
1427
|
+
}
|
|
1428
|
+
async function pickGroup(groups) {
|
|
1429
|
+
const title = t("pickGroup");
|
|
1430
|
+
const value = await pi.ui.input(title, groups.map((each, index2) => `${index2 + 1}. ${each.title}`).join(`
|
|
1431
|
+
`), { value: "1" });
|
|
1432
|
+
const index = Number(value?.trim()) - 1;
|
|
1433
|
+
return Number.isInteger(index) && index >= 0 && index < groups.length ? index : -1;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
// web-src/org-people.tsx
|
|
1437
|
+
function OrgPeople({ org, onOpen }) {
|
|
1438
|
+
const [dept, setDept] = React.useState("all");
|
|
1439
|
+
const shown = org.people.filter((each) => dept === "all" || each.depts.some((one) => one.id === dept));
|
|
1440
|
+
const byDept = new Map;
|
|
1441
|
+
for (const person of shown) {
|
|
1442
|
+
const id = person.depts[0]?.id ?? "all";
|
|
1443
|
+
byDept.set(id, [...byDept.get(id) ?? [], person]);
|
|
1444
|
+
}
|
|
1445
|
+
const order = ["all", ...org.depts.filter((each) => each.id !== "all").map((each) => each.id)];
|
|
1446
|
+
const groups = [...byDept.entries()].sort((a, b) => order.indexOf(a[0]) - order.indexOf(b[0]));
|
|
1447
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, org.depts.length > 2 ? /* @__PURE__ */ React.createElement("div", {
|
|
1448
|
+
className: "ta-chips tor-chips-bar"
|
|
1449
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1450
|
+
type: "button",
|
|
1451
|
+
className: "ta-chip-filter",
|
|
1452
|
+
"aria-pressed": dept === "all",
|
|
1453
|
+
onClick: () => setDept("all")
|
|
1454
|
+
}, t("all")), org.depts.filter((each) => each.id !== "all").map((each) => /* @__PURE__ */ React.createElement("button", {
|
|
1455
|
+
key: each.id,
|
|
1456
|
+
type: "button",
|
|
1457
|
+
className: "ta-chip-filter",
|
|
1458
|
+
"aria-pressed": dept === each.id,
|
|
1459
|
+
onClick: () => setDept(each.id)
|
|
1460
|
+
}, each.name))) : null, groups.map(([id, people]) => /* @__PURE__ */ React.createElement("div", {
|
|
1461
|
+
key: id,
|
|
1462
|
+
className: "tor-section"
|
|
1463
|
+
}, /* @__PURE__ */ React.createElement("h3", null, org.depts.find((each) => each.id === id)?.name || t("none")), /* @__PURE__ */ React.createElement("ul", {
|
|
1464
|
+
className: "tor-card"
|
|
1465
|
+
}, people.map((person) => /* @__PURE__ */ React.createElement("li", {
|
|
1466
|
+
key: person.member
|
|
1467
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1468
|
+
type: "button",
|
|
1469
|
+
className: "tor-row",
|
|
1470
|
+
onClick: () => onOpen(person.member)
|
|
1471
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1472
|
+
member: person.id,
|
|
1473
|
+
name: person.name,
|
|
1474
|
+
look: person.look,
|
|
1475
|
+
online: person.online && person.in
|
|
1476
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1477
|
+
className: "tor-row-text"
|
|
1478
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1479
|
+
className: "tor-row-head"
|
|
1480
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1481
|
+
className: "tor-row-name"
|
|
1482
|
+
}, person.name), person.in ? null : /* @__PURE__ */ React.createElement("span", {
|
|
1483
|
+
className: "tor-tag tor-tag-warn"
|
|
1484
|
+
}, t("invited")), roleTag(person.role)), /* @__PURE__ */ React.createElement("span", {
|
|
1485
|
+
className: "tor-row-line"
|
|
1486
|
+
}, under(org, person))), person.agents.length ? /* @__PURE__ */ React.createElement("span", {
|
|
1487
|
+
className: "tor-row-side"
|
|
1488
|
+
}, person.agents.map((agent) => agent.name).join("、")) : null)))))), shown.length ? null : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1489
|
+
compact: true,
|
|
1490
|
+
title: t("none")
|
|
1491
|
+
}));
|
|
1492
|
+
}
|
|
1493
|
+
function Person({ org, person, close }) {
|
|
1494
|
+
const admin = org.role === "owner" || org.role === "admin";
|
|
1495
|
+
const mine = person.member === org.self;
|
|
1496
|
+
const profile = person.profile;
|
|
1497
|
+
const [title, setTitle] = React.useState(profile?.title ?? "");
|
|
1498
|
+
const [about, setAbout] = React.useState(profile?.about ?? "");
|
|
1499
|
+
const [staff, setStaff] = React.useState(profile?.staff ?? "");
|
|
1500
|
+
const [mail, setMail] = React.useState(profile?.mail ?? "");
|
|
1501
|
+
const [phone, setPhone] = React.useState(profile?.phone ?? "");
|
|
1502
|
+
const [edit, setEdit] = React.useState(false);
|
|
1503
|
+
const save = async () => {
|
|
1504
|
+
await call({ kind: "profile", room: org.room, profile: { title, about, staff, mail, phone } });
|
|
1505
|
+
setEdit(false);
|
|
1506
|
+
pi.ui.notify(t("saved"), "info");
|
|
1507
|
+
};
|
|
1508
|
+
const facts = [
|
|
1509
|
+
[
|
|
1510
|
+
t("department"),
|
|
1511
|
+
person.depts.map((each) => each.name).filter(Boolean).join(" / ") || t("none")
|
|
1512
|
+
],
|
|
1513
|
+
[t("managerAxis"), person.manager?.name ?? ""],
|
|
1514
|
+
[t("cardStaff"), profile?.staff ?? ""],
|
|
1515
|
+
[t("cardMail"), profile?.mail ?? ""],
|
|
1516
|
+
[t("cardPhone"), profile?.phone ?? ""]
|
|
1517
|
+
];
|
|
1518
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1519
|
+
className: "tor-page"
|
|
1520
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1521
|
+
className: "tor-body"
|
|
1522
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1523
|
+
className: "tor-profile"
|
|
1524
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
1525
|
+
member: person.id,
|
|
1526
|
+
name: person.name,
|
|
1527
|
+
look: person.look,
|
|
1528
|
+
size: 64,
|
|
1529
|
+
online: person.online && person.in
|
|
1530
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1531
|
+
className: "tor-profile-name"
|
|
1532
|
+
}, person.name), /* @__PURE__ */ React.createElement("span", {
|
|
1533
|
+
className: "tor-chips"
|
|
1534
|
+
}, person.depts.map((each) => each.name ? /* @__PURE__ */ React.createElement("span", {
|
|
1535
|
+
key: each.id,
|
|
1536
|
+
className: "tor-tag"
|
|
1537
|
+
}, each.name) : null), roleTag(person.role)), profile?.about ? /* @__PURE__ */ React.createElement("p", {
|
|
1538
|
+
className: "tor-profile-line"
|
|
1539
|
+
}, profile.about) : null), mine ? /* @__PURE__ */ React.createElement(Busy, {
|
|
1540
|
+
onClick: () => setEdit(!edit)
|
|
1541
|
+
}, edit ? t("done") : t("card")) : null, edit && mine ? /* @__PURE__ */ React.createElement("div", {
|
|
1542
|
+
className: "tor-card",
|
|
1543
|
+
style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }
|
|
1544
|
+
}, /* @__PURE__ */ React.createElement(Field, {
|
|
1545
|
+
label: t("cardTitle")
|
|
1546
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1547
|
+
value: title,
|
|
1548
|
+
onChange: setTitle
|
|
1549
|
+
})), /* @__PURE__ */ React.createElement(Field, {
|
|
1550
|
+
label: t("cardAbout")
|
|
1551
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1552
|
+
value: about,
|
|
1553
|
+
onChange: setAbout,
|
|
1554
|
+
multiline: true
|
|
1555
|
+
})), /* @__PURE__ */ React.createElement(Field, {
|
|
1556
|
+
label: t("cardStaff")
|
|
1557
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1558
|
+
value: staff,
|
|
1559
|
+
onChange: setStaff
|
|
1560
|
+
})), /* @__PURE__ */ React.createElement(Field, {
|
|
1561
|
+
label: t("cardMail")
|
|
1562
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1563
|
+
value: mail,
|
|
1564
|
+
onChange: setMail
|
|
1565
|
+
})), /* @__PURE__ */ React.createElement(Field, {
|
|
1566
|
+
label: t("cardPhone")
|
|
1567
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1568
|
+
value: phone,
|
|
1569
|
+
onChange: setPhone
|
|
1570
|
+
})), /* @__PURE__ */ React.createElement(Busy, {
|
|
1571
|
+
primary: true,
|
|
1572
|
+
onClick: save
|
|
1573
|
+
}, t("save"))) : /* @__PURE__ */ React.createElement("dl", {
|
|
1574
|
+
className: "tor-facts"
|
|
1575
|
+
}, facts.filter(([, value]) => !!value).map(([label, value]) => /* @__PURE__ */ React.createElement("div", {
|
|
1576
|
+
key: label
|
|
1577
|
+
}, /* @__PURE__ */ React.createElement("dt", null, label), /* @__PURE__ */ React.createElement("dd", null, value)))), person.agents.length ? /* @__PURE__ */ React.createElement("div", {
|
|
1578
|
+
className: "tor-section"
|
|
1579
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("tabAgents")), /* @__PURE__ */ React.createElement("ul", {
|
|
1580
|
+
className: "tor-card"
|
|
1581
|
+
}, person.agents.map((agent) => /* @__PURE__ */ React.createElement("li", {
|
|
1582
|
+
key: agent.id,
|
|
1583
|
+
className: "tor-row",
|
|
1584
|
+
style: { cursor: "default" }
|
|
1585
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1586
|
+
className: "tor-row-text"
|
|
1587
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1588
|
+
className: "tor-row-head"
|
|
1589
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1590
|
+
className: "tor-row-name"
|
|
1591
|
+
}, agent.name)), agent.about ? /* @__PURE__ */ React.createElement("span", {
|
|
1592
|
+
className: "tor-row-line"
|
|
1593
|
+
}, agent.about) : null))))) : null, admin && !mine ? /* @__PURE__ */ React.createElement(Busy, {
|
|
1594
|
+
onClick: () => place(org, person, close)
|
|
1595
|
+
}, t("place")) : null, admin && !mine && person.in ? /* @__PURE__ */ React.createElement(Busy, {
|
|
1596
|
+
danger: true,
|
|
1597
|
+
onClick: () => takeOut(org, person)
|
|
1598
|
+
}, t("out")) : null));
|
|
1599
|
+
}
|
|
1600
|
+
async function takeOut(org, person) {
|
|
1601
|
+
const yes = await pi.ui.confirm(t("out"), `${t("outAsk", { name: person.name })}
|
|
1602
|
+
${t("outHint")}`, { danger: true, confirmLabel: t("out") });
|
|
1603
|
+
if (yes) {
|
|
1604
|
+
await call({ kind: "out", room: org.room, member: person.member });
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
async function place(org, person, close) {
|
|
1608
|
+
const depts = await pi.ui.input(t("deptsOf"), t("deptsOf"), {
|
|
1609
|
+
value: person.depts.map((each) => each.id === "all" ? "" : each.id).filter(Boolean).join(", ")
|
|
1610
|
+
});
|
|
1611
|
+
if (depts === undefined) {
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
const names = depts.split(/[,,\s]+/).map((each) => each.trim()).filter(Boolean);
|
|
1615
|
+
const unknown = names.filter((each) => !org.depts.some((dept) => dept.id === each || dept.name === each));
|
|
1616
|
+
if (unknown.length) {
|
|
1617
|
+
pi.ui.notify(`${t("depts")}: ${org.depts.filter((each) => each.id !== "all").map((each) => `${each.name}(${each.id})`).join("、")}`, "warning");
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
const ids = names.map((each) => org.depts.find((dept) => dept.id === each || dept.name === each)?.id ?? each);
|
|
1621
|
+
const manager = await pi.ui.input(t("managerOf"), t("nobody"), { value: person.manager?.name ?? "" });
|
|
1622
|
+
const foundManager = manager?.trim() ? org.people.find((each) => each.name === manager.trim() || each.member === manager.trim()) : undefined;
|
|
1623
|
+
await call({ kind: "place", room: org.room, member: person.member, depts: ids, ...foundManager ? { manager: foundManager.member } : {} });
|
|
1624
|
+
book.load(org.room);
|
|
1625
|
+
close();
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// web-src/org-page.tsx
|
|
1629
|
+
function OrgPage() {
|
|
1630
|
+
const state = useState();
|
|
1631
|
+
const [open, setOpen] = React.useState();
|
|
1632
|
+
const [shown, setShown] = React.useState();
|
|
1633
|
+
const org = state.org;
|
|
1634
|
+
if (state.loading && !state.org && !state.orgs.length) {
|
|
1635
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Loading, null);
|
|
1636
|
+
}
|
|
1637
|
+
if (!state.orgs.length) {
|
|
1638
|
+
return /* @__PURE__ */ React.createElement(Nothing, null);
|
|
1639
|
+
}
|
|
1640
|
+
const onOpen = (member) => {
|
|
1641
|
+
setOpen(member);
|
|
1642
|
+
setShown(member);
|
|
1643
|
+
};
|
|
1644
|
+
const base = /* @__PURE__ */ React.createElement("div", {
|
|
1645
|
+
className: "tor-page"
|
|
1646
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1647
|
+
className: "tor-body"
|
|
1648
|
+
}, /* @__PURE__ */ React.createElement(Orgs, {
|
|
1649
|
+
orgs: state.orgs,
|
|
1650
|
+
room: org?.room
|
|
1651
|
+
}), org ? /* @__PURE__ */ React.createElement(One, {
|
|
1652
|
+
org,
|
|
1653
|
+
onOpen
|
|
1654
|
+
}) : /* @__PURE__ */ React.createElement(pi.ui.Loading, null), state.error ? /* @__PURE__ */ React.createElement("p", {
|
|
1655
|
+
className: "tor-quiet tor-small"
|
|
1656
|
+
}, state.error) : null));
|
|
1657
|
+
const person = org?.people.find((each) => each.member === shown);
|
|
1658
|
+
const top = org && person ? /* @__PURE__ */ React.createElement(Person, {
|
|
1659
|
+
org,
|
|
1660
|
+
person,
|
|
1661
|
+
close: () => setOpen(undefined)
|
|
1662
|
+
}) : null;
|
|
1663
|
+
if (!pi.ui.Stack) {
|
|
1664
|
+
return open && top ? top : base;
|
|
1665
|
+
}
|
|
1666
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Stack, {
|
|
1667
|
+
base,
|
|
1668
|
+
top,
|
|
1669
|
+
open: !!open && !!top,
|
|
1670
|
+
onClose: () => setOpen(undefined)
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
function Orgs({ orgs, room }) {
|
|
1674
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
1675
|
+
const current = orgs.find((each) => each.id === room) ?? orgs[0];
|
|
1676
|
+
if (!current) {
|
|
1677
|
+
return null;
|
|
1678
|
+
}
|
|
1679
|
+
const Chevron = icon("ChevronDown");
|
|
1680
|
+
const line = /* @__PURE__ */ React.createElement("span", {
|
|
1681
|
+
className: "tor-company-line"
|
|
1682
|
+
}, t("members", { n: current.members }), current.role === "owner" || current.role === "admin" ? ` · ${t(current.role)}` : "");
|
|
1683
|
+
if (orgs.length < 2) {
|
|
1684
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1685
|
+
className: "tor-company"
|
|
1686
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1687
|
+
className: "tor-company-name"
|
|
1688
|
+
}, current.title), line);
|
|
1689
|
+
}
|
|
1690
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
1691
|
+
type: "button",
|
|
1692
|
+
className: "tor-company tor-company-switch",
|
|
1693
|
+
onClick: (event) => openMenu(event, [orgs.map((each) => ({ key: each.id, label: each.title, checked: each.id === current.id, run: () => book.soon(each.id) }))])
|
|
1694
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1695
|
+
className: "tor-company-name"
|
|
1696
|
+
}, current.title, /* @__PURE__ */ React.createElement(Chevron, {
|
|
1697
|
+
size: 16
|
|
1698
|
+
})), line), menu);
|
|
1699
|
+
}
|
|
1700
|
+
function Nothing() {
|
|
1701
|
+
const [title, setTitle] = React.useState("");
|
|
1702
|
+
const [link, setLink] = React.useState("");
|
|
1703
|
+
const [shown, setShown] = React.useState();
|
|
1704
|
+
const make = async () => {
|
|
1705
|
+
if (!title.trim()) {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
const made = await call({ kind: "create", title: title.trim(), name: title.trim() });
|
|
1709
|
+
await book.load(made.id);
|
|
1710
|
+
};
|
|
1711
|
+
const join = async () => {
|
|
1712
|
+
const text = link.trim();
|
|
1713
|
+
if (!/^https?:\/\//.test(text)) {
|
|
1714
|
+
pi.ui.notify(t("joinPlaceholder"), "warning");
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
await call({ kind: "join", room: "", link: text });
|
|
1718
|
+
pi.ui.notify(t("joined"), "info");
|
|
1719
|
+
await book.load();
|
|
1720
|
+
};
|
|
1721
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1722
|
+
className: "tor-page"
|
|
1723
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1724
|
+
className: "tor-body"
|
|
1725
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1726
|
+
className: "tor-empty"
|
|
1727
|
+
}, /* @__PURE__ */ React.createElement("h2", null, t("empty")), /* @__PURE__ */ React.createElement("p", null, t("emptyHint")), /* @__PURE__ */ React.createElement("div", {
|
|
1728
|
+
className: "tor-actions"
|
|
1729
|
+
}, /* @__PURE__ */ React.createElement(Busy, {
|
|
1730
|
+
primary: true,
|
|
1731
|
+
onClick: () => setShown(shown === "make" ? undefined : "make")
|
|
1732
|
+
}, t("make")), /* @__PURE__ */ React.createElement(Busy, {
|
|
1733
|
+
onClick: () => setShown(shown === "join" ? undefined : "join")
|
|
1734
|
+
}, t("join")))), shown === "make" ? /* @__PURE__ */ React.createElement("div", {
|
|
1735
|
+
className: "tor-card",
|
|
1736
|
+
style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }
|
|
1737
|
+
}, /* @__PURE__ */ React.createElement(Field, {
|
|
1738
|
+
label: t("makeName")
|
|
1739
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1740
|
+
value: title,
|
|
1741
|
+
onChange: setTitle,
|
|
1742
|
+
placeholder: t("makePlaceholder")
|
|
1743
|
+
})), /* @__PURE__ */ React.createElement(Busy, {
|
|
1744
|
+
primary: true,
|
|
1745
|
+
onClick: make,
|
|
1746
|
+
disabled: !title.trim()
|
|
1747
|
+
}, t("make"))) : null, shown === "join" ? /* @__PURE__ */ React.createElement("div", {
|
|
1748
|
+
className: "tor-card",
|
|
1749
|
+
style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }
|
|
1750
|
+
}, /* @__PURE__ */ React.createElement(Field, {
|
|
1751
|
+
label: t("join"),
|
|
1752
|
+
hint: t("joined")
|
|
1753
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1754
|
+
value: link,
|
|
1755
|
+
onChange: setLink,
|
|
1756
|
+
placeholder: t("joinPlaceholder")
|
|
1757
|
+
})), /* @__PURE__ */ React.createElement(Busy, {
|
|
1758
|
+
primary: true,
|
|
1759
|
+
onClick: join,
|
|
1760
|
+
disabled: !link.trim()
|
|
1761
|
+
}, t("join"))) : null));
|
|
1762
|
+
}
|
|
1763
|
+
function One({ org, onOpen }) {
|
|
1764
|
+
const [tab, setTab] = React.useState("people");
|
|
1765
|
+
const admin = org.role === "owner" || org.role === "admin";
|
|
1766
|
+
const asking = org.waiting.length + (admin ? org.review.length : 0);
|
|
1767
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("fieldset", {
|
|
1768
|
+
className: "ta-segmented tor-tabs",
|
|
1769
|
+
"aria-label": t("title")
|
|
1770
|
+
}, ["people", "agents"].map((each) => /* @__PURE__ */ React.createElement("button", {
|
|
1771
|
+
key: each,
|
|
1772
|
+
type: "button",
|
|
1773
|
+
"aria-pressed": tab === each,
|
|
1774
|
+
className: tab === each ? "ta-on" : undefined,
|
|
1775
|
+
onClick: () => setTab(each)
|
|
1776
|
+
}, t(each === "people" ? "tabPeople" : "tabAgents"), each === "agents" && org.pulls.length ? /* @__PURE__ */ React.createElement("span", {
|
|
1777
|
+
className: "tor-count"
|
|
1778
|
+
}, org.pulls.length) : null)), admin ? /* @__PURE__ */ React.createElement("button", {
|
|
1779
|
+
type: "button",
|
|
1780
|
+
"aria-pressed": tab === "admin",
|
|
1781
|
+
className: tab === "admin" ? "ta-on" : undefined,
|
|
1782
|
+
onClick: () => setTab("admin")
|
|
1783
|
+
}, t("tabAdmin"), asking ? /* @__PURE__ */ React.createElement("span", {
|
|
1784
|
+
className: "tor-count"
|
|
1785
|
+
}, asking) : null) : null), tab === "people" ? /* @__PURE__ */ React.createElement(OrgPeople, {
|
|
1786
|
+
org,
|
|
1787
|
+
onOpen
|
|
1788
|
+
}) : tab === "agents" ? /* @__PURE__ */ React.createElement(OrgAgents, {
|
|
1789
|
+
org
|
|
1790
|
+
}) : /* @__PURE__ */ React.createElement(OrgAdmin, {
|
|
1791
|
+
org
|
|
1792
|
+
}));
|
|
1793
|
+
}
|
|
1794
|
+
function under(_org, person) {
|
|
1795
|
+
const depts = person.depts.map((each) => each.name).filter(Boolean);
|
|
1796
|
+
const title = person.profile?.title;
|
|
1797
|
+
return [...title ? [title] : [], ...depts.length ? [depts.join(" / ")] : []].join(" · ") || t("noProfile");
|
|
1798
|
+
}
|
|
1799
|
+
function roleTag(role) {
|
|
1800
|
+
const word = role === "owner" ? t("owner") : role === "admin" ? t("admin") : undefined;
|
|
1801
|
+
return word ? /* @__PURE__ */ React.createElement("span", {
|
|
1802
|
+
className: `tor-tag${role === "owner" ? " tor-tag-good" : ""}`
|
|
1803
|
+
}, word) : null;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// web-src/style.ts
|
|
1807
|
+
var STYLE = `
|
|
1808
|
+
.tor-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; }
|
|
1809
|
+
.tor-body { display: flex; flex-direction: column; gap: 16px; max-width: var(--ta-page-width); margin: 0 auto; padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
|
|
1810
|
+
.tor-quiet { color: var(--ta-muted); }
|
|
1811
|
+
.tor-company { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 4px 2px 0; border: 0; background: none; color: var(--ta-text); font: inherit; text-align: left; }
|
|
1812
|
+
.tor-company-switch { cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
1813
|
+
.tor-company-name { display: inline-flex; align-items: center; gap: 4px; font-size: calc(20px * var(--ta-font-scale)); font-weight: 600; letter-spacing: -0.01em; }
|
|
1814
|
+
.tor-company-name svg { color: var(--ta-muted); }
|
|
1815
|
+
.tor-company-line { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1816
|
+
.tor-chips-bar { margin-top: -4px; }
|
|
1817
|
+
.tor-count { margin-left: 5px; color: var(--ta-red); font-size: calc(11.5px * var(--ta-font-scale)); font-weight: 600; }
|
|
1818
|
+
.tor-small { font-size: calc(12px * var(--ta-font-scale)); }
|
|
1819
|
+
.tor-center { margin: 0; text-align: center; }
|
|
1820
|
+
.tor-section h3 { margin: 0 0 6px; padding: 0 4px; font-size: calc(12px * var(--ta-font-scale)); font-weight: 500; color: var(--ta-muted); }
|
|
1821
|
+
.tor-card { margin: 0; padding: 2px 12px; list-style: none; border-radius: 14px; background: var(--ta-raised); }
|
|
1822
|
+
.tor-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 9px 2px; border: 0; background: none; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
1823
|
+
.tor-card > .tor-row + .tor-row::before, .tor-card > li + li > .tor-row::before { content: ''; position: absolute; top: 0; left: 52px; right: 0; border-top: 1px solid var(--ta-border-muted); }
|
|
1824
|
+
.tor-row:active { background: var(--ta-hover); }
|
|
1825
|
+
.tor-row-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
|
|
1826
|
+
.tor-row-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
1827
|
+
.tor-row-name { overflow: hidden; font-size: calc(15px * var(--ta-font-scale)); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
|
|
1828
|
+
.tor-row-line { overflow: hidden; color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); text-overflow: ellipsis; white-space: nowrap; }
|
|
1829
|
+
.tor-row-side { flex: none; margin-left: auto; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale)); }
|
|
1830
|
+
.tor-tag { flex: none; padding: 0 6px; border-radius: 6px; background: var(--ta-chip, var(--ta-hover)); color: var(--ta-secondary); font-size: calc(10.5px * var(--ta-font-scale)); line-height: calc(17px * var(--ta-font-scale)); }
|
|
1831
|
+
.tor-tag-good { background: var(--ta-selected, var(--ta-hover)); color: var(--ta-text); font-weight: 500; }
|
|
1832
|
+
.tor-tag-warn { background: color-mix(in srgb, var(--ta-orange, #e8a33d) 16%, transparent); color: var(--ta-orange, #b8791a); }
|
|
1833
|
+
.tor-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ta-green); }
|
|
1834
|
+
.tor-facts { display: flex; flex-direction: column; margin: 0; padding: 4px 12px; }
|
|
1835
|
+
.tor-facts > div { display: flex; gap: 12px; padding: 9px 0; font-size: calc(13.5px * var(--ta-font-scale)); line-height: 1.5; }
|
|
1836
|
+
.tor-facts > div + div { border-top: 1px solid var(--ta-border-muted); }
|
|
1837
|
+
.tor-facts dt { flex: none; width: 4.5em; color: var(--ta-muted); }
|
|
1838
|
+
.tor-facts dd { flex: 1; min-width: 0; margin: 0; }
|
|
1839
|
+
.tor-chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
1840
|
+
.tor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
1841
|
+
.tor-wide { display: block; width: 100%; margin-top: 8px; padding: 11px 14px; border: 0; border-radius: 14px; background: var(--ta-raised); color: var(--ta-link); font: inherit; font-size: calc(14px * var(--ta-font-scale)); cursor: pointer; }
|
|
1842
|
+
.tor-small.ta-button { min-height: 28px; padding: 0 10px; font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1843
|
+
.tor-danger.ta-button { color: var(--ta-red); }
|
|
1844
|
+
.tor-profile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 2px; text-align: center; }
|
|
1845
|
+
.tor-profile-name { margin-top: 4px; font-size: calc(19px * var(--ta-font-scale)); font-weight: 600; }
|
|
1846
|
+
.tor-profile-line { max-width: 420px; margin: 4px 0 0; font-size: calc(13.5px * var(--ta-font-scale)); line-height: 1.55; }
|
|
1847
|
+
.tor-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 8px; text-align: center; }
|
|
1848
|
+
.tor-empty h2 { margin: 4px 0 0; font-size: calc(16px * var(--ta-font-scale)); font-weight: 600; }
|
|
1849
|
+
.tor-empty p { max-width: 360px; margin: 0; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.6; text-wrap: balance; }
|
|
1850
|
+
.tor-empty .tor-actions { margin-top: 12px; }
|
|
1851
|
+
.tor-ask { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--ta-raised); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.5; }
|
|
1852
|
+
.tor-ask .tor-actions { margin-left: auto; flex: none; }
|
|
1853
|
+
.tor-name-side { display: flex; align-items: center; gap: 8px; margin: 0; font-size: calc(12.5px * var(--ta-font-scale)); color: var(--ta-secondary); }
|
|
1854
|
+
.tor-tree { display: flex; flex-direction: column; margin: 0; padding: 6px 12px; }
|
|
1855
|
+
.tor-tree > div { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: calc(13.5px * var(--ta-font-scale)); }
|
|
1856
|
+
.tor-tree > div + div { border-top: 1px solid var(--ta-border-muted); }
|
|
1857
|
+
.tor-tree .tor-tree-name { flex: 1; min-width: 0; }
|
|
1858
|
+
.tor-tree > .tor-tree-add { display: flex; align-items: center; gap: 6px; width: 100%; padding: 11px 0; border: 0; border-top: 1px solid var(--ta-border-muted); background: none; color: var(--ta-secondary); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); cursor: pointer; }
|
|
1859
|
+
.tor-tree > .tor-tree-add:first-child { border-top: 0; }
|
|
1860
|
+
.tor-tree > .tor-tree-add:hover { color: var(--ta-text); }
|
|
1861
|
+
.tor-tree > .tor-tree-form { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 0; }
|
|
1862
|
+
.tor-tree-form .tor-actions { justify-content: flex-end; }
|
|
1863
|
+
.tor-switch { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
|
|
1864
|
+
.tor-switch > .ta-button { flex: none; }
|
|
1865
|
+
.tor-switch + .tor-switch { border-top: 1px solid var(--ta-border-muted); }
|
|
1866
|
+
.tor-switch-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; font-size: calc(13.5px * var(--ta-font-scale)); line-height: 1.45; }
|
|
1867
|
+
.tor-choice { display: inline-flex; flex: none; align-items: center; gap: 4px; align-self: center; padding: 4px 2px; border: 0; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); cursor: pointer; }
|
|
1868
|
+
.tor-choice:hover { color: var(--ta-text); }
|
|
1869
|
+
.tor-link { padding: 2px 6px; border: 0; border-radius: 6px; background: none; color: var(--ta-link); font: inherit; cursor: pointer; }
|
|
1870
|
+
.tor-pulled { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; font-size: calc(13px * var(--ta-font-scale)); line-height: 1.5; }
|
|
1871
|
+
.tor-pulled + .tor-pulled { border-top: 1px solid var(--ta-border-muted); }
|
|
1872
|
+
`;
|
|
1873
|
+
function injectStyle() {
|
|
1874
|
+
const style = document.createElement("style");
|
|
1875
|
+
style.dataset.taOrg = "";
|
|
1876
|
+
style.textContent = STYLE;
|
|
1877
|
+
document.head.append(style);
|
|
1878
|
+
return () => style.remove();
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// web-src/index.tsx
|
|
1882
|
+
function activate(api) {
|
|
1883
|
+
bind(api.React);
|
|
1884
|
+
bindPage(api);
|
|
1885
|
+
const removeStyle = injectStyle();
|
|
1886
|
+
api.registerView("org", { title: () => t("title"), icon: icon("Building2"), render: OrgPage, group: "people", order: 80 });
|
|
1887
|
+
const stop = book.start();
|
|
1888
|
+
return () => {
|
|
1889
|
+
stop();
|
|
1890
|
+
removeStyle();
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
export {
|
|
1894
|
+
activate as default
|
|
1895
|
+
};
|