@harvard-lts/mirador-citation-plugin 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/es/index.js +913 -370
  2. package/package.json +3 -3
package/dist/es/index.js CHANGED
@@ -8,17 +8,35 @@ import SanitizedHtml from 'mirador/dist/es/src/containers/SanitizedHtml';
8
8
  import { PluginHook } from 'mirador/dist/es/src/components/PluginHook';
9
9
  import ns from 'mirador/dist/es/src/config/css-ns';
10
10
  import List from '@material-ui/core/List';
11
+ import Typography from '@material-ui/core/Typography';
12
+ import Link from '@material-ui/core/Link';
11
13
  import ListItem from '@material-ui/core/ListItem';
12
14
  import ListItemText from '@material-ui/core/ListItemText';
13
- import Typography from '@material-ui/core/Typography';
14
- import { jsxs, jsx } from 'react/jsx-runtime';
15
+ import { jsx, jsxs } from 'react/jsx-runtime';
15
16
  import { withStyles } from '@material-ui/core/styles';
16
17
  import { withTranslation } from 'react-i18next';
17
- import { getManifestTitle } from 'mirador/dist/es/src/state/selectors';
18
+ import { getManifestUrl, getManifestTitle, getAnnotationResourcesByMotivation, getCanvases, getVisibleCanvases, getWindow, getSearchQuery, getCompanionWindowsForPosition, getManifestSearchService, getWindowConfig } from 'mirador/dist/es/src/state/selectors';
18
19
  import CitationIcon from '@material-ui/icons/FormatQuote';
19
- import Link from '@material-ui/core/Link';
20
+ import Icon from '@material-ui/core/Icon';
20
21
  import RelatedLinksIcon from '@material-ui/icons/Link';
22
+ import { withStyles as withStyles$1 } from '@material-ui/core';
23
+ import 'mirador/dist/es/src/extend/withPlugins';
24
+ import * as actions from 'mirador/dist/es/src/state/actions';
25
+ import MiradorCanvas from 'mirador/dist/es/src/lib/MiradorCanvas';
26
+ import Badge from '@material-ui/core/Badge';
27
+ import Tabs from '@material-ui/core/Tabs';
28
+ import Tab from '@material-ui/core/Tab';
29
+ import Tooltip from '@material-ui/core/Tooltip';
30
+ import InfoIcon from '@material-ui/icons/InfoSharp';
31
+ import AnnotationIcon from '@material-ui/icons/CommentSharp';
32
+ import AttributionIcon from '@material-ui/icons/CopyrightSharp';
33
+ import LayersIcon from '@material-ui/icons/LayersSharp';
34
+ import SearchIcon from '@material-ui/icons/SearchSharp';
35
+ import CanvasIndexIcon from 'mirador/dist/es/src/components/icons/CanvasIndexIcon';
21
36
 
37
+ function _OverloadYield(e, d) {
38
+ this.v = e, this.k = d;
39
+ }
22
40
  function _assertThisInitialized(e) {
23
41
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24
42
  return e;
@@ -124,306 +142,178 @@ function _possibleConstructorReturn(t, e) {
124
142
  if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
125
143
  return _assertThisInitialized(t);
126
144
  }
127
- function _regeneratorRuntime() {
128
- _regeneratorRuntime = function () {
129
- return e;
130
- };
131
- var t,
132
- e = {},
133
- r = Object.prototype,
134
- n = r.hasOwnProperty,
135
- o = Object.defineProperty || function (t, e, r) {
136
- t[e] = r.value;
137
- },
138
- i = "function" == typeof Symbol ? Symbol : {},
139
- a = i.iterator || "@@iterator",
140
- c = i.asyncIterator || "@@asyncIterator",
141
- u = i.toStringTag || "@@toStringTag";
142
- function define(t, e, r) {
143
- return Object.defineProperty(t, e, {
144
- value: r,
145
- enumerable: !0,
146
- configurable: !0,
147
- writable: !0
148
- }), t[e];
149
- }
150
- try {
151
- define({}, "");
152
- } catch (t) {
153
- define = function (t, e, r) {
154
- return t[e] = r;
155
- };
156
- }
157
- function wrap(t, e, r, n) {
158
- var i = e && e.prototype instanceof Generator ? e : Generator,
159
- a = Object.create(i.prototype),
160
- c = new Context(n || []);
161
- return o(a, "_invoke", {
162
- value: makeInvokeMethod(t, r, c)
163
- }), a;
164
- }
165
- function tryCatch(t, e, r) {
166
- try {
167
- return {
168
- type: "normal",
169
- arg: t.call(e, r)
170
- };
171
- } catch (t) {
172
- return {
173
- type: "throw",
174
- arg: t
145
+ function _regenerator() {
146
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
147
+ var e,
148
+ t,
149
+ r = "function" == typeof Symbol ? Symbol : {},
150
+ n = r.iterator || "@@iterator",
151
+ o = r.toStringTag || "@@toStringTag";
152
+ function i(r, n, o, i) {
153
+ var c = n && n.prototype instanceof Generator ? n : Generator,
154
+ u = Object.create(c.prototype);
155
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
156
+ var i,
157
+ c,
158
+ u,
159
+ f = 0,
160
+ p = o || [],
161
+ y = !1,
162
+ G = {
163
+ p: 0,
164
+ n: 0,
165
+ v: e,
166
+ a: d,
167
+ f: d.bind(e, 4),
168
+ d: function (t, r) {
169
+ return i = t, c = 0, u = e, G.n = r, a;
170
+ }
171
+ };
172
+ function d(r, n) {
173
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
174
+ var o,
175
+ i = p[t],
176
+ d = G.p,
177
+ l = i[2];
178
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
179
+ }
180
+ if (o || r > 1) return a;
181
+ throw y = !0, n;
182
+ }
183
+ return function (o, p, l) {
184
+ if (f > 1) throw TypeError("Generator is already running");
185
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
186
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
187
+ try {
188
+ if (f = 2, i) {
189
+ if (c || (o = "next"), t = i[o]) {
190
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
191
+ if (!t.done) return t;
192
+ u = t.value, c < 2 && (c = 0);
193
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
194
+ i = e;
195
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
196
+ } catch (t) {
197
+ i = e, c = 1, u = t;
198
+ } finally {
199
+ f = 1;
200
+ }
201
+ }
202
+ return {
203
+ value: t,
204
+ done: y
205
+ };
175
206
  };
176
- }
207
+ }(r, o, i), !0), u;
177
208
  }
178
- e.wrap = wrap;
179
- var h = "suspendedStart",
180
- l = "suspendedYield",
181
- f = "executing",
182
- s = "completed",
183
- y = {};
209
+ var a = {};
184
210
  function Generator() {}
185
211
  function GeneratorFunction() {}
186
212
  function GeneratorFunctionPrototype() {}
187
- var p = {};
188
- define(p, a, function () {
213
+ t = Object.getPrototypeOf;
214
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
215
+ return this;
216
+ }), t),
217
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
218
+ function f(e) {
219
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
220
+ }
221
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
189
222
  return this;
223
+ }), _regeneratorDefine(u, "toString", function () {
224
+ return "[object Generator]";
225
+ }), (_regenerator = function () {
226
+ return {
227
+ w: i,
228
+ m: f
229
+ };
230
+ })();
231
+ }
232
+ function _regeneratorAsync(n, e, r, t, o) {
233
+ var a = _regeneratorAsyncGen(n, e, r, t, o);
234
+ return a.next().then(function (n) {
235
+ return n.done ? n.value : a.next();
190
236
  });
191
- var d = Object.getPrototypeOf,
192
- v = d && d(d(values([])));
193
- v && v !== r && n.call(v, a) && (p = v);
194
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
195
- function defineIteratorMethods(t) {
196
- ["next", "throw", "return"].forEach(function (e) {
197
- define(t, e, function (t) {
198
- return this._invoke(e, t);
237
+ }
238
+ function _regeneratorAsyncGen(r, e, t, o, n) {
239
+ return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
240
+ }
241
+ function _regeneratorAsyncIterator(t, e) {
242
+ function n(r, o, i, f) {
243
+ try {
244
+ var c = t[r](o),
245
+ u = c.value;
246
+ return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
247
+ n("next", t, i, f);
248
+ }, function (t) {
249
+ n("throw", t, i, f);
250
+ }) : e.resolve(u).then(function (t) {
251
+ c.value = t, i(c);
252
+ }, function (t) {
253
+ return n("throw", t, i, f);
199
254
  });
200
- });
255
+ } catch (t) {
256
+ f(t);
257
+ }
201
258
  }
202
- function AsyncIterator(t, e) {
203
- function invoke(r, o, i, a) {
204
- var c = tryCatch(t[r], t, o);
205
- if ("throw" !== c.type) {
206
- var u = c.arg,
207
- h = u.value;
208
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
209
- invoke("next", t, i, a);
210
- }, function (t) {
211
- invoke("throw", t, i, a);
212
- }) : e.resolve(h).then(function (t) {
213
- u.value = t, i(u);
214
- }, function (t) {
215
- return invoke("throw", t, i, a);
216
- });
217
- }
218
- a(c.arg);
259
+ var r;
260
+ this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
261
+ return this;
262
+ })), _regeneratorDefine(this, "_invoke", function (t, o, i) {
263
+ function f() {
264
+ return new e(function (e, r) {
265
+ n(t, i, e, r);
266
+ });
219
267
  }
220
- var r;
221
- o(this, "_invoke", {
222
- value: function (t, n) {
223
- function callInvokeWithMethodAndArg() {
224
- return new e(function (e, r) {
225
- invoke(t, n, e, r);
226
- });
227
- }
228
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
229
- }
230
- });
268
+ return r = r ? r.then(f, f) : f();
269
+ }, !0);
270
+ }
271
+ function _regeneratorDefine(e, r, n, t) {
272
+ var i = Object.defineProperty;
273
+ try {
274
+ i({}, "", {});
275
+ } catch (e) {
276
+ i = 0;
231
277
  }
232
- function makeInvokeMethod(e, r, n) {
233
- var o = h;
234
- return function (i, a) {
235
- if (o === f) throw Error("Generator is already running");
236
- if (o === s) {
237
- if ("throw" === i) throw a;
238
- return {
239
- value: t,
240
- done: !0
278
+ _regeneratorDefine = function (e, r, n, t) {
279
+ function o(r, n) {
280
+ _regeneratorDefine(e, r, function (e) {
281
+ return this._invoke(r, n, e);
282
+ });
283
+ }
284
+ r ? i ? i(e, r, {
285
+ value: n,
286
+ enumerable: !t,
287
+ configurable: !t,
288
+ writable: !t
289
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
290
+ }, _regeneratorDefine(e, r, n, t);
291
+ }
292
+ function _regeneratorKeys(e) {
293
+ var n = Object(e),
294
+ r = [];
295
+ for (var t in n) r.unshift(t);
296
+ return function e() {
297
+ for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
298
+ return e.done = !0, e;
299
+ };
300
+ }
301
+ function _regeneratorValues(e) {
302
+ if (null != e) {
303
+ var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
304
+ r = 0;
305
+ if (t) return t.call(e);
306
+ if ("function" == typeof e.next) return e;
307
+ if (!isNaN(e.length)) return {
308
+ next: function () {
309
+ return e && r >= e.length && (e = void 0), {
310
+ value: e && e[r++],
311
+ done: !e
241
312
  };
242
313
  }
243
- for (n.method = i, n.arg = a;;) {
244
- var c = n.delegate;
245
- if (c) {
246
- var u = maybeInvokeDelegate(c, n);
247
- if (u) {
248
- if (u === y) continue;
249
- return u;
250
- }
251
- }
252
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
253
- if (o === h) throw o = s, n.arg;
254
- n.dispatchException(n.arg);
255
- } else "return" === n.method && n.abrupt("return", n.arg);
256
- o = f;
257
- var p = tryCatch(e, r, n);
258
- if ("normal" === p.type) {
259
- if (o = n.done ? s : l, p.arg === y) continue;
260
- return {
261
- value: p.arg,
262
- done: n.done
263
- };
264
- }
265
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
266
- }
267
- };
268
- }
269
- function maybeInvokeDelegate(e, r) {
270
- var n = r.method,
271
- o = e.iterator[n];
272
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
273
- var i = tryCatch(o, e.iterator, r.arg);
274
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
275
- var a = i.arg;
276
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
277
- }
278
- function pushTryEntry(t) {
279
- var e = {
280
- tryLoc: t[0]
281
314
  };
282
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
283
- }
284
- function resetTryEntry(t) {
285
- var e = t.completion || {};
286
- e.type = "normal", delete e.arg, t.completion = e;
287
- }
288
- function Context(t) {
289
- this.tryEntries = [{
290
- tryLoc: "root"
291
- }], t.forEach(pushTryEntry, this), this.reset(!0);
292
315
  }
293
- function values(e) {
294
- if (e || "" === e) {
295
- var r = e[a];
296
- if (r) return r.call(e);
297
- if ("function" == typeof e.next) return e;
298
- if (!isNaN(e.length)) {
299
- var o = -1,
300
- i = function next() {
301
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
302
- return next.value = t, next.done = !0, next;
303
- };
304
- return i.next = i;
305
- }
306
- }
307
- throw new TypeError(typeof e + " is not iterable");
308
- }
309
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
310
- value: GeneratorFunctionPrototype,
311
- configurable: !0
312
- }), o(GeneratorFunctionPrototype, "constructor", {
313
- value: GeneratorFunction,
314
- configurable: !0
315
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
316
- var e = "function" == typeof t && t.constructor;
317
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
318
- }, e.mark = function (t) {
319
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
320
- }, e.awrap = function (t) {
321
- return {
322
- __await: t
323
- };
324
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
325
- return this;
326
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
327
- void 0 === i && (i = Promise);
328
- var a = new AsyncIterator(wrap(t, r, n, o), i);
329
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
330
- return t.done ? t.value : a.next();
331
- });
332
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
333
- return this;
334
- }), define(g, "toString", function () {
335
- return "[object Generator]";
336
- }), e.keys = function (t) {
337
- var e = Object(t),
338
- r = [];
339
- for (var n in e) r.push(n);
340
- return r.reverse(), function next() {
341
- for (; r.length;) {
342
- var t = r.pop();
343
- if (t in e) return next.value = t, next.done = !1, next;
344
- }
345
- return next.done = !0, next;
346
- };
347
- }, e.values = values, Context.prototype = {
348
- constructor: Context,
349
- reset: function (e) {
350
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
351
- },
352
- stop: function () {
353
- this.done = !0;
354
- var t = this.tryEntries[0].completion;
355
- if ("throw" === t.type) throw t.arg;
356
- return this.rval;
357
- },
358
- dispatchException: function (e) {
359
- if (this.done) throw e;
360
- var r = this;
361
- function handle(n, o) {
362
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
363
- }
364
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
365
- var i = this.tryEntries[o],
366
- a = i.completion;
367
- if ("root" === i.tryLoc) return handle("end");
368
- if (i.tryLoc <= this.prev) {
369
- var c = n.call(i, "catchLoc"),
370
- u = n.call(i, "finallyLoc");
371
- if (c && u) {
372
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
373
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
374
- } else if (c) {
375
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
376
- } else {
377
- if (!u) throw Error("try statement without catch or finally");
378
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
379
- }
380
- }
381
- }
382
- },
383
- abrupt: function (t, e) {
384
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
385
- var o = this.tryEntries[r];
386
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
387
- var i = o;
388
- break;
389
- }
390
- }
391
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
392
- var a = i ? i.completion : {};
393
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
394
- },
395
- complete: function (t, e) {
396
- if ("throw" === t.type) throw t.arg;
397
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
398
- },
399
- finish: function (t) {
400
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
401
- var r = this.tryEntries[e];
402
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
403
- }
404
- },
405
- catch: function (t) {
406
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
407
- var r = this.tryEntries[e];
408
- if (r.tryLoc === t) {
409
- var n = r.completion;
410
- if ("throw" === n.type) {
411
- var o = n.arg;
412
- resetTryEntry(r);
413
- }
414
- return o;
415
- }
416
- }
417
- throw Error("illegal catch attempt");
418
- },
419
- delegateYield: function (e, r, n) {
420
- return this.delegate = {
421
- iterator: values(e),
422
- resultName: r,
423
- nextLoc: n
424
- }, "next" === this.method && (this.arg = t), y;
425
- }
426
- }, e;
316
+ throw new TypeError(typeof e + " is not iterable");
427
317
  }
428
318
  function _setPrototypeOf(t, e) {
429
319
  return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
@@ -444,6 +334,120 @@ function _toPropertyKey(t) {
444
334
  var i = _toPrimitive(t, "string");
445
335
  return "symbol" == typeof i ? i : i + "";
446
336
  }
337
+ function _regeneratorRuntime() {
338
+
339
+ var r = _regenerator(),
340
+ e = r.m(_regeneratorRuntime),
341
+ t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
342
+ function n(r) {
343
+ var e = "function" == typeof r && r.constructor;
344
+ return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
345
+ }
346
+ var o = {
347
+ throw: 1,
348
+ return: 2,
349
+ break: 3,
350
+ continue: 3
351
+ };
352
+ function a(r) {
353
+ var e, t;
354
+ return function (n) {
355
+ e || (e = {
356
+ stop: function () {
357
+ return t(n.a, 2);
358
+ },
359
+ catch: function () {
360
+ return n.v;
361
+ },
362
+ abrupt: function (r, e) {
363
+ return t(n.a, o[r], e);
364
+ },
365
+ delegateYield: function (r, o, a) {
366
+ return e.resultName = o, t(n.d, _regeneratorValues(r), a);
367
+ },
368
+ finish: function (r) {
369
+ return t(n.f, r);
370
+ }
371
+ }, t = function (r, t, o) {
372
+ n.p = e.prev, n.n = e.next;
373
+ try {
374
+ return r(t, o);
375
+ } finally {
376
+ e.next = n.n;
377
+ }
378
+ }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
379
+ try {
380
+ return r.call(this, e);
381
+ } finally {
382
+ n.p = e.prev, n.n = e.next;
383
+ }
384
+ };
385
+ }
386
+ return (_regeneratorRuntime = function () {
387
+ return {
388
+ wrap: function (e, t, n, o) {
389
+ return r.w(a(e), t, n, o && o.reverse());
390
+ },
391
+ isGeneratorFunction: n,
392
+ mark: r.m,
393
+ awrap: function (r, e) {
394
+ return new _OverloadYield(r, e);
395
+ },
396
+ AsyncIterator: _regeneratorAsyncIterator,
397
+ async: function (r, e, t, o, u) {
398
+ return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
399
+ },
400
+ keys: _regeneratorKeys,
401
+ values: _regeneratorValues
402
+ };
403
+ })();
404
+ }
405
+
406
+ /**
407
+ */
408
+ function isValidUrl(url) {
409
+ try {
410
+ new URL(url);
411
+ return true;
412
+ } catch (e) {
413
+ return false;
414
+ }
415
+ }
416
+
417
+ function CitationListItem(_ref) {
418
+ var primary = _ref.primary,
419
+ secondary = _ref.secondary,
420
+ i = _ref.i;
421
+ if (primary !== undefined && secondary !== undefined) {
422
+ if (isValidUrl(secondary)) {
423
+ return /*#__PURE__*/jsx(ListItem, {
424
+ button: true,
425
+ component: Link,
426
+ href: secondary,
427
+ target: "_blank",
428
+ rel: "noopener",
429
+ children: /*#__PURE__*/jsx(ListItemText, {
430
+ primary: primary,
431
+ secondary: secondary
432
+ })
433
+ }, i);
434
+ } else {
435
+ return /*#__PURE__*/jsx(ListItem, {
436
+ children: /*#__PURE__*/jsx(ListItemText, {
437
+ primary: primary,
438
+ secondary: secondary
439
+ }, i)
440
+ });
441
+ }
442
+ } else {
443
+ return null;
444
+ }
445
+ }
446
+ CitationListItem.propTypes = {
447
+ primary: PropTypes.string,
448
+ secondary: PropTypes.string,
449
+ i: PropTypes.number
450
+ };
447
451
 
448
452
  var CitationSidePanel = /*#__PURE__*/function (_Component) {
449
453
  function CitationSidePanel(props) {
@@ -554,31 +558,21 @@ var CitationSidePanel = /*#__PURE__*/function (_Component) {
554
558
  id: "".concat(id, "-resource"),
555
559
  label: 'resource',
556
560
  children: /*#__PURE__*/jsxs(List, {
557
- children: [/*#__PURE__*/jsx(ListItem, {
558
- children: /*#__PURE__*/jsx(ListItemText, {
559
- primary: "Persistent Link:",
560
- secondary: citationData.resource_persistent_link
561
- })
562
- }), /*#__PURE__*/jsx(ListItem, {
563
- children: /*#__PURE__*/jsx(ListItemText, {
564
- primary: "Description:",
565
- secondary: manifestTitle
566
- })
567
- }), /*#__PURE__*/jsx(ListItem, {
568
- children: /*#__PURE__*/jsx(ListItemText, {
569
- primary: "Repository:",
570
- secondary: citationData.repository
571
- })
572
- }), /*#__PURE__*/jsx(ListItem, {
573
- children: /*#__PURE__*/jsx(ListItemText, {
574
- primary: "Institution:",
575
- secondary: citationData.institution
576
- })
577
- }), /*#__PURE__*/jsx(ListItem, {
578
- children: /*#__PURE__*/jsx(ListItemText, {
579
- primary: "Accessed:",
580
- secondary: citationData.access_date
581
- })
561
+ children: [/*#__PURE__*/jsx(CitationListItem, {
562
+ primary: "Persistent Link:",
563
+ secondary: citationData.resource_persistent_link
564
+ }), /*#__PURE__*/jsx(CitationListItem, {
565
+ primary: "Description:",
566
+ secondary: manifestTitle
567
+ }), /*#__PURE__*/jsx(CitationListItem, {
568
+ primary: "Repository:",
569
+ secondary: citationData.repository
570
+ }), /*#__PURE__*/jsx(CitationListItem, {
571
+ primary: "Institution:",
572
+ secondary: citationData.institution
573
+ }), /*#__PURE__*/jsx(CitationListItem, {
574
+ primary: "Accessed:",
575
+ secondary: citationData.access_date
582
576
  })]
583
577
  })
584
578
  })
@@ -603,7 +597,7 @@ CitationSidePanel.defaultProps = {
603
597
  index: 1
604
598
  };
605
599
 
606
- var styles$1 = function styles(theme) {
600
+ var styles$3 = function styles(theme) {
607
601
  return {
608
602
  section: {
609
603
  borderBottom: ".5px solid ".concat(theme.palette.section_divider),
@@ -620,32 +614,195 @@ var styles$1 = function styles(theme) {
620
614
  }
621
615
  };
622
616
  };
623
- var mapStateToProps$1 = function mapStateToProps(state, _ref) {
624
- var _state$config$windows, _state$config$mirador;
617
+ var mapStateToProps$4 = function mapStateToProps(state, _ref) {
618
+ var _state$config$mirador;
625
619
  _ref.id;
626
620
  var windowId = _ref.windowId;
627
621
  return {
628
- manifestId: (_state$config$windows = state.config.windows[0]) === null || _state$config$windows === void 0 ? void 0 : _state$config$windows.manifestId,
622
+ manifestId: getManifestUrl(state, {
623
+ windowId: windowId
624
+ }),
629
625
  citationAPI: (_state$config$mirador = state.config.miradorCitationPlugin) === null || _state$config$mirador === void 0 ? void 0 : _state$config$mirador.citationAPI,
630
626
  manifestTitle: getManifestTitle(state, {
631
627
  windowId: windowId
632
628
  })
633
629
  };
634
630
  };
635
- var enhance$1 = compose(withTranslation(), withStyles(styles$1), connect(mapStateToProps$1));
631
+ var enhance$4 = compose(withTranslation(), withStyles(styles$3), connect(mapStateToProps$4));
636
632
  var CitationPanel = {
637
- component: enhance$1(CitationSidePanel),
633
+ component: enhance$4(CitationSidePanel),
638
634
  companionWindowKey: 'CitationKey'
639
635
  };
640
636
 
641
- var CitationButton = function CitationButton() {
642
- return /*#__PURE__*/jsx(CitationIcon, {});
637
+ var styles$2 = function styles(theme) {
638
+ return {
639
+ hideCitationButton: {
640
+ display: 'none'
641
+ }
642
+ };
643
643
  };
644
+ var CitationButton = /*#__PURE__*/function (_Component) {
645
+ function CitationButton(props) {
646
+ var _this;
647
+ _classCallCheck(this, CitationButton);
648
+ _this = _callSuper(this, CitationButton, [props]);
649
+ var _this$props = _this.props,
650
+ manifestId = _this$props.manifestId,
651
+ citationAPI = _this$props.citationAPI,
652
+ manifestTitle = _this$props.manifestTitle;
653
+ _this.state = {
654
+ manifestId: manifestId,
655
+ citationAPI: citationAPI,
656
+ manifestTitle: manifestTitle
657
+ };
658
+ return _this;
659
+ }
660
+ _inherits(CitationButton, _Component);
661
+ return _createClass(CitationButton, [{
662
+ key: "componentDidMount",
663
+ value: function () {
664
+ var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
665
+ var _this2 = this;
666
+ var _this$state, manifestId, citationAPI, body;
667
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
668
+ while (1) switch (_context.prev = _context.next) {
669
+ case 0:
670
+ _this$state = this.state, manifestId = _this$state.manifestId, citationAPI = _this$state.citationAPI, _this$state.manifestTitle;
671
+ body = {
672
+ "manifest_id": manifestId
673
+ };
674
+ fetch(citationAPI, {
675
+ method: 'post',
676
+ body: JSON.stringify(body),
677
+ headers: {
678
+ 'Content-Type': 'application/json'
679
+ }
680
+ }).then(function (response) {
681
+ if (!response.ok) {
682
+ throw new Error('Network response was not ok');
683
+ }
684
+ return response.json();
685
+ }).then(function (citationData) {
686
+ _this2.setState({
687
+ citationData: citationData,
688
+ loading: false
689
+ });
690
+ })["catch"](function (error) {
691
+ console.error('There was a problem receiving the citation:', error);
692
+ _this2.setState({
693
+ loading: false,
694
+ error: error.message
695
+ });
696
+ });
697
+ case 3:
698
+ case "end":
699
+ return _context.stop();
700
+ }
701
+ }, _callee, this);
702
+ }));
703
+ function componentDidMount() {
704
+ return _componentDidMount.apply(this, arguments);
705
+ }
706
+ return componentDidMount;
707
+ }()
708
+ }, {
709
+ key: "render",
710
+ value: function render() {
711
+ var _this$props2 = this.props,
712
+ classes = _this$props2.classes,
713
+ windowId = _this$props2.windowId;
714
+ var _this$state2 = this.state,
715
+ citationData = _this$state2.citationData;
716
+ _this$state2.loading;
717
+ _this$state2.error;
718
+ if (citationData) {
719
+ if (!citationData.error) {
720
+ return /*#__PURE__*/jsx("div", {
721
+ children: /*#__PURE__*/jsx(CitationIcon, {})
722
+ });
723
+ } else {
724
+ return /*#__PURE__*/jsxs("div", {
725
+ className: classes.hideCitationButton,
726
+ children: [/*#__PURE__*/jsx("style", {
727
+ children: "\n section[id=\"" + windowId + "\"] button[title=\"Cite\"] { display: none }\n "
728
+ }), /*#__PURE__*/jsx(Icon, {})]
729
+ });
730
+ }
731
+ } else {
732
+ return /*#__PURE__*/jsxs("div", {
733
+ className: classes.hideCitationButton,
734
+ children: [/*#__PURE__*/jsx("style", {
735
+ children: "\n section[id=\"" + windowId + "\"] button[title=\"Cite\"] { display: none }\n "
736
+ }), /*#__PURE__*/jsx(Icon, {})]
737
+ });
738
+ }
739
+ }
740
+ }]);
741
+ }(Component);
644
742
  CitationButton.value = 'CitationKey';
743
+ var mapStateToProps$3 = function mapStateToProps(state, _ref) {
744
+ var _state$config$mirador;
745
+ var windowId = _ref.windowId;
746
+ var manifestId = getManifestUrl(state, {
747
+ windowId: windowId
748
+ });
749
+ var citationAPI = (_state$config$mirador = state.config.miradorCitationPlugin) === null || _state$config$mirador === void 0 ? void 0 : _state$config$mirador.citationAPI;
750
+ var manifestTitle = getManifestTitle(state, {
751
+ windowId: windowId
752
+ });
753
+ return {
754
+ manifestId: manifestId,
755
+ citationAPI: citationAPI,
756
+ manifestTitle: manifestTitle
757
+ };
758
+ };
759
+ var enhance$3 = compose(withStyles(styles$2), connect(mapStateToProps$3));
760
+ CitationButton.propTypes = {
761
+ classes: PropTypes.objectOf(PropTypes.string),
762
+ manifestId: PropTypes.string,
763
+ citationAPI: PropTypes.string,
764
+ manifestTitle: PropTypes.string
765
+ };
766
+ CitationButton.defaultProps = {
767
+ classes: {},
768
+ manifestId: null,
769
+ citationAPI: null,
770
+ manifestTitle: null
771
+ };
645
772
  var CitationButton$1 = {
646
773
  target: 'WindowSideBarButtons',
774
+ name: 'WindowSideBarCitationButton',
647
775
  mode: 'add',
648
- component: CitationButton
776
+ component: enhance$3(CitationButton)
777
+ };
778
+
779
+ function CitationSection(_ref) {
780
+ var id = _ref.id,
781
+ label = _ref.label,
782
+ links = _ref.links;
783
+ if (!links) {
784
+ return null;
785
+ } else if (links.length === 0) {
786
+ return null;
787
+ } else {
788
+ return /*#__PURE__*/jsx(CollapsibleSection, {
789
+ id: "".concat(id, "-").concat(id),
790
+ label: "".concat(label),
791
+ children: /*#__PURE__*/jsx(List, {
792
+ children: links.map(function (link, i) {
793
+ return /*#__PURE__*/jsx(CitationListItem, {
794
+ primary: link.label,
795
+ secondary: link.link
796
+ }, i);
797
+ })
798
+ })
799
+ });
800
+ }
801
+ }
802
+ CitationSection.propTypes = {
803
+ id: PropTypes.string.isRequired,
804
+ label: PropTypes.string.isRequired,
805
+ links: PropTypes.arrayOf(PropTypes.object)
649
806
  };
650
807
 
651
808
  var RelatedLinksSidePanel = /*#__PURE__*/function (_Component) {
@@ -764,42 +921,14 @@ var RelatedLinksSidePanel = /*#__PURE__*/function (_Component) {
764
921
  })]
765
922
  }), citationData && /*#__PURE__*/jsxs("div", {
766
923
  className: classes.section,
767
- children: [/*#__PURE__*/jsx(CollapsibleSection, {
768
- id: "".concat(id, "-harvard-metadata"),
769
- label: 'harvard metadata',
770
- children: /*#__PURE__*/jsx(List, {
771
- children: citationData.harvard_metadata_links.map(function (metadataLink, i) {
772
- return /*#__PURE__*/jsx(ListItem, {
773
- button: true,
774
- component: Link,
775
- href: metadataLink.link,
776
- target: "_blank",
777
- rel: "noopener",
778
- children: /*#__PURE__*/jsx(ListItemText, {
779
- primary: metadataLink.label,
780
- secondary: metadataLink.link
781
- })
782
- }, i);
783
- })
784
- })
785
- }), /*#__PURE__*/jsx(CollapsibleSection, {
786
- id: "".concat(id, "-related-links"),
787
- label: 'related links',
788
- children: /*#__PURE__*/jsx(List, {
789
- children: citationData.related_links.map(function (relatedLink, i) {
790
- return /*#__PURE__*/jsx(ListItem, {
791
- button: true,
792
- component: Link,
793
- href: relatedLink.link,
794
- target: "_blank",
795
- rel: "noopener",
796
- children: /*#__PURE__*/jsx(ListItemText, {
797
- primary: relatedLink.label,
798
- secondary: relatedLink.link
799
- })
800
- }, i);
801
- })
802
- })
924
+ children: [/*#__PURE__*/jsx(CitationSection, {
925
+ id: "harvard-metadata",
926
+ label: "harvard metadata",
927
+ links: citationData.harvard_metadata_links
928
+ }), /*#__PURE__*/jsx(CitationSection, {
929
+ id: "related-links",
930
+ label: "related links",
931
+ links: citationData.related_links
803
932
  })]
804
933
  }), /*#__PURE__*/jsx(PluginHook, _objectSpread2({}, this.props))]
805
934
  });
@@ -820,7 +949,7 @@ RelatedLinksSidePanel.defaultProps = {
820
949
  index: 1
821
950
  };
822
951
 
823
- var styles = function styles(theme) {
952
+ var styles$1 = function styles(theme) {
824
953
  return {
825
954
  section: {
826
955
  borderBottom: ".5px solid ".concat(theme.palette.section_divider),
@@ -837,34 +966,448 @@ var styles = function styles(theme) {
837
966
  }
838
967
  };
839
968
  };
840
- var mapStateToProps = function mapStateToProps(state, _ref) {
841
- var _state$config$windows, _state$config$mirador;
969
+ var mapStateToProps$2 = function mapStateToProps(state, _ref) {
970
+ var _state$config$mirador;
842
971
  _ref.id;
843
972
  var windowId = _ref.windowId;
844
973
  return {
845
- manifestId: (_state$config$windows = state.config.windows[0]) === null || _state$config$windows === void 0 ? void 0 : _state$config$windows.manifestId,
974
+ manifestId: getManifestUrl(state, {
975
+ windowId: windowId
976
+ }),
846
977
  citationAPI: (_state$config$mirador = state.config.miradorCitationPlugin) === null || _state$config$mirador === void 0 ? void 0 : _state$config$mirador.citationAPI,
847
978
  manifestTitle: getManifestTitle(state, {
848
979
  windowId: windowId
849
980
  })
850
981
  };
851
982
  };
852
- var enhance = compose(withTranslation(), withStyles(styles), connect(mapStateToProps));
983
+ var enhance$2 = compose(withTranslation(), withStyles(styles$1), connect(mapStateToProps$2));
853
984
  var RelatedLinksPanel = {
854
- component: enhance(RelatedLinksSidePanel),
985
+ component: enhance$2(RelatedLinksSidePanel),
855
986
  companionWindowKey: 'RelatedLinksKey'
856
987
  };
857
988
 
858
- var RelatedLinksButton = function RelatedLinksButton() {
859
- return /*#__PURE__*/jsx(RelatedLinksIcon, {});
989
+ var styles = function styles(theme) {
990
+ return {
991
+ hideRelatedLinksButton: {
992
+ display: 'none'
993
+ }
994
+ };
860
995
  };
996
+ var RelatedLinksButton = /*#__PURE__*/function (_Component) {
997
+ function RelatedLinksButton(props) {
998
+ var _this;
999
+ _classCallCheck(this, RelatedLinksButton);
1000
+ _this = _callSuper(this, RelatedLinksButton, [props]);
1001
+ var _this$props = _this.props,
1002
+ manifestId = _this$props.manifestId,
1003
+ citationAPI = _this$props.citationAPI,
1004
+ manifestTitle = _this$props.manifestTitle;
1005
+ _this.state = {
1006
+ manifestId: manifestId,
1007
+ citationAPI: citationAPI,
1008
+ manifestTitle: manifestTitle
1009
+ };
1010
+ return _this;
1011
+ }
1012
+ _inherits(RelatedLinksButton, _Component);
1013
+ return _createClass(RelatedLinksButton, [{
1014
+ key: "componentDidMount",
1015
+ value: function () {
1016
+ var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1017
+ var _this2 = this;
1018
+ var _this$state, manifestId, citationAPI, body;
1019
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1020
+ while (1) switch (_context.prev = _context.next) {
1021
+ case 0:
1022
+ _this$state = this.state, manifestId = _this$state.manifestId, citationAPI = _this$state.citationAPI, _this$state.manifestTitle;
1023
+ body = {
1024
+ "manifest_id": manifestId
1025
+ };
1026
+ fetch(citationAPI, {
1027
+ method: 'post',
1028
+ body: JSON.stringify(body),
1029
+ headers: {
1030
+ 'Content-Type': 'application/json'
1031
+ }
1032
+ }).then(function (response) {
1033
+ if (!response.ok) {
1034
+ throw new Error('Network response was not ok');
1035
+ }
1036
+ return response.json();
1037
+ }).then(function (citationData) {
1038
+ _this2.setState({
1039
+ citationData: citationData,
1040
+ loading: false
1041
+ });
1042
+ })["catch"](function (error) {
1043
+ console.error('There was a problem receiving the citation:', error);
1044
+ _this2.setState({
1045
+ loading: false,
1046
+ error: error.message
1047
+ });
1048
+ });
1049
+ case 3:
1050
+ case "end":
1051
+ return _context.stop();
1052
+ }
1053
+ }, _callee, this);
1054
+ }));
1055
+ function componentDidMount() {
1056
+ return _componentDidMount.apply(this, arguments);
1057
+ }
1058
+ return componentDidMount;
1059
+ }()
1060
+ }, {
1061
+ key: "render",
1062
+ value: function render() {
1063
+ var _this$props2 = this.props,
1064
+ classes = _this$props2.classes,
1065
+ windowId = _this$props2.windowId;
1066
+ var _this$state2 = this.state,
1067
+ citationData = _this$state2.citationData;
1068
+ _this$state2.loading;
1069
+ _this$state2.error;
1070
+ if (citationData) {
1071
+ if (!citationData.error) {
1072
+ return /*#__PURE__*/jsx("div", {
1073
+ children: /*#__PURE__*/jsx(RelatedLinksIcon, {})
1074
+ });
1075
+ } else {
1076
+ return /*#__PURE__*/jsxs("div", {
1077
+ className: classes.hideRelatedLinksButton,
1078
+ children: [/*#__PURE__*/jsx("style", {
1079
+ children: "\n section[id=\"" + windowId + "\"] button[title=\"Related Links\"] { display: none }\n "
1080
+ }), /*#__PURE__*/jsx(Icon, {})]
1081
+ });
1082
+ }
1083
+ } else {
1084
+ return /*#__PURE__*/jsxs("div", {
1085
+ className: classes.hideRelatedLinksButton,
1086
+ children: [/*#__PURE__*/jsx("style", {
1087
+ children: "\n section[id=\"" + windowId + "\"] button[title=\"Related Links\"] { display: none }\n "
1088
+ }), /*#__PURE__*/jsx(Icon, {})]
1089
+ });
1090
+ }
1091
+ }
1092
+ }]);
1093
+ }(Component);
861
1094
  RelatedLinksButton.value = 'RelatedLinksKey';
1095
+ var mapStateToProps$1 = function mapStateToProps(state, _ref) {
1096
+ var _state$config$mirador;
1097
+ var windowId = _ref.windowId;
1098
+ var manifestId = getManifestUrl(state, {
1099
+ windowId: windowId
1100
+ });
1101
+ var citationAPI = (_state$config$mirador = state.config.miradorCitationPlugin) === null || _state$config$mirador === void 0 ? void 0 : _state$config$mirador.citationAPI;
1102
+ var manifestTitle = getManifestTitle(state, {
1103
+ windowId: windowId
1104
+ });
1105
+ return {
1106
+ manifestId: manifestId,
1107
+ citationAPI: citationAPI,
1108
+ manifestTitle: manifestTitle
1109
+ };
1110
+ };
1111
+ var enhance$1 = compose(withStyles(styles), connect(mapStateToProps$1));
1112
+ RelatedLinksButton.propTypes = {
1113
+ classes: PropTypes.objectOf(PropTypes.string),
1114
+ manifestId: PropTypes.string,
1115
+ citationAPI: PropTypes.string,
1116
+ manifestTitle: PropTypes.string
1117
+ };
1118
+ RelatedLinksButton.defaultProps = {
1119
+ classes: {},
1120
+ manifestId: null,
1121
+ citationAPI: null,
1122
+ manifestTitle: null
1123
+ };
862
1124
  var RelatedLinksButton$1 = {
863
1125
  target: 'WindowSideBarButtons',
1126
+ name: 'WindowSideBarRelatedLinksButton',
864
1127
  mode: 'add',
865
- component: RelatedLinksButton
1128
+ component: enhance$1(RelatedLinksButton)
1129
+ };
1130
+
1131
+ var WindowSideBarButtons = /*#__PURE__*/function (_Component) {
1132
+ /** */
1133
+ function WindowSideBarButtons(props) {
1134
+ var _this;
1135
+ _classCallCheck(this, WindowSideBarButtons);
1136
+ _this = _callSuper(this, WindowSideBarButtons, [props]);
1137
+ _this.handleChange = _this.handleChange.bind(_this);
1138
+ return _this;
1139
+ }
1140
+
1141
+ /**
1142
+ * @param {object} event the change event
1143
+ * @param {string} value the tab's value
1144
+ */
1145
+ _inherits(WindowSideBarButtons, _Component);
1146
+ return _createClass(WindowSideBarButtons, [{
1147
+ key: "handleChange",
1148
+ value: function handleChange(event, value) {
1149
+ var addCompanionWindow = this.props.addCompanionWindow;
1150
+ addCompanionWindow(value);
1151
+ }
1152
+
1153
+ /**
1154
+ * render
1155
+ *
1156
+ * @return {type} description
1157
+ */
1158
+ }, {
1159
+ key: "render",
1160
+ value: function render() {
1161
+ var _this2 = this;
1162
+ var _this$props = this.props,
1163
+ classes = _this$props.classes,
1164
+ hasAnnotations = _this$props.hasAnnotations,
1165
+ hasAnyAnnotations = _this$props.hasAnyAnnotations,
1166
+ hasAnyLayers = _this$props.hasAnyLayers,
1167
+ hasCurrentLayers = _this$props.hasCurrentLayers,
1168
+ hasSearchResults = _this$props.hasSearchResults,
1169
+ hasSearchService = _this$props.hasSearchService,
1170
+ panels = _this$props.panels,
1171
+ PluginComponents = _this$props.PluginComponents,
1172
+ sideBarPanel = _this$props.sideBarPanel,
1173
+ t = _this$props.t,
1174
+ windowId = _this$props.windowId;
1175
+
1176
+ /** */
1177
+ var TabButton = function TabButton(props) {
1178
+ return /*#__PURE__*/jsx(Tooltip, {
1179
+ title: t('openCompanionWindow', {
1180
+ context: props.value
1181
+ }),
1182
+ children: /*#__PURE__*/jsx(Tab, _objectSpread2(_objectSpread2({}, props), {}, {
1183
+ classes: {
1184
+ root: classes.tab,
1185
+ selected: classes.tabSelected
1186
+ },
1187
+ "aria-label": t('openCompanionWindow', {
1188
+ context: props.value
1189
+ }),
1190
+ disableRipple: true,
1191
+ onKeyUp: _this2.handleKeyUp
1192
+ }))
1193
+ });
1194
+ };
1195
+ return /*#__PURE__*/jsxs(Tabs, {
1196
+ classes: {
1197
+ flexContainer: classes.tabsFlexContainer,
1198
+ indicator: classes.tabsIndicator
1199
+ },
1200
+ value: sideBarPanel === 'closed' ? false : sideBarPanel,
1201
+ onChange: this.handleChange,
1202
+ variant: "fullWidth",
1203
+ indicatorColor: "primary",
1204
+ textColor: "primary",
1205
+ orientation: "vertical",
1206
+ "aria-orientation": "vertical",
1207
+ "aria-label": t('sidebarPanelsNavigation'),
1208
+ children: [panels.info && /*#__PURE__*/jsx(TabButton, {
1209
+ value: "info",
1210
+ icon: /*#__PURE__*/jsx(InfoIcon, {})
1211
+ }), panels.attribution && /*#__PURE__*/jsx(TabButton, {
1212
+ value: "attribution",
1213
+ icon: /*#__PURE__*/jsx(AttributionIcon, {})
1214
+ }), panels.canvas && /*#__PURE__*/jsx(TabButton, {
1215
+ value: "canvas",
1216
+ icon: /*#__PURE__*/jsx(CanvasIndexIcon, {})
1217
+ }), panels.annotations && (hasAnnotations || hasAnyAnnotations) && /*#__PURE__*/jsx(TabButton, {
1218
+ value: "annotations",
1219
+ icon: /*#__PURE__*/jsx(Badge, {
1220
+ classes: {
1221
+ badge: classes.badge
1222
+ },
1223
+ invisible: !hasAnnotations,
1224
+ variant: "dot",
1225
+ children: /*#__PURE__*/jsx(AnnotationIcon, {})
1226
+ })
1227
+ }), panels.search && hasSearchService && /*#__PURE__*/jsx(TabButton, {
1228
+ value: "search",
1229
+ icon: /*#__PURE__*/jsx(Badge, {
1230
+ classes: {
1231
+ badge: classes.badge
1232
+ },
1233
+ invisible: !hasSearchResults,
1234
+ variant: "dot",
1235
+ children: /*#__PURE__*/jsx(SearchIcon, {})
1236
+ })
1237
+ }), panels.layers && hasAnyLayers && /*#__PURE__*/jsx(TabButton, {
1238
+ value: "layers",
1239
+ icon: /*#__PURE__*/jsx(Badge, {
1240
+ classes: {
1241
+ badge: classes.badge
1242
+ },
1243
+ invisible: !hasCurrentLayers,
1244
+ variant: "dot",
1245
+ children: /*#__PURE__*/jsx(LayersIcon, {})
1246
+ })
1247
+ }), PluginComponents && PluginComponents.map(function (PluginComponent) {
1248
+ return /*#__PURE__*/jsx(TabButton, {
1249
+ value: PluginComponent.value,
1250
+ icon: /*#__PURE__*/jsx(PluginComponent, {
1251
+ windowId: windowId
1252
+ })
1253
+ }, PluginComponent.value);
1254
+ })]
1255
+ });
1256
+ }
1257
+ }]);
1258
+ }(Component);
1259
+ WindowSideBarButtons.propTypes = {
1260
+ addCompanionWindow: PropTypes.func.isRequired,
1261
+ classes: PropTypes.objectOf(PropTypes.string),
1262
+ hasAnnotations: PropTypes.bool,
1263
+ hasAnyAnnotations: PropTypes.bool,
1264
+ hasAnyLayers: PropTypes.bool,
1265
+ hasCurrentLayers: PropTypes.bool,
1266
+ hasSearchResults: PropTypes.bool,
1267
+ hasSearchService: PropTypes.bool,
1268
+ panels: PropTypes.arrayOf(PropTypes.bool),
1269
+ PluginComponents: PropTypes.array,
1270
+ // eslint-disable-line react/forbid-prop-types
1271
+ sideBarPanel: PropTypes.string,
1272
+ t: PropTypes.func
1273
+ };
1274
+ WindowSideBarButtons.defaultProps = {
1275
+ classes: {},
1276
+ hasAnnotations: false,
1277
+ hasAnyAnnotations: false,
1278
+ hasAnyLayers: false,
1279
+ hasCurrentLayers: false,
1280
+ hasSearchResults: false,
1281
+ hasSearchService: false,
1282
+ panels: [],
1283
+ PluginComponents: null,
1284
+ sideBarPanel: 'closed',
1285
+ t: function t(key) {
1286
+ return key;
1287
+ }
1288
+ };
1289
+
1290
+ /**
1291
+ * mapDispatchToProps - used to hook up connect to action creators
1292
+ * @memberof WindowSideButtons
1293
+ * @private
1294
+ */
1295
+ var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
1296
+ var windowId = _ref.windowId;
1297
+ return {
1298
+ addCompanionWindow: function addCompanionWindow(content) {
1299
+ return dispatch(actions.addOrUpdateCompanionWindow(windowId, {
1300
+ content: content,
1301
+ position: 'left'
1302
+ }));
1303
+ }
1304
+ };
1305
+ };
1306
+
1307
+ /** */
1308
+ function hasLayers(canvases) {
1309
+ return canvases && canvases.some(function (c) {
1310
+ return new MiradorCanvas(c).imageResources.length > 1;
1311
+ });
1312
+ }
1313
+
1314
+ /** */
1315
+ function hasAnnotations(canvases) {
1316
+ return canvases && canvases.some(function (c) {
1317
+ var canvas = new MiradorCanvas(c);
1318
+ return canvas.annotationListUris.length > 0 || canvas.canvasAnnotationPages.length > 0;
1319
+ });
1320
+ }
1321
+
1322
+ /**
1323
+ * mapStateToProps - used to hook up connect to state
1324
+ * @memberof WindowSideButtons
1325
+ * @private
1326
+ */
1327
+ var mapStateToProps = function mapStateToProps(state, _ref2) {
1328
+ var windowId = _ref2.windowId;
1329
+ return {
1330
+ hasAnnotations: getAnnotationResourcesByMotivation(state, {
1331
+ windowId: windowId
1332
+ }).length > 0,
1333
+ hasAnyAnnotations: hasAnnotations(getCanvases(state, {
1334
+ windowId: windowId
1335
+ })),
1336
+ hasAnyLayers: hasLayers(getCanvases(state, {
1337
+ windowId: windowId
1338
+ })),
1339
+ hasCurrentLayers: hasLayers(getVisibleCanvases(state, {
1340
+ windowId: windowId
1341
+ })),
1342
+ hasSearchResults: getWindow(state, {
1343
+ windowId: windowId
1344
+ }).suggestedSearches || getSearchQuery(state, {
1345
+ companionWindowId: (getCompanionWindowsForPosition(state, {
1346
+ position: 'left',
1347
+ windowId: windowId
1348
+ })[0] || {}).id,
1349
+ windowId: windowId
1350
+ }),
1351
+ hasSearchService: getManifestSearchService(state, {
1352
+ windowId: windowId
1353
+ }) !== null,
1354
+ panels: getWindowConfig(state, {
1355
+ windowId: windowId
1356
+ }).panels,
1357
+ sideBarPanel: (getCompanionWindowsForPosition(state, {
1358
+ position: 'left',
1359
+ windowId: windowId
1360
+ })[0] || {}).content
1361
+ };
1362
+ };
1363
+
1364
+ /** */
1365
+ var style = function style(theme) {
1366
+ return {
1367
+ badge: {
1368
+ backgroundColor: theme.palette.notification.main
1369
+ },
1370
+ tab: {
1371
+ '&:active': {
1372
+ backgroundColor: theme.palette.action.active
1373
+ },
1374
+ '&:focus': {
1375
+ '@media (hover: none)': {
1376
+ backgroundColor: 'transparent'
1377
+ },
1378
+ backgroundColor: theme.palette.action.hover,
1379
+ textDecoration: 'none'
1380
+ // Reset on touch devices, it doesn't add specificity
1381
+ },
1382
+ '&:hover': {
1383
+ '@media (hover: none)': {
1384
+ backgroundColor: 'transparent'
1385
+ },
1386
+ backgroundColor: theme.palette.action.hover,
1387
+ textDecoration: 'none'
1388
+ // Reset on touch devices, it doesn't add specificity
1389
+ },
1390
+ borderRight: '2px solid transparent',
1391
+ minWidth: 'auto'
1392
+ },
1393
+ tabSelected: {
1394
+ borderRight: "2px solid ".concat(theme.palette.primary.main)
1395
+ },
1396
+ tabsFlexContainer: {
1397
+ flexDirection: 'column'
1398
+ },
1399
+ tabsIndicator: {
1400
+ display: 'none'
1401
+ }
1402
+ };
1403
+ };
1404
+ var enhance = compose(withTranslation(), withStyles$1(style), connect(mapStateToProps, mapDispatchToProps));
1405
+ var WindowSidebarButtons = {
1406
+ target: 'WindowSideBarButtons',
1407
+ mode: 'wrap',
1408
+ component: enhance(WindowSideBarButtons)
866
1409
  };
867
1410
 
868
- var index = [CitationPanel, CitationButton$1, RelatedLinksPanel, RelatedLinksButton$1];
1411
+ var index = [CitationPanel, CitationButton$1, RelatedLinksPanel, RelatedLinksButton$1, WindowSidebarButtons];
869
1412
 
870
- export { CitationButton$1 as CitationButton, CitationPanel, RelatedLinksButton$1 as RelatedLinksButton, RelatedLinksPanel, index as default };
1413
+ export { CitationButton$1 as CitationButton, CitationPanel, RelatedLinksButton$1 as RelatedLinksButton, RelatedLinksPanel, WindowSidebarButtons, index as default };