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