@celljs/ta-creator 4.32.1 → 4.33.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
@@ -1,9 +1,3 @@
1
- // web-src/react.ts
2
- var React;
3
- function bind(react) {
4
- React = react;
5
- }
6
-
7
1
  // web-src/creator-protocol.ts
8
2
  var NAME = "@celljs/ta-creator";
9
3
  var PAGE = `${NAME}/home`;
@@ -15,11 +9,21 @@ var Keys;
15
9
  Keys.WEEKS = "weeks";
16
10
  Keys.TASKS = "tasks";
17
11
  Keys.INSIGHTS = "insights";
12
+ Keys.COMMENTS = "comments";
13
+ Keys.LESSONS = "lessons";
14
+ Keys.PHASES = "phases";
18
15
  })(Keys ||= {});
19
- var STAGES = ["topic", "making", "review", "published"];
20
- var FORMS = ["video", "post"];
21
- var KINDS = ["hot", "howto", "explain"];
16
+ var STAGES = ["topic", "materials", "making", "review", "published"];
17
+ var FORMS = ["video", "post", "article", "note"];
18
+ var FORM_FALLBACKS = {
19
+ video: ["video", "article", "post"],
20
+ post: ["post", "note", "article"],
21
+ article: ["article", "post", "note"],
22
+ note: ["note", "post"]
23
+ };
24
+ var KINDS = ["hot", "howto", "explain", "original"];
22
25
  var STEPS = ["script", "visuals", "voice", "captions", "versions", "checks"];
26
+ var REACHES = ["public", "internal", "both"];
23
27
  var SERIES_COLORS = ["#22c55e", "#f97316", "#3b82f6", "#a855f7", "#ec4899", "#14b8a6", "#eab308", "#64748b"];
24
28
  var ASPECTS = ["16:9", "9:16", "3:4", "1:1"];
25
29
  var PLATFORMS = [
@@ -28,6 +32,8 @@ var PLATFORMS = [
28
32
  name: "B站",
29
33
  color: "#fb7299",
30
34
  video: { aspect: "16:9" },
35
+ article: {},
36
+ note: { maxChars: 1000 },
31
37
  publish: "https://member.bilibili.com/platform/upload/video/frame",
32
38
  declare: "创作声明 → 该视频使用人工智能合成技术"
33
39
  },
@@ -37,6 +43,7 @@ var PLATFORMS = [
37
43
  color: "#ff2442",
38
44
  video: { aspect: "3:4", maxSeconds: 900 },
39
45
  post: { aspect: "3:4", maxImages: 18 },
46
+ article: {},
40
47
  publish: "https://creator.xiaohongshu.com",
41
48
  declare: "内容类型声明 → 笔记含 AI 合成内容"
42
49
  },
@@ -45,6 +52,7 @@ var PLATFORMS = [
45
52
  name: "视频号",
46
53
  color: "#fa9d3b",
47
54
  video: { aspect: "9:16" },
55
+ post: { aspect: "3:4", maxImages: 9 },
48
56
  publish: "https://channels.weixin.qq.com",
49
57
  declare: "声明 → 内容由 AI 生成"
50
58
  },
@@ -63,6 +71,7 @@ var PLATFORMS = [
63
71
  name: "YouTube",
64
72
  color: "#ff0033",
65
73
  video: { aspect: "16:9" },
74
+ note: { maxChars: 1500 },
66
75
  publish: "https://studio.youtube.com",
67
76
  declare: "Altered or synthetic content → Yes"
68
77
  },
@@ -70,9 +79,19 @@ var PLATFORMS = [
70
79
  id: "wechat-article",
71
80
  name: "公众号",
72
81
  color: "#07c160",
73
- post: { aspect: "16:9" },
82
+ article: {},
74
83
  publish: "https://mp.weixin.qq.com",
75
84
  declare: "创作来源 → 内容由 AI 生成"
85
+ },
86
+ {
87
+ id: "zhihu",
88
+ name: "知乎",
89
+ color: "#1772f6",
90
+ video: { aspect: "16:9" },
91
+ article: {},
92
+ note: { maxChars: 1000 },
93
+ publish: "https://www.zhihu.com/creator",
94
+ declare: "创作声明 → 包含 AI 辅助创作"
76
95
  }
77
96
  ];
78
97
  var SOURCES = [
@@ -81,85 +100,232 @@ var SOURCES = [
81
100
  { name: "Product Hunt", url: "https://www.producthunt.com" },
82
101
  { name: "Hugging Face Papers", url: "https://huggingface.co/papers" }
83
102
  ];
103
+ var COMMENT_CLASSES = ["question", "suggestion", "correction", "praise", "negative", "spam"];
104
+ var REPLY_CLASSES = ["question", "suggestion", "correction", "praise"];
105
+ var REPLY_STATES = ["draft", "approved", "sent", "dropped", "withdrawn", "removed"];
106
+
107
+ // web-src/publish-util.ts
108
+ var text = (value, max) => typeof value === "string" ? value.trim().slice(0, max) : "";
109
+ var time = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
110
+ var object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
111
+ var PublishUtil;
112
+ ((PublishUtil) => {
113
+ function dayOf(at) {
114
+ const day = new Date(at);
115
+ const two = (n) => String(n).padStart(2, "0");
116
+ return `${day.getFullYear()}-${two(day.getMonth() + 1)}-${two(day.getDate())}`;
117
+ }
118
+ PublishUtil.dayOf = dayOf;
119
+ function publishQueue(items) {
120
+ const due = (item) => item.kind === "hot" && item.until ? item.until : Number.POSITIVE_INFINITY;
121
+ return items.filter((one) => one.publishing?.state === "queued" && !one.dropped).sort((a, b) => due(a) - due(b) || (a.approved ?? a.changedAt) - (b.approved ?? b.changedAt));
122
+ }
123
+ PublishUtil.publishQueue = publishQueue;
124
+ function ahead(items, id) {
125
+ const running = items.some((one) => one.publishing?.state === "running" && !one.dropped && one.id !== id) ? 1 : 0;
126
+ const at = publishQueue(items).findIndex((one) => one.id === id);
127
+ return at < 0 ? 0 : at + running;
128
+ }
129
+ PublishUtil.ahead = ahead;
130
+ function slots(items, item, now, hour = 12) {
131
+ const done = new Set((item.links ?? []).map((one) => one.platform));
132
+ const platforms = [
133
+ ...new Set((item.versions ?? []).filter((one) => one.files.length || ["article", "note"].includes(one.form ?? item.form) && !!one.text).map((one) => one.platform))
134
+ ].filter((one) => !done.has(one));
135
+ const others = items.filter((one) => one.id !== item.id && !one.dropped);
136
+ return platforms.map((platform) => {
137
+ const taken = new Set([
138
+ ...others.flatMap((one) => (one.links ?? []).filter((link) => link.platform === platform).map((link) => dayOf(link.scheduled ?? link.at))),
139
+ ...others.filter((one) => one.publishing?.state === "running").flatMap((one) => (one.publishing?.slots ?? []).filter((slot) => slot.platform === platform).map((slot) => dayOf(slot.at ?? one.publishing?.since ?? now)))
140
+ ]);
141
+ if (!taken.has(dayOf(now))) {
142
+ return { platform };
143
+ }
144
+ const day = new Date(now);
145
+ day.setHours(hour, 0, 0, 0);
146
+ do {
147
+ day.setDate(day.getDate() + 1);
148
+ } while (taken.has(dayOf(day.getTime())));
149
+ return { platform, at: day.getTime() };
150
+ });
151
+ }
152
+ PublishUtil.slots = slots;
153
+ function timeOf(value) {
154
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(value.trim())) {
155
+ const at = new Date(value.trim().replace(" ", "T")).getTime();
156
+ return Number.isFinite(at) ? at : undefined;
157
+ }
158
+ return time(value);
159
+ }
160
+ PublishUtil.timeOf = timeOf;
161
+ function publishing(value) {
162
+ const kept = object(value);
163
+ const since = time(kept?.since);
164
+ const state = kept && ["queued", "running", "stopped"].find((one) => one === kept.state);
165
+ if (!kept || !since || !state) {
166
+ return;
167
+ }
168
+ const slots2 = Array.isArray(kept.slots) ? kept.slots.map((one) => object(one)).filter((one) => !!one && !!text(one.platform, 60)).map((one) => ({ platform: text(one.platform, 60), ...time(one.at) ? { at: time(one.at) } : {} })) : undefined;
169
+ return {
170
+ state,
171
+ since,
172
+ ...slots2 ? { slots: slots2 } : {},
173
+ ...text(kept.note, 300) ? { note: text(kept.note, 300) } : {},
174
+ ...text(kept.ask, 500) ? { ask: text(kept.ask, 500) } : {}
175
+ };
176
+ }
177
+ PublishUtil.publishing = publishing;
178
+ })(PublishUtil ||= {});
179
+
180
+ // web-src/react.ts
181
+ var React;
182
+ function bind(react) {
183
+ React = react;
184
+ }
185
+
186
+ // web-src/values.ts
187
+ var text2 = (value, max = 2000) => typeof value === "string" ? value.trim().slice(0, max) : "";
188
+ var texts = (value, max = 50) => Array.isArray(value) ? value.map((one) => text2(one, 200)).filter(Boolean).slice(0, max) : [];
189
+ var time2 = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
190
+ var oneOf = (all, value, fallback) => all.includes(value) ? value : fallback;
191
+ var object2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
192
+ function hash(value) {
193
+ let h = 0;
194
+ for (const char of value) {
195
+ h = Math.imul(h, 31) + (char.codePointAt(0) ?? 0) | 0;
196
+ }
197
+ return (h >>> 0).toString(36);
198
+ }
199
+ function url(value) {
200
+ const raw = text2(value, 1000);
201
+ return /^https?:\/\/\S+$/i.test(raw) ? raw : undefined;
202
+ }
203
+ function count(value, fallback) {
204
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : fallback;
205
+ }
84
206
 
85
207
  // web-src/creator-util.ts
86
208
  var DAY = 86400000;
87
209
  var MAX_TOPICS = 200;
88
210
  var HOT_FOR = 2 * DAY;
89
- var text = (value, max = 2000) => typeof value === "string" ? value.trim().slice(0, max) : "";
90
- var texts = (value, max = 50) => Array.isArray(value) ? value.map((one) => text(one, 200)).filter(Boolean).slice(0, max) : [];
91
- var time = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
92
- var oneOf = (all, value, fallback) => all.includes(value) ? value : fallback;
93
- var object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
94
211
  var CreatorUtil;
95
212
  ((CreatorUtil) => {
96
213
  function settings(value) {
97
- const kept = object(value) ?? {};
98
- const platforms = Array.isArray(kept.platforms) ? kept.platforms.map(platform).filter((one) => !!one) : [...PLATFORMS];
214
+ const kept = object2(value) ?? {};
215
+ const platforms = Array.isArray(kept.platforms) ? withBuiltins(kept.platforms.map(platform).filter((one) => !!one)) : [...PLATFORMS];
99
216
  const ids = new Set(platforms.map((one) => one.id));
100
- const goal = object(kept.goal);
217
+ const goal = object2(kept.goal);
101
218
  return {
102
- niche: text(kept.niche, 500),
219
+ niche: text2(kept.niche, 500),
103
220
  picked: texts(kept.picked).filter((id) => ids.has(id)),
104
221
  platforms,
105
222
  sources: Array.isArray(kept.sources) ? kept.sources.map(source).filter((one) => !!one) : [...SOURCES],
106
- ...goal && time(goal.from) ? { goal: { from: time(goal.from), days: count(goal.days, 30), videos: count(goal.videos, 0), posts: count(goal.posts, 0) } } : {},
223
+ ...goal && time2(goal.from) ? { goal: { from: time2(goal.from), days: count(goal.days, 30), videos: count(goal.videos, 0), posts: count(goal.posts, 0) } } : {},
107
224
  minutesCap: count(kept.minutesCap, 120),
108
- voice: text(kept.voice, 60) || "zh-CN-XiaoxiaoNeural",
109
- series: Array.isArray(kept.series) ? seriesOf(kept.series) : []
225
+ voice: text2(kept.voice, 60) || "zh-CN-XiaoxiaoNeural",
226
+ series: Array.isArray(kept.series) ? seriesOf(kept.series) : [],
227
+ strategy: kept.strategy === "manual" ? "manual" : "auto",
228
+ phaseWeeks: typeof kept.phaseWeeks === "number" ? Math.min(26, count(kept.phaseWeeks, 4)) : 4,
229
+ commentsEvery: Math.min(72, count(kept.commentsEvery, 0)),
230
+ commentsDays: Math.max(1, Math.min(60, count(kept.commentsDays, 14)))
110
231
  };
111
232
  }
112
233
  CreatorUtil.settings = settings;
234
+ function withBuiltins(kept) {
235
+ const forms = (one) => ({ video: one.video, post: one.post, article: one.article, note: one.note });
236
+ const known = kept.map((one) => {
237
+ const builtin = PLATFORMS.find((it) => it.id === one.id);
238
+ if (!builtin) {
239
+ return one;
240
+ }
241
+ const { video: _v, post: _p, article: _a, note: _n, ...rest } = one;
242
+ return JSON.parse(JSON.stringify({ ...rest, ...forms(builtin) }));
243
+ });
244
+ return [...known, ...PLATFORMS.filter((one) => !kept.some((it) => it.id === one.id))];
245
+ }
246
+ CreatorUtil.withBuiltins = withBuiltins;
247
+ function reach(item2, settings2) {
248
+ return item2.reach ?? settings2.series.find((one) => one.id === item2.series)?.reach ?? "public";
249
+ }
250
+ CreatorUtil.reach = reach;
251
+ function platformsFor(settings2, item2) {
252
+ const to = reach(item2, settings2);
253
+ return picked(settings2).filter((platform2) => to === "both" || to === "internal" === !!platform2.internal).map((platform2) => ({ platform: platform2, form: formFor(platform2, item2.form) })).filter((one) => !!one.form);
254
+ }
255
+ CreatorUtil.platformsFor = platformsFor;
256
+ function takes(platform2, form) {
257
+ return !!platform2[form];
258
+ }
259
+ CreatorUtil.takes = takes;
260
+ function formFor(platform2, form) {
261
+ return FORM_FALLBACKS[form].find((one) => takes(platform2, one));
262
+ }
263
+ CreatorUtil.formFor = formFor;
264
+ function ready(version2, form) {
265
+ return version2.files.length > 0 || (version2.form ?? form) !== "video" && (version2.form ?? form) !== "post" && !!version2.text;
266
+ }
267
+ CreatorUtil.ready = ready;
113
268
  function seriesOf(values) {
114
269
  const all = [];
115
270
  for (const value of values) {
116
- const kept = object(value);
117
- const name = text(kept?.name, 40);
271
+ const kept = object2(value);
272
+ const name = text2(kept?.name, 40);
118
273
  if (!kept || !name) {
119
274
  continue;
120
275
  }
121
- const id = text(kept.id, 60) || `s${hash(name)}`;
276
+ const id = text2(kept.id, 60) || `s${hash(name)}`;
122
277
  if (all.some((one) => one.id === id)) {
123
278
  continue;
124
279
  }
125
- const about = text(kept.about, 200);
280
+ const about = text2(kept.about, 200);
126
281
  const perWeek = count(kept.perWeek, 0);
127
282
  all.push({
128
283
  id,
129
284
  name,
130
285
  ...about ? { about } : {},
131
- color: text(kept.color, 40) || SERIES_COLORS[all.length % SERIES_COLORS.length],
286
+ color: text2(kept.color, 40) || SERIES_COLORS[all.length % SERIES_COLORS.length],
132
287
  ...kept.ordered === true ? { ordered: true } : {},
133
- ...perWeek ? { perWeek: Math.min(perWeek, 14) } : {}
288
+ ...perWeek ? { perWeek: Math.min(perWeek, 14) } : {},
289
+ ...kept.reach === "internal" || kept.reach === "both" ? { reach: kept.reach } : {}
134
290
  });
135
291
  }
136
292
  return all.slice(0, 12);
137
293
  }
138
294
  CreatorUtil.seriesOf = seriesOf;
139
295
  function platform(value) {
140
- const kept = object(value);
141
- const id = text(kept?.id, 60);
142
- const name = text(kept?.name, 60);
296
+ const kept = object2(value);
297
+ const id = text2(kept?.id, 60);
298
+ const name = text2(kept?.name, 60);
143
299
  if (!kept || !id || !name) {
144
300
  return;
145
301
  }
146
302
  const shape = (one) => {
147
- const it = object(one);
303
+ const it = object2(one);
148
304
  return it ? { aspect: oneOf(ASPECTS, it.aspect, "16:9"), ...count(it.maxSeconds, 0) ? { maxSeconds: count(it.maxSeconds, 0) } : {} } : undefined;
149
305
  };
150
306
  const video = shape(kept.video);
151
- const post = object(kept.post) ? {
152
- aspect: oneOf(ASPECTS, object(kept.post)?.aspect, "3:4"),
153
- ...count(object(kept.post)?.maxImages, 0) ? { maxImages: count(object(kept.post)?.maxImages, 0) } : {}
307
+ const post = object2(kept.post) ? {
308
+ aspect: oneOf(ASPECTS, object2(kept.post)?.aspect, "3:4"),
309
+ ...count(object2(kept.post)?.maxImages, 0) ? { maxImages: count(object2(kept.post)?.maxImages, 0) } : {}
154
310
  } : undefined;
311
+ const words = (one) => {
312
+ const it = object2(one);
313
+ return it ? count(it.maxChars, 0) ? { maxChars: count(it.maxChars, 0) } : {} : undefined;
314
+ };
315
+ const article = words(kept.article);
316
+ const note = words(kept.note);
155
317
  const publish = url(kept.publish);
156
- const declare = text(kept.declare, 200);
318
+ const declare = text2(kept.declare, 200);
319
+ const inside = kept.internal === true ? { internal: true } : {};
157
320
  return {
321
+ ...inside,
158
322
  id,
159
323
  name,
160
- color: text(kept.color, 40) || "#8e8e93",
324
+ color: text2(kept.color, 40) || "#8e8e93",
161
325
  ...video ? { video } : {},
162
326
  ...post ? { post } : {},
327
+ ...article ? { article } : {},
328
+ ...note ? { note } : {},
163
329
  ...publish ? { publish } : {},
164
330
  ...declare ? { declare } : {}
165
331
  };
@@ -170,14 +336,14 @@ var CreatorUtil;
170
336
  }
171
337
  CreatorUtil.items = items;
172
338
  function item(value) {
173
- const kept = object(value);
174
- const id = text(kept?.id, 80);
175
- const title = text(kept?.title, 200);
176
- const at = time(kept?.at);
339
+ const kept = object2(value);
340
+ const id = text2(kept?.id, 80);
341
+ const title = text2(kept?.title, 200);
342
+ const at = time2(kept?.at);
177
343
  if (!kept || !id || !title || !at) {
178
344
  return;
179
345
  }
180
- const origin = object(kept.origin);
346
+ const origin = object2(kept.origin);
181
347
  const originUrl = url(origin?.url);
182
348
  return {
183
349
  id,
@@ -185,31 +351,38 @@ var CreatorUtil;
185
351
  form: oneOf(FORMS, kept.form, "video"),
186
352
  kind: oneOf(KINDS, kept.kind, "howto"),
187
353
  stage: oneOf(STAGES, kept.stage, "topic"),
188
- ...text(kept.series, 60) ? { series: text(kept.series, 60) } : {},
354
+ ...text2(kept.series, 60) ? { series: text2(kept.series, 60) } : {},
189
355
  ...count(kept.number, 0) ? { number: count(kept.number, 0) } : {},
190
- ...text(kept.why, 300) ? { why: text(kept.why, 300) } : {},
356
+ ...REACHES.includes(kept.reach) ? { reach: kept.reach } : {},
357
+ ...text2(kept.why, 300) ? { why: text2(kept.why, 300) } : {},
191
358
  ...typeof kept.heat === "number" ? { heat: Math.max(0, Math.min(100, Math.round(kept.heat))) } : {},
192
- ...time(kept.until) ? { until: time(kept.until) } : {},
359
+ ...time2(kept.until) ? { until: time2(kept.until) } : {},
193
360
  ...texts(kept.seen, 10).length ? { seen: texts(kept.seen, 10) } : {},
194
361
  ...origin && originUrl ? {
195
362
  origin: {
196
363
  url: originUrl,
197
- ...text(origin.title, 200) ? { title: text(origin.title, 200) } : {},
198
- ...text(origin.author, 100) ? { author: text(origin.author, 100) } : {},
199
- ...text(origin.licence, 100) ? { licence: text(origin.licence, 100) } : {}
364
+ ...text2(origin.title, 200) ? { title: text2(origin.title, 200) } : {},
365
+ ...text2(origin.author, 100) ? { author: text2(origin.author, 100) } : {},
366
+ ...text2(origin.licence, 100) ? { licence: text2(origin.licence, 100) } : {}
200
367
  }
201
368
  } : {},
369
+ ...Array.isArray(kept.needs) ? {
370
+ needs: kept.needs.map(need).filter((one) => !!one).slice(0, 12)
371
+ } : {},
202
372
  ...Array.isArray(kept.done) ? { done: STEPS.filter((step) => kept.done.includes(step)) } : {},
203
- ...text(kept.script, 20000) ? { script: text(kept.script, 20000) } : {},
373
+ ...text2(kept.script, 20000) ? { script: text2(kept.script, 20000) } : {},
204
374
  ...Array.isArray(kept.versions) ? { versions: kept.versions.map(version).filter((one) => !!one) } : {},
205
375
  ...Array.isArray(kept.checks) ? { checks: kept.checks.map(check).filter((one) => !!one) } : {},
206
- ...text(kept.session, 1000) ? { session: text(kept.session, 1000) } : {},
207
- ...time(kept.approved) ? { approved: time(kept.approved) } : {},
376
+ ...text2(kept.session, 1000) ? { session: text2(kept.session, 1000) } : {},
377
+ ...time2(kept.approved) ? { approved: time2(kept.approved) } : {},
378
+ ...PublishUtil.publishing(kept.publishing) ? { publishing: PublishUtil.publishing(kept.publishing) } : {},
208
379
  ...Array.isArray(kept.links) ? { links: kept.links.map(link).filter((one) => !!one) } : {},
209
380
  ...Array.isArray(kept.stats) ? { stats: kept.stats.map(stat).filter((one) => !!one) } : {},
210
381
  ...kept.dropped === true ? { dropped: true } : {},
382
+ ...time2(kept.commentsAt) ? { commentsAt: time2(kept.commentsAt) } : {},
383
+ ...time2(kept.commentsGap) ? { commentsGap: time2(kept.commentsGap) } : {},
211
384
  at,
212
- changedAt: time(kept.changedAt) ?? at
385
+ changedAt: time2(kept.changedAt) ?? at
213
386
  };
214
387
  }
215
388
  CreatorUtil.item = item;
@@ -217,10 +390,10 @@ var CreatorUtil;
217
390
  if (!Array.isArray(value)) {
218
391
  return [];
219
392
  }
220
- return value.map((one) => object(one)).filter((one) => !!one && /^\d{4}-\d{2}-\d{2}$/.test(String(one.week))).map((one) => ({
393
+ return value.map((one) => object2(one)).filter((one) => !!one && /^\d{4}-\d{2}-\d{2}$/.test(String(one.week))).map((one) => ({
221
394
  week: String(one.week),
222
- platforms: (Array.isArray(one.platforms) ? one.platforms : []).map((it) => object(it)).filter((it) => !!it && !!text(it.platform, 60)).map((it) => ({
223
- platform: text(it.platform, 60),
395
+ platforms: (Array.isArray(one.platforms) ? one.platforms : []).map((it) => object2(it)).filter((it) => !!it && !!text2(it.platform, 60)).map((it) => ({
396
+ platform: text2(it.platform, 60),
224
397
  views: count(it.views, 0),
225
398
  ...typeof it.likes === "number" ? { likes: count(it.likes, 0) } : {},
226
399
  ...typeof it.follows === "number" ? { follows: count(it.follows, 0) } : {},
@@ -239,6 +412,7 @@ var CreatorUtil;
239
412
  const of = (stage) => items2.filter((one) => one.stage === stage && !one.dropped);
240
413
  return {
241
414
  topic: of("topic").filter((one) => !expired(one, now)).sort((a, b) => (b.heat ?? 0) - (a.heat ?? 0) || b.at - a.at),
415
+ materials: of("materials").sort(latest),
242
416
  making: of("making").sort(latest),
243
417
  review: of("review").sort(latest),
244
418
  published: of("published").sort((a, b) => publishedAt(b) - publishedAt(a))
@@ -250,7 +424,7 @@ var CreatorUtil;
250
424
  }
251
425
  CreatorUtil.expired = expired;
252
426
  function publishedAt(item2) {
253
- return Math.min(...(item2.links ?? []).map((one) => one.at), item2.changedAt);
427
+ return Math.min(...(item2.links ?? []).map((one) => one.scheduled ?? one.at), item2.changedAt);
254
428
  }
255
429
  CreatorUtil.publishedAt = publishedAt;
256
430
  function addTopics(items2, topics, now, id, series = []) {
@@ -291,7 +465,7 @@ var CreatorUtil;
291
465
  }
292
466
  CreatorUtil.change = change;
293
467
  function seriesNamed(series, value) {
294
- const key = text(value, 60).toLowerCase();
468
+ const key = text2(value, 60).toLowerCase();
295
469
  return key ? series.find((one) => one.id.toLowerCase() === key || one.name.toLowerCase() === key) : undefined;
296
470
  }
297
471
  CreatorUtil.seriesNamed = seriesNamed;
@@ -317,47 +491,8 @@ var CreatorUtil;
317
491
  return item2.stats?.length ? item2.stats.reduce((all, one) => all + one.views, 0) : undefined;
318
492
  }
319
493
  CreatorUtil.views = views;
320
- function analysis(items2, settings2) {
321
- const published = items2.filter((one) => one.stage === "published" && !one.dropped);
322
- const measured = published.filter((one) => one.stats?.length);
323
- const group = (key, of) => {
324
- const read = of.filter((one) => one.stats?.length);
325
- const total = read.reduce((all, one) => all + (views(one) ?? 0), 0);
326
- const watched = read.flatMap((one) => (one.stats ?? []).filter((stat2) => stat2.completion !== undefined));
327
- const weight = watched.reduce((all, one) => all + Math.max(1, one.views), 0);
328
- return {
329
- key,
330
- count: of.length,
331
- measured: read.length,
332
- views: total,
333
- average: read.length ? Math.round(total / read.length) : 0,
334
- ...watched.length ? { completion: watched.reduce((all, one) => all + (one.completion ?? 0) * Math.max(1, one.views), 0) / weight } : {}
335
- };
336
- };
337
- const known = new Set(settings2.series.map((one) => one.id));
338
- const none = published.filter((one) => !one.series || !known.has(one.series));
339
- const platforms = [...new Set(measured.flatMap((one) => (one.stats ?? []).map((stat2) => stat2.platform)))].map((platform2) => {
340
- const stats = measured.flatMap((one) => (one.stats ?? []).filter((stat2) => stat2.platform === platform2));
341
- const total = stats.reduce((all, one) => all + one.views, 0);
342
- return { key: platform2, count: stats.length, measured: stats.length, views: total, average: stats.length ? Math.round(total / stats.length) : 0 };
343
- });
344
- return {
345
- published: published.length,
346
- measured: measured.length,
347
- views: measured.reduce((all, one) => all + (views(one) ?? 0), 0),
348
- series: [
349
- ...settings2.series.map((one) => group(one.id, published.filter((item2) => item2.series === one.id))),
350
- ...none.length ? [group("", none)] : []
351
- ],
352
- kinds: KINDS.map((kind) => group(kind, published.filter((one) => one.kind === kind))).filter((one) => one.count),
353
- forms: FORMS.map((form) => group(form, published.filter((one) => one.form === form))).filter((one) => one.count),
354
- platforms: platforms.sort((a, b) => b.views - a.views),
355
- top: measured.map((item2) => ({ item: item2, views: views(item2) ?? 0 })).sort((a, b) => b.views - a.views).slice(0, 5)
356
- };
357
- }
358
- CreatorUtil.analysis = analysis;
359
494
  function setStats(items2, id, stats, now) {
360
- const read = stats.map((one) => stat({ at: now, ...object(one) ?? {} })).filter((one) => !!one);
495
+ const read = stats.map((one) => stat({ at: now, ...object2(one) ?? {} })).filter((one) => !!one);
361
496
  const before = items2.find((one) => one.id === id);
362
497
  if (!before) {
363
498
  throw new Error(`No such piece: ${id}.`);
@@ -366,25 +501,6 @@ var CreatorUtil;
366
501
  return change(items2, id, { stats: [...kept, ...read] }, now);
367
502
  }
368
503
  CreatorUtil.setStats = setStats;
369
- function insights(value) {
370
- return (Array.isArray(value) ? value : []).map((one) => object(one)).filter((one) => !!one && !!text(one.text, 300) && !!time(one.at)).map((one) => ({
371
- text: text(one.text, 300),
372
- tone: oneOf(["good", "bad", "idea"], one.tone, "idea"),
373
- ...text(one.series, 60) ? { series: text(one.series, 60) } : {},
374
- at: time(one.at)
375
- })).sort((a, b) => b.at - a.at).slice(0, 30);
376
- }
377
- CreatorUtil.insights = insights;
378
- function addInsights(kept, added, series, now) {
379
- const read = added.map((one) => typeof one === "string" ? { text: one } : object(one)).filter((one) => !!one).map((one) => ({ ...one, series: seriesNamed(series, one.series)?.id, at: now }));
380
- return insights([...read, ...kept]);
381
- }
382
- CreatorUtil.addInsights = addInsights;
383
- function latestInsights(insights2) {
384
- const newest = insights2[0]?.at ?? 0;
385
- return insights2.filter((one) => newest - one.at < DAY);
386
- }
387
- CreatorUtil.latestInsights = latestInsights;
388
504
  function progress(items2, goal, now) {
389
505
  if (!goal) {
390
506
  return;
@@ -396,7 +512,7 @@ var CreatorUtil;
396
512
  });
397
513
  return {
398
514
  videos: published.filter((one) => one.form === "video").length,
399
- posts: published.filter((one) => one.form === "post").length,
515
+ posts: published.filter((one) => one.form !== "video").length,
400
516
  day: Math.max(1, Math.min(goal.days, Math.floor((now - goal.from) / DAY) + 1))
401
517
  };
402
518
  }
@@ -433,34 +549,45 @@ var CreatorUtil;
433
549
  return minutes(weeks2, now) >= settings2.minutesCap * 0.75 ? 2 : 6;
434
550
  }
435
551
  CreatorUtil.offer = offer;
552
+ function need(value) {
553
+ const kept = object2(value);
554
+ const words = text2(kept?.text, 300);
555
+ if (!kept || !words) {
556
+ return;
557
+ }
558
+ return { id: text2(kept.id, 60), text: words, ...kept.done === true ? { done: true } : {} };
559
+ }
560
+ CreatorUtil.need = need;
436
561
  function version(value) {
437
- const kept = object(value);
438
- const platform2 = text(kept?.platform, 60);
562
+ const kept = object2(value);
563
+ const platform2 = text2(kept?.platform, 60);
439
564
  if (!kept || !platform2) {
440
565
  return;
441
566
  }
442
- const cover = text(kept.cover, 500);
567
+ const cover = text2(kept.cover, 500);
443
568
  return {
444
569
  platform: platform2,
445
- title: text(kept.title, 200),
446
- text: text(kept.text, 5000),
570
+ ...FORMS.includes(kept.form) ? { form: kept.form } : {},
571
+ title: text2(kept.title, 200),
572
+ text: text2(kept.text, 20000),
447
573
  tags: texts(kept.tags, 20),
448
574
  files: texts(kept.files, 40),
449
575
  ...cover ? { cover } : {}
450
576
  };
451
577
  }
452
578
  function check(value) {
453
- const kept = object(value);
454
- return kept && text(kept.text, 200) ? { text: text(kept.text, 200), ok: kept.ok === true } : undefined;
579
+ const kept = object2(value);
580
+ return kept && text2(kept.text, 200) ? { text: text2(kept.text, 200), ok: kept.ok === true } : undefined;
455
581
  }
456
582
  function link(value) {
457
- const kept = object(value);
583
+ const kept = object2(value);
458
584
  const href = url(kept?.url);
459
- return kept && href && text(kept.platform, 60) ? { platform: text(kept.platform, 60), url: href, at: time(kept.at) ?? Date.now() } : undefined;
585
+ const scheduled = PublishUtil.timeOf(kept?.scheduled);
586
+ return kept && href && text2(kept.platform, 60) ? { platform: text2(kept.platform, 60), url: href, at: time2(kept.at) ?? Date.now(), ...scheduled ? { scheduled } : {} } : undefined;
460
587
  }
461
588
  function stat(value) {
462
- const kept = object(value);
463
- const platform2 = text(kept?.platform, 60);
589
+ const kept = object2(value);
590
+ const platform2 = text2(kept?.platform, 60);
464
591
  if (!kept || !platform2 || typeof kept.views !== "number") {
465
592
  return;
466
593
  }
@@ -472,27 +599,13 @@ var CreatorUtil;
472
599
  ...optional("comments"),
473
600
  ...optional("follows"),
474
601
  ...typeof kept.completion === "number" && Number.isFinite(kept.completion) ? { completion: Math.max(0, Math.min(1, kept.completion)) } : {},
475
- at: time(kept.at) ?? Date.now()
602
+ at: time2(kept.at) ?? Date.now()
476
603
  };
477
604
  }
478
- function hash(value) {
479
- let h = 0;
480
- for (const char of value) {
481
- h = Math.imul(h, 31) + (char.codePointAt(0) ?? 0) | 0;
482
- }
483
- return (h >>> 0).toString(36);
484
- }
485
605
  function source(value) {
486
- const kept = object(value);
606
+ const kept = object2(value);
487
607
  const href = url(kept?.url);
488
- return kept && href && text(kept.name, 80) ? { name: text(kept.name, 80), url: href } : undefined;
489
- }
490
- function url(value) {
491
- const raw = text(value, 1000);
492
- return /^https?:\/\/\S+$/i.test(raw) ? raw : undefined;
493
- }
494
- function count(value, fallback) {
495
- return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : fallback;
608
+ return kept && href && text2(kept.name, 80) ? { name: text2(kept.name, 80), url: href } : undefined;
496
609
  }
497
610
  })(CreatorUtil ||= {});
498
611
 
@@ -605,6 +718,12 @@ var EN = {
605
718
  pass: "Pass, publish it",
606
719
  approved: "Passed: Ta publishes it on each platform",
607
720
  passPrompt: "Passed: publish {id} on each platform and keep the links",
721
+ queuedNext: "Passed: published next",
722
+ queuedAhead: "Passed: {n} to publish before it",
723
+ publishingNow: "Publishing now",
724
+ slotNow: "now",
725
+ stoppedNote: "Not published: {note}",
726
+ publishAgain: "Publish again",
608
727
  doingScript: "Writing the script: a hook in the first 3 seconds",
609
728
  doingVisuals: "Drawing the scenes: host, terminal, phone",
610
729
  doingVoice: "Recording the voice, scene by scene",
@@ -640,7 +759,84 @@ var EN = {
640
759
  reviewPrompt: "Review my channel now: read the numbers of each piece on each platform, compare series, kinds and forms, and keep what you find for the topics to come",
641
760
  viewsShort: "{n} views",
642
761
  cancel: "Cancel",
643
- noneYet: "Nothing published yet"
762
+ noneYet: "Nothing published yet",
763
+ article: "Article",
764
+ note: "Note",
765
+ original: "Your own",
766
+ talk: "Comments",
767
+ materials: "Materials",
768
+ needsTitle: "Waiting for your materials",
769
+ needsHint: "Ta looked in the working directory first; send the rest in its conversation",
770
+ giveNow: "Send them",
771
+ skipNeeds: "Go on without",
772
+ skipPrompt: "{id}: do not wait for the materials, make it with what there is",
773
+ flowMaterials: "{n} wait for materials",
774
+ public: "Public",
775
+ internal: "In-company",
776
+ both: "Both",
777
+ reachTip: "Who it is for: tap to change",
778
+ noInside: "For your company, but no in-company platform is picked: add one in Settings",
779
+ drafts: "Answers waiting for you",
780
+ autoSent: "Answered lately",
781
+ asked: "What the audience asks",
782
+ send: "Send",
783
+ dropReply: "Don’t answer",
784
+ withdraw: "Take back",
785
+ withdrawn: "Taken back",
786
+ sending: "Posting soon",
787
+ sent: "Posted",
788
+ autoTag: "by Ta",
789
+ replyLevels: "How comments are answered",
790
+ levelAct: "On its own",
791
+ levelAsk: "Show me first",
792
+ levelOff: "Not at all",
793
+ levelAuto: "Let Ta adjust",
794
+ levelLearn: "Ta learns from you: answers sent as written move a kind to “on its own”; changed or taken back, back to “show me first”",
795
+ question: "Question",
796
+ suggestion: "Suggestion",
797
+ correction: "Correction",
798
+ praise: "Praise",
799
+ negative: "Negative",
800
+ spam: "Ad",
801
+ noComments: "No comments read yet",
802
+ commentsHint: "Read after publishing: more often while comments come, less while none do",
803
+ commentsPace: "Reading comments",
804
+ paceHow: "How often",
805
+ paceAuto: "Auto",
806
+ paceHours: "Every {n} h",
807
+ paceDaily: "Daily",
808
+ paceFor: "For how long",
809
+ paceDays: "{n} days",
810
+ paceAutoNote: "Ta reads more often when many come (down to 1 h) and slows down when none do (up to 2 days); a new piece starts where the last ones settled",
811
+ paceNow: "Now about every {n} h",
812
+ paceFixedNote: "Each piece is read at this pace; Ta still learns, for when you go back to Auto",
813
+ flowDrafts: "{n} to answer",
814
+ flowComments: "{n} comments",
815
+ ledTo: "Made a topic",
816
+ strategy: "Strategy",
817
+ strategyAuto: "Learns itself",
818
+ strategyManual: "I decide",
819
+ strategyAutoHint: "Each review updates it; remove what you disagree with",
820
+ strategyManualHint: "Reviews only propose; it changes once you take them",
821
+ ruleMine: "Yours",
822
+ take: "Take",
823
+ decline: "No",
824
+ keepRule: "Keep",
825
+ addRule: "Add a rule",
826
+ ruleHint: "e.g. at least one article a week",
827
+ proposedRules: "Proposed",
828
+ phases: "Looking back",
829
+ phaseEvery: "Every {n} weeks",
830
+ phaseOff: "Off",
831
+ phaseNow: "Look back now",
832
+ phasePrompt: "Look back on this stage of my channel now: what was published, how the numbers and followers went, what the strategy was and what changed, what to change next; keep it and make it a topic of the channel’s own story",
833
+ noPhases: "Every few weeks Ta looks back on the stage; the look back can become a piece",
834
+ insideLabel: "In-company platforms",
835
+ insideHint: "They take only pieces for your company, such as an internal knowledge base",
836
+ insideName: "Name",
837
+ insideUrl: "Address of its publishing page",
838
+ addInside: "Add",
839
+ seriesInside: "In-company"
644
840
  };
645
841
  var ZH = {
646
842
  title: "创作者",
@@ -711,6 +907,12 @@ var ZH = {
711
907
  pass: "通过,自动发布",
712
908
  approved: "已通过:Ta 正在各平台发布",
713
909
  passPrompt: "{id} 审过了:去各平台发布,发完记下链接",
910
+ queuedNext: "已通过:下一条就发它",
911
+ queuedAhead: "已通过:前面还有 {n} 条在发",
912
+ publishingNow: "正在发布",
913
+ slotNow: "立即",
914
+ stoppedNote: "没发出去:{note}",
915
+ publishAgain: "再发一次",
714
916
  doingScript: "写脚本:开头 3 秒抓住人",
715
917
  doingVisuals: "画画面:主播、终端、手机",
716
918
  doingVoice: "逐个场景配音",
@@ -746,7 +948,84 @@ var ZH = {
746
948
  reviewPrompt: "现在复盘我的内容号:读各平台每条内容的数据,按系列、类型、形式对比,把结论记下来用于后面的选题",
747
949
  viewsShort: "{n} 播放",
748
950
  cancel: "取消",
749
- noneYet: "还没有发布"
951
+ noneYet: "还没有发布",
952
+ article: "长文",
953
+ note: "动态",
954
+ original: "原创",
955
+ talk: "互动",
956
+ materials: "等素材",
957
+ needsTitle: "等你的素材",
958
+ needsHint: "Ta 已先在工作目录里找过,剩下的在对话里发给 Ta",
959
+ giveNow: "去发素材",
960
+ skipNeeds: "不等了,先做",
961
+ skipPrompt: "{id} 不等素材了,用现有的先做",
962
+ flowMaterials: "{n} 条等素材",
963
+ public: "公开",
964
+ internal: "公司内",
965
+ both: "内外都发",
966
+ reachTip: "发布范围:点一下切换",
967
+ noInside: "这条要发公司内,但还没选公司内平台:在设置里添加",
968
+ drafts: "等你过目的回复",
969
+ autoSent: "最近的回复",
970
+ asked: "观众在问",
971
+ send: "发送",
972
+ dropReply: "不回",
973
+ withdraw: "撤回",
974
+ withdrawn: "已撤回",
975
+ sending: "稍后发出",
976
+ sent: "已发出",
977
+ autoTag: "Ta 自动回",
978
+ replyLevels: "回复方式",
979
+ levelAct: "自动回",
980
+ levelAsk: "先给我看",
981
+ levelOff: "不回",
982
+ levelAuto: "交给 Ta 调",
983
+ levelLearn: "Ta 会跟着你学:照发多了改成自动回,常改常撤就退回先给你看",
984
+ question: "提问",
985
+ suggestion: "建议",
986
+ correction: "纠错",
987
+ praise: "夸奖",
988
+ negative: "负面",
989
+ spam: "广告",
990
+ noComments: "还没有读到评论",
991
+ commentsHint: "发布后自动读评论:评论多就读得勤,没有就放慢",
992
+ commentsPace: "读评论",
993
+ paceHow: "多久读一次",
994
+ paceAuto: "自动",
995
+ paceHours: "每 {n} 小时",
996
+ paceDaily: "每天",
997
+ paceFor: "读多久",
998
+ paceDays: "{n} 天",
999
+ paceAutoNote: "Ta 按评论多少自己调:新评论多就读得勤(最快 1 小时),没有就放慢(最慢 2 天);新发布的从最近几条摸出的节奏开始",
1000
+ paceNow: "现在约每 {n} 小时一次",
1001
+ paceFixedNote: "每条都按这个节奏读;Ta 仍在学,切回自动时直接用上",
1002
+ flowDrafts: "{n} 条待回",
1003
+ flowComments: "{n} 条评论",
1004
+ ledTo: "已成选题",
1005
+ strategy: "策略",
1006
+ strategyAuto: "自动进化",
1007
+ strategyManual: "我来定",
1008
+ strategyAutoHint: "每次复盘自动更新,不认同的删掉就行",
1009
+ strategyManualHint: "复盘只提建议,你采纳才生效",
1010
+ ruleMine: "你定的",
1011
+ take: "采纳",
1012
+ decline: "不要",
1013
+ keepRule: "固定",
1014
+ addRule: "加一条规则",
1015
+ ruleHint: "比如:每周至少一篇长文",
1016
+ proposedRules: "复盘建议",
1017
+ phases: "阶段回顾",
1018
+ phaseEvery: "每 {n} 周",
1019
+ phaseOff: "不回顾",
1020
+ phaseNow: "现在回顾",
1021
+ phasePrompt: "现在回顾我的内容号这一阶段:发了什么、数据和粉丝怎么变、策略是什么又改了什么、下一阶段改什么;记下来,并做成一期讲这个号自己经历的选题",
1022
+ noPhases: "每隔几周 Ta 回顾一次这一阶段,回顾可以做成一期内容",
1023
+ insideLabel: "公司内平台",
1024
+ insideHint: "只发给公司内看的内容,比如内部知识库",
1025
+ insideName: "平台名",
1026
+ insideUrl: "发布页地址",
1027
+ addInside: "添加",
1028
+ seriesInside: "公司内"
750
1029
  };
751
1030
  var ZH_TW = {
752
1031
  title: "創作者",
@@ -817,6 +1096,12 @@ var ZH_TW = {
817
1096
  pass: "通過,自動發佈",
818
1097
  approved: "已通過:Ta 正在各平台發佈",
819
1098
  passPrompt: "{id} 審過了:去各平台發佈,發完記下連結",
1099
+ queuedNext: "已通過:下一條就發它",
1100
+ queuedAhead: "已通過:前面還有 {n} 條在發",
1101
+ publishingNow: "正在發佈",
1102
+ slotNow: "立即",
1103
+ stoppedNote: "沒發出去:{note}",
1104
+ publishAgain: "再發一次",
820
1105
  doingScript: "寫腳本:開頭 3 秒抓住人",
821
1106
  doingVisuals: "畫畫面:主播、終端、手機",
822
1107
  doingVoice: "逐個場景配音",
@@ -852,7 +1137,84 @@ var ZH_TW = {
852
1137
  reviewPrompt: "現在複盤我的內容號:讀各平台每條內容的數據,按系列、類型、形式對比,把結論記下來用於後面的選題",
853
1138
  viewsShort: "{n} 播放",
854
1139
  cancel: "取消",
855
- noneYet: "還沒有發佈"
1140
+ noneYet: "還沒有發佈",
1141
+ article: "長文",
1142
+ note: "動態",
1143
+ original: "原創",
1144
+ talk: "互動",
1145
+ materials: "等素材",
1146
+ needsTitle: "等你的素材",
1147
+ needsHint: "Ta 已先在工作目錄裡找過,剩下的在對話裡發給 Ta",
1148
+ giveNow: "去發素材",
1149
+ skipNeeds: "不等了,先做",
1150
+ skipPrompt: "{id} 不等素材了,用現有的先做",
1151
+ flowMaterials: "{n} 條等素材",
1152
+ public: "公開",
1153
+ internal: "公司內",
1154
+ both: "內外都發",
1155
+ reachTip: "發佈範圍:點一下切換",
1156
+ noInside: "這條要發公司內,但還沒選公司內平台:在設定裡新增",
1157
+ drafts: "等你過目的回覆",
1158
+ autoSent: "最近的回覆",
1159
+ asked: "觀眾在問",
1160
+ send: "發送",
1161
+ dropReply: "不回",
1162
+ withdraw: "撤回",
1163
+ withdrawn: "已撤回",
1164
+ sending: "稍後發出",
1165
+ sent: "已發出",
1166
+ autoTag: "Ta 自動回",
1167
+ replyLevels: "回覆方式",
1168
+ levelAct: "自動回",
1169
+ levelAsk: "先給我看",
1170
+ levelOff: "不回",
1171
+ levelAuto: "交給 Ta 調",
1172
+ levelLearn: "Ta 會跟著你學:照發多了改成自動回,常改常撤就退回先給你看",
1173
+ question: "提問",
1174
+ suggestion: "建議",
1175
+ correction: "糾錯",
1176
+ praise: "稱讚",
1177
+ negative: "負面",
1178
+ spam: "廣告",
1179
+ noComments: "還沒有讀到留言",
1180
+ commentsHint: "發佈後自動讀評論:評論多就讀得勤,沒有就放慢",
1181
+ commentsPace: "讀評論",
1182
+ paceHow: "多久讀一次",
1183
+ paceAuto: "自動",
1184
+ paceHours: "每 {n} 小時",
1185
+ paceDaily: "每天",
1186
+ paceFor: "讀多久",
1187
+ paceDays: "{n} 天",
1188
+ paceAutoNote: "Ta 依評論多少自己調:新評論多就讀得勤(最快 1 小時),沒有就放慢(最慢 2 天);新發佈的從最近幾條摸出的節奏開始",
1189
+ paceNow: "現在約每 {n} 小時一次",
1190
+ paceFixedNote: "每條都照這個節奏讀;Ta 仍在學,切回自動時直接用上",
1191
+ flowDrafts: "{n} 條待回",
1192
+ flowComments: "{n} 條留言",
1193
+ ledTo: "已成選題",
1194
+ strategy: "策略",
1195
+ strategyAuto: "自動進化",
1196
+ strategyManual: "我來定",
1197
+ strategyAutoHint: "每次複盤自動更新,不認同的刪掉就行",
1198
+ strategyManualHint: "複盤只提建議,你採納才生效",
1199
+ ruleMine: "你定的",
1200
+ take: "採納",
1201
+ decline: "不要",
1202
+ keepRule: "固定",
1203
+ addRule: "加一條規則",
1204
+ ruleHint: "比如:每週至少一篇長文",
1205
+ proposedRules: "複盤建議",
1206
+ phases: "階段回顧",
1207
+ phaseEvery: "每 {n} 週",
1208
+ phaseOff: "不回顧",
1209
+ phaseNow: "現在回顧",
1210
+ phasePrompt: "現在回顧我的內容號這一階段:發了什麼、數據和粉絲怎麼變、策略是什麼又改了什麼、下一階段改什麼;記下來,並做成一期講這個號自己經歷的選題",
1211
+ noPhases: "每隔幾週 Ta 回顧一次這一階段,回顧可以做成一期內容",
1212
+ insideLabel: "公司內平台",
1213
+ insideHint: "只發給公司內看的內容,比如內部知識庫",
1214
+ insideName: "平台名",
1215
+ insideUrl: "發佈頁地址",
1216
+ addInside: "新增",
1217
+ seriesInside: "公司內"
856
1218
  };
857
1219
  var JA = {
858
1220
  title: "クリエイター",
@@ -923,6 +1285,12 @@ var JA = {
923
1285
  pass: "OK、自動で投稿",
924
1286
  approved: "OK 済み:Ta が各プラットフォームに投稿中",
925
1287
  passPrompt: "{id} は確認済み:各プラットフォームに投稿し、リンクを記録して",
1288
+ queuedNext: "OK 済み:次に投稿します",
1289
+ queuedAhead: "OK 済み:先に {n} 件を投稿します",
1290
+ publishingNow: "投稿中",
1291
+ slotNow: "すぐ",
1292
+ stoppedNote: "投稿できませんでした:{note}",
1293
+ publishAgain: "もう一度投稿",
926
1294
  doingScript: "台本:最初の 3 秒でつかむ",
927
1295
  doingVisuals: "映像:ホスト、ターミナル、スマホ",
928
1296
  doingVoice: "シーンごとにナレーション",
@@ -958,7 +1326,84 @@ var JA = {
958
1326
  reviewPrompt: "私のチャンネルを今すぐ振り返って:各プラットフォームの各コンテンツのデータを読み、シリーズ・種類・形式で比べ、結論を今後のネタ選びのために記録して",
959
1327
  viewsShort: "{n} 再生",
960
1328
  cancel: "キャンセル",
961
- noneYet: "まだ公開なし"
1329
+ noneYet: "まだ公開なし",
1330
+ article: "記事",
1331
+ note: "短文",
1332
+ original: "オリジナル",
1333
+ talk: "コメント",
1334
+ materials: "素材待ち",
1335
+ needsTitle: "あなたの素材待ち",
1336
+ needsHint: "Ta が先に作業ディレクトリを探しました。残りは会話で送ってください",
1337
+ giveNow: "素材を送る",
1338
+ skipNeeds: "待たずに作る",
1339
+ skipPrompt: "{id}:素材を待たず、今あるもので作って",
1340
+ flowMaterials: "{n} 件が素材待ち",
1341
+ public: "公開",
1342
+ internal: "社内",
1343
+ both: "社内外",
1344
+ reachTip: "公開範囲:タップで切り替え",
1345
+ noInside: "社内向けですが社内プラットフォームが未選択です:設定で追加",
1346
+ drafts: "確認待ちの返信",
1347
+ autoSent: "最近の返信",
1348
+ asked: "視聴者の声",
1349
+ send: "送信",
1350
+ dropReply: "返信しない",
1351
+ withdraw: "取り消す",
1352
+ withdrawn: "取り消し済み",
1353
+ sending: "まもなく投稿",
1354
+ sent: "投稿済み",
1355
+ autoTag: "Ta が自動返信",
1356
+ replyLevels: "返信のしかた",
1357
+ levelAct: "自動で返信",
1358
+ levelAsk: "先に見せる",
1359
+ levelOff: "返信しない",
1360
+ levelAuto: "Ta に任せる",
1361
+ levelLearn: "Ta はあなたから学びます:そのまま送ることが多ければ自動に、直したり取り消したりが多ければ確認に戻ります",
1362
+ question: "質問",
1363
+ suggestion: "提案",
1364
+ correction: "指摘",
1365
+ praise: "称賛",
1366
+ negative: "否定的",
1367
+ spam: "広告",
1368
+ noComments: "まだコメントを読んでいません",
1369
+ commentsHint: "公開後に自動で読みます。コメントが多いほど頻繁に、ないときは間隔を空けます",
1370
+ commentsPace: "コメントの確認",
1371
+ paceHow: "頻度",
1372
+ paceAuto: "自動",
1373
+ paceHours: "{n} 時間ごと",
1374
+ paceDaily: "毎日",
1375
+ paceFor: "期間",
1376
+ paceDays: "{n} 日",
1377
+ paceAutoNote: "新しいコメントが多ければ頻繁に(最短 1 時間)、なければ間隔を空けます(最長 2 日)。新しい投稿は直近の投稿で落ち着いた間隔から始めます",
1378
+ paceNow: "今はおよそ {n} 時間ごと",
1379
+ paceFixedNote: "どの投稿もこの頻度で読みます。Ta は学び続け、自動に戻すとすぐ使います",
1380
+ flowDrafts: "返信待ち {n}",
1381
+ flowComments: "{n} 件のコメント",
1382
+ ledTo: "ネタになった",
1383
+ strategy: "戦略",
1384
+ strategyAuto: "自動で進化",
1385
+ strategyManual: "自分で決める",
1386
+ strategyAutoHint: "振り返りのたびに更新。合わないものは削除",
1387
+ strategyManualHint: "振り返りは提案だけ。採用すると反映",
1388
+ ruleMine: "あなたのルール",
1389
+ take: "採用",
1390
+ decline: "不要",
1391
+ keepRule: "固定",
1392
+ addRule: "ルールを追加",
1393
+ ruleHint: "例:毎週少なくとも 1 本の記事",
1394
+ proposedRules: "振り返りの提案",
1395
+ phases: "段階の振り返り",
1396
+ phaseEvery: "{n} 週ごと",
1397
+ phaseOff: "しない",
1398
+ phaseNow: "今すぐ振り返る",
1399
+ phasePrompt: "私のチャンネルのこの段階を今すぐ振り返って:何を公開し、数字とフォロワーはどう動き、戦略は何で何を変えたか、次に何を変えるか。記録し、このチャンネル自身の話としてネタにして",
1400
+ noPhases: "数週間ごとに Ta が段階を振り返ります。振り返りは 1 本のコンテンツにもなります",
1401
+ insideLabel: "社内プラットフォーム",
1402
+ insideHint: "社内向けのコンテンツだけを投稿(社内ナレッジベースなど)",
1403
+ insideName: "名前",
1404
+ insideUrl: "投稿ページのアドレス",
1405
+ addInside: "追加",
1406
+ seriesInside: "社内"
962
1407
  };
963
1408
  var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
964
1409
  var CreatorWords;
@@ -967,8 +1412,8 @@ var CreatorWords;
967
1412
  return TaLanguageUtil.pick(language, WORDS);
968
1413
  }
969
1414
  CreatorWords.of = of;
970
- function format(text2, values) {
971
- return text2.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
1415
+ function format(text3, values) {
1416
+ return text3.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
972
1417
  }
973
1418
  CreatorWords.format = format;
974
1419
  })(CreatorWords ||= {});
@@ -1013,6 +1458,14 @@ async function openPiece(context, item) {
1013
1458
  }
1014
1459
  await talk(pi, item.title, format(useWordsOf(pi).makePrompt, { title: item.title, id: item.id }));
1015
1460
  }
1461
+ async function tell(context, item, text3) {
1462
+ const { pi } = context;
1463
+ if (item.session && await pi.openChat?.(item.session)) {
1464
+ await pi.sendUserMessage(text3);
1465
+ } else {
1466
+ await talk(pi, item.title, text3);
1467
+ }
1468
+ }
1016
1469
  function useWordsOf(pi) {
1017
1470
  return CreatorWords.of(pi.ui.language);
1018
1471
  }
@@ -1124,6 +1577,7 @@ function BusyButton({
1124
1577
  pi,
1125
1578
  className,
1126
1579
  disabled,
1580
+ pressed,
1127
1581
  onClick,
1128
1582
  children
1129
1583
  }) {
@@ -1132,6 +1586,7 @@ function BusyButton({
1132
1586
  type: "button",
1133
1587
  className: busy ? `${className} ta-busy` : className,
1134
1588
  disabled,
1589
+ "aria-pressed": pressed,
1135
1590
  onClick: () => void run(() => Promise.resolve().then(onClick).catch(failed(pi)))
1136
1591
  }, busy && /* @__PURE__ */ React.createElement("span", {
1137
1592
  className: "ta-spinner ta-busy-mark"
@@ -1140,14 +1595,15 @@ function BusyButton({
1140
1595
 
1141
1596
  // web-src/cards.tsx
1142
1597
  var VIDEO = /\.(mp4|mov|webm|m4v)$/i;
1598
+ var IMAGE = /\.(png|jpe?g|webp|gif)$/i;
1143
1599
  function useFileUrl(context, path) {
1144
- const [url, setUrl] = React.useState();
1600
+ const [url2, setUrl] = React.useState();
1145
1601
  React.useEffect(() => {
1146
1602
  let live = true;
1147
1603
  setUrl(undefined);
1148
1604
  if (path) {
1149
1605
  const { pi } = context;
1150
- pi.workspace.fileUrl(path).then((url2) => pi.files.loadable(url2)).then((got) => live && setUrl(got), () => {
1606
+ pi.workspace.fileUrl(path).then((url3) => pi.files.loadable(url3)).then((got) => live && setUrl(got), () => {
1151
1607
  return;
1152
1608
  });
1153
1609
  }
@@ -1155,25 +1611,27 @@ function useFileUrl(context, path) {
1155
1611
  live = false;
1156
1612
  };
1157
1613
  }, [path]);
1158
- return url;
1614
+ return url2;
1159
1615
  }
1160
1616
  function Preview({ context, version }) {
1161
- const file = version?.files[0];
1162
- const url = useFileUrl(context, file);
1617
+ const file = version?.files.find((one) => VIDEO.test(one) || IMAGE.test(one));
1618
+ const url2 = useFileUrl(context, file);
1163
1619
  const cover = useFileUrl(context, version?.cover);
1164
1620
  const words = useWords(context.pi);
1165
1621
  return /* @__PURE__ */ React.createElement("div", {
1166
1622
  className: "tcre-preview"
1167
- }, url && file && VIDEO.test(file) ? /* @__PURE__ */ React.createElement("video", {
1168
- src: url,
1623
+ }, url2 && file && VIDEO.test(file) ? /* @__PURE__ */ React.createElement("video", {
1624
+ src: url2,
1169
1625
  poster: cover,
1170
1626
  controls: true,
1171
1627
  playsInline: true,
1172
1628
  preload: "metadata"
1173
- }) : url ? /* @__PURE__ */ React.createElement("img", {
1174
- src: url,
1629
+ }) : url2 ? /* @__PURE__ */ React.createElement("img", {
1630
+ src: url2,
1175
1631
  alt: ""
1176
- }) : /* @__PURE__ */ React.createElement("div", {
1632
+ }) : version?.text && !file ? /* @__PURE__ */ React.createElement("div", {
1633
+ className: "tcre-preview-words"
1634
+ }, version.text) : /* @__PURE__ */ React.createElement("div", {
1177
1635
  className: "tcre-preview-empty"
1178
1636
  }, version ? "" : words.versions), /* @__PURE__ */ React.createElement("span", {
1179
1637
  className: "tcre-ai"
@@ -1195,15 +1653,12 @@ function ReviewCard({
1195
1653
  const opened = React.useRef(Date.now());
1196
1654
  const version = versions[Math.min(shown, versions.length - 1)];
1197
1655
  const minutes = () => Math.min(30, Math.max(1, Math.round((Date.now() - opened.current) / 60000)));
1198
- const say = async (text2) => {
1199
- if (send) {
1200
- await send(text2);
1201
- } else if (item.session && await pi.openChat?.(item.session)) {
1202
- await pi.sendUserMessage(text2);
1203
- } else {
1204
- await talk(pi, item.title, text2);
1205
- }
1206
- };
1656
+ const say = (text3) => send ? send(text3) : tell(context, item, text3);
1657
+ const state = useStore(store);
1658
+ const reach = CreatorUtil.reach(item, state.settings);
1659
+ const open = item.stage === "review" && !item.approved;
1660
+ const inside = CreatorUtil.picked(state.settings).some((one) => one.internal);
1661
+ const nextReach = () => store.call("update", item.id, { reach: REACHES[(REACHES.indexOf(reach) + 1) % REACHES.length] });
1207
1662
  const change = async () => {
1208
1663
  const note = (await pi.ui.input(words.changeAsk))?.trim();
1209
1664
  if (note) {
@@ -1212,12 +1667,11 @@ function ReviewCard({
1212
1667
  }
1213
1668
  };
1214
1669
  const pass = async () => {
1215
- await store.call("approve", item.id, minutes());
1216
- await say(format(words.passPrompt, { id: item.id }));
1670
+ await store.call("approve", item.id, minutes(), format(words.passPrompt, { id: item.id }));
1217
1671
  };
1218
1672
  return /* @__PURE__ */ React.createElement("div", {
1219
1673
  className: "tcre-card tcre-review"
1220
- }, (item.series || onRemove) && /* @__PURE__ */ React.createElement("div", {
1674
+ }, (item.series || onRemove || reach !== "public" || open) && /* @__PURE__ */ React.createElement("div", {
1221
1675
  className: "tcre-review-head"
1222
1676
  }, /* @__PURE__ */ React.createElement(SeriesTag, {
1223
1677
  series: seriesOf(context, item.series),
@@ -1225,7 +1679,17 @@ function ReviewCard({
1225
1679
  words
1226
1680
  }), /* @__PURE__ */ React.createElement("span", {
1227
1681
  className: "tcre-grow"
1228
- }), onRemove && /* @__PURE__ */ React.createElement(IconButton, {
1682
+ }), open ? /* @__PURE__ */ React.createElement(BusyButton, {
1683
+ pi,
1684
+ className: "tcre-reach",
1685
+ onClick: nextReach
1686
+ }, /* @__PURE__ */ React.createElement("span", {
1687
+ title: words.reachTip,
1688
+ "data-reach": reach
1689
+ }, words[reach])) : reach !== "public" && /* @__PURE__ */ React.createElement("span", {
1690
+ className: "tcre-reach",
1691
+ "data-reach": reach
1692
+ }, words[reach]), onRemove && /* @__PURE__ */ React.createElement(IconButton, {
1229
1693
  pi,
1230
1694
  icon: "Trash2",
1231
1695
  label: words.remove,
@@ -1245,7 +1709,9 @@ function ReviewCard({
1245
1709
  onClick: () => setShown(at)
1246
1710
  }, /* @__PURE__ */ React.createElement(PlatformName, {
1247
1711
  platform: platformOf(context, one.platform) ?? { id: one.platform, name: one.platform, color: "var(--ta-muted)" }
1248
- })))), /* @__PURE__ */ React.createElement("div", {
1712
+ }), one.form && one.form !== item.form && /* @__PURE__ */ React.createElement("em", {
1713
+ className: "tcre-tab-form"
1714
+ }, words[one.form])))), /* @__PURE__ */ React.createElement("div", {
1249
1715
  className: "tcre-review-title"
1250
1716
  }, version?.title || item.title), version?.text && /* @__PURE__ */ React.createElement("button", {
1251
1717
  type: "button",
@@ -1261,9 +1727,12 @@ function ReviewCard({
1261
1727
  }, item.checks.map((check) => /* @__PURE__ */ React.createElement("span", {
1262
1728
  key: check.text,
1263
1729
  "data-ok": check.ok || undefined
1264
- }, /* @__PURE__ */ React.createElement("i", null, check.ok ? "✓" : "!"), check.text))), item.approved ? /* @__PURE__ */ React.createElement("div", {
1265
- className: "tcre-approved"
1266
- }, words.approved) : item.stage === "review" && /* @__PURE__ */ React.createElement("div", {
1730
+ }, /* @__PURE__ */ React.createElement("i", null, check.ok ? "✓" : "!"), check.text))), open && reach !== "public" && !inside && /* @__PURE__ */ React.createElement("div", {
1731
+ className: "tcre-notice"
1732
+ }, words.noInside), item.approved ? /* @__PURE__ */ React.createElement(Publishing, {
1733
+ context,
1734
+ item
1735
+ }) : item.stage === "review" && /* @__PURE__ */ React.createElement("div", {
1267
1736
  className: "tcre-buttons"
1268
1737
  }, /* @__PURE__ */ React.createElement(BusyButton, {
1269
1738
  pi,
@@ -1275,6 +1744,43 @@ function ReviewCard({
1275
1744
  onClick: pass
1276
1745
  }, words.pass)));
1277
1746
  }
1747
+ function Publishing({ context, item }) {
1748
+ const { pi, store } = context;
1749
+ const words = useWords(pi);
1750
+ const state = useStore(store);
1751
+ const publishing = item.publishing;
1752
+ if (publishing?.state === "stopped") {
1753
+ return /* @__PURE__ */ React.createElement("div", {
1754
+ className: "tcre-approved",
1755
+ "data-tone": "warn"
1756
+ }, /* @__PURE__ */ React.createElement("span", null, format(words.stoppedNote, { note: publishing.note || "—" })), /* @__PURE__ */ React.createElement(BusyButton, {
1757
+ pi,
1758
+ className: "tcre-secondary",
1759
+ onClick: () => store.call("approve", item.id, 0, format(words.passPrompt, { id: item.id }))
1760
+ }, words.publishAgain));
1761
+ }
1762
+ if (publishing?.state === "running") {
1763
+ const two = (n) => String(n).padStart(2, "0");
1764
+ const when = (at) => at ? `${new Date(at).getMonth() + 1}-${new Date(at).getDate()} ${two(new Date(at).getHours())}:${two(new Date(at).getMinutes())}` : words.slotNow;
1765
+ return /* @__PURE__ */ React.createElement("div", {
1766
+ className: "tcre-approved"
1767
+ }, /* @__PURE__ */ React.createElement("span", null, words.publishingNow), (publishing.slots ?? []).map((slot) => /* @__PURE__ */ React.createElement("span", {
1768
+ key: slot.platform,
1769
+ className: "tcre-slot"
1770
+ }, /* @__PURE__ */ React.createElement(PlatformName, {
1771
+ platform: platformOf(context, slot.platform) ?? { id: slot.platform, name: slot.platform, color: "var(--ta-muted)" }
1772
+ }), when(slot.at))));
1773
+ }
1774
+ if (publishing?.state === "queued") {
1775
+ const n = PublishUtil.ahead(state.items, item.id);
1776
+ return /* @__PURE__ */ React.createElement("div", {
1777
+ className: "tcre-approved"
1778
+ }, n ? format(words.queuedAhead, { n }) : words.queuedNext);
1779
+ }
1780
+ return /* @__PURE__ */ React.createElement("div", {
1781
+ className: "tcre-approved"
1782
+ }, words.approved);
1783
+ }
1278
1784
  function reviewBlock(context) {
1279
1785
  return function Review({ code, closed, send, conversation }) {
1280
1786
  const state = useStore(context.store);
@@ -1314,12 +1820,266 @@ var ReviewCode;
1314
1820
  ReviewCode.id = id;
1315
1821
  })(ReviewCode ||= {});
1316
1822
 
1823
+ // web-src/channel-util.ts
1824
+ var HOUR = 3600000;
1825
+ var DAY2 = 24 * HOUR;
1826
+ var MAX_COMMENTS = 600;
1827
+ var COMMENTS_FOR = 60 * DAY2;
1828
+ var MAX_LESSONS = 40;
1829
+ var ChannelUtil;
1830
+ ((ChannelUtil) => {
1831
+ function analysis(items, settings) {
1832
+ const published = items.filter((one) => one.stage === "published" && !one.dropped);
1833
+ const measured = published.filter((one) => one.stats?.length);
1834
+ const group = (key, of) => {
1835
+ const read = of.filter((one) => one.stats?.length);
1836
+ const total = read.reduce((all, one) => all + (CreatorUtil.views(one) ?? 0), 0);
1837
+ const watched = read.flatMap((one) => (one.stats ?? []).filter((stat) => stat.completion !== undefined));
1838
+ const weight = watched.reduce((all, one) => all + Math.max(1, one.views), 0);
1839
+ return {
1840
+ key,
1841
+ count: of.length,
1842
+ measured: read.length,
1843
+ views: total,
1844
+ average: read.length ? Math.round(total / read.length) : 0,
1845
+ ...watched.length ? { completion: watched.reduce((all, one) => all + (one.completion ?? 0) * Math.max(1, one.views), 0) / weight } : {}
1846
+ };
1847
+ };
1848
+ const known = new Set(settings.series.map((one) => one.id));
1849
+ const none = published.filter((one) => !one.series || !known.has(one.series));
1850
+ const platforms = [...new Set(measured.flatMap((one) => (one.stats ?? []).map((stat) => stat.platform)))].map((platform) => {
1851
+ const stats = measured.flatMap((one) => (one.stats ?? []).filter((stat) => stat.platform === platform));
1852
+ const total = stats.reduce((all, one) => all + one.views, 0);
1853
+ return { key: platform, count: stats.length, measured: stats.length, views: total, average: stats.length ? Math.round(total / stats.length) : 0 };
1854
+ });
1855
+ return {
1856
+ published: published.length,
1857
+ measured: measured.length,
1858
+ views: measured.reduce((all, one) => all + (CreatorUtil.views(one) ?? 0), 0),
1859
+ series: [
1860
+ ...settings.series.map((one) => group(one.id, published.filter((item) => item.series === one.id))),
1861
+ ...none.length ? [group("", none)] : []
1862
+ ],
1863
+ kinds: KINDS.map((kind) => group(kind, published.filter((one) => one.kind === kind))).filter((one) => one.count),
1864
+ forms: FORMS.map((form) => group(form, published.filter((one) => one.form === form))).filter((one) => one.count),
1865
+ platforms: platforms.sort((a, b) => b.views - a.views),
1866
+ top: measured.map((item) => ({ item, views: CreatorUtil.views(item) ?? 0 })).sort((a, b) => b.views - a.views).slice(0, 5)
1867
+ };
1868
+ }
1869
+ ChannelUtil.analysis = analysis;
1870
+ function insights(value) {
1871
+ const all = (Array.isArray(value) ? value : []).map((one) => object2(one)).filter((one) => !!one && !!text2(one.text, 300) && !!time2(one.at)).map((one) => {
1872
+ const at = time2(one.at);
1873
+ const words = text2(one.text, 300);
1874
+ return {
1875
+ id: text2(one.id, 60) || `i${hash(words + at)}`,
1876
+ text: words,
1877
+ tone: oneOf(["good", "bad", "idea"], one.tone, "idea"),
1878
+ ...text2(one.series, 60) ? { series: text2(one.series, 60) } : {},
1879
+ ...one.by === "user" ? { by: "user" } : {},
1880
+ ...one.state === "proposed" || one.state === "declined" ? { state: one.state } : {},
1881
+ at
1882
+ };
1883
+ }).sort((a, b) => b.at - a.at);
1884
+ const mine = all.filter((one) => one.by === "user");
1885
+ const ta = all.filter((one) => one.by !== "user").slice(0, 30);
1886
+ return [...mine, ...ta].sort((a, b) => b.at - a.at);
1887
+ }
1888
+ ChannelUtil.insights = insights;
1889
+ function addInsights(kept, added, series, now, mode = "auto") {
1890
+ const read = added.map((one) => typeof one === "string" ? { text: one } : object2(one)).filter((one) => !!one).map((one, at) => ({
1891
+ ...one,
1892
+ id: `i${now.toString(36)}${at}`,
1893
+ by: undefined,
1894
+ series: CreatorUtil.seriesNamed(series, one.series)?.id,
1895
+ ...mode === "manual" ? { state: "proposed" } : { state: undefined },
1896
+ at: now
1897
+ }));
1898
+ return insights([...read, ...kept.filter((one) => one.state !== "proposed")]);
1899
+ }
1900
+ ChannelUtil.addInsights = addInsights;
1901
+ function addRule(kept, words, series, now, seriesId) {
1902
+ const rule = text2(words, 300);
1903
+ if (!rule) {
1904
+ throw new Error("A rule needs its words.");
1905
+ }
1906
+ return insights([
1907
+ { id: `u${now.toString(36)}`, text: rule, tone: "idea", by: "user", series: CreatorUtil.seriesNamed(series, seriesId)?.id, at: now },
1908
+ ...kept
1909
+ ]);
1910
+ }
1911
+ ChannelUtil.addRule = addRule;
1912
+ function decideRule(kept, id, action) {
1913
+ const rule = kept.find((one) => one.id === id);
1914
+ if (!rule) {
1915
+ throw new Error(`No such rule: ${id}.`);
1916
+ }
1917
+ const changed = (patch) => insights(kept.map((one) => one.id === id ? { ...one, ...patch, state: patch.state } : one));
1918
+ switch (action) {
1919
+ case "take":
1920
+ return changed({ state: undefined });
1921
+ case "decline":
1922
+ case "remove":
1923
+ return rule.by === "user" ? insights(kept.filter((one) => one.id !== id)) : changed({ state: "declined" });
1924
+ case "keep":
1925
+ return changed({ by: "user", state: undefined });
1926
+ default:
1927
+ throw new Error(`An answer to a rule is take, decline, keep or remove: ${action}.`);
1928
+ }
1929
+ }
1930
+ ChannelUtil.decideRule = decideRule;
1931
+ function latestInsights(insights2) {
1932
+ const ta = insights2.filter((one) => one.by !== "user" && !one.state);
1933
+ const newest = ta[0]?.at ?? 0;
1934
+ return insights2.filter((one) => one.by === "user" || !one.state && newest - one.at < DAY2);
1935
+ }
1936
+ ChannelUtil.latestInsights = latestInsights;
1937
+ function proposed(insights2) {
1938
+ return insights2.filter((one) => one.state === "proposed");
1939
+ }
1940
+ ChannelUtil.proposed = proposed;
1941
+ function phases(value) {
1942
+ return (Array.isArray(value) ? value : []).map((one) => object2(one)).filter((one) => !!one && !!time2(one.from) && !!time2(one.to) && !!text2(one.summary, 2000) && !!time2(one.at)).map((one) => ({
1943
+ from: time2(one.from),
1944
+ to: time2(one.to),
1945
+ summary: text2(one.summary, 2000),
1946
+ ...text2(one.topic, 80) ? { topic: text2(one.topic, 80) } : {},
1947
+ at: time2(one.at)
1948
+ })).sort((a, b) => b.at - a.at).slice(0, 24);
1949
+ }
1950
+ ChannelUtil.phases = phases;
1951
+ function phaseDue(settings, items, phases2, now) {
1952
+ if (!settings.phaseWeeks) {
1953
+ return;
1954
+ }
1955
+ const published = items.filter((one) => one.stage === "published" && !one.dropped).map(CreatorUtil.publishedAt);
1956
+ const from = phases2[0]?.to ?? (published.length ? Math.min(...published) : undefined);
1957
+ if (from === undefined || now - from < settings.phaseWeeks * 7 * DAY2 || !published.some((at) => at >= from)) {
1958
+ return;
1959
+ }
1960
+ return { from, to: now };
1961
+ }
1962
+ ChannelUtil.phaseDue = phaseDue;
1963
+ function needsOf(values, now) {
1964
+ return values.map((one, at) => CreatorUtil.need(typeof one === "string" ? { text: one } : { id: `n${now.toString(36)}${at}`, ...object2(one) ?? {} })).filter((one) => !!one).map((one, at) => one.id ? one : { ...one, id: `n${now.toString(36)}${at}` }).slice(0, 12);
1965
+ }
1966
+ ChannelUtil.needsOf = needsOf;
1967
+ function given(item) {
1968
+ return (item.needs ?? []).every((one) => one.done);
1969
+ }
1970
+ ChannelUtil.given = given;
1971
+ ChannelUtil.PACE = { start: 6 * HOUR, first: 12 * HOUR, min: HOUR, max: 2 * DAY2, many: 3 };
1972
+ function nextGap(gap, added) {
1973
+ if (added >= ChannelUtil.PACE.many) {
1974
+ return Math.max(ChannelUtil.PACE.min, Math.round(gap / 2));
1975
+ }
1976
+ return added ? gap : Math.min(ChannelUtil.PACE.max, gap * 2);
1977
+ }
1978
+ ChannelUtil.nextGap = nextGap;
1979
+ function firstGap(items) {
1980
+ const gaps = items.filter((one) => one.commentsGap).sort((a, b) => (b.commentsAt ?? 0) - (a.commentsAt ?? 0)).slice(0, 5).map((one) => one.commentsGap).sort((a, b) => a - b);
1981
+ return gaps.length ? Math.max(ChannelUtil.PACE.min, Math.min(ChannelUtil.PACE.first, gaps[Math.floor(gaps.length / 2)])) : ChannelUtil.PACE.start;
1982
+ }
1983
+ ChannelUtil.firstGap = firstGap;
1984
+ function commentsGap(item, items, settings) {
1985
+ return settings.commentsEvery ? settings.commentsEvery * HOUR : item.commentsGap ?? firstGap(items);
1986
+ }
1987
+ ChannelUtil.commentsGap = commentsGap;
1988
+ function comments(value, now = Date.now()) {
1989
+ 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);
1990
+ }
1991
+ ChannelUtil.comments = comments;
1992
+ function addComments(kept, item, input, levels, now, id) {
1993
+ const all = [...kept];
1994
+ const added = [];
1995
+ for (const value of input) {
1996
+ const read = object2(value);
1997
+ const platform = text2(read?.platform, 60);
1998
+ const words = text2(read?.text, 1000);
1999
+ if (!read || !platform || !words) {
2000
+ continue;
2001
+ }
2002
+ const key = text2(read.key, 120) || `t${hash(words)}`;
2003
+ const cls = oneOf(COMMENT_CLASSES, read.class, "question");
2004
+ const level = REPLY_CLASSES.includes(cls) ? levels[cls] : "off";
2005
+ const answer = text2(read.reply, 500);
2006
+ const reply = answer && level !== "off" ? level === "act" && read.sent === true ? { text: answer, state: "sent", auto: true, at: now } : { text: answer, state: "draft", at: now } : undefined;
2007
+ const at = all.findIndex((one) => one.item === item && one.platform === platform && one.key === key);
2008
+ if (at >= 0) {
2009
+ const before = all[at];
2010
+ const open = !before.reply || before.reply.state === "draft";
2011
+ all[at] = {
2012
+ ...before,
2013
+ ...typeof read.likes === "number" ? { likes: count(read.likes, 0) } : {},
2014
+ ...open && reply ? { reply } : {}
2015
+ };
2016
+ continue;
2017
+ }
2018
+ const made = {
2019
+ id: id(),
2020
+ item,
2021
+ platform,
2022
+ key,
2023
+ text: words,
2024
+ class: cls,
2025
+ ...typeof read.likes === "number" ? { likes: count(read.likes, 0) } : {},
2026
+ ...reply ? { reply } : {},
2027
+ at: now
2028
+ };
2029
+ all.push(made);
2030
+ added.push(made);
2031
+ }
2032
+ return { comments: comments(all, now), added };
2033
+ }
2034
+ ChannelUtil.addComments = addComments;
2035
+ function examples(comments2, max = 8) {
2036
+ return comments2.filter((one) => one.reply?.draft && (one.reply.state === "approved" || one.reply.state === "sent")).sort((a, b) => (b.reply?.at ?? 0) - (a.reply?.at ?? 0)).slice(0, max).map((one) => ({ comment: one.text, draft: one.reply?.draft ?? "", sent: one.reply?.text ?? "" }));
2037
+ }
2038
+ ChannelUtil.examples = examples;
2039
+ function lessons(value) {
2040
+ return (Array.isArray(value) ? value : []).map((one) => object2(one)).filter((one) => !!one && !!text2(one.text, 300) && !!time2(one.at)).map((one) => ({ text: text2(one.text, 300), item: text2(one.item, 80), at: time2(one.at) })).sort((a, b) => b.at - a.at).slice(0, MAX_LESSONS);
2041
+ }
2042
+ ChannelUtil.lessons = lessons;
2043
+ function comment(value) {
2044
+ const kept = object2(value);
2045
+ const id = text2(kept?.id, 80);
2046
+ const words = text2(kept?.text, 1000);
2047
+ const at = time2(kept?.at);
2048
+ if (!kept || !id || !words || !at || !text2(kept.item, 80) || !text2(kept.platform, 60)) {
2049
+ return;
2050
+ }
2051
+ const reply = object2(kept.reply);
2052
+ const answer = text2(reply?.text, 500);
2053
+ const draft = text2(reply?.draft, 500);
2054
+ return {
2055
+ id,
2056
+ item: text2(kept.item, 80),
2057
+ platform: text2(kept.platform, 60),
2058
+ key: text2(kept.key, 120) || `t${hash(words)}`,
2059
+ text: words,
2060
+ class: oneOf(COMMENT_CLASSES, kept.class, "question"),
2061
+ ...typeof kept.likes === "number" ? { likes: count(kept.likes, 0) } : {},
2062
+ ...reply && answer ? {
2063
+ reply: {
2064
+ text: answer,
2065
+ state: oneOf(REPLY_STATES, reply.state, "draft"),
2066
+ ...reply.auto === true ? { auto: true } : {},
2067
+ ...draft ? { draft } : {},
2068
+ at: time2(reply.at) ?? at
2069
+ }
2070
+ } : {},
2071
+ ...text2(kept.topic, 80) ? { topic: text2(kept.topic, 80) } : {},
2072
+ at
2073
+ };
2074
+ }
2075
+ })(ChannelUtil ||= {});
2076
+
1317
2077
  // web-src/creator-store.ts
1318
- var KEYS = [Keys.SETTINGS, Keys.ITEMS, Keys.WEEKS, Keys.INSIGHTS];
2078
+ var KEYS = [Keys.SETTINGS, Keys.ITEMS, Keys.WEEKS, Keys.INSIGHTS, Keys.COMMENTS, Keys.PHASES];
1319
2079
 
1320
2080
  class CreatorStore {
1321
2081
  pi;
1322
- current = { loaded: false, settings: CreatorUtil.settings(undefined), items: [], weeks: [], insights: [] };
2082
+ current = { loaded: false, settings: CreatorUtil.settings(undefined), items: [], weeks: [], insights: [], comments: [], phases: [] };
1323
2083
  listeners = new Set;
1324
2084
  constructor(pi) {
1325
2085
  this.pi = pi;
@@ -1340,13 +2100,15 @@ class CreatorStore {
1340
2100
  return this.pi.callHost(method, ...params);
1341
2101
  }
1342
2102
  read() {
1343
- Promise.all(KEYS.map((key) => this.pi.storage.get(key))).then(([settings, items, weeks, insights]) => {
2103
+ Promise.all(KEYS.map((key) => this.pi.storage.get(key))).then(([settings, items, weeks, insights, comments, phases]) => {
1344
2104
  const next = {
1345
2105
  loaded: true,
1346
2106
  settings: CreatorUtil.settings(settings),
1347
2107
  items: CreatorUtil.items(items),
1348
2108
  weeks: CreatorUtil.weeks(weeks),
1349
- insights: CreatorUtil.insights(insights)
2109
+ insights: ChannelUtil.insights(insights),
2110
+ comments: ChannelUtil.comments(comments),
2111
+ phases: ChannelUtil.phases(phases)
1350
2112
  };
1351
2113
  if (!this.current.loaded || JSON.stringify(next) !== JSON.stringify(this.current)) {
1352
2114
  this.set(next);
@@ -1361,6 +2123,161 @@ class CreatorStore {
1361
2123
  }
1362
2124
  }
1363
2125
 
2126
+ // web-src/strategy.tsx
2127
+ var PHASE_WEEKS = [2, 4, 8, 0];
2128
+ function Strategy({ context }) {
2129
+ const { pi, store } = context;
2130
+ const state = useStore(store);
2131
+ const words = useWords(pi);
2132
+ const [rule, setRule] = React.useState("");
2133
+ const mode = state.settings.strategy;
2134
+ const rules = ChannelUtil.latestInsights(state.insights);
2135
+ const proposed = ChannelUtil.proposed(state.insights);
2136
+ const { TrendingUp, TrendingDown, Lightbulb, User } = pi.ui.icons;
2137
+ const tones = { good: TrendingUp, bad: TrendingDown, idea: Lightbulb };
2138
+ const icon = (one) => one.by === "user" ? User : tones[one.tone];
2139
+ const add = async () => {
2140
+ await store.call("addRule", rule);
2141
+ setRule("");
2142
+ };
2143
+ return /* @__PURE__ */ React.createElement("div", {
2144
+ className: "tcre-card tcre-panel tcre-insights"
2145
+ }, /* @__PURE__ */ React.createElement("div", {
2146
+ className: "tcre-panel-title"
2147
+ }, words.strategy, /* @__PURE__ */ React.createElement("div", {
2148
+ className: "ta-segmented tcre-seg"
2149
+ }, ["auto", "manual"].map((one) => /* @__PURE__ */ React.createElement(BusyButton, {
2150
+ key: one,
2151
+ pi,
2152
+ pressed: mode === one,
2153
+ className: mode === one ? "ta-on" : "",
2154
+ onClick: () => store.call("setSettings", { strategy: one })
2155
+ }, one === "auto" ? words.strategyAuto : words.strategyManual))), /* @__PURE__ */ React.createElement("span", {
2156
+ className: "tcre-grow"
2157
+ }), /* @__PURE__ */ React.createElement(BusyButton, {
2158
+ pi,
2159
+ className: "tcre-secondary tcre-small",
2160
+ onClick: () => talk(pi, words.reviewNow, words.reviewPrompt)
2161
+ }, words.reviewNow)), /* @__PURE__ */ React.createElement("div", {
2162
+ className: "tcre-muted tcre-strategy-hint"
2163
+ }, mode === "auto" ? words.strategyAutoHint : words.strategyManualHint), proposed.map((one) => /* @__PURE__ */ React.createElement(Rule, {
2164
+ key: one.id,
2165
+ context,
2166
+ rule: one,
2167
+ Icon: tones[one.tone],
2168
+ proposed: true
2169
+ }, /* @__PURE__ */ React.createElement(BusyButton, {
2170
+ pi,
2171
+ className: "tcre-text tcre-small",
2172
+ onClick: () => store.call("rule", one.id, "decline")
2173
+ }, words.decline), /* @__PURE__ */ React.createElement(BusyButton, {
2174
+ pi,
2175
+ className: "tcre-secondary tcre-small",
2176
+ onClick: () => store.call("rule", one.id, "take")
2177
+ }, words.take))), rules.map((one) => /* @__PURE__ */ React.createElement(Rule, {
2178
+ key: one.id,
2179
+ context,
2180
+ rule: one,
2181
+ Icon: icon(one)
2182
+ }, one.by !== "user" && /* @__PURE__ */ React.createElement(IconButton, {
2183
+ pi,
2184
+ icon: "Pin",
2185
+ label: words.keepRule,
2186
+ onClick: () => store.call("rule", one.id, "keep")
2187
+ }), /* @__PURE__ */ React.createElement(IconButton, {
2188
+ pi,
2189
+ icon: "X",
2190
+ label: words.remove,
2191
+ onClick: () => store.call("rule", one.id, "remove")
2192
+ }))), !rules.length && !proposed.length && /* @__PURE__ */ React.createElement("div", {
2193
+ className: "tcre-muted tcre-pad"
2194
+ }, words.noInsights), /* @__PURE__ */ React.createElement("div", {
2195
+ className: "tcre-rule-add"
2196
+ }, /* @__PURE__ */ React.createElement("input", {
2197
+ className: "tcre-field",
2198
+ value: rule,
2199
+ placeholder: words.ruleHint,
2200
+ onChange: (event) => setRule(event.target.value),
2201
+ onKeyDown: (event) => {
2202
+ if (event.key === "Enter" && rule.trim() && !event.nativeEvent.isComposing) {
2203
+ add();
2204
+ }
2205
+ }
2206
+ }), /* @__PURE__ */ React.createElement(BusyButton, {
2207
+ pi,
2208
+ className: "tcre-secondary tcre-small",
2209
+ disabled: !rule.trim(),
2210
+ onClick: add
2211
+ }, words.addRule)));
2212
+ }
2213
+ function Rule({
2214
+ context,
2215
+ rule,
2216
+ Icon,
2217
+ proposed,
2218
+ children
2219
+ }) {
2220
+ const words = useWords(context.pi);
2221
+ const series = seriesOf(context, rule.series);
2222
+ return /* @__PURE__ */ React.createElement("div", {
2223
+ className: "tcre-insight",
2224
+ "data-tone": rule.by === "user" ? "user" : rule.tone,
2225
+ "data-proposed": proposed || undefined
2226
+ }, /* @__PURE__ */ React.createElement("span", {
2227
+ className: "tcre-insight-icon"
2228
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
2229
+ size: 14
2230
+ })), /* @__PURE__ */ React.createElement("span", {
2231
+ className: "tcre-insight-text"
2232
+ }, proposed && /* @__PURE__ */ React.createElement("span", {
2233
+ className: "tcre-chip"
2234
+ }, words.proposedRules), rule.by === "user" && /* @__PURE__ */ React.createElement("span", {
2235
+ className: "tcre-chip"
2236
+ }, words.ruleMine), series && /* @__PURE__ */ React.createElement(SeriesTag, {
2237
+ series,
2238
+ words
2239
+ }), rule.text), /* @__PURE__ */ React.createElement("span", {
2240
+ className: "tcre-rule-actions"
2241
+ }, children));
2242
+ }
2243
+ function Phases({ context }) {
2244
+ const { pi, store } = context;
2245
+ const state = useStore(store);
2246
+ const words = useWords(pi);
2247
+ const every = state.settings.phaseWeeks;
2248
+ const day = (at) => new Date(at).toLocaleDateString(pi.ui.language, { month: "numeric", day: "numeric" });
2249
+ return /* @__PURE__ */ React.createElement("div", {
2250
+ className: "tcre-card tcre-panel tcre-wide"
2251
+ }, /* @__PURE__ */ React.createElement("div", {
2252
+ className: "tcre-panel-title"
2253
+ }, words.phases, /* @__PURE__ */ React.createElement("div", {
2254
+ className: "ta-segmented tcre-seg"
2255
+ }, PHASE_WEEKS.map((n) => /* @__PURE__ */ React.createElement(BusyButton, {
2256
+ key: n,
2257
+ pi,
2258
+ pressed: every === n,
2259
+ className: every === n ? "ta-on" : "",
2260
+ onClick: () => store.call("setSettings", { phaseWeeks: n })
2261
+ }, n ? format(words.phaseEvery, { n }) : words.phaseOff))), /* @__PURE__ */ React.createElement("span", {
2262
+ className: "tcre-grow"
2263
+ }), /* @__PURE__ */ React.createElement(BusyButton, {
2264
+ pi,
2265
+ className: "tcre-secondary tcre-small",
2266
+ onClick: () => talk(pi, words.phaseNow, words.phasePrompt)
2267
+ }, words.phaseNow)), state.phases.length ? state.phases.slice(0, 6).map((one) => /* @__PURE__ */ React.createElement("div", {
2268
+ key: one.at,
2269
+ className: "tcre-phase"
2270
+ }, /* @__PURE__ */ React.createElement("span", {
2271
+ className: "tcre-phase-when"
2272
+ }, day(one.from), " – ", day(one.to)), /* @__PURE__ */ React.createElement("span", {
2273
+ className: "tcre-phase-text"
2274
+ }, one.summary), one.topic && /* @__PURE__ */ React.createElement("span", {
2275
+ className: "tcre-chip"
2276
+ }, words.ledTo))) : /* @__PURE__ */ React.createElement("div", {
2277
+ className: "tcre-muted tcre-pad"
2278
+ }, words.noPhases));
2279
+ }
2280
+
1364
2281
  // web-src/numbers.tsx
1365
2282
  function GroupBars({
1366
2283
  context,
@@ -1432,12 +2349,9 @@ function Numbers({ context }) {
1432
2349
  const before = weeks[weeks.length - 2];
1433
2350
  const sum = (week, key) => (week?.platforms ?? []).reduce((all, one) => all + (one[key] ?? 0), 0);
1434
2351
  const delta = (a, b) => b > 0 ? `${a >= b ? "+" : ""}${Math.round((a - b) / b * 100)}%` : "";
1435
- const analysis = CreatorUtil.analysis(state.items, state.settings);
2352
+ const analysis = ChannelUtil.analysis(state.items, state.settings);
1436
2353
  const progress = CreatorUtil.progress(state.items, state.settings.goal, now);
1437
2354
  const goal = state.settings.goal;
1438
- const insights = CreatorUtil.latestInsights(state.insights);
1439
- const { TrendingUp, TrendingDown, Lightbulb } = pi.ui.icons;
1440
- const tones = { good: TrendingUp, bad: TrendingDown, idea: Lightbulb };
1441
2355
  const stats = [
1442
2356
  [words.publishedCount, String(analysis.published)],
1443
2357
  [words.totalViews, analysis.measured ? short(analysis.views, pi.ui.language) : "—"],
@@ -1459,36 +2373,9 @@ function Numbers({ context }) {
1459
2373
  "data-none": value === "—" || undefined
1460
2374
  }, /* @__PURE__ */ React.createElement("b", null, value, change && /* @__PURE__ */ React.createElement("em", {
1461
2375
  "data-down": change.startsWith("-") || undefined
1462
- }, change)), /* @__PURE__ */ React.createElement("span", null, label)))), /* @__PURE__ */ React.createElement("div", {
1463
- className: "tcre-card tcre-panel tcre-insights"
1464
- }, /* @__PURE__ */ React.createElement("div", {
1465
- className: "tcre-panel-title"
1466
- }, words.insights, /* @__PURE__ */ React.createElement("span", {
1467
- className: "tcre-muted"
1468
- }, words.insightsHint), /* @__PURE__ */ React.createElement("span", {
1469
- className: "tcre-grow"
1470
- }), /* @__PURE__ */ React.createElement(BusyButton, {
1471
- pi,
1472
- className: "tcre-secondary tcre-small",
1473
- onClick: () => talk(pi, words.reviewNow, words.reviewPrompt)
1474
- }, words.reviewNow)), insights.length ? insights.map((one) => {
1475
- const Icon = tones[one.tone];
1476
- const series = seriesOf(context, one.series);
1477
- return /* @__PURE__ */ React.createElement("div", {
1478
- key: one.at + one.text,
1479
- className: "tcre-insight",
1480
- "data-tone": one.tone
1481
- }, /* @__PURE__ */ React.createElement("span", {
1482
- className: "tcre-insight-icon"
1483
- }, Icon && /* @__PURE__ */ React.createElement(Icon, {
1484
- size: 14
1485
- })), /* @__PURE__ */ React.createElement("span", null, series && /* @__PURE__ */ React.createElement(SeriesTag, {
1486
- series,
1487
- words
1488
- }), one.text));
1489
- }) : /* @__PURE__ */ React.createElement("div", {
1490
- className: "tcre-muted tcre-pad"
1491
- }, words.noInsights)), seriesGroups.length > 0 && /* @__PURE__ */ React.createElement(GroupBars, {
2376
+ }, change)), /* @__PURE__ */ React.createElement("span", null, label)))), /* @__PURE__ */ React.createElement(Strategy, {
2377
+ context
2378
+ }), seriesGroups.length > 0 && /* @__PURE__ */ React.createElement(GroupBars, {
1492
2379
  context,
1493
2380
  label: words.bySeries,
1494
2381
  groups: seriesGroups,
@@ -1524,7 +2411,9 @@ function Numbers({ context }) {
1524
2411
  words
1525
2412
  }), /* @__PURE__ */ React.createElement("span", {
1526
2413
  className: "tcre-bar-value"
1527
- }, short(views, pi.ui.language))))), goal && progress && /* @__PURE__ */ React.createElement("div", {
2414
+ }, short(views, pi.ui.language))))), /* @__PURE__ */ React.createElement(Phases, {
2415
+ context
2416
+ }), goal && progress && /* @__PURE__ */ React.createElement("div", {
1528
2417
  className: "tcre-card tcre-panel tcre-goal"
1529
2418
  }, /* @__PURE__ */ React.createElement("div", {
1530
2419
  className: "tcre-panel-title"
@@ -1558,11 +2447,14 @@ function Setup({ context, done }) {
1558
2447
  const [niche, setNiche] = React.useState(state.settings.niche);
1559
2448
  const [picked, setPicked] = React.useState(state.settings.picked);
1560
2449
  const [series, setSeries] = React.useState(state.settings.series);
2450
+ const [platforms, setPlatforms] = React.useState(state.settings.platforms);
2451
+ const [inside, setInside] = React.useState({ name: "", url: "" });
1561
2452
  const { Trash2, Plus } = pi.ui.icons;
1562
2453
  const first = !state.settings.picked.length;
1563
2454
  const save = (goal) => store.call("setSettings", {
1564
2455
  niche: niche.trim(),
1565
2456
  picked,
2457
+ platforms,
1566
2458
  series: series.map((one) => ({ ...one, name: one.name.trim(), about: one.about?.trim() })).filter((one) => one.name),
1567
2459
  ...goal ? { goal: { from: Date.now(), days: 30, videos: 8, posts: 12 } } : {}
1568
2460
  }).then(done);
@@ -1604,6 +2496,11 @@ function Setup({ context, done }) {
1604
2496
  "aria-pressed": !!one.ordered,
1605
2497
  onClick: () => set(at, { ordered: !one.ordered })
1606
2498
  }, words.seriesOrdered), /* @__PURE__ */ React.createElement("button", {
2499
+ type: "button",
2500
+ className: "tcre-toggle",
2501
+ "aria-pressed": one.reach === "internal",
2502
+ onClick: () => set(at, { reach: one.reach === "internal" ? undefined : "internal" })
2503
+ }, words.seriesInside), /* @__PURE__ */ React.createElement("button", {
1607
2504
  type: "button",
1608
2505
  className: "tcre-icon",
1609
2506
  "aria-label": words.remove,
@@ -1621,7 +2518,7 @@ function Setup({ context, done }) {
1621
2518
  className: "tcre-setup-label"
1622
2519
  }, words.platformsLabel), /* @__PURE__ */ React.createElement("div", {
1623
2520
  className: "tcre-pick"
1624
- }, state.settings.platforms.map((platform) => {
2521
+ }, platforms.filter((platform) => !platform.internal).map((platform) => {
1625
2522
  const on = picked.includes(platform.id);
1626
2523
  return /* @__PURE__ */ React.createElement("button", {
1627
2524
  key: platform.id,
@@ -1632,6 +2529,58 @@ function Setup({ context, done }) {
1632
2529
  platform
1633
2530
  }));
1634
2531
  })), /* @__PURE__ */ React.createElement("div", {
2532
+ className: "tcre-setup-label"
2533
+ }, words.insideLabel, /* @__PURE__ */ React.createElement("span", null, words.insideHint)), /* @__PURE__ */ React.createElement("div", {
2534
+ className: "tcre-pick"
2535
+ }, platforms.filter((platform) => platform.internal).map((platform) => {
2536
+ const on = picked.includes(platform.id);
2537
+ return /* @__PURE__ */ React.createElement("span", {
2538
+ key: platform.id,
2539
+ className: "tcre-inside"
2540
+ }, /* @__PURE__ */ React.createElement("button", {
2541
+ type: "button",
2542
+ "aria-pressed": on,
2543
+ onClick: () => setPicked(on ? picked.filter((id) => id !== platform.id) : [...picked, platform.id])
2544
+ }, /* @__PURE__ */ React.createElement(PlatformName, {
2545
+ platform
2546
+ })), /* @__PURE__ */ React.createElement("button", {
2547
+ type: "button",
2548
+ className: "tcre-icon",
2549
+ "aria-label": words.remove,
2550
+ title: words.remove,
2551
+ onClick: () => {
2552
+ setPlatforms(platforms.filter((one) => one.id !== platform.id));
2553
+ setPicked(picked.filter((id) => id !== platform.id));
2554
+ }
2555
+ }, /* @__PURE__ */ React.createElement(Trash2, {
2556
+ size: 14
2557
+ })));
2558
+ })), /* @__PURE__ */ React.createElement("div", {
2559
+ className: "tcre-inside-add"
2560
+ }, /* @__PURE__ */ React.createElement("input", {
2561
+ className: "tcre-field tcre-field-name",
2562
+ value: inside.name,
2563
+ placeholder: words.insideName,
2564
+ onChange: (event) => setInside({ ...inside, name: event.target.value })
2565
+ }), /* @__PURE__ */ React.createElement("input", {
2566
+ className: "tcre-field",
2567
+ value: inside.url,
2568
+ placeholder: words.insideUrl,
2569
+ onChange: (event) => setInside({ ...inside, url: event.target.value })
2570
+ }), /* @__PURE__ */ React.createElement("button", {
2571
+ type: "button",
2572
+ className: "tcre-secondary tcre-small",
2573
+ disabled: !inside.name.trim() || !/^https?:\/\/\S+$/i.test(inside.url.trim()),
2574
+ onClick: () => {
2575
+ const id = `in-${Date.now().toString(36)}`;
2576
+ setPlatforms([
2577
+ ...platforms,
2578
+ { id, name: inside.name.trim(), color: "#0052d9", article: {}, internal: true, publish: inside.url.trim() }
2579
+ ]);
2580
+ setPicked([...picked, id]);
2581
+ setInside({ name: "", url: "" });
2582
+ }
2583
+ }, words.addInside)), /* @__PURE__ */ React.createElement("div", {
1635
2584
  className: "tcre-buttons"
1636
2585
  }, !first && /* @__PURE__ */ React.createElement("button", {
1637
2586
  type: "button",
@@ -1652,9 +2601,233 @@ function Setup({ context, done }) {
1652
2601
  }, first ? words.start : words.save)));
1653
2602
  }
1654
2603
 
2604
+ // web-src/talk.tsx
2605
+ var DAY3 = 86400000;
2606
+ var LEVELS = ["act", "ask", "off"];
2607
+ var LEVEL_WORDS = { act: "levelAct", ask: "levelAsk", off: "levelOff" };
2608
+ var HOUR2 = 3600000;
2609
+ var PACE_HOURS = [0, 2, 6, 24];
2610
+ var PACE_DAYS = [7, 14, 30];
2611
+ function drafts(comments) {
2612
+ return comments.filter((one) => one.reply?.state === "draft").sort((a, b) => b.at - a.at);
2613
+ }
2614
+ function Talk({ context }) {
2615
+ const { pi, store } = context;
2616
+ const state = useStore(store);
2617
+ const words = useWords(pi);
2618
+ const now = Date.now();
2619
+ const waiting = drafts(state.comments);
2620
+ 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);
2621
+ 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);
2622
+ return /* @__PURE__ */ React.createElement("div", {
2623
+ className: "tcre-talk"
2624
+ }, !state.comments.length && /* @__PURE__ */ React.createElement("div", {
2625
+ className: "tcre-empty"
2626
+ }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2627
+ compact: true,
2628
+ title: words.noComments,
2629
+ hint: words.commentsHint
2630
+ })), waiting.length > 0 && /* @__PURE__ */ React.createElement("section", {
2631
+ className: "tcre-section"
2632
+ }, /* @__PURE__ */ React.createElement("div", {
2633
+ className: "tcre-h"
2634
+ }, /* @__PURE__ */ React.createElement("span", null, words.drafts)), /* @__PURE__ */ React.createElement("div", {
2635
+ className: "tcre-list"
2636
+ }, waiting.map((one) => /* @__PURE__ */ React.createElement(Draft, {
2637
+ key: one.id,
2638
+ context,
2639
+ comment: one
2640
+ })))), /* @__PURE__ */ React.createElement(Levels, {
2641
+ context
2642
+ }), /* @__PURE__ */ React.createElement(Pace, {
2643
+ context
2644
+ }), asked.length > 0 && /* @__PURE__ */ React.createElement("div", {
2645
+ className: "tcre-card tcre-panel"
2646
+ }, /* @__PURE__ */ React.createElement("div", {
2647
+ className: "tcre-panel-title"
2648
+ }, words.asked), asked.map((one) => /* @__PURE__ */ React.createElement("div", {
2649
+ key: one.id,
2650
+ className: "tcre-asked"
2651
+ }, /* @__PURE__ */ React.createElement("span", {
2652
+ className: "tcre-class",
2653
+ "data-class": one.class
2654
+ }, words[one.class]), /* @__PURE__ */ React.createElement("span", {
2655
+ className: "tcre-asked-text"
2656
+ }, one.text), one.topic ? /* @__PURE__ */ React.createElement("span", {
2657
+ className: "tcre-chip"
2658
+ }, words.ledTo) : one.likes ? /* @__PURE__ */ React.createElement("span", {
2659
+ className: "tcre-muted"
2660
+ }, "♥ ", one.likes) : null))), recent.length > 0 && /* @__PURE__ */ React.createElement("div", {
2661
+ className: "tcre-card tcre-panel"
2662
+ }, /* @__PURE__ */ React.createElement("div", {
2663
+ className: "tcre-panel-title"
2664
+ }, words.autoSent), recent.map((one) => /* @__PURE__ */ React.createElement(Answered, {
2665
+ key: one.id,
2666
+ context,
2667
+ comment: one
2668
+ }))));
2669
+ }
2670
+ function Meta({ context, comment }) {
2671
+ const state = useStore(context.store);
2672
+ const words = useWords(context.pi);
2673
+ const piece = state.items.find((one) => one.id === comment.item);
2674
+ return /* @__PURE__ */ React.createElement("div", {
2675
+ className: "tcre-comment-meta"
2676
+ }, /* @__PURE__ */ React.createElement("span", {
2677
+ className: "tcre-class",
2678
+ "data-class": comment.class
2679
+ }, words[comment.class]), /* @__PURE__ */ React.createElement(PlatformName, {
2680
+ platform: platformOf(context, comment.platform)
2681
+ }), piece && /* @__PURE__ */ React.createElement("span", {
2682
+ className: "tcre-comment-piece"
2683
+ }, piece.title));
2684
+ }
2685
+ function Draft({ context, comment }) {
2686
+ const { pi, store } = context;
2687
+ const words = useWords(pi);
2688
+ const [text3, setText] = React.useState(comment.reply?.text ?? "");
2689
+ return /* @__PURE__ */ React.createElement("div", {
2690
+ className: "tcre-card tcre-comment"
2691
+ }, /* @__PURE__ */ React.createElement(Meta, {
2692
+ context,
2693
+ comment
2694
+ }), /* @__PURE__ */ React.createElement("div", {
2695
+ className: "tcre-comment-text"
2696
+ }, comment.text), /* @__PURE__ */ React.createElement("textarea", {
2697
+ className: "tcre-input tcre-reply-input",
2698
+ rows: 2,
2699
+ value: text3,
2700
+ onChange: (event) => setText(event.target.value)
2701
+ }), /* @__PURE__ */ React.createElement("div", {
2702
+ className: "tcre-buttons"
2703
+ }, /* @__PURE__ */ React.createElement("span", {
2704
+ className: "tcre-grow"
2705
+ }), /* @__PURE__ */ React.createElement(BusyButton, {
2706
+ pi,
2707
+ className: "tcre-text",
2708
+ onClick: () => store.call("reply", comment.id, "drop")
2709
+ }, words.dropReply), /* @__PURE__ */ React.createElement(BusyButton, {
2710
+ pi,
2711
+ className: "tcre-primary tcre-small",
2712
+ disabled: !text3.trim(),
2713
+ onClick: () => store.call("reply", comment.id, "send", text3)
2714
+ }, words.send)));
2715
+ }
2716
+ function Answered({ context, comment }) {
2717
+ const { pi, store } = context;
2718
+ const words = useWords(pi);
2719
+ const reply = comment.reply;
2720
+ if (!reply) {
2721
+ return null;
2722
+ }
2723
+ const where = { approved: words.sending, sent: words.sent, withdrawn: words.withdrawn, removed: words.withdrawn, draft: "", dropped: "" }[reply.state];
2724
+ return /* @__PURE__ */ React.createElement("div", {
2725
+ className: "tcre-answered"
2726
+ }, /* @__PURE__ */ React.createElement(Meta, {
2727
+ context,
2728
+ comment
2729
+ }), /* @__PURE__ */ React.createElement("div", {
2730
+ className: "tcre-comment-text"
2731
+ }, comment.text), /* @__PURE__ */ React.createElement("div", {
2732
+ className: "tcre-answer"
2733
+ }, /* @__PURE__ */ React.createElement("span", null, reply.text), /* @__PURE__ */ React.createElement("span", {
2734
+ className: "tcre-grow"
2735
+ }), /* @__PURE__ */ React.createElement("span", {
2736
+ className: "tcre-muted"
2737
+ }, reply.auto ? `${words.autoTag} · ` : "", where), reply.state === "sent" && /* @__PURE__ */ React.createElement(BusyButton, {
2738
+ pi,
2739
+ className: "tcre-text",
2740
+ onClick: () => store.call("reply", comment.id, "withdraw")
2741
+ }, words.withdraw)));
2742
+ }
2743
+ function Pace({ context }) {
2744
+ const { pi, store } = context;
2745
+ const state = useStore(store);
2746
+ const words = useWords(pi);
2747
+ const { commentsEvery: every, commentsDays: days } = state.settings;
2748
+ const latest = state.items.filter((one) => one.stage === "published" && one.commentsGap).sort((a, b) => (b.commentsAt ?? 0) - (a.commentsAt ?? 0))[0];
2749
+ const now = latest?.commentsGap ? Math.max(1, Math.round(latest.commentsGap / HOUR2)) : undefined;
2750
+ const choice = (values, value, label, set) => /* @__PURE__ */ React.createElement("div", {
2751
+ className: "ta-segmented tcre-seg"
2752
+ }, values.map((n) => /* @__PURE__ */ React.createElement(BusyButton, {
2753
+ key: n,
2754
+ pi,
2755
+ pressed: value === n,
2756
+ className: value === n ? "ta-on" : "",
2757
+ onClick: () => store.call("setSettings", set(n))
2758
+ }, label(n))));
2759
+ return /* @__PURE__ */ React.createElement("div", {
2760
+ className: "tcre-card tcre-panel"
2761
+ }, /* @__PURE__ */ React.createElement("div", {
2762
+ className: "tcre-panel-title"
2763
+ }, words.commentsPace), /* @__PURE__ */ React.createElement("div", {
2764
+ className: "tcre-level-row"
2765
+ }, /* @__PURE__ */ React.createElement("span", null, words.paceHow), /* @__PURE__ */ React.createElement("span", {
2766
+ className: "tcre-grow"
2767
+ }), choice(PACE_HOURS, every, (n) => !n ? words.paceAuto : n === 24 ? words.paceDaily : format(words.paceHours, { n }), (n) => ({ commentsEvery: n }))), /* @__PURE__ */ React.createElement("div", {
2768
+ className: "tcre-level-row"
2769
+ }, /* @__PURE__ */ React.createElement("span", null, words.paceFor), /* @__PURE__ */ React.createElement("span", {
2770
+ className: "tcre-grow"
2771
+ }), choice(PACE_DAYS, days, (n) => format(words.paceDays, { n }), (n) => ({ commentsDays: n }))), /* @__PURE__ */ React.createElement("div", {
2772
+ className: "tcre-muted tcre-level-note"
2773
+ }, every ? words.paceFixedNote : now ? `${format(words.paceNow, { n: now })} · ${words.paceAutoNote}` : words.paceAutoNote));
2774
+ }
2775
+ function Levels({ context }) {
2776
+ const { pi, store } = context;
2777
+ const words = useWords(pi);
2778
+ const [levels, setLevels] = React.useState();
2779
+ React.useEffect(() => {
2780
+ let live = true;
2781
+ store.call("replyLevels").then((got) => live && setLevels(got), () => {
2782
+ return;
2783
+ });
2784
+ return () => {
2785
+ live = false;
2786
+ };
2787
+ }, [store]);
2788
+ if (!levels) {
2789
+ return null;
2790
+ }
2791
+ const set = (cls, level) => store.call("setReplyLevel", cls, level).then(setLevels);
2792
+ return /* @__PURE__ */ React.createElement("div", {
2793
+ className: "tcre-card tcre-panel"
2794
+ }, /* @__PURE__ */ React.createElement("div", {
2795
+ className: "tcre-panel-title"
2796
+ }, words.replyLevels), levels.map((one) => /* @__PURE__ */ React.createElement("div", {
2797
+ key: one.class,
2798
+ className: "tcre-level-row"
2799
+ }, /* @__PURE__ */ React.createElement("span", {
2800
+ className: "tcre-class",
2801
+ "data-class": one.class
2802
+ }, words[one.class]), /* @__PURE__ */ React.createElement("span", {
2803
+ className: "tcre-grow"
2804
+ }), one.locked && /* @__PURE__ */ React.createElement(BusyButton, {
2805
+ pi,
2806
+ className: "tcre-text tcre-small",
2807
+ onClick: () => set(one.class, null)
2808
+ }, words.levelAuto), /* @__PURE__ */ React.createElement("div", {
2809
+ className: "ta-segmented tcre-seg"
2810
+ }, LEVELS.map((level) => /* @__PURE__ */ React.createElement(BusyButton, {
2811
+ key: level,
2812
+ pi,
2813
+ pressed: one.level === level,
2814
+ className: one.level === level ? "ta-on" : "",
2815
+ onClick: () => set(one.class, level)
2816
+ }, words[LEVEL_WORDS[level]]))))), /* @__PURE__ */ React.createElement("div", {
2817
+ className: "tcre-muted tcre-level-note"
2818
+ }, words.levelLearn));
2819
+ }
2820
+
1655
2821
  // web-src/page.tsx
1656
- var COLUMNS = ["topic", "making", "review", "published", "data"];
1657
- var COLUMN_ICONS = { topic: "Lightbulb", making: "Film", review: "Eye", published: "Send", data: "ChartColumn" };
2822
+ var COLUMNS = ["topic", "making", "review", "published", "talk", "data"];
2823
+ var COLUMN_ICONS = {
2824
+ topic: "Lightbulb",
2825
+ making: "Film",
2826
+ review: "Eye",
2827
+ published: "Send",
2828
+ talk: "MessageCircle",
2829
+ data: "ChartColumn"
2830
+ };
1658
2831
  var FIRST = 6;
1659
2832
  function CreatorHead({ context }) {
1660
2833
  const state = useStore(context.store);
@@ -1693,7 +2866,7 @@ function CreatorPage({ context }) {
1693
2866
  const shown = column ?? (waiting ? "review" : "topic");
1694
2867
  const known = state.settings.series.some((one) => one.id === series);
1695
2868
  const of = (items) => known ? items.filter((one) => one.series === series) : items;
1696
- const columns = { topic: of(all.topic), making: of(all.making), review: of(all.review), published: of(all.published) };
2869
+ const columns = { topic: of(all.topic), making: of([...all.materials, ...all.making]), review: of(all.review), published: of(all.published) };
1697
2870
  const body = () => {
1698
2871
  switch (shown) {
1699
2872
  case "topic":
@@ -1717,6 +2890,10 @@ function CreatorPage({ context }) {
1717
2890
  context,
1718
2891
  items: columns.published
1719
2892
  });
2893
+ case "talk":
2894
+ return /* @__PURE__ */ React.createElement(Talk, {
2895
+ context
2896
+ });
1720
2897
  case "data":
1721
2898
  return /* @__PURE__ */ React.createElement(Numbers, {
1722
2899
  context
@@ -1746,9 +2923,9 @@ function CreatorPage({ context }) {
1746
2923
  columns,
1747
2924
  shown,
1748
2925
  pick: setColumn
1749
- }), shown !== "data" && /* @__PURE__ */ React.createElement(SeriesBar, {
2926
+ }), shown !== "data" && shown !== "talk" && /* @__PURE__ */ React.createElement(SeriesBar, {
1750
2927
  context,
1751
- counts: all[shown],
2928
+ counts: shown === "making" ? [...all.materials, ...all.making] : all[shown],
1752
2929
  picked: known ? series : "",
1753
2930
  pick: setSeries,
1754
2931
  add: () => setEditing(true)
@@ -1757,28 +2934,27 @@ function CreatorPage({ context }) {
1757
2934
  key: shown
1758
2935
  }, body()));
1759
2936
  }
1760
- function Flow({
1761
- context,
1762
- columns,
1763
- shown,
1764
- pick
1765
- }) {
2937
+ function Flow({ context, columns, shown, pick }) {
1766
2938
  const { pi } = context;
1767
2939
  const state = useStore(context.store);
1768
2940
  const words = useWords(pi);
1769
2941
  const now = Date.now();
1770
2942
  const waiting = columns.review.filter((one) => !one.approved).length;
1771
2943
  const thisWeek = columns.published.filter((one) => CreatorUtil.publishedAt(one) >= new Date(`${CreatorUtil.weekOf(now)}T00:00:00`).getTime()).length;
1772
- const step = columns.making[0] && stepOf(columns.making[0]);
2944
+ const materials = columns.making.filter((one) => one.stage === "materials").length;
2945
+ const making = columns.making.filter((one) => one.stage === "making");
2946
+ const step = making[0] && stepOf(making[0]);
2947
+ const answers = drafts(state.comments).length;
1773
2948
  const last = state.weeks.filter((one) => one.week < CreatorUtil.weekOf(now) && one.platforms.length).pop();
1774
2949
  const hint = {
1775
2950
  topic: state.settings.series.length ? format(words.flowSeries, { n: state.settings.series.length }) : words.findNow,
1776
- making: step ? `${words[step]} · ${columns.making[0].title}` : columns.making.length ? words.doneAll : words.flowNone,
2951
+ making: materials ? format(words.flowMaterials, { n: materials }) : step ? `${words[step]} · ${making[0].title}` : making.length ? words.doneAll : words.flowNone,
1777
2952
  review: waiting ? format(words.flowWaiting, { n: waiting }) : columns.review.length ? words.flowPassed : words.flowNone,
1778
2953
  published: format(words.flowWeek, { n: thisWeek }),
2954
+ talk: answers ? format(words.flowDrafts, { n: answers }) : format(words.flowComments, { n: state.comments.length }),
1779
2955
  data: last ? `${words.lastWeek} ${short(last.platforms.reduce((all, one) => all + one.views, 0), pi.ui.language)}` : words.flowMonday
1780
2956
  };
1781
- const count = (one) => one === "data" ? undefined : columns[one].length;
2957
+ const count2 = (one) => one === "data" ? undefined : one === "talk" ? answers || undefined : columns[one].length;
1782
2958
  const { ChevronRight } = pi.ui.icons;
1783
2959
  return /* @__PURE__ */ React.createElement("div", {
1784
2960
  className: "tcre-flow",
@@ -1789,8 +2965,8 @@ function Flow({
1789
2965
  key: one
1790
2966
  }, at > 0 && /* @__PURE__ */ React.createElement("span", {
1791
2967
  className: "tcre-flow-arrow",
1792
- "data-gap": one === "data" || undefined
1793
- }, one !== "data" && /* @__PURE__ */ React.createElement(ChevronRight, {
2968
+ "data-gap": one === "talk" || undefined
2969
+ }, one !== "talk" && one !== "data" && /* @__PURE__ */ React.createElement(ChevronRight, {
1794
2970
  size: 14
1795
2971
  })), /* @__PURE__ */ React.createElement("button", {
1796
2972
  type: "button",
@@ -1798,7 +2974,7 @@ function Flow({
1798
2974
  "aria-selected": one === shown,
1799
2975
  className: "tcre-flow-node",
1800
2976
  "data-stage": one,
1801
- "data-attn": one === "review" && waiting > 0 || undefined,
2977
+ "data-attn": one === "review" && waiting > 0 || one === "talk" && answers > 0 || undefined,
1802
2978
  onClick: () => pick(one)
1803
2979
  }, /* @__PURE__ */ React.createElement("span", {
1804
2980
  className: "tcre-flow-icon"
@@ -1808,7 +2984,7 @@ function Flow({
1808
2984
  className: "tcre-flow-text"
1809
2985
  }, /* @__PURE__ */ React.createElement("span", {
1810
2986
  className: "tcre-flow-name"
1811
- }, words[one], count(one) !== undefined && /* @__PURE__ */ React.createElement("b", null, count(one))), /* @__PURE__ */ React.createElement("span", {
2987
+ }, words[one], count2(one) !== undefined && /* @__PURE__ */ React.createElement("b", null, count2(one))), /* @__PURE__ */ React.createElement("span", {
1812
2988
  className: "tcre-flow-hint"
1813
2989
  }, hint[one]))));
1814
2990
  }));
@@ -1844,17 +3020,17 @@ function SeriesBar({ context, counts, picked, pick, add }) {
1844
3020
  size: 14
1845
3021
  })));
1846
3022
  }
1847
- function Empty({ pi, text: text2, hint, children }) {
3023
+ function Empty({ pi, text: text3, hint, children }) {
1848
3024
  return /* @__PURE__ */ React.createElement("div", {
1849
3025
  className: "tcre-empty"
1850
3026
  }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1851
3027
  compact: true,
1852
- title: text2,
3028
+ title: text3,
1853
3029
  hint
1854
3030
  }, children));
1855
3031
  }
1856
3032
  function kindLabel(item, words) {
1857
- return [words[item.form], words[item.kind]].join(" · ");
3033
+ return [words[item.form], words[item.kind], ...item.reach && item.reach !== "public" ? [words[item.reach]] : []].join(" · ");
1858
3034
  }
1859
3035
  function Removed({ context, stage }) {
1860
3036
  const { pi, store } = context;
@@ -1981,15 +3157,77 @@ function Topic({ context, item }) {
1981
3157
  onClick: () => make(context, item)
1982
3158
  }, words.make)));
1983
3159
  }
3160
+ function Waiting({ context, item }) {
3161
+ const { pi, store } = context;
3162
+ const words = useWords(pi);
3163
+ const { Check, Circle } = pi.ui.icons;
3164
+ const skip = async () => {
3165
+ await store.call("skip", item.id);
3166
+ await tell(context, item, format(words.skipPrompt, { id: item.id }));
3167
+ };
3168
+ return /* @__PURE__ */ React.createElement("div", {
3169
+ className: "tcre-card tcre-making tcre-waiting"
3170
+ }, /* @__PURE__ */ React.createElement("div", {
3171
+ className: "tcre-making-head"
3172
+ }, /* @__PURE__ */ React.createElement("div", {
3173
+ className: "tcre-making-main"
3174
+ }, /* @__PURE__ */ React.createElement(SeriesTag, {
3175
+ series: seriesOf(context, item.series),
3176
+ number: item.number,
3177
+ words
3178
+ }), /* @__PURE__ */ React.createElement("span", {
3179
+ className: "tcre-making-title"
3180
+ }, item.title)), /* @__PURE__ */ React.createElement(IconButton, {
3181
+ pi,
3182
+ icon: "Trash2",
3183
+ label: words.remove,
3184
+ onClick: () => remove(context, item)
3185
+ })), /* @__PURE__ */ React.createElement("ul", {
3186
+ className: "tcre-needs"
3187
+ }, (item.needs ?? []).map((need) => /* @__PURE__ */ React.createElement("li", {
3188
+ key: need.id,
3189
+ "data-done": need.done || undefined
3190
+ }, need.done ? /* @__PURE__ */ React.createElement(Check, {
3191
+ size: 14
3192
+ }) : /* @__PURE__ */ React.createElement(Circle, {
3193
+ size: 14
3194
+ }), need.text))), /* @__PURE__ */ React.createElement("div", {
3195
+ className: "tcre-buttons"
3196
+ }, /* @__PURE__ */ React.createElement("span", {
3197
+ className: "tcre-muted tcre-needs-hint"
3198
+ }, words.needsHint), /* @__PURE__ */ React.createElement("span", {
3199
+ className: "tcre-grow"
3200
+ }), /* @__PURE__ */ React.createElement(BusyButton, {
3201
+ pi,
3202
+ className: "tcre-text",
3203
+ onClick: skip
3204
+ }, words.skipNeeds), /* @__PURE__ */ React.createElement(BusyButton, {
3205
+ pi,
3206
+ className: "tcre-primary tcre-small",
3207
+ onClick: () => openPiece(context, item)
3208
+ }, words.giveNow)));
3209
+ }
1984
3210
  function Making({ context, items }) {
1985
3211
  const { pi } = context;
1986
3212
  const words = useWords(pi);
3213
+ const waiting = items.filter((one) => one.stage === "materials");
3214
+ const making = items.filter((one) => one.stage === "making");
1987
3215
  return /* @__PURE__ */ React.createElement(React.Fragment, null, !items.length && /* @__PURE__ */ React.createElement(Empty, {
1988
3216
  pi,
1989
3217
  text: words.makingEmpty
1990
- }), /* @__PURE__ */ React.createElement("div", {
3218
+ }), waiting.length > 0 && /* @__PURE__ */ React.createElement("section", {
3219
+ className: "tcre-section"
3220
+ }, /* @__PURE__ */ React.createElement("div", {
3221
+ className: "tcre-h"
3222
+ }, /* @__PURE__ */ React.createElement("span", null, words.needsTitle)), /* @__PURE__ */ React.createElement("div", {
1991
3223
  className: "tcre-list"
1992
- }, items.map((item) => {
3224
+ }, waiting.map((item) => /* @__PURE__ */ React.createElement(Waiting, {
3225
+ key: item.id,
3226
+ context,
3227
+ item
3228
+ })))), /* @__PURE__ */ React.createElement("div", {
3229
+ className: "tcre-list"
3230
+ }, making.map((item) => {
1993
3231
  const series = seriesOf(context, item.series);
1994
3232
  return /* @__PURE__ */ React.createElement("div", {
1995
3233
  key: item.id,
@@ -2022,6 +3260,9 @@ function Making({ context, items }) {
2022
3260
  })), /* @__PURE__ */ React.createElement(Removed, {
2023
3261
  context,
2024
3262
  stage: "making"
3263
+ }), /* @__PURE__ */ React.createElement(Removed, {
3264
+ context,
3265
+ stage: "materials"
2025
3266
  }));
2026
3267
  }
2027
3268
  function Reviews({ context, items }) {
@@ -2097,7 +3338,8 @@ var STYLE = `
2097
3338
  /* The page: the top (bar, stations, series), then the station picked with room to read. */
2098
3339
  .tcre-home { padding: 0 0 calc(32px + env(safe-area-inset-bottom)); }
2099
3340
  .tcre-top { padding: 10px 28px 0; }
2100
- .tcre-body { max-width: var(--ta-page-wide); margin: 0 auto; padding: 18px 28px 0; animation: tcre-in 180ms var(--ta-ease); }
3341
+ .tcre-body { box-sizing: border-box; max-width: calc(var(--ta-page-wide) + 56px); margin: 0 auto; padding: 18px 28px 0; animation: tcre-in 180ms var(--ta-ease); }
3342
+ .tcre-home[data-compact] .tcre-body { max-width: none; }
2101
3343
  .tcre-home[data-compact] .tcre-top { padding: 4px 14px 0; }
2102
3344
  .tcre-home[data-compact] .tcre-body { padding: 14px 14px 0; }
2103
3345
  @keyframes tcre-in { from { opacity: 0; transform: translateY(4px); } }
@@ -2239,7 +3481,10 @@ button.tcre-pill:hover { background: var(--ta-hover); }
2239
3481
  .tcre-buttons { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
2240
3482
  .tcre-review .tcre-buttons .tcre-secondary { flex: 1; }
2241
3483
  .tcre-review .tcre-buttons .tcre-primary { flex: 2; }
2242
- .tcre-approved { margin: 4px 2px 2px; padding: 9px 12px; border-radius: 10px; background: color-mix(in oklab, var(--tcre-ok) 10%, transparent); color: var(--tcre-ok); font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; }
3484
+ .tcre-approved { margin: 4px 2px 2px; padding: 9px 12px; border-radius: 10px; background: color-mix(in oklab, var(--tcre-ok) 10%, transparent); color: var(--tcre-ok); font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
3485
+ .tcre-approved[data-tone="warn"] { background: color-mix(in oklab, var(--ta-warning, #d97706) 12%, transparent); color: var(--ta-warning, #d97706); justify-content: space-between; }
3486
+ .tcre-approved[data-tone="warn"] > span { flex: 1; min-width: 0; }
3487
+ .tcre-slot { display: inline-flex; align-items: center; gap: 6px; color: var(--ta-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
2243
3488
 
2244
3489
  /* Published, a row each. */
2245
3490
  .tcre-rows { padding: 4px 16px; }
@@ -2273,6 +3518,61 @@ button.tcre-pill:hover { background: var(--ta-hover); }
2273
3518
  .tcre-panel { padding: 14px 16px 12px; }
2274
3519
  .tcre-panel-title { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 8px; font-size: calc(14px * var(--ta-font-scale)); font-weight: 600; }
2275
3520
  .tcre-insights, .tcre-wide { grid-column: 1 / -1; }
3521
+ .tcre-flow-node[data-stage='talk'] { --tcre-s: #14b8a6; }
3522
+ .tcre-flow-node[data-attn][data-stage='talk'] .tcre-flow-hint { color: #14b8a6; }
3523
+ .tcre-talk { display: flex; flex-direction: column; gap: 14px; max-width: var(--ta-page-wide); margin: 0 auto; }
3524
+ .tcre-comment { padding: 14px 16px 12px; }
3525
+ .tcre-comment-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
3526
+ .tcre-comment-piece { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3527
+ .tcre-comment-text { margin: 8px 0; font-size: calc(14px * var(--ta-font-scale)); line-height: 1.55; overflow-wrap: anywhere; }
3528
+ .tcre-reply-input { width: 100%; box-sizing: border-box; resize: vertical; background: var(--ta-side); box-shadow: inset 0 0 0 1px var(--tcre-line); }
3529
+ .tcre-class { flex: none; padding: 1px 7px; border-radius: 6px; font-size: calc(11.5px * var(--ta-font-scale)); font-weight: 600; color: var(--tcre-k, var(--ta-secondary)); background: color-mix(in oklab, var(--tcre-k, var(--ta-muted)) 14%, transparent); }
3530
+ .tcre-class[data-class='question'] { --tcre-k: #3b82f6; }
3531
+ .tcre-class[data-class='suggestion'] { --tcre-k: #a855f7; }
3532
+ .tcre-class[data-class='correction'] { --tcre-k: #f97316; }
3533
+ .tcre-class[data-class='praise'] { --tcre-k: #22c55e; }
3534
+ .tcre-asked { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-top: 1px solid var(--tcre-line); font-size: calc(13.5px * var(--ta-font-scale)); }
3535
+ .tcre-asked:first-of-type { border-top: 0; }
3536
+ .tcre-asked-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
3537
+ .tcre-answered { padding: 10px 0; border-top: 1px solid var(--tcre-line); }
3538
+ .tcre-answered:first-of-type { border-top: 0; }
3539
+ .tcre-answered .tcre-comment-text { margin: 6px 0 4px; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); }
3540
+ .tcre-answer { display: flex; align-items: baseline; gap: 10px; padding-left: 10px; border-left: 2px solid var(--tcre-line); font-size: calc(13.5px * var(--ta-font-scale)); }
3541
+ .tcre-answer > span:first-child { min-width: 0; overflow-wrap: anywhere; }
3542
+ .tcre-level-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--tcre-line); }
3543
+ .tcre-level-row:first-of-type { border-top: 0; }
3544
+ .tcre-level-note { margin-top: 6px; font-size: calc(12px * var(--ta-font-scale)); line-height: 1.5; }
3545
+ .tcre-seg { flex: none; font-size: calc(12px * var(--ta-font-scale)); }
3546
+ .tcre-panel-title .tcre-seg { margin-left: 10px; font-weight: 500; }
3547
+ .tcre-strategy-hint { margin: -2px 0 8px; font-size: calc(12px * var(--ta-font-scale)); }
3548
+ .tcre-insight-text { flex: 1; min-width: 0; }
3549
+ .tcre-insight-text .tcre-chip { margin-right: 6px; }
3550
+ .tcre-insight[data-proposed] { opacity: 0.85; }
3551
+ .tcre-insight[data-tone='user'] .tcre-insight-icon { color: #3b82f6; background: color-mix(in oklab, #3b82f6 15%, transparent); }
3552
+ .tcre-rule-actions { flex: none; display: flex; align-items: center; gap: 4px; }
3553
+ .tcre-rule-add { display: flex; gap: 8px; margin-top: 10px; }
3554
+ .tcre-rule-add .tcre-field { flex: 1; min-width: 0; }
3555
+ .tcre-phase { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid var(--tcre-line); font-size: calc(13.5px * var(--ta-font-scale)); }
3556
+ .tcre-phase:first-of-type { border-top: 0; }
3557
+ .tcre-phase-when { flex: none; color: var(--ta-muted); font-variant-numeric: tabular-nums; font-size: calc(12px * var(--ta-font-scale)); }
3558
+ .tcre-phase-text { flex: 1; min-width: 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
3559
+ .tcre-needs { list-style: none; margin: 10px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: calc(13.5px * var(--ta-font-scale)); }
3560
+ .tcre-needs li { display: flex; align-items: center; gap: 8px; }
3561
+ .tcre-needs li svg { flex: none; color: var(--ta-muted); }
3562
+ .tcre-needs li[data-done] { color: var(--ta-muted); text-decoration: line-through; }
3563
+ .tcre-needs li[data-done] svg { color: var(--tcre-ok); }
3564
+ .tcre-needs-hint { min-width: 0; font-size: calc(12px * var(--ta-font-scale)); }
3565
+ .tcre-home[data-compact] .tcre-needs-hint { display: none; }
3566
+ .tcre-reach { flex: none; padding: 1px 8px; border: 0; border-radius: 6px; font: inherit; font-size: calc(11.5px * var(--ta-font-scale)); font-weight: 600; color: var(--ta-secondary); background: color-mix(in oklab, var(--ta-text) 7%, transparent); cursor: pointer; }
3567
+ .tcre-reach [data-reach='internal'], .tcre-reach[data-reach='internal'] { color: #0052d9; }
3568
+ .tcre-reach [data-reach='both'], .tcre-reach[data-reach='both'] { color: #7c3aed; }
3569
+ .tcre-tab-form { margin-left: 4px; font-style: normal; color: var(--ta-muted); font-size: 0.9em; }
3570
+ .tcre-preview-words { box-sizing: border-box; width: 100%; height: 100%; padding: 18px 20px; overflow: hidden; color: #e7e7ea; font-size: calc(13px * var(--ta-font-scale)); line-height: 1.7; white-space: pre-wrap; text-align: left; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
3571
+ .tcre-notice { margin: 10px 2px 0; padding: 8px 10px; border-radius: 10px; color: var(--ta-warning, #d97706); background: color-mix(in oklab, var(--ta-warning, #d97706) 12%, transparent); font-size: calc(12.5px * var(--ta-font-scale)); }
3572
+ .tcre-inside { display: inline-flex; align-items: center; gap: 2px; }
3573
+ .tcre-inside-add { display: flex; gap: 8px; margin-top: 8px; }
3574
+ .tcre-inside-add .tcre-field { flex: 1; min-width: 0; }
3575
+ .tcre-inside-add .tcre-field-name { flex: 0 1 140px; }
2276
3576
  .tcre-insight { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: calc(13.5px * var(--ta-font-scale)); line-height: 1.55; }
2277
3577
  .tcre-insight + .tcre-insight { border-top: 1px solid var(--tcre-line); }
2278
3578
  .tcre-insight .tcre-series-tag { margin-right: 8px; }
@@ -2335,6 +3635,9 @@ button.tcre-pill:hover { background: var(--ta-hover); }
2335
3635
  .tcre-setup .tcre-buttons { margin-top: 26px; }
2336
3636
 
2337
3637
  @media (prefers-reduced-motion: reduce) { .tcre-body { animation: none; } .tcre-pipe li[data-state='now'] .tcre-pipe-dot, .tcre-pulse { animation: none; } }
3638
+ .tcre-pick .tcre-icon { height: 28px; width: 28px; padding: 0; background: transparent; box-shadow: none; }
3639
+ .tcre-rule-add .tcre-field, .tcre-inside-add .tcre-field { height: 32px; padding: 0 10px; border-radius: 9px; background: var(--ta-side); box-shadow: inset 0 0 0 1px var(--tcre-line); }
3640
+ .tcre-card .tcre-rule-add .tcre-field { background: transparent; }
2338
3641
  `;
2339
3642
  function injectStyle() {
2340
3643
  const element = document.createElement("style");
@@ -2366,7 +3669,8 @@ function activate(pi) {
2366
3669
  const words = CreatorWords.of(pi.ui.language);
2367
3670
  const columns = CreatorUtil.columns(store.state.items, Date.now());
2368
3671
  const waiting = columns.review.filter((one) => !one.approved).length;
2369
- const detail = waiting ? `${words.review} ${waiting}` : columns.topic[0] ? `${words.topic} · ${columns.topic[0].title}` : store.state.settings.niche || words.sub;
3672
+ const answers = drafts(store.state.comments).length;
3673
+ const detail = waiting ? `${words.review} ${waiting}` : answers ? CreatorWords.format(words.flowDrafts, { n: answers }) : columns.topic[0] ? `${words.topic} · ${columns.topic[0].title}` : store.state.settings.niche || words.sub;
2370
3674
  return [
2371
3675
  {
2372
3676
  id: "creator",
@@ -2374,7 +3678,7 @@ function activate(pi) {
2374
3678
  detail,
2375
3679
  icon: pi.ui.icons.Film,
2376
3680
  tint: "creator",
2377
- unseen: waiting > 0,
3681
+ unseen: waiting > 0 || answers > 0,
2378
3682
  place: "double",
2379
3683
  open: () => pi.ui.showView(PAGE)
2380
3684
  }