@logora/debate 0.4.110 → 0.4.111

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.
@@ -1,93 +1,93 @@
1
- import { jsxs as S, jsx as s } from "react/jsx-runtime";
2
- import { storePendingReply as Qe } from "../../util/pending_reply/pendingReply.js";
3
- import { useRef as be, useState as d, useEffect as M, Suspense as Xe, lazy as Ze } from "react";
4
- import { useIntl as et, FormattedMessage as ve } from "react-intl";
5
- import { useLocation as tt } from "react-router";
1
+ import { jsxs as w, jsx as s } from "react/jsx-runtime";
2
+ import { storePendingReply as Xe } from "../../util/pending_reply/pendingReply.js";
3
+ import { useRef as ve, useState as d, useEffect as M, Suspense as Ze, lazy as et } from "react";
4
+ import { useIntl as tt, FormattedMessage as Se } from "react-intl";
5
+ import { useLocation as nt } from "react-router";
6
6
  import I from "classnames";
7
7
  import n from "./ArgumentInput.module.scss.js";
8
- import { useDataProvider as nt } from "../../data/data_provider/useDataProvider.js";
9
- import { useList as at } from "../../list/list_provider/useList.js";
10
- import { useConfig as st } from "../../data/config_provider/useConfig.js";
11
- import { useInput as it } from "../input_provider/useInput.js";
12
- import { useAuth as ot } from "../../auth/use_auth/useAuth.js";
13
- import { useFormValidation as rt } from "../../forms/use_form_validation/useFormValidation.js";
14
- import { useResponsive as ut } from "../../hooks/use_responsive/useResponsive.js";
15
- import { useScrollToEditor as dt } from "../use_scroll_to_editor/useScrollToEditor.js";
16
- import { useSessionStorageState as lt } from "../../hooks/use_session_storage_state/useSessionStorageState.js";
17
- import { useAuthRequired as ct } from "../../hooks/use_auth_required/useAuthRequired.js";
18
- import { useModal as mt } from "../../dialog/modal/useModal.js";
19
- import { useToast as ft } from "../../dialog/toast_provider/useToast.js";
20
- import { TogglePosition as gt } from "../toggle_position/TogglePosition.js";
21
- import { Avatar as ht } from "../../user/avatar/Avatar.js";
22
- import { AuthorBox as pt } from "../../user/author_box/AuthorBox.js";
23
- import { TextEditor as _t } from "../text_editor/TextEditor.js";
24
- import { Icon as Mt } from "../../icons/icon/Icon.js";
25
- const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Ae = 2e4, Rt = ({
8
+ import { useDataProvider as at } from "../../data/data_provider/useDataProvider.js";
9
+ import { useList as st } from "../../list/list_provider/useList.js";
10
+ import { useConfig as it } from "../../data/config_provider/useConfig.js";
11
+ import { useInput as ot } from "../input_provider/useInput.js";
12
+ import { useAuth as rt } from "../../auth/use_auth/useAuth.js";
13
+ import { useFormValidation as ut } from "../../forms/use_form_validation/useFormValidation.js";
14
+ import { useResponsive as dt } from "../../hooks/use_responsive/useResponsive.js";
15
+ import { useScrollToEditor as lt } from "../use_scroll_to_editor/useScrollToEditor.js";
16
+ import { useSessionStorageState as ct } from "../../hooks/use_session_storage_state/useSessionStorageState.js";
17
+ import { useSubscriptionRequired as mt, useAuthRequired as ft } from "../../hooks/use_auth_required/useAuthRequired.js";
18
+ import { useModal as gt } from "../../dialog/modal/useModal.js";
19
+ import { useToast as ht } from "../../dialog/toast_provider/useToast.js";
20
+ import { TogglePosition as pt } from "../toggle_position/TogglePosition.js";
21
+ import { Avatar as _t } from "../../user/avatar/Avatar.js";
22
+ import { AuthorBox as Mt } from "../../user/author_box/AuthorBox.js";
23
+ import { TextEditor as bt } from "../text_editor/TextEditor.js";
24
+ import { Icon as vt } from "../../icons/icon/Icon.js";
25
+ const St = et(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Ae = 2e4, zt = ({
26
26
  argumentListId: x,
27
- avatarSize: Se = 48,
28
- disabled: K = !1,
27
+ avatarSize: we = 48,
28
+ disabled: G = !1,
29
29
  positions: a = [],
30
30
  disabledPositions: N = [],
31
31
  groupId: f,
32
- groupName: we,
33
- groupType: G,
34
- hideSourceAction: Ce = !1,
32
+ groupName: Ce,
33
+ groupType: H,
34
+ hideSourceAction: ye = !1,
35
35
  isReply: o = !1,
36
- onSubmit: H,
37
- onUpdate: Q,
36
+ onSubmit: Q,
37
+ onUpdate: X,
38
38
  parentId: m,
39
- ancestorIds: ye = [],
40
- placeholder: Ie,
41
- positionId: w,
42
- focusOnInit: xe = !1,
39
+ ancestorIds: Ie = [],
40
+ placeholder: xe,
41
+ positionId: C,
42
+ focusOnInit: Ne = !1,
43
43
  activeOnInit: Y = !1,
44
- userGuideUrl: X,
45
- hideUserGuideLink: Ne = !1,
46
- hideCharCount: Te = !1,
47
- disableAutoActivate: Le = !1,
48
- autoFocus: Z = !1
44
+ userGuideUrl: Z,
45
+ hideUserGuideLink: Te = !1,
46
+ hideCharCount: Le = !1,
47
+ disableAutoActivate: Pe = !1,
48
+ autoFocus: ee = !1
49
49
  }) => {
50
- const r = et(), ee = nt(), T = at(), b = st(), {
51
- focus: te,
52
- setFocus: ne,
50
+ const r = tt(), te = at(), T = st(), b = it(), {
51
+ focus: ne,
52
+ setFocus: ae,
53
53
  inputContent: $,
54
- setInputContent: ae,
55
- setInputRichContent: Pe
56
- } = it(), { isLoggedIn: C, currentUser: l } = ot(), { errors: U, validate: q } = rt(), { isMobile: g } = ut(), Fe = tt(), se = be(null), L = dt(se), [V, D] = d([]), [W, k] = d(""), [ie, O] = d(null), [c, v] = d(null), [oe, re] = d(null), [ue, de] = d(!1), [y, le] = d(!1), [A, ce] = d({}), [Ee, R] = d(!1), [Be, Ye] = d(0), P = be(!1), [$e, me] = d(!1), [h, Ue] = lt(
54
+ setInputContent: se,
55
+ setInputRichContent: Fe
56
+ } = ot(), { isLoggedIn: v, currentUser: l } = rt(), { errors: U, validate: R } = ut(), { isMobile: g } = dt(), Ee = nt(), ie = ve(null), L = lt(ie), [V, D] = d([]), [W, k] = d(""), [oe, O] = d(null), [c, S] = d(null), [re, ue] = d(null), [de, le] = d(!1), [y, ce] = d(!1), [A, me] = d({}), [Be, j] = d(!1), [qe, Ye] = d(0), P = ve(!1), [$e, fe] = d(!1), [h, Ue] = ct(
57
57
  "userSide",
58
58
  {}
59
- ), [p, qe] = d(
60
- !C && b?.actions?.disableInputForVisitor
61
- ), j = ct(), { showModal: Ve } = mt(), { toast: F } = ft() || {}, fe = new URLSearchParams(
62
- typeof window < "u" ? window.location.search : Fe.search
59
+ ), F = mt(), [p, Re] = d(
60
+ !v && b?.actions?.disableInputForVisitor || F
61
+ ), z = ft(), { showModal: Ve } = gt(), { toast: E } = ht() || {}, ge = new URLSearchParams(
62
+ typeof window < "u" ? window.location.search : Ee.search
63
63
  );
64
64
  M(() => {
65
- qe(
66
- !C && b?.actions?.disableInputForVisitor
65
+ Re(
66
+ !v && b?.actions?.disableInputForVisitor || F
67
67
  );
68
- }, [C, b]);
69
- const z = l?.role === "editor" || l?.role === "moderator", ge = l?.moderation_status === "banned";
68
+ }, [v, b, F]);
69
+ const J = l?.role === "editor" || l?.role === "moderator", he = l?.moderation_status === "banned";
70
70
  M(() => {
71
71
  let e = null;
72
- typeof window < "u" && (e = fe.get("positionId")), w && w != a[2]?.id && a?.find((t) => t.id === w) ? v(w) : e && e != a[2]?.id ? v(e) : h && h.groupId == f && h.positionId != a[2]?.id && v(h.positionId);
73
- }, [w]), M(() => {
74
- Z && R(!0);
75
- }, [Z]), M(() => {
76
- Y && (J(), R(!0), L());
72
+ typeof window < "u" && (e = ge.get("positionId")), C && C != a[2]?.id && a?.find((t) => t.id === C) ? S(C) : e && e != a[2]?.id ? S(e) : h && h.groupId == f && h.positionId != a[2]?.id && S(h.positionId);
73
+ }, [C]), M(() => {
74
+ ee && j(!0);
75
+ }, [ee]), M(() => {
76
+ Y && (K(), j(!0), L());
77
77
  }, [Y]), M(() => {
78
78
  if (typeof window < "u") {
79
- const e = xe || fe.get("initArgument");
80
- (e === !0 || e === "true") && (R(!0), L(), Ke());
79
+ const e = Ne || ge.get("initArgument");
80
+ (e === !0 || e === "true") && (j(!0), L(), Ge());
81
81
  }
82
82
  }, []), M(() => {
83
- te && !o && (L(), ne(!1));
84
- }, [te]), M(() => {
85
- $?.id && !o && (De($), ne(!0));
83
+ ne && !o && (L(), ae(!1));
84
+ }, [ne]), M(() => {
85
+ $?.id && !o && (De($), ae(!0));
86
86
  }, [$]);
87
87
  const De = (e) => {
88
- ce(e), le(!0), D(e.sources), k(e.content), O(e.rich_content), re(e.id), L(), v(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Pe(e.rich_content) : ae(e.content);
89
- }, he = () => {
90
- k(""), O(null), ce({}), re(null), D([]), Ye((e) => e + 1), ae(null);
88
+ me(e), ce(!0), D(e.sources), k(e.content), O(e.rich_content), ue(e.id), L(), S(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Fe(e.rich_content) : se(e.content);
89
+ }, pe = () => {
90
+ k(""), O(null), me({}), ue(null), D([]), Ye((e) => e + 1), se(null);
91
91
  }, We = {
92
92
  create: {
93
93
  id: "alert.argument_create_error",
@@ -101,23 +101,23 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
101
101
  id: "alert.argument_rate_limited",
102
102
  defaultMessage: "Your contribution could not be sent. Please try again in a few moments."
103
103
  }
104
- }, E = (e, t) => {
104
+ }, B = (e, t) => {
105
105
  t && console.error("[ArgumentInput] submission failed", t);
106
106
  const { id: u, defaultMessage: i } = We[t?.response?.status === 429 ? "rateLimited" : e];
107
- F?.(r.formatMessage({ id: u, defaultMessage: i }), { type: "error" });
108
- }, pe = async (e) => {
109
- P.current = !0, me(!0);
107
+ E?.(r.formatMessage({ id: u, defaultMessage: i }), { type: "error" });
108
+ }, _e = async (e) => {
109
+ P.current = !0, fe(!0);
110
110
  try {
111
111
  return await e();
112
112
  } finally {
113
- P.current = !1, me(!1);
113
+ P.current = !1, fe(!1);
114
114
  }
115
115
  }, ke = (e) => {
116
- v(e), Me(e);
116
+ S(e), be(e);
117
117
  }, Oe = () => {
118
118
  Ve(
119
- /* @__PURE__ */ s(Xe, { fallback: null, children: /* @__PURE__ */ s(
120
- bt,
119
+ /* @__PURE__ */ s(Ze, { fallback: null, children: /* @__PURE__ */ s(
120
+ St,
121
121
  {
122
122
  modalTitle: r.formatMessage({
123
123
  id: "modal.side_modal.modal_title",
@@ -125,47 +125,47 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
125
125
  }),
126
126
  onChooseSide: ke,
127
127
  positions: a,
128
- title: we,
128
+ title: Ce,
129
129
  disabledPositions: !o && N,
130
130
  isNeutral: h && h.groupId == f && h.positionId === a[2]?.id
131
131
  }
132
132
  ) })
133
133
  );
134
- }, Re = () => {
135
- C ? oe ? Je() : !a || a?.length === 0 || !N?.find((e) => e?.id === c) && c || z && o ? Me(o && z && a[0]?.id) : Oe() : (m && Qe({ groupId: f, parentId: m, ancestorIds: ye }), j({ loginAction: "argument" }));
136
- }, je = (e, t) => {
137
- p ? j({ loginAction: "argument" }) : (k(e), O(t), q({ content: e }, [{ content: ["url", null] }]));
138
- }, ze = (e) => {
134
+ }, je = () => {
135
+ v && !F ? re ? Ke() : !a || a?.length === 0 || !N?.find((e) => e?.id === c) && c || J && o ? be(o && J && a[0]?.id) : Oe() : (m && !v && Xe({ groupId: f, parentId: m, ancestorIds: Ie }), z({ loginAction: "argument" }));
136
+ }, ze = (e, t) => {
137
+ p ? z({ loginAction: "argument" }) : (k(e), O(t), R({ content: e }, [{ content: ["url", null] }]));
138
+ }, Je = (e) => {
139
139
  D(e);
140
- }, _e = [
140
+ }, Me = [
141
141
  { content: ["length", 3] },
142
142
  { content: ["required", null] },
143
143
  { content: ["url", null] },
144
144
  ...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
145
- ], Me = (e) => {
145
+ ], be = (e) => {
146
146
  if (P.current)
147
147
  return;
148
148
  const t = e || c, u = {
149
149
  content: W,
150
- rich_content: ie,
150
+ rich_content: oe,
151
151
  group_id: f,
152
- ...G && { group_type: G },
152
+ ...H && { group_type: H },
153
153
  ...t && { position_id: t },
154
154
  is_reply: !!m,
155
155
  message_id: m || null,
156
156
  source_ids: V?.map((i) => i.id)
157
157
  };
158
- q(u, _e) && (t && a && a.map((i) => i.id).includes(t) && Ue({
158
+ R(u, Me) && (t && a && a.map((i) => i.id).includes(t) && Ue({
159
159
  groupId: f,
160
160
  positionId: t
161
- }), pe(
162
- () => ee.create("messages", u, {}, !0, {
161
+ }), _e(
162
+ () => te.create("messages", u, {}, !0, {
163
163
  timeout: Ae
164
164
  })
165
165
  ).then((i) => {
166
166
  if (i?.data?.success) {
167
167
  if (m)
168
- H(i.data.data.resource), F(
168
+ Q(i.data.data.resource), E(
169
169
  r.formatMessage({
170
170
  id: "alert.argument_create",
171
171
  defaultMessage: "Your contribution has been sent !"
@@ -180,11 +180,11 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
180
180
  );
181
181
  else {
182
182
  const _ = i.data.data.resource;
183
- let B = x;
184
- t && !g && (B = `argumentList${_.position.id}`), H?.(
183
+ let q = x;
184
+ t && !g && (q = `argumentList${_.position.id}`), Q?.(
185
185
  W,
186
- a.find((He) => He.id === t) || null
187
- ), T.add(B, [_]), F(
186
+ a.find((Qe) => Qe.id === t) || null
187
+ ), T.add(q, [_]), E(
188
188
  r.formatMessage({
189
189
  id: "alert.argument_create",
190
190
  defaultMessage: "Your contribution has been sent !"
@@ -206,21 +206,21 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
206
206
  content: i.data.data?.resource
207
207
  }
208
208
  })
209
- ), he();
209
+ ), pe();
210
210
  } else
211
- E("create");
212
- }, (i) => E("create", i)));
213
- }, Je = () => {
211
+ B("create");
212
+ }, (i) => B("create", i)));
213
+ }, Ke = () => {
214
214
  if (P.current)
215
215
  return;
216
216
  const e = {
217
217
  content: W,
218
- rich_content: ie,
218
+ rich_content: oe,
219
219
  source_ids: V?.map((t) => t.id),
220
220
  ...c && { position_id: c }
221
221
  };
222
- q(e, _e) && pe(
223
- () => ee.update("messages", oe, e, {}, !0, {
222
+ R(e, Me) && _e(
223
+ () => te.update("messages", re, e, {}, !0, {
224
224
  timeout: Ae
225
225
  })
226
226
  ).then(
@@ -233,29 +233,29 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
233
233
  _ && (i = `argument_${_}_reply_list`);
234
234
  } else c && !g && (i = `argumentList${u.position?.id}`);
235
235
  if (!A?.is_reply && A?.position?.id != u.position?.id && !g) {
236
- const _ = `argumentList${A.position.id}`, B = `argumentList${u.position.id}`;
237
- T.remove(_, [u]), T.add(B, [u]);
236
+ const _ = `argumentList${A.position.id}`, q = `argumentList${u.position.id}`;
237
+ T.remove(_, [u]), T.add(q, [u]);
238
238
  } else
239
239
  T.update(i, [u]);
240
- Q && Q(u), F(r.formatMessage({ id: "alert.argument_modify" }), {
240
+ X && X(u), E(r.formatMessage({ id: "alert.argument_modify" }), {
241
241
  type: "success"
242
- }), he();
242
+ }), pe();
243
243
  } else
244
- E("update");
244
+ B("update");
245
245
  },
246
- (t) => E("update", t)
246
+ (t) => B("update", t)
247
247
  );
248
- }, Ke = () => {
249
- if (!ue) {
250
- de(!0);
248
+ }, Ge = () => {
249
+ if (!de) {
250
+ le(!0);
251
251
  const e = setTimeout(() => {
252
- de(!1);
252
+ le(!1);
253
253
  }, 2e3);
254
254
  return () => clearTimeout(e);
255
255
  }
256
- }, J = () => {
257
- p ? j({ loginAction: "argument" }) : le(!0);
258
- }, Ge = () => {
256
+ }, K = () => {
257
+ p ? z({ loginAction: "argument" }) : ce(!0);
258
+ }, He = () => {
259
259
  const e = N.find(
260
260
  (t) => t.id === c
261
261
  );
@@ -268,8 +268,8 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
268
268
  { position: e.name }
269
269
  );
270
270
  };
271
- return /* @__PURE__ */ S("div", { className: n.inputContainer, children: [
272
- K && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ge ? r.formatMessage({
271
+ return /* @__PURE__ */ w("div", { className: n.inputContainer, children: [
272
+ G && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: he ? r.formatMessage({
273
273
  id: "input.argument_input.user_banned",
274
274
  defaultMessage: "You are banned from the debate space."
275
275
  }) : r.formatMessage({
@@ -280,26 +280,26 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
280
280
  "div",
281
281
  {
282
282
  className: I(n.argumentInput, {
283
- [n.flash]: ue,
283
+ [n.flash]: de,
284
284
  [n.replyInputContainer]: o
285
285
  }),
286
- children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: se, children: /* @__PURE__ */ S("div", { className: n.argumentInputBox, children: [
287
- a.length > 0 && C && (!o || !z) && /* @__PURE__ */ S("div", { className: n.userPosition, children: [
286
+ children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ie, children: /* @__PURE__ */ w("div", { className: n.argumentInputBox, children: [
287
+ a.length > 0 && v && (!o || !J) && /* @__PURE__ */ w("div", { className: n.userPosition, children: [
288
288
  /* @__PURE__ */ s("div", { children: r.formatMessage({
289
289
  id: "input.position",
290
290
  defaultMessage: "Your position"
291
291
  }) }),
292
292
  /* @__PURE__ */ s(
293
- gt,
293
+ pt,
294
294
  {
295
295
  activeLabel: c === a[0].id ? 0 : c === a[1].id ? 1 : null,
296
296
  firstLabel: a[0],
297
297
  secondLabel: a[1],
298
- onChange: (e) => v(a[e].id)
298
+ onChange: (e) => S(a[e].id)
299
299
  }
300
300
  )
301
301
  ] }),
302
- /* @__PURE__ */ S(
302
+ /* @__PURE__ */ w(
303
303
  "div",
304
304
  {
305
305
  className: I(n.argumentTextInputBox, {
@@ -315,14 +315,14 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
315
315
  [n.argumentAuthorContainerActivated]: !g && y || o
316
316
  }),
317
317
  children: !g && y || o ? /* @__PURE__ */ s(
318
- ht,
318
+ _t,
319
319
  {
320
320
  avatarUrl: l.image_url,
321
321
  userName: l.full_name,
322
- size: Se
322
+ size: we
323
323
  }
324
324
  ) : /* @__PURE__ */ s(
325
- pt,
325
+ Mt,
326
326
  {
327
327
  fullName: l?.full_name || r.formatMessage({ id: "default_author.full_name" }),
328
328
  avatarUrl: l?.image_url,
@@ -332,54 +332,54 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
332
332
  )
333
333
  }
334
334
  ),
335
- /* @__PURE__ */ S(
335
+ /* @__PURE__ */ w(
336
336
  "div",
337
337
  {
338
- onClick: J,
338
+ onClick: K,
339
339
  "data-testid": "argument-input",
340
340
  className: I(n.textEditorBox, {
341
341
  [n.replyTextEditorBox]: o
342
342
  }),
343
343
  children: [
344
344
  /* @__PURE__ */ s(
345
- _t,
345
+ bt,
346
346
  {
347
347
  handleChange: (e, t) => {
348
- je(e, t);
348
+ ze(e, t);
349
349
  },
350
350
  handleSourcesChange: (e) => {
351
- ze(e);
351
+ Je(e);
352
352
  },
353
- placeholder: Ie,
353
+ placeholder: xe,
354
354
  "aria-label": r.formatMessage({
355
355
  id: "input.argument_input.aria_label",
356
356
  defaultMessage: "Message input field"
357
357
  }),
358
- onSubmit: Re,
358
+ onSubmit: je,
359
359
  sources: V,
360
- hideSourceAction: Ce || p,
360
+ hideSourceAction: ye || p,
361
361
  uid: m ? `Reply${f}_${m}` : `Argument${f}`,
362
- onActivation: J,
362
+ onActivation: K,
363
363
  showStylesControls: y,
364
- disabled: K || p || ge,
364
+ disabled: G || p || he,
365
365
  maxLength: p ? !1 : b?.actions?.argumentMaxLength,
366
366
  disableRichText: b?.actions?.disableRichText || p,
367
367
  shortBar: o,
368
368
  isReply: o,
369
- resetSignal: Be,
369
+ resetSignal: qe,
370
370
  hideSubmit: p,
371
371
  allowedDomains: b?.allowed_sources,
372
372
  active: Y,
373
- autoFocus: Ee,
374
- hideCharCount: Te,
375
- disableAutoActivate: Le,
373
+ autoFocus: Be,
374
+ hideCharCount: Le,
375
+ disableAutoActivate: Pe,
376
376
  submitting: $e
377
377
  }
378
378
  ),
379
379
  U?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: U && Object.values(U).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
380
380
  y && N?.find(
381
381
  (e) => e.id === c
382
- ) && /* @__PURE__ */ S(
382
+ ) && /* @__PURE__ */ w(
383
383
  "div",
384
384
  {
385
385
  className: I(
@@ -388,7 +388,7 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
388
388
  ),
389
389
  children: [
390
390
  /* @__PURE__ */ s(
391
- Mt,
391
+ vt,
392
392
  {
393
393
  name: "announcement",
394
394
  className: n.warningIcon,
@@ -396,12 +396,12 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
396
396
  width: 20
397
397
  }
398
398
  ),
399
- /* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: Ge() })
399
+ /* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: He() })
400
400
  ]
401
401
  }
402
402
  ),
403
- y && X && !Ne && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
404
- ve,
403
+ y && Z && !Te && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
404
+ Se,
405
405
  {
406
406
  id: "alert.guide_message",
407
407
  defaultMessage: "Contributions must comply with our {userCharter}.",
@@ -410,11 +410,11 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
410
410
  "a",
411
411
  {
412
412
  className: n.guideMessage,
413
- href: X,
413
+ href: Z,
414
414
  target: "_blank",
415
415
  rel: "noreferrer",
416
416
  children: /* @__PURE__ */ s(
417
- ve,
417
+ Se,
418
418
  {
419
419
  id: "alert.user_charter",
420
420
  defaultMessage: "user charter"
@@ -437,5 +437,5 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
437
437
  ] });
438
438
  };
439
439
  export {
440
- Rt as ArgumentInput
440
+ zt as ArgumentInput
441
441
  };
@@ -1,28 +1,28 @@
1
1
  import { useContext as H, useState as n, useEffect as I } from "react";
2
2
  import { VoteContext as O } from "../vote_provider/VoteProvider.js";
3
3
  import { useAuth as P } from "../../auth/use_auth/useAuth.js";
4
- import { useDataProvider as R } from "../../data/data_provider/useDataProvider.js";
5
- import { useAuthRequired as z } from "../../hooks/use_auth_required/useAuthRequired.js";
6
- const W = (x, d, L, S, v = null) => {
7
- const { votes: f, voteableIds: w, votesLoading: q } = H(O), { isLoggedIn: i } = P(), V = R(), A = Array.isArray(w) && w.includes(d) && q, [T, h] = n(!1), [D, g] = n(!0), [b, m] = n(), [l, _] = n(L), [u, y] = n(S), [C, s] = n(!1), [j, k] = n(!1), B = z();
4
+ import { useDataProvider as z } from "../../data/data_provider/useDataProvider.js";
5
+ import { useAuthRequired as F, useSubscriptionRequired as G } from "../../hooks/use_auth_required/useAuthRequired.js";
6
+ const Y = (S, i, k, x, v = null) => {
7
+ const { votes: d, voteableIds: w, votesLoading: L } = H(O), { isLoggedIn: f } = P(), V = z(), A = Array.isArray(w) && w.includes(i) && L, [T, h] = n(!1), [b, D] = n(!0), [g, m] = n(), [l, _] = n(k), [u, q] = n(x), [R, s] = n(!1), [C, y] = n(!1), j = F(), B = G();
8
8
  I(() => {
9
- if (!j && i && Object.keys(f).length > 0 && d in f) {
10
- const e = f[d];
11
- k(!0), h(!!e), g(e?.is_upvote), m(e?.id);
9
+ if (!C && f && Object.keys(d).length > 0 && i in d) {
10
+ const e = d[i];
11
+ y(!0), h(!!e), D(e?.is_upvote), m(e?.id);
12
12
  }
13
- }, [f, i]);
13
+ }, [d, f]);
14
14
  const r = (e) => {
15
- h(!0), g(e);
15
+ h(!0), D(e);
16
16
  const t = e ? l + 1 : l, o = e ? u : u + 1;
17
- v?.(e, !0, t, o), e ? _((a) => a + 1) : y((a) => a + 1);
17
+ v?.(e, !0, t, o), e ? _((a) => a + 1) : q((a) => a + 1);
18
18
  }, c = (e) => {
19
19
  h(!1);
20
20
  const t = e ? l - 1 : l, o = e ? u : u - 1;
21
- v?.(e, !1, t, o), e ? _((a) => a - 1) : y((a) => a - 1);
21
+ v?.(e, !1, t, o), e ? _((a) => a - 1) : q((a) => a - 1);
22
22
  }, E = (e) => {
23
- if (k(!0), T)
24
- if (D === e)
25
- c(e), s(!0), V.delete("votes", b).then(
23
+ if (y(!0), T)
24
+ if (b === e)
25
+ c(e), s(!0), V.delete("votes", g).then(
26
26
  (t) => {
27
27
  t.data?.success ? m(null) : r(e), s(!1);
28
28
  },
@@ -35,7 +35,7 @@ const W = (x, d, L, S, v = null) => {
35
35
  const t = {
36
36
  is_upvote: e
37
37
  };
38
- s(!0), V.update("votes", b, t).then(
38
+ s(!0), V.update("votes", g, t).then(
39
39
  (o) => {
40
40
  o.data?.success || (c(e), r(!e)), s(!1);
41
41
  },
@@ -46,8 +46,8 @@ const W = (x, d, L, S, v = null) => {
46
46
  }
47
47
  else {
48
48
  const t = {
49
- voteable_id: d,
50
- voteable_type: x,
49
+ voteable_id: i,
50
+ voteable_type: S,
51
51
  is_upvote: e
52
52
  };
53
53
  r(e), s(!0), V.create("votes", t).then(
@@ -64,13 +64,13 @@ const W = (x, d, L, S, v = null) => {
64
64
  totalUpvotes: l,
65
65
  totalDownvotes: u,
66
66
  activeVote: T,
67
- voteSide: D,
67
+ voteSide: b,
68
68
  handleVote: (e) => {
69
- !C && !A && (i ? E(e) : B({ loginAction: "vote" }));
69
+ !R && !A && (f && !B ? E(e) : j({ loginAction: "vote" }));
70
70
  },
71
71
  voteLoading: A
72
72
  };
73
73
  };
74
74
  export {
75
- W as useVote
75
+ Y as useVote
76
76
  };