@instructure/platform-notebook 1.5.2 → 1.6.1

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/dist/index.js CHANGED
@@ -1,48 +1,48 @@
1
- import { jsx as i, jsxs as T, Fragment as rt } from "react/jsx-runtime";
2
- import { createContext as je, useMemo as ge, useContext as ze, useReducer as We, useRef as K, useEffect as V, useState as U, useCallback as Y } from "react";
3
- import { createPortal as st } from "react-dom";
1
+ import { jsx as i, jsxs as C, Fragment as it } from "react/jsx-runtime";
2
+ import { createContext as Ue, useMemo as fe, useContext as ze, useReducer as We, useRef as _, useEffect as W, useState as j, useCallback as X } from "react";
3
+ import { createPortal as lt } from "react-dom";
4
4
  import { z as u } from "zod";
5
- import it from "diff-match-patch";
6
- import { useQueryClient as Ie, useMutation as xe, useQuery as at } from "@tanstack/react-query";
7
- import { CloseButton as lt, Button as ee, IconButton as le } from "@instructure/ui-buttons";
8
- import { Flex as v } from "@instructure/ui-flex";
9
- import { Heading as pe } from "@instructure/ui-heading";
10
- import { Tray as ct } from "@instructure/ui-tray";
11
- import { View as j } from "@instructure/ui-view";
12
- import { IconQuestionLine as ke, IconPinLine as we, IconWarningLine as dt, IconNoteLine as ut, IconEditLine as Se, IconTrashLine as he, IconArrowStartLine as ft } from "@instructure/ui-icons";
13
- import { Menu as ie } from "@instructure/ui-menu";
14
- import { TruncateText as Te } from "@instructure/ui-truncate-text";
5
+ import at from "diff-match-patch";
6
+ import { useQueryClient as Ce, useMutation as xe, useQuery as ct } from "@tanstack/react-query";
7
+ import { CloseButton as dt, Button as J, IconButton as de } from "@instructure/ui-buttons";
8
+ import { Flex as x } from "@instructure/ui-flex";
9
+ import { Heading as Ne } from "@instructure/ui-heading";
10
+ import { Tray as ut } from "@instructure/ui-tray";
11
+ import { View as q } from "@instructure/ui-view";
12
+ import { IconQuestionLine as ke, IconPinLine as Re, IconWarningLine as ft, IconNoteLine as mt, IconEditLine as Te, IconTrashLine as pe, IconArrowStartLine as gt } from "@instructure/ui-icons";
13
+ import { Menu as ae } from "@instructure/ui-menu";
14
+ import { TruncateText as Ie } from "@instructure/ui-truncate-text";
15
15
  import { SimpleSelect as Fe } from "@instructure/ui-simple-select";
16
- import { Text as J } from "@instructure/ui-text";
17
- import { ScreenReaderContent as mt } from "@instructure/ui-a11y-content";
16
+ import { Text as Z } from "@instructure/ui-text";
17
+ import { ScreenReaderContent as ht } from "@instructure/ui-a11y-content";
18
18
  import { TextArea as qe } from "@instructure/ui-text-area";
19
19
  import { Pill as Me } from "@instructure/ui-pill";
20
- import { Pagination as gt } from "@instructure/ui-pagination";
21
- import { Spinner as ht } from "@instructure/ui-spinner";
22
- const pt = u.object({
20
+ import { Pagination as pt } from "@instructure/ui-pagination";
21
+ import { Spinner as Nt } from "@instructure/ui-spinner";
22
+ const yt = u.object({
23
23
  startContainer: u.string(),
24
24
  endContainer: u.string(),
25
25
  startOffset: u.number(),
26
26
  endOffset: u.number()
27
- }), Nt = u.object({
27
+ }), bt = u.object({
28
28
  start: u.number(),
29
29
  end: u.number()
30
- }), Oe = u.object({
30
+ }), we = u.object({
31
31
  selectedText: u.string(),
32
32
  hasNoHighlightAnymore: u.boolean().optional(),
33
- textPosition: Nt.nullable(),
34
- range: pt.nullable(),
33
+ textPosition: bt.nullable(),
34
+ range: yt.nullable(),
35
35
  pageLastModifiedAt: u.string()
36
36
  });
37
- var x = /* @__PURE__ */ ((t) => (t.IMPORTANT = "Important", t.CONFUSING = "Confusing", t))(x || {});
38
- const Re = u.enum([
37
+ var L = /* @__PURE__ */ ((t) => (t.IMPORTANT = "Important", t.CONFUSING = "Confusing", t))(L || {});
38
+ const Oe = u.enum([
39
39
  "Important",
40
40
  "Confusing"
41
41
  /* CONFUSING */
42
- ]), yt = u.object({
42
+ ]), Et = u.object({
43
43
  totalCount: u.number().nullish(),
44
44
  totalNrOfPages: u.number().nullish()
45
- }), Ne = u.object({
45
+ }), ye = u.object({
46
46
  id: u.string(),
47
47
  rootAccountUuid: u.string(),
48
48
  userId: u.string(),
@@ -50,32 +50,32 @@ const Re = u.enum([
50
50
  objectId: u.string(),
51
51
  objectType: u.string(),
52
52
  userText: u.string().optional(),
53
- reaction: u.array(Re),
54
- highlightData: Oe,
53
+ reaction: u.array(Oe),
54
+ highlightData: we,
55
55
  createdAt: u.string(),
56
56
  updatedAt: u.string()
57
- }), bt = u.object({
57
+ }), St = u.object({
58
58
  cursor: u.string(),
59
- node: Ne
59
+ node: ye
60
60
  });
61
61
  u.object({
62
62
  notes: u.object({
63
- edges: u.array(bt),
64
- nodes: u.array(Ne),
65
- pageInfo: yt
63
+ edges: u.array(St),
64
+ nodes: u.array(ye),
65
+ pageInfo: Et
66
66
  })
67
67
  });
68
- const Et = u.object({
68
+ const Tt = u.object({
69
69
  type: u.string(),
70
70
  id: u.string()
71
- }), St = u.object({
71
+ }), It = u.object({
72
72
  courseId: u.string().optional(),
73
- learningObject: Et.optional(),
73
+ learningObject: Tt.optional(),
74
74
  reactions: u.array(u.string()).optional()
75
75
  }).optional();
76
76
  u.object({
77
77
  courseId: u.string().optional(),
78
- filter: St,
78
+ filter: It,
79
79
  offset: u.number().optional(),
80
80
  pageSize: u.number().optional()
81
81
  });
@@ -84,26 +84,26 @@ u.object({
84
84
  objectId: u.string(),
85
85
  objectType: u.string(),
86
86
  userText: u.string().optional(),
87
- reaction: u.array(Re),
88
- highlightData: Oe
87
+ reaction: u.array(Oe),
88
+ highlightData: we
89
89
  });
90
90
  u.object({
91
- createNote: Ne
91
+ createNote: ye
92
92
  });
93
93
  u.object({
94
94
  id: u.string(),
95
95
  userText: u.string().optional(),
96
- reaction: u.array(Re),
97
- highlightData: Oe
96
+ reaction: u.array(Oe),
97
+ highlightData: we
98
98
  });
99
99
  u.object({
100
- updateNote: Ne
100
+ updateNote: ye
101
101
  });
102
102
  u.object({
103
103
  deleteNote: u.string()
104
104
  });
105
105
  var Ke = /* @__PURE__ */ ((t) => (t[t.FORWARDS = 1] = "FORWARDS", t[t.BACKWARDS = 2] = "BACKWARDS", t))(Ke || {});
106
- class te {
106
+ class ee {
107
107
  constructor(e, n) {
108
108
  this.start = e, this.end = n;
109
109
  }
@@ -121,17 +121,17 @@ class te {
121
121
  return o.setStart(e.node, e.offset), o.setEnd(n.node, n.offset), o;
122
122
  }
123
123
  static fromRange(e) {
124
- const n = G.fromPoint(e.startContainer, e.startOffset), o = G.fromPoint(e.endContainer, e.endOffset);
125
- return !n || !o ? null : new te(n, o);
124
+ const n = z.fromPoint(e.startContainer, e.startOffset), o = z.fromPoint(e.endContainer, e.endOffset);
125
+ return !n || !o ? null : new ee(n, o);
126
126
  }
127
127
  static fromOffsets(e, n, o) {
128
- return new te(new G(e, n), new G(e, o));
128
+ return new ee(new z(e, n), new z(e, o));
129
129
  }
130
130
  relativeTo(e) {
131
- return new te(this.start.relativeTo(e), this.end.relativeTo(e));
131
+ return new ee(this.start.relativeTo(e), this.end.relativeTo(e));
132
132
  }
133
133
  }
134
- class G {
134
+ class z {
135
135
  constructor(e, n) {
136
136
  n < 0 && console.error("Offset is invalid"), this.element = e, this.offset = n;
137
137
  }
@@ -153,9 +153,9 @@ class G {
153
153
  static fromCharOffset(e, n) {
154
154
  switch (e.nodeType) {
155
155
  case Node.TEXT_NODE:
156
- return G.fromPoint(e, n);
156
+ return z.fromPoint(e, n);
157
157
  case Node.ELEMENT_NODE:
158
- return new G(e, n);
158
+ return new z(e, n);
159
159
  default:
160
160
  return console.error("Node is not an element or text node"), null;
161
161
  }
@@ -168,7 +168,7 @@ class G {
168
168
  if (!e.parentElement)
169
169
  return console.error("Text node has no parent"), null;
170
170
  const o = $e(e) + n;
171
- return new G(e.parentElement, o);
171
+ return new z(e.parentElement, o);
172
172
  }
173
173
  case Node.ELEMENT_NODE: {
174
174
  if (n < 0 || n > e.childNodes.length)
@@ -176,7 +176,7 @@ class G {
176
176
  let o = 0;
177
177
  for (let r = 0; r < n; r++)
178
178
  o += Xe(e.childNodes[r]);
179
- return new G(e, o);
179
+ return new z(e, o);
180
180
  }
181
181
  default:
182
182
  return console.error("Point is not in an element or text node"), null;
@@ -188,21 +188,21 @@ class G {
188
188
  let n = this.element, o = this.offset;
189
189
  for (; n !== e; )
190
190
  o += $e(n), n.parentElement && (n = n.parentElement);
191
- return new G(n, o);
191
+ return new z(n, o);
192
192
  }
193
193
  }
194
- const Tt = (t) => {
194
+ const vt = (t) => {
195
195
  const e = t.nodeName.toLowerCase();
196
196
  return e === "#text" ? "text()" : e;
197
197
  };
198
- function vt(t) {
198
+ function Ct(t) {
199
199
  let e = 0, n = t;
200
200
  for (; n; )
201
201
  n.nodeName === t.nodeName && (e += 1), n = n.previousSibling;
202
202
  return e;
203
203
  }
204
- const Ct = (t) => {
205
- const e = Tt(t), n = vt(t);
204
+ const xt = (t) => {
205
+ const e = vt(t), n = Ct(t);
206
206
  return `${e}[${n}]`;
207
207
  }, Be = (t, e) => {
208
208
  let n = "", o = t;
@@ -211,43 +211,43 @@ const Ct = (t) => {
211
211
  console.error("Node is not a descendant of root");
212
212
  return;
213
213
  }
214
- n = `${Ct(o)}/${n}`, o = o.parentNode;
214
+ n = `${xt(o)}/${n}`, o = o.parentNode;
215
215
  }
216
216
  return n = `/${n}`, n = n.replace(/\/$/, ""), n;
217
- }, It = (t, e, n) => {
217
+ }, kt = (t, e, n) => {
218
218
  const o = e.toUpperCase();
219
219
  let r = -1;
220
220
  for (let s = 0; s < t.children.length; s++) {
221
- const a = t.children[s];
222
- if (a.nodeName.toUpperCase() === o && (++r, r === n))
223
- return a;
221
+ const l = t.children[s];
222
+ if (l.nodeName.toUpperCase() === o && (++r, r === n))
223
+ return l;
224
224
  }
225
225
  return null;
226
- }, xt = (t, e) => {
226
+ }, Rt = (t, e) => {
227
227
  if (!(t.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+])?)+$/) !== null))
228
228
  return console.error("Expression is not a simple XPath"), null;
229
229
  const o = t.split("/");
230
230
  let r = e;
231
231
  o.shift();
232
232
  for (const s of o) {
233
- let a, l;
234
- const g = s.indexOf("[");
235
- if (g !== -1) {
236
- a = s.slice(0, g);
237
- const h = s.slice(g + 1, s.indexOf("]"));
238
- if (l = Number.parseInt(h, 10) - 1, l < 0)
233
+ let l, a;
234
+ const m = s.indexOf("[");
235
+ if (m !== -1) {
236
+ l = s.slice(0, m);
237
+ const g = s.slice(m + 1, s.indexOf("]"));
238
+ if (a = Number.parseInt(g, 10) - 1, a < 0)
239
239
  return null;
240
240
  } else
241
- a = s, l = 0;
242
- const d = It(r, a, l);
243
- if (!d)
241
+ l = s, a = 0;
242
+ const c = kt(r, l, a);
243
+ if (!c)
244
244
  return null;
245
- r = d;
245
+ r = c;
246
246
  }
247
247
  return r;
248
248
  }, He = (t, e = document.body) => {
249
249
  try {
250
- return xt(t, e);
250
+ return Rt(t, e);
251
251
  } catch {
252
252
  return document.evaluate(`.${t}`, e, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
253
253
  }
@@ -268,18 +268,18 @@ class oe {
268
268
  const r = He(n.endContainer, e);
269
269
  if (!r)
270
270
  return console.error("Failed to resolve endContainer XPath"), null;
271
- const s = G.fromCharOffset(o, n.startOffset), a = G.fromCharOffset(r, n.endOffset);
272
- if (!s || !a)
271
+ const s = z.fromCharOffset(o, n.startOffset), l = z.fromCharOffset(r, n.endOffset);
272
+ if (!s || !l)
273
273
  return null;
274
- const l = new te(s, a).toRange();
275
- return l ? new oe(e, l) : null;
274
+ const a = new ee(s, l).toRange();
275
+ return a ? new oe(e, a) : null;
276
276
  }
277
277
  toRange() {
278
278
  return this.range;
279
279
  }
280
280
  toSelector() {
281
281
  var s;
282
- const e = (s = te.fromRange(this.range)) == null ? void 0 : s.toRange(), n = e && te.fromRange(e), o = n && Be(n.start.element, this.root), r = n && Be(n.end.element, this.root);
282
+ const e = (s = ee.fromRange(this.range)) == null ? void 0 : s.toRange(), n = e && ee.fromRange(e), o = n && Be(n.start.element, this.root), r = n && Be(n.end.element, this.root);
283
283
  return !o || !r ? null : {
284
284
  startContainer: o,
285
285
  startOffset: n.start.offset,
@@ -288,17 +288,17 @@ class oe {
288
288
  };
289
289
  }
290
290
  }
291
- class ne {
291
+ class te {
292
292
  constructor(e, n, o) {
293
293
  this.root = e, this.start = n, this.end = o;
294
294
  }
295
295
  static fromRange(e, n) {
296
296
  var r;
297
- const o = (r = te.fromRange(n)) == null ? void 0 : r.relativeTo(e);
298
- return o ? new ne(e, o.start.offset, o.end.offset) : null;
297
+ const o = (r = ee.fromRange(n)) == null ? void 0 : r.relativeTo(e);
298
+ return o ? new te(e, o.start.offset, o.end.offset) : null;
299
299
  }
300
300
  static fromSelector(e, n) {
301
- return new ne(e, n.start, n.end);
301
+ return new te(e, n.start, n.end);
302
302
  }
303
303
  toSelector() {
304
304
  return {
@@ -307,7 +307,7 @@ class ne {
307
307
  };
308
308
  }
309
309
  toRange() {
310
- return te.fromOffsets(this.root, this.start, this.end).toRange();
310
+ return ee.fromOffsets(this.root, this.start, this.end).toRange();
311
311
  }
312
312
  }
313
313
  const Xe = (t) => {
@@ -327,72 +327,72 @@ const Xe = (t) => {
327
327
  }, Qe = (t, ...e) => {
328
328
  let n = e.shift();
329
329
  const o = t.ownerDocument.createNodeIterator(t, NodeFilter.SHOW_TEXT), r = [];
330
- let s = o.nextNode(), a = null, l = 0;
330
+ let s = o.nextNode(), l = null, a = 0;
331
331
  for (; n !== void 0 && s; )
332
- a = s, l + a.data.length > n ? (r.push({ node: a, offset: n - l }), n = e.shift()) : (s = o.nextNode(), l += a.data.length);
333
- for (; n !== void 0 && a && l === n; )
334
- r.push({ node: a, offset: a.data.length }), n = e.shift();
332
+ l = s, a + l.data.length > n ? (r.push({ node: l, offset: n - a }), n = e.shift()) : (s = o.nextNode(), a += l.data.length);
333
+ for (; n !== void 0 && l && a === n; )
334
+ r.push({ node: l, offset: l.data.length }), n = e.shift();
335
335
  return n !== void 0 && console.error("Offset exceeds text length"), r;
336
- }, kt = (t, e, n, o) => {
336
+ }, wt = (t, e, n, o) => {
337
337
  const r = n - e;
338
- return Math.abs(r - o) <= 5 ? ne.fromSelector(t, {
338
+ return Math.abs(r - o) <= 5 ? te.fromSelector(t, {
339
339
  start: e,
340
340
  end: n
341
341
  }) : null;
342
- }, wt = (t, e, n, o) => {
343
- const r = new it();
342
+ }, Ot = (t, e, n, o) => {
343
+ const r = new at();
344
344
  r.Match_Distance = 5e3;
345
345
  const s = t.textContent;
346
346
  if (!s)
347
347
  return null;
348
348
  if (e.length > 32) {
349
- const a = e.slice(0, 32), l = e.slice(-32), g = o - n;
350
- let d = r.match_main(s, a, n);
351
- const h = r.match_main(s, l, o), c = h + l.length;
352
- if (d === -1 || h === -1)
349
+ const l = e.slice(0, 32), a = e.slice(-32), m = o - n;
350
+ let c = r.match_main(s, l, n);
351
+ const g = r.match_main(s, a, o), d = g + a.length;
352
+ if (c === -1 || g === -1)
353
353
  return null;
354
- const S = c - d, p = Math.abs(S - g);
355
- if ((d > c || p > 5) && (r.Match_Distance = e.length + 100, d = r.match_main(s, a, c), d !== -1 && d < c))
356
- return kt(t, d, c, g);
357
- if (d < c && p <= 5)
358
- return ne.fromSelector(t, {
359
- start: d,
360
- end: c
354
+ const y = d - c, N = Math.abs(y - m);
355
+ if ((c > d || N > 5) && (r.Match_Distance = e.length + 100, c = r.match_main(s, l, d), c !== -1 && c < d))
356
+ return wt(t, c, d, m);
357
+ if (c < d && N <= 5)
358
+ return te.fromSelector(t, {
359
+ start: c,
360
+ end: d
361
361
  });
362
362
  } else {
363
- const a = r.match_main(s, e, n);
364
- if (a !== -1)
365
- return ne.fromSelector(t, {
366
- start: a,
367
- end: a + e.length
363
+ const l = r.match_main(s, e, n);
364
+ if (l !== -1)
365
+ return te.fromSelector(t, {
366
+ start: l,
367
+ end: l + e.length
368
368
  });
369
369
  }
370
370
  return null;
371
- }, Ot = (t, e) => {
371
+ }, Lt = (t, e) => {
372
372
  if (!e) return null;
373
373
  const { highlightData: n } = t, { textPosition: o, selectedText: r } = n;
374
- return wt(
374
+ return Ot(
375
375
  e,
376
376
  r,
377
377
  (o == null ? void 0 : o.start) ?? 0,
378
378
  (o == null ? void 0 : o.end) ?? 0
379
379
  );
380
- }, Rt = (t, e, n) => {
380
+ }, At = (t, e, n) => {
381
381
  const o = [], r = [];
382
382
  for (const s of e) {
383
- const a = Ot(s, t);
384
- if (a) {
385
- const l = a.toRange(), g = l && oe.fromRange(t, l), d = (l == null ? void 0 : l.toString().trim()) || s.highlightData.selectedText;
383
+ const l = Lt(s, t);
384
+ if (l) {
385
+ const a = l.toRange(), m = a && oe.fromRange(t, a), c = (a == null ? void 0 : a.toString().trim()) || s.highlightData.selectedText;
386
386
  o.push({
387
387
  id: s.id,
388
388
  reaction: s.reaction,
389
389
  userText: s.userText,
390
390
  highlightData: {
391
391
  ...s.highlightData,
392
- selectedText: d,
392
+ selectedText: c,
393
393
  hasNoHighlightAnymore: !1,
394
- range: (g == null ? void 0 : g.toSelector()) ?? null,
395
- textPosition: a.toSelector(),
394
+ range: (m == null ? void 0 : m.toSelector()) ?? null,
395
+ textPosition: l.toSelector(),
396
396
  pageLastModifiedAt: n
397
397
  }
398
398
  });
@@ -409,61 +409,61 @@ const Xe = (t) => {
409
409
  }) : r.push(s.id);
410
410
  }
411
411
  return { notesForUpdate: o, noteIdsForDelete: r };
412
- }, Ue = (t, e) => {
413
- var a;
412
+ }, je = (t, e) => {
413
+ var l;
414
414
  if (!e) return;
415
415
  const { highlightData: n, id: o } = t, { range: r } = n ?? {};
416
- r && ((a = oe.fromSelector(e, r)) == null ? void 0 : a.toRange()) && Ut({ id: o });
417
- }, At = (t) => {
416
+ r && ((l = oe.fromSelector(e, r)) == null ? void 0 : l.toRange()) && Ut({ id: o });
417
+ }, Pt = (t) => {
418
418
  const n = document.querySelector(
419
419
  `[data-highlight-id="${CSS.escape(t)}"].highlight-content`
420
- ) ?? document.getElementById(ye(t));
420
+ ) ?? document.getElementById(be(t));
421
421
  if (n) {
422
422
  const o = n.getBoundingClientRect();
423
423
  o.top >= 0 && o.bottom <= (window.innerHeight || document.documentElement.clientHeight) || n.scrollIntoView({ behavior: "smooth", block: "center" });
424
424
  }
425
- }, ue = 90, fe = 172, Lt = (t) => {
425
+ }, me = 90, ge = 172, Dt = (t) => {
426
426
  const e = t.getClientRects();
427
427
  if (!e.length)
428
428
  return null;
429
- const n = e[0], o = e[e.length - 1], r = 4, s = 16, a = window.innerWidth || document.documentElement.clientWidth, l = window.innerHeight || document.documentElement.clientHeight, g = (b) => {
430
- const y = b + fe;
431
- return b >= s && y <= a - s;
432
- }, d = (b) => {
433
- const y = b + ue;
434
- return b >= s && y <= l - s;
429
+ const n = e[0], o = e[e.length - 1], r = 4, s = 16, l = window.innerWidth || document.documentElement.clientWidth, a = window.innerHeight || document.documentElement.clientHeight, m = (h) => {
430
+ const T = h + ge;
431
+ return h >= s && T <= l - s;
432
+ }, c = (h) => {
433
+ const T = h + me;
434
+ return h >= s && T <= a - s;
435
435
  };
436
- let h;
437
- const c = n.right - fe;
438
- if (g(c))
439
- h = c;
436
+ let g;
437
+ const d = n.right - ge;
438
+ if (m(d))
439
+ g = d;
440
440
  else {
441
- const b = n.left;
442
- if (g(b))
443
- h = b;
441
+ const h = n.left;
442
+ if (m(h))
443
+ g = h;
444
444
  else {
445
- const N = (n.left + n.right) / 2 - fe / 2;
446
- g(N) ? h = N : c < s ? h = s : h = a - fe - s;
445
+ const p = (n.left + n.right) / 2 - ge / 2;
446
+ m(p) ? g = p : d < s ? g = s : g = l - ge - s;
447
447
  }
448
448
  }
449
- let S;
450
- const p = o.bottom + r;
451
- if (d(p))
452
- S = p;
449
+ let y;
450
+ const N = o.bottom + r;
451
+ if (c(N))
452
+ y = N;
453
453
  else {
454
- const b = n.top - ue - r;
455
- d(b) ? S = b : p + ue > l - s ? S = l - ue - s : S = s;
454
+ const h = n.top - me - r;
455
+ c(h) ? y = h : N + me > a - s ? y = a - me - s : y = s;
456
456
  }
457
- return { top: S, left: h };
458
- }, Dt = (t, e) => {
457
+ return { top: y, left: g };
458
+ }, _t = (t, e) => {
459
459
  for (const n of e)
460
460
  if (t.start < n.end && t.end > n.start)
461
461
  return !0;
462
462
  return !1;
463
- }, Ae = (t) => `highlight-wrapper-${t}`, ye = (t) => `${Ae(t)}-start`, Ye = (t) => `${Ae(t)}-end`, ce = (t) => `[data-highlight-id="${CSS.escape(t)}"]`, Pt = "2px", _t = "3px", Ft = "Notebook note", Le = (t, e) => {
463
+ }, Le = (t) => `highlight-wrapper-${t}`, be = (t) => `${Le(t)}-start`, Ye = (t) => `${Le(t)}-end`, ue = (t) => `[data-highlight-id="${CSS.escape(t)}"]`, Ft = "2px", Mt = "3px", Bt = "Notebook note", Ae = (t, e) => {
464
464
  const n = Number.parseInt(t.slice(1, 3), 16), o = Number.parseInt(t.slice(3, 5), 16), r = Number.parseInt(t.slice(5, 7), 16);
465
465
  return `rgba(${n}, ${o}, ${r}, ${e})`;
466
- }, Mt = (t, e) => {
466
+ }, Ht = (t, e) => {
467
467
  var n;
468
468
  try {
469
469
  const o = ((n = e.nodeValue) == null ? void 0 : n.length) ?? e.childNodes.length;
@@ -471,7 +471,7 @@ const Xe = (t) => {
471
471
  } catch {
472
472
  return !1;
473
473
  }
474
- }, Bt = (t) => {
474
+ }, $t = (t) => {
475
475
  var s;
476
476
  if (t.collapsed)
477
477
  return [];
@@ -481,231 +481,251 @@ const Xe = (t) => {
481
481
  const n = [], o = (s = e == null ? void 0 : e.ownerDocument) == null ? void 0 : s.createNodeIterator(e, NodeFilter.SHOW_TEXT);
482
482
  let r = (o == null ? void 0 : o.nextNode()) || null;
483
483
  for (; r; ) {
484
- if (!Mt(t, r)) {
484
+ if (!Ht(t, r)) {
485
485
  r = (o == null ? void 0 : o.nextNode()) || null;
486
486
  continue;
487
487
  }
488
- const a = r;
489
- if (a === t.startContainer && t.startOffset > 0) {
490
- a.splitText(t.startOffset), r = (o == null ? void 0 : o.nextNode()) || null;
488
+ const l = r;
489
+ if (l === t.startContainer && t.startOffset > 0) {
490
+ l.splitText(t.startOffset), r = (o == null ? void 0 : o.nextNode()) || null;
491
491
  continue;
492
492
  }
493
- a === t.endContainer && t.endOffset < a.data.length && a.splitText(t.endOffset), n.push(a), r = (o == null ? void 0 : o.nextNode()) || null;
493
+ l === t.endContainer && t.endOffset < l.data.length && l.splitText(t.endOffset), n.push(l), r = (o == null ? void 0 : o.nextNode()) || null;
494
494
  }
495
495
  return n;
496
- }, Ht = (t, e, n) => {
496
+ }, jt = (t, e, n) => {
497
497
  if (t.collapsed) return;
498
- const o = e.id ?? "", r = Ae(o);
499
- if (document.getElementById(ye(o))) {
500
- $t(e, n);
498
+ const o = e.id ?? "", r = Le(o);
499
+ if (document.getElementById(be(o))) {
500
+ Gt(e, n);
501
501
  return;
502
502
  }
503
- const a = e.type === x.IMPORTANT ? n.colors.importantBackground : n.colors.confusingBackground, l = e.id === e.selectedNoteId, g = l ? a : Le(a, 0.5), d = e.type === x.IMPORTANT ? n.colors.importantUnderline : n.colors.confusingUnderline, h = e.type === x.IMPORTANT ? "solid" : "dashed", c = document.createElement("span");
504
- c.id = `${r}-start`, c.className = "highlight-marker-start", c.dataset.highlightId = o || "";
505
- const S = e.labelPrefix ?? Ft;
506
- c.setAttribute("role", "button"), c.setAttribute("tabindex", "0"), c.setAttribute("aria-label", S), c.setAttribute("aria-haspopup", "dialog"), c.setAttribute("aria-expanded", String(l && !!e.isTrayOpen)), e.popupId && c.setAttribute("aria-controls", e.popupId), c.style.position = "relative", c.style.fontSize = "0", c.style.lineHeight = "0", c.style.width = "0", c.style.height = "0", c.style.margin = "0", c.style.padding = "0", c.style.border = "0", c.style.outline = "none";
507
- const p = document.createElement("span");
508
- p.id = Ye(o), p.className = "highlight-marker-end", p.dataset.highlightId = o || "";
509
- const b = t.cloneRange();
510
- b.collapse(!1), b.insertNode(p);
511
- const y = t.cloneRange();
512
- y.collapse(!0), y.insertNode(c);
513
- const N = document.createRange();
514
- N.setStartAfter(c), N.setEndBefore(p);
515
- const O = Bt(N).filter((m) => m.textContent && m.textContent.length > 0);
516
- O.forEach((m, E) => {
517
- var W;
518
- const I = m.parentElement;
519
- if ((I == null ? void 0 : I.dataset.highlightId) === o) return;
520
- const L = E === 0, F = E === O.length - 1, z = O.length === 1;
521
- let B;
522
- z ? B = "single" : L ? B = "first" : F ? B = "last" : B = "middle";
503
+ const l = e.type === L.IMPORTANT ? n.colors.importantBackground : n.colors.confusingBackground, a = e.id === e.selectedNoteId, m = a ? l : Ae(l, 0.5), c = e.type === L.IMPORTANT ? n.colors.importantUnderline : n.colors.confusingUnderline, g = e.type === L.IMPORTANT ? "solid" : "dashed", d = document.createElement("span");
504
+ d.id = `${r}-start`, d.className = "highlight-marker-start", d.dataset.highlightId = o || "";
505
+ const y = e.labelPrefix ?? Bt;
506
+ d.setAttribute("role", "button"), d.setAttribute("tabindex", "0"), d.setAttribute("aria-label", y), d.setAttribute("aria-haspopup", "dialog"), d.setAttribute("aria-expanded", String(a && !!e.isTrayOpen)), e.popupId && d.setAttribute("aria-controls", e.popupId), d.style.position = "relative", d.style.fontSize = "0", d.style.lineHeight = "0", d.style.width = "0", d.style.height = "0", d.style.margin = "0", d.style.padding = "0", d.style.border = "0", d.style.outline = "none";
507
+ const N = document.createElement("span");
508
+ N.id = Ye(o), N.className = "highlight-marker-end", N.dataset.highlightId = o || "";
509
+ const h = t.cloneRange();
510
+ h.collapse(!1), h.insertNode(N);
511
+ const T = t.cloneRange();
512
+ T.collapse(!0), T.insertNode(d);
513
+ const p = document.createRange();
514
+ p.setStartAfter(d), p.setEndBefore(N);
515
+ const M = $t(p).filter((b) => b.textContent && b.textContent.length > 0);
516
+ M.forEach((b, v) => {
517
+ var $;
518
+ const B = b.parentElement;
519
+ if ((B == null ? void 0 : B.dataset.highlightId) === o) return;
520
+ const F = v === 0, E = v === M.length - 1, A = M.length === 1;
521
+ let R;
522
+ A ? R = "single" : F ? R = "first" : E ? R = "last" : R = "middle";
523
523
  const k = document.createElement("span");
524
- k.className = "highlight-content", k.dataset.highlightId = o || "", k.dataset.position = B, k.style.backgroundColor = g, k.style.textDecorationLine = "underline", k.style.textDecorationColor = d, k.style.textDecorationStyle = h, k.style.textDecorationThickness = n.borderWidthSmall, k.style.textUnderlineOffset = n.underlineOffset, k.style.cursor = "pointer", k.addEventListener("click", (X) => {
525
- var H;
526
- X.target.tagName !== "A" && ((H = e.onClick) == null || H.call(e));
527
- }), (W = m.parentNode) == null || W.insertBefore(k, m), k.appendChild(m);
528
- }), c.addEventListener("click", (m) => {
529
- var E;
530
- m.target.tagName !== "A" && ((E = e.onClick) == null || E.call(e));
531
- }), c.addEventListener("keydown", (m) => {
532
- var E;
533
- if (m.key === "Enter" || m.key === " ")
534
- m.preventDefault(), (E = e.onClick) == null || E.call(e);
535
- else if (m.key === "Tab" && !m.shiftKey) {
536
- const I = document.querySelectorAll(ce(o));
537
- for (const L of I) {
538
- const F = L.querySelector("a");
539
- if (F) {
540
- m.preventDefault(), F.focus();
524
+ k.className = "highlight-content", k.dataset.highlightId = o || "", k.dataset.position = R, k.style.backgroundColor = m, k.style.textDecorationLine = "underline", k.style.textDecorationColor = c, k.style.textDecorationStyle = g, k.style.textDecorationThickness = n.borderWidthSmall, k.style.textUnderlineOffset = n.underlineOffset, k.style.cursor = "pointer", k.addEventListener("click", (Q) => {
525
+ var K;
526
+ Q.target.tagName !== "A" && ((K = e.onClick) == null || K.call(e));
527
+ }), ($ = b.parentNode) == null || $.insertBefore(k, b), k.appendChild(b);
528
+ }), d.addEventListener("click", (b) => {
529
+ var v;
530
+ b.target.tagName !== "A" && ((v = e.onClick) == null || v.call(e));
531
+ }), d.addEventListener("keydown", (b) => {
532
+ var v;
533
+ if (b.key === "Enter" || b.key === " ")
534
+ b.preventDefault(), (v = e.onClick) == null || v.call(e);
535
+ else if (b.key === "Tab" && !b.shiftKey) {
536
+ const B = document.querySelectorAll(ue(o));
537
+ for (const F of B) {
538
+ const E = F.querySelector("a");
539
+ if (E) {
540
+ b.preventDefault(), E.focus();
541
541
  break;
542
542
  }
543
543
  }
544
544
  }
545
- }), c.addEventListener("focus", () => {
545
+ }), d.addEventListener("focus", () => {
546
546
  document.querySelectorAll(
547
- `.highlight-content${ce(o)}`
548
- ).forEach((E) => {
549
- E.style.boxShadow = `0 0 0 ${Pt} ${n.colors.focusOutline}`, E.style.borderRadius = _t;
547
+ `.highlight-content${ue(o)}`
548
+ ).forEach((v) => {
549
+ v.style.boxShadow = `0 0 0 ${Ft} ${n.colors.focusOutline}`, v.style.borderRadius = Mt;
550
550
  });
551
- }), c.addEventListener("blur", () => {
551
+ }), d.addEventListener("blur", () => {
552
552
  document.querySelectorAll(
553
- `.highlight-content${ce(o)}`
554
- ).forEach((E) => {
555
- E.style.boxShadow = "", E.style.borderRadius = "";
553
+ `.highlight-content${ue(o)}`
554
+ ).forEach((v) => {
555
+ v.style.boxShadow = "", v.style.borderRadius = "";
556
556
  });
557
557
  });
558
558
  };
559
- function $t(t, e) {
560
- const n = t.type === x.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground, o = t.id === t.selectedNoteId, r = o ? n : Le(n, 0.5);
559
+ function Gt(t, e) {
560
+ const n = t.type === L.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground, o = t.id === t.selectedNoteId, r = o ? n : Ae(n, 0.5);
561
561
  document.querySelectorAll(
562
- ce(t.id ?? "")
563
- ).forEach((l) => {
564
- l.style.backgroundColor = r;
562
+ ue(t.id ?? "")
563
+ ).forEach((a) => {
564
+ a.style.backgroundColor = r;
565
565
  });
566
- const a = document.getElementById(
567
- ye(t.id ?? "")
566
+ const l = document.getElementById(
567
+ be(t.id ?? "")
568
568
  );
569
- a && a.setAttribute("aria-expanded", String(o && !!t.isTrayOpen));
569
+ l && l.setAttribute("aria-expanded", String(o && !!t.isTrayOpen));
570
570
  }
571
571
  const Ut = (t) => {
572
- const e = t.id ?? "", n = document.getElementById(ye(e)), o = document.getElementById(Ye(e));
572
+ const e = t.id ?? "", n = document.getElementById(be(e)), o = document.getElementById(Ye(e));
573
573
  document.querySelectorAll(
574
- ce(e)
574
+ ue(e)
575
575
  ).forEach((s) => {
576
- var a;
576
+ var l;
577
577
  for (; s.firstChild; )
578
- (a = s.parentNode) == null || a.insertBefore(s.firstChild, s);
578
+ (l = s.parentNode) == null || l.insertBefore(s.firstChild, s);
579
579
  s.remove();
580
580
  }), n == null || n.remove(), o == null || o.remove();
581
- }, ae = {
581
+ }, ce = {
582
582
  all: ["notebook"],
583
583
  notes: (t) => ["notebook", "notes", t]
584
584
  };
585
- function Gt(t) {
586
- const e = Ie();
585
+ function zt(t) {
586
+ const e = Ce();
587
587
  return xe({
588
588
  mutationFn: (n) => t.createNote(n),
589
589
  onSuccess: () => {
590
- e.invalidateQueries({ queryKey: ae.all });
590
+ e.invalidateQueries({ queryKey: ce.all });
591
591
  }
592
592
  });
593
593
  }
594
- function jt(t) {
595
- const e = Ie();
594
+ function Wt(t) {
595
+ const e = Ce();
596
596
  return xe({
597
597
  mutationFn: (n) => t.deleteNote(n),
598
598
  onSuccess: () => {
599
- e.invalidateQueries({ queryKey: ae.all });
599
+ e.invalidateQueries({ queryKey: ce.all });
600
600
  }
601
601
  });
602
602
  }
603
- function ve({
603
+ function Ve({
604
604
  api: t,
605
605
  enabled: e = !0,
606
606
  ...n
607
607
  }) {
608
- return at({
609
- queryKey: ae.notes(n),
608
+ return ct({
609
+ queryKey: ce.notes(n),
610
610
  queryFn: () => t.getNotes(n),
611
611
  enabled: e
612
612
  });
613
613
  }
614
- function zt(t) {
615
- const e = Ie();
614
+ const qt = 100;
615
+ function Ze({
616
+ api: t,
617
+ courseId: e,
618
+ learningObject: n,
619
+ reactions: o,
620
+ enabled: r = !0
621
+ }) {
622
+ return Ve({
623
+ api: t,
624
+ filter: {
625
+ ...e ? { courseId: e } : {},
626
+ ...n ? { learningObject: n } : {},
627
+ ...o != null && o.length ? { reactions: o } : {}
628
+ },
629
+ offset: 0,
630
+ pageSize: qt,
631
+ enabled: r
632
+ });
633
+ }
634
+ function Kt(t) {
635
+ const e = Ce();
616
636
  return xe({
617
637
  mutationFn: ({ id: n, input: o }) => t.updateNote(n, o),
618
638
  onMutate: async ({ id: n, input: o }) => {
619
- await e.cancelQueries({ queryKey: ae.all });
620
- const s = e.getQueryCache().findAll({ queryKey: ae.all }), a = /* @__PURE__ */ new Map();
621
- for (const l of s) {
622
- const g = l.state.data;
623
- g && (a.set(l.queryKey, g), e.setQueryData(l.queryKey, {
624
- ...g,
625
- notes: g.notes.map(
626
- (d) => d.id === n ? { ...d, ...o, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : d
639
+ await e.cancelQueries({ queryKey: ce.all });
640
+ const s = e.getQueryCache().findAll({ queryKey: ce.all }), l = /* @__PURE__ */ new Map();
641
+ for (const a of s) {
642
+ const m = a.state.data;
643
+ m && (l.set(a.queryKey, m), e.setQueryData(a.queryKey, {
644
+ ...m,
645
+ notes: m.notes.map(
646
+ (c) => c.id === n ? { ...c, ...o, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : c
627
647
  )
628
648
  }));
629
649
  }
630
- return { previousData: a };
650
+ return { previousData: l };
631
651
  },
632
652
  onError: (n, o, r) => {
633
653
  if (r != null && r.previousData)
634
- for (const [s, a] of r.previousData)
635
- e.setQueryData(s, a);
654
+ for (const [s, l] of r.previousData)
655
+ e.setQueryData(s, l);
636
656
  },
637
657
  onSettled: () => {
638
- e.invalidateQueries({ queryKey: ae.all });
658
+ e.invalidateQueries({ queryKey: ce.all });
639
659
  }
640
660
  });
641
661
  }
642
- const Wt = "Notebook", qt = "Notes", Kt = "Important", Xt = "Unclear", Qt = "Back", Yt = "Edit note", Vt = "Save", Zt = "Cancel", Jt = "Delete note", en = "note", tn = "Add note (optional)", nn = "Remove from Notebook", on = "Add a note (optional)", rn = "Mark important", sn = "Mark unclear", an = "Saved to Notebook.", ln = "Note updated", cn = "Note deleted", dn = "Error saving to Notebook.", un = "Error updating note", fn = "Note deletion failed", mn = "Loading notes", gn = "Failed to load notes", hn = "Start capturing your notes", pn = "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.", Nn = "Nothing here yet", yn = "Adjust your filters or create a new note to get started.", bn = "You have no notes for the selected filter", En = "Filter", Sn = "Previous page", Tn = "Next page", vn = "All courses", Cn = "All notes", In = "Close Notebook panel", xn = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", kn = "The content you highlighted is no longer available.", wn = "Notebook note", De = {
643
- notebook: Wt,
644
- notes: qt,
645
- important: Kt,
646
- unclear: Xt,
647
- back: Qt,
648
- editNote: Yt,
649
- save: Vt,
650
- cancel: Zt,
651
- deleteNote: Jt,
652
- note: en,
653
- addNotePrompt: tn,
654
- removeFromNotebook: nn,
655
- addNoteOptional: on,
656
- markImportant: rn,
657
- markUnclear: sn,
658
- savedToNotebook: an,
659
- noteUpdated: ln,
660
- noteDeleted: cn,
661
- errorSavingNote: dn,
662
- errorUpdatingNote: un,
663
- noteDeletionFailed: fn,
664
- loadingNotes: mn,
665
- failedToLoadNotes: gn,
666
- emptyStateHeading: hn,
667
- emptyStateDescription: pn,
668
- nothingHereYet: Nn,
669
- adjustFiltersOrCreate: yn,
670
- noNotesForFilter: bn,
671
- filter: En,
672
- previousPage: Sn,
673
- nextPage: Tn,
674
- allCourses: vn,
675
- allNotes: Cn,
676
- closeNotebookPanel: In,
677
- featureDescription: xn,
678
- highlightUnavailable: kn,
679
- notebookNote: wn
680
- }, Ve = je(null);
681
- function Ze(t, e) {
682
- const n = De[t] ?? t;
662
+ const Xt = "Notebook", Qt = "Notes", Yt = "Important", Vt = "Unclear", Zt = "Back", Jt = "Edit note", en = "Save", tn = "Cancel", nn = "Delete note", on = "note", rn = "Add note (optional)", sn = "Remove from Notebook", ln = "Add a note (optional)", an = "Mark important", cn = "Mark unclear", dn = "Saved to Notebook.", un = "Note updated", fn = "Note deleted", mn = "Error saving to Notebook.", gn = "Error updating note", hn = "Note deletion failed", pn = "Loading notes", Nn = "Failed to load notes", yn = "Start capturing your notes", bn = "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.", En = "Nothing here yet", Sn = "Adjust your filters or create a new note to get started.", Tn = "You have no notes for the selected filter", In = "Filter", vn = "Previous page", Cn = "Next page", xn = "All courses", kn = "All notes", Rn = "Close Notebook panel", wn = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", On = "The content you highlighted is no longer available.", Ln = "Notebook note", Pe = {
663
+ notebook: Xt,
664
+ notes: Qt,
665
+ important: Yt,
666
+ unclear: Vt,
667
+ back: Zt,
668
+ editNote: Jt,
669
+ save: en,
670
+ cancel: tn,
671
+ deleteNote: nn,
672
+ note: on,
673
+ addNotePrompt: rn,
674
+ removeFromNotebook: sn,
675
+ addNoteOptional: ln,
676
+ markImportant: an,
677
+ markUnclear: cn,
678
+ savedToNotebook: dn,
679
+ noteUpdated: un,
680
+ noteDeleted: fn,
681
+ errorSavingNote: mn,
682
+ errorUpdatingNote: gn,
683
+ noteDeletionFailed: hn,
684
+ loadingNotes: pn,
685
+ failedToLoadNotes: Nn,
686
+ emptyStateHeading: yn,
687
+ emptyStateDescription: bn,
688
+ nothingHereYet: En,
689
+ adjustFiltersOrCreate: Sn,
690
+ noNotesForFilter: Tn,
691
+ filter: In,
692
+ previousPage: vn,
693
+ nextPage: Cn,
694
+ allCourses: xn,
695
+ allNotes: kn,
696
+ closeNotebookPanel: Rn,
697
+ featureDescription: wn,
698
+ highlightUnavailable: On,
699
+ notebookNote: Ln
700
+ }, Je = Ue(null);
701
+ function et(t, e) {
702
+ const n = Pe[t] ?? t;
683
703
  return e ? n.replace(/%\{([^}]+)}/g, (o, r) => String(e[r] ?? `%{${r}}`)) : n;
684
704
  }
685
- function On({
705
+ function An({
686
706
  translations: t,
687
707
  translate: e,
688
708
  children: n
689
709
  }) {
690
- const o = ge(
710
+ const o = fe(
691
711
  () => ({
692
- translations: { ...De, ...t },
693
- translate: e ?? Ze
712
+ translations: { ...Pe, ...t },
713
+ translate: e ?? et
694
714
  }),
695
715
  [t, e]
696
716
  );
697
- return /* @__PURE__ */ i(Ve.Provider, { value: o, children: n });
717
+ return /* @__PURE__ */ i(Je.Provider, { value: o, children: n });
698
718
  }
699
- function Z() {
700
- const t = ze(Ve);
701
- return t || { translations: De, translate: Ze };
719
+ function Y() {
720
+ const t = ze(Je);
721
+ return t || { translations: Pe, translate: et };
702
722
  }
703
- const Rn = (t) => ({
723
+ const Pn = (t) => ({
704
724
  selectedNoteId: t ?? null,
705
725
  isNoteEditing: !1,
706
726
  isTrayOpen: t != null
707
727
  });
708
- function An(t, e) {
728
+ function Dn(t, e) {
709
729
  switch (e.type) {
710
730
  case "SELECT_NOTE":
711
731
  return {
@@ -725,22 +745,22 @@ function An(t, e) {
725
745
  return t;
726
746
  }
727
747
  }
728
- const Je = je(null);
729
- function lo({
748
+ const tt = Ue(null);
749
+ function uo({
730
750
  api: t,
731
751
  currentUserId: e,
732
752
  objectId: n,
733
753
  objectType: o,
734
754
  courseId: r,
735
755
  pageLastModifiedAt: s,
736
- onAnalyticsEvent: a,
737
- onOpen: l,
738
- initialNoteId: g,
739
- translations: d,
740
- translate: h,
741
- children: c
756
+ onAnalyticsEvent: l,
757
+ onOpen: a,
758
+ initialNoteId: m,
759
+ translations: c,
760
+ translate: g,
761
+ children: d
742
762
  }) {
743
- const [S, p] = We(An, Rn(g)), b = K(g != null), y = ge(
763
+ const [y, N] = We(Dn, Pn(m)), h = _(m != null), T = fe(
744
764
  () => ({
745
765
  api: t,
746
766
  currentUserId: e,
@@ -748,16 +768,16 @@ function lo({
748
768
  objectType: o,
749
769
  courseId: r,
750
770
  pageLastModifiedAt: s,
751
- onAnalyticsEvent: a,
752
- ...S,
753
- selectNote: (N, _ = !1) => p({ type: "SELECT_NOTE", payload: { id: N, isEditing: _ } }),
754
- clearSelectedNote: () => p({ type: "CLEAR_SELECTED_NOTE" }),
755
- setEditing: (N) => p({ type: "SET_EDITING", payload: N }),
771
+ onAnalyticsEvent: l,
772
+ ...y,
773
+ selectNote: (p, G = !1) => N({ type: "SELECT_NOTE", payload: { id: p, isEditing: G } }),
774
+ clearSelectedNote: () => N({ type: "CLEAR_SELECTED_NOTE" }),
775
+ setEditing: (p) => N({ type: "SET_EDITING", payload: p }),
756
776
  openTray: () => {
757
- b.current || (b.current = !0, l == null || l()), p({ type: "OPEN_TRAY" });
777
+ h.current || (h.current = !0, a == null || a()), N({ type: "OPEN_TRAY" });
758
778
  },
759
779
  closeTray: () => {
760
- b.current = !1, p({ type: "CLOSE_TRAY" });
780
+ h.current = !1, N({ type: "CLOSE_TRAY" });
761
781
  }
762
782
  }),
763
783
  [
@@ -767,34 +787,34 @@ function lo({
767
787
  o,
768
788
  r,
769
789
  s,
770
- a,
771
790
  l,
772
- S
791
+ a,
792
+ y
773
793
  ]
774
794
  );
775
- return /* @__PURE__ */ i(Je.Provider, { value: y, children: /* @__PURE__ */ i(On, { translations: d, translate: h, children: c }) });
795
+ return /* @__PURE__ */ i(tt.Provider, { value: T, children: /* @__PURE__ */ i(An, { translations: c, translate: g, children: d }) });
776
796
  }
777
- function et() {
778
- const t = ze(Je);
797
+ function nt() {
798
+ const t = ze(tt);
779
799
  if (!t)
780
800
  throw new Error("useNotebook must be used within a NotebookProvider");
781
801
  return t;
782
802
  }
783
- const tt = "notebook-tray-content", co = ({ children: t }) => {
784
- const { isTrayOpen: e, closeTray: n } = et(), { translations: o } = Z();
803
+ const ot = "notebook-tray-content", fo = ({ children: t }) => {
804
+ const { isTrayOpen: e, closeTray: n } = nt(), { translations: o } = Y();
785
805
  return /* @__PURE__ */ i(
786
- ct,
806
+ ut,
787
807
  {
788
808
  label: o.notebook,
789
809
  open: e,
790
810
  onDismiss: n,
791
811
  placement: "end",
792
812
  size: "regular",
793
- children: /* @__PURE__ */ T(v, { direction: "column", height: "100vh", id: tt, children: [
794
- /* @__PURE__ */ i(v.Item, { children: /* @__PURE__ */ i(j, { as: "div", padding: "small medium", borderWidth: "0 0 small 0", children: /* @__PURE__ */ T(v, { justifyItems: "space-between", alignItems: "center", children: [
795
- /* @__PURE__ */ i(pe, { level: "h3", children: o.notebook }),
813
+ children: /* @__PURE__ */ C(x, { direction: "column", height: "100vh", id: ot, children: [
814
+ /* @__PURE__ */ i(x.Item, { children: /* @__PURE__ */ i(q, { as: "div", padding: "small medium", borderWidth: "0 0 small 0", children: /* @__PURE__ */ C(x, { justifyItems: "space-between", alignItems: "center", children: [
815
+ /* @__PURE__ */ i(Ne, { level: "h3", children: o.notebook }),
796
816
  /* @__PURE__ */ i(
797
- lt,
817
+ dt,
798
818
  {
799
819
  screenReaderLabel: o.closeNotebookPanel,
800
820
  onClick: n,
@@ -803,16 +823,16 @@ const tt = "notebook-tray-content", co = ({ children: t }) => {
803
823
  }
804
824
  )
805
825
  ] }) }) }),
806
- /* @__PURE__ */ i(v.Item, { shouldGrow: !0, shouldShrink: !0, overflowY: "auto", overflowX: "hidden", children: t })
826
+ /* @__PURE__ */ i(x.Item, { shouldGrow: !0, shouldShrink: !0, overflowY: "auto", overflowX: "hidden", children: t })
807
827
  ] })
808
828
  }
809
829
  );
810
- }, Ln = ({ currentType: t, onSelectReaction: e }) => {
811
- const { translations: n } = Z(), o = K(null), r = K(null);
812
- return V(() => {
813
- t === x.CONFUSING && o.current ? o.current.focus() : t === x.IMPORTANT && r.current ? r.current.focus() : o.current && o.current.focus();
830
+ }, _n = ({ currentType: t, onSelectReaction: e }) => {
831
+ const { translations: n } = Y(), o = _(null), r = _(null);
832
+ return W(() => {
833
+ t === L.CONFUSING && o.current ? o.current.focus() : t === L.IMPORTANT && r.current ? r.current.focus() : o.current && o.current.focus();
814
834
  }, [t]), /* @__PURE__ */ i(
815
- j,
835
+ q,
816
836
  {
817
837
  as: "div",
818
838
  background: "primary",
@@ -820,25 +840,25 @@ const tt = "notebook-tray-content", co = ({ children: t }) => {
820
840
  borderColor: "secondary",
821
841
  borderRadius: "medium",
822
842
  shadow: "resting",
823
- children: /* @__PURE__ */ T(ie, { children: [
824
- /* @__PURE__ */ T(
825
- ie.Item,
843
+ children: /* @__PURE__ */ C(ae, { children: [
844
+ /* @__PURE__ */ C(
845
+ ae.Item,
826
846
  {
827
847
  ref: o,
828
- onClick: () => e(x.CONFUSING),
848
+ onClick: () => e(L.CONFUSING),
829
849
  children: [
830
850
  /* @__PURE__ */ i(ke, { size: "x-small" }),
831
851
  ` ${n.markUnclear}`
832
852
  ]
833
853
  }
834
854
  ),
835
- /* @__PURE__ */ T(
836
- ie.Item,
855
+ /* @__PURE__ */ C(
856
+ ae.Item,
837
857
  {
838
858
  ref: r,
839
- onClick: () => e(x.IMPORTANT),
859
+ onClick: () => e(L.IMPORTANT),
840
860
  children: [
841
- /* @__PURE__ */ i(we, { size: "x-small" }),
861
+ /* @__PURE__ */ i(Re, { size: "x-small" }),
842
862
  ` ${n.markImportant}`
843
863
  ]
844
864
  }
@@ -846,8 +866,8 @@ const tt = "notebook-tray-content", co = ({ children: t }) => {
846
866
  ] })
847
867
  }
848
868
  );
849
- }, be = "notebook-inline-reaction-menu";
850
- function uo({
869
+ }, Ee = "notebook-inline-reaction-menu";
870
+ function mo({
851
871
  containerRef: t,
852
872
  highlightTheme: e,
853
873
  debounceTime: n = 500,
@@ -856,199 +876,198 @@ function uo({
856
876
  onDeleteError: s
857
877
  }) {
858
878
  const {
859
- api: a,
860
- objectId: l,
861
- objectType: g,
862
- courseId: d,
863
- pageLastModifiedAt: h,
864
- selectedNoteId: c,
865
- isTrayOpen: S,
866
- selectNote: p,
867
- openTray: b
868
- } = et(), { translations: y } = Z(), { data: N } = ve({
869
- api: a,
870
- filter: {
871
- learningObject: { type: g, id: l }
872
- },
873
- courseId: d,
874
- pageSize: 100
875
- }), { mutate: _ } = Gt(a), { mutateAsync: O } = zt(a), { mutate: m } = jt(a), E = K([]), [I, L] = U([]), [F, z] = U(null), [B, k] = U(""), [W, X] = U(null), [H, $] = U(!1);
876
- V(() => {
877
- const R = t.current;
878
- if (!R) return;
879
- const f = R.closest(".user_content") ?? R;
880
- if (f.classList.contains("enhanced")) {
881
- $(!0);
879
+ api: l,
880
+ objectId: a,
881
+ objectType: m,
882
+ courseId: c,
883
+ pageLastModifiedAt: g,
884
+ selectedNoteId: d,
885
+ isTrayOpen: y,
886
+ selectNote: N,
887
+ openTray: h
888
+ } = nt(), { translations: T } = Y(), { data: p } = Ze({
889
+ api: l,
890
+ courseId: c,
891
+ learningObject: { type: m, id: a }
892
+ }), { mutate: G } = zt(l), { mutateAsync: M } = Kt(l), { mutate: b } = Wt(l), v = _([]), [B, F] = j([]), [E, A] = j(null), [R, k] = j(""), [$, Q] = j(null), K = _(null);
893
+ K.current = $;
894
+ const [V, ne] = j(!1);
895
+ W(() => {
896
+ const S = t.current;
897
+ if (!S) return;
898
+ const I = S.closest(".user_content") ?? S;
899
+ if (I.classList.contains("enhanced")) {
900
+ ne(!0);
882
901
  return;
883
902
  }
884
- const w = new MutationObserver((D) => {
885
- for (const M of D)
886
- if (M.type === "attributes" && M.attributeName === "class" && M.target.classList.contains("enhanced")) {
887
- $(!0), w.disconnect();
903
+ const P = new MutationObserver((f) => {
904
+ for (const O of f)
905
+ if (O.type === "attributes" && O.attributeName === "class" && O.target.classList.contains("enhanced")) {
906
+ ne(!0), P.disconnect();
888
907
  return;
889
908
  }
890
909
  });
891
- return w.observe(f, { attributes: !0, attributeFilter: ["class"] }), () => w.disconnect();
910
+ return P.observe(I, { attributes: !0, attributeFilter: ["class"] }), () => P.disconnect();
892
911
  }, [t]);
893
- const q = Y(() => {
894
- X(null), z(null), k("");
912
+ const U = X(() => {
913
+ Q(null), A(null), k("");
895
914
  }, []);
896
- V(() => {
897
- if (!H || !t.current) return;
898
- let f = null;
899
- const w = () => {
900
- f && clearTimeout(f), f = setTimeout(() => {
915
+ W(() => {
916
+ if (!V || !t.current) return;
917
+ let I = null;
918
+ const P = () => {
919
+ I && clearTimeout(I), I = setTimeout(() => {
901
920
  var _e;
902
- const C = window.getSelection(), P = t.current;
903
- if (!(C != null && C.rangeCount) || !P) return;
904
- const re = C.toString().trim();
905
- if (re === "") return;
906
- const se = C.getRangeAt(0);
907
- if (!P.contains(se.commonAncestorContainer)) return;
908
- const Pe = (_e = ne.fromRange(P, se)) == null ? void 0 : _e.toSelector();
909
- Pe && !Dt(Pe, I) && (z(se.cloneRange()), k(re), X(Lt(se)));
921
+ const w = window.getSelection(), H = t.current;
922
+ if (!(w != null && w.rangeCount) || !H) return;
923
+ const ie = w.toString().trim();
924
+ if (ie === "") return;
925
+ const le = w.getRangeAt(0);
926
+ if (!H.contains(le.commonAncestorContainer)) return;
927
+ const De = (_e = te.fromRange(H, le)) == null ? void 0 : _e.toSelector();
928
+ De && !_t(De, B) && (A(le.cloneRange()), k(ie), Q(Dt(le)));
910
929
  }, n);
911
- }, D = (C) => {
912
- if (!(C.target instanceof Node)) return;
913
- const P = document.getElementById(be);
914
- P != null && P.contains(C.target) ? (C.preventDefault(), C.stopImmediatePropagation()) : q();
915
- }, M = () => {
916
- q();
917
- }, A = (C) => {
918
- C.key === "Escape" && q();
930
+ }, f = (w) => {
931
+ if (!(w.target instanceof Node)) return;
932
+ const H = document.getElementById(Ee);
933
+ H != null && H.contains(w.target) ? (w.preventDefault(), w.stopImmediatePropagation()) : U();
934
+ }, O = () => {
935
+ U();
936
+ }, D = (w) => {
937
+ w.key === "Escape" && K.current !== null && (U(), w.stopImmediatePropagation());
919
938
  };
920
- return document.addEventListener("selectionchange", w), document.addEventListener("mousedown", D), document.addEventListener("touchstart", D), document.addEventListener("keydown", A), window.addEventListener("scroll", M, !0), () => {
921
- f && clearTimeout(f), document.removeEventListener("selectionchange", w), document.removeEventListener("mousedown", D), document.removeEventListener("touchstart", D), document.removeEventListener("keydown", A), window.removeEventListener("scroll", M, !0);
939
+ return document.addEventListener("selectionchange", P), document.addEventListener("mousedown", f), document.addEventListener("touchstart", f), document.addEventListener("keydown", D), window.addEventListener("scroll", O, !0), () => {
940
+ I && clearTimeout(I), document.removeEventListener("selectionchange", P), document.removeEventListener("mousedown", f), document.removeEventListener("touchstart", f), document.removeEventListener("keydown", D), window.removeEventListener("scroll", O, !0);
922
941
  };
923
- }, [H, I, n, t, q]);
924
- const Q = Y(
925
- (R) => {
926
- var P;
927
- const f = t.current;
928
- if (!f || !R.highlightData) return null;
929
- const { highlightData: w, reaction: D, id: M } = R, { range: A } = w, C = A && ((P = oe.fromSelector(f, A)) == null ? void 0 : P.toRange());
930
- if (C) {
931
- const re = D[0] === x.IMPORTANT ? y.important : y.unclear, se = {
932
- id: M,
933
- selectedNoteId: c,
934
- type: D[0],
935
- isTrayOpen: S,
936
- labelPrefix: `${y.notebookNote} (${re})`,
937
- popupId: tt,
942
+ }, [V, B, n, t, U]);
943
+ const re = X(
944
+ (S) => {
945
+ var H;
946
+ const I = t.current;
947
+ if (!I || !S.highlightData) return null;
948
+ const { highlightData: P, reaction: f, id: O } = S, { range: D } = P, w = D && ((H = oe.fromSelector(I, D)) == null ? void 0 : H.toRange());
949
+ if (w) {
950
+ const ie = f[0] === L.IMPORTANT ? T.important : T.unclear, le = {
951
+ id: O,
952
+ selectedNoteId: d,
953
+ type: f[0],
954
+ isTrayOpen: y,
955
+ labelPrefix: `${T.notebookNote} (${ie})`,
956
+ popupId: ot,
938
957
  onClick: () => {
939
- p(M), b();
958
+ N(O), h();
940
959
  }
941
960
  };
942
- return Ht(C, se, e), w.textPosition;
961
+ return jt(w, le, e), P.textPosition;
943
962
  }
944
963
  return null;
945
964
  },
946
- [t, c, S, e, y, p, b]
965
+ [t, d, y, e, T, N, h]
947
966
  );
948
- V(() => {
949
- if (!H || !N || !t.current) return;
950
- const R = t.current, f = N.notes, w = /* @__PURE__ */ new Set(), D = [], M = [];
951
- if (f.length === 0) {
952
- if (E.current.length > 0) {
953
- for (const A of E.current)
954
- Ue(A, R);
955
- E.current = [], L([]);
967
+ W(() => {
968
+ if (!V || !p || !t.current) return;
969
+ const S = t.current, I = p.notes, P = /* @__PURE__ */ new Set(), f = [], O = [];
970
+ if (I.length === 0) {
971
+ if (v.current.length > 0) {
972
+ for (const D of v.current)
973
+ je(D, S);
974
+ v.current = [], F([]);
956
975
  }
957
976
  return;
958
977
  }
959
- if (h && f[0].highlightData.pageLastModifiedAt !== h) {
960
- const { notesForUpdate: A, noteIdsForDelete: C } = Rt(
961
- R,
962
- f,
963
- h
978
+ if (g && I[0].highlightData.pageLastModifiedAt !== g) {
979
+ const { notesForUpdate: D, noteIdsForDelete: w } = At(
980
+ S,
981
+ I,
982
+ g
964
983
  );
965
- for (const P of A)
966
- O({ id: P.id, input: P }).catch((re) => r == null ? void 0 : r(re));
967
- for (const P of C)
968
- m(P, { onError: s });
984
+ for (const H of D)
985
+ M({ id: H.id, input: H }).catch((ie) => r == null ? void 0 : r(ie));
986
+ for (const H of w)
987
+ b(H, { onError: s });
969
988
  } else {
970
- for (const A of f) {
971
- const C = Q(A);
972
- w.add(A.id), C && (D.push(A), M.push(C));
989
+ for (const D of I) {
990
+ const w = re(D);
991
+ P.add(D.id), w && (f.push(D), O.push(w));
973
992
  }
974
- for (const A of E.current)
975
- w.has(A.id) || Ue(A, R);
976
- L(M), E.current = D, c && At(c);
993
+ for (const D of v.current)
994
+ P.has(D.id) || je(D, S);
995
+ F(O), v.current = f, d && Pt(d);
977
996
  }
978
997
  }, [
979
- H,
980
- N,
981
- Q,
982
- h,
998
+ V,
999
+ p,
1000
+ re,
1001
+ g,
983
1002
  t,
984
- O,
985
- m,
986
- c
1003
+ M,
1004
+ b,
1005
+ d
987
1006
  ]);
988
- const de = (R) => {
989
- const f = t.current;
990
- if (!F || !f) return;
991
- const w = oe.fromRange(f, F), D = ne.fromRange(f, F);
992
- _(
1007
+ const se = (S) => {
1008
+ const I = t.current;
1009
+ if (!E || !I) return;
1010
+ const P = oe.fromRange(I, E), f = te.fromRange(I, E);
1011
+ G(
993
1012
  {
994
- courseId: d,
995
- objectId: l,
996
- objectType: g,
1013
+ courseId: c,
1014
+ objectId: a,
1015
+ objectType: m,
997
1016
  userText: "",
998
- reaction: [R],
1017
+ reaction: [S],
999
1018
  highlightData: {
1000
- selectedText: B,
1001
- textPosition: (D == null ? void 0 : D.toSelector()) ?? null,
1002
- range: w.toSelector(),
1003
- pageLastModifiedAt: h ?? ""
1019
+ selectedText: R,
1020
+ textPosition: (f == null ? void 0 : f.toSelector()) ?? null,
1021
+ range: P.toSelector(),
1022
+ pageLastModifiedAt: g ?? ""
1004
1023
  }
1005
1024
  },
1006
1025
  {
1007
- onSuccess: (M) => {
1008
- var C;
1009
- const A = M.id;
1010
- q(), (C = window.getSelection()) == null || C.removeAllRanges(), p(A), b();
1026
+ onSuccess: (O) => {
1027
+ var w;
1028
+ const D = O.id;
1029
+ U(), (w = window.getSelection()) == null || w.removeAllRanges(), N(D), h();
1011
1030
  },
1012
1031
  onError: o
1013
1032
  }
1014
1033
  );
1015
1034
  };
1016
- return !F || !W ? null : st(
1035
+ return !E || !$ ? null : lt(
1017
1036
  /* @__PURE__ */ i(
1018
1037
  "div",
1019
1038
  {
1020
- id: be,
1039
+ id: Ee,
1021
1040
  role: "toolbar",
1022
1041
  style: {
1023
1042
  position: "fixed",
1024
1043
  zIndex: 100,
1025
- top: W.top,
1026
- left: W.left,
1044
+ top: $.top,
1045
+ left: $.left,
1027
1046
  whiteSpace: "nowrap"
1028
1047
  },
1029
- onBlur: (R) => {
1030
- const f = document.getElementById(be);
1031
- f != null && f.contains(R.relatedTarget) || q();
1048
+ onBlur: (S) => {
1049
+ const I = document.getElementById(Ee);
1050
+ I != null && I.contains(S.relatedTarget) || U();
1032
1051
  },
1033
- children: /* @__PURE__ */ i(Ln, { onSelectReaction: de })
1052
+ children: /* @__PURE__ */ i(_n, { onSelectReaction: se })
1034
1053
  }
1035
1054
  ),
1036
1055
  document.body
1037
1056
  );
1038
1057
  }
1039
- const Dn = (t, e) => ({
1040
- backgroundColor: t === x.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground,
1041
- underlineColor: t === x.IMPORTANT ? e.colors.importantUnderline : e.colors.confusingUnderline,
1042
- underlineStyle: t === x.IMPORTANT ? "solid" : "dashed"
1043
- }), Ce = ({
1058
+ const Fn = (t, e) => ({
1059
+ backgroundColor: t === L.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground,
1060
+ underlineColor: t === L.IMPORTANT ? e.colors.importantUnderline : e.colors.confusingUnderline,
1061
+ underlineStyle: t === L.IMPORTANT ? "solid" : "dashed"
1062
+ }), ve = ({
1044
1063
  children: t,
1045
- type: e = x.IMPORTANT,
1064
+ type: e = L.IMPORTANT,
1046
1065
  isCardActive: n = !0,
1047
1066
  theme: o
1048
1067
  }) => {
1049
- const r = Dn(e, o), a = {
1068
+ const r = Fn(e, o), l = {
1050
1069
  position: "relative",
1051
- backgroundColor: n ? r.backgroundColor : Le(r.backgroundColor, 0.5),
1070
+ backgroundColor: n ? r.backgroundColor : Ae(r.backgroundColor, 0.5),
1052
1071
  textDecorationLine: "underline",
1053
1072
  textDecorationStyle: r.underlineStyle,
1054
1073
  textDecorationColor: r.underlineColor,
@@ -1056,48 +1075,48 @@ const Dn = (t, e) => ({
1056
1075
  textUnderlineOffset: o.underlineOffset,
1057
1076
  lineHeight: "normal"
1058
1077
  };
1059
- return /* @__PURE__ */ i("span", { "data-note-highlight": "true", style: a, children: t });
1060
- }, nt = () => {
1061
- const { translations: t } = Z();
1062
- return /* @__PURE__ */ T(v, { gap: "xx-small", alignItems: "start", as: "div", children: [
1063
- /* @__PURE__ */ i(v.Item, { as: "div", children: /* @__PURE__ */ i(dt, { color: "error" }) }),
1064
- /* @__PURE__ */ i(v.Item, { padding: "xxx-small none", shouldShrink: !0, children: /* @__PURE__ */ i(Te, { maxLines: 3, children: t.highlightUnavailable }) })
1078
+ return /* @__PURE__ */ i("span", { "data-note-highlight": "true", style: l, children: t });
1079
+ }, rt = () => {
1080
+ const { translations: t } = Y();
1081
+ return /* @__PURE__ */ C(x, { gap: "xx-small", alignItems: "start", as: "div", children: [
1082
+ /* @__PURE__ */ i(x.Item, { as: "div", children: /* @__PURE__ */ i(ft, { color: "error" }) }),
1083
+ /* @__PURE__ */ i(x.Item, { padding: "xxx-small none", shouldShrink: !0, children: /* @__PURE__ */ i(Ie, { maxLines: 3, children: t.highlightUnavailable }) })
1065
1084
  ] });
1066
- }, Pn = 100, _n = {
1085
+ }, Mn = {
1067
1086
  filter: null,
1068
1087
  courseFilter: null,
1069
1088
  currentPage: 1,
1070
1089
  totalPages: void 0
1071
1090
  };
1072
- function me(t, e) {
1091
+ function he(t, e) {
1073
1092
  const n = typeof e == "number" ? Math.min(e, t) : t;
1074
1093
  return Math.max(1, n);
1075
1094
  }
1076
- function Fn(t, e) {
1095
+ function Bn(t, e) {
1077
1096
  switch (e.type) {
1078
1097
  case "SET_FILTER":
1079
1098
  return { ...t, filter: e.payload, currentPage: 1 };
1080
1099
  case "SET_COURSE_FILTER":
1081
1100
  return { ...t, courseFilter: e.payload, currentPage: 1 };
1082
1101
  case "SET_PAGE":
1083
- return { ...t, currentPage: me(e.payload, t.totalPages) };
1102
+ return { ...t, currentPage: he(e.payload, t.totalPages) };
1084
1103
  case "FOCUS_PAGE":
1085
1104
  return { ...t, currentPage: Math.max(1, e.payload) };
1086
1105
  case "INCREMENT_PAGE":
1087
- return { ...t, currentPage: me(t.currentPage + 1, t.totalPages) };
1106
+ return { ...t, currentPage: he(t.currentPage + 1, t.totalPages) };
1088
1107
  case "DECREMENT_PAGE":
1089
- return { ...t, currentPage: me(t.currentPage - 1, t.totalPages) };
1108
+ return { ...t, currentPage: he(t.currentPage - 1, t.totalPages) };
1090
1109
  case "SET_TOTAL_PAGES":
1091
1110
  return t.totalPages === e.payload ? t : {
1092
1111
  ...t,
1093
1112
  totalPages: e.payload,
1094
- currentPage: me(t.currentPage, e.payload)
1113
+ currentPage: he(t.currentPage, e.payload)
1095
1114
  };
1096
1115
  default:
1097
1116
  return t;
1098
1117
  }
1099
1118
  }
1100
- function fo({
1119
+ function go({
1101
1120
  api: t,
1102
1121
  courseId: e,
1103
1122
  enableCourseFilter: n = !1,
@@ -1105,99 +1124,111 @@ function fo({
1105
1124
  pageSize: r = 16,
1106
1125
  focusNoteId: s
1107
1126
  }) {
1108
- const [a, l] = We(Fn, _n), { filter: g, courseFilter: d, currentPage: h, totalPages: c } = a;
1109
- V(() => {
1110
- l({ type: "SET_PAGE", payload: 1 });
1127
+ var se;
1128
+ const [l, a] = We(Bn, Mn), { filter: m, courseFilter: c, currentPage: g, totalPages: d } = l;
1129
+ W(() => {
1130
+ a({ type: "SET_PAGE", payload: 1 });
1111
1131
  }, [r]);
1112
- const S = n ? d : e, p = (h - 1) * r, b = {
1113
- ...S ? { courseId: S } : {},
1114
- ...g ? { reactions: [g] } : {},
1132
+ const y = n ? c : e, N = (g - 1) * r, h = !!o, T = {
1133
+ ...y ? { courseId: y } : {},
1134
+ ...m ? { reactions: [m] } : {},
1115
1135
  ...o ? { learningObject: o } : {}
1116
- }, { data: y, isLoading: N, isError: _ } = ve({
1136
+ }, {
1137
+ data: p,
1138
+ isLoading: G,
1139
+ isError: M
1140
+ } = Ve({
1117
1141
  api: t,
1118
- filter: b,
1119
- offset: p,
1120
- pageSize: r
1121
- }), { data: O } = ve({
1142
+ filter: T,
1143
+ offset: N,
1144
+ pageSize: r,
1145
+ enabled: !h
1146
+ }), {
1147
+ data: b,
1148
+ isLoading: v,
1149
+ isError: B
1150
+ } = Ze({
1122
1151
  api: t,
1123
- filter: b,
1124
- offset: 0,
1125
- pageSize: Pn,
1126
- enabled: !!s
1127
- }), m = K(null);
1128
- V(() => {
1152
+ courseId: y ?? void 0,
1153
+ learningObject: o,
1154
+ enabled: h
1155
+ }), F = fe(() => {
1156
+ const S = (b == null ? void 0 : b.notes) ?? [];
1157
+ return m ? S.filter((I) => I.reaction.includes(m)) : S;
1158
+ }, [b, m]), E = _(null);
1159
+ W(() => {
1129
1160
  if (!s) {
1130
- m.current = null;
1161
+ E.current = null;
1131
1162
  return;
1132
1163
  }
1133
- if (m.current === s) return;
1134
- const $ = (O == null ? void 0 : O.notes.findIndex((Q) => Q.id === s)) ?? -1;
1135
- if ($ === -1) return;
1136
- m.current = s;
1137
- const q = Math.floor($ / r) + 1;
1138
- q !== h && l({ type: "FOCUS_PAGE", payload: q });
1139
- }, [s, O, r, h]);
1140
- const E = (y == null ? void 0 : y.notes) ?? [], I = y == null ? void 0 : y.pageInfo, L = (I == null ? void 0 : I.totalNrOfPages) ?? void 0, F = s && O ? Math.ceil(O.notes.length / r) : void 0, z = L === void 0 && F === void 0 ? void 0 : Math.max(L ?? 0, F ?? 0);
1141
- V(() => {
1142
- l({ type: "SET_TOTAL_PAGES", payload: z });
1143
- }, [z]);
1144
- const B = Y(($) => {
1145
- l({ type: "SET_PAGE", payload: $ });
1146
- }, []), k = Y(() => {
1147
- l({
1164
+ if (E.current === s) return;
1165
+ const S = F.findIndex((P) => P.id === s);
1166
+ if (S === -1) return;
1167
+ E.current = s;
1168
+ const I = Math.floor(S / r) + 1;
1169
+ I !== g && a({ type: "FOCUS_PAGE", payload: I });
1170
+ }, [s, F, r, g]);
1171
+ const A = h ? F.slice(N, N + r) : (p == null ? void 0 : p.notes) ?? [], R = h ? v : G, k = h ? B : M, $ = h ? Math.max(1, Math.ceil(F.length / r)) : ((se = p == null ? void 0 : p.pageInfo) == null ? void 0 : se.totalNrOfPages) ?? void 0, Q = h ? { totalCount: F.length, totalNrOfPages: $ } : p == null ? void 0 : p.pageInfo;
1172
+ W(() => {
1173
+ a({ type: "SET_TOTAL_PAGES", payload: $ });
1174
+ }, [$]);
1175
+ const K = X((S) => {
1176
+ a({ type: "SET_PAGE", payload: S });
1177
+ }, []), V = X(() => {
1178
+ a({
1148
1179
  type: "INCREMENT_PAGE"
1149
1180
  /* IncrementPage */
1150
1181
  });
1151
- }, []), W = Y(() => {
1152
- l({
1182
+ }, []), ne = X(() => {
1183
+ a({
1153
1184
  type: "DECREMENT_PAGE"
1154
1185
  /* DecrementPage */
1155
1186
  });
1156
- }, []), X = Y(($) => {
1157
- l({ type: "SET_FILTER", payload: $ });
1158
- }, []), H = Y(($) => {
1159
- l({ type: "SET_COURSE_FILTER", payload: $ });
1187
+ }, []), U = X((S) => {
1188
+ a({ type: "SET_FILTER", payload: S });
1189
+ }, []), re = X((S) => {
1190
+ a({ type: "SET_COURSE_FILTER", payload: S });
1160
1191
  }, []);
1161
1192
  return {
1162
- notes: E,
1163
- pageInfo: I,
1164
- isLoading: N,
1165
- isError: _,
1166
- filter: g,
1167
- courseFilter: d,
1168
- currentPage: h,
1169
- totalPages: c,
1170
- setFilter: X,
1171
- setCourseFilter: H,
1172
- setPage: B,
1173
- fetchNextPage: k,
1174
- fetchPreviousPage: W
1193
+ notes: A,
1194
+ pageInfo: Q,
1195
+ isLoading: R,
1196
+ isError: k,
1197
+ filter: m,
1198
+ courseFilter: c,
1199
+ currentPage: g,
1200
+ totalPages: d,
1201
+ setFilter: U,
1202
+ setCourseFilter: re,
1203
+ setPage: K,
1204
+ fetchNextPage: V,
1205
+ fetchPreviousPage: ne
1175
1206
  };
1176
1207
  }
1177
- const Ee = "all";
1178
- function mo({ filter: t, setFilter: e }) {
1179
- const { translations: n } = Z(), o = ge(
1208
+ const Se = "all";
1209
+ function ho({ filter: t, setFilter: e }) {
1210
+ const { translations: n } = Y(), o = fe(
1180
1211
  () => [
1181
- { label: n.allNotes, value: Ee },
1182
- { label: n.important, value: x.IMPORTANT },
1183
- { label: n.unclear, value: x.CONFUSING }
1212
+ { label: n.allNotes, value: Se },
1213
+ { label: n.important, value: L.IMPORTANT },
1214
+ { label: n.unclear, value: L.CONFUSING }
1184
1215
  ],
1185
1216
  [n]
1186
- ), r = Y(
1187
- (a, { value: l }) => {
1188
- e(!l || l === Ee ? null : l);
1217
+ ), r = X(
1218
+ (l, { value: a }) => {
1219
+ e(!a || a === Se ? null : a);
1189
1220
  },
1190
1221
  [e]
1191
1222
  );
1192
1223
  return {
1193
- filterElement: ge(
1224
+ filterElement: fe(
1194
1225
  () => /* @__PURE__ */ i(
1195
1226
  Fe,
1196
1227
  {
1197
1228
  renderLabel: n.filter,
1198
- value: t ?? Ee,
1229
+ value: t ?? Se,
1199
1230
  onChange: r,
1200
- children: o.map((a) => /* @__PURE__ */ i(Fe.Option, { id: a.value, value: a.value, children: a.label }, a.value))
1231
+ children: o.map((l) => /* @__PURE__ */ i(Fe.Option, { id: l.value, value: l.value, children: l.label }, l.value))
1201
1232
  }
1202
1233
  ),
1203
1234
  [t, o, r, n.filter]
@@ -1206,62 +1237,73 @@ function mo({ filter: t, setFilter: e }) {
1206
1237
  handleReactionFilterChange: r
1207
1238
  };
1208
1239
  }
1209
- const Mn = ({ hasActiveFilter: t = !1 }) => {
1210
- const { translations: e } = Z(), n = t ? e.nothingHereYet : e.emptyStateHeading, o = t ? e.adjustFiltersOrCreate : e.emptyStateDescription;
1211
- return /* @__PURE__ */ i(j, { as: "div", textAlign: "center", children: /* @__PURE__ */ T(v, { direction: "column", alignItems: "center", gap: "small", children: [
1212
- !t && /* @__PURE__ */ i(ut, { size: "medium" }),
1213
- /* @__PURE__ */ i(pe, { level: "h3", children: n }),
1214
- /* @__PURE__ */ i(J, { color: "secondary", children: o })
1240
+ const Hn = ({ hasActiveFilter: t = !1 }) => {
1241
+ const { translations: e } = Y(), n = t ? e.nothingHereYet : e.emptyStateHeading, o = t ? e.adjustFiltersOrCreate : e.emptyStateDescription;
1242
+ return /* @__PURE__ */ i(q, { as: "div", textAlign: "center", children: /* @__PURE__ */ C(x, { direction: "column", alignItems: "center", gap: "small", children: [
1243
+ !t && /* @__PURE__ */ i(mt, { size: "medium" }),
1244
+ /* @__PURE__ */ i(Ne, { level: "h3", children: n }),
1245
+ /* @__PURE__ */ i(Z, { color: "secondary", children: o })
1215
1246
  ] }) });
1216
- }, Bn = {
1217
- [x.IMPORTANT]: {
1247
+ }, $n = {
1248
+ [L.IMPORTANT]: {
1218
1249
  color: "success",
1219
1250
  translationKey: "important",
1220
- icon: /* @__PURE__ */ i(we, { size: "x-small" })
1251
+ icon: /* @__PURE__ */ i(Re, { size: "x-small" })
1221
1252
  },
1222
- [x.CONFUSING]: {
1253
+ [L.CONFUSING]: {
1223
1254
  color: "danger",
1224
1255
  translationKey: "unclear",
1225
1256
  icon: /* @__PURE__ */ i(ke, { size: "x-small" })
1226
1257
  }
1227
- }, ot = ({ type: t, onTypeChange: e, renderAsMenuTrigger: n = !1 }) => {
1228
- const { translations: o } = Z(), r = Bn[t], s = o[r.translationKey], [a, l] = U(!1), g = K(null), d = K(null), h = Y(
1229
- (c) => {
1230
- e == null || e(c), l(!1);
1258
+ }, st = ({ type: t, onTypeChange: e, renderAsMenuTrigger: n = !1 }) => {
1259
+ const { translations: o } = Y(), r = $n[t], s = o[r.translationKey], [l, a] = j(!1), m = _(null), c = _(null), g = _(null), d = X(
1260
+ (y) => {
1261
+ e == null || e(y), a(!1);
1231
1262
  },
1232
1263
  [e]
1233
1264
  );
1234
- return V(() => {
1235
- if (!a) return;
1236
- const c = (p) => {
1237
- p.key === "Escape" && p.stopPropagation();
1238
- }, S = (p) => {
1239
- p.key === "Escape" && (p.stopPropagation(), l(!1));
1265
+ return W(() => {
1266
+ if (!l) return;
1267
+ const y = (h) => {
1268
+ h.key === "Escape" && h.stopPropagation();
1269
+ }, N = (h) => {
1270
+ var T;
1271
+ h.key === "Escape" && (h.stopPropagation(), a(!1), (T = g.current) == null || T.focus());
1240
1272
  };
1241
- return document.addEventListener("keydown", c, !0), document.addEventListener("keyup", S, !0), () => {
1242
- document.removeEventListener("keydown", c, !0), document.removeEventListener("keyup", S, !0);
1273
+ return document.addEventListener("keydown", y, !0), document.addEventListener("keyup", N, !0), () => {
1274
+ document.removeEventListener("keydown", y, !0), document.removeEventListener("keyup", N, !0);
1243
1275
  };
1244
- }, [a]), n && e ? /* @__PURE__ */ T(
1245
- ie,
1276
+ }, [l]), n && e ? /* @__PURE__ */ C(
1277
+ ae,
1246
1278
  {
1247
1279
  placement: "bottom start",
1248
- show: a,
1249
- onToggle: (c) => l(c),
1280
+ show: l,
1281
+ onToggle: (y) => a(y),
1250
1282
  shouldHideOnSelect: !0,
1251
1283
  shouldFocusTriggerOnClose: !0,
1252
- trigger: /* @__PURE__ */ i(Me, { color: r.color, renderIcon: r.icon, children: s }),
1284
+ trigger: /* @__PURE__ */ i(
1285
+ Me,
1286
+ {
1287
+ color: r.color,
1288
+ renderIcon: r.icon,
1289
+ elementRef: (y) => {
1290
+ g.current = y;
1291
+ },
1292
+ children: s
1293
+ }
1294
+ ),
1253
1295
  children: [
1254
- /* @__PURE__ */ T(ie.Item, { ref: g, onClick: () => h(x.CONFUSING), children: [
1296
+ /* @__PURE__ */ C(ae.Item, { ref: m, onClick: () => d(L.CONFUSING), children: [
1255
1297
  /* @__PURE__ */ i(ke, { size: "x-small" }),
1256
1298
  ` ${o.markUnclear}`
1257
1299
  ] }),
1258
- /* @__PURE__ */ T(ie.Item, { ref: d, onClick: () => h(x.IMPORTANT), children: [
1259
- /* @__PURE__ */ i(we, { size: "x-small" }),
1300
+ /* @__PURE__ */ C(ae.Item, { ref: c, onClick: () => d(L.IMPORTANT), children: [
1301
+ /* @__PURE__ */ i(Re, { size: "x-small" }),
1260
1302
  ` ${o.markImportant}`
1261
1303
  ] })
1262
1304
  ]
1263
1305
  }
1264
- ) : /* @__PURE__ */ i(j, { display: "inline-flex", children: /* @__PURE__ */ i(Me, { color: r.color, renderIcon: r.icon, children: s }) });
1306
+ ) : /* @__PURE__ */ i(q, { display: "inline-flex", children: /* @__PURE__ */ i(Me, { color: r.color, renderIcon: r.icon, children: s }) });
1265
1307
  };
1266
1308
  function Ge(t, e) {
1267
1309
  return (t instanceof Date ? t : new Date(t)).toLocaleString(e, {
@@ -1270,40 +1312,43 @@ function Ge(t, e) {
1270
1312
  day: "numeric"
1271
1313
  });
1272
1314
  }
1273
- const Hn = ({
1315
+ const jn = ({
1274
1316
  noteId: t,
1275
1317
  date: e,
1276
1318
  highlight: n,
1277
1319
  note: o,
1278
1320
  type: r,
1279
1321
  onClick: s,
1280
- onDelete: a,
1281
- onSaveNote: l,
1282
- onTypeChange: g,
1283
- isActive: d,
1284
- isPanelView: h = !1,
1285
- courseName: c,
1286
- locale: S,
1287
- highlightTheme: p,
1288
- renderLink: b,
1289
- href: y
1322
+ onDelete: l,
1323
+ onSaveNote: a,
1324
+ onTypeChange: m,
1325
+ isActive: c,
1326
+ isPanelView: g = !1,
1327
+ courseName: d,
1328
+ locale: y,
1329
+ highlightTheme: N,
1330
+ renderLink: h,
1331
+ href: T
1290
1332
  }) => {
1291
- const { translations: N } = Z(), [_, O] = U(!1), [m, E] = U(!1), [I, L] = U(o || ""), [F, z] = U(!1), B = K(null), k = Y((f) => {
1292
- B.current = f;
1293
- }, []), W = K(null), X = K(null), H = K(!1);
1294
- V(() => {
1295
- var f, w;
1296
- d && ((f = B.current) == null || f.scrollIntoView({ behavior: "smooth", block: "nearest" }), (w = B.current) == null || w.focus());
1297
- }, [d]), V(() => {
1298
- var f, w;
1299
- m ? (H.current = !0, (f = W.current) == null || f.focus()) : H.current && (H.current = !1, (w = X.current) == null || w.focus());
1300
- }, [m]);
1301
- const $ = r === x.IMPORTANT ? N.important : N.unclear, q = (f) => {
1333
+ const { translations: p } = Y(), [G, M] = j(!1), [b, v] = j(!1), [B, F] = j(o || ""), [E, A] = j(!1), R = _(null), k = X((f) => {
1334
+ R.current = f;
1335
+ }, []), $ = _(null), Q = _(null), K = _(!1), V = _(null), ne = _(null), U = _(!1);
1336
+ W(() => {
1337
+ var f, O;
1338
+ c && ((f = R.current) == null || f.scrollIntoView({ behavior: "smooth", block: "nearest" }), (O = R.current) == null || O.focus());
1339
+ }, [c]), W(() => {
1340
+ var f, O;
1341
+ b ? (K.current = !0, (f = $.current) == null || f.focus()) : K.current && (K.current = !1, (O = Q.current) == null || O.focus());
1342
+ }, [b]), W(() => {
1343
+ var f, O;
1344
+ E ? (f = ne.current) == null || f.focus() : U.current && (U.current = !1, (O = V.current) == null || O.focus());
1345
+ }, [E]);
1346
+ const re = r === L.IMPORTANT ? p.important : p.unclear, se = (f) => {
1302
1347
  f.key === "Enter" && (f.preventDefault(), s == null || s());
1303
- }, Q = [$, N.note];
1304
- n && Q.push(n), o && Q.push(o), e && Q.push(Ge(e, S)), c && Q.push(c);
1305
- const de = Q.join(", "), R = /* @__PURE__ */ T(
1306
- j,
1348
+ }, S = [re, p.note];
1349
+ n && S.push(n), o && S.push(o), e && S.push(Ge(e, y)), d && S.push(d);
1350
+ const I = S.join(", "), P = /* @__PURE__ */ C(
1351
+ q,
1307
1352
  {
1308
1353
  as: "div",
1309
1354
  height: "100%",
@@ -1311,151 +1356,155 @@ const Hn = ({
1311
1356
  borderRadius: "medium",
1312
1357
  padding: "small",
1313
1358
  position: "relative",
1314
- role: y || m ? void 0 : "button",
1315
- "aria-label": y ? void 0 : de,
1316
- "aria-pressed": y || m ? void 0 : d,
1317
- tabIndex: y || d ? -1 : 0,
1359
+ role: T ? void 0 : c || b ? "group" : "button",
1360
+ "aria-label": T ? void 0 : I,
1361
+ "aria-pressed": T || c || b ? void 0 : c,
1362
+ tabIndex: T || c ? -1 : 0,
1318
1363
  "data-testid": `note-card-${t}`,
1319
1364
  elementRef: k,
1320
- onClick: d ? void 0 : s,
1321
- onMouseEnter: () => O(!0),
1322
- onMouseLeave: () => O(!1),
1323
- onKeyDown: d ? void 0 : q,
1324
- cursor: m ? "default" : "pointer",
1365
+ onClick: c ? void 0 : s,
1366
+ onMouseEnter: () => M(!0),
1367
+ onMouseLeave: () => M(!1),
1368
+ onKeyDown: c ? void 0 : se,
1369
+ cursor: b ? "default" : "pointer",
1325
1370
  children: [
1326
- /* @__PURE__ */ T(v, { direction: "column", gap: "small", height: "100%", children: [
1371
+ /* @__PURE__ */ C(x, { direction: "column", gap: "small", height: "100%", children: [
1327
1372
  /* @__PURE__ */ i(
1328
- ot,
1373
+ st,
1329
1374
  {
1330
1375
  type: r,
1331
- onTypeChange: h && g ? (f) => g(t, f) : void 0,
1332
- renderAsMenuTrigger: h && !!g && !!d
1376
+ onTypeChange: g && m ? (f) => m(t, f) : void 0,
1377
+ renderAsMenuTrigger: g && !!m && !!c
1333
1378
  }
1334
1379
  ),
1335
- n ? /* @__PURE__ */ i("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: /* @__PURE__ */ i(J, { children: d && h ? /* @__PURE__ */ i(
1336
- Ce,
1380
+ n ? /* @__PURE__ */ i("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: /* @__PURE__ */ i(Z, { children: c && g ? /* @__PURE__ */ i(
1381
+ ve,
1337
1382
  {
1338
1383
  type: r,
1339
- isCardActive: !!d || _,
1340
- theme: p,
1384
+ isCardActive: !!c || G,
1385
+ theme: N,
1341
1386
  children: n
1342
1387
  }
1343
- ) : /* @__PURE__ */ i(Te, { maxLines: 3, truncate: "word", children: /* @__PURE__ */ i(
1344
- Ce,
1388
+ ) : /* @__PURE__ */ i(Ie, { maxLines: 3, truncate: "word", children: /* @__PURE__ */ i(
1389
+ ve,
1345
1390
  {
1346
1391
  type: r,
1347
- isCardActive: !!d || _,
1348
- theme: p,
1392
+ isCardActive: !!c || G,
1393
+ theme: N,
1349
1394
  children: n
1350
1395
  }
1351
- ) }) }) }) : /* @__PURE__ */ i(nt, {}),
1352
- /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ T(v, { direction: "column", gap: "small", height: "100%", children: [
1353
- m && h ? /* @__PURE__ */ T(v, { direction: "column", gap: "x-small", children: [
1396
+ ) }) }) }) : /* @__PURE__ */ i(rt, {}),
1397
+ /* @__PURE__ */ i(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ C(x, { direction: "column", gap: "small", height: "100%", children: [
1398
+ b && g ? /* @__PURE__ */ C(x, { direction: "column", gap: "x-small", margin: "xx-small", children: [
1354
1399
  /* @__PURE__ */ i(
1355
1400
  qe,
1356
1401
  {
1357
- label: /* @__PURE__ */ i(mt, { children: N.editNote }),
1358
- value: I,
1359
- onChange: (f) => L(f.target.value),
1360
- placeholder: N.addNoteOptional,
1402
+ label: /* @__PURE__ */ i(ht, { children: p.editNote }),
1403
+ value: B,
1404
+ onChange: (f) => F(f.target.value),
1405
+ placeholder: p.addNoteOptional,
1361
1406
  textareaRef: (f) => {
1362
- W.current = f;
1407
+ $.current = f;
1363
1408
  }
1364
1409
  }
1365
1410
  ),
1366
- /* @__PURE__ */ T(v, { gap: "xx-small", children: [
1367
- /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1368
- ee,
1411
+ /* @__PURE__ */ C(x, { gap: "xx-small", children: [
1412
+ /* @__PURE__ */ i(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1413
+ J,
1369
1414
  {
1370
1415
  display: "block",
1371
1416
  size: "small",
1372
1417
  "data-testid": `note-card-${t}-cancel`,
1373
1418
  onClick: () => {
1374
- L(o || ""), E(!1);
1419
+ F(o || ""), v(!1);
1375
1420
  },
1376
- children: N.cancel
1421
+ children: p.cancel
1377
1422
  }
1378
1423
  ) }),
1379
- /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1380
- ee,
1424
+ /* @__PURE__ */ i(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1425
+ J,
1381
1426
  {
1382
1427
  display: "block",
1383
1428
  color: "primary",
1384
1429
  size: "small",
1385
1430
  "data-testid": `note-card-${t}-save`,
1386
1431
  onClick: () => {
1387
- l == null || l(t, I.trim()), E(!1);
1432
+ a == null || a(t, B.trim()), v(!1);
1388
1433
  },
1389
- children: N.save
1434
+ children: p.save
1390
1435
  }
1391
1436
  ) })
1392
1437
  ] })
1393
- ] }) : o ? /* @__PURE__ */ i("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: d && h ? /* @__PURE__ */ T(J, { children: [
1438
+ ] }) : o ? /* @__PURE__ */ i("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: c && g ? /* @__PURE__ */ C(Z, { children: [
1394
1439
  o,
1395
1440
  " ",
1396
1441
  /* @__PURE__ */ i(
1397
- le,
1442
+ de,
1398
1443
  {
1399
1444
  size: "small",
1400
1445
  withBackground: !1,
1401
1446
  withBorder: !1,
1402
- margin: "0 0 0 xxx-small",
1403
- screenReaderLabel: N.editNote,
1447
+ margin: "xx-small 0 0 xxx-small",
1448
+ screenReaderLabel: p.editNote,
1404
1449
  "data-testid": `note-card-${t}-edit`,
1405
1450
  elementRef: (f) => {
1406
- X.current = f;
1451
+ Q.current = f;
1407
1452
  },
1408
1453
  onClick: (f) => {
1409
- f.stopPropagation(), E(!0);
1454
+ f.stopPropagation(), v(!0);
1410
1455
  },
1411
- children: /* @__PURE__ */ i(Se, {})
1456
+ children: /* @__PURE__ */ i(Te, {})
1412
1457
  }
1413
1458
  )
1414
- ] }) : /* @__PURE__ */ i(J, { children: /* @__PURE__ */ i(Te, { maxLines: 3, truncate: "word", children: o }) }) }) : h && d ? /* @__PURE__ */ i("div", { children: /* @__PURE__ */ T(J, { color: "secondary", children: [
1415
- N.addNotePrompt,
1459
+ ] }) : /* @__PURE__ */ i(Z, { children: /* @__PURE__ */ i(Ie, { maxLines: 3, truncate: "word", children: o }) }) }) : g && c ? /* @__PURE__ */ i("div", { children: /* @__PURE__ */ C(Z, { color: "secondary", children: [
1460
+ p.addNotePrompt,
1416
1461
  " ",
1417
1462
  /* @__PURE__ */ i(
1418
- le,
1463
+ de,
1419
1464
  {
1420
1465
  size: "small",
1421
1466
  withBackground: !1,
1422
1467
  withBorder: !1,
1423
- margin: "0 0 0 xxx-small",
1424
- screenReaderLabel: N.editNote,
1468
+ margin: "xx-small 0 0 xxx-small",
1469
+ screenReaderLabel: p.editNote,
1425
1470
  "data-testid": `note-card-${t}-edit`,
1426
1471
  elementRef: (f) => {
1427
- X.current = f;
1472
+ Q.current = f;
1428
1473
  },
1429
1474
  onClick: (f) => {
1430
- f.stopPropagation(), E(!0);
1475
+ f.stopPropagation(), v(!0);
1431
1476
  },
1432
- children: /* @__PURE__ */ i(Se, {})
1477
+ children: /* @__PURE__ */ i(Te, {})
1433
1478
  }
1434
1479
  )
1435
1480
  ] }) }) : null,
1436
- /* @__PURE__ */ T(v, { justifyItems: "space-between", alignItems: "center", margin: "auto 0 0 0", children: [
1437
- /* @__PURE__ */ i(J, { size: "small", color: "secondary", children: Ge(e, S) }),
1438
- d && a && /* @__PURE__ */ i(
1439
- le,
1481
+ /* @__PURE__ */ C(x, { justifyItems: "space-between", alignItems: "center", margin: "auto 0 0 0", children: [
1482
+ /* @__PURE__ */ i(Z, { size: "small", color: "secondary", children: Ge(e, y) }),
1483
+ c && l && /* @__PURE__ */ i(
1484
+ de,
1440
1485
  {
1441
1486
  size: "small",
1442
1487
  withBackground: !1,
1443
1488
  withBorder: !1,
1444
1489
  color: "danger",
1445
- screenReaderLabel: N.deleteNote,
1490
+ margin: "xx-small",
1491
+ screenReaderLabel: p.deleteNote,
1446
1492
  "data-testid": `note-card-${t}-delete`,
1493
+ elementRef: (f) => {
1494
+ V.current = f;
1495
+ },
1447
1496
  onClick: (f) => {
1448
- f.stopPropagation(), z(!0);
1497
+ f.stopPropagation(), A(!0);
1449
1498
  },
1450
- children: /* @__PURE__ */ i(he, {})
1499
+ children: /* @__PURE__ */ i(pe, {})
1451
1500
  }
1452
1501
  )
1453
1502
  ] }),
1454
- c && /* @__PURE__ */ i(J, { size: "small", color: "secondary", children: c })
1503
+ d && /* @__PURE__ */ i(Z, { size: "small", color: "secondary", children: d })
1455
1504
  ] }) })
1456
1505
  ] }),
1457
- F && a && /* @__PURE__ */ i(
1458
- j,
1506
+ E && l && /* @__PURE__ */ i(
1507
+ q,
1459
1508
  {
1460
1509
  as: "div",
1461
1510
  background: "primary",
@@ -1467,8 +1516,8 @@ const Hn = ({
1467
1516
  insetInlineStart: "0",
1468
1517
  insetInlineEnd: "0",
1469
1518
  stacking: "above",
1470
- children: /* @__PURE__ */ T(
1471
- v,
1519
+ children: /* @__PURE__ */ C(
1520
+ x,
1472
1521
  {
1473
1522
  direction: "column",
1474
1523
  justifyItems: "center",
@@ -1477,29 +1526,32 @@ const Hn = ({
1477
1526
  height: "100%",
1478
1527
  children: [
1479
1528
  /* @__PURE__ */ i(
1480
- ee,
1529
+ J,
1481
1530
  {
1482
1531
  display: "block",
1483
1532
  color: "danger",
1484
1533
  size: "small",
1485
- renderIcon: /* @__PURE__ */ i(he, {}),
1534
+ renderIcon: /* @__PURE__ */ i(pe, {}),
1486
1535
  "data-testid": `note-card-${t}-confirm-delete`,
1536
+ elementRef: (f) => {
1537
+ ne.current = f;
1538
+ },
1487
1539
  onClick: (f) => {
1488
- f.stopPropagation(), a(t), z(!1);
1540
+ f.stopPropagation(), l(t), A(!1);
1489
1541
  },
1490
- children: N.deleteNote
1542
+ children: p.deleteNote
1491
1543
  }
1492
1544
  ),
1493
1545
  /* @__PURE__ */ i(
1494
- ee,
1546
+ J,
1495
1547
  {
1496
1548
  display: "block",
1497
1549
  size: "small",
1498
1550
  "data-testid": `note-card-${t}-cancel-delete`,
1499
1551
  onClick: (f) => {
1500
- f.stopPropagation(), z(!1);
1552
+ f.stopPropagation(), U.current = !0, A(!1);
1501
1553
  },
1502
- children: N.cancel
1554
+ children: p.cancel
1503
1555
  }
1504
1556
  )
1505
1557
  ]
@@ -1510,8 +1562,8 @@ const Hn = ({
1510
1562
  ]
1511
1563
  }
1512
1564
  );
1513
- return y && b ? b({ href: y, children: R, ariaLabel: de }) : R;
1514
- }, $n = {
1565
+ return T && h ? h({ href: T, children: P, ariaLabel: I }) : P;
1566
+ }, Gn = {
1515
1567
  display: "grid",
1516
1568
  gap: "1rem",
1517
1569
  boxSizing: "border-box",
@@ -1519,197 +1571,218 @@ const Hn = ({
1519
1571
  margin: 0,
1520
1572
  padding: 0,
1521
1573
  listStyle: "none"
1522
- }, go = ({
1574
+ }, po = ({
1523
1575
  notes: t,
1524
1576
  isLoading: e,
1525
1577
  isError: n,
1526
1578
  currentPage: o,
1527
1579
  totalPages: r,
1528
1580
  onPageChange: s,
1529
- onNoteSelect: a,
1530
- onNoteDelete: l,
1531
- onNoteSave: g,
1532
- onNoteTypeChange: d,
1533
- selectedNoteId: h,
1534
- hasActiveFilter: c = !1,
1535
- columnCount: S = 1,
1536
- highlightTheme: p,
1537
- locale: b,
1538
- renderNoteLink: y,
1539
- noteHref: N
1581
+ onNoteSelect: l,
1582
+ onNoteDelete: a,
1583
+ onNoteSave: m,
1584
+ onNoteTypeChange: c,
1585
+ onNotesEmptied: g,
1586
+ selectedNoteId: d,
1587
+ hasActiveFilter: y = !1,
1588
+ columnCount: N = 1,
1589
+ highlightTheme: h,
1590
+ locale: T,
1591
+ renderNoteLink: p,
1592
+ noteHref: G
1540
1593
  }) => {
1541
- const { translations: _ } = Z();
1542
- if (e)
1543
- return /* @__PURE__ */ i(j, { as: "div", textAlign: "center", padding: "large", "data-testid": "notes-loading", children: /* @__PURE__ */ i(ht, { renderTitle: _.loadingNotes }) });
1594
+ const { translations: M } = Y(), b = _(null), v = _(null), B = X(
1595
+ (E) => {
1596
+ const A = t.findIndex((k) => k.id === E);
1597
+ let R = null;
1598
+ t.length > 1 && (R = A > 0 ? t[A - 1].id : t[1].id), v.current = { targetId: R }, a == null || a(E);
1599
+ },
1600
+ [t, a]
1601
+ );
1602
+ if (W(() => {
1603
+ var A;
1604
+ const E = v.current;
1605
+ if (E)
1606
+ if (v.current = null, E.targetId === null)
1607
+ g == null || g();
1608
+ else {
1609
+ const R = (A = b.current) == null ? void 0 : A.querySelector(
1610
+ `[data-testid="note-card-${E.targetId}"]`
1611
+ );
1612
+ R == null || R.focus();
1613
+ }
1614
+ }, [t, g]), e)
1615
+ return /* @__PURE__ */ i(q, { as: "div", textAlign: "center", padding: "large", "data-testid": "notes-loading", children: /* @__PURE__ */ i(Nt, { renderTitle: M.loadingNotes }) });
1544
1616
  if (n)
1545
- return /* @__PURE__ */ i(j, { as: "div", textAlign: "center", padding: "large", "data-testid": "notes-error", children: /* @__PURE__ */ i(pe, { level: "h4", children: _.failedToLoadNotes }) });
1617
+ return /* @__PURE__ */ i(q, { as: "div", textAlign: "center", padding: "large", "data-testid": "notes-error", children: /* @__PURE__ */ i(Ne, { level: "h4", children: M.failedToLoadNotes }) });
1546
1618
  if (t.length === 0)
1547
- return /* @__PURE__ */ i(j, { as: "div", padding: "large", "data-testid": "empty-notes", children: /* @__PURE__ */ i(Mn, { hasActiveFilter: c }) });
1548
- const O = typeof o == "number" && typeof r == "number" && r > 1 && s !== void 0;
1549
- return /* @__PURE__ */ T(rt, { children: [
1619
+ return /* @__PURE__ */ i(q, { as: "div", padding: "large", "data-testid": "empty-notes", children: /* @__PURE__ */ i(Hn, { hasActiveFilter: y }) });
1620
+ const F = typeof o == "number" && typeof r == "number" && r > 1 && s !== void 0;
1621
+ return /* @__PURE__ */ C(it, { children: [
1550
1622
  /* @__PURE__ */ i(
1551
1623
  "ul",
1552
1624
  {
1553
- style: { ...$n, gridTemplateColumns: `repeat(${S}, minmax(0, 1fr))` },
1625
+ ref: b,
1626
+ style: { ...Gn, gridTemplateColumns: `repeat(${N}, minmax(0, 1fr))` },
1554
1627
  role: "list",
1555
1628
  "data-testid": "notes-grid",
1556
- children: t.map((m) => {
1557
- var E;
1629
+ children: t.map((E) => {
1630
+ var A;
1558
1631
  return /* @__PURE__ */ i("li", { children: /* @__PURE__ */ i(
1559
- Hn,
1632
+ jn,
1560
1633
  {
1561
- noteId: m.id,
1562
- date: m.createdAt,
1563
- type: m.reaction[0] ?? x.IMPORTANT,
1564
- highlight: (E = m.highlightData) == null ? void 0 : E.selectedText,
1565
- note: m.userText,
1566
- isActive: h === m.id,
1567
- isPanelView: !!h,
1568
- onClick: a ? () => a(m.id) : void 0,
1569
- onDelete: l ? (I) => l(I) : void 0,
1570
- onSaveNote: g ? (I, L) => g(I, L) : void 0,
1571
- onTypeChange: d ? (I, L) => d(I, L) : void 0,
1572
- highlightTheme: p,
1573
- locale: b,
1574
- renderLink: y,
1575
- href: N ? N(m.id, m) : void 0
1634
+ noteId: E.id,
1635
+ date: E.createdAt,
1636
+ type: E.reaction[0] ?? L.IMPORTANT,
1637
+ highlight: (A = E.highlightData) == null ? void 0 : A.selectedText,
1638
+ note: E.userText,
1639
+ isActive: d === E.id,
1640
+ isPanelView: !!d,
1641
+ onClick: l ? () => l(E.id) : void 0,
1642
+ onDelete: a ? B : void 0,
1643
+ onSaveNote: m ? (R, k) => m(R, k) : void 0,
1644
+ onTypeChange: c ? (R, k) => c(R, k) : void 0,
1645
+ highlightTheme: h,
1646
+ locale: T,
1647
+ renderLink: p,
1648
+ href: G ? G(E.id, E) : void 0
1576
1649
  }
1577
- ) }, m.id);
1650
+ ) }, E.id);
1578
1651
  })
1579
1652
  }
1580
1653
  ),
1581
- O && /* @__PURE__ */ i(v, { justifyItems: "center", padding: "small", "data-testid": "notes-pagination", children: /* @__PURE__ */ i(v.Item, { children: /* @__PURE__ */ i(
1582
- gt,
1654
+ F && /* @__PURE__ */ i(x, { justifyItems: "center", padding: "small", "data-testid": "notes-pagination", children: /* @__PURE__ */ i(x.Item, { children: /* @__PURE__ */ i(
1655
+ pt,
1583
1656
  {
1584
1657
  as: "nav",
1585
1658
  variant: "input",
1586
- labelNext: _.nextPage,
1587
- labelPrev: _.previousPage,
1659
+ labelNext: M.nextPage,
1660
+ labelPrev: M.previousPage,
1588
1661
  currentPage: o,
1589
1662
  totalPageNumber: r,
1590
1663
  onPageChange: s
1591
1664
  }
1592
1665
  ) }) })
1593
1666
  ] });
1594
- }, ho = ({
1667
+ }, No = ({
1595
1668
  noteText: t,
1596
1669
  reaction: e,
1597
1670
  highlightText: n,
1598
1671
  highlightTheme: o,
1599
1672
  onSave: r,
1600
1673
  onDelete: s,
1601
- onTypeChange: a,
1602
- onBack: l,
1603
- editing: g = !1
1674
+ onTypeChange: l,
1675
+ onBack: a,
1676
+ editing: m = !1
1604
1677
  }) => {
1605
- const { translations: d } = Z(), [h, c] = U(g), [S, p] = U(t || ""), [b, y] = U(!1);
1606
- return /* @__PURE__ */ T(v, { direction: "column", gap: "small", "data-testid": "single-note", children: [
1607
- n != null ? /* @__PURE__ */ i(j, { as: "div", children: /* @__PURE__ */ i(J, { children: /* @__PURE__ */ i(Ce, { type: e, isCardActive: !0, theme: o, children: n }) }) }) : /* @__PURE__ */ i(nt, {}),
1608
- /* @__PURE__ */ i(ot, { type: e, onTypeChange: a, renderAsMenuTrigger: !!a }),
1609
- h ? /* @__PURE__ */ T(v, { direction: "column", gap: "x-small", children: [
1678
+ const { translations: c } = Y(), [g, d] = j(m), [y, N] = j(t || ""), [h, T] = j(!1);
1679
+ return /* @__PURE__ */ C(x, { direction: "column", gap: "small", "data-testid": "single-note", children: [
1680
+ n != null ? /* @__PURE__ */ i(q, { as: "div", children: /* @__PURE__ */ i(Z, { children: /* @__PURE__ */ i(ve, { type: e, isCardActive: !0, theme: o, children: n }) }) }) : /* @__PURE__ */ i(rt, {}),
1681
+ /* @__PURE__ */ i(st, { type: e, onTypeChange: l, renderAsMenuTrigger: !!l }),
1682
+ g ? /* @__PURE__ */ C(x, { direction: "column", gap: "x-small", children: [
1610
1683
  /* @__PURE__ */ i(
1611
1684
  qe,
1612
1685
  {
1613
- label: d.addNoteOptional,
1614
- value: S,
1615
- onChange: (N) => p(N.target.value),
1686
+ label: c.addNoteOptional,
1687
+ value: y,
1688
+ onChange: (p) => N(p.target.value),
1616
1689
  resize: "vertical"
1617
1690
  }
1618
1691
  ),
1619
- /* @__PURE__ */ T(v, { gap: "xx-small", children: [
1620
- /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1621
- ee,
1692
+ /* @__PURE__ */ C(x, { gap: "xx-small", children: [
1693
+ /* @__PURE__ */ i(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1694
+ J,
1622
1695
  {
1623
1696
  display: "block",
1624
1697
  size: "small",
1625
1698
  "data-testid": "single-note-cancel",
1626
1699
  onClick: () => {
1627
- p(t || ""), c(!1);
1700
+ N(t || ""), d(!1);
1628
1701
  },
1629
- children: d.cancel
1702
+ children: c.cancel
1630
1703
  }
1631
1704
  ) }),
1632
- /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1633
- ee,
1705
+ /* @__PURE__ */ i(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1706
+ J,
1634
1707
  {
1635
1708
  display: "block",
1636
1709
  color: "primary",
1637
1710
  size: "small",
1638
1711
  "data-testid": "single-note-save",
1639
1712
  onClick: () => {
1640
- r(S), c(!1);
1713
+ r(y), d(!1);
1641
1714
  },
1642
- children: d.save
1715
+ children: c.save
1643
1716
  }
1644
1717
  ) })
1645
1718
  ] })
1646
- ] }) : /* @__PURE__ */ T(v, { direction: "column", gap: "small", children: [
1647
- t && /* @__PURE__ */ T(j, { as: "div", children: [
1648
- /* @__PURE__ */ i(pe, { level: "h4", margin: "0 0 xx-small 0", children: d.note }),
1649
- /* @__PURE__ */ i(J, { children: t })
1719
+ ] }) : /* @__PURE__ */ C(x, { direction: "column", gap: "small", children: [
1720
+ t && /* @__PURE__ */ C(q, { as: "div", children: [
1721
+ /* @__PURE__ */ i(Ne, { level: "h4", margin: "0 0 xx-small 0", children: c.note }),
1722
+ /* @__PURE__ */ i(Z, { children: t })
1650
1723
  ] }),
1651
- /* @__PURE__ */ T(v, { justifyItems: "space-between", children: [
1724
+ /* @__PURE__ */ C(x, { justifyItems: "space-between", children: [
1652
1725
  /* @__PURE__ */ i(
1653
- ee,
1726
+ J,
1654
1727
  {
1655
1728
  size: "small",
1656
- renderIcon: /* @__PURE__ */ i(ft, {}),
1729
+ renderIcon: /* @__PURE__ */ i(gt, {}),
1657
1730
  "data-testid": "single-note-back",
1658
- onClick: () => l == null ? void 0 : l(),
1659
- children: d.back
1731
+ onClick: () => a == null ? void 0 : a(),
1732
+ children: c.back
1660
1733
  }
1661
1734
  ),
1662
- /* @__PURE__ */ T(v, { gap: "xx-small", children: [
1735
+ /* @__PURE__ */ C(x, { gap: "xx-small", children: [
1663
1736
  s && /* @__PURE__ */ i(
1664
- le,
1737
+ de,
1665
1738
  {
1666
1739
  size: "small",
1667
1740
  withBackground: !1,
1668
1741
  withBorder: !1,
1669
1742
  color: "danger",
1670
- screenReaderLabel: d.deleteNote,
1743
+ screenReaderLabel: c.deleteNote,
1671
1744
  "data-testid": "single-note-delete",
1672
- onClick: () => y(!0),
1673
- children: /* @__PURE__ */ i(he, {})
1745
+ onClick: () => T(!0),
1746
+ children: /* @__PURE__ */ i(pe, {})
1674
1747
  }
1675
1748
  ),
1676
1749
  /* @__PURE__ */ i(
1677
- le,
1750
+ de,
1678
1751
  {
1679
1752
  size: "small",
1680
1753
  withBackground: !1,
1681
1754
  withBorder: !1,
1682
- screenReaderLabel: d.editNote,
1755
+ screenReaderLabel: c.editNote,
1683
1756
  "data-testid": "single-note-edit",
1684
- onClick: () => c(!0),
1685
- children: /* @__PURE__ */ i(Se, {})
1757
+ onClick: () => d(!0),
1758
+ children: /* @__PURE__ */ i(Te, {})
1686
1759
  }
1687
1760
  )
1688
1761
  ] })
1689
1762
  ] }),
1690
- b && s && /* @__PURE__ */ i(j, { as: "div", background: "primary", padding: "medium", borderRadius: "large", children: /* @__PURE__ */ T(v, { direction: "column", justifyItems: "center", alignItems: "center", gap: "x-small", children: [
1763
+ h && s && /* @__PURE__ */ i(q, { as: "div", background: "primary", padding: "medium", borderRadius: "large", children: /* @__PURE__ */ C(x, { direction: "column", justifyItems: "center", alignItems: "center", gap: "x-small", children: [
1691
1764
  /* @__PURE__ */ i(
1692
- ee,
1765
+ J,
1693
1766
  {
1694
1767
  display: "block",
1695
1768
  color: "danger",
1696
1769
  size: "small",
1697
- renderIcon: /* @__PURE__ */ i(he, {}),
1770
+ renderIcon: /* @__PURE__ */ i(pe, {}),
1698
1771
  "data-testid": "single-note-confirm-delete",
1699
1772
  onClick: () => {
1700
- s(), y(!1);
1773
+ s(), T(!1);
1701
1774
  },
1702
- children: d.deleteNote
1775
+ children: c.deleteNote
1703
1776
  }
1704
1777
  ),
1705
1778
  /* @__PURE__ */ i(
1706
- ee,
1779
+ J,
1707
1780
  {
1708
1781
  display: "block",
1709
1782
  size: "small",
1710
1783
  "data-testid": "single-note-cancel-delete",
1711
- onClick: () => y(!1),
1712
- children: d.cancel
1784
+ onClick: () => T(!1),
1785
+ children: c.cancel
1713
1786
  }
1714
1787
  )
1715
1788
  ] }) })
@@ -1717,26 +1790,26 @@ const Hn = ({
1717
1790
  ] });
1718
1791
  };
1719
1792
  export {
1720
- uo as ContentWithNoteWrapper,
1721
- Ce as Highlight,
1722
- nt as HighlightError,
1723
- Hn as NoteCard,
1724
- ot as NoteChip,
1725
- Ln as NoteReactionMenu,
1726
- Mn as NotebookEmptyState,
1727
- lo as NotebookProvider,
1728
- On as NotebookTranslationsProvider,
1729
- co as NotebookTray,
1730
- go as NotesListView,
1731
- x as REACTION_TYPE,
1732
- ho as SingleNote,
1733
- Le as createTransparentColor,
1734
- Gt as useCreateNote,
1735
- jt as useDeleteNote,
1736
- ve as useGetNotes,
1737
- et as useNotebook,
1738
- Z as useNotebookTranslations,
1739
- fo as useNotesData,
1740
- mo as useReactionFilter,
1741
- zt as useUpdateNote
1793
+ mo as ContentWithNoteWrapper,
1794
+ ve as Highlight,
1795
+ rt as HighlightError,
1796
+ jn as NoteCard,
1797
+ st as NoteChip,
1798
+ _n as NoteReactionMenu,
1799
+ Hn as NotebookEmptyState,
1800
+ uo as NotebookProvider,
1801
+ An as NotebookTranslationsProvider,
1802
+ fo as NotebookTray,
1803
+ po as NotesListView,
1804
+ L as REACTION_TYPE,
1805
+ No as SingleNote,
1806
+ Ae as createTransparentColor,
1807
+ zt as useCreateNote,
1808
+ Wt as useDeleteNote,
1809
+ Ve as useGetNotes,
1810
+ nt as useNotebook,
1811
+ Y as useNotebookTranslations,
1812
+ go as useNotesData,
1813
+ ho as useReactionFilter,
1814
+ Kt as useUpdateNote
1742
1815
  };