@blogmcp/sdk 0.10.0 → 0.11.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.
Files changed (53) hide show
  1. package/dist/community/channels.d.ts +3 -2
  2. package/dist/community/client.d.ts +129 -2
  3. package/dist/community/client.js +231 -161
  4. package/dist/community/forum.d.ts +82 -0
  5. package/dist/community/forum.js +96 -0
  6. package/dist/community/index.d.ts +14 -7
  7. package/dist/community/index.js +185 -121
  8. package/dist/community/links.d.ts +38 -0
  9. package/dist/community/links.js +98 -71
  10. package/dist/community/messages.cs.d.ts +160 -1
  11. package/dist/community/messages.cs.js +178 -1
  12. package/dist/community/messages.d.ts +19 -1
  13. package/dist/community/messages.en.d.ts +150 -1
  14. package/dist/community/messages.en.js +161 -1
  15. package/dist/community/messages.js +37 -28
  16. package/dist/community/outcome.d.ts +8 -3
  17. package/dist/community/outcome.js +64 -20
  18. package/dist/community/poll.d.ts +28 -4
  19. package/dist/community/poll.js +70 -47
  20. package/dist/community/realtime/index.d.ts +19 -3
  21. package/dist/community/realtime/index.js +175 -145
  22. package/dist/community/routes.d.ts +36 -1
  23. package/dist/community/routes.js +51 -21
  24. package/dist/community/server/bff.d.ts +25 -2
  25. package/dist/community/server/bff.js +135 -118
  26. package/dist/community/server/host-routes.d.ts +3 -0
  27. package/dist/community/server/host-routes.js +17 -0
  28. package/dist/community/server/index.d.ts +5 -1
  29. package/dist/community/shapes.d.ts +634 -7
  30. package/dist/community/shapes.js +92 -61
  31. package/dist/community/store.d.ts +15 -0
  32. package/dist/community/store.js +65 -61
  33. package/dist/community/topic.d.ts +173 -0
  34. package/dist/community/topic.js +225 -0
  35. package/package.json +3 -3
  36. package/src/community/channels.ts +3 -2
  37. package/src/community/client.ts +209 -5
  38. package/src/community/forum.ts +209 -0
  39. package/src/community/index.ts +146 -2
  40. package/src/community/links.ts +64 -4
  41. package/src/community/messages.cs.ts +179 -1
  42. package/src/community/messages.en.ts +162 -1
  43. package/src/community/messages.ts +25 -2
  44. package/src/community/outcome.ts +50 -1
  45. package/src/community/poll.ts +79 -17
  46. package/src/community/realtime/index.ts +124 -48
  47. package/src/community/routes.ts +42 -1
  48. package/src/community/server/bff.ts +89 -30
  49. package/src/community/server/host-routes.ts +20 -0
  50. package/src/community/server/index.ts +5 -1
  51. package/src/community/shapes.ts +662 -6
  52. package/src/community/store.ts +11 -5
  53. package/src/community/topic.ts +521 -0
@@ -1,4 +1,4 @@
1
- const i = (e, t) => typeof t == "string" && e.includes(t), f = Object.freeze(["visible", "held", "removed", "deleted"]), m = (e) => i(f, e), a = Object.freeze(["member", "staff", "system"]), u = (e) => i(a, e), _ = Object.freeze(["sign_in", "onboarding", "reconsent_rules", "art9_consent"]), T = (e) => i(_, e), d = Object.freeze(["restriction", "suspension", "ban"]), A = (e) => i(d, e), p = Object.freeze([
1
+ const t = (e, o) => typeof o == "string" && e.includes(o), f = Object.freeze(["visible", "held", "removed", "deleted"]), y = (e) => t(f, e), O = Object.freeze(["member", "staff", "system"]), l = (e) => t(O, e), u = Object.freeze(["sign_in", "onboarding", "reconsent_rules", "art9_consent"]), z = (e) => t(u, e), S = Object.freeze(["restriction", "suspension", "ban"]), I = (e) => t(S, e), E = Object.freeze([
2
2
  "decision",
3
3
  "appeal_resolved",
4
4
  "erasure_scheduled",
@@ -10,8 +10,12 @@ const i = (e, t) => typeof t == "string" && e.includes(t), f = Object.freeze(["v
10
10
  "reply",
11
11
  "mention",
12
12
  "module_push_reset",
13
- "age_limit_changed"
14
- ]), E = (e) => i(p, e), O = Object.freeze(["new", "member", "regular", "trusted"]), j = (e) => i(O, e), y = Object.freeze([
13
+ "age_limit_changed",
14
+ // M3 F3 (m3-contracts.md §4.3): a new visible message in a followed topic or article discussion; a new topic in a
15
+ // followed category (in-app and the digest, never push). Both switched by `notifyTopic`.
16
+ "topic_update",
17
+ "category_topic"
18
+ ]), C = (e) => t(E, e), d = Object.freeze(["new", "member", "regular", "trusted"]), N = (e) => t(d, e), a = Object.freeze([
15
19
  "fraud_spam",
16
20
  "harassment",
17
21
  "hate",
@@ -28,76 +32,103 @@ const i = (e, t) => typeof t == "string" && e.includes(t), f = Object.freeze(["v
28
32
  "adverse_event",
29
33
  "third_party_health_data",
30
34
  "suspected_minor"
31
- ]), g = (e) => i(y, e), h = "child_at_risk", R = Object.freeze(["16_17", "18_plus"]), z = Object.freeze(["rules", "terms", "privacy", "art9_consent"]);
32
- function N(e) {
33
- return typeof e == "object" && e !== null && u(e.kind);
35
+ ]), g = (e) => t(a, e), h = "child_at_risk", K = Object.freeze(
36
+ a.filter((e) => e !== "rules" && e !== "adverse_event" && e !== "third_party_health_data" && e !== "suspected_minor")
37
+ ), T = Object.freeze(["recorded", "reported_to_authority", "not_adverse"]), v = (e) => t(T, e), D = Object.freeze(["16_17", "18_plus"]), M = Object.freeze(["rules", "terms", "privacy", "art9_consent"]);
38
+ function w(e) {
39
+ return typeof e == "object" && e !== null && l(e.kind);
34
40
  }
35
- const b = Object.freeze(["dark", "live", "read_only", "braked"]), I = (e) => i(b, e), K = Object.freeze(["joint", "split"]), C = Object.freeze(["read_only", "public_write"]), L = (e) => e === "split" ? "split" : "joint", w = (e) => e === "public_write" ? "public_write" : "read_only", v = Object.freeze(["conversation", "member"]), D = Object.freeze(["android", "ios", "desktop", "other"]), U = Object.freeze(["message", "edit", "delete", "reaction", "resync"]);
36
- function k(e) {
37
- const t = typeof e == "object" && e !== null ? e.rules : void 0;
38
- if (!Array.isArray(t)) return [];
39
- const o = [];
40
- for (const n of t) {
41
+ const p = Object.freeze(["dark", "live", "read_only", "braked"]), U = (e) => t(p, e), L = Object.freeze(["joint", "split"]), k = Object.freeze(["read_only", "public_write"]), F = (e) => e === "split" ? "split" : "joint", G = (e) => e === "public_write" ? "public_write" : "read_only", P = Object.freeze(["conversation", "member"]), B = Object.freeze(["android", "ios", "desktop", "other"]), x = Object.freeze(["message", "edit", "delete", "reaction", "resync"]);
42
+ function H(e) {
43
+ const o = typeof e == "object" && e !== null ? e.rules : void 0;
44
+ if (!Array.isArray(o)) return [];
45
+ const r = [];
46
+ for (const n of o) {
41
47
  if (typeof n != "object" || n === null) continue;
42
- const { id: r, title: s, summary: c, anchor: l } = n;
43
- typeof r != "string" || typeof s != "string" || typeof l != "string" || o.push(Object.freeze({ id: r, title: s, summary: typeof c == "string" ? c : null, anchor: l }));
48
+ const { id: s, title: c, summary: i, anchor: _ } = n;
49
+ typeof s != "string" || typeof c != "string" || typeof _ != "string" || r.push(Object.freeze({ id: s, title: c, summary: typeof i == "string" ? i : null, anchor: _ }));
44
50
  }
45
- return o;
51
+ return r;
46
52
  }
47
- const S = 2;
48
- function G(e) {
49
- const t = typeof e == "object" && e !== null ? e.controllers : void 0;
50
- if (!Array.isArray(t)) return [];
51
- const o = [];
52
- for (const n of t) {
53
- if (o.length >= S) break;
53
+ const b = 2;
54
+ function Y(e) {
55
+ const o = typeof e == "object" && e !== null ? e.controllers : void 0;
56
+ if (!Array.isArray(o)) return [];
57
+ const r = [];
58
+ for (const n of o) {
59
+ if (r.length >= b) break;
54
60
  if (typeof n != "object" || n === null) continue;
55
- const { entity: r, label: s } = n;
56
- typeof r != "string" || typeof s != "string" || r.trim() === "" || s.trim() === "" || o.push(Object.freeze({ entity: r, label: s.trim() }));
61
+ const { entity: s, label: c } = n;
62
+ typeof s != "string" || typeof c != "string" || s.trim() === "" || c.trim() === "" || r.push(Object.freeze({ entity: s, label: c.trim() }));
57
63
  }
58
- return o;
64
+ return r;
59
65
  }
60
- function M(e) {
61
- const t = typeof e == "object" && e !== null ? e.sections : void 0;
62
- if (!Array.isArray(t)) return [];
63
- const o = [];
64
- for (const n of t) {
66
+ function V(e) {
67
+ const o = typeof e == "object" && e !== null ? e.sections : void 0;
68
+ if (!Array.isArray(o)) return [];
69
+ const r = [];
70
+ for (const n of o) {
65
71
  if (typeof n != "object" || n === null) continue;
66
- const { id: r, title: s, anchor: c } = n;
67
- typeof r != "string" || typeof s != "string" || typeof c != "string" || o.push(Object.freeze({ id: r, title: s, anchor: c }));
72
+ const { id: s, title: c, anchor: i } = n;
73
+ typeof s != "string" || typeof c != "string" || typeof i != "string" || r.push(Object.freeze({ id: s, title: c, anchor: i }));
68
74
  }
69
- return o;
75
+ return r;
70
76
  }
77
+ const A = Object.freeze(["topics", "article_discussions"]), W = (e) => t(A, e), j = Object.freeze(["post", "hold_flagged", "pre"]), X = (e) => t(j, e), q = Object.freeze(["members", "team"]), m = Object.freeze(["open", "locked", "archived"]), Q = (e) => t(m, e), Z = Object.freeze(["topic", "article"]), $ = Object.freeze(["activity", "new"]), J = Object.freeze(["forum", "article"]), ee = Object.freeze(["topic", "message"]), te = Object.freeze(["conversation", "category"]), R = Object.freeze(["forum", "article_discussions"]), oe = (e) => t(R, e), ne = Object.freeze(["case", "premod"]), re = Object.freeze(["open", "decided"]), se = Object.freeze(["member_report", "filter", "staff"]), ce = Object.freeze(["no_action", "visibility_restricted", "removal"]), ie = Object.freeze(["notice", "own_initiative"]), _e = Object.freeze(["open", "locked"]), ae = Object.freeze(["approve", "reject"]);
71
78
  export {
72
- R as AGE_BANDS,
73
- K as ART9_CONSENT_LAYOUTS,
74
- S as ART9_CONTROLLERS_MAX,
75
- C as ART9_REFUSALS,
76
- a as AUTHOR_KINDS,
77
- y as CASE_CATEGORIES,
79
+ T as ADVERSE_EVENT_OUTCOMES,
80
+ D as AGE_BANDS,
81
+ L as ART9_CONSENT_LAYOUTS,
82
+ b as ART9_CONTROLLERS_MAX,
83
+ k as ART9_REFUSALS,
84
+ O as AUTHOR_KINDS,
85
+ R as BRAKE_SURFACES,
86
+ a as CASE_CATEGORIES,
78
87
  h as CATEGORY_WITHOUT_NOTIFIER,
79
- z as LEGAL_TEXT_KINDS,
88
+ K as ESCALATION_CATEGORIES,
89
+ te as FOLLOW_TARGET_KINDS,
90
+ A as FORUM_CATEGORY_KINDS,
91
+ j as FORUM_CATEGORY_MODES,
92
+ $ as FORUM_SORTS,
93
+ J as FORUM_SPACES,
94
+ M as LEGAL_TEXT_KINDS,
80
95
  f as MESSAGE_STATES,
81
- b as MODULE_STATES,
82
- v as MUTE_TARGET_KINDS,
83
- _ as NEEDS,
84
- p as NOTIFICATION_CODES,
85
- D as PUSH_USER_AGENT_CLASSES,
86
- U as REALTIME_EVENT_KINDS,
87
- d as RESTRICTION_KINDS,
88
- O as TRUST_LABELS,
89
- L as art9ConsentLayoutOf,
90
- G as art9ControllersOf,
91
- w as art9RefusalOf,
92
- M as communityLegalSectionsOf,
93
- k as communityRulesOf,
96
+ ie as MODERATION_BASES,
97
+ re as MODERATION_CASE_STATUSES,
98
+ ne as MODERATION_ITEM_KINDS,
99
+ ce as MODERATION_RESTRICTIONS,
100
+ se as MODERATION_SOURCES,
101
+ _e as MODERATOR_TOPIC_STATES,
102
+ p as MODULE_STATES,
103
+ P as MUTE_TARGET_KINDS,
104
+ u as NEEDS,
105
+ E as NOTIFICATION_CODES,
106
+ ae as PREMOD_OUTCOMES,
107
+ B as PUSH_USER_AGENT_CLASSES,
108
+ x as REALTIME_EVENT_KINDS,
109
+ S as RESTRICTION_KINDS,
110
+ ee as SEARCH_RESULT_KINDS,
111
+ q as TOPIC_CREATIONS,
112
+ Z as TOPIC_ITEM_KINDS,
113
+ m as TOPIC_STATES,
114
+ d as TRUST_LABELS,
115
+ F as art9ConsentLayoutOf,
116
+ Y as art9ControllersOf,
117
+ G as art9RefusalOf,
118
+ V as communityLegalSectionsOf,
119
+ H as communityRulesOf,
94
120
  g as isCaseCategory,
95
- N as isKnownAuthor,
96
- u as isKnownAuthorKind,
97
- I as isKnownModuleState,
98
- T as isKnownNeed,
99
- E as isKnownNotificationCode,
100
- A as isKnownRestrictionKind,
101
- m as isKnownState,
102
- j as isKnownTrustLabel
121
+ v as isKnownAdverseEventOutcome,
122
+ w as isKnownAuthor,
123
+ l as isKnownAuthorKind,
124
+ oe as isKnownBrakeSurface,
125
+ W as isKnownForumCategoryKind,
126
+ X as isKnownForumCategoryMode,
127
+ U as isKnownModuleState,
128
+ z as isKnownNeed,
129
+ C as isKnownNotificationCode,
130
+ I as isKnownRestrictionKind,
131
+ y as isKnownState,
132
+ Q as isKnownTopicState,
133
+ N as isKnownTrustLabel
103
134
  };
@@ -150,6 +150,12 @@ export interface DiscussionStore {
150
150
  /** Back to the empty state (another article); the answers still on their way are dropped when they come. */
151
151
  reset(): void;
152
152
  }
153
+ /**
154
+ * A known author kind as the store renders it (a member short of its fields is the deleted placeholder); else null.
155
+ * M3: a member's `moderator: true` (a moderator's message in a category they moderate, §3.5) is kept, nothing else.
156
+ * The topic store (topic.ts) reads a topic's author through it too.
157
+ */
158
+ export declare function authorOf(raw: unknown): KnownAuthor | null;
153
159
  export declare function createDiscussionStore(): DiscussionStore;
154
160
  /** What the composer waits for, from the viewer's known needs. */
155
161
  export interface ViewerNeeds {
@@ -179,6 +185,15 @@ export declare function reactionsFor(state: DiscussionState, target: ReactionTar
179
185
  */
180
186
  export declare function reactionAfter(summary: ReactionSummary, emoji: string | null): ReactionSummary;
181
187
  type ListClient = Pick<CommunityClient, 'discussions'>;
188
+ /**
189
+ * Where a store is (its generation, the article it shows), so a loader can tell whether it moved on — reset(), a
190
+ * page of another article — while a page was on its way. A store of another make has no generation: the article
191
+ * it shows is the sign. Internal: the topic store (topic.ts) tracks its own discussion store with it.
192
+ */
193
+ export declare function placeOf(store: DiscussionStore): {
194
+ moved(): boolean;
195
+ mark(): void;
196
+ };
182
197
  /**
183
198
  * Loads the discussion, or brings the loaded pages up to date (after a newer head): the first page, then the next
184
199
  * ones until the pages loaded before are covered — to the end when the end was loaded. The first failure is the
@@ -1,4 +1,4 @@
1
- import { isKnownNeed as w, isKnownState as ge, isKnownRestrictionKind as me, isKnownAuthorKind as be } from "./shapes.js";
1
+ import { isKnownNeed as $, isKnownAuthorKind as me, isKnownState as ge, isKnownRestrictionKind as be } from "./shapes.js";
2
2
  const C = (e) => typeof e == "object" && e !== null && !Array.isArray(e), f = (e) => typeof e == "string" ? e : null, P = (e) => typeof e == "number" && Number.isSafeInteger(e) && e > 0, D = Object.freeze({ counts: Object.freeze({}), mine: null });
3
3
  function L(e) {
4
4
  if (!C(e)) return D;
@@ -8,7 +8,7 @@ function L(e) {
8
8
  typeof r == "number" && Number.isSafeInteger(r) && r > 0 && (s[n] = r);
9
9
  return Object.freeze({ counts: Object.freeze(s), mine: f(e.mine) });
10
10
  }
11
- const $ = Object.freeze({
11
+ const J = Object.freeze({
12
12
  kind: "member",
13
13
  memberId: null,
14
14
  handle: null,
@@ -16,31 +16,31 @@ const $ = Object.freeze({
16
16
  avatarPreset: null,
17
17
  deleted: !0
18
18
  }), ye = Object.freeze({ kind: "system" });
19
- function J(e) {
20
- if (!C(e) || !be(e.kind)) return null;
19
+ function Q(e) {
20
+ if (!C(e) || !me(e.kind)) return null;
21
21
  if (e.kind === "system") return ye;
22
22
  if (e.kind === "staff")
23
23
  return Object.freeze({ kind: "staff", staffId: f(e.staffId) ?? "", displayName: f(e.displayName) ?? "", badge: f(e.badge) ?? "" });
24
24
  const s = f(e.memberId), n = f(e.handle), r = f(e.displayName);
25
- return s === null || n === null || r === null || e.deleted === !0 ? $ : Object.freeze({ kind: "member", memberId: s, handle: n, displayName: r, avatarPreset: f(e.avatarPreset) });
25
+ return s === null || n === null || r === null || e.deleted === !0 ? J : Object.freeze({ kind: "member", memberId: s, handle: n, displayName: r, avatarPreset: f(e.avatarPreset), ...e.moderator === !0 ? { moderator: !0 } : {} });
26
26
  }
27
- function Q(e) {
27
+ function Z(e) {
28
28
  if (Array.isArray(e))
29
29
  return Object.freeze(e.filter((s) => typeof s == "string"));
30
30
  }
31
31
  function N(e, s) {
32
32
  if (!C(e)) return null;
33
- const n = J(e.author);
33
+ const n = Q(e.author);
34
34
  if (n === null || !ge(e.state)) return null;
35
35
  const r = f(e.conversationId), c = f(e.id);
36
36
  if (r === null || c === null || !P(e.seq)) return null;
37
- const g = f(e.body), m = [];
37
+ const m = f(e.body), g = [];
38
38
  if (s && Array.isArray(e.replies))
39
39
  for (const y of e.replies) {
40
40
  const M = N(y, !1);
41
- M && m.push(M);
41
+ M && g.push(M);
42
42
  }
43
- const z = Q(e.notes);
43
+ const z = Z(e.notes);
44
44
  return Object.freeze({
45
45
  conversationId: r,
46
46
  seq: e.seq,
@@ -49,8 +49,8 @@ function N(e, s) {
49
49
  replyToSeq: s ? null : P(e.replyToSeq) ? e.replyToSeq : null,
50
50
  author: n,
51
51
  state: e.state,
52
- body: g,
53
- displayBody: f(e.displayBody) ?? g,
52
+ body: m,
53
+ displayBody: f(e.displayBody) ?? m,
54
54
  displayLanguageCode: f(e.displayLanguageCode),
55
55
  sourceLanguageCode: f(e.sourceLanguageCode),
56
56
  isTranslated: e.isTranslated === !0,
@@ -63,15 +63,17 @@ function N(e, s) {
63
63
  ...z && z.length > 0 ? { notes: z } : {},
64
64
  // Only as kb-api sends it: true, on a `held` message (the author's own, held back by the art. 9 policy).
65
65
  ...e.hiddenUntilConsent === !0 && e.state === "held" ? { hiddenUntilConsent: !0 } : {},
66
- replies: x(m),
66
+ // M3 (§4.2): the author's own message waiting in pre-moderation — true on a `held` row only, as kb-api sends it.
67
+ ...e.premoderated === !0 && e.state === "held" ? { premoderated: !0 } : {},
68
+ replies: x(g),
67
69
  ...s && e.repliesTruncated === !0 ? { repliesTruncated: !0 } : {}
68
70
  });
69
71
  }
70
72
  function Ie(e) {
71
- const s = C(e) ? e : {}, n = Array.isArray(s.needs) ? s.needs.filter(w) : [], r = [];
73
+ const s = C(e) ? e : {}, n = Array.isArray(s.needs) ? s.needs.filter($) : [], r = [];
72
74
  if (Array.isArray(s.restrictions))
73
75
  for (const c of s.restrictions)
74
- !C(c) || !me(c.kind) || typeof c.decisionId != "string" || r.push(Object.freeze({ kind: c.kind, scope: f(c.scope) ?? "", endsAt: f(c.endsAt), decisionId: c.decisionId }));
76
+ !C(c) || !be(c.kind) || typeof c.decisionId != "string" || r.push(Object.freeze({ kind: c.kind, scope: f(c.scope) ?? "", endsAt: f(c.endsAt), decisionId: c.decisionId }));
75
77
  return Object.freeze({
76
78
  memberId: f(s.memberId),
77
79
  canPost: s.canPost === !0,
@@ -102,16 +104,16 @@ function T(e, s) {
102
104
  let n = !1;
103
105
  const r = [];
104
106
  for (const c of e) {
105
- let g = s(c);
106
- if (g !== null && g.replies.length > 0) {
107
- const m = T(g.replies, s);
108
- m !== g.replies && (g = Object.freeze({ ...g, replies: m }));
107
+ let m = s(c);
108
+ if (m !== null && m.replies.length > 0) {
109
+ const g = T(m.replies, s);
110
+ g !== m.replies && (m = Object.freeze({ ...m, replies: g }));
109
111
  }
110
- g !== c && (n = !0), g !== null && r.push(g);
112
+ m !== c && (n = !0), m !== null && r.push(m);
111
113
  }
112
114
  return n ? Object.freeze(r) : e;
113
115
  }
114
- function h(e, s) {
116
+ function k(e, s) {
115
117
  for (const n of e) {
116
118
  if (s(n)) return n;
117
119
  for (const r of n.replies) if (s(r)) return r;
@@ -122,18 +124,18 @@ function K(e, s) {
122
124
  return T(e, (n) => n.seq === s.seq ? n.replyToSeq === null && s.replyToSeq === null ? Object.freeze({ ...s, replies: n.replies }) : s : n);
123
125
  }
124
126
  function U(e, s) {
125
- if (h(e, (r) => r.seq === s.seq)) return K(e, s);
127
+ if (k(e, (r) => r.seq === s.seq)) return K(e, s);
126
128
  if (s.replyToSeq === null) return x([...e, s]);
127
129
  const n = e.find((r) => r.seq === s.replyToSeq);
128
130
  return n ? Object.freeze(e.map((r) => r === n ? Object.freeze({ ...r, replies: x([...r.replies, s]) }) : r)) : e;
129
131
  }
130
- const Y = (e) => e.replyToSeq === null && e.replies.length > 0, G = (e, s) => e.toLowerCase() === s.toLowerCase(), W = (e) => e.author.kind === "member" && e.author.memberId !== null ? e.author.memberId.toLowerCase() : null, Oe = 256, Z = /* @__PURE__ */ new WeakMap();
132
+ const Y = (e) => e.replyToSeq === null && e.replies.length > 0, G = (e, s) => e.toLowerCase() === s.toLowerCase(), W = (e) => e.author.kind === "member" && e.author.memberId !== null ? e.author.memberId.toLowerCase() : null, Oe = 256, w = /* @__PURE__ */ new WeakMap();
131
133
  function Ce() {
132
134
  let e = V;
133
135
  const s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
134
- let c = 0, g = -1;
135
- const m = /* @__PURE__ */ new Set(), z = () => {
136
- c += 1, m.clear();
136
+ let c = 0, m = -1;
137
+ const g = /* @__PURE__ */ new Set(), z = () => {
138
+ c += 1, g.clear();
137
139
  for (const t of n.keys())
138
140
  r.delete(t), r.add(t);
139
141
  n.clear();
@@ -155,15 +157,15 @@ function Ce() {
155
157
  if (!C(t)) return;
156
158
  const u = f(t.articleId)?.toLowerCase() ?? null, l = e.articleId !== null && u !== null && u !== e.articleId, i = l ? V : e;
157
159
  l && z();
158
- const b = typeof o.cursor == "number" && Number.isFinite(o.cursor) ? o.cursor : null, I = b ?? 0, q = typeof t.nextCursor == "number" && Number.isFinite(t.nextCursor) ? t.nextCursor : null, k = q ?? Number.POSITIVE_INFINITY, j = /* @__PURE__ */ new Map();
160
+ const b = typeof o.cursor == "number" && Number.isFinite(o.cursor) ? o.cursor : null, I = b ?? 0, q = typeof t.nextCursor == "number" && Number.isFinite(t.nextCursor) ? t.nextCursor : null, h = q ?? Number.POSITIVE_INFINITY, j = /* @__PURE__ */ new Map();
159
161
  for (const d of Array.isArray(t.messages) ? t.messages : []) {
160
162
  const a = N(d, !0);
161
- a && a.seq > I && a.seq <= k && j.set(a.seq, a);
163
+ a && a.seq > I && a.seq <= h && j.set(a.seq, a);
162
164
  }
163
165
  for (const d of j.values())
164
166
  for (const a of [d, ...d.replies]) {
165
167
  const S = W(a);
166
- S === null || a.body === null || (a.collapsed ? m.add(S) : m.delete(S));
168
+ S === null || a.body === null || (a.collapsed ? g.add(S) : g.delete(S));
167
169
  }
168
170
  const p = /* @__PURE__ */ new Map();
169
171
  for (const d of i.messages) {
@@ -175,7 +177,7 @@ function Ce() {
175
177
  if (!a) return d;
176
178
  const S = a.clientMsgId ? n.get(a.clientMsgId) : void 0;
177
179
  return S && (S.before = d), a.replyToSeq === null ? Object.freeze({ ...a, replies: d.replies }) : a;
178
- }, v = i.messages.filter((d) => d.seq < 0 || d.seq <= I || d.seq > k), R = /* @__PURE__ */ new Map();
180
+ }, v = i.messages.filter((d) => d.seq < 0 || d.seq <= I || d.seq > h), R = /* @__PURE__ */ new Map();
179
181
  for (const d of i.messages)
180
182
  for (const a of d.replies)
181
183
  a.seq < 0 && a.replyToSeq !== null && R.set(a.replyToSeq, [...R.get(a.replyToSeq) ?? [], a]);
@@ -204,9 +206,9 @@ function Ce() {
204
206
  if (n.has(t.clientMsgId)) return;
205
207
  const o = P(t.replyToSeq) ? t.replyToSeq : null;
206
208
  if (o !== null && !e.messages.some((b) => b.seq === o)) return;
207
- const u = J(t.author) ?? $, l = Object.freeze({
209
+ const u = Q(t.author) ?? J, l = Object.freeze({
208
210
  conversationId: e.conversationId ?? "",
209
- seq: g--,
211
+ seq: m--,
210
212
  id: `pending:${t.clientMsgId}`,
211
213
  rev: 0,
212
214
  replyToSeq: o,
@@ -233,7 +235,7 @@ function Ce() {
233
235
  }
234
236
  function te(t) {
235
237
  if (n.has(t.clientMsgId)) return;
236
- const o = h(e.messages, (l) => l.seq === t.seq);
238
+ const o = k(e.messages, (l) => l.seq === t.seq);
237
239
  if (!o || o.pending) return;
238
240
  n.set(t.clientMsgId, { type: t.type, before: o });
239
241
  const u = t.type === "edit" ? Object.freeze({
@@ -261,23 +263,23 @@ function Ce() {
261
263
  i !== e.messages && y({ ...e, messages: i });
262
264
  return;
263
265
  }
264
- const b = t.warnings ? Q(t.warnings) : void 0, I = b && b.length > 0 ? Object.freeze({ ...l, warnings: b }) : l, q = h(i, (p) => p.seq === I.seq);
265
- let k, j = e.count;
266
+ const b = t.warnings ? Z(t.warnings) : void 0, I = b && b.length > 0 ? Object.freeze({ ...l, warnings: b }) : l, q = k(i, (p) => p.seq === I.seq);
267
+ let h, j = e.count;
266
268
  if (I.state === "deleted" || o?.type === "delete") {
267
269
  const p = q ?? null, O = p?.state === "visible" && p.body !== null;
268
- k = T(
270
+ h = T(
269
271
  i,
270
272
  (v) => v.seq !== I.seq ? v : Y(v) ? Object.freeze({ ...I, replies: v.replies }) : null
271
273
  ), O && (j = Math.max(0, j - 1));
272
274
  } else
273
- k = U(i, I), !q && I.state === "visible" && (j += 1);
275
+ h = U(i, I), !q && I.state === "visible" && (j += 1);
274
276
  y({
275
277
  ...e,
276
278
  // The answer to this store's own change names the new conversation; a row it never saw may be another article's.
277
279
  conversationId: e.conversationId ?? (o ? I.conversationId : null),
278
280
  lastSeq: Math.max(e.lastSeq, I.seq),
279
281
  count: j,
280
- messages: k
282
+ messages: h
281
283
  });
282
284
  }
283
285
  function ne(t) {
@@ -294,7 +296,7 @@ function Ce() {
294
296
  }
295
297
  function re(t) {
296
298
  const o = N(t, t?.replyToSeq === null || t?.replyToSeq === void 0);
297
- !o || !h(e.messages, (u) => u.seq === o.seq && !u.pending && G(u.conversationId, o.conversationId)) || y({ ...e, messages: K(e.messages, o) });
299
+ !o || !k(e.messages, (u) => u.seq === o.seq && !u.pending && G(u.conversationId, o.conversationId)) || y({ ...e, messages: K(e.messages, o) });
298
300
  }
299
301
  function oe(t) {
300
302
  if (C(t))
@@ -334,7 +336,7 @@ function Ce() {
334
336
  function ce(t, o) {
335
337
  if (typeof t != "string" || t === "") return;
336
338
  const u = t.toLowerCase();
337
- o ? m.add(u) : m.delete(u);
339
+ o ? g.add(u) : g.delete(u);
338
340
  const l = T(
339
341
  e.messages,
340
342
  (i) => i.author.kind === "member" && i.author.memberId !== null && i.author.memberId.toLowerCase() === u && i.body !== null && i.collapsed !== o ? Object.freeze({ ...i, collapsed: o }) : i
@@ -342,7 +344,7 @@ function Ce() {
342
344
  l !== e.messages && y({ ...e, messages: l });
343
345
  }
344
346
  function ue(t, o) {
345
- const u = W(t), l = t.body !== null && u !== null && m.has(u), i = o ? o.reactions.mine : null, b = i === t.reactions.mine ? t.reactions : Object.freeze({ counts: t.reactions.counts, mine: i }), I = o?.repliesTruncated === !0 && t.replyToSeq === null, q = o?.warnings;
347
+ const u = W(t), l = t.body !== null && u !== null && g.has(u), i = o ? o.reactions.mine : null, b = i === t.reactions.mine ? t.reactions : Object.freeze({ counts: t.reactions.counts, mine: i }), I = o?.repliesTruncated === !0 && t.replyToSeq === null, q = o?.warnings;
346
348
  return l === t.collapsed && b === t.reactions && !I && !q ? t : Object.freeze({
347
349
  ...t,
348
350
  collapsed: l,
@@ -362,7 +364,7 @@ function Ce() {
362
364
  return y({ ...e, articleReactions: Object.freeze({ counts: A.counts, mine: e.articleReactions.mine }) }), "applied";
363
365
  }
364
366
  if (!P(t.seq)) return "dropped";
365
- const p = t.seq, O = h(e.messages, (A) => A.seq === p);
367
+ const p = t.seq, O = k(e.messages, (A) => A.seq === p);
366
368
  if (!O || O.pending || o < O.rev) return "dropped";
367
369
  if (o > O.rev) return "resync";
368
370
  const v = L(t.reactions), R = Object.freeze({ counts: v.counts, mine: O.reactions.mine });
@@ -371,7 +373,7 @@ function Ce() {
371
373
  if (t.kind !== "message" && t.kind !== "edit" && t.kind !== "delete") return "dropped";
372
374
  const u = t.message, l = N(u, u?.replyToSeq === null || u?.replyToSeq === void 0);
373
375
  if (!l || !F(l)) return "dropped";
374
- const i = h(e.messages, (p) => p.seq === l.seq);
376
+ const i = k(e.messages, (p) => p.seq === l.seq);
375
377
  if (i?.pending) return "dropped";
376
378
  const b = i?.rev ?? 0;
377
379
  if (t.kind === "delete") {
@@ -385,8 +387,8 @@ function Ce() {
385
387
  const I = l.author.kind === "member" && l.author.memberId !== null && l.author.memberId === e.viewer.memberId;
386
388
  if (!i && I && [...n.values()].some((p) => p.type === "post") || o <= b) return "dropped";
387
389
  if (o > b + 1 || !i && l.replyToSeq !== null && !e.messages.some((p) => p.seq === l.replyToSeq)) return "resync";
388
- const q = ue(l, i), k = i ? K(e.messages, q) : U(e.messages, q), j = !i && l.state === "visible" ? e.count + 1 : e.count;
389
- return y({ ...e, messages: k, count: j, lastSeq: Math.max(e.lastSeq, l.seq) }), "applied";
390
+ const q = ue(l, i), h = i ? K(e.messages, q) : U(e.messages, q), j = !i && l.state === "visible" ? e.count + 1 : e.count;
391
+ return y({ ...e, messages: h, count: j, lastSeq: Math.max(e.lastSeq, l.seq) }), "applied";
390
392
  }
391
393
  const B = {
392
394
  getState: () => e,
@@ -405,28 +407,28 @@ function Ce() {
405
407
  z(), y(V);
406
408
  }
407
409
  };
408
- return Z.set(B, () => c), B;
410
+ return w.set(B, () => c), B;
409
411
  }
410
412
  function X(e) {
411
413
  const { pending: s, clientMsgId: n, ...r } = e;
412
414
  return Object.freeze(r);
413
415
  }
414
416
  function Te(e) {
415
- const s = "viewer" in e ? e.viewer.needs : e.needs, n = new Set(s.filter(w)), r = n.has("sign_in"), c = n.has("onboarding"), g = c || n.has("reconsent_rules"), m = n.has("art9_consent");
416
- return Object.freeze({ signIn: r, onboarding: c, rules: g, art9: m, any: r || c || g || m });
417
+ const s = "viewer" in e ? e.viewer.needs : e.needs, n = new Set(s.filter($)), r = n.has("sign_in"), c = n.has("onboarding"), m = c || n.has("reconsent_rules"), g = n.has("art9_consent");
418
+ return Object.freeze({ signIn: r, onboarding: c, rules: m, art9: g, any: r || c || m || g });
417
419
  }
418
420
  function Me(e, s) {
419
- return h(e.messages, (n) => n.seq === s);
421
+ return k(e.messages, (n) => n.seq === s);
420
422
  }
421
423
  function Ae(e, s) {
422
424
  return s.author.kind === "member" && s.author.memberId !== null && s.author.memberId === e.viewer.memberId;
423
425
  }
424
- function ke(e, s) {
426
+ function he(e, s) {
425
427
  if ("articleId" in s) return e.articleReactions;
426
428
  const n = s.conversationId.toLowerCase();
427
- return h(e.messages, (c) => c.seq === s.seq && c.conversationId.toLowerCase() === n)?.reactions ?? D;
429
+ return k(e.messages, (c) => c.seq === s.seq && c.conversationId.toLowerCase() === n)?.reactions ?? D;
428
430
  }
429
- function he(e, s) {
431
+ function ke(e, s) {
430
432
  const n = { ...e.counts }, r = e.mine;
431
433
  if (r !== null) {
432
434
  const c = (n[r] ?? 0) - 1;
@@ -436,7 +438,7 @@ function he(e, s) {
436
438
  }
437
439
  const ve = 20;
438
440
  function ee(e) {
439
- const s = Z.get(e);
441
+ const s = w.get(e);
440
442
  let n = s?.(), r = e.getState().articleId;
441
443
  return {
442
444
  moved: () => s !== void 0 && s() !== n || e.getState().articleId !== r,
@@ -447,15 +449,15 @@ function ee(e) {
447
449
  }
448
450
  const ze = (e) => typeof e == "number" && Number.isFinite(e) ? e : null;
449
451
  async function xe(e, s, n, r) {
450
- const c = e.getState(), g = c.loaded ? c.nextCursor : 0, m = ee(e);
452
+ const c = e.getState(), m = c.loaded ? c.nextCursor : 0, g = ee(e);
451
453
  let z = null;
452
454
  for (let y = 0; y < ve; y++) {
453
455
  const M = await s.discussions.list({ articleId: n.articleId, languageCode: n.languageCode ?? null, cursor: z }, r);
454
456
  if (!M.ok) return M;
455
- if (m.moved()) break;
456
- e.applyPage(M.value, { cursor: z }), m.mark();
457
+ if (g.moved()) break;
458
+ e.applyPage(M.value, { cursor: z }), g.mark();
457
459
  const E = ze(M.value.nextCursor);
458
- if (E === null || g !== null && E >= g || z !== null && E <= z) break;
460
+ if (E === null || m !== null && E >= m || z !== null && E <= z) break;
459
461
  z = E;
460
462
  }
461
463
  return { ok: !0, value: e.getState() };
@@ -463,16 +465,18 @@ async function xe(e, s, n, r) {
463
465
  async function Ee(e, s, n, r) {
464
466
  const c = e.getState().nextCursor;
465
467
  if (c === null) return { ok: !0, value: e.getState() };
466
- const g = ee(e), m = await s.discussions.list({ articleId: n.articleId, languageCode: n.languageCode ?? null, cursor: c }, r);
467
- return m.ok ? (g.moved() || e.applyPage(m.value, { cursor: c }), { ok: !0, value: e.getState() }) : m;
468
+ const m = ee(e), g = await s.discussions.list({ articleId: n.articleId, languageCode: n.languageCode ?? null, cursor: c }, r);
469
+ return g.ok ? (m.moved() || e.applyPage(g.value, { cursor: c }), { ok: !0, value: e.getState() }) : g;
468
470
  }
469
471
  export {
472
+ Q as authorOf,
470
473
  Ce as createDiscussionStore,
471
474
  Me as findMessage,
472
475
  Ae as isOwnMessage,
473
476
  Ee as loadMoreDiscussion,
474
- he as reactionAfter,
475
- ke as reactionsFor,
477
+ ee as placeOf,
478
+ ke as reactionAfter,
479
+ he as reactionsFor,
476
480
  xe as refreshDiscussion,
477
481
  Te as viewerNeeds
478
482
  };