@celljs/ta-creator 4.34.0 → 4.36.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/web/index.js CHANGED
@@ -192,12 +192,6 @@ var PublishUtil;
192
192
  PublishUtil.publishing = publishing;
193
193
  })(PublishUtil ||= {});
194
194
 
195
- // web-src/react.ts
196
- var React;
197
- function bind(react) {
198
- React = react;
199
- }
200
-
201
195
  // web-src/values.ts
202
196
  var text2 = (value, max = 2000) => typeof value === "string" ? value.trim().slice(0, max) : "";
203
197
  var texts = (value, max = 50) => Array.isArray(value) ? value.map((one) => text2(one, 200)).filter(Boolean).slice(0, max) : [];
@@ -219,10 +213,446 @@ function count(value, fallback) {
219
213
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : fallback;
220
214
  }
221
215
 
216
+ // web-src/quality.ts
217
+ var RUBRIC = [
218
+ { id: "hook", weight: 20, asks: "the first 3 seconds give the point, a question or a picture that moves; no slow greeting" },
219
+ { id: "clarity", weight: 20, asks: "one idea, its terms explained, every fact checked; a newcomer follows it" },
220
+ { id: "visuals", weight: 15, asks: "scenes vary (a device or a flow every other one), none of the host talking 20 seconds on" },
221
+ { id: "pace", weight: 15, asks: "its length fits the platform, short sentences, no dead air, it ends when the point is made" },
222
+ { id: "title", weight: 10, asks: "title and cover say truly and plainly what one gets: a number, a question, never exaggerated" },
223
+ { id: "series", weight: 10, asks: "of a series: its number, a line to the last piece, and the next piece told at the end" },
224
+ { id: "fit", weight: 10, asks: "each version in its platform's form, voice, length and tags; its declaration ticked" }
225
+ ];
226
+ var PASS = 80;
227
+ var Quality;
228
+ ((Quality) => {
229
+ function score(value, now) {
230
+ const given = Array.isArray(value) ? value.map(object2).filter((one) => !!one) : [];
231
+ const parts = RUBRIC.map(({ id }) => {
232
+ const one = given.find((it) => it.id === id);
233
+ const note = text2(one?.note, 200);
234
+ return { id, score: Math.min(100, count(one?.score, 0)), ...note ? { note } : {} };
235
+ });
236
+ const total = Math.round(parts.reduce((all, one, at) => all + one.score * RUBRIC[at].weight / 100, 0));
237
+ return { total, parts, at: now };
238
+ }
239
+ Quality.score = score;
240
+ function weak(score2) {
241
+ return score2.parts.filter((one) => one.score < PASS).sort((a, b) => a.score - b.score);
242
+ }
243
+ Quality.weak = weak;
244
+ function fields(kept) {
245
+ const one = object2(kept.score);
246
+ return one && time2(one.at) ? { score: { ...score(one.parts, time2(one.at)) } } : {};
247
+ }
248
+ Quality.fields = fields;
249
+ })(Quality ||= {});
250
+
251
+ // web-src/react.ts
252
+ var React;
253
+ function bind(react) {
254
+ React = react;
255
+ }
256
+
257
+ // ../ta-protocol/esm/common/message-protocol.js
258
+ var TaMessageContext;
259
+ (function(TaMessageContext2) {
260
+ const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
261
+ function wrap(context, message) {
262
+ return `<context>
263
+ ${context}
264
+ </context>
265
+ ${message}`;
266
+ }
267
+ TaMessageContext2.wrap = wrap;
268
+ function strip(message) {
269
+ return message.replace(BLOCK, "");
270
+ }
271
+ TaMessageContext2.strip = strip;
272
+ function read(message) {
273
+ var _a;
274
+ const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
275
+ return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
276
+ }
277
+ TaMessageContext2.read = read;
278
+ })(TaMessageContext || (TaMessageContext = {}));
279
+ var TaMessageSource;
280
+ (function(TaMessageSource2) {
281
+ TaMessageSource2.DOUBLE = "ta:double";
282
+ const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
283
+ function mark(message, from, detail) {
284
+ return marked(message, line(from, detail));
285
+ }
286
+ TaMessageSource2.mark = mark;
287
+ function notice(message, from, detail) {
288
+ return marked(message, line(from, detail, true));
289
+ }
290
+ TaMessageSource2.notice = notice;
291
+ function line(from, detail, notice2 = false) {
292
+ return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
293
+ }
294
+ TaMessageSource2.line = line;
295
+ function of(message) {
296
+ const context = TaMessageContext.read(message);
297
+ const match = context === undefined ? null : LINE.exec(context);
298
+ return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
299
+ }
300
+ TaMessageSource2.of = of;
301
+ function isNotice(message) {
302
+ var _a;
303
+ return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
304
+ }
305
+ TaMessageSource2.isNotice = isNotice;
306
+ TaMessageSource2.SECTION = "ta-sources";
307
+ TaMessageSource2.PROMPT = [
308
+ "Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
309
+ "One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
310
+ "- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
311
+ "- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
312
+ "- Never quote it as the user's words nor answer it as if they had said it."
313
+ ].join(`
314
+ `);
315
+ function marked(message, source) {
316
+ if (/^[/!]/.test(message) || of(message)) {
317
+ return message;
318
+ }
319
+ const context = TaMessageContext.read(message);
320
+ return TaMessageContext.wrap(context === undefined ? source : `${context}
321
+ ${source}`, TaMessageContext.strip(message));
322
+ }
323
+ })(TaMessageSource || (TaMessageSource = {}));
324
+ var TaImageNote;
325
+ (function(TaImageNote2) {
326
+ const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
327
+ function strip(text3) {
328
+ const lines = text3.split(`
329
+ `);
330
+ const kept = lines.filter((line) => !NOTE.test(line.trim()));
331
+ if (kept.length === lines.length) {
332
+ return text3;
333
+ }
334
+ return kept.join(`
335
+ `).replace(/\n+$/, "").replace(/^\n+/, "");
336
+ }
337
+ TaImageNote2.strip = strip;
338
+ })(TaImageNote || (TaImageNote = {}));
339
+ var TaImageSize;
340
+ (function(TaImageSize2) {
341
+ const JPEG_BYTES = 256 * 1024;
342
+ function type(bytes) {
343
+ const at = (offset, ...values) => values.every((value, index) => bytes[offset + index] === value);
344
+ return at(0, 255, 216, 255) ? "image/jpeg" : at(0, 137, 80, 78, 71) ? "image/png" : at(0, 71, 73, 70, 56) ? "image/gif" : at(0, 82, 73, 70, 70) && at(8, 87, 69, 66, 80) ? "image/webp" : undefined;
345
+ }
346
+ TaImageSize2.type = type;
347
+ function of(base64) {
348
+ var _a, _b, _c;
349
+ let bytes;
350
+ try {
351
+ const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
352
+ bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
353
+ } catch (_d) {
354
+ return;
355
+ }
356
+ const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
357
+ return size && size.width > 0 && size.height > 0 ? size : undefined;
358
+ }
359
+ TaImageSize2.of = of;
360
+ function u16be(bytes, at) {
361
+ return bytes[at] << 8 | bytes[at + 1];
362
+ }
363
+ function u16le(bytes, at) {
364
+ return bytes[at] | bytes[at + 1] << 8;
365
+ }
366
+ function u24le(bytes, at) {
367
+ return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
368
+ }
369
+ function u32be(bytes, at) {
370
+ return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
371
+ }
372
+ function text3(bytes, at, length) {
373
+ return String.fromCharCode(...bytes.subarray(at, at + length));
374
+ }
375
+ function png(bytes) {
376
+ return bytes.length >= 24 && bytes[0] === 137 && text3(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
377
+ }
378
+ function gif(bytes) {
379
+ return bytes.length >= 10 && text3(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
380
+ }
381
+ function webp(bytes) {
382
+ if (bytes.length < 30 || text3(bytes, 0, 4) !== "RIFF" || text3(bytes, 8, 4) !== "WEBP") {
383
+ return;
384
+ }
385
+ switch (text3(bytes, 12, 4)) {
386
+ case "VP8 ":
387
+ return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
388
+ case "VP8L": {
389
+ const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
390
+ return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
391
+ }
392
+ case "VP8X":
393
+ return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
394
+ default:
395
+ return;
396
+ }
397
+ }
398
+ function jpeg(bytes) {
399
+ if (bytes[0] !== 255 || bytes[1] !== 216) {
400
+ return;
401
+ }
402
+ let at = 2;
403
+ while (at + 9 < bytes.length) {
404
+ if (bytes[at] !== 255) {
405
+ return;
406
+ }
407
+ const marker = bytes[at + 1];
408
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
409
+ return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
410
+ }
411
+ at += 2 + u16be(bytes, at + 2);
412
+ }
413
+ return;
414
+ }
415
+ })(TaImageSize || (TaImageSize = {}));
416
+ var TaAgentSummary;
417
+ (function(TaAgentSummary2) {
418
+ const START = /^\s*<conversation_history_summary>/;
419
+ const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
420
+ function read(text3) {
421
+ if (!START.test(text3)) {
422
+ return;
423
+ }
424
+ return text3.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
425
+ }
426
+ TaAgentSummary2.read = read;
427
+ function strip(text3) {
428
+ return text3.replace(BLOCK, "");
429
+ }
430
+ TaAgentSummary2.strip = strip;
431
+ })(TaAgentSummary || (TaAgentSummary = {}));
432
+ var TaPictureNote;
433
+ (function(TaPictureNote2) {
434
+ TaPictureNote2.OPEN = "<pictures>";
435
+ TaPictureNote2.CLOSE = "</pictures>";
436
+ const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
437
+ const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
438
+ function take(text3) {
439
+ const told = new Map;
440
+ if (!/<p/i.test(text3)) {
441
+ return { said: text3, told };
442
+ }
443
+ const said = text3.replace(BLOCK, (_all, body) => {
444
+ const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
445
+ rows.forEach((row, index) => {
446
+ var _a;
447
+ var _b, _c;
448
+ const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
449
+ const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
450
+ if (what) {
451
+ told.set(Number(row[1]), what);
452
+ }
453
+ });
454
+ return "";
455
+ });
456
+ return { said: said === text3 ? text3 : said.replace(/\n{3,}/g, `
457
+
458
+ `).trim(), told };
459
+ }
460
+ TaPictureNote2.take = take;
461
+ function strip(text3) {
462
+ return take(text3).said;
463
+ }
464
+ TaPictureNote2.strip = strip;
465
+ })(TaPictureNote || (TaPictureNote = {}));
466
+ var TaSkillUse;
467
+ (function(TaSkillUse2) {
468
+ const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
469
+ function parse(message) {
470
+ var _a;
471
+ const match = BLOCK.exec(message);
472
+ if (!match) {
473
+ return;
474
+ }
475
+ return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
476
+ }
477
+ TaSkillUse2.parse = parse;
478
+ function command(use) {
479
+ return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
480
+ }
481
+ TaSkillUse2.command = command;
482
+ })(TaSkillUse || (TaSkillUse = {}));
483
+ var TaTaskNote;
484
+ (function(TaTaskNote2) {
485
+ const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
486
+ const ATTRIBUTE = /(\w+)="([^"]*)"/g;
487
+ function write(note) {
488
+ const attributes = [`id="${quote(note.id)}"`];
489
+ if (note.was !== undefined) {
490
+ attributes.push(`was="${quote(note.was)}"`);
491
+ }
492
+ attributes.push(`title="${quote(note.title)}"`);
493
+ if (note.status !== undefined) {
494
+ attributes.push(`status="${quote(note.status)}"`);
495
+ }
496
+ return `<task_${note.kind} ${attributes.join(" ")}>
497
+ ${note.body}
498
+ </task_${note.kind}>`;
499
+ }
500
+ TaTaskNote2.write = write;
501
+ function parse(text3) {
502
+ const match = NOTE.exec(text3.trim());
503
+ if (!match) {
504
+ return;
505
+ }
506
+ const attributes = {};
507
+ for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
508
+ attributes[name] = unquote(value);
509
+ }
510
+ if (!attributes.id || attributes.title === undefined) {
511
+ return;
512
+ }
513
+ const { id, title, status, was } = attributes;
514
+ return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
515
+ }
516
+ TaTaskNote2.parse = parse;
517
+ function quote(text3) {
518
+ return text3.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/\n/g, " ");
519
+ }
520
+ function unquote(text3) {
521
+ return text3.replace(/&quot;/g, '"').replace(/&amp;/g, "&");
522
+ }
523
+ })(TaTaskNote || (TaTaskNote = {}));
524
+ var TaSecretRef;
525
+ (function(TaSecretRef2) {
526
+ TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
527
+ const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
528
+ const KINDS2 = [
529
+ [/^PHONE(?:_\d+)?$/, "phone"],
530
+ [/^EMAIL(?:_\d+)?$/, "email"],
531
+ [/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
532
+ [/^BANK_CARD(?:_\d+)?$/, "bankCard"]
533
+ ];
534
+ function has(text3) {
535
+ return text3.includes("TA_SECRET_") && new RegExp(REF.source).test(text3);
536
+ }
537
+ TaSecretRef2.has = has;
538
+ function kind(name) {
539
+ var _a;
540
+ var _b;
541
+ return (_b = (_a = KINDS2.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
542
+ }
543
+ TaSecretRef2.kind = kind;
544
+ function split(text3) {
545
+ if (!has(text3)) {
546
+ return [{ text: text3 }];
547
+ }
548
+ const parts = [];
549
+ let at = 0;
550
+ for (const match of text3.matchAll(REF)) {
551
+ if (match.index > at) {
552
+ parts.push({ text: text3.slice(at, match.index) });
553
+ }
554
+ parts.push({ secret: match[1], kind: kind(match[1]) });
555
+ at = match.index + match[0].length;
556
+ }
557
+ if (at < text3.length) {
558
+ parts.push({ text: text3.slice(at) });
559
+ }
560
+ return parts;
561
+ }
562
+ TaSecretRef2.split = split;
563
+ function plain(text3, label) {
564
+ return has(text3) ? text3.replace(REF, (_whole, name) => label(name, kind(name))) : text3;
565
+ }
566
+ TaSecretRef2.plain = plain;
567
+ })(TaSecretRef || (TaSecretRef = {}));
568
+
569
+ // web-src/efficiency.ts
570
+ var HOUR = 3600000;
571
+ var DAY = 24 * HOUR;
572
+ var Efficiency;
573
+ ((Efficiency) => {
574
+ Efficiency.SPAN = 7 * DAY;
575
+ function costOf(messages, now) {
576
+ let ms = 0;
577
+ let tokens = 0;
578
+ let turns = 0;
579
+ for (const message of messages) {
580
+ const kept = object2(message);
581
+ if (kept?.role === "assistant") {
582
+ ms += count(kept.durationMs, 0);
583
+ tokens += count(object2(kept.usage)?.totalTokens, 0);
584
+ } else if (kept?.role === "user") {
585
+ turns++;
586
+ }
587
+ }
588
+ return ms ? { minutes: Math.round(ms / 6000) / 10, ...tokens ? { tokens } : {}, turns, at: now } : undefined;
589
+ }
590
+ Efficiency.costOf = costOf;
591
+ function cost(value) {
592
+ const kept = object2(value);
593
+ const at = time2(kept?.at);
594
+ return kept && at && typeof kept.minutes === "number" ? { minutes: Math.max(0, kept.minutes), ...count(kept.tokens, 0) ? { tokens: count(kept.tokens, 0) } : {}, turns: count(kept.turns, 0), at } : undefined;
595
+ }
596
+ Efficiency.cost = cost;
597
+ function fields(kept) {
598
+ const made = cost(kept.cost);
599
+ return { ...time2(kept.started) ? { started: time2(kept.started) } : {}, ...made ? { cost: made } : {} };
600
+ }
601
+ Efficiency.fields = fields;
602
+ function leadHours(item) {
603
+ return item.stage === "published" && item.links?.length ? Math.round((outAt(item) - item.at) / HOUR * 10) / 10 : undefined;
604
+ }
605
+ Efficiency.leadHours = leadHours;
606
+ function taskRuns(runs, from, to) {
607
+ const of = runs.filter((one) => {
608
+ const at = Date.parse(one.startedAt);
609
+ return at >= from && at < to && one.status !== "running";
610
+ });
611
+ return {
612
+ runs: of.length,
613
+ empty: of.filter((one) => one.quiet).length,
614
+ failed: of.filter((one) => one.status === "error").length,
615
+ minutes: Math.round(of.reduce((all, one) => all + (one.ranMs ?? 0), 0) / 60000)
616
+ };
617
+ }
618
+ Efficiency.taskRuns = taskRuns;
619
+ function pieces(items, from, to) {
620
+ const of = items.filter((one) => {
621
+ const at = one.stage === "published" && one.links?.length ? outAt(one) : 0;
622
+ return !one.dropped && at >= from && at < to;
623
+ });
624
+ const costs = of.flatMap((one) => one.cost ? [one.cost] : []);
625
+ return {
626
+ pieces: of.length,
627
+ leadHours: middle(of.map(leadHours)),
628
+ minutes: middle(costs.map((one) => one.minutes)),
629
+ tokens: middle(costs.map((one) => one.tokens)),
630
+ turns: middle(costs.map((one) => one.turns))
631
+ };
632
+ }
633
+ Efficiency.pieces = pieces;
634
+ function outAt(item) {
635
+ return Math.min(...(item.links ?? []).map((one) => one.scheduled ?? one.at));
636
+ }
637
+ function middle(values) {
638
+ const known = values.filter((one) => typeof one === "number").sort((a, b) => a - b);
639
+ if (!known.length) {
640
+ return;
641
+ }
642
+ const at = Math.floor(known.length / 2);
643
+ return known.length % 2 ? known[at] : Math.round((known[at - 1] + known[at]) / 2 * 10) / 10;
644
+ }
645
+ Efficiency.middle = middle;
646
+ function windows(now) {
647
+ return { before: [now - 2 * Efficiency.SPAN, now - Efficiency.SPAN], after: [now - Efficiency.SPAN, now + 1] };
648
+ }
649
+ Efficiency.windows = windows;
650
+ })(Efficiency ||= {});
651
+
222
652
  // web-src/creator-util.ts
223
- var DAY = 86400000;
653
+ var DAY2 = 86400000;
224
654
  var MAX_TOPICS = 200;
225
- var HOT_FOR = 2 * DAY;
655
+ var HOT_FOR = 2 * DAY2;
226
656
  var MAX_TONES = 3;
227
657
  var CreatorUtil;
228
658
  ((CreatorUtil) => {
@@ -411,6 +841,8 @@ var CreatorUtil;
411
841
  ...kept.dropped === true ? { dropped: true } : {},
412
842
  ...time2(kept.commentsAt) ? { commentsAt: time2(kept.commentsAt) } : {},
413
843
  ...time2(kept.commentsGap) ? { commentsGap: time2(kept.commentsGap) } : {},
844
+ ...Efficiency.fields(kept),
845
+ ...Quality.fields(kept),
414
846
  at,
415
847
  changedAt: time2(kept.changedAt) ?? at
416
848
  };
@@ -536,7 +968,7 @@ var CreatorUtil;
536
968
  if (!goal) {
537
969
  return;
538
970
  }
539
- const end = goal.from + goal.days * DAY;
971
+ const end = goal.from + goal.days * DAY2;
540
972
  const published = items2.filter((one) => one.stage === "published" && (one.links?.length ?? 0) > 0).filter((one) => {
541
973
  const at = publishedAt(one);
542
974
  return at >= goal.from && at < end;
@@ -544,7 +976,7 @@ var CreatorUtil;
544
976
  return {
545
977
  videos: published.filter((one) => one.form === "video").length,
546
978
  posts: published.filter((one) => one.form !== "video").length,
547
- day: Math.max(1, Math.min(goal.days, Math.floor((now - goal.from) / DAY) + 1))
979
+ day: Math.max(1, Math.min(goal.days, Math.floor((now - goal.from) / DAY2) + 1))
548
980
  };
549
981
  }
550
982
  CreatorUtil.progress = progress;
@@ -583,10 +1015,7 @@ var CreatorUtil;
583
1015
  function need(value) {
584
1016
  const kept = object2(value);
585
1017
  const words = text2(kept?.text, 300);
586
- if (!kept || !words) {
587
- return;
588
- }
589
- return { id: text2(kept.id, 60), text: words, ...kept.done === true ? { done: true } : {} };
1018
+ return kept && words ? { id: text2(kept.id, 60), text: words, ...kept.done === true ? { done: true } : {} } : undefined;
590
1019
  }
591
1020
  CreatorUtil.need = need;
592
1021
  function version(value) {
@@ -626,9 +1055,7 @@ var CreatorUtil;
626
1055
  return {
627
1056
  platform: platform2,
628
1057
  views: count(kept.views, 0),
629
- ...optional("likes"),
630
- ...optional("comments"),
631
- ...optional("follows"),
1058
+ ...Object.assign({}, ...["likes", "comments", "follows", "watch"].map(optional)),
632
1059
  ...typeof kept.completion === "number" && Number.isFinite(kept.completion) ? { completion: Math.max(0, Math.min(1, kept.completion)) } : {},
633
1060
  at: time2(kept.at) ?? Date.now()
634
1061
  };
@@ -728,7 +1155,7 @@ var EN = {
728
1155
  startGoal: "Start a 30-day goal",
729
1156
  source: "Source",
730
1157
  failed: "Did not work: {error}",
731
- makePrompt: "Make this piece: {title} ({id})",
1158
+ makePrompt: "Make this piece: {title}",
732
1159
  findPrompt: "Find hot topics for my channel now",
733
1160
  changePrompt: "Change {id}: {note}",
734
1161
  all: "All",
@@ -783,6 +1210,40 @@ var EN = {
783
1210
  perPiece: "views a piece",
784
1211
  noViews: "no views yet",
785
1212
  completion: "watched {n}%",
1213
+ eachPiece: "Each piece",
1214
+ statViews: "{n} views",
1215
+ statWatch: "{n}s on average",
1216
+ statLikes: "{n} likes",
1217
+ statComments: "{n} comments",
1218
+ statFollows: "+{n} followers",
1219
+ statWaiting: "Read a day after it is out",
1220
+ statLate: "Not read in 48 hours",
1221
+ score: "Quality score, 80 to pass",
1222
+ score_hook: "Hook",
1223
+ score_clarity: "Clarity",
1224
+ score_visuals: "Visuals",
1225
+ score_pace: "Pace",
1226
+ score_title: "Title",
1227
+ score_series: "Series",
1228
+ score_fit: "Platforms",
1229
+ effTitle: "What it took Ta",
1230
+ effHint: "last 7 days against the 7 before",
1231
+ effBefore: "Before",
1232
+ effAfter: "Last 7 days",
1233
+ effPieces: "Pieces published",
1234
+ effLead: "Topic to out",
1235
+ effMinutes: "Model time a piece",
1236
+ effMin: " min",
1237
+ effTokens: "Tokens a piece",
1238
+ effTurns: "Your messages a piece",
1239
+ eff_topics: "Topic runs",
1240
+ eff_comments: "Comment runs",
1241
+ eff_review: "Review runs",
1242
+ effRuns: "{n} · {empty} empty · {failed} failed",
1243
+ effCost: "Took",
1244
+ effLeadValue: "{n} h to out",
1245
+ effMinutesValue: "model {n} min",
1246
+ effTokensValue: "{n} tokens",
786
1247
  pieces: "{n} pieces",
787
1248
  weekly: "Views by week",
788
1249
  top: "Did best",
@@ -934,7 +1395,7 @@ var ZH = {
934
1395
  startGoal: "开始 30 天目标",
935
1396
  source: "出处",
936
1397
  failed: "没做成:{error}",
937
- makePrompt: "做这条内容:{title}({id})",
1398
+ makePrompt: "做这条内容:{title}",
938
1399
  findPrompt: "现在给我的内容号找一批热点选题",
939
1400
  changePrompt: "{id} 要改:{note}",
940
1401
  all: "全部",
@@ -989,6 +1450,40 @@ var ZH = {
989
1450
  perPiece: "条均播放",
990
1451
  noViews: "还没有播放数据",
991
1452
  completion: "完播 {n}%",
1453
+ eachPiece: "每条数据",
1454
+ statViews: "播放 {n}",
1455
+ statWatch: "均看 {n} 秒",
1456
+ statLikes: "赞 {n}",
1457
+ statComments: "评 {n}",
1458
+ statFollows: "涨粉 {n}",
1459
+ statWaiting: "发布满一天后读取",
1460
+ statLate: "超过 48 小时未读",
1461
+ score: "品质自评 · 80 分过审",
1462
+ score_hook: "开头",
1463
+ score_clarity: "讲清楚",
1464
+ score_visuals: "画面",
1465
+ score_pace: "节奏",
1466
+ score_title: "标题",
1467
+ score_series: "系列",
1468
+ score_fit: "平台",
1469
+ effTitle: "执行效率",
1470
+ effHint: "近 7 天对比前 7 天",
1471
+ effBefore: "前 7 天",
1472
+ effAfter: "近 7 天",
1473
+ effPieces: "发布条数",
1474
+ effLead: "选题到发布",
1475
+ effMinutes: "每条运行时长",
1476
+ effMin: " 分",
1477
+ effTokens: "每条 token",
1478
+ effTurns: "每条你发的消息",
1479
+ eff_topics: "选题任务",
1480
+ eff_comments: "评论任务",
1481
+ eff_review: "复盘任务",
1482
+ effRuns: "{n} 次 · 空跑 {empty} · 失败 {failed}",
1483
+ effCost: "耗时",
1484
+ effLeadValue: "选题到发布 {n} 小时",
1485
+ effMinutesValue: "运行 {n} 分",
1486
+ effTokensValue: "{n} token",
992
1487
  pieces: "{n} 条",
993
1488
  weekly: "每周播放",
994
1489
  top: "表现最好",
@@ -1140,7 +1635,7 @@ var ZH_TW = {
1140
1635
  startGoal: "開始 30 天目標",
1141
1636
  source: "出處",
1142
1637
  failed: "沒做成:{error}",
1143
- makePrompt: "做這條內容:{title}({id})",
1638
+ makePrompt: "做這條內容:{title}",
1144
1639
  findPrompt: "現在給我的內容號找一批熱點選題",
1145
1640
  changePrompt: "{id} 要改:{note}",
1146
1641
  all: "全部",
@@ -1195,6 +1690,40 @@ var ZH_TW = {
1195
1690
  perPiece: "條均播放",
1196
1691
  noViews: "還沒有播放數據",
1197
1692
  completion: "完播 {n}%",
1693
+ eachPiece: "每則數據",
1694
+ statViews: "播放 {n}",
1695
+ statWatch: "均看 {n} 秒",
1696
+ statLikes: "讚 {n}",
1697
+ statComments: "評 {n}",
1698
+ statFollows: "漲粉 {n}",
1699
+ statWaiting: "發布滿一天後讀取",
1700
+ statLate: "超過 48 小時未讀",
1701
+ score: "品質自評 · 80 分過審",
1702
+ score_hook: "開頭",
1703
+ score_clarity: "講清楚",
1704
+ score_visuals: "畫面",
1705
+ score_pace: "節奏",
1706
+ score_title: "標題",
1707
+ score_series: "系列",
1708
+ score_fit: "平台",
1709
+ effTitle: "執行效率",
1710
+ effHint: "近 7 天對比前 7 天",
1711
+ effBefore: "前 7 天",
1712
+ effAfter: "近 7 天",
1713
+ effPieces: "發布則數",
1714
+ effLead: "選題到發布",
1715
+ effMinutes: "每則執行時長",
1716
+ effMin: " 分",
1717
+ effTokens: "每則 token",
1718
+ effTurns: "每則你發的訊息",
1719
+ eff_topics: "選題任務",
1720
+ eff_comments: "留言任務",
1721
+ eff_review: "複盤任務",
1722
+ effRuns: "{n} 次 · 空跑 {empty} · 失敗 {failed}",
1723
+ effCost: "耗時",
1724
+ effLeadValue: "選題到發布 {n} 小時",
1725
+ effMinutesValue: "執行 {n} 分",
1726
+ effTokensValue: "{n} token",
1198
1727
  pieces: "{n} 條",
1199
1728
  weekly: "每週播放",
1200
1729
  top: "表現最好",
@@ -1346,7 +1875,7 @@ var JA = {
1346
1875
  startGoal: "30 日間の目標を始める",
1347
1876
  source: "出典",
1348
1877
  failed: "できませんでした:{error}",
1349
- makePrompt: "このコンテンツを作って:{title}({id})",
1878
+ makePrompt: "このコンテンツを作って:{title}",
1350
1879
  findPrompt: "私のチャンネル向けに今の話題からネタを探して",
1351
1880
  changePrompt: "{id} を直して:{note}",
1352
1881
  all: "すべて",
@@ -1401,6 +1930,40 @@ var JA = {
1401
1930
  perPiece: "1 件あたり再生",
1402
1931
  noViews: "まだ再生データなし",
1403
1932
  completion: "完走 {n}%",
1933
+ eachPiece: "作品ごとの数字",
1934
+ statViews: "再生 {n}",
1935
+ statWatch: "平均 {n} 秒",
1936
+ statLikes: "いいね {n}",
1937
+ statComments: "コメント {n}",
1938
+ statFollows: "フォロワー +{n}",
1939
+ statWaiting: "公開から 1 日後に読み取り",
1940
+ statLate: "48 時間読めていません",
1941
+ score: "品質の自己採点 · 80 点で審査へ",
1942
+ score_hook: "冒頭",
1943
+ score_clarity: "わかりやすさ",
1944
+ score_visuals: "画面",
1945
+ score_pace: "テンポ",
1946
+ score_title: "タイトル",
1947
+ score_series: "シリーズ",
1948
+ score_fit: "プラットフォーム",
1949
+ effTitle: "実行効率",
1950
+ effHint: "直近 7 日とその前の 7 日",
1951
+ effBefore: "前の 7 日",
1952
+ effAfter: "直近 7 日",
1953
+ effPieces: "公開数",
1954
+ effLead: "企画から公開",
1955
+ effMinutes: "1 本の実行時間",
1956
+ effMin: " 分",
1957
+ effTokens: "1 本の token",
1958
+ effTurns: "1 本のあなたのメッセージ",
1959
+ eff_topics: "企画タスク",
1960
+ eff_comments: "コメントタスク",
1961
+ eff_review: "振り返りタスク",
1962
+ effRuns: "{n} 回 · 空振り {empty} · 失敗 {failed}",
1963
+ effCost: "所要",
1964
+ effLeadValue: "企画から公開 {n} 時間",
1965
+ effMinutesValue: "実行 {n} 分",
1966
+ effTokensValue: "{n} token",
1404
1967
  pieces: "{n} 件",
1405
1968
  weekly: "週ごとの再生",
1406
1969
  top: "好調だったもの",
@@ -1541,11 +2104,14 @@ async function talk(pi, title, message) {
1541
2104
  await pi.server.prompt(session.sessionId, { message, clientMessageId: crypto.randomUUID() });
1542
2105
  return session.sessionFile;
1543
2106
  }
2107
+ function makeMessage(pi, item) {
2108
+ const shown = format(useWordsOf(pi).makePrompt, { title: item.title });
2109
+ return TaMessageSource.mark(TaMessageContext.wrap(`Make the piece ${item.id} of Creator.`, shown), NAME);
2110
+ }
1544
2111
  async function make(context, item) {
1545
2112
  const { pi, store } = context;
1546
- const words = useWordsOf(pi);
1547
2113
  await store.call("start", item.id);
1548
- const file = await talk(pi, item.title, format(words.makePrompt, { title: item.title, id: item.id }));
2114
+ const file = await talk(pi, item.title, makeMessage(pi, item));
1549
2115
  if (file) {
1550
2116
  await store.call("update", item.id, { session: file });
1551
2117
  }
@@ -1555,7 +2121,7 @@ async function openPiece(context, item) {
1555
2121
  if (item.session && await pi.openChat?.(item.session)) {
1556
2122
  return;
1557
2123
  }
1558
- await talk(pi, item.title, format(useWordsOf(pi).makePrompt, { title: item.title, id: item.id }));
2124
+ await talk(pi, item.title, makeMessage(pi, item));
1559
2125
  }
1560
2126
  async function tell(context, item, text3) {
1561
2127
  const { pi } = context;
@@ -1821,7 +2387,18 @@ function ReviewCard({
1821
2387
  className: "tcre-tags"
1822
2388
  }, version.tags.map((tag) => `#${tag}`).join(" ")), item.origin && /* @__PURE__ */ React.createElement("div", {
1823
2389
  className: "tcre-origin"
1824
- }, words.source, ": ", item.origin.title ?? item.origin.url, item.origin.author ? ` · ${item.origin.author}` : ""), !!item.checks?.length && /* @__PURE__ */ React.createElement("div", {
2390
+ }, words.source, ": ", item.origin.title ?? item.origin.url, item.origin.author ? ` · ${item.origin.author}` : ""), item.score && /* @__PURE__ */ React.createElement("div", {
2391
+ className: "tcre-score",
2392
+ "data-low": item.score.total < PASS || undefined
2393
+ }, /* @__PURE__ */ React.createElement("b", null, item.score.total), /* @__PURE__ */ React.createElement("span", {
2394
+ className: "tcre-score-label"
2395
+ }, words.score), /* @__PURE__ */ React.createElement("span", {
2396
+ className: "tcre-score-parts"
2397
+ }, item.score.parts.map((part) => /* @__PURE__ */ React.createElement("span", {
2398
+ key: part.id,
2399
+ title: part.note,
2400
+ "data-low": part.score < PASS || undefined
2401
+ }, words[`score_${part.id}`], " ", part.score)))), !!item.checks?.length && /* @__PURE__ */ React.createElement("div", {
1825
2402
  className: "tcre-checks"
1826
2403
  }, item.checks.map((check) => /* @__PURE__ */ React.createElement("span", {
1827
2404
  key: check.text,
@@ -1920,10 +2497,10 @@ var ReviewCode;
1920
2497
  })(ReviewCode ||= {});
1921
2498
 
1922
2499
  // web-src/channel-util.ts
1923
- var HOUR = 3600000;
1924
- var DAY2 = 24 * HOUR;
2500
+ var HOUR2 = 3600000;
2501
+ var DAY3 = 24 * HOUR2;
1925
2502
  var MAX_COMMENTS = 600;
1926
- var COMMENTS_FOR = 60 * DAY2;
2503
+ var COMMENTS_FOR = 60 * DAY3;
1927
2504
  var MAX_LESSONS = 40;
1928
2505
  var ChannelUtil;
1929
2506
  ((ChannelUtil) => {
@@ -2030,7 +2607,7 @@ var ChannelUtil;
2030
2607
  function latestInsights(insights2) {
2031
2608
  const ta = insights2.filter((one) => one.by !== "user" && !one.state);
2032
2609
  const newest = ta[0]?.at ?? 0;
2033
- return insights2.filter((one) => one.by === "user" || !one.state && newest - one.at < DAY2);
2610
+ return insights2.filter((one) => one.by === "user" || !one.state && newest - one.at < DAY3);
2034
2611
  }
2035
2612
  ChannelUtil.latestInsights = latestInsights;
2036
2613
  function proposed(insights2) {
@@ -2053,7 +2630,7 @@ var ChannelUtil;
2053
2630
  }
2054
2631
  const published = items.filter((one) => one.stage === "published" && !one.dropped).map(CreatorUtil.publishedAt);
2055
2632
  const from = phases2[0]?.to ?? (published.length ? Math.min(...published) : undefined);
2056
- if (from === undefined || now - from < settings.phaseWeeks * 7 * DAY2 || !published.some((at) => at >= from)) {
2633
+ if (from === undefined || now - from < settings.phaseWeeks * 7 * DAY3 || !published.some((at) => at >= from)) {
2057
2634
  return;
2058
2635
  }
2059
2636
  return { from, to: now };
@@ -2067,7 +2644,7 @@ var ChannelUtil;
2067
2644
  return (item.needs ?? []).every((one) => one.done);
2068
2645
  }
2069
2646
  ChannelUtil.given = given;
2070
- ChannelUtil.PACE = { start: 12 * HOUR, first: 24 * HOUR, min: 2 * HOUR, max: 2 * DAY2, many: 3, ride: 0.5 };
2647
+ ChannelUtil.PACE = { start: 12 * HOUR2, first: 24 * HOUR2, min: 2 * HOUR2, max: 2 * DAY3, many: 3, ride: 0.5 };
2071
2648
  function nextGap(gap, added) {
2072
2649
  if (added >= ChannelUtil.PACE.many) {
2073
2650
  return Math.max(ChannelUtil.PACE.min, Math.round(gap / 2));
@@ -2081,7 +2658,7 @@ var ChannelUtil;
2081
2658
  }
2082
2659
  ChannelUtil.firstGap = firstGap;
2083
2660
  function commentsGap(item, items, settings) {
2084
- return settings.commentsEvery ? settings.commentsEvery * HOUR : item.commentsGap ?? firstGap(items);
2661
+ return settings.commentsEvery ? settings.commentsEvery * HOUR2 : item.commentsGap ?? firstGap(items);
2085
2662
  }
2086
2663
  ChannelUtil.commentsGap = commentsGap;
2087
2664
  function live(item, now) {
@@ -2096,10 +2673,31 @@ var ChannelUtil;
2096
2673
  }
2097
2674
  const published = Math.min(...out);
2098
2675
  const since = now - Math.max(one.commentsAt ?? 0, published);
2099
- return now - published < settings.commentsDays * DAY2 && since >= share * commentsGap(one, items, settings);
2676
+ return now - published < settings.commentsDays * DAY3 && since >= share * commentsGap(one, items, settings);
2100
2677
  });
2101
2678
  }
2102
2679
  ChannelUtil.due = due;
2680
+ ChannelUtil.STATS = { first: 20 * HOUR2, again: 7 * DAY3, until: 14 * DAY3 };
2681
+ function enough(waiting, settings) {
2682
+ const perWeek = settings.series.reduce((all, one) => all + (one.perWeek ?? 1), 0);
2683
+ return perWeek > 0 && waiting >= 2 * perWeek;
2684
+ }
2685
+ ChannelUtil.enough = enough;
2686
+ function statsDue(items, now) {
2687
+ return items.filter((one) => one.stage === "published" && !one.dropped).map((item) => ({
2688
+ item,
2689
+ links: live(item, now).filter((link) => {
2690
+ const out = link.scheduled ?? link.at;
2691
+ const read = item.stats?.find((one) => one.platform === link.platform);
2692
+ const age = now - out;
2693
+ if (age < ChannelUtil.STATS.first || age >= ChannelUtil.STATS.until) {
2694
+ return false;
2695
+ }
2696
+ return !read || age >= ChannelUtil.STATS.again && read.at - out < ChannelUtil.STATS.again - DAY3;
2697
+ })
2698
+ })).filter((one) => one.links.length > 0);
2699
+ }
2700
+ ChannelUtil.statsDue = statsDue;
2103
2701
  function comments(value, now = Date.now()) {
2104
2702
  return (Array.isArray(value) ? value : []).map(comment).filter((one) => !!one && now - one.at < COMMENTS_FOR).sort((a, b) => a.at - b.at).slice(-MAX_COMMENTS);
2105
2703
  }
@@ -2238,6 +2836,67 @@ class CreatorStore {
2238
2836
  }
2239
2837
  }
2240
2838
 
2839
+ // web-src/efficiency-panel.tsx
2840
+ function EfficiencyPanel({ context }) {
2841
+ const { pi, store } = context;
2842
+ const words = useWords(pi);
2843
+ const state = useStore(store);
2844
+ const [numbers, setNumbers] = React.useState();
2845
+ const published = state.items.filter((one) => one.stage === "published").length;
2846
+ React.useEffect(() => {
2847
+ let live = true;
2848
+ store.call("efficiency").then((got) => live && setNumbers(got), () => {
2849
+ return;
2850
+ });
2851
+ return () => {
2852
+ live = false;
2853
+ };
2854
+ }, [store, published]);
2855
+ if (!numbers) {
2856
+ return null;
2857
+ }
2858
+ const n = (value, unit = "") => value === undefined ? "—" : `${short(value, pi.ui.language)}${unit}`;
2859
+ const runs = (one) => one ? format(words.effRuns, { n: one.runs, empty: one.empty, failed: one.failed }) : "—";
2860
+ const rows = [
2861
+ [words.effPieces, n(numbers.before.pieces.pieces), n(numbers.after.pieces.pieces)],
2862
+ [
2863
+ words.effLead,
2864
+ n(numbers.before.pieces.leadHours, " h"),
2865
+ n(numbers.after.pieces.leadHours, " h"),
2866
+ lower(numbers.before.pieces.leadHours, numbers.after.pieces.leadHours)
2867
+ ],
2868
+ [
2869
+ words.effMinutes,
2870
+ n(numbers.before.pieces.minutes, words.effMin),
2871
+ n(numbers.after.pieces.minutes, words.effMin),
2872
+ lower(numbers.before.pieces.minutes, numbers.after.pieces.minutes)
2873
+ ],
2874
+ [words.effTokens, n(numbers.before.pieces.tokens), n(numbers.after.pieces.tokens), lower(numbers.before.pieces.tokens, numbers.after.pieces.tokens)],
2875
+ [words.effTurns, n(numbers.before.pieces.turns), n(numbers.after.pieces.turns), lower(numbers.before.pieces.turns, numbers.after.pieces.turns)],
2876
+ ...["topics", "comments", "review"].map((id) => [words[`eff_${id}`], runs(numbers.before.tasks[id]), runs(numbers.after.tasks[id])])
2877
+ ];
2878
+ return /* @__PURE__ */ React.createElement("div", {
2879
+ className: "tcre-card tcre-panel tcre-wide"
2880
+ }, /* @__PURE__ */ React.createElement("div", {
2881
+ className: "tcre-panel-title"
2882
+ }, words.effTitle, /* @__PURE__ */ React.createElement("span", {
2883
+ className: "tcre-muted"
2884
+ }, words.effHint)), /* @__PURE__ */ React.createElement("div", {
2885
+ className: "tcre-eff"
2886
+ }, /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement("span", {
2887
+ className: "tcre-muted"
2888
+ }, words.effBefore), /* @__PURE__ */ React.createElement("span", {
2889
+ className: "tcre-muted"
2890
+ }, words.effAfter), rows.map(([label, before, after, better]) => /* @__PURE__ */ React.createElement(React.Fragment, {
2891
+ key: label
2892
+ }, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", null, before), /* @__PURE__ */ React.createElement("span", {
2893
+ "data-better": better === undefined ? undefined : String(better)
2894
+ }, after)))));
2895
+ }
2896
+ function lower(before, after) {
2897
+ return before === undefined || after === undefined || before === after ? undefined : after < before;
2898
+ }
2899
+
2241
2900
  // web-src/strategy.tsx
2242
2901
  var PHASE_WEEKS = [2, 4, 8, 0];
2243
2902
  function Strategy({ context }) {
@@ -2457,6 +3116,67 @@ function WeekLine({ context }) {
2457
3116
  className: "tcre-line-labels"
2458
3117
  }, /* @__PURE__ */ React.createElement("span", null, weeks[0].week.slice(5)), /* @__PURE__ */ React.createElement("span", null, weeks[weeks.length - 1].week.slice(5))));
2459
3118
  }
3119
+ function PieceNumbers({ context, now }) {
3120
+ const { pi } = context;
3121
+ const state = useStore(context.store);
3122
+ const words = useWords(pi);
3123
+ const pieces = state.items.filter((one) => one.stage === "published" && !one.dropped && ChannelUtil.live(one, now).length > 0).sort((a, b) => CreatorUtil.publishedAt(b) - CreatorUtil.publishedAt(a));
3124
+ if (!pieces.length) {
3125
+ return null;
3126
+ }
3127
+ const n = (value) => short(value, pi.ui.language);
3128
+ return /* @__PURE__ */ React.createElement("div", {
3129
+ className: "tcre-card tcre-panel tcre-wide"
3130
+ }, /* @__PURE__ */ React.createElement("div", {
3131
+ className: "tcre-panel-title"
3132
+ }, words.eachPiece), pieces.map((item) => /* @__PURE__ */ React.createElement("div", {
3133
+ key: item.id,
3134
+ className: "tcre-piece-stats"
3135
+ }, /* @__PURE__ */ React.createElement("div", {
3136
+ className: "tcre-piece-title"
3137
+ }, /* @__PURE__ */ React.createElement("span", null, item.title), /* @__PURE__ */ React.createElement(SeriesTag, {
3138
+ series: seriesOf(context, item.series),
3139
+ words
3140
+ })), (item.cost || Efficiency.leadHours(item) !== undefined) && /* @__PURE__ */ React.createElement("div", {
3141
+ className: "tcre-piece-row tcre-piece-cost"
3142
+ }, /* @__PURE__ */ React.createElement("span", {
3143
+ className: "tcre-bar-label"
3144
+ }, words.effCost), /* @__PURE__ */ React.createElement("span", {
3145
+ className: "tcre-piece-values"
3146
+ }, [
3147
+ Efficiency.leadHours(item) !== undefined ? format(words.effLeadValue, { n: Efficiency.leadHours(item) }) : "",
3148
+ item.cost ? format(words.effMinutesValue, { n: item.cost.minutes }) : "",
3149
+ item.cost?.tokens ? format(words.effTokensValue, { n: n(item.cost.tokens) }) : ""
3150
+ ].filter(Boolean).map((part) => /* @__PURE__ */ React.createElement("span", {
3151
+ key: part
3152
+ }, part)))), ChannelUtil.live(item, now).map((link) => {
3153
+ const platform = platformOf(context, link.platform);
3154
+ const stat = item.stats?.find((one) => one.platform === link.platform);
3155
+ const late = !stat && now - (link.scheduled ?? link.at) > 48 * 3600000;
3156
+ const parts = stat ? [
3157
+ format(words.statViews, { n: n(stat.views) }),
3158
+ stat.completion !== undefined ? format(words.completion, { n: Math.round(stat.completion * 100) }) : "",
3159
+ stat.watch !== undefined ? format(words.statWatch, { n: stat.watch }) : "",
3160
+ stat.likes !== undefined ? format(words.statLikes, { n: n(stat.likes) }) : "",
3161
+ stat.comments !== undefined ? format(words.statComments, { n: n(stat.comments) }) : "",
3162
+ stat.follows !== undefined ? format(words.statFollows, { n: n(stat.follows) }) : ""
3163
+ ].filter(Boolean) : [late ? words.statLate : words.statWaiting];
3164
+ return /* @__PURE__ */ React.createElement("div", {
3165
+ key: link.platform,
3166
+ className: "tcre-piece-row",
3167
+ "data-late": late || undefined,
3168
+ "data-none": !stat || undefined
3169
+ }, /* @__PURE__ */ React.createElement("span", {
3170
+ className: "tcre-bar-label"
3171
+ }, platform?.color && /* @__PURE__ */ React.createElement("i", {
3172
+ style: { background: platform.color }
3173
+ }), platform?.name ?? link.platform), /* @__PURE__ */ React.createElement("span", {
3174
+ className: "tcre-piece-values"
3175
+ }, parts.map((part) => /* @__PURE__ */ React.createElement("span", {
3176
+ key: part
3177
+ }, part))));
3178
+ }))));
3179
+ }
2460
3180
  function Numbers({ context }) {
2461
3181
  const { pi } = context;
2462
3182
  const state = useStore(context.store);
@@ -2516,6 +3236,11 @@ function Numbers({ context }) {
2516
3236
  })
2517
3237
  }), /* @__PURE__ */ React.createElement(WeekLine, {
2518
3238
  context
3239
+ }), /* @__PURE__ */ React.createElement(EfficiencyPanel, {
3240
+ context
3241
+ }), /* @__PURE__ */ React.createElement(PieceNumbers, {
3242
+ context,
3243
+ now
2519
3244
  }), analysis.top.length > 0 && /* @__PURE__ */ React.createElement("div", {
2520
3245
  className: "tcre-card tcre-panel"
2521
3246
  }, /* @__PURE__ */ React.createElement("div", {
@@ -2770,10 +3495,10 @@ function Setup({ context, done }) {
2770
3495
  }
2771
3496
 
2772
3497
  // web-src/talk.tsx
2773
- var DAY3 = 86400000;
3498
+ var DAY4 = 86400000;
2774
3499
  var LEVELS = ["act", "ask", "off"];
2775
3500
  var LEVEL_WORDS = { act: "levelAct", ask: "levelAsk", off: "levelOff" };
2776
- var HOUR2 = 3600000;
3501
+ var HOUR3 = 3600000;
2777
3502
  var PACE_HOURS = [0, 2, 6, 24];
2778
3503
  var PACE_DAYS = [7, 14, 30];
2779
3504
  function drafts(comments) {
@@ -2785,8 +3510,8 @@ function Talk({ context }) {
2785
3510
  const words = useWords(pi);
2786
3511
  const now = Date.now();
2787
3512
  const waiting = drafts(state.comments);
2788
- const asked = state.comments.filter((one) => (one.class === "question" || one.class === "suggestion") && now - one.at < 14 * DAY3).sort((a, b) => (b.likes ?? 0) - (a.likes ?? 0) || b.at - a.at).slice(0, 12);
2789
- const recent = state.comments.filter((one) => one.reply && one.reply.state !== "draft" && one.reply.state !== "dropped" && now - one.reply.at < 7 * DAY3).sort((a, b) => (b.reply?.at ?? 0) - (a.reply?.at ?? 0)).slice(0, 20);
3513
+ const asked = state.comments.filter((one) => (one.class === "question" || one.class === "suggestion") && now - one.at < 14 * DAY4).sort((a, b) => (b.likes ?? 0) - (a.likes ?? 0) || b.at - a.at).slice(0, 12);
3514
+ const recent = state.comments.filter((one) => one.reply && one.reply.state !== "draft" && one.reply.state !== "dropped" && now - one.reply.at < 7 * DAY4).sort((a, b) => (b.reply?.at ?? 0) - (a.reply?.at ?? 0)).slice(0, 20);
2790
3515
  return /* @__PURE__ */ React.createElement("div", {
2791
3516
  className: "tcre-talk"
2792
3517
  }, !state.comments.length && /* @__PURE__ */ React.createElement("div", {
@@ -2914,7 +3639,7 @@ function Pace({ context }) {
2914
3639
  const words = useWords(pi);
2915
3640
  const { commentsEvery: every, commentsDays: days } = state.settings;
2916
3641
  const latest = state.items.filter((one) => one.stage === "published" && one.commentsGap).sort((a, b) => (b.commentsAt ?? 0) - (a.commentsAt ?? 0))[0];
2917
- const now = latest?.commentsGap ? Math.max(1, Math.round(latest.commentsGap / HOUR2)) : undefined;
3642
+ const now = latest?.commentsGap ? Math.max(1, Math.round(latest.commentsGap / HOUR3)) : undefined;
2918
3643
  const choice = (values, value, label, set) => /* @__PURE__ */ React.createElement("div", {
2919
3644
  className: "ta-segmented tcre-seg"
2920
3645
  }, values.map((n) => /* @__PURE__ */ React.createElement(BusyButton, {
@@ -3664,6 +4389,14 @@ button.tcre-pill:hover { background: var(--ta-hover); }
3664
4389
  .tcre-review-text { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; width: 100%; margin: 0; padding: 0 2px; border: 0; background: transparent; color: var(--ta-secondary); font: inherit; font-size: calc(13px * var(--ta-font-scale)); line-height: 1.6; text-align: left; white-space: pre-wrap; cursor: pointer; }
3665
4390
  .tcre-review-text[data-open] { display: block; }
3666
4391
  .tcre-tags, .tcre-origin { margin: 6px 2px 0; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); overflow-wrap: anywhere; }
4392
+ .tcre-score { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 10px; row-gap: 4px; margin: 12px 2px 0; padding-top: 12px; border-top: 1px solid var(--tcre-line); }
4393
+ .tcre-score > b { grid-row: span 2; font-size: calc(26px * var(--ta-font-scale)); font-weight: 650; line-height: 1; letter-spacing: -0.4px; color: var(--tcre-ok); font-variant-numeric: tabular-nums; }
4394
+ .tcre-score[data-low] > b { color: var(--ta-warning, #d97706); }
4395
+ .tcre-score-label { font-size: calc(12.5px * var(--ta-font-scale)); color: var(--ta-muted); }
4396
+ .tcre-score-parts { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: calc(12px * var(--ta-font-scale)); color: var(--ta-muted); font-variant-numeric: tabular-nums; }
4397
+ .tcre-score-parts > span { white-space: nowrap; }
4398
+ .tcre-score-parts > span[data-low] { color: var(--ta-warning, #d97706); }
4399
+ .tcre-score + .tcre-checks { border-top: 0; padding-top: 4px; }
3667
4400
  .tcre-checks { display: flex; flex-direction: column; gap: 7px; margin: 12px 2px; padding-top: 12px; border-top: 1px solid var(--tcre-line); font-size: calc(13px * var(--ta-font-scale)); color: var(--ta-text); }
3668
4401
  .tcre-checks span { display: flex; gap: 8px; align-items: flex-start; }
3669
4402
  .tcre-checks i { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: calc(10px * var(--ta-font-scale)); font-weight: 700; color: var(--ta-warning, #d97706); background: color-mix(in oklab, var(--ta-warning, #d97706) 18%, transparent); }
@@ -3786,6 +4519,21 @@ button.tcre-pill:hover { background: var(--ta-hover); }
3786
4519
  .tcre-top-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: calc(13px * var(--ta-font-scale)); }
3787
4520
  .tcre-top-row + .tcre-top-row { border-top: 1px solid var(--tcre-line); }
3788
4521
  .tcre-top-row > b { flex: none; width: 18px; color: var(--ta-muted); font-variant-numeric: tabular-nums; }
4522
+ .tcre-piece-stats { padding: 8px 0; }
4523
+ .tcre-piece-stats + .tcre-piece-stats { border-top: 1px solid var(--tcre-line); }
4524
+ .tcre-piece-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; }
4525
+ .tcre-piece-title > span:first-child { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4526
+ .tcre-piece-row { display: flex; align-items: baseline; gap: 10px; padding: 2px 0; font-size: calc(12px * var(--ta-font-scale)); }
4527
+ .tcre-piece-row .tcre-bar-label { flex: none; width: 64px; }
4528
+ .tcre-piece-values { display: flex; flex-wrap: wrap; gap: 0 12px; min-width: 0; font-variant-numeric: tabular-nums; }
4529
+ .tcre-piece-values > span { white-space: nowrap; }
4530
+ .tcre-piece-row[data-none] .tcre-piece-values { color: var(--ta-muted); }
4531
+ .tcre-piece-row[data-late] .tcre-piece-values { color: #d97706; }
4532
+ .tcre-piece-cost .tcre-piece-values { color: var(--ta-muted); }
4533
+ .tcre-eff { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 7px 12px; font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
4534
+ .tcre-eff > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4535
+ .tcre-eff > span[data-better='true'] { color: var(--tcre-ok); font-weight: 600; }
4536
+ .tcre-eff > span[data-better='false'] { color: #d97706; font-weight: 600; }
3789
4537
  .tcre-top-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3790
4538
  .tcre-goal-row { display: flex; justify-content: space-between; margin: 8px 0 6px; font-size: calc(13px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
3791
4539
  .tcre-goal-track { height: 6px; border-radius: 3px; background: var(--ta-chip); overflow: hidden; }