@manifest-editor/creators 1.4.3 → 2.0.1-next.0.d468080

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 (90) hide show
  1. package/dist/iiif-browser-form.lazy-3ZdoCwGA.cjs +1 -0
  2. package/dist/iiif-browser-form.lazy-C2OEJ-sB.js +2 -0
  3. package/dist/iiif-browser-form.lazy-C2OEJ-sB.js.map +1 -0
  4. package/dist/index.cjs +19 -2675
  5. package/dist/index.css +758 -0
  6. package/dist/index.css.map +1 -0
  7. package/dist/index.d.cts +392 -292
  8. package/dist/index.d.cts.map +1 -0
  9. package/dist/index.d.ts +392 -292
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +20 -2526
  12. package/dist/index.js.map +1 -0
  13. package/dist/manifest-browser-form.lazy-ChGxMNuK.js +1 -0
  14. package/dist/manifest-browser-form.lazy-CyY_B4mJ.cjs +1 -0
  15. package/dist/manifest-browser-form.lazy-DnIXlrw4.cjs +1 -0
  16. package/dist/manifest-browser-form.lazy-WlvvR5FO.js +2 -0
  17. package/dist/manifest-browser-form.lazy-WlvvR5FO.js.map +1 -0
  18. package/package.json +28 -32
  19. package/dist/chunk-2B2F7X4A.js +0 -59
  20. package/dist/chunk-5YV7MYAZ.js +0 -60
  21. package/dist/chunk-7FSKLOVQ.js +0 -33
  22. package/dist/chunk-AVISJS46.js +0 -50
  23. package/dist/chunk-CYVZA2MU.js +0 -59
  24. package/dist/chunk-ES62IRNT.js +0 -50
  25. package/dist/chunk-KLSWX2QF.js +0 -38
  26. package/dist/chunk-PFQB3PNW.js +0 -47
  27. package/dist/chunk-S3JO5Y3Z.js +0 -50
  28. package/dist/chunk-W4PYM3PN.js +0 -59
  29. package/dist/iiif-browser-form.lazy-3EZNJN4M.js +0 -21
  30. package/dist/iiif-browser-form.lazy-3INAWCE5.js +0 -54
  31. package/dist/iiif-browser-form.lazy-3YUQOIEL.js +0 -21
  32. package/dist/iiif-browser-form.lazy-4CDWA6JD.js +0 -47
  33. package/dist/iiif-browser-form.lazy-4NX7YPGK.js +0 -57
  34. package/dist/iiif-browser-form.lazy-4X5LD2U4.js +0 -51
  35. package/dist/iiif-browser-form.lazy-5TF74M2Q.js +0 -48
  36. package/dist/iiif-browser-form.lazy-B2RXVKR5.js +0 -21
  37. package/dist/iiif-browser-form.lazy-BHX6TGDY.js +0 -58
  38. package/dist/iiif-browser-form.lazy-C72INDSJ.js +0 -57
  39. package/dist/iiif-browser-form.lazy-DCCYGD42.js +0 -35
  40. package/dist/iiif-browser-form.lazy-DKKTAIO5.js +0 -59
  41. package/dist/iiif-browser-form.lazy-DPRO7R2W.js +0 -59
  42. package/dist/iiif-browser-form.lazy-DU2NJUCE.js +0 -46
  43. package/dist/iiif-browser-form.lazy-DUTUHLUT.js +0 -50
  44. package/dist/iiif-browser-form.lazy-EJZ754MG.js +0 -42
  45. package/dist/iiif-browser-form.lazy-ENQRBLTJ.js +0 -21
  46. package/dist/iiif-browser-form.lazy-EREIP6PZ.js +0 -58
  47. package/dist/iiif-browser-form.lazy-FMKQQWDE.js +0 -33
  48. package/dist/iiif-browser-form.lazy-FOIWPPI7.js +0 -47
  49. package/dist/iiif-browser-form.lazy-FQDZQ3UW.js +0 -58
  50. package/dist/iiif-browser-form.lazy-G7TCZSC2.js +0 -58
  51. package/dist/iiif-browser-form.lazy-G7XAQYYG.js +0 -51
  52. package/dist/iiif-browser-form.lazy-GO6U6NE5.js +0 -32
  53. package/dist/iiif-browser-form.lazy-GVEEZX37.js +0 -33
  54. package/dist/iiif-browser-form.lazy-HBWB7QGF.js +0 -31
  55. package/dist/iiif-browser-form.lazy-HZ3M2DXT.js +0 -57
  56. package/dist/iiif-browser-form.lazy-I7KTYV3O.js +0 -57
  57. package/dist/iiif-browser-form.lazy-I7ZNZHID.js +0 -48
  58. package/dist/iiif-browser-form.lazy-IX5DFVDG.js +0 -47
  59. package/dist/iiif-browser-form.lazy-JMT72BLP.js +0 -59
  60. package/dist/iiif-browser-form.lazy-JX4S6NGX.js +0 -48
  61. package/dist/iiif-browser-form.lazy-KPB57B25.js +0 -21
  62. package/dist/iiif-browser-form.lazy-KTB4BQBM.js +0 -59
  63. package/dist/iiif-browser-form.lazy-KYOKLDRV.js +0 -47
  64. package/dist/iiif-browser-form.lazy-NDPLPCQQ.js +0 -43
  65. package/dist/iiif-browser-form.lazy-O35TC45U.js +0 -49
  66. package/dist/iiif-browser-form.lazy-OMDV43NQ.js +0 -51
  67. package/dist/iiif-browser-form.lazy-OQLU6NDJ.js +0 -51
  68. package/dist/iiif-browser-form.lazy-OXQVZ3GS.js +0 -59
  69. package/dist/iiif-browser-form.lazy-OZNQO2OO.js +0 -21
  70. package/dist/iiif-browser-form.lazy-PL3WMLU5.js +0 -33
  71. package/dist/iiif-browser-form.lazy-QR55LXI4.js +0 -21
  72. package/dist/iiif-browser-form.lazy-R5TMXUBV.js +0 -19
  73. package/dist/iiif-browser-form.lazy-RWEJWTIW.js +0 -21
  74. package/dist/iiif-browser-form.lazy-T6LT6BJD.js +0 -48
  75. package/dist/iiif-browser-form.lazy-TWQYATEG.js +0 -21
  76. package/dist/iiif-browser-form.lazy-UPZXU6JB.js +0 -51
  77. package/dist/iiif-browser-form.lazy-W42LJ6X2.js +0 -47
  78. package/dist/iiif-browser-form.lazy-WAK45BLF.js +0 -42
  79. package/dist/iiif-browser-form.lazy-WVCVE6XK.js +0 -21
  80. package/dist/iiif-browser-form.lazy-XORWZFSW.js +0 -49
  81. package/dist/manifest-browser-form.lazy-4CFTHOMZ.js +0 -6
  82. package/dist/manifest-browser-form.lazy-5JVKGB7O.js +0 -6
  83. package/dist/manifest-browser-form.lazy-ALVCNMEV.js +0 -6
  84. package/dist/manifest-browser-form.lazy-FI4GGCPX.js +0 -6
  85. package/dist/manifest-browser-form.lazy-HJJKFMR6.js +0 -6
  86. package/dist/manifest-browser-form.lazy-MYI26AX4.js +0 -6
  87. package/dist/manifest-browser-form.lazy-QGTJHSSC.js +0 -6
  88. package/dist/manifest-browser-form.lazy-WRWZPVRC.js +0 -6
  89. package/dist/manifest-browser-form.lazy-XVYSAQAW.js +0 -6
  90. package/dist/manifest-browser-form.lazy-YYKOYF7R.js +0 -6
package/dist/index.cjs CHANGED
@@ -1,298 +1,9 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
-
33
- // src/ContentResource/IIIFBrowserCreator/iiif-browser-form.lazy.tsx
34
- var iiif_browser_form_lazy_exports = {};
35
- __export(iiif_browser_form_lazy_exports, {
36
- default: () => IIIFBrowserCreatorForm
37
- });
38
- function IIIFBrowserCreatorForm(props) {
39
- const vault = (0, import_react8.useMemo)(() => new import_helpers4.Vault(), []);
40
- const output = (0, import_react8.useMemo)(() => {
41
- return [
42
- {
43
- type: "callback",
44
- label: "Select",
45
- supportedTypes: ["Canvas", "CanvasList", "CanvasRegion", "ImageService", "ImageServiceRegion"],
46
- cb: (resource) => props.runCreate({ output: resource }),
47
- format: {
48
- type: "custom",
49
- format: (resource, parent, vault2) => {
50
- const resourcesAsArray = Array.isArray(resource) ? resource : [{ ...resource, parent }];
51
- const resources = [];
52
- for (const resource2 of resourcesAsArray) {
53
- resources.push({ resource: vault2.get(resource2), parent: resource2.parent, selector: resource2.selector });
54
- }
55
- return resources;
56
- }
57
- }
58
- }
59
- ];
60
- }, [props.runCreate]);
61
- const navigationOptions = (0, import_react8.useMemo)(() => {
62
- return {
63
- canCropImage: true,
64
- canSelectCanvas: true,
65
- canSelectManifest: false,
66
- canSelectCollection: false,
67
- // @todo fix the output so this one works.
68
- multiSelect: true
69
- };
70
- }, []);
71
- const uiOptions = (0, import_react8.useMemo)(() => {
72
- return {
73
- buttonClassName: "bg-me-primary-500 text-white hover:bg-me-primary-600"
74
- };
75
- }, []);
76
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_shell3.PreviewVaultBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
77
- import_iiif_browser2.IIIFBrowser,
78
- {
79
- ui: uiOptions,
80
- vault,
81
- className: "iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full",
82
- output,
83
- navigation: navigationOptions
84
- }
85
- ) });
86
- }
87
- var import_helpers4, import_shell3, import_iiif_browser2, import_react8, import_jsx_runtime29;
88
- var init_iiif_browser_form_lazy = __esm({
89
- "src/ContentResource/IIIFBrowserCreator/iiif-browser-form.lazy.tsx"() {
90
- "use strict";
91
- import_helpers4 = require("@iiif/helpers");
92
- import_shell3 = require("@manifest-editor/shell");
93
- import_iiif_browser2 = require("iiif-browser");
94
- import_react8 = require("react");
95
- import_jsx_runtime29 = require("react/jsx-runtime");
96
- }
97
- });
98
-
99
- // src/Manifest/ManifestBrowserCreator/manifest-browser-form.lazy.tsx
100
- var manifest_browser_form_lazy_exports = {};
101
- __export(manifest_browser_form_lazy_exports, {
102
- default: () => ManifestBrowserCreatorForm
103
- });
104
- function ManifestBrowserCreatorForm(props) {
105
- const vault = (0, import_react13.useMemo)(() => new import_helpers6.Vault(), []);
106
- const output = (0, import_react13.useMemo)(() => {
107
- return [
108
- {
109
- type: "callback",
110
- label: "Select",
111
- supportedTypes: ["Manifest", "Collection", "ManifestList", "CollectionList", "CollectionItemList"],
112
- cb: (resource) => props.runCreate({ output: resource }),
113
- format: {
114
- type: "custom",
115
- format: (resource, parent, vault2) => {
116
- const resourcesAsArray = Array.isArray(resource) ? resource : [{ ...resource, parent }];
117
- const resources = [];
118
- for (const resource2 of resourcesAsArray) {
119
- resources.push({ resource: vault2.get(resource2), parent: resource2.parent, selector: resource2.selector });
120
- }
121
- return resources;
122
- }
123
- }
124
- }
125
- ];
126
- }, [props.runCreate]);
127
- const navigationOptions = (0, import_react13.useMemo)(() => {
128
- return {
129
- canCropImage: false,
130
- canSelectCanvas: false,
131
- canSelectManifest: true,
132
- canSelectCollection: true,
133
- multiSelect: true
134
- };
135
- }, []);
136
- const uiOptions = (0, import_react13.useMemo)(() => {
137
- return {
138
- buttonClassName: "bg-me-primary-500 text-white hover:bg-me-primary-600"
139
- };
140
- }, []);
141
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_shell4.PreviewVaultBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
142
- import_iiif_browser3.IIIFBrowser,
143
- {
144
- debug: true,
145
- ui: uiOptions,
146
- vault,
147
- className: "iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full",
148
- output,
149
- navigation: navigationOptions
150
- }
151
- ) });
152
- }
153
- var import_helpers6, import_shell4, import_iiif_browser3, import_react13, import_jsx_runtime43;
154
- var init_manifest_browser_form_lazy = __esm({
155
- "src/Manifest/ManifestBrowserCreator/manifest-browser-form.lazy.tsx"() {
156
- "use strict";
157
- import_helpers6 = require("@iiif/helpers");
158
- import_shell4 = require("@manifest-editor/shell");
159
- import_iiif_browser3 = require("iiif-browser");
160
- import_react13 = require("react");
161
- import_jsx_runtime43 = require("react/jsx-runtime");
162
- }
163
- });
164
-
165
- // src/index.ts
166
- var src_exports = {};
167
- __export(src_exports, {
168
- CreateAudioAnnotationForm: () => CreateAudioAnnotationForm,
169
- CreateCaptionedImageAnnotation: () => CreateCaptionedImageAnnotation,
170
- CreateHTMLAnnotation: () => CreateHTMLAnnotation,
171
- CreateHTMLBodyForm: () => CreateHTMLBodyForm,
172
- CreateImageServerForm: () => CreateImageServerForm,
173
- CreateImageServiceAnnotationForm: () => CreateImageServiceAnnotationForm,
174
- CreateImageUrlAnnotationForm: () => CreateImageUrlAnnotationForm,
175
- CreateImageUrlForm: () => CreateImageUrlForm,
176
- CreateImageUrlListForm: () => CreateImageUrlListForm,
177
- CreatePlaintextForm: () => CreatePlaintextForm,
178
- CreateThumbnailForm: () => CreateThumbnailForm,
179
- CreateVideoAnnotationForm: () => CreateVideoAnnotationForm,
180
- CreateWebPageForm: () => CreateWebPageForm,
181
- IIIFBrowserCreatorForm: () => IIIFBrowserCreatorForm2,
182
- ManifestBrowserCreatorForm: () => ManifestBrowserCreatorForm2,
183
- YouTubeForm: () => YouTubeForm,
184
- allCreators: () => allCreators,
185
- audioAnnotation: () => audioAnnotation,
186
- captionedImageAnnotation: () => captionedImageAnnotation,
187
- createAudioAnnotation: () => createAudioAnnotation,
188
- createCaptionedImageAnnotation: () => createCaptionedImageAnnotation,
189
- createFromIIIFBrowserOutput: () => createFromIIIFBrowserOutput,
190
- createFromManifestBrowserOutput: () => createFromManifestBrowserOutput,
191
- createHtmlAnnotation: () => createHtmlAnnotation,
192
- createHtmlBody: () => createHtmlBody,
193
- createImageServer: () => createImageServer,
194
- createImageServiceAnnotation: () => createImageServiceAnnotation,
195
- createImageUrl: () => createImageUrl,
196
- createImageUrlAnnotation: () => createImageUrlAnnotation,
197
- createImageUrlList: () => createImageUrlList,
198
- createImageUrlListAnnotation: () => createImageUrlListAnnotation,
199
- createNoBodyAnnotation: () => createNoBodyAnnotation,
200
- createPlaintext: () => createPlaintext,
201
- createThumbnail: () => createThumbnail,
202
- createVideoAnnotation: () => createVideoAnnotation,
203
- createWebPage: () => createWebPage,
204
- createYoutubeBody: () => createYoutubeBody,
205
- emptyAnnotationPage: () => emptyAnnotationPage,
206
- emptyCanvas: () => emptyCanvas,
207
- getYouTubeId: () => getYouTubeId,
208
- htmlAnnotation: () => htmlAnnotation,
209
- htmlBodyCreator: () => htmlBodyCreator,
210
- iiifBrowserCreator: () => iiifBrowserCreator,
211
- imageServiceAnnotation: () => imageServiceAnnotation,
212
- imageServiceCreator: () => imageServiceCreator,
213
- imageUrlAnnotation: () => imageUrlAnnotation,
214
- imageUrlCreator: () => imageUrlCreator,
215
- imageUrlListAnnotation: () => imageUrlListAnnotation,
216
- imageUrlListCreator: () => imageUrlListCreator,
217
- internalCanvas: () => internalCanvas,
218
- manifestBrowserCreator: () => manifestBrowserCreator,
219
- noBodyAnnotation: () => noBodyAnnotation,
220
- plaintextCreator: () => plaintextCreator,
221
- validateYouTube: () => validateYouTube,
222
- videoAnnotation: () => videoAnnotation,
223
- webPageCreator: () => webPageCreator,
224
- youTubeBodyCreator: () => youTubeBodyCreator
225
- });
226
- module.exports = __toCommonJS(src_exports);
227
-
228
- // src/Annotation/AudioAnnotation/index.tsx
229
- var import_components2 = require("@manifest-editor/components");
230
- var import_creator_api = require("@manifest-editor/creator-api");
231
-
232
- // src/Annotation/AudioAnnotation/create-audio-annotation.tsx
233
- var import_helpers = require("@iiif/helpers");
234
- var import_components = require("@manifest-editor/components");
235
- var import_editors = require("@manifest-editor/editors");
236
-
237
- // ../ui/ui/MediaControls/MediaControls.tsx
238
- var import_react_iiif_vault = require("react-iiif-vault");
239
- var import_react = require("react");
240
-
241
- // ../ui/ui/MediaControls/MediaControls.icons.tsx
242
- var import_jsx_runtime = require("react/jsx-runtime");
243
- var PlayIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...props, viewBox: "4 4 16 16", xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", children: [
244
- props.title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: props.title }) : null,
245
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
246
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 5v14l11-7z", fill: "currentColor" })
247
- ] });
248
- var PauseIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...props, viewBox: "4 4 16 16", xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", children: [
249
- props.title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: props.title }) : null,
250
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
251
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" })
252
- ] });
253
- var VolumeUpIcon = ({ title, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "2 2 20 20", children: [
254
- title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: title }) : null,
255
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
256
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
257
- "path",
258
- {
259
- fill: "currentColor",
260
- d: "M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"
261
- }
262
- )
263
- ] });
264
- var VolumeDownIcon = ({ title, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "2 2 20 20", children: [
265
- title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: title }) : null,
266
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
267
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
268
- "path",
269
- {
270
- fill: "currentColor",
271
- d: "M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"
272
- }
273
- )
274
- ] });
275
- var VolumeOffIcon = ({ title, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "2 2 20 20", children: [
276
- title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: title }) : null,
277
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
278
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
279
- "path",
280
- {
281
- fill: "currentColor",
282
- d: "M16.5 12A4.5 4.5 0 0 0 14 7.97v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z"
283
- }
284
- )
285
- ] });
286
-
287
- // ../ui/ui/MediaControls/MediaControls.styles.ts
288
- var import_styled_components = __toESM(require("styled-components"), 1);
289
- var AudioPlayerContainer = import_styled_components.default.div`
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./manifest-browser-form.lazy-CyY_B4mJ.cjs`);let l=require(`@manifest-editor/creator-api`),u=require(`@iiif/helpers`),d=require(`@manifest-editor/components`),f=require(`@manifest-editor/editors`),p=require(`react`);p=s(p);let m=require(`react/jsx-runtime`),h=require(`react-iiif-vault`),g=require(`styled-components`);g=s(g);let _=require(`@manifest-editor/shell`),v=require(`@iiif/parser/image-3`),y=require(`@manifest-editor/editor-api`),ee=require(`react-error-boundary`),te=require(`iiif-browser`);async function b(e,t){let n={id:e.url||t.generateId(`provider`),label:e.label,type:`Agent`,homepage:[],logo:[]};return e.homepage&&(n.homepage=[t.embed({id:e.url,label:(0,u.getValue)(e.homepageLabel)?e.homepageLabel:{en:[`Homepage`]},type:`Text`,format:`text/html`,language:[`en`]})]),e.logo&&(n.logo=[t.embed({id:e.logo,type:`Image`})]),t.embed(n)}function x(e){let t=e.options.initialData,[n,r]=(0,p.useState)(t.url||``),[i,a]=(0,p.useState)(t.label||{en:[``]}),[o,s]=(0,p.useState)(t.homepage||``),[c,l]=(0,p.useState)(t.logo||``),[u,h]=(0,p.useState)(t.homepageLabel||{en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`div`,{className:`max-w-xl`,children:[(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:i,onSave:e=>a(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`provider-logo`,children:`Logo`}),(0,m.jsx)(f.Input,{placeholder:`https://example.org/logo.png`,type:`text`,id:`provider-logo`,value:c,onChange:e=>l(e.target.value)})]}),(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`provider-homepage`,children:`Homepage`}),(0,m.jsx)(f.Input,{placeholder:`https://example.org/homepage`,type:`text`,id:`provider-homepage`,value:o,onChange:e=>s(e.target.value)})]}),o?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`homepageLabel`,focusId:`homepageLabel_`,label:`Homepage label`,fields:u,onSave:e=>h(e.toInternationalString())})}):null,(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{$margin:!1,htmlFor:`provider-url`,children:`Provider ID`}),(0,m.jsx)(`span`,{className:`text-gray-500 text-sm mb-2`,children:`Will be generated if not specified, this is not a URL that the user can follow`}),(0,m.jsx)(f.Input,{placeholder:`https://id.loc.gov/authorities/abc123`,type:`text`,id:`provider-url`,value:n,onChange:e=>r(e.target.value)})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,label:i,homepage:o,homepageLabel:u,logo:c})},children:`Add provider`})]})})}const ne=(0,l.defineCreator)({id:`@manifest-editor/provider`,label:`Provider`,summary:`Create a new provider`,resourceType:`Agent`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`,`Collection`],parentFields:[`provider`],initialData:!0},create:b,render(e){return(0,m.jsx)(x,{...e})}}),re=e=>(0,m.jsxs)(`svg`,{...e,viewBox:`4 4 16 16`,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,children:[e.title?(0,m.jsx)(`title`,{children:e.title}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{d:`M8 5v14l11-7z`,fill:`currentColor`})]}),ie=e=>(0,m.jsxs)(`svg`,{...e,viewBox:`4 4 16 16`,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,children:[e.title?(0,m.jsx)(`title`,{children:e.title}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M6 19h4V5H6v14zm8-14v14h4V5h-4z`})]}),ae=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`})]}),oe=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z`})]}),se=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M16.5 12A4.5 4.5 0 0 0 14 7.97v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z`})]}),ce=g.default.div`
290
2
  background: #ededed; // Not in variable.
291
3
  display: flex;
292
4
  padding: 0.5em;
293
5
  align-items: center;
294
- `;
295
- var BaseButton = import_styled_components.default.button`
6
+ `,le=g.default.button`
296
7
  cursor: pointer;
297
8
  padding: 0.75em 1.5em;
298
9
  font-size: 0.938em;
@@ -303,8 +14,7 @@ var BaseButton = import_styled_components.default.button`
303
14
  display: inline-block;
304
15
  vertical-align: top;
305
16
  white-space: nowrap;
306
- `;
307
- var PlayButton = (0, import_styled_components.default)(BaseButton)`
17
+ `,ue=(0,g.default)(le)`
308
18
  width: 2em;
309
19
  height: 2em;
310
20
  overflow: hidden;
@@ -318,20 +28,17 @@ var PlayButton = (0, import_styled_components.default)(BaseButton)`
318
28
  &:disabled {
319
29
  color: #999;
320
30
  }
321
- `;
322
- var TimeDisplay = import_styled_components.default.div`
31
+ `,de=g.default.div`
323
32
  margin: 0 1em;
324
33
  font-size: 0.85em;
325
34
  color: #000;
326
- `;
327
- var ProgressContainer = import_styled_components.default.div`
35
+ `,fe=g.default.div`
328
36
  flex: 1 1 0px;
329
37
  height: 6px;
330
38
  display: flex;
331
39
  position: relative;
332
40
  padding: 15px 0;
333
- `;
334
- var ProgressCurrent = import_styled_components.default.div`
41
+ `,pe=g.default.div`
335
42
  background: #d85680;
336
43
  height: 6px;
337
44
  pointer-events: none;
@@ -340,8 +47,7 @@ var ProgressCurrent = import_styled_components.default.div`
340
47
  left: 0;
341
48
  border-radius: 3px;
342
49
  transition: width 200ms;
343
- `;
344
- var ProgressBackground = import_styled_components.default.div`
50
+ `,me=g.default.div`
345
51
  position: absolute;
346
52
  top: 13px;
347
53
  left: 0;
@@ -350,8 +56,7 @@ var ProgressBackground = import_styled_components.default.div`
350
56
  width: 100%;
351
57
  pointer-events: none;
352
58
  background: #fff;
353
- `;
354
- var SoundButton = (0, import_styled_components.default)(BaseButton)`
59
+ `,he=(0,g.default)(le)`
355
60
  width: 2em;
356
61
  height: 2em;
357
62
  overflow: hidden;
@@ -360,59 +65,22 @@ var SoundButton = (0, import_styled_components.default)(BaseButton)`
360
65
  border-radius: 3px;
361
66
  padding: 0;
362
67
  margin: 0;
363
- `;
364
- var SoundContainer = import_styled_components.default.div`
68
+ `,ge=g.default.div`
365
69
  display: flex;
366
70
  align-items: center;
367
- `;
368
- var VolumeContainer = import_styled_components.default.div`
71
+ `,_e=g.default.div`
369
72
  width: 0;
370
73
  overflow: hidden;
371
74
  transition: width 500ms;
372
75
  color: #4a473f; // Not in colours
373
76
 
374
- ${(props) => props.$isOpen && import_styled_components.css`
77
+ ${e=>e.$isOpen&&g.css`
375
78
  width: 150px;
376
79
  `}
377
- `;
378
- var VolumeSlider = import_styled_components.default.input.attrs({ type: "range" })`
80
+ `,ve=g.default.input.attrs({type:`range`})`
379
81
  width: 120px;
380
82
  margin: 0 15px;
381
- `;
382
-
383
- // ../ui/madoc/components/icons/Spinner.tsx
384
- var import_jsx_runtime2 = require("react/jsx-runtime");
385
- function Spinner(props) {
386
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
387
- "svg",
388
- {
389
- width: "1em",
390
- height: "1em",
391
- viewBox: "0 0 42 42",
392
- xmlns: "http://www.w3.org/2000/svg",
393
- stroke: "currentColor",
394
- ...props,
395
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { transform: "translate(2 2)", strokeWidth: 5, fill: "none", fillRule: "evenodd", children: [
396
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { strokeOpacity: 0.5, cx: 18, cy: 18, r: 18 }),
397
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
398
- "animateTransform",
399
- {
400
- attributeName: "transform",
401
- type: "rotate",
402
- from: "0 18 18",
403
- to: "360 18 18",
404
- dur: "1s",
405
- repeatCount: "indefinite"
406
- }
407
- ) })
408
- ] })
409
- }
410
- );
411
- }
412
-
413
- // ../ui/atoms/VisuallHidden/VisuallHidden.tsx
414
- var import_styled_components2 = __toESM(require("styled-components"), 1);
415
- var visuallyHidden = import_styled_components2.css`
83
+ `;function ye(e){return(0,m.jsx)(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 42 42`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,...e,children:(0,m.jsxs)(`g`,{transform:`translate(2 2)`,strokeWidth:5,fill:`none`,fillRule:`evenodd`,children:[(0,m.jsx)(`circle`,{strokeOpacity:.5,cx:18,cy:18,r:18}),(0,m.jsx)(`path`,{d:`M36 18c0-9.94-8.06-18-18-18`,children:(0,m.jsx)(`animateTransform`,{attributeName:`transform`,type:`rotate`,from:`0 18 18`,to:`360 18 18`,dur:`1s`,repeatCount:`indefinite`})})]})})}const be=g.css`
416
84
  clip: rect(1px, 1px, 1px, 1px);
417
85
  clip-path: inset(50%);
418
86
  height: 1px;
@@ -421,2333 +89,9 @@ var visuallyHidden = import_styled_components2.css`
421
89
  overflow: hidden;
422
90
  padding: 0;
423
91
  position: absolute;
424
- `;
425
- var VisuallyHiddenLabel = import_styled_components2.default.label`
426
- ${visuallyHidden}
427
- `;
428
-
429
- // ../ui/ui/MediaControls/MediaControls.tsx
430
- var import_jsx_runtime3 = require("react/jsx-runtime");
431
- function MediaControls(props) {
432
- const [isVolumeOpen, setIsVolumeOpen] = (0, import_react.useState)(false);
433
- const { progress, currentTime, element } = (0, import_react_iiif_vault.useMediaElements)();
434
- const { duration, isMuted, volume, isPlaying, playRequested } = (0, import_react_iiif_vault.useMediaState)();
435
- const { setVolume, toggleMute, play, pause, setDurationPercent } = (0, import_react_iiif_vault.useMediaActions)();
436
- const Volume = isMuted || volume === 0 ? VolumeOffIcon : volume > 50 ? VolumeUpIcon : VolumeDownIcon;
437
- (0, import_react.useLayoutEffect)(() => {
438
- if (element.current) {
439
- const $el = element.current;
440
- if ($el.error && props.onError) {
441
- props.onError($el.error?.message || "Unknown error");
442
- return;
443
- }
444
- const onError = () => {
445
- if (props.onError) {
446
- props.onError($el.error?.message || "Unknown error");
447
- }
448
- };
449
- const loadedMetadata = () => {
450
- if ($el.duration && props.onDuration) {
451
- props.onDuration($el.duration);
452
- }
453
- if (props.onDimensions && $el instanceof HTMLVideoElement) {
454
- props.onDimensions($el.videoWidth, $el.videoHeight);
455
- }
456
- };
457
- $el.addEventListener("loadedmetadata", loadedMetadata);
458
- $el.addEventListener("error", onError);
459
- return () => {
460
- $el.removeEventListener("loadedmetadata", loadedMetadata);
461
- $el.removeEventListener("error", onError);
462
- };
463
- }
464
- }, []);
465
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(AudioPlayerContainer, { children: [
466
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
467
- PlayButton,
468
- {
469
- disabled: playRequested,
470
- onClick: () => {
471
- if (isPlaying) {
472
- pause();
473
- } else {
474
- play();
475
- }
476
- },
477
- children: playRequested ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Spinner, { stroke: "#999" }) : isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PauseIcon, { title: "Pause" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PlayIcon, { title: "Play" })
478
- }
479
- ),
480
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TimeDisplay, { ref: currentTime, children: "0:00" }),
481
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
482
- ProgressContainer,
483
- {
484
- onClick: (e) => {
485
- const { left, width } = e.currentTarget.getBoundingClientRect();
486
- const percent = (e.pageX - left) / width;
487
- setDurationPercent(percent);
488
- },
489
- children: [
490
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProgressBackground, {}),
491
- duration ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProgressCurrent, { ref: progress }) : null
492
- ]
493
- }
494
- ),
495
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TimeDisplay, { children: (0, import_react_iiif_vault.formatTime)(duration) }),
496
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SoundContainer, { onMouseEnter: () => setIsVolumeOpen(true), onMouseLeave: () => setIsVolumeOpen(false), children: [
497
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VolumeContainer, { $isOpen: isVolumeOpen, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
498
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VisuallyHiddenLabel, { htmlFor: "audio-slider", children: "Change volume" }),
499
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
500
- VolumeSlider,
501
- {
502
- id: "audio-slider",
503
- role: "slider",
504
- disabled: isMuted,
505
- min: "0",
506
- max: "100",
507
- value: volume,
508
- onChange: (e) => setVolume(Number(e.currentTarget.value))
509
- }
510
- )
511
- ] }) }),
512
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SoundButton, { onClick: () => toggleMute(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Volume, { title: isMuted ? "Mute" : "Unmute" }) })
513
- ] })
514
- ] });
515
- }
516
-
517
- // ../ui/atoms/PaddedSidebarContainer.tsx
518
- var import_styled_components3 = __toESM(require("styled-components"), 1);
519
- var PaddedSidebarContainer = import_styled_components3.default.div`
520
- padding: 0 0.7em;
521
- margin: 0.7em 0;
522
- flex: 1;
523
- overflow: visible;
524
- `;
525
-
526
- // src/Annotation/AudioAnnotation/create-audio-annotation.tsx
527
- var import_react2 = require("react");
528
- var import_react_iiif_vault2 = require("react-iiif-vault");
529
- var import_jsx_runtime4 = require("react/jsx-runtime");
530
- async function createAudioAnnotation(data, ctx) {
531
- const annotation = {
532
- id: ctx.generateId("annotation"),
533
- type: "Annotation"
534
- };
535
- const targetType = ctx.options.targetType;
536
- const body = ctx.embed({
537
- id: data.url,
538
- type: "Sound",
539
- format: "audio/mp4",
540
- duration: data.duration || 0
541
- });
542
- if (targetType === "Annotation") {
543
- return ctx.embed({
544
- ...annotation,
545
- label: (0, import_helpers.getValue)(data.label) && data.label,
546
- motivation: data.motivation || ctx.options.initialData?.motivation || "painting",
547
- body,
548
- target: ctx.getTarget()
549
- });
550
- }
551
- if (targetType === "Canvas") {
552
- const canvasId = ctx.generateId("canvas");
553
- const pageId = ctx.generateId("annotation-page", {
554
- id: canvasId,
555
- type: "Canvas"
556
- });
557
- const annotationResource = ctx.embed({
558
- ...annotation,
559
- motivation: "painting",
560
- body,
561
- target: {
562
- type: "SpecificResource",
563
- source: { id: canvasId, type: "Canvas" }
564
- }
565
- });
566
- const page = ctx.embed({
567
- id: pageId,
568
- type: "AnnotationPage",
569
- items: [annotationResource]
570
- });
571
- return ctx.embed({
572
- id: canvasId,
573
- type: "Canvas",
574
- label: data.label || { en: ["Untitled HTML canvas"] },
575
- duration: data.duration || 0,
576
- items: [page]
577
- });
578
- }
579
- }
580
- function CreateAudioAnnotationForm(props) {
581
- const [url, setUrl] = (0, import_react2.useState)("");
582
- const [duration, setDuration] = (0, import_react2.useState)(0);
583
- const [error, setError] = (0, import_react2.useState)("");
584
- const [label, setLabel] = (0, import_react2.useState)({ en: [""] });
585
- const onSubmit = () => {
586
- props.runCreate({
587
- url,
588
- duration,
589
- label
590
- });
591
- };
592
- (0, import_react2.useEffect)(() => {
593
- setError("");
594
- setDuration(0);
595
- if (url) {
596
- const labelFromUrl = url.split("/").pop()?.split(".").shift();
597
- setLabel({ en: [labelFromUrl || ""] });
598
- }
599
- }, [url]);
600
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(PaddedSidebarContainer, { children: [
601
- error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_components.ErrorMessage, { children: error }) : null,
602
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_editors.InputContainer, { $wide: true, children: [
603
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.InputLabel, { htmlFor: "audio-url", children: "URL" }),
604
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.Input, { type: "text", id: "audio-url", value: url, onChange: (e) => setUrl(e.target.value) })
605
- ] }),
606
- url && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
607
- import_editors.LanguageFieldEditor,
608
- {
609
- containerId: "label",
610
- focusId: "label_",
611
- label: "Label",
612
- fields: label,
613
- onSave: (e) => setLabel(e.toInternationalString())
614
- },
615
- `${url}__${duration}`
616
- ) }) : null,
617
- url && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_iiif_vault2.CanvasPanel.AudioHTML, { media: { url, duration, type: "Sound" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
618
- MediaControls,
619
- {
620
- onError: (error2) => setError(error2),
621
- onDuration: (duration2) => setDuration(~~duration2)
622
- },
623
- `${url}__${duration}`
624
- ) }, `${url}__${duration}`) : null,
625
- duration && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_editors.FormFieldWrapper, { children: [
626
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.InputLabel, { htmlFor: "duration", children: "Duration" }),
627
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.Input, { type: "number", id: "duration", value: duration, onChange: (e) => setDuration(e.target.valueAsNumber) })
628
- ] }) : null,
629
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_components.ActionButton, { primary: true, large: true, type: "button", onPress: onSubmit, isDisabled: !url || !!error, children: "Add audio" })
630
- ] });
631
- }
632
-
633
- // src/Annotation/AudioAnnotation/index.tsx
634
- var import_jsx_runtime5 = require("react/jsx-runtime");
635
- var audioAnnotation = (0, import_creator_api.defineCreator)({
636
- id: "@manifest-editor/audio-annotation",
637
- create: createAudioAnnotation,
638
- label: "Audio",
639
- summary: "Audio annotation",
640
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_components2.AudioIcon, {}),
641
- render(ctx) {
642
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CreateAudioAnnotationForm, { ...ctx });
643
- },
644
- resourceType: "Annotation",
645
- resourceFields: ["id", "type", "motivation", "body", "target"],
646
- additionalTypes: ["Canvas"],
647
- supports: {
648
- initialData: true,
649
- parentTypes: ["AnnotationPage", "Manifest"],
650
- parentFields: ["items"]
651
- },
652
- staticFields: {
653
- type: "Annotation"
654
- }
655
- });
656
-
657
- // src/Annotation/CaptionedImageAnnotation/index.tsx
658
- var import_components4 = require("@manifest-editor/components");
659
- var import_creator_api2 = require("@manifest-editor/creator-api");
660
-
661
- // src/Annotation/CaptionedImageAnnotation/create-captioned-image-annotation.tsx
662
- var import_components3 = require("@manifest-editor/components");
663
- var import_editors2 = require("@manifest-editor/editors");
664
- var import_react3 = require("react");
665
- var import_jsx_runtime6 = require("react/jsx-runtime");
666
- async function createCaptionedImageAnnotation(data, ctx) {
667
- const annotation = {
668
- id: ctx.generateId("annotation"),
669
- type: "Annotation"
670
- };
671
- const targetType = ctx.options.targetType;
672
- const languages = Object.keys(data.body);
673
- const bodies = [];
674
- for (const language of languages) {
675
- const body = data.body[language].join("\n");
676
- if (body) {
677
- bodies.push(
678
- await ctx.create(
679
- "@manifest-editor/html-body-creator",
680
- {
681
- language,
682
- body
683
- },
684
- { parent: { resource: annotation, property: "items" } }
685
- )
686
- );
687
- }
688
- }
689
- const resource = await ctx.create(
690
- "@manifest-editor/image-url-creator",
691
- { url: data.imageUrl },
692
- {
693
- parent: { resource: annotation, property: "body" }
694
- }
695
- );
696
- if (resource) {
697
- bodies.push(resource);
698
- }
699
- if (targetType === "Annotation") {
700
- return ctx.embed({
701
- ...annotation,
702
- motivation: data.motivation || ctx.options.initialData?.motivation || "painting",
703
- body: bodies,
704
- target: ctx.getTarget()
705
- });
706
- }
707
- if (targetType === "Canvas") {
708
- const canvasId = ctx.generateId("canvas");
709
- const pageId = ctx.generateId("annotation-page", {
710
- id: canvasId,
711
- type: "Canvas"
712
- });
713
- const annotationResource = ctx.embed({
714
- ...annotation,
715
- motivation: "painting",
716
- body: bodies,
717
- target: {
718
- type: "SpecificResource",
719
- source: { id: canvasId, type: "Canvas" }
720
- }
721
- });
722
- const page = ctx.embed({
723
- id: pageId,
724
- type: "AnnotationPage",
725
- items: [annotationResource]
726
- });
727
- return ctx.embed({
728
- id: canvasId,
729
- type: "Canvas",
730
- label: data.label || { en: ["Untitled HTML canvas"] },
731
- height: data.height || 1e3,
732
- width: data.width || 1e3,
733
- items: [page]
734
- });
735
- }
736
- }
737
- function CreateCaptionedImageAnnotation(props) {
738
- const [body, setBody] = (0, import_react3.useState)({ en: [""] });
739
- const onSubmit = (e) => {
740
- e.preventDefault();
741
- const data = new FormData(e.target);
742
- const formData = Object.fromEntries(data.entries());
743
- props.runCreate({
744
- body,
745
- imageUrl: formData.url
746
- });
747
- };
748
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("form", { onSubmit, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(PaddedSidebarContainer, { children: [
749
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_editors2.InputContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_editors2.InputContainer, { $wide: true, children: [
750
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_editors2.InputLabel, { htmlFor: "id", children: "Link to Image" }),
751
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_editors2.Input, { id: "url", name: "url", defaultValue: "" })
752
- ] }) }),
753
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_editors2.InputContainer, { children: [
754
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_editors2.InputLabel, { children: "Image Caption" }),
755
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
756
- import_editors2.LanguageFieldEditor,
757
- {
758
- focusId: "html-content",
759
- label: "HTML Content",
760
- fields: body,
761
- onSave: (e) => setBody(e.toInternationalString())
762
- }
763
- )
764
- ] }),
765
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_components3.ActionButton, { primary: true, large: true, type: "submit", children: "Create" })
766
- ] }) });
767
- }
768
-
769
- // src/Annotation/CaptionedImageAnnotation/index.tsx
770
- var import_jsx_runtime7 = require("react/jsx-runtime");
771
- var captionedImageAnnotation = (0, import_creator_api2.defineCreator)({
772
- id: "@manifest-editor/captioned-image-annotation",
773
- create: createCaptionedImageAnnotation,
774
- label: "Captioned image",
775
- summary: "Add an image from a URL with caption",
776
- icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_components4.AddImageIcon, {}),
777
- render(ctx) {
778
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreateCaptionedImageAnnotation, { ...ctx });
779
- },
780
- resourceType: "Annotation",
781
- resourceFields: ["id", "type", "motivation", "body", "target"],
782
- additionalTypes: ["Canvas"],
783
- supports: {
784
- initialData: true,
785
- parentTypes: ["AnnotationPage"],
786
- parentFields: ["items"]
787
- },
788
- staticFields: {
789
- type: "Annotation"
790
- }
791
- });
792
-
793
- // src/Annotation/HTMLAnnotation/index.tsx
794
- var import_components6 = require("@manifest-editor/components");
795
- var import_creator_api3 = require("@manifest-editor/creator-api");
796
-
797
- // src/Annotation/HTMLAnnotation/create-html-annotation.tsx
798
- var import_helpers2 = require("@iiif/helpers");
799
- var import_components5 = require("@manifest-editor/components");
800
- var import_editors3 = require("@manifest-editor/editors");
801
- var import_react4 = require("react");
802
- var import_jsx_runtime8 = require("react/jsx-runtime");
803
- async function createHtmlAnnotation(data, ctx) {
804
- const annotation = {
805
- id: ctx.generateId("annotation"),
806
- type: "Annotation"
807
- };
808
- const targetType = ctx.options.targetType;
809
- const languages = Object.keys(data.body);
810
- const bodies = [];
811
- for (const language of languages) {
812
- const body = data.body[language].join("\n");
813
- if (body) {
814
- bodies.push(
815
- await ctx.create(
816
- "@manifest-editor/html-body-creator",
817
- {
818
- language,
819
- body
820
- },
821
- { parent: { resource: annotation, property: "items" } }
822
- )
823
- );
824
- }
825
- }
826
- if (targetType === "Annotation") {
827
- return ctx.embed({
828
- ...annotation,
829
- motivation: data.motivation || ctx.options.initialData?.motivation || "painting",
830
- body: bodies,
831
- target: ctx.getTarget()
832
- });
833
- }
834
- if (targetType === "Canvas") {
835
- const canvasId = ctx.generateId("canvas");
836
- const pageId = ctx.generateId("annotation-page", {
837
- id: canvasId,
838
- type: "Canvas"
839
- });
840
- const annotationResource = ctx.embed({
841
- ...annotation,
842
- motivation: "painting",
843
- body: bodies,
844
- target: {
845
- type: "SpecificResource",
846
- source: { id: canvasId, type: "Canvas" }
847
- }
848
- });
849
- const page = ctx.embed({
850
- id: pageId,
851
- type: "AnnotationPage",
852
- items: [annotationResource]
853
- });
854
- return ctx.embed({
855
- id: canvasId,
856
- type: "Canvas",
857
- label: data.label || { en: ["Untitled HTML canvas"] },
858
- height: data.height || 1e3,
859
- width: data.width || 1e3,
860
- items: [page]
861
- });
862
- }
863
- }
864
- function CreateHTMLAnnotation(props) {
865
- const [body, setBody] = (0, import_react4.useState)({ en: [""] });
866
- const isEmpty = (0, import_helpers2.getValue)(body).trim() === "";
867
- const onSubmit = () => {
868
- props.runCreate({
869
- body
870
- });
871
- };
872
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(PaddedSidebarContainer, { children: [
873
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
874
- import_editors3.LanguageFieldEditor,
875
- {
876
- focusId: "html-content",
877
- label: "HTML Content",
878
- fields: body,
879
- onSave: (e) => setBody(e.toInternationalString())
880
- }
881
- ),
882
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components5.ActionButton, { primary: true, large: true, type: "button", onPress: onSubmit, isDisabled: isEmpty, children: "Create" })
883
- ] });
884
- }
885
-
886
- // src/Annotation/HTMLAnnotation/index.tsx
887
- var import_jsx_runtime9 = require("react/jsx-runtime");
888
- var htmlAnnotation = (0, import_creator_api3.defineCreator)({
889
- id: "@manifest-editor/html-annotation",
890
- create: createHtmlAnnotation,
891
- label: "HTML",
892
- summary: "HTML annotation",
893
- icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_components6.HTMLIcon, {}),
894
- render(ctx) {
895
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CreateHTMLAnnotation, { ...ctx });
896
- },
897
- resourceType: "Annotation",
898
- resourceFields: ["id", "type", "motivation", "body", "target"],
899
- additionalTypes: ["Canvas"],
900
- supports: {
901
- initialData: true,
902
- parentTypes: ["AnnotationPage", "Manifest"],
903
- parentFields: ["items"]
904
- },
905
- staticFields: {
906
- type: "Annotation"
907
- }
908
- });
909
-
910
- // src/Annotation/ImageServiceAnnotation/index.tsx
911
- var import_components8 = require("@manifest-editor/components");
912
- var import_creator_api5 = require("@manifest-editor/creator-api");
913
-
914
- // src/side-effects/reposition-multiple-images.ts
915
- var import_image_3 = require("@iiif/parser/image-3");
916
- var import_editor_api = require("@manifest-editor/editor-api");
917
- var import_editors4 = require("@manifest-editor/editors");
918
- var repositionMultipleImages = {
919
- canvasInteraction: true,
920
- spatial: true,
921
- async run(result, { vault, options }) {
922
- if (result && result.type === "Annotation" && options.targetType === "Annotation") {
923
- const fullAnno = vault.get(result);
924
- const target = fullAnno.target;
925
- if (!(target && target.source?.type === "Canvas")) {
926
- return;
927
- }
928
- const canvasRef = target.source;
929
- const canvas = vault.get(canvasRef);
930
- if (!canvas.items) {
931
- return;
932
- }
933
- const annoPage = vault.get(canvas.items[0]);
934
- if (!annoPage) {
935
- return;
936
- }
937
- if (annoPage.items.length < 2 && !canvas.behavior.includes("multi-image")) {
938
- return;
939
- }
940
- const bodies = vault.get(fullAnno.body);
941
- const body = bodies[0];
942
- const selector = fullAnno.body[0]?.selector;
943
- const serviceList = body.service || [];
944
- const imageService = serviceList.find((s) => (0, import_image_3.isImageService)(s));
945
- if (imageService) {
946
- if (imageService.width && imageService.height) {
947
- if (imageService.width !== body.width) {
948
- vault.modifyEntityField(
949
- { id: body.id, type: "ContentResource" },
950
- "width",
951
- imageService.width
952
- );
953
- }
954
- if (imageService.height !== body.height) {
955
- vault.modifyEntityField(
956
- { id: body.id, type: "ContentResource" },
957
- "height",
958
- imageService.height
959
- );
960
- }
961
- }
962
- }
963
- let width = imageService?.width || body.width;
964
- let height = imageService?.height || body.height;
965
- if (selector) {
966
- if ((selector.type === "iiif:ImageApiSelector" || selector.type === "ImageApiSelector") && selector.region) {
967
- const [x, y, width_, height_] = selector.region.split(",");
968
- width = Number(width_) || width;
969
- height = Number(height_) || height;
970
- }
971
- }
972
- const editor = new import_editor_api.EditorInstance({ vault, reference: result });
973
- const imagePosition = (0, import_editors4.centerRectangles)(
974
- canvas,
975
- {
976
- width,
977
- height
978
- },
979
- 0.6
980
- );
981
- editor.annotation.target.setPosition(imagePosition);
982
- }
983
- }
984
- };
985
-
986
- // src/side-effects/resize-resource-to-empty-canvas.ts
987
- var import_editor_api2 = require("@manifest-editor/editor-api");
988
- var resizeResourceToEmptyCanvas = {
989
- canvasInteraction: true,
990
- spatial: true,
991
- async run(result, { vault, options }) {
992
- if (result && result.type === "Annotation" && options.targetType === "Annotation") {
993
- const fullAnno = vault.get(result);
994
- const target = fullAnno.target;
995
- if (!(target && target.source?.type === "Canvas")) {
996
- return;
997
- }
998
- const canvasRef = target.source;
999
- const canvas = vault.get(canvasRef);
1000
- if (!canvas.items) {
1001
- return;
1002
- }
1003
- if (canvas.behavior.includes("multi-image")) {
1004
- return;
1005
- }
1006
- const annoPage = vault.get(canvas.items[0]);
1007
- if (!annoPage) {
1008
- return;
1009
- }
1010
- if (annoPage.items.length > 1) {
1011
- return;
1012
- }
1013
- const bodies = vault.get(fullAnno.body);
1014
- if (bodies.length !== 1) {
1015
- return;
1016
- }
1017
- const body = bodies[0];
1018
- const selector = fullAnno.body[0]?.selector;
1019
- const service = (body.service || [])[0];
1020
- let width = service?.width || body.width;
1021
- let height = service?.height || body.height;
1022
- const duration = body.duration || service?.duration;
1023
- if (selector) {
1024
- if ((selector.type === "iiif:ImageApiSelector" || selector.type === "ImageApiSelector") && selector.region) {
1025
- const [x, y, width_, height_] = selector.region.split(",");
1026
- width = Number(width_) || width;
1027
- height = Number(height_) || height;
1028
- }
1029
- }
1030
- const editor = new import_editor_api2.EditorInstance({ vault, reference: canvasRef });
1031
- vault.batch(() => {
1032
- if (typeof width !== "undefined") {
1033
- editor.technical.width.set(width);
1034
- }
1035
- if (typeof height !== "undefined") {
1036
- editor.technical.height.set(height);
1037
- }
1038
- if (typeof duration !== "undefined") {
1039
- editor.technical.duration.set(duration);
1040
- }
1041
- });
1042
- }
1043
- }
1044
- };
1045
-
1046
- // src/side-effects/resize-to-fit-service.ts
1047
- var import_iiif_image_api = require("@atlas-viewer/iiif-image-api");
1048
- var resizeToFitService = {
1049
- canvasInteraction: true,
1050
- spatial: true,
1051
- async run(result, { vault, options }) {
1052
- if (result && result.type === "Annotation" && options.targetType === "Annotation") {
1053
- const fullAnno = vault.get(result);
1054
- const target = fullAnno.target;
1055
- if (!(target && target.source?.type === "Canvas")) {
1056
- return;
1057
- }
1058
- const canvasRef = target.source;
1059
- const canvas = vault.get(canvasRef);
1060
- if (!canvas.items) {
1061
- return;
1062
- }
1063
- if (canvas.behavior.includes("multi-image")) {
1064
- return;
1065
- }
1066
- const annoPage = vault.get(canvas.items[0]);
1067
- if (!annoPage) {
1068
- return;
1069
- }
1070
- const resourceBody = Array.isArray(fullAnno.body) ? fullAnno.body[0] : fullAnno.body;
1071
- if (resourceBody.type === "SpecificResource" && resourceBody.selector) {
1072
- return;
1073
- }
1074
- const bodies = vault.get(fullAnno.body);
1075
- const body = bodies[0];
1076
- const serviceList = body.service || [];
1077
- const imageService = serviceList.find((s) => (0, import_iiif_image_api.isImageService)(s));
1078
- if (imageService) {
1079
- if (imageService.width && imageService.height) {
1080
- if (imageService.width !== body.width) {
1081
- vault.modifyEntityField(
1082
- { id: body.id, type: "ContentResource" },
1083
- "width",
1084
- imageService.width
1085
- );
1086
- }
1087
- if (imageService.height !== body.height) {
1088
- vault.modifyEntityField(
1089
- { id: body.id, type: "ContentResource" },
1090
- "height",
1091
- imageService.height
1092
- );
1093
- }
1094
- }
1095
- }
1096
- }
1097
- }
1098
- };
1099
-
1100
- // src/Annotation/ImageServiceAnnotation/create-service-annotation.tsx
1101
- var import_creator_api4 = require("@manifest-editor/creator-api");
1102
-
1103
- // src/ContentResource/ImageServiceCreator/create-image-service.tsx
1104
- var import_image_32 = require("@iiif/parser/image-3");
1105
- var import_components7 = require("@manifest-editor/components");
1106
- var import_editors5 = require("@manifest-editor/editors");
1107
- var import_react5 = require("react");
1108
- var import_react_error_boundary = require("react-error-boundary");
1109
- var import_react_iiif_vault3 = require("react-iiif-vault");
1110
- var import_jsx_runtime10 = require("react/jsx-runtime");
1111
- async function createImageServer(data, ctx) {
1112
- const service = { ...data.service };
1113
- if (service["@id"]) {
1114
- service.id = service["@id"];
1115
- }
1116
- if (service["@type"]) {
1117
- service.type = service["@type"];
1118
- }
1119
- const request = (0, import_image_32.createImageServiceRequest)(service);
1120
- const imageId = (0, import_image_32.imageServiceRequestToString)({
1121
- identifier: request.identifier,
1122
- server: request.server,
1123
- scheme: request.scheme,
1124
- type: "image",
1125
- size: {
1126
- max: !data.size?.width && !data.size?.height,
1127
- confined: false,
1128
- upscaled: false,
1129
- ...data.size || {}
1130
- },
1131
- format: "jpg",
1132
- // This isn't how it should be modelled, always full,
1133
- // region: data.selector ? data.selector : { full: true },
1134
- region: { full: true },
1135
- rotation: { angle: 0 },
1136
- quality: "default",
1137
- prefix: request.prefix,
1138
- originalPath: request.originalPath
1139
- });
1140
- const resource = ctx.embed({
1141
- id: imageId,
1142
- type: "Image",
1143
- format: data.format || "image/jpeg",
1144
- height: data.height || service.height,
1145
- width: data.width || service.width,
1146
- service: data.embedService === false ? void 0 : [data.service]
1147
- });
1148
- return resource;
1149
- }
1150
- function getCanonicalUrl(url) {
1151
- return url.endsWith("default.jpg") ? (0, import_image_32.imageServiceRequestToString)({
1152
- ...(0, import_image_32.parseImageServiceRequest)(url),
1153
- type: "info"
1154
- }) : (0, import_image_32.canonicalServiceUrl)(url);
1155
- }
1156
- function CreateImageServerForm(props) {
1157
- const [url, setUrl] = (0, import_react5.useState)("");
1158
- const onSubmit = (e) => {
1159
- e.preventDefault();
1160
- const data = new FormData(e.target);
1161
- const formData = Object.fromEntries(data.entries());
1162
- const url2 = formData.url;
1163
- if (url2) {
1164
- const info = getCanonicalUrl(url2);
1165
- if (!info) {
1166
- throw new Error("Invalid image service request");
1167
- }
1168
- fetch(info).then((r) => r.json()).then((service) => {
1169
- props.runCreate({ url: formData.url, service });
1170
- });
1171
- }
1172
- };
1173
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { onSubmit, children: [
1174
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_editors5.InputContainer, { $wide: true, children: [
1175
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_editors5.InputLabel, { htmlFor: "id", children: "Link to image service" }),
1176
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1177
- import_editors5.Input,
1178
- {
1179
- id: "url",
1180
- name: "url",
1181
- defaultValue: "",
1182
- onPaste: (e) => {
1183
- const text = e.clipboardData.getData("text/plain");
1184
- setUrl(text ? getCanonicalUrl(text) : "");
1185
- },
1186
- onBlur: (e) => setUrl(e.currentTarget.value ? getCanonicalUrl(e.currentTarget.value) : "")
1187
- }
1188
- )
1189
- ] }) }),
1190
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "relative flex z-0 my-5 h-96 min-h-0 min-w-0 overflow-hidden bg-gray-200 rounded items-center justify-center", children: url.trim() ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_error_boundary.ErrorBoundary, { fallbackRender: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: "Invalid service" }), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1191
- import_react_iiif_vault3.ImageService,
1192
- {
1193
- src: url,
1194
- fluid: true,
1195
- errorFallback: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: "Invalid service" }),
1196
- background: "rgb(229,231,235)",
1197
- className: "h-full w-full",
1198
- containerProps: { className: "w-full h-full z-10" }
1199
- }
1200
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "text-grey-600", children: "Preview" }) }),
1201
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_components7.ActionButton, { primary: true, large: true, type: "submit", isDisabled: !url, children: "Create" }) })
1202
- ] }) });
1203
- }
1204
-
1205
- // src/Annotation/ImageServiceAnnotation/create-service-annotation.tsx
1206
- var import_jsx_runtime11 = require("react/jsx-runtime");
1207
- async function createImageServiceAnnotation(data, ctx) {
1208
- const annotation = {
1209
- id: ctx.generateId("annotation"),
1210
- type: "Annotation"
1211
- };
1212
- const targetType = ctx.options.targetType;
1213
- const createImage = (0, import_creator_api4.creatorHelper)(ctx, "Annotation", "body", "@manifest-editor/image-service-creator");
1214
- const resource = await createImage(data, {
1215
- parent: { resource: annotation, property: "body" }
1216
- });
1217
- if (targetType === "Annotation") {
1218
- return {
1219
- ...annotation,
1220
- body: [resource],
1221
- motivation: data.motivation || "painting",
1222
- target: ctx.getTarget()
1223
- };
1224
- }
1225
- if (targetType === "Canvas") {
1226
- const canvasId = ctx.generateId("canvas");
1227
- const pageId = ctx.generateId("annotation-page", {
1228
- id: canvasId,
1229
- type: "Canvas"
1230
- });
1231
- const annotationResource = ctx.embed({
1232
- ...annotation,
1233
- motivation: "painting",
1234
- body: [resource],
1235
- target: {
1236
- type: "SpecificResource",
1237
- source: { id: canvasId, type: "Canvas" }
1238
- }
1239
- });
1240
- const page = ctx.embed({
1241
- id: pageId,
1242
- type: "AnnotationPage",
1243
- items: [annotationResource]
1244
- });
1245
- let thumbnail = void 0;
1246
- if (data.service?.sizes) {
1247
- const createThumbnail2 = (0, import_creator_api4.creatorHelper)(ctx, "Canvas", "thumbnail", "@manifest-editor/thumbnail-image");
1248
- thumbnail = await createThumbnail2({
1249
- service: data.service,
1250
- width: data.thumbnailSize || 400
1251
- });
1252
- }
1253
- return ctx.embed({
1254
- id: canvasId,
1255
- type: "Canvas",
1256
- label: data.label || { en: ["Untitled canvas"] },
1257
- height: resource.resource.height || 1e3,
1258
- width: resource.resource.width || 1e3,
1259
- thumbnail: thumbnail ? [thumbnail] : void 0,
1260
- items: [page]
1261
- });
1262
- }
1263
- }
1264
- function CreateImageServiceAnnotationForm(props) {
1265
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CreateImageServerForm, { ...props });
1266
- }
1267
-
1268
- // src/Annotation/ImageServiceAnnotation/index.tsx
1269
- var import_jsx_runtime12 = require("react/jsx-runtime");
1270
- var imageServiceAnnotation = (0, import_creator_api5.defineCreator)({
1271
- id: "@manifest-editor/image-service-annotation",
1272
- create: createImageServiceAnnotation,
1273
- label: "IIIF Image",
1274
- dependencies: ["@manifest-editor/image-service-creator"],
1275
- summary: "IIIF Image service",
1276
- tags: ["image", "image-service"],
1277
- icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components8.IIIFLogo, { style: { padding: 10 } }),
1278
- render(ctx) {
1279
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CreateImageServiceAnnotationForm, { ...ctx });
1280
- },
1281
- resourceType: "Annotation",
1282
- resourceFields: ["id", "type", "motivation", "body", "target"],
1283
- additionalTypes: ["Canvas"],
1284
- supports: {
1285
- parentTypes: ["AnnotationPage", "Manifest"],
1286
- parentFields: ["items"]
1287
- },
1288
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1289
- staticFields: {
1290
- type: "Annotation"
1291
- }
1292
- });
1293
-
1294
- // src/Annotation/ImageUrlAnnotation/index.tsx
1295
- var import_components10 = require("@manifest-editor/components");
1296
- var import_creator_api7 = require("@manifest-editor/creator-api");
1297
-
1298
- // src/Annotation/ImageUrlAnnotation/create-image-url-annotation.tsx
1299
- var import_creator_api6 = require("@manifest-editor/creator-api");
1300
-
1301
- // src/ContentResource/ImageUrlCreator/create-image-url.tsx
1302
- var import_components9 = require("@manifest-editor/components");
1303
- var import_editors6 = require("@manifest-editor/editors");
1304
- var import_shell = require("@manifest-editor/shell");
1305
- var import_jsx_runtime13 = require("react/jsx-runtime");
1306
- async function createImageUrl(data, ctx) {
1307
- if (!data.height || !data.width) {
1308
- const dimensions = await (0, import_shell.getImageDimensions)(data.url);
1309
- if (dimensions) {
1310
- data.height = dimensions.height;
1311
- data.width = dimensions.width;
1312
- }
1313
- }
1314
- return ctx.embed({
1315
- id: data.url,
1316
- type: "Image",
1317
- format: data.format || await (0, import_shell.getFormat)(data.url),
1318
- height: data.height,
1319
- width: data.width,
1320
- service: data.service ? Array.isArray(data.service) ? data.service : [data.service] : void 0
1321
- });
1322
- }
1323
- function CreateImageUrlForm(props) {
1324
- const onSubmit = (e) => {
1325
- e.preventDefault();
1326
- const data = new FormData(e.target);
1327
- const formData = Object.fromEntries(data.entries());
1328
- if (formData.url) {
1329
- props.runCreate({ url: formData.url });
1330
- }
1331
- };
1332
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("form", { onSubmit, children: [
1333
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_editors6.InputContainer, { $wide: true, children: [
1334
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_editors6.InputLabel, { htmlFor: "id", children: "Link to Image" }),
1335
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_editors6.Input, { id: "url", name: "url", defaultValue: "" })
1336
- ] }),
1337
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components9.ActionButton, { primary: true, large: true, type: "submit", children: "Create" })
1338
- ] }) });
1339
- }
1340
-
1341
- // src/Annotation/ImageUrlAnnotation/create-image-url-annotation.tsx
1342
- var import_jsx_runtime14 = require("react/jsx-runtime");
1343
- async function createImageUrlAnnotation(data, ctx) {
1344
- const annotation = {
1345
- id: ctx.generateId("annotation"),
1346
- type: "Annotation"
1347
- };
1348
- const targetType = ctx.options.targetType;
1349
- const createImage = (0, import_creator_api6.creatorHelper)(ctx, "Annotation", "body", "@manifest-editor/image-url-creator");
1350
- const resource = await createImage(data, {
1351
- parent: { resource: annotation, property: "body" }
1352
- });
1353
- if (targetType === "Annotation") {
1354
- return ctx.embed({
1355
- ...annotation,
1356
- body: [resource],
1357
- motivation: data.motivation || "painting",
1358
- target: ctx.getTarget()
1359
- });
1360
- }
1361
- if (targetType === "Canvas") {
1362
- const canvasId = ctx.generateId("canvas");
1363
- const pageId = ctx.generateId("annotation-page", {
1364
- id: canvasId,
1365
- type: "Canvas"
1366
- });
1367
- const annotationResource = ctx.embed({
1368
- ...annotation,
1369
- motivation: "painting",
1370
- body: [resource],
1371
- target: {
1372
- type: "SpecificResource",
1373
- source: { id: canvasId, type: "Canvas" }
1374
- }
1375
- });
1376
- const page = ctx.embed({
1377
- id: pageId,
1378
- type: "AnnotationPage",
1379
- items: [annotationResource]
1380
- });
1381
- return ctx.embed({
1382
- id: canvasId,
1383
- type: "Canvas",
1384
- label: data.label || { en: ["Untitled canvas"] },
1385
- height: resource.resource.height || 1e3,
1386
- width: resource.resource.width || 1e3,
1387
- items: [page]
1388
- });
1389
- }
1390
- throw new Error("Unsupported target type");
1391
- }
1392
- function CreateImageUrlAnnotationForm(props) {
1393
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CreateImageUrlForm, { ...props });
1394
- }
1395
-
1396
- // src/Annotation/ImageUrlAnnotation/index.tsx
1397
- var import_jsx_runtime15 = require("react/jsx-runtime");
1398
- var imageUrlAnnotation = (0, import_creator_api7.defineCreator)({
1399
- id: "@manifest-editor/image-url-annotation",
1400
- create: createImageUrlAnnotation,
1401
- label: "Image",
1402
- dependencies: ["@manifest-editor/image-url-creator"],
1403
- summary: "Image from URL",
1404
- tags: ["image"],
1405
- icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components10.AddImageIcon, {}),
1406
- render(ctx) {
1407
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CreateImageUrlAnnotationForm, { ...ctx });
1408
- },
1409
- resourceType: "Annotation",
1410
- resourceFields: ["id", "type", "motivation", "body", "target"],
1411
- additionalTypes: ["Canvas"],
1412
- supports: {
1413
- parentTypes: ["AnnotationPage", "Manifest"],
1414
- parentFields: ["items"]
1415
- },
1416
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1417
- staticFields: {
1418
- type: "Annotation"
1419
- }
1420
- });
1421
-
1422
- // src/Annotation/ImageUrlListAnnotation/index.tsx
1423
- var import_components12 = require("@manifest-editor/components");
1424
- var import_creator_api10 = require("@manifest-editor/creator-api");
1425
-
1426
- // src/ContentResource/ImageUrlListCreator/create-image-url-list.tsx
1427
- var import_components11 = require("@manifest-editor/components");
1428
- var import_creator_api8 = require("@manifest-editor/creator-api");
1429
- var import_jsx_runtime16 = require("react/jsx-runtime");
1430
- async function createImageUrlList(payload, ctx) {
1431
- const items = [];
1432
- const createImage = (0, import_creator_api8.creatorHelper)(ctx, "Annotation", "body", "@manifest-editor/image-url-creator");
1433
- for (const image of payload.images) {
1434
- items.push(await createImage(image, ctx.options));
1435
- }
1436
- return items;
1437
- }
1438
- function CreateImageUrlListForm(props) {
1439
- const onSubmit = (e) => {
1440
- e.preventDefault();
1441
- const data = new FormData(e.target);
1442
- const formData = Object.fromEntries(data.entries());
1443
- if (formData.urls) {
1444
- props.runCreate({ images: formData.urls.split("\n").map((url) => ({ url })) });
1445
- }
1446
- };
1447
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_components11.Form.Form, { onSubmit, children: [
1448
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_components11.Form.InputContainer, { className: "mb-4", children: [
1449
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components11.Form.Label, { children: "Enter a list of URLs (one per line)" }),
1450
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components11.Form.TextArea, { name: "urls", rows: "10" })
1451
- ] }),
1452
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components11.ActionButton, { primary: true, large: true, type: "submit", children: "Create" })
1453
- ] }) });
1454
- }
1455
-
1456
- // src/Annotation/ImageUrlListAnnotation/create-image-url-list-annotation.tsx
1457
- var import_creator_api9 = require("@manifest-editor/creator-api");
1458
- async function createImageUrlListAnnotation(payload, ctx) {
1459
- const items = [];
1460
- const createAnnotation = (0, import_creator_api9.creatorHelper)(ctx, "AnnotationPage", "items", "@manifest-editor/image-url-annotation");
1461
- for (const image of payload.images) {
1462
- items.push(await createAnnotation(image, ctx.options));
1463
- }
1464
- return items;
1465
- }
1466
-
1467
- // src/Annotation/ImageUrlListAnnotation/index.tsx
1468
- var import_jsx_runtime17 = require("react/jsx-runtime");
1469
- var imageUrlListAnnotation = (0, import_creator_api10.defineCreator)({
1470
- id: "@manifest-editor/image-url-list-annotation",
1471
- create: createImageUrlListAnnotation,
1472
- label: "List of Images",
1473
- dependencies: ["@manifest-editor/image-url-annotation"],
1474
- summary: "List of Images from URLs",
1475
- tags: ["image"],
1476
- icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_components12.ImageListIcon, {}),
1477
- render(ctx) {
1478
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CreateImageUrlListForm, { ...ctx });
1479
- },
1480
- resourceType: "Annotation",
1481
- resourceFields: ["id", "type", "motivation", "body", "target"],
1482
- additionalTypes: ["Canvas"],
1483
- supports: {
1484
- parentTypes: ["AnnotationPage", "Manifest"],
1485
- parentFields: ["items"]
1486
- },
1487
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1488
- staticFields: {
1489
- type: "Annotation"
1490
- }
1491
- });
1492
-
1493
- // src/Annotation/NoBodyAnnotation/index.tsx
1494
- var import_components13 = require("@manifest-editor/components");
1495
- var import_creator_api11 = require("@manifest-editor/creator-api");
1496
- var import_jsx_runtime18 = require("react/jsx-runtime");
1497
- var noBodyAnnotation = (0, import_creator_api11.defineCreator)({
1498
- id: "@manifest-editor/no-body-annotation",
1499
- create: createNoBodyAnnotation,
1500
- label: "Annotation without body",
1501
- summary: "Add an annotation that only has motivation and target",
1502
- icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components13.EmptyCanvasIcon, {}),
1503
- resourceType: "Annotation",
1504
- resourceFields: ["id", "type", "motivation", "target"],
1505
- supports: {
1506
- initialData: true,
1507
- parentTypes: ["AnnotationPage"],
1508
- parentFields: ["items"],
1509
- disallowPainting: true
1510
- },
1511
- sideEffects: [],
1512
- staticFields: {
1513
- type: "Annotation"
1514
- }
1515
- });
1516
- function createNoBodyAnnotation(data, ctx) {
1517
- return ctx.embed({
1518
- id: ctx.generateId("annotation"),
1519
- type: "Annotation",
1520
- label: data?.label,
1521
- motivation: data.motivation || ctx.options.initialData?.motivation || "highlighting",
1522
- target: ctx.getTarget()
1523
- });
1524
- }
1525
-
1526
- // src/Annotation/VideoAnnotation/index.tsx
1527
- var import_components15 = require("@manifest-editor/components");
1528
- var import_creator_api12 = require("@manifest-editor/creator-api");
1529
-
1530
- // src/Annotation/VideoAnnotation/create-video-annotation.tsx
1531
- var import_helpers3 = require("@iiif/helpers");
1532
- var import_components14 = require("@manifest-editor/components");
1533
- var import_editors7 = require("@manifest-editor/editors");
1534
-
1535
- // ../ui/ui/VideoPlayer/VideoPlayer.tsx
1536
- var import_react_iiif_vault4 = require("react-iiif-vault");
1537
- var import_jsx_runtime19 = require("react/jsx-runtime");
1538
- function VideoPlayer({
1539
- media,
1540
- onError,
1541
- duration,
1542
- onDuration,
1543
- onDimensions
1544
- }) {
1545
- const [{ element, currentTime, progress }, state, actions] = (0, import_react_iiif_vault4.useSimpleMediaPlayer)({ duration });
1546
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1547
- import_react_iiif_vault4.MediaPlayerProvider,
1548
- {
1549
- element,
1550
- state,
1551
- actions,
1552
- currentTime,
1553
- progress,
1554
- children: [
1555
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1556
- "div",
1557
- {
1558
- style: {
1559
- maxHeight: 400,
1560
- aspectRatio: `${media.width}/${media.height}`,
1561
- position: "relative"
1562
- },
1563
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_iiif_vault4.CanvasPanel.VideoHTML, { element, media, playPause: actions.playPause })
1564
- }
1565
- ),
1566
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MediaControls, { onError, onDuration, onDimensions })
1567
- ]
1568
- }
1569
- );
1570
- }
1571
-
1572
- // src/Annotation/VideoAnnotation/create-video-annotation.tsx
1573
- var import_react6 = require("react");
1574
- var import_jsx_runtime20 = require("react/jsx-runtime");
1575
- async function createVideoAnnotation(data, ctx) {
1576
- const annotation = {
1577
- id: ctx.generateId("annotation"),
1578
- type: "Annotation"
1579
- };
1580
- const targetType = ctx.options.targetType;
1581
- const body = ctx.embed({
1582
- id: data.url,
1583
- type: "Video",
1584
- format: "video/mp4",
1585
- width: data.width,
1586
- height: data.height,
1587
- duration: data.duration || 0
1588
- });
1589
- if (targetType === "Annotation") {
1590
- return ctx.embed({
1591
- ...annotation,
1592
- label: (0, import_helpers3.getValue)(data.label) && data.label,
1593
- motivation: data.motivation || ctx.options.initialData?.motivation || "painting",
1594
- body,
1595
- target: ctx.getTarget()
1596
- });
1597
- }
1598
- if (targetType === "Canvas") {
1599
- const canvasId = ctx.generateId("canvas");
1600
- const pageId = ctx.generateId("annotation-page", {
1601
- id: canvasId,
1602
- type: "Canvas"
1603
- });
1604
- const annotationResource = ctx.embed({
1605
- ...annotation,
1606
- motivation: "painting",
1607
- body,
1608
- target: {
1609
- type: "SpecificResource",
1610
- source: { id: canvasId, type: "Canvas" }
1611
- }
1612
- });
1613
- const page = ctx.embed({
1614
- id: pageId,
1615
- type: "AnnotationPage",
1616
- items: [annotationResource]
1617
- });
1618
- return ctx.embed({
1619
- id: canvasId,
1620
- type: "Canvas",
1621
- label: data.label || { en: ["Untitled HTML canvas"] },
1622
- duration: data.duration || 0,
1623
- width: data.width,
1624
- height: data.height,
1625
- items: [page]
1626
- });
1627
- }
1628
- }
1629
- function CreateVideoAnnotationForm(props) {
1630
- const [url, setUrl] = (0, import_react6.useState)("");
1631
- const [duration, setDuration] = (0, import_react6.useState)(0);
1632
- const [width, setWidth] = (0, import_react6.useState)(0);
1633
- const [height, setHeight] = (0, import_react6.useState)(0);
1634
- const [error, setError] = (0, import_react6.useState)("");
1635
- const [label, setLabel] = (0, import_react6.useState)({ en: [""] });
1636
- const onSubmit = () => {
1637
- props.runCreate({
1638
- url,
1639
- duration,
1640
- label,
1641
- width,
1642
- height
1643
- });
1644
- };
1645
- (0, import_react6.useEffect)(() => {
1646
- setError("");
1647
- setDuration(0);
1648
- if (url) {
1649
- const labelFromUrl = url.split("/").pop()?.split(".").shift();
1650
- setLabel({ en: [labelFromUrl || ""] });
1651
- }
1652
- }, [url]);
1653
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(PaddedSidebarContainer, { children: [
1654
- error ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components14.ErrorMessage, { children: error }) : null,
1655
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_editors7.InputContainer, { $wide: true, children: [
1656
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_editors7.InputLabel, { htmlFor: "video-url", children: "URL" }),
1657
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_editors7.Input, { type: "text", id: "video-url", value: url, onChange: (e) => setUrl(e.target.value) })
1658
- ] }),
1659
- url && !error ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1660
- import_editors7.LanguageFieldEditor,
1661
- {
1662
- containerId: "label",
1663
- focusId: "label_",
1664
- label: "Label",
1665
- fields: label,
1666
- onSave: (e) => setLabel(e.toInternationalString())
1667
- },
1668
- `${url}__${duration}`
1669
- ) }) : null,
1670
- url && !error ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-4 bg-black", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1671
- VideoPlayer,
1672
- {
1673
- duration,
1674
- onDuration: (d) => setDuration(d),
1675
- onError: (err) => setError(err),
1676
- media: {
1677
- url,
1678
- duration,
1679
- height,
1680
- width,
1681
- type: "Video"
1682
- },
1683
- onDimensions: (w, h) => {
1684
- setWidth(w || 0);
1685
- setHeight(h || 0);
1686
- }
1687
- }
1688
- ) }) : null,
1689
- !error && (duration || width || height) ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_editors7.InputContainer, { $wide: true, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1690
- import_editors7.DimensionsTriplet,
1691
- {
1692
- widthId: "width",
1693
- width: width || 0,
1694
- changeWidth: (v) => setWidth(v),
1695
- heightId: "height",
1696
- height: height || 0,
1697
- changeHeight: (v) => setHeight(v),
1698
- durationId: "duration",
1699
- duration: duration || 0,
1700
- changeDuration: (v) => setDuration(v)
1701
- }
1702
- ) }) : null,
1703
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components14.ActionButton, { primary: true, large: true, type: "button", onPress: onSubmit, isDisabled: !url || !!error, children: "Add video" })
1704
- ] });
1705
- }
1706
-
1707
- // src/Annotation/VideoAnnotation/index.tsx
1708
- var import_jsx_runtime21 = require("react/jsx-runtime");
1709
- var videoAnnotation = (0, import_creator_api12.defineCreator)({
1710
- id: "@manifest-editor/video-annotation",
1711
- create: createVideoAnnotation,
1712
- label: "Video",
1713
- summary: "Video annotation",
1714
- icon: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components15.VideoIcon, {}),
1715
- render(ctx) {
1716
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CreateVideoAnnotationForm, { ...ctx });
1717
- },
1718
- resourceType: "Annotation",
1719
- resourceFields: ["id", "type", "motivation", "body", "target"],
1720
- additionalTypes: ["Canvas"],
1721
- supports: {
1722
- initialData: true,
1723
- parentTypes: ["AnnotationPage", "Manifest"],
1724
- parentFields: ["items"]
1725
- },
1726
- staticFields: {
1727
- type: "Annotation"
1728
- }
1729
- });
1730
-
1731
- // src/AnnotationPage/EmptyAnnotationPage/index.tsx
1732
- var import_creator_api13 = require("@manifest-editor/creator-api");
1733
-
1734
- // ../ui/icons/ThumbnailStripIcon.tsx
1735
- var import_jsx_runtime22 = require("react/jsx-runtime");
1736
- var ThumbnailStripIcon = () => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
1737
- "svg",
1738
- {
1739
- xmlns: "http://www.w3.org/2000/svg",
1740
- height: "24px",
1741
- viewBox: "0 0 24 24",
1742
- width: "24px",
1743
- fill: "#000000",
1744
- transform: "scale(-1, 1)",
1745
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("g", { children: [
1746
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { fill: "none", height: "24", width: "24" }),
1747
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M16,20H2V4h14V20z M18,8h4V4h-4V8z M18,20h4v-4h-4V20z M18,14h4v-4h-4V14z" })
1748
- ] })
1749
- }
1750
- );
1751
-
1752
- // src/AnnotationPage/EmptyAnnotationPage/index.tsx
1753
- var import_jsx_runtime23 = require("react/jsx-runtime");
1754
- var emptyAnnotationPage = (0, import_creator_api13.defineCreator)({
1755
- id: "@manifest-editor/empty-annotation-page",
1756
- create: (data, ctx) => {
1757
- return ctx.embed({
1758
- id: ctx.generateId("annotations"),
1759
- label: data.label,
1760
- type: "AnnotationPage",
1761
- items: []
1762
- });
1763
- },
1764
- label: "Empty annotation page",
1765
- summary: "AnnotationPage with nothing",
1766
- icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ThumbnailStripIcon, {}),
1767
- resourceType: "AnnotationPage",
1768
- resourceFields: ["id", "type", "items"],
1769
- supports: {
1770
- parentTypes: ["Manifest", "Canvas", "Range"],
1771
- parentFieldMap: {
1772
- Manifest: ["annotations"],
1773
- Canvas: ["items", "annotations"],
1774
- Range: ["annotations"]
1775
- }
1776
- }
1777
- });
1778
-
1779
- // src/Canvas/EmptyCanvas/index.tsx
1780
- var import_components16 = require("@manifest-editor/components");
1781
- var import_creator_api14 = require("@manifest-editor/creator-api");
1782
- var import_jsx_runtime24 = require("react/jsx-runtime");
1783
- var emptyCanvas = (0, import_creator_api14.defineCreator)({
1784
- id: "@manifest-editor/empty-canvas",
1785
- create: (data, ctx) => {
1786
- const canvasId = ctx.generateId("canvas");
1787
- const page = ctx.embed({
1788
- id: ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" }),
1789
- type: "AnnotationPage",
1790
- items: []
1791
- });
1792
- return {
1793
- id: canvasId,
1794
- type: "Canvas",
1795
- label: data.label || { en: [""] },
1796
- height: data.height || 1e3,
1797
- width: data.width || 1e3,
1798
- items: [page]
1799
- };
1800
- },
1801
- label: "Empty canvas",
1802
- summary: "No content",
1803
- icon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components16.EmptyCanvasIcon, {}),
1804
- resourceType: "Canvas",
1805
- resourceFields: ["id", "type", "label", "height", "width", "items"],
1806
- supports: {
1807
- parentTypes: ["Manifest"],
1808
- parentFields: ["items"]
1809
- }
1810
- });
1811
-
1812
- // src/Canvas/InternalCanvas/index.tsx
1813
- var import_creator_api15 = require("@manifest-editor/creator-api");
1814
- var import_iiif_browser = require("@manifest-editor/iiif-browser");
1815
- var import_react_iiif_vault5 = require("react-iiif-vault");
1816
-
1817
- // ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
1818
- var isProduction = false;
1819
- var prefix = "Invariant failed";
1820
- function invariant(condition, message) {
1821
- if (condition) {
1822
- return;
1823
- }
1824
- if (isProduction) {
1825
- throw new Error(prefix);
1826
- }
1827
- var provided = typeof message === "function" ? message() : message;
1828
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
1829
- throw new Error(value);
1830
- }
1831
-
1832
- // src/Canvas/InternalCanvas/index.tsx
1833
- var import_jsx_runtime25 = require("react/jsx-runtime");
1834
- var internalCanvas = (0, import_creator_api15.defineCreator)({
1835
- id: "@manifest-editor/internal-canvas",
1836
- create: createInternalCanvas,
1837
- label: "Internal canvas link",
1838
- summary: "Canvas from the same manifest",
1839
- icon: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ThumbnailStripIcon, {}),
1840
- resourceType: "Canvas",
1841
- resourceFields: ["id", "type", "label"],
1842
- supports: {
1843
- parentTypes: ["Manifest"],
1844
- parentFields: ["start"]
1845
- },
1846
- render: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(InternalCanvas, { ...ctx })
1847
- });
1848
- function InternalCanvas(props) {
1849
- const manifest = (0, import_react_iiif_vault5.useManifest)();
1850
- const vault = (0, import_react_iiif_vault5.useVault)();
1851
- invariant(manifest, "Manifest is not loaded");
1852
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1853
- import_iiif_browser.IIIFExplorer,
1854
- {
1855
- vault,
1856
- entry: manifest,
1857
- window: false,
1858
- hideHeader: true,
1859
- hideBack: true,
1860
- output: { type: "url" },
1861
- outputTargets: [
1862
- {
1863
- type: "callback",
1864
- label: "Select canvas",
1865
- cb: (url) => {
1866
- props.runCreate({ id: url });
1867
- }
1868
- }
1869
- ],
1870
- outputTypes: ["Canvas"]
1871
- }
1872
- );
1873
- }
1874
- async function createInternalCanvas(data, ctx) {
1875
- return ctx.embed({ id: data.id, type: "Canvas" });
1876
- }
1877
-
1878
- // src/ContentResource/HTMLBodyCreator/index.tsx
1879
- var import_creator_api16 = require("@manifest-editor/creator-api");
1880
-
1881
- // ../ui/icons/TextFormatIcon.tsx
1882
- var import_jsx_runtime26 = require("react/jsx-runtime");
1883
- var TextFormatIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", height: "1em", width: "1em", ...props, children: [
1884
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
1885
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98 13.87 11h-3.74L12 5.98z" })
1886
- ] });
1887
-
1888
- // src/ContentResource/HTMLBodyCreator/create-html-body.tsx
1889
- var import_components17 = require("@manifest-editor/components");
1890
- var import_editors8 = require("@manifest-editor/editors");
1891
- var import_shell2 = require("@manifest-editor/shell");
1892
- var import_react7 = require("react");
1893
- var import_jsx_runtime27 = require("react/jsx-runtime");
1894
- async function createHtmlBody(data, ctx) {
1895
- return ctx.embed({
1896
- id: ctx.generateId(`html/${data.language}`),
1897
- language: data.language,
1898
- type: "TextualBody",
1899
- format: "text/html",
1900
- value: data.body || ""
1901
- });
1902
- }
1903
- function CreateHTMLBodyForm(props) {
1904
- const { i18n } = (0, import_shell2.useConfig)();
1905
- const [body, setBodyValue] = (0, import_react7.useState)("<p></p>");
1906
- const [language, setLang] = (0, import_react7.useState)(i18n.defaultLanguage);
1907
- const onSubmit = () => {
1908
- props.runCreate({
1909
- language,
1910
- body
1911
- });
1912
- };
1913
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(PaddedSidebarContainer, { children: [
1914
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_editors8.InputContainer, { children: [
1915
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_editors8.InputLabel, { children: "HTML Body" }),
1916
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1917
- import_editors8.RichTextLanguageField,
1918
- {
1919
- value: body,
1920
- language,
1921
- onUpdateLanguage: (lng) => setLang(lng),
1922
- languages: i18n.availableLanguages,
1923
- onUpdate: (e) => setBodyValue(e)
1924
- }
1925
- )
1926
- ] }),
1927
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components17.ActionButton, { primary: true, large: true, type: "button", onPress: onSubmit, children: "Create" })
1928
- ] });
1929
- }
1930
-
1931
- // src/ContentResource/HTMLBodyCreator/index.tsx
1932
- var import_jsx_runtime28 = require("react/jsx-runtime");
1933
- var htmlBodyCreator = (0, import_creator_api16.defineCreator)({
1934
- id: "@manifest-editor/html-body-creator",
1935
- create: createHtmlBody,
1936
- label: "HTML Body",
1937
- summary: "Add HTML annotation body",
1938
- icon: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TextFormatIcon, {}),
1939
- render(ctx) {
1940
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CreateHTMLBodyForm, { ...ctx });
1941
- },
1942
- resourceType: "ContentResource",
1943
- resourceFields: ["id", "language", "type", "format", "value"],
1944
- supports: {
1945
- parentTypes: ["Annotation"],
1946
- parentFields: ["body"]
1947
- },
1948
- staticFields: {
1949
- type: "TextualBody",
1950
- format: "text/html"
1951
- }
1952
- });
1953
-
1954
- // src/ContentResource/IIIFBrowserCreator/index.tsx
1955
- var import_components18 = require("@manifest-editor/components");
1956
- var import_creator_api17 = require("@manifest-editor/creator-api");
1957
-
1958
- // src/ContentResource/IIIFBrowserCreator/iiif-browser-creator.tsx
1959
- var import_helpers5 = require("@iiif/helpers");
1960
- var import_image_33 = require("@iiif/parser/image-3");
1961
- var import_react9 = require("react");
1962
- function croppedRegion(imageServiceId, region, size) {
1963
- return `${imageServiceId}/${Math.floor(region.x)},${Math.floor(region.y)},${Math.floor(region.width)},${Math.floor(
1964
- region.height
1965
- )}/${size}/0/default.jpg`;
1966
- }
1967
- async function createFromIIIFBrowserOutput(data, ctx) {
1968
- const targetType = ctx.options.targetType;
1969
- const resources = data.output;
1970
- const returnResources = [];
1971
- for (const { resource, selector, parent } of resources) {
1972
- const type = resource.type;
1973
- const previewVault = new import_helpers5.Vault();
1974
- if (targetType === "Canvas" || targetType === "Annotation" || targetType === "ContentResource") {
1975
- if (type === "Canvas") {
1976
- const canvasId = resource.id;
1977
- const manifestId = parent?.type === "Manifest" ? parent.id : void 0;
1978
- invariant(manifestId, "Could not find Manifest");
1979
- const manifest = await previewVault.loadManifest(manifestId);
1980
- invariant(manifest, "Manifest not found");
1981
- const canvasRef = manifest.items.find((item) => item.id === canvasId);
1982
- invariant(canvasRef, "Canvas not found");
1983
- const canvas = previewVault.get(canvasRef);
1984
- if (targetType === "Canvas" && selector?.type !== "BoxSelector") {
1985
- const fullCanvas = previewVault.toPresentation3(canvas);
1986
- if (!fullCanvas.label) {
1987
- fullCanvas.label = { en: ["Untitled canvas"] };
1988
- }
1989
- ctx.vault.loadSync(fullCanvas.id, fullCanvas);
1990
- returnResources.push(ctx.embed(fullCanvas));
1991
- continue;
1992
- }
1993
- const annotationPage = previewVault.get(canvas.items[0]);
1994
- const annotation = previewVault.get(annotationPage.items[0]);
1995
- if (targetType === "Annotation" || targetType === "Canvas" || targetType === "ContentResource") {
1996
- const fullAnnotation = previewVault.toPresentation3(annotation);
1997
- fullAnnotation.id = ctx.generateId("Annotation");
1998
- let service = null;
1999
- const dimensions = { width: 0, height: 0 };
2000
- if (fullAnnotation?.body?.service) {
2001
- const width = fullAnnotation?.body.width;
2002
- const height = fullAnnotation?.body.height;
2003
- service = (0, import_image_33.getImageServices)(fullAnnotation?.body)[0];
2004
- if (service && (!service.width || !service.height)) {
2005
- service.width = width;
2006
- service.height = height;
2007
- }
2008
- dimensions.width = width;
2009
- dimensions.height = height;
2010
- if (data.trackSize) {
2011
- data.trackSize(dimensions);
2012
- }
2013
- }
2014
- if (selector?.type === "BoxSelector") {
2015
- const imageApiSelector = {
2016
- type: "ImageApiSelector",
2017
- region: [
2018
- ~~selector.spatial.x,
2019
- ~~selector.spatial.y,
2020
- ~~selector.spatial.width,
2021
- ~~selector.spatial.height
2022
- ].join(",")
2023
- };
2024
- const newBody = { ...fullAnnotation.body };
2025
- let thumbnailId = "";
2026
- if (service) {
2027
- const id = service.id || service["@id"] || "";
2028
- if (id) {
2029
- newBody.id = croppedRegion(id, selector.spatial, "max");
2030
- thumbnailId = croppedRegion(id, selector.spatial, "512,");
2031
- }
2032
- }
2033
- fullAnnotation.body = {
2034
- id: ctx.generateId("SpecificResource", annotation),
2035
- type: "SpecificResource",
2036
- source: newBody,
2037
- selector: imageApiSelector
2038
- };
2039
- if (data.trackSize) {
2040
- data.trackSize({
2041
- width: ~~selector.spatial.width,
2042
- height: ~~selector.spatial.height
2043
- });
2044
- }
2045
- if (targetType === "ContentResource") {
2046
- returnResources.push(fullAnnotation.body);
2047
- continue;
2048
- }
2049
- if (targetType === "Canvas") {
2050
- const canvasId2 = ctx.generateId("Canvas", annotation);
2051
- fullAnnotation.target = canvasId2;
2052
- const pageId = ctx.generateId("Page", annotation);
2053
- const annotationPage2 = ctx.embed({
2054
- id: pageId,
2055
- type: "AnnotationPage",
2056
- items: [fullAnnotation]
2057
- });
2058
- returnResources.push(
2059
- ctx.embed({
2060
- id: canvasId2,
2061
- type: "Canvas",
2062
- label: { en: ["Untitled canvas"] },
2063
- width: ~~selector.spatial.width,
2064
- height: ~~selector.spatial.height,
2065
- thumbnail: thumbnailId ? [
2066
- ctx.embed({
2067
- id: thumbnailId,
2068
- type: "Image",
2069
- format: "image/jpeg",
2070
- width: 512,
2071
- height: Math.round(selector.spatial.height / selector.spatial.width * 512)
2072
- })
2073
- ] : void 0,
2074
- items: [annotationPage2]
2075
- })
2076
- );
2077
- continue;
2078
- }
2079
- returnResources.push(
2080
- ctx.embed({
2081
- ...fullAnnotation,
2082
- target: ctx.getTarget()
2083
- })
2084
- );
2085
- continue;
2086
- }
2087
- returnResources.push(
2088
- ctx.embed({
2089
- ...previewVault.toPresentation3(annotation),
2090
- target: ctx.getTarget()
2091
- })
2092
- );
2093
- }
2094
- }
2095
- }
2096
- }
2097
- return returnResources;
2098
- }
2099
- var IIIFBrowserCreatorForm2 = (0, import_react9.lazy)(() => Promise.resolve().then(() => (init_iiif_browser_form_lazy(), iiif_browser_form_lazy_exports)));
2100
-
2101
- // src/ContentResource/IIIFBrowserCreator/index.tsx
2102
- var import_jsx_runtime30 = require("react/jsx-runtime");
2103
- var iiifBrowserCreator = (0, import_creator_api17.defineCreator)({
2104
- id: "@manifest-editor/iiif-browser-creator",
2105
- create: createFromIIIFBrowserOutput,
2106
- label: "IIIF Browser",
2107
- summary: "Browse IIIF Resources",
2108
- icon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components18.IIIFBrowserIcon, {}),
2109
- render(ctx) {
2110
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(IIIFBrowserCreatorForm2, { ...ctx });
2111
- },
2112
- hiddenModal: true,
2113
- tags: ["image", "image-service"],
2114
- resourceType: "ContentResource",
2115
- resourceFields: ["id", "language", "type", "format", "value"],
2116
- additionalTypes: ["Annotation", "Canvas"],
2117
- supports: {
2118
- parentTypes: ["Annotation", "Manifest", "AnnotationPage"],
2119
- parentFields: ["body", "items"],
2120
- parentFieldMap: {
2121
- Annotation: ["body"],
2122
- Manifest: ["items"],
2123
- AnnotationPage: ["items"]
2124
- }
2125
- },
2126
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
2127
- staticFields: {}
2128
- });
2129
-
2130
- // src/ContentResource/ImageServiceCreator/index.tsx
2131
- var import_components19 = require("@manifest-editor/components");
2132
- var import_creator_api18 = require("@manifest-editor/creator-api");
2133
- var import_jsx_runtime31 = require("react/jsx-runtime");
2134
- var imageServiceCreator = (0, import_creator_api18.defineCreator)({
2135
- id: "@manifest-editor/image-service-creator",
2136
- create: createImageServer,
2137
- label: "Image Service",
2138
- summary: "Add an image from Image Service",
2139
- icon: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components19.IIIFLogo, { style: { padding: 10 } }),
2140
- render(ctx) {
2141
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CreateImageServerForm, { ...ctx });
2142
- },
2143
- resourceType: "ContentResource",
2144
- resourceFields: ["id", "type", "height", "width", "format", "service"],
2145
- supports: {
2146
- parentFields: ["logo", "body", "thumbnail"]
2147
- }
2148
- });
2149
-
2150
- // src/ContentResource/ImageUrlCreator/index.tsx
2151
- var import_components20 = require("@manifest-editor/components");
2152
- var import_creator_api19 = require("@manifest-editor/creator-api");
2153
- var import_jsx_runtime32 = require("react/jsx-runtime");
2154
- var imageUrlCreator = (0, import_creator_api19.defineCreator)({
2155
- id: "@manifest-editor/image-url-creator",
2156
- create: createImageUrl,
2157
- label: "Image",
2158
- summary: "Image from a URL",
2159
- icon: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_components20.AddImageIcon, {}),
2160
- render(ctx) {
2161
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CreateImageUrlForm, { ...ctx });
2162
- },
2163
- resourceType: "ContentResource",
2164
- resourceFields: ["format"],
2165
- supports: {
2166
- parentFields: ["logo", "body", "thumbnail"]
2167
- },
2168
- staticFields: {
2169
- type: "Image"
2170
- }
2171
- });
2172
-
2173
- // src/ContentResource/ImageUrlListCreator/index.tsx
2174
- var import_components21 = require("@manifest-editor/components");
2175
- var import_creator_api20 = require("@manifest-editor/creator-api");
2176
- var import_jsx_runtime33 = require("react/jsx-runtime");
2177
- var imageUrlListCreator = (0, import_creator_api20.defineCreator)({
2178
- id: "@manifest-editor/image-url-list",
2179
- label: "Image URL List",
2180
- summary: "Image from a list of URLs",
2181
- create: createImageUrlList,
2182
- icon: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components21.ImageListIcon, {}),
2183
- render(ctx) {
2184
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CreateImageUrlListForm, { ...ctx });
2185
- },
2186
- resourceType: "ContentResource",
2187
- resourceFields: ["format"],
2188
- supports: {
2189
- parentFields: ["logo", "body", "thumbnail"]
2190
- },
2191
- staticFields: {
2192
- type: "Image"
2193
- }
2194
- });
2195
-
2196
- // src/ContentResource/PlaintextCreator/index.tsx
2197
- var import_creator_api21 = require("@manifest-editor/creator-api");
2198
-
2199
- // src/ContentResource/PlaintextCreator/create-plaintext.tsx
2200
- var import_components22 = require("@manifest-editor/components");
2201
- var import_editors9 = require("@manifest-editor/editors");
2202
- var import_react10 = require("react");
2203
- var import_jsx_runtime34 = require("react/jsx-runtime");
2204
- async function createPlaintext(data, ctx) {
2205
- return ctx.embed({
2206
- id: data.url,
2207
- type: "Text",
2208
- label: data.label,
2209
- format: "text/plain"
2210
- });
2211
- }
2212
- function CreatePlaintextForm(props) {
2213
- const [label, setLabel] = (0, import_react10.useState)({
2214
- en: ["View as text"]
2215
- });
2216
- const onSubmit = (e) => {
2217
- e.preventDefault();
2218
- const data = new FormData(e.target);
2219
- const formData = Object.fromEntries(data.entries());
2220
- if (formData.url) {
2221
- props.runCreate({ url: formData.url, label });
2222
- }
2223
- };
2224
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("form", { onSubmit, children: [
2225
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
2226
- import_editors9.LanguageFieldEditor,
2227
- {
2228
- focusId: "label",
2229
- label: "Label",
2230
- fields: label,
2231
- onSave: (e) => setLabel(e.toInternationalString())
2232
- }
2233
- ),
2234
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_editors9.InputContainer, { $wide: true, children: [
2235
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_editors9.InputLabel, { htmlFor: "id", children: "Link to plaintext" }),
2236
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_editors9.Input, { id: "url", name: "url", defaultValue: "" })
2237
- ] }),
2238
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components22.ActionButton, { primary: true, large: true, type: "submit", children: "Create" })
2239
- ] }) });
2240
- }
2241
-
2242
- // src/ContentResource/PlaintextCreator/index.tsx
2243
- var import_jsx_runtime35 = require("react/jsx-runtime");
2244
- var plaintextCreator = (0, import_creator_api21.defineCreator)({
2245
- id: "@manifest-editor/plaintext-creator",
2246
- create: createPlaintext,
2247
- label: "Plaintext",
2248
- summary: "Add link to an plaintext",
2249
- icon: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TextFormatIcon, {}),
2250
- render(ctx) {
2251
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CreatePlaintextForm, { ...ctx });
2252
- },
2253
- resourceType: "ContentResource",
2254
- resourceFields: ["label", "format"],
2255
- supports: {
2256
- parentFields: ["seeAlso", "rendering", "homepage"]
2257
- },
2258
- staticFields: {
2259
- format: "text/plain"
2260
- }
2261
- });
2262
-
2263
- // src/ContentResource/ThumbnailCreator/index.tsx
2264
- var import_components24 = require("@manifest-editor/components");
2265
- var import_creator_api22 = require("@manifest-editor/creator-api");
2266
-
2267
- // src/ContentResource/ThumbnailCreator/create-thumbnail.tsx
2268
- var import_components23 = require("@manifest-editor/components");
2269
- var import_editors10 = require("@manifest-editor/editors");
2270
- var import_react11 = require("react");
2271
-
2272
- // src/ContentResource/ThumbnailCreator/thumbnail-helpers.ts
2273
- var import_image_34 = require("@iiif/parser/image-3");
2274
- function serviceImageAtSize(service, size) {
2275
- if (service["@id"]) {
2276
- service.id = service["@id"];
2277
- }
2278
- if (service["@type"]) {
2279
- service.type = service["@type"];
2280
- }
2281
- const request = (0, import_image_34.createImageServiceRequest)(service);
2282
- return (0, import_image_34.imageServiceRequestToString)({
2283
- identifier: request.identifier,
2284
- server: request.server,
2285
- scheme: request.scheme,
2286
- type: "image",
2287
- size: {
2288
- max: false,
2289
- confined: false,
2290
- upscaled: false,
2291
- width: size.width,
2292
- height: size.height
2293
- },
2294
- format: "jpg",
2295
- // This isn't how it should be modelled, always full,
2296
- // region: data.selector ? data.selector : { full: true },
2297
- region: { full: true },
2298
- rotation: { angle: 0 },
2299
- quality: "default",
2300
- prefix: request.prefix,
2301
- originalPath: request.originalPath
2302
- });
2303
- }
2304
- function getCanonicalUrl2(url) {
2305
- return url.endsWith("default.jpg") ? (0, import_image_34.imageServiceRequestToString)({
2306
- ...(0, import_image_34.parseImageServiceRequest)(url),
2307
- type: "info"
2308
- }) : (0, import_image_34.canonicalServiceUrl)(url);
2309
- }
2310
-
2311
- // src/ContentResource/ThumbnailCreator/create-thumbnail.tsx
2312
- var import_jsx_runtime36 = require("react/jsx-runtime");
2313
- async function createThumbnail(data, ctx) {
2314
- const service = { ...data.service };
2315
- const sizes = service.sizes;
2316
- if (service["@id"]) {
2317
- service.id = service["@id"];
2318
- }
2319
- if (service["@type"]) {
2320
- service.type = service["@type"];
2321
- }
2322
- if (data.thumbnailUrl) {
2323
- return ctx.embed({
2324
- id: data.thumbnailUrl,
2325
- type: "Image",
2326
- format: "image/jpeg",
2327
- width: data.width,
2328
- height: data.height
2329
- });
2330
- }
2331
- if (sizes) {
2332
- const thumbnailSize = data.width || 400;
2333
- let bestMatch = null;
2334
- for (const size of sizes) {
2335
- if (!bestMatch || Math.abs(size.width - thumbnailSize) < Math.abs(bestMatch.width - thumbnailSize)) {
2336
- bestMatch = { width: size.width, height: size.height };
2337
- }
2338
- }
2339
- if (bestMatch) {
2340
- const imageId = serviceImageAtSize(service, bestMatch);
2341
- return ctx.embed({
2342
- id: imageId,
2343
- type: "Image",
2344
- format: "image/jpeg",
2345
- width: bestMatch.width,
2346
- height: bestMatch.height
2347
- });
2348
- }
2349
- }
2350
- return null;
2351
- }
2352
- function CreateThumbnailForm(props) {
2353
- const [url, setUrl] = (0, import_react11.useState)("");
2354
- const [service, setService] = (0, import_react11.useState)(null);
2355
- const [selectedSize, setSelectedSize] = (0, import_react11.useState)({ width: 0, height: 0 });
2356
- const previewUrl = (0, import_react11.useMemo)(() => {
2357
- if (!service)
2358
- return null;
2359
- if (!selectedSize.width || !selectedSize.height)
2360
- return null;
2361
- return serviceImageAtSize(service, selectedSize);
2362
- }, [selectedSize, service]);
2363
- const onSubmit = (e) => {
2364
- e.preventDefault();
2365
- const data = new FormData(e.target);
2366
- const formData = Object.fromEntries(data.entries());
2367
- const url2 = formData.url;
2368
- if (url2) {
2369
- const info = getCanonicalUrl2(url2);
2370
- if (!info) {
2371
- throw new Error("Invalid image service request");
2372
- }
2373
- fetch(info).then((r) => r.json()).then((service2) => {
2374
- setService(service2);
2375
- const size0 = service2.sizes?.[0];
2376
- if (size0) {
2377
- setSelectedSize(size0);
2378
- }
2379
- });
2380
- }
2381
- };
2382
- if (service) {
2383
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(PaddedSidebarContainer, { children: [
2384
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "mb-4", children: [
2385
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "mb-2", children: service["@id"] || service.id }),
2386
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex gap-2 mb-4", children: service.sizes?.map((size) => {
2387
- const isSelected = size.width === selectedSize.width;
2388
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
2389
- import_components23.ActionButton,
2390
- {
2391
- primary: isSelected,
2392
- isDisabled: isSelected,
2393
- large: true,
2394
- onPress: () => setSelectedSize(size),
2395
- children: [
2396
- size.width,
2397
- "x",
2398
- size.height
2399
- ]
2400
- },
2401
- size.width
2402
- );
2403
- }) }),
2404
- previewUrl ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("img", { src: previewUrl, alt: "preview of selected resource" }) : null
2405
- ] }),
2406
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2407
- import_components23.ActionButton,
2408
- {
2409
- primary: true,
2410
- large: true,
2411
- isDisabled: !previewUrl,
2412
- onPress: () => {
2413
- if (!service)
2414
- return;
2415
- props.runCreate({ service, width: selectedSize.width, height: selectedSize.height });
2416
- },
2417
- children: "Add thumbnail"
2418
- }
2419
- )
2420
- ] });
2421
- }
2422
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("form", { onSubmit, children: [
2423
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex gap-2 items-center", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_editors10.InputContainer, { $wide: true, children: [
2424
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_editors10.InputLabel, { htmlFor: "id", children: "Link to image service" }),
2425
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2426
- import_editors10.Input,
2427
- {
2428
- id: "url",
2429
- name: "url",
2430
- defaultValue: "",
2431
- onPaste: (e) => {
2432
- const text = e.clipboardData.getData("text/plain");
2433
- setUrl(text ? getCanonicalUrl2(text) : "");
2434
- },
2435
- onBlur: (e) => setUrl(e.currentTarget.value ? getCanonicalUrl2(e.currentTarget.value) : "")
2436
- }
2437
- )
2438
- ] }) }),
2439
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components23.ActionButton, { primary: true, large: true, type: "submit", isDisabled: !url, children: "Select size" }) })
2440
- ] }) });
2441
- }
2442
-
2443
- // src/ContentResource/ThumbnailCreator/index.tsx
2444
- var import_jsx_runtime37 = require("react/jsx-runtime");
2445
- var thumbnailCreator = (0, import_creator_api22.defineCreator)({
2446
- id: "@manifest-editor/thumbnail-image",
2447
- create: createThumbnail,
2448
- label: "Thumbnail from service",
2449
- summary: "Add thumbnail from an image service",
2450
- icon: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components24.ScaledImageIcon, {}),
2451
- render(ctx) {
2452
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CreateThumbnailForm, { ...ctx });
2453
- },
2454
- resourceType: "ContentResource",
2455
- resourceFields: ["id", "type", "format"],
2456
- supports: {
2457
- parentFields: ["thumbnail"]
2458
- }
2459
- });
2460
-
2461
- // src/ContentResource/WebPageCreator/index.tsx
2462
- var import_creator_api23 = require("@manifest-editor/creator-api");
2463
-
2464
- // ../ui/icons/LinkIcon.tsx
2465
- var import_jsx_runtime38 = require("react/jsx-runtime");
2466
- function LinkIcon() {
2467
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000", children: [
2468
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
2469
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { d: "M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z" })
2470
- ] });
2471
- }
2472
-
2473
- // src/ContentResource/WebPageCreator/create-web-page.tsx
2474
- var import_components25 = require("@manifest-editor/components");
2475
- var import_editors11 = require("@manifest-editor/editors");
2476
- var import_react12 = require("react");
2477
- var import_jsx_runtime39 = require("react/jsx-runtime");
2478
- async function createWebPage(data, ctx) {
2479
- return ctx.embed({
2480
- id: data.url,
2481
- type: "Text",
2482
- label: data.label,
2483
- format: "text/html"
2484
- });
2485
- }
2486
- function CreateWebPageForm(props) {
2487
- const [label, setLabel] = (0, import_react12.useState)({ en: [""] });
2488
- const onSubmit = (e) => {
2489
- e.preventDefault();
2490
- const data = new FormData(e.target);
2491
- const formData = Object.fromEntries(data.entries());
2492
- if (formData.url) {
2493
- props.runCreate({ url: formData.url, label });
2494
- }
2495
- };
2496
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("form", { onSubmit, children: [
2497
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
2498
- import_editors11.LanguageFieldEditor,
2499
- {
2500
- focusId: "label",
2501
- label: "Label",
2502
- fields: label,
2503
- onSave: (e) => setLabel(e.toInternationalString())
2504
- }
2505
- ),
2506
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_editors11.InputContainer, { $wide: true, children: [
2507
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_editors11.InputLabel, { htmlFor: "id", children: "Link" }),
2508
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_editors11.Input, { id: "url", name: "url", defaultValue: "" })
2509
- ] }),
2510
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components25.ActionButton, { primary: true, large: true, type: "submit", children: "Create link" })
2511
- ] }) });
2512
- }
2513
-
2514
- // src/ContentResource/WebPageCreator/index.tsx
2515
- var import_jsx_runtime40 = require("react/jsx-runtime");
2516
- var webPageCreator = (0, import_creator_api23.defineCreator)({
2517
- id: "@manifest-editor/web-page-creator",
2518
- create: createWebPage,
2519
- label: "Web page",
2520
- summary: "Add link to an external web page",
2521
- icon: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LinkIcon, {}),
2522
- render(ctx) {
2523
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CreateWebPageForm, { ...ctx });
2524
- },
2525
- resourceType: "ContentResource",
2526
- resourceFields: ["label", "format"],
2527
- supports: {
2528
- parentFields: ["seeAlso", "rendering", "homepage"]
2529
- }
2530
- });
2531
-
2532
- // src/ContentResource/YouTubeCreator/index.tsx
2533
- var import_components27 = require("@manifest-editor/components");
2534
- var import_creator_api24 = require("@manifest-editor/creator-api");
2535
-
2536
- // src/ContentResource/YouTubeCreator/create-youtube-body.tsx
2537
- var import_components26 = require("@manifest-editor/components");
2538
- var import_editors12 = require("@manifest-editor/editors");
2539
- var import_jsx_runtime41 = require("react/jsx-runtime");
2540
- var ytRegex = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;
2541
- function getYouTubeId(url) {
2542
- const id = (url || "").match(ytRegex);
2543
- return id ? id[1] : null;
2544
- }
2545
- function validateYouTube(data) {
2546
- return !!getYouTubeId(data.youtubeUrl);
2547
- }
2548
- async function createYoutubeBody(data, ctx) {
2549
- const id = getYouTubeId(data.youtubeUrl);
2550
- const body = ctx.embed({
2551
- id: `https://www.youtube.com/watch?v=${id}`,
2552
- type: "Video",
2553
- service: [
2554
- {
2555
- profile: "http://digirati.com/objectifier",
2556
- params: {
2557
- data: `https://www.youtube.com/embed/${id}`
2558
- }
2559
- },
2560
- {
2561
- id: `https://www.youtube.com/watch?v=${id}`,
2562
- profile: "https://www.youtube.com"
2563
- }
2564
- ]
2565
- });
2566
- if (ctx.options.targetType === "Canvas") {
2567
- const canvasId = ctx.generateId("canvas");
2568
- const pageId = ctx.generateId("annotation-page", {
2569
- id: canvasId,
2570
- type: "Canvas"
2571
- });
2572
- const annotation = ctx.embed({
2573
- id: ctx.generateId("annotation", { id: pageId, type: "AnnotationPage" }),
2574
- type: "Annotation",
2575
- motivation: "painting",
2576
- body: [body],
2577
- target: {
2578
- type: "SpecificResource",
2579
- source: { id: canvasId, type: "Canvas" }
2580
- }
2581
- });
2582
- const page = ctx.embed({
2583
- id: pageId,
2584
- type: "AnnotationPage",
2585
- items: [annotation]
2586
- });
2587
- return ctx.embed({
2588
- id: canvasId,
2589
- type: "Canvas",
2590
- label: data.label || { en: ["Untitled YouTube canvas"] },
2591
- height: data.height || 1e3,
2592
- width: data.width || 1e3,
2593
- duration: data.duration || 1,
2594
- items: [page]
2595
- });
2596
- }
2597
- if (ctx.options.targetType === "Annotation") {
2598
- return ctx.embed({
2599
- id: ctx.generateId("annotation"),
2600
- type: "Annotation",
2601
- motivation: "painting",
2602
- body: [body],
2603
- target: ctx.getTarget()
2604
- });
2605
- }
2606
- return body;
2607
- }
2608
- function YouTubeForm(props) {
2609
- const onSubmit = (e) => {
2610
- e.preventDefault();
2611
- const data = new FormData(e.target);
2612
- const formData = Object.fromEntries(data.entries());
2613
- if (formData.youtubeUrl) {
2614
- props.runCreate({ youtubeUrl: formData.youtubeUrl });
2615
- }
2616
- };
2617
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("form", { onSubmit, children: [
2618
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_editors12.InputContainer, { $wide: true, children: [
2619
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_editors12.InputLabel, { htmlFor: "id", children: "Link to YouTube" }),
2620
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_editors12.Input, { id: "youtubeUrl", name: "youtubeUrl", defaultValue: "" })
2621
- ] }),
2622
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_components26.ActionButton, { primary: true, large: true, type: "submit", children: "Create" })
2623
- ] }) });
2624
- }
2625
-
2626
- // src/ContentResource/YouTubeCreator/index.tsx
2627
- var import_jsx_runtime42 = require("react/jsx-runtime");
2628
- var youTubeBodyCreator = (0, import_creator_api24.defineCreator)({
2629
- id: "@manifest-editor/youtube",
2630
- create: createYoutubeBody,
2631
- label: "YouTube",
2632
- summary: "Embed YouTube",
2633
- icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components27.YouTubeIcon, {}),
2634
- resourceType: "ContentResource",
2635
- additionalTypes: ["Canvas", "Annotation"],
2636
- resourceFields: ["id", "type", "service"],
2637
- render: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(YouTubeForm, { ...ctx }),
2638
- supports: {
2639
- parentTypes: ["Annotation", "Manifest", "AnnotationPage"],
2640
- parentFieldMap: {
2641
- Annotation: ["body"],
2642
- Manifest: ["items"],
2643
- AnnotationPage: ["items"]
2644
- }
2645
- },
2646
- staticFields: {
2647
- type: "Video"
2648
- }
2649
- });
2650
-
2651
- // src/Manifest/ManifestBrowserCreator/index.tsx
2652
- var import_components28 = require("@manifest-editor/components");
2653
- var import_creator_api25 = require("@manifest-editor/creator-api");
2654
-
2655
- // src/Manifest/ManifestBrowserCreator/manifest-browser-creator.tsx
2656
- var import_helpers7 = require("@iiif/helpers");
2657
- var import_react14 = require("react");
2658
- async function createFromManifestBrowserOutput(data, ctx) {
2659
- const inputItems = data.output || [];
2660
- const itemsToAdd = [];
2661
- for (const item of inputItems) {
2662
- const { resource, parent, selector } = item;
2663
- const previewVault = ctx.getPreviewVault();
2664
- const thumbnails = (0, import_helpers7.createThumbnailHelper)(previewVault);
2665
- if (resource.type === "Manifest") {
2666
- const manifestId = resource.id;
2667
- invariant(manifestId, "Could not find Manifest ID");
2668
- const manifest = await previewVault.loadManifest(manifestId);
2669
- const thumbnail = await thumbnails.getBestThumbnailAtSize(manifest, { width: 256, height: 256 }, false);
2670
- invariant(manifest, "Manifest not found");
2671
- itemsToAdd.push(
2672
- ctx.embed({
2673
- id: resource.id,
2674
- type: "Manifest",
2675
- label: manifest.label,
2676
- summary: manifest.summary,
2677
- thumbnail: thumbnail?.best ? [
2678
- {
2679
- id: thumbnail.best.id,
2680
- type: "Image"
2681
- }
2682
- ] : void 0
2683
- })
2684
- );
2685
- continue;
2686
- }
2687
- if (resource.type === "Collection") {
2688
- const collectionId = resource.id;
2689
- invariant(collectionId, "Could not find Manifest ID");
2690
- const collection = await previewVault.loadManifest(collectionId);
2691
- invariant(collection, "Collection not found");
2692
- itemsToAdd.push(
2693
- ctx.embed({
2694
- id: resource.id,
2695
- type: "Collection",
2696
- label: collection.label
2697
- })
2698
- );
2699
- }
2700
- }
2701
- return itemsToAdd;
2702
- }
2703
- var ManifestBrowserCreatorForm2 = (0, import_react14.lazy)(() => Promise.resolve().then(() => (init_manifest_browser_form_lazy(), manifest_browser_form_lazy_exports)));
2704
-
2705
- // src/Manifest/ManifestBrowserCreator/index.tsx
2706
- init_manifest_browser_form_lazy();
2707
- var import_jsx_runtime44 = require("react/jsx-runtime");
2708
- var manifestBrowserCreator = (0, import_creator_api25.defineCreator)({
2709
- id: "@manifest-editor/manifest-browser-creator",
2710
- create: createFromManifestBrowserOutput,
2711
- label: "IIIF Browser",
2712
- summary: "Browse IIIF Resources",
2713
- icon: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components28.IIIFBrowserIcon, {}),
2714
- render(ctx) {
2715
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ManifestBrowserCreatorForm, { ...ctx });
2716
- },
2717
- resourceType: "Manifest",
2718
- resourceFields: ["id", "label"],
2719
- additionalTypes: ["Collection"],
2720
- supports: {
2721
- parentTypes: ["Collection"],
2722
- parentFieldMap: {
2723
- Collection: ["items"]
2724
- }
2725
- },
2726
- sideEffects: [],
2727
- staticFields: {}
2728
- });
2729
-
2730
- // src/index.ts
2731
- var allCreators = [
2732
- // Images first.
2733
- imageServiceCreator,
2734
- imageServiceAnnotation,
2735
- imageUrlCreator,
2736
- imageUrlAnnotation,
2737
- videoAnnotation,
2738
- audioAnnotation,
2739
- htmlBodyCreator,
2740
- htmlAnnotation,
2741
- youTubeBodyCreator,
2742
- iiifBrowserCreator,
2743
- emptyCanvas,
2744
- plaintextCreator,
2745
- webPageCreator,
2746
- emptyAnnotationPage,
2747
- noBodyAnnotation,
2748
- internalCanvas,
2749
- captionedImageAnnotation,
2750
- imageUrlListCreator,
2751
- imageUrlListAnnotation,
2752
- thumbnailCreator
2753
- ];
92
+ `,xe=g.default.label`
93
+ ${be}
94
+ `;function S(e){let[t,n]=(0,p.useState)(!1),{progress:r,currentTime:i,element:a}=(0,h.useMediaElements)(),{duration:o,isMuted:s,volume:c,isPlaying:l,playRequested:u}=(0,h.useMediaState)(),{setVolume:d,toggleMute:f,play:g,pause:_,setDurationPercent:v}=(0,h.useMediaActions)(),y=s||c===0?se:c>50?ae:oe;return(0,p.useLayoutEffect)(()=>{if(a.current){let t=a.current;if(t.error&&e.onError){e.onError(t.error?.message||`Unknown error`);return}let n=()=>{e.onError&&e.onError(t.error?.message||`Unknown error`)},r=()=>{t.duration&&e.onDuration&&e.onDuration(t.duration),e.onDimensions&&t instanceof HTMLVideoElement&&e.onDimensions(t.videoWidth,t.videoHeight)};return t.addEventListener(`loadedmetadata`,r),t.addEventListener(`error`,n),()=>{t.removeEventListener(`loadedmetadata`,r),t.removeEventListener(`error`,n)}}},[]),(0,m.jsxs)(ce,{children:[(0,m.jsx)(ue,{disabled:u,onClick:()=>{l?_():g()},children:u?(0,m.jsx)(ye,{stroke:`#999`}):l?(0,m.jsx)(ie,{title:`Pause`}):(0,m.jsx)(re,{title:`Play`})}),(0,m.jsx)(de,{ref:i,children:`0:00`}),(0,m.jsxs)(fe,{onClick:e=>{let{left:t,width:n}=e.currentTarget.getBoundingClientRect();v((e.pageX-t)/n)},children:[(0,m.jsx)(me,{}),o?(0,m.jsx)(pe,{ref:r}):null]}),(0,m.jsx)(de,{children:(0,h.formatTime)(o)}),(0,m.jsxs)(ge,{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,m.jsx)(_e,{$isOpen:t,children:(0,m.jsxs)(`span`,{children:[(0,m.jsx)(xe,{htmlFor:`audio-slider`,children:`Change volume`}),(0,m.jsx)(ve,{id:`audio-slider`,role:`slider`,disabled:s,min:`0`,max:`100`,value:c,onChange:e=>d(Number(e.currentTarget.value))})]})}),(0,m.jsx)(he,{onClick:()=>f(),children:(0,m.jsx)(y,{title:s?`Mute`:`Unmute`})})]})]})}async function C(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=t.embed({id:e.url,type:`Sound`,format:`audio/mp4`,duration:e.duration||0});if(r===`Annotation`)return t.embed({...n,label:(0,u.getValue)(e.label)&&e.label,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:i,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:i,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},duration:e.duration||0,items:[s]})}}function w(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(0),[a,o]=(0,p.useState)(``),[s,c]=(0,p.useState)({en:[``]});return(0,p.useEffect)(()=>{if(o(``),i(0),t){let e=t.split(`/`).pop()?.split(`.`).shift();c({en:[e||``]})}},[t]),(0,m.jsxs)(d.PaddedSidebarContainer,{children:[a?(0,m.jsx)(d.ErrorMessage,{children:a}):null,(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`audio-url`,children:`URL`}),(0,m.jsx)(f.Input,{type:`text`,id:`audio-url`,value:t,onChange:e=>n(e.target.value)})]}),t&&!a?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:s,onSave:e=>c(e.toInternationalString())},`${t}__${r}`)}):null,t&&!a?(0,m.jsx)(h.CanvasPanel.AudioHTML,{media:{url:t,duration:r,type:`Sound`},children:(0,m.jsx)(S,{onError:e=>o(e),onDuration:e=>i(~~e)},`${t}__${r}`)},`${t}__${r}`):null,r&&!a?(0,m.jsxs)(f.FormFieldWrapper,{children:[(0,m.jsx)(f.InputLabel,{htmlFor:`duration`,children:`Duration`}),(0,m.jsx)(f.Input,{type:`number`,id:`duration`,value:r,onChange:e=>i(e.target.valueAsNumber)})]}):null,(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:t,duration:r,label:s})},isDisabled:!t||!!a,children:`Add audio`})]})}const T=(0,l.defineCreator)({id:`@manifest-editor/audio-annotation`,create:C,label:`Audio`,summary:`Audio annotation`,icon:(0,m.jsx)(d.AudioIcon,{}),render(e){return(0,m.jsx)(w,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function E(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=Object.keys(e.body),a=[];for(let r of i){let i=e.body[r].join(`
95
+ `);i&&a.push(await t.create(`@manifest-editor/html-body-creator`,{language:r,body:i},{parent:{resource:n,property:`items`}}))}let o=await t.create(`@manifest-editor/image-url-creator`,{url:e.imageUrl},{parent:{resource:n,property:`body`}});if(o&&a.push(o),r===`Annotation`)return t.embed({...n,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:a,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:a,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:i,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},height:e.height||1e3,width:e.width||1e3,items:[s]})}}function D(e){let[t,n]=(0,_.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId});return(0,m.jsx)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());e.runCreate({body:{en:[r.caption]},imageUrl:r.url})},children:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`url`,children:`URL to Image`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,placeholder:`https://example.org/image.jpg`})]}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`caption`,children:`Caption`}),(0,m.jsx)(f.Input,{id:`caption`,name:`caption`,placeholder:`Enter a caption`,onChange:e=>n({en:[e.target.value]}),value:t.en?.[0]||``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create`})]})})}const O=(0,l.defineCreator)({id:`@manifest-editor/captioned-image-annotation`,create:E,label:`Captioned image`,summary:`Add an image from a URL with caption`,icon:(0,m.jsx)(d.AddImageIcon,{}),render(e){return(0,m.jsx)(D,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,disallowPainting:!0,parentTypes:[`AnnotationPage`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function k(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=Object.keys(e.body),a=[];for(let r of i){let i=e.body[r].join(`
96
+ `);i&&a.push(await t.create(`@manifest-editor/html-body-creator`,{language:r,body:i},{parent:{resource:n,property:`items`}}))}if(r===`Annotation`)return t.embed({...n,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:a,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:a,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:i,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},height:e.height||1e3,width:e.width||1e3,items:[s]})}}function A(e){let[t,n]=(0,_.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId}),r=(0,u.getValue)(t).trim()===``;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.HTMLEditor,{className:`border-none`,value:t.en?.[0]||``,onChange:e=>n({en:[e]})}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`button`,onPress:()=>{e.runCreate({body:t})},isDisabled:r,children:`Create`})]})}const j=(0,l.defineCreator)({id:`@manifest-editor/html-annotation`,create:k,label:`HTML`,summary:`HTML annotation`,icon:(0,m.jsx)(d.HTMLIcon,{}),render(e){return(0,m.jsx)(A,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),M={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items)return;let o=t.get(a.items[0]);if(!o||o.items.length<2&&!a.behavior.includes(`multi-image`))return;let s=t.get(n.body)[0],c=n.body[0]?.selector,l=(s.service||[]).find(e=>(0,v.isImageService)(e));l&&l.width&&l.height&&(l.width!==s.width&&t.modifyEntityField({id:s.id,type:`ContentResource`},`width`,l.width),l.height!==s.height&&t.modifyEntityField({id:s.id,type:`ContentResource`},`height`,l.height));let u=l?.width||s.width,d=l?.height||s.height;if(c&&(c.type===`iiif:ImageApiSelector`||c.type===`ImageApiSelector`)&&c.region){let[e,t,n,r]=c.region.split(`,`);u=Number(n)||u,d=Number(r)||d}let p=new y.EditorInstance({vault:t,reference:e}),m=(0,f.centerRectangles)(a,{width:u,height:d},.6);p.annotation.target.setPosition(m)}}},N={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items||a.behavior.includes(`multi-image`))return;let o=t.get(a.items[0]);if(!o||o.items.length>1)return;let s=t.get(n.body);if(s.length!==1)return;let c=s[0],l=n.body[0]?.selector,u=(c.service||[])[0],d=u?.width||c.width,f=u?.height||c.height,p=c.duration||u?.duration;if(l&&(l.type===`iiif:ImageApiSelector`||l.type===`ImageApiSelector`)&&l.region){let[e,t,n,r]=l.region.split(`,`);d=Number(n)||d,f=Number(r)||f}let m=new y.EditorInstance({vault:t,reference:i});t.batch(()=>{d!==void 0&&m.technical.width.set(d),f!==void 0&&m.technical.height.set(f),p!==void 0&&m.technical.duration.set(p)})}}};var Se=Object.defineProperty,Ce=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t,n)=>(Ce(e,typeof t==`symbol`?t:t+``,n),n);function F(e){return e.endsWith(`info.json`)?e:e.endsWith(`/`)?`${e}info.json`:`${e}/info.json`}var we=`http://library.stanford.edu/iiif/image-api/compliance.html#level0`,I=`http://library.stanford.edu/iiif/image-api/compliance.html#level1`,L=`http://library.stanford.edu/iiif/image-api/compliance.html#level2`,Te=`http://library.stanford.edu/iiif/image-api/conformance.html#level0`,Ee=`http://library.stanford.edu/iiif/image-api/conformance.html#level1`,De=`http://library.stanford.edu/iiif/image-api/conformance.html#level2`,Oe=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0`,ke=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1`,Ae=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2`,je=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0`,Me=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1`,Ne=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2`,Pe=`http://iiif.io/api/image/1/level0.json`,Fe=`http://iiif.io/api/image/1/profiles/level0.json`,Ie=`http://iiif.io/api/image/1/level1.json`,Le=`http://iiif.io/api/image/1/profiles/level1.json`,Re=`http://iiif.io/api/image/1/level2.json`,ze=`http://iiif.io/api/image/1/profiles/level2.json`,Be=`http://iiif.io/api/image/2/level0.json`,Ve=`http://iiif.io/api/image/2/profiles/level0.json`,He=`http://iiif.io/api/image/2/level1.json`,Ue=`http://iiif.io/api/image/2/profiles/level1.json`,We=`http://iiif.io/api/image/2/level2.json`,Ge=`http://iiif.io/api/image/2/profiles/level2.json`,Ke=`level0`,qe=`level1`,Je=`level2`,Ye=`http://iiif.io/api/image/2/level0`,Xe=`http://iiif.io/api/image/2/level1`,Ze=`http://iiif.io/api/image/2/level2`,Qe=[Ze,L,De,Ae,Ne,Re,ze,We,Ge,Je],$e=[...Qe,Xe,I,Ee,ke,Me,Ie,Le,He,Ue,qe],et=[Ye,Xe,Ze,we,I,L,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je],tt=et,nt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`sizeByWhListed`]},rt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPx`,`regionSquare`,`sizeByWhListed`,`sizeByH`,`sizeByW`,`sizeByWh`]},it={extraFormats:[`jpg`,`png`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPct`,`regionByPx`,`regionSquare`,`rotationBy90s`,`sizeByWhListed`,`sizeByConfinedWh`,`sizeByH`,`sizeByPct`,`sizeByW`,`sizeByWh`]},at=[`baseUriRedirect`,`canonicalLinkHeader`,`cors`,`jsonldMediaType`,`mirroring`,`profileLinkHeader`,`regionByPct`,`regionByPx`,`regionSquare`,`rotationArbitrary`,`rotationBy90s`,`sizeByConfinedWh`,`sizeByH`,`sizeByPct`,`sizeByW`,`sizeByWh`,`sizeUpscaling`,`sizeByWhListed`,`sizeByDistortedWh`,`sizeByForcedWh`];function ot(e){return Qe.indexOf(e)===-1?$e.indexOf(e)===-1?nt:rt:it}function st(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],n={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let e of t)if(typeof e==`string`&&(e=ot(e)),e){if(e.formats)for(let t of e.formats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.qualities)for(let t of e.qualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);if(e.supports)for(let t of e.supports)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);if(e.maxHeight&&(n.maxHeight=e.maxHeight),e.maxWidth&&(n.maxWidth=e.maxWidth),e.maxArea&&(n.maxArea=e.maxArea),e.extraFormats)for(let t of e.extraFormats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.extraQualities)for(let t of e.extraQualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);if(e.extraFeatures)for(let t of e.extraFeatures)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);e.maxHeight&&(n.maxHeight=e.maxHeight),e.maxWidth&&(n.maxWidth=e.maxWidth),e.maxArea&&(n.maxArea=e.maxArea)}if(e.extraFormats)for(let t of e.extraFormats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.extraFeatures)for(let t of e.extraFeatures)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);if(e.extraQualities)for(let t of e.extraQualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);return n}function ct(e){try{if(e===`full`)return{full:!0};if(e===`square`)return{square:!0};let t=e.startsWith(`pct:`),n=e.substr(t?4:0).split(`,`).map(e=>parseFloat(e));return{x:n[0],y:n[1],w:n[2],h:n[3],percent:t}}catch{throw Error(`Expected 'full', 'square' or 'x,y,w,h'. Found `+e)}}function lt(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]===`^`&&(t.upscaled=!0,e=e.slice(1)),e===`max`||e===`full`)return t.max=!0,t.serialiseAsFull=e===`full`,t;if(e[0]===`!`&&(t.confined=!0,e=e.slice(1)),e[0]===`p`)return t.percentScale=parseFloat(e.slice(4)),t;let n=e.split(`,`).map(e=>e.trim());return n.length&&typeof n[0]<`u`&&(n[0]!==``&&(t.width=parseInt(n[0],10)),typeof n[1]<`u`&&n[1]!==``?(t.height=parseInt(n[1],10),t.version=2):t.version=3),t}function ut(e){let t={angle:0};if(e[0]===`!`&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw Error(`Invalid rotation ${e}`);return t}function dt(e,t=``){let n=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!n)throw Error(`Invalid or unknown input ${e}`);let r=n[2],i=n[3],a=n[4];if(a[0]===`/`&&(a=a.substring(1)),t.length>0){if(t[0]===`/`&&(t=t.substring(1)),t!==a.substring(0,t.length))throw Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:r,server:i,path:a,prefix:t}}function ft(e,t=``){let{path:n,scheme:r,server:i,prefix:a}=dt(e,t),o=(n||``).split(`/`).reverse(),[s,c,l,u,...d]=o,f=d.reverse().filter(Boolean).join(`/`);if(o.length===1||s===``)return{type:`base`,scheme:r,server:i,prefix:a,identifier:f};if(s===`info.json`){let[,...e]=o;return{type:`info`,scheme:r,server:i,prefix:a,identifier:e.reverse().filter(Boolean).join(`/`)}}let p=(s||``).split(`.`);if(typeof p[1]>`u`||typeof p[0]>`u`||typeof u>`u`||typeof l>`u`||typeof c>`u`)throw Error(`Invalid image request`);return{type:`image`,scheme:r,server:i,prefix:a,identifier:f,originalPath:n,region:ct(u),size:lt(l),rotation:ut(c),quality:p[0],format:p[1]}}function pt(e){let t=ft(F(e.id));if(t.type!==`info`)throw Error(`Invalid service URL`);let n=st(e);return{identifier:t.identifier,originalPath:``,server:t.server,prefix:t.prefix,scheme:t.scheme,type:`image`,quality:n.extraQualities.indexOf(`default`)===-1?n.extraQualities[0]:`default`,region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:`jpg`,rotation:{angle:0}}}function mt(e,t,n){let r=n.length,i=[];for(let t=0;t<r;t++){let r=n[t];if(r){let t=r.width;i.push(e/t)}}return i}function ht(e,t,n){let r=n.length,i=[];for(let a=0;a<r;a++){let r=n[a];r&&i.push({width:Math.floor(e/r),height:Math.floor(t/r)})}return i}function R(e){if(e[`@id`])return e[`@id`];if(e.id)return e.id}function z(e){if(!e||!e.profile||!R(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`&&et.indexOf(e)!==-1)return!0;return!1}function gt(e){if(!z(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`){if($e.indexOf(e)!==-1)return!0}else{let t=[...e.supports||[],...e.extraFeatures||[]];if(t.indexOf(`regionByPx`)!==-1&&(t.indexOf(`sizeByW`)!==-1||t.indexOf(`sizeByWh`)!==-1))return!0}return!1}function B(e,t){if(t&&t.profile){let n=t.profile;if(n){let t=Array.isArray(n)?n:[n];return t.includes(`level${e}`)||t.includes(`http://iiif.io/api/image/2/level${e}.json`)||t.includes(`http://iiif.io/api/image/1/level${e}.json`)||t.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`)}}return!1}function V(e){return z(e)?B(0,e)?0:B(1,e)?1:B(2,e)?2:null:null}function _t(e){return(e[`@context`]?Array.isArray(e[`@context`])?e[`@context`]:[e[`@context`]]:[]).indexOf(`http://iiif.io/api/image/3/context.json`)!==-1}function vt(e){if(!gt(e))return[];let t=[],n=Array.isArray(e.profile)?e.profile:[e.profile],r=n.length;for(let t=0;t<r;t++){let r=n[t];if(r&&typeof r!=`string`&&(r.maxHeight||r.maxWidth))return[{id:R(e),type:`variable`,minWidth:0,minHeight:0,maxHeight:r.maxHeight||r.maxWidth,maxWidth:r.maxWidth||r.maxHeight,level:V(e),version:e[`@context`]===`http://iiif.io/api/image/3/context.json`?3:2}]}if(e.tiles){let n=e.tiles.length;for(let r=0;r<n;r++){let n=e.tiles[r];n&&(n.height||n.width)&&t.push({id:R(e),type:`variable`,minHeight:0,minWidth:0,maxHeight:n.height||n.width,maxWidth:n.width,level:V(e),version:_t(e)?3:2})}}return t}function yt(e){let t=e.match(/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/);if(t&&t[4]&&t[5]){let n=t[1],r=parseInt(t[4],10),i=parseInt(t[5],10),a=t[7];if((n===`max`||n===`full`)&&r&&i&&a)return{type:`fixed`,id:e,height:i,width:r}}return{type:`unknown`,id:e}}function bt(e){if(e[`@type`])return e[`@type`];if(e.type)return e.type}function xt(e){if(typeof e==`string`)return yt(e);let t=bt(e);if(t!==`Image`&&t!==`sc:Image`)return null;let n=e,r=R(n);return r?r&&n.width&&n.height?{id:r,type:`fixed`,width:n.width,height:n.height,unsafe:!0}:yt(r):null}function St(e){return z(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:R(e),type:`fixed-service`,height:t.height,width:t.width,level:V(e),version:_t(e)?3:2})):[]}function Ct(e){let t=[],n=e.length;for(let r=0;r<n;r++){let n=e[r];if(!n)continue;let i=St(n);i.length&&t.push(...i);let a=vt(n);a.length&&t.push(...a)}return t}function wt(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],n=t.length,r=[];for(let e=0;e<n;e++)z(t[e])&&r.push(t[e]);return r}function Tt(e,t=!0,n){let r=[],i=xt(e);if(i===null)return r;let a=e;if(r.push(i),t&&a&&a.width&&a.height){let e=[],t=wt(a);for(let r of t){let t={id:R(r),width:a.width,height:a.height};if(n.canLoadSync(t)){let r=n.loadServiceSync(t);r&&(r.height||(r.height=a.height),r.width||(r.width=a.width),e.push(...Ct([r])))}}if(e.length)return r.push(...e),r}return a.service&&r.push(...Ct(a.service)),r}function Et({x:e=0,y:t=0,w:n,h:r,full:i,square:a,percent:o}){if(i)return`full`;if(a)return`square`;if(typeof n>`u`||typeof r>`u`)throw Error(`RegionParameter: invalid region`);let s=`${e},${t},${n},${r}`;return o?`pct:${s}`:s}function Dt({max:e,percentScale:t,upscaled:n,confined:r,width:i,height:a,serialiseAsFull:o,version:s}){let c=[];return n&&c.push(`^`),e?(c.push(o?`full`:`max`),c.join(``)):(r&&c.push(`!`),t&&c.push(`pct:${t}`),i&&c.push(`${i}`),c.push(`,`),a&&s===3&&c.push(`${a}`),c.join(``))}function Ot(e){return`${e.mirror?`!`:``}${(e.angle||0)%360}`}function kt(e,t){let n=e.prefix.startsWith(`/`)?e.prefix.substr(1):e.prefix,r=`${e.scheme}://${e.server}/${n?`${n}/`:``}${e.identifier}`;if(e.type===`base`)return r;if(e.type===`info`)return`${r}/info.json`;let{size:i}=e,{region:a,rotation:o,format:s,quality:c}=e;if(t){let e=t[`@context`]?Array.isArray(t[`@context`])?t[`@context`]:[t[`@context`]]:[],n=e.indexOf(`http://iiif.io/api/image/2/context.json`)!==-1,r=e.indexOf(`http://iiif.io/api/image/3/context.json`)!==-1;if((i.width===t.width&&!i.height||i.height===t.height&&!i.width||i.width===t.width&&i.height===t.height)&&(i={...i,max:!0}),n&&(i.max&&!i.serialiseAsFull&&(i={...i,serialiseAsFull:!0}),!i.max&&i.width&&i.height&&(i={...i,height:void 0}),i={...i,version:2}),r){if(i.max&&i.serialiseAsFull&&(i={...i,serialiseAsFull:!1}),i.width&&!i.height&&t.width&&t.height){let e=t.height/t.width;i={...i,height:Math.ceil(i.width*e)}}i={...i,version:3}}}return[r,Et(a),Dt(i),Ot(o),`${c}.${s}`].filter(Boolean).join(`/`)}function H(e,t,n){let r=pt({"@context":e.version===3?`http://iiif.io/api/image/3/context.json`:`http://iiif.io/api/image/2/context.json`,id:F(R(e)),profile:e.level===null||typeof e.level>`u`?`level0`:`level${e.level}`,type:e.version===3?`ImageService3`:`ImageService2`});if(r.type!==`image`)throw Error(`Invalid service`);return r.size.max=!1,r.size.width=t,r.size.height=n,{id:kt(r),type:`fixed`,width:t,height:n||e.height/(e.width||1)*t,unsafe:e.width>t}}function U(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,``);return t.indexOf(`/`)===-1?t:t.split(`/`)[0]}function At(e,t,n){let r=e.width?e.width:e.maxWidth;return n.height<=e.maxHeight&&n.width<=e.maxWidth&&n.height>=e.minHeight&&n.width>=e.minWidth&&(!t||Math.abs(n.width-r)<Math.abs(t.width-r))}function jt(e,t){let n=[],r=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),i=(e,t=0)=>r.explain?n.push(Array(t).fill(0).map(e=>` `).join(``)+e().trim()):void 0,a=[],o=[],s=null;i(()=>`Using configuration: ${JSON.stringify(r,null,2)}`);let c=(e,t)=>{if(i(()=>`Swapping choice`,3),At(r,t,e)){if(r.preferFixedSize&&e.unsafe){i(()=>`We found an image that was marked as unsafe, but it was the best size. (${e.id})`,4),o.push(e);return}r.returnAllOptions&&t&&o.push(t),i(()=>`We found a new image that was the best size. (${e.id})`,4),s=e}else r.returnAllOptions&&o.push(e)};i(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let l=t.length;for(let e=0;e<l;e++){let n=t[e]();i(()=>`Candidate group ${e}: ${JSON.stringify(n,null,2)}`,1);let o=n.length;i(()=>`Checking candidate list number ${e} and found ${o} potential ways of creating image(s)`,1);for(let e=0;e<o;e++){let t=n[e];i(()=>`-> Checking candidate ${e}`,1),t.type===`unknown`&&r.atAnyCost&&(i(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(t)),t.type===`fixed`&&(t.unsafe?(i(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(t)):(i(()=>`We've found a fixed size image, checking if it matches the request`,2),c(t,s))),t.type===`fixed-service`&&(r.unsafeImageService?(i(()=>`Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)`,2),c(H(t,r.width,r.height),s)):(i(()=>`Checking for an image from the tile source 3`,2),c(H(t,t.width,t.height),s))),t.type===`variable`&&t.maxWidth&&c(H({id:t.id,type:`fixed-service`,width:t.maxWidth,height:t.maxWidth,level:t.level,version:t.version},t.maxWidth),s)}if(s&&!r.returnAllOptions){if(s.unsafe||r.allowUnsafe)continue;i(()=>`We found a match in choice list number ${e}, no searching any more`);break}}return r.atAnyCost&&o.length===0?(i(()=>s?`We found an image! ${s.id} of type ${s.type}`:`We found no images, but "atAnyCost" is set, so returning that`),{best:s||a[0]||null,fallback:a.slice(1),log:n}):r.returnAllOptions?(i(()=>`Returning all options that we have found`),{best:(r.atAnyCost?s||o[0]||a[0]:s||o[0])||null,fallback:[...o,...a],log:n}):(i(()=>`Returning the best image that we found, and a fallback`),{best:s||o[0]||null,fallback:s?o:o.slice(1),log:n})}function Mt(e,t,n){let r=e>t?e:t,i=n.length,a=[];for(let e=0;e<i;e++){let t=n[e];if(!t||t.scaleFactors.length===0)continue;let i=t.scaleFactors[0];if(!i)continue;let o=r/i,s=[i];for(;o>=t.width;)i*=2,s.push(i),o/=2;a.push({...t,scaleFactors:s})}return a}function Nt(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let n=e.length,r=!0;for(let i=0;i<n;i++){let n=e[i],a=t[i];if(n.width!==a.width||n.height!==a.height){r=!1;break}}if(r)return!0;let i=0;for(let r=0;r<n;r++)for(let a=0;a<n;a++)if(e[r].width===t[a].width&&e[r].height===t[a].height){i++;break}return i===n}function Pt(e){return B(0,e)}var Ft=class{constructor(e={}){P(this,`config`,{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),P(this,`fetchingCount`,0),P(this,`imageServices`,{}),P(this,`knownImageServers`,{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,n=!0){let r=U(R(e)),i=F(R(e)),a=this.knownImageServers[r];return this.imageServices[i]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Pt(e)?(this.knownImageServers[r]={verifications:0,malformed:!1,root:r,preLoaded:n,sampledId:R(e),verified:!1,server:null,result:{context:e[`@context`]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:mt(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,n=!1){let r=e?.source,i=U(R(e)),a=this.knownImageServers[i],o=F(R(e));return this.imageServices[o]?this.imageServices[o]||null:!this.config.approximateServices||!a||!a.result||!(r?.height||e.height)||!(r?.width||e.width)||!n&&(a.malformed||a.verifications<this.config.verificationsRequired)||Pt(e.source)?null:(this.imageServices[o]||(this.imageServices[o]={"@context":a.result.context,"@id":R(e),id:R(e),protocol:`http://iiif.io/api/image`,tiles:r?.tiles||Mt(e.width,e.height,a.result.sampledTiles),sizes:r?.sizes||ht(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:r?.profile||a.result.sampledProfile,height:r?.height||e.height,width:r?.width||e.width,real:!1}),this.imageServices[o]||null)}async getThumbnailFromResource(e,t,n=!0,r=[]){let i=e?await this.getImageCandidates(e,n):[];return jt(t,[()=>r,()=>i])}async getImageCandidates(e,t=!0){let n=e;if(t&&n&&n.height&&n.width){let e=wt(n);for(let t of e){let e={id:R(t),width:t.width?t.width:n.width,height:t.height?t.height:n.height,source:t};await this.loadService(e)}}return Tt(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),n=await this.fetchService(R(e));if(!t)return!1;let r=t.height===n.height&&t.width===n.width&&t[`@context`]===n[`@context`]&&Nt(t.sizes||[],n.sizes||[]);if(r){let t=U(R(e)),n=this.knownImageServers[t];n&&(n.verifications+=1,n.verifications>=this.config.verificationsRequired&&(n.verified=!0))}return r}canLoadSync(e){let t=typeof e==`string`?e:R(e),n=F(t);if(this.imageServices[n])return!0;let r=this.knownImageServers[U(t)];return!!(r&&!r.malformed&&r.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[U(R(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let n=F(e),r=this.imageServices[n];if(r&&(!t||r.real))return r;if(!this.config.enableFetching)throw Error(`Fetching is not enabled`);let i=await this.fetch(n).then(e=>e.json());return!i.id&&i[`@id`]&&(i.id=i[`@id`]),i.id!==e&&(i.id=e,i[`@id`]&&(i[`@id`]=e)),this.imageServices[n]=Object.assign(i,{real:!0}),this.imageServices[n]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let e=!0;for(;e;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(e=>setTimeout(e,500));else{e=!1;break}}let n=this.knownImageServers[U(R(e))];if(n&&!n.malformed&&!t){await n.result;let t=this.loadServiceSync(e);if(t)return t}this.fetchingCount++;let r=await this.fetchService(R(e),t);return this.fetchingCount--,r.real&&this.sample(r,e),r}loadServiceSync(e){let t=F(R(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}},It=new Ft;const W={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items||a.behavior.includes(`multi-image`)||!t.get(a.items[0]))return;let o=Array.isArray(n.body)?n.body[0]:n.body;if(o.type===`SpecificResource`&&o.selector)return;let s=t.get(n.body)[0],c=(s.service||[]).find(e=>z(e));c&&c.width&&c.height&&(c.width!==s.width&&t.modifyEntityField({id:s.id,type:`ContentResource`},`width`,c.width),c.height!==s.height&&t.modifyEntityField({id:s.id,type:`ContentResource`},`height`,c.height))}}};async function Lt(e,t){let n={...e.service};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,v.createImageServiceRequest)(n),i=(0,v.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.scheme,type:`image`,size:{max:!e.size?.width&&!e.size?.height,confined:!1,upscaled:!1,...e.size||{}},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:r.prefix,originalPath:r.originalPath});return t.embed({id:i,type:`Image`,format:e.format||`image/jpeg`,height:e.height||n.height,width:e.width||n.width,service:e.embedService===!1?void 0:[e.service]})}function G(e){return e.endsWith(`default.jpg`)?(0,v.imageServiceRequestToString)({...(0,v.parseImageServiceRequest)(e),type:`info`}):(0,v.canonicalServiceUrl)(e)}function K(e){let[t,n]=(0,p.useState)(``);return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries()),i=r.url;if(i){let t=G(i);if(!t)throw Error(`Invalid image service request`);fetch(t).then(e=>e.json()).then(t=>{e.runCreate({url:r.url,service:t})})}},children:[(0,m.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?G(t):``)},onBlur:e=>n(e.currentTarget.value?G(e.currentTarget.value):``)})]})}),(0,m.jsx)(`div`,{className:`relative flex z-0 my-5 h-96 min-h-0 min-w-0 overflow-hidden bg-gray-200 rounded items-center justify-center`,children:t.trim()?(0,m.jsx)(ee.ErrorBoundary,{fallbackRender:()=>(0,m.jsx)(`div`,{children:`Invalid service`}),children:(0,m.jsx)(h.ImageService,{src:t,fluid:!0,errorFallback:()=>(0,m.jsx)(`div`,{children:`Invalid service`}),background:`rgb(229,231,235)`,className:`h-full w-full`,containerProps:{className:`w-full h-full z-10`}})}):(0,m.jsx)(`div`,{className:`text-grey-600`,children:`Preview`})}),(0,m.jsx)(`div`,{children:(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Create`})})]})})}async function Rt(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,l.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-service-creator`)(e,{parent:{resource:n,property:`body`}});if(r===`Annotation`)return{...n,body:[i],motivation:e.motivation||`painting`,target:t.getTarget()};if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]}),c;return e.service?.sizes&&(c=await(0,l.creatorHelper)(t,`Canvas`,`thumbnail`,`@manifest-editor/thumbnail-image`)({service:e.service,width:e.thumbnailSize||400})),t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled canvas`]},height:i.resource.height||1e3,width:i.resource.width||1e3,thumbnail:c?[c]:void 0,items:[s]})}}function zt(e){return(0,m.jsx)(K,{...e})}const Bt=(0,l.defineCreator)({id:`@manifest-editor/image-service-annotation`,create:Rt,label:`IIIF Image`,dependencies:[`@manifest-editor/image-service-creator`],summary:`IIIF Image service`,tags:[`image`,`image-service`],icon:(0,m.jsx)(d.IIIFLogo,{style:{padding:10}}),render(e){return(0,m.jsx)(zt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}});async function Vt(e,t){if(!e.height||!e.width){let t=await(0,_.getImageDimensions)(e.url);t&&(e.height=t.height,e.width=t.width)}return t.embed({id:e.url,type:`Image`,format:e.format||await(0,_.getFormat)(e.url),height:e.height,width:e.width,service:e.service?Array.isArray(e.service)?e.service:[e.service]:void 0})}function q(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.url&&e.runCreate({url:r.url})},children:[(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to Image`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function Ht(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,l.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-url-creator`)(e,{parent:{resource:n,property:`body`}});if(r===`Annotation`)return t.embed({...n,body:[i],motivation:e.motivation||`painting`,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled canvas`]},height:i.resource.height||1e3,width:i.resource.width||1e3,items:[s]})}throw Error(`Unsupported target type`)}function Ut(e){return(0,m.jsx)(q,{...e})}const Wt=(0,l.defineCreator)({id:`@manifest-editor/image-url-annotation`,create:Ht,label:`Image`,dependencies:[`@manifest-editor/image-url-creator`],summary:`Image from URL`,tags:[`image`],icon:(0,m.jsx)(d.AddImageIcon,{}),render(e){return(0,m.jsx)(Ut,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}});async function Gt(e,t){let n=[],r=(0,l.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-url-creator`);for(let i of e.images)n.push(await r(i,t.options));return n}function J(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(d.Form.Form,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.urls&&e.runCreate({images:r.urls.split(`
97
+ `).map(e=>({url:e}))})},children:[(0,m.jsxs)(d.Form.InputContainer,{className:`mb-4`,children:[(0,m.jsx)(d.Form.Label,{children:`Enter a list of URLs (one per line)`}),(0,m.jsx)(d.Form.TextArea,{name:`urls`,rows:`10`})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function Kt(e,t){let n=[],r=(0,l.creatorHelper)(t,`AnnotationPage`,`items`,`@manifest-editor/image-url-annotation`);for(let i of e.images)n.push(await r(i,t.options));return n}const qt=(0,l.defineCreator)({id:`@manifest-editor/image-url-list-annotation`,create:Kt,label:`List of Images`,dependencies:[`@manifest-editor/image-url-annotation`],summary:`List of Images from URLs`,tags:[`image`],icon:(0,m.jsx)(d.ImageListIcon,{}),render(e){return(0,m.jsx)(J,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}}),Jt=(0,l.defineCreator)({id:`@manifest-editor/no-body-annotation`,create:Yt,label:`Annotation without body`,summary:`Add an annotation that only has motivation and target`,icon:(0,m.jsx)(d.EmptyCanvasIcon,{}),resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`target`],supports:{initialData:!0,parentTypes:[`AnnotationPage`],parentFields:[`items`],disallowPainting:!0},actionButton:`Create empty annotation`,sideEffects:[],staticFields:{type:`Annotation`}});function Yt(e,t){return t.embed({id:t.generateId(`annotation`),type:`Annotation`,label:e?.label,motivation:e.motivation||t.options.initialData?.motivation||`highlighting`,target:t.getTarget()})}function Xt({media:e,onError:t,duration:n,onDuration:r,onDimensions:i}){let[{element:a,currentTime:o,progress:s},c,l]=(0,h.useSimpleMediaPlayer)({duration:n});return(0,m.jsxs)(h.MediaPlayerProvider,{element:a,state:c,actions:l,currentTime:o,progress:s,children:[(0,m.jsx)(`div`,{style:{maxHeight:400,aspectRatio:`${e.width}/${e.height}`,position:`relative`},children:(0,m.jsx)(h.CanvasPanel.VideoHTML,{element:a,media:e,playPause:l.playPause})}),(0,m.jsx)(S,{onError:t,onDuration:r,onDimensions:i})]})}async function Zt(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=t.embed({id:e.url,type:`Video`,format:`video/mp4`,width:e.width,height:e.height,duration:e.duration||0});if(r===`Annotation`)return t.embed({...n,label:(0,u.getValue)(e.label)&&e.label,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:i,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:i,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},duration:e.duration||0,width:e.width,height:e.height,items:[s]})}}function Qt(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(0),[a,o]=(0,p.useState)(0),[s,c]=(0,p.useState)(0),[l,u]=(0,p.useState)(``),[h,g]=(0,p.useState)({en:[``]});return(0,p.useEffect)(()=>{if(u(``),i(0),t){let e=t.split(`/`).pop()?.split(`.`).shift();g({en:[e||``]})}},[t]),(0,m.jsxs)(d.PaddedSidebarContainer,{children:[l?(0,m.jsx)(d.ErrorMessage,{children:l}):null,(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`video-url`,children:`URL`}),(0,m.jsx)(f.Input,{type:`text`,id:`video-url`,value:t,onChange:e=>n(e.target.value)})]}),t&&!l?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:h,onSave:e=>g(e.toInternationalString())},`${t}__${r}`)}):null,t&&!l?(0,m.jsx)(`div`,{className:`mb-4 bg-black`,children:(0,m.jsx)(Xt,{duration:r,onDuration:e=>i(e),onError:e=>u(e),media:{url:t,duration:r,height:s,width:a,type:`Video`},onDimensions:(e,t)=>{o(e||0),c(t||0)}})}):null,!l&&(r||a||s)?(0,m.jsx)(f.InputContainer,{$wide:!0,children:(0,m.jsx)(f.DimensionsTriplet,{widthId:`width`,width:a||0,changeWidth:e=>o(e),heightId:`height`,height:s||0,changeHeight:e=>c(e),durationId:`duration`,duration:r||0,changeDuration:e=>i(e)})}):null,(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:t,duration:r,label:h,width:a,height:s})},isDisabled:!t||!!l,children:`Add video`})]})}const $t=(0,l.defineCreator)({id:`@manifest-editor/video-annotation`,create:Zt,label:`Video`,summary:`Video annotation`,icon:(0,m.jsx)(d.VideoIcon,{}),render(e){return(0,m.jsx)(Qt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),en=()=>(0,m.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,transform:`scale(-1, 1)`,children:(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`rect`,{fill:`none`,height:`24`,width:`24`}),(0,m.jsx)(`path`,{d:`M16,20H2V4h14V20z M18,8h4V4h-4V8z M18,20h4v-4h-4V20z M18,14h4v-4h-4V14z`})]})}),tn=(0,l.defineCreator)({id:`@manifest-editor/empty-annotation-page`,create:(e,t)=>t.embed({id:t.generateId(`annotations`),label:e.label,type:`AnnotationPage`,items:[]}),label:`Empty annotation page`,summary:`AnnotationPage with nothing`,icon:(0,m.jsx)(en,{}),resourceType:`AnnotationPage`,resourceFields:[`id`,`type`,`items`],supports:{parentTypes:[`Manifest`,`Canvas`,`Range`],parentFieldMap:{Manifest:[`annotations`],Canvas:[`items`,`annotations`],Range:[`annotations`]}}}),nn=(0,l.defineCreator)({id:`@manifest-editor/empty-canvas`,create:(e,t)=>{let n=t.generateId(`canvas`),r=t.embed({id:t.generateId(`annotation-page`,{id:n,type:`Canvas`}),type:`AnnotationPage`,items:[]});return{id:n,type:`Canvas`,label:e.label||{en:[``]},height:e.height||1e3,width:e.width||1e3,items:[r]}},label:`Empty canvas`,summary:`No content`,icon:(0,m.jsx)(d.EmptyCanvasIcon,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});var rn=process.env.NODE_ENV===`production`,Y=`Invariant failed`;function X(e,t){if(!e){if(rn)throw Error(Y);var n=typeof t==`function`?t():t,r=n?`${Y}: ${n}`:Y;throw Error(r)}}const an=(0,l.defineCreator)({id:`@manifest-editor/internal-canvas`,create:sn,label:`Internal canvas link`,summary:`Canvas from the same manifest`,icon:(0,m.jsx)(en,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`],parentFields:[`start`]},render:e=>(0,m.jsx)(on,{...e})});function on(e){let t=(0,h.useManifest)(),n=(0,h.useVault)(),r=(0,p.useMemo)(()=>({canSelectCanvas:!1,canSelectCollection:!1,canSelectManifest:!0,canCropImage:!1,alwaysShowNavigationArrow:!1,multiSelect:!1}),[]),i=(0,p.useMemo)(()=>[{type:`callback`,cb:t=>e.runCreate({id:t}),label:`Select canvas`,supportedTypes:[`Canvas`],format:{type:`url`}}],[e.runCreate]),a=(0,p.useMemo)(()=>({saveToLocalStorage:!1,restoreFromLocalStorage:!1,initialHistory:[{url:t?.id,resource:t?.id,route:`/loading?id=${t?.id}`,metadata:{type:`Manifest`}}]}),[t?.id]);return X(t,`Manifest is not loaded`),(0,m.jsx)(h.VaultProvider,{vault:n,children:(0,m.jsx)(te.IIIFBrowser,{vault:n,navigation:r,output:i,history:a})})}async function sn(e,t){return t.embed({id:e.id,type:`Canvas`})}const cn=e=>(0,m.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{d:`M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98 13.87 11h-3.74L12 5.98z`})]});async function ln(e,t){return t.embed({id:t.generateId(`html/${e.language}`),language:e.language,type:`TextualBody`,format:`text/html`,value:e.body||``})}function un(e){let{i18n:t}=(0,_.useConfig)(),[n,r]=(0,p.useState)(`<p></p>`),[i,a]=(0,p.useState)(t.defaultLanguage);return(0,m.jsxs)(d.PaddedSidebarContainer,{children:[(0,m.jsx)(d.HTMLEditor,{className:`border-none`,value:n,onChange:e=>r(e)}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({language:i,body:n})},children:`Create`})]})}const dn=(0,l.defineCreator)({id:`@manifest-editor/html-body-creator`,create:ln,label:`HTML Body`,summary:`Add HTML annotation body`,icon:(0,m.jsx)(cn,{}),render(e){return(0,m.jsx)(un,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],supports:{parentTypes:[`Annotation`],parentFields:[`body`]},staticFields:{type:`TextualBody`,format:`text/html`}});function fn(e,t,n){return`${e}/${Math.floor(t.x)},${Math.floor(t.y)},${Math.floor(t.width)},${Math.floor(t.height)}/${n}/0/default.jpg`}async function pn(e,t){let n=t.options.targetType,r=e.output,i=[];for(let{resource:a,selector:o,parent:s}of r){let r=a.type,c=new u.Vault;if((n===`Canvas`||n===`Annotation`||n===`ContentResource`)&&r===`Canvas`){let r=a.id,l=s?.type===`Manifest`?s.id:void 0;X(l,`Could not find Manifest`);let u=c.get({id:l,type:`Manifest`})||await c.loadManifest(l);X(u,`Manifest not found`);let d=u.items.find(e=>e.id===r);X(d,`Canvas not found`);let f=c.get(d);if(n===`Canvas`&&o?.type!==`BoxSelector`){let e=c.toPresentation3(f);e.label||(e.label={en:[`Untitled canvas`]}),console.log(`loading full canvas`,e),t.vault.loadSync(e.id,e),i.push(t.embed({id:e.id,type:`Canvas`}));continue}let p=c.get(f.items[0]),m=c.get(p.items[0]);if(n===`Annotation`||n===`Canvas`||n===`ContentResource`){let r=c.toPresentation3(m);r.id=t.generateId(`Annotation`);let a=null,s={width:0,height:0};if(r?.body?.service){let t=r?.body.width,n=r?.body.height;a=(0,v.getImageServices)(r?.body)[0],a&&(!a.width||!a.height)&&(a.width=t,a.height=n),s.width=t,s.height=n,e.trackSize&&e.trackSize(s)}if(o?.type===`BoxSelector`){let s={type:`ImageApiSelector`,region:[~~o.spatial.x,~~o.spatial.y,~~o.spatial.width,~~o.spatial.height].join(`,`)},c={...r.body},l=``;if(a){let e=a.id||a[`@id`]||``;e&&(c.id=fn(e,o.spatial,`max`),l=fn(e,o.spatial,`512,`))}if(r.body={id:t.generateId(`SpecificResource`,m),type:`SpecificResource`,source:c,selector:s},e.trackSize&&e.trackSize({width:~~o.spatial.width,height:~~o.spatial.height}),n===`ContentResource`){i.push(r.body);continue}if(n===`Canvas`){let e=t.generateId(`Canvas`,m);r.target=e;let n=t.generateId(`Page`,m),a=t.embed({id:n,type:`AnnotationPage`,items:[r]});i.push(t.embed({id:e,type:`Canvas`,label:{en:[`Untitled canvas`]},width:~~o.spatial.width,height:~~o.spatial.height,thumbnail:l?[t.embed({id:l,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(o.spatial.height/o.spatial.width*512)})]:void 0,items:[a]}));continue}i.push(t.embed({...r,target:t.getTarget()}));continue}i.push(t.embed({...c.toPresentation3(m),target:t.getTarget()}))}}}return i}const mn=(0,p.lazy)(()=>Promise.resolve().then(()=>require(`./iiif-browser-form.lazy-3ZdoCwGA.cjs`))),hn=(0,l.defineCreator)({id:`@manifest-editor/iiif-browser-creator`,create:pn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,m.jsx)(d.IIIFBrowserIcon,{}),render(e){return(0,m.jsx)(mn,{...e})},hiddenModal:!0,tags:[`image`,`image-service`],resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[`Annotation`,`Canvas`],supports:{onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFields:[`body`,`items`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},sideEffects:[W,N,M],staticFields:{}}),gn=(0,l.defineCreator)({id:`@manifest-editor/image-service-creator`,create:Lt,label:`Image Service`,summary:`Add an image from Image Service`,icon:(0,m.jsx)(d.IIIFLogo,{style:{padding:10}}),render(e){return(0,m.jsx)(K,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`height`,`width`,`format`,`service`],supports:{parentFields:[`logo`,`body`,`thumbnail`]}}),Z=(0,l.defineCreator)({id:`@manifest-editor/image-url-creator`,create:Vt,label:`Image`,summary:`Image from a URL`,icon:(0,m.jsx)(d.AddImageIcon,{}),render(e){return(0,m.jsx)(q,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}}),_n=(0,l.defineCreator)({id:`@manifest-editor/image-url-list`,label:`Image URL List`,summary:`Image from a list of URLs`,create:Gt,icon:(0,m.jsx)(d.ImageListIcon,{}),render(e){return(0,m.jsx)(J,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}});async function vn(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/plain`})}function yn(e){let[t,n]=(0,p.useState)({en:[`View as text`]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault();let r=new FormData(n.target),i=Object.fromEntries(r.entries());i.url&&e.runCreate({url:i.url,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to plaintext`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const bn=(0,l.defineCreator)({id:`@manifest-editor/plaintext-creator`,create:vn,label:`Plaintext`,summary:`Add link to an plaintext`,icon:(0,m.jsx)(cn,{}),render(e){return(0,m.jsx)(yn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]},staticFields:{format:`text/plain`}});function xn(e,t){e[`@id`]&&(e.id=e[`@id`]),e[`@type`]&&(e.type=e[`@type`]);let n=(0,v.createImageServiceRequest)(e);return(0,v.imageServiceRequestToString)({identifier:n.identifier,server:n.server,scheme:n.scheme,type:`image`,size:{max:!1,confined:!1,upscaled:!1,width:t.width,height:t.height},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:n.prefix,originalPath:n.originalPath})}function Q(e){return e.endsWith(`default.jpg`)?(0,v.imageServiceRequestToString)({...(0,v.parseImageServiceRequest)(e),type:`info`}):(0,v.canonicalServiceUrl)(e)}async function Sn(e,t){let n={...e.service},r=n.sizes;if(n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]),e.thumbnailUrl)return t.embed({id:e.thumbnailUrl,type:`Image`,format:`image/jpeg`,width:e.width,height:e.height});if(r){let i=e.width||400,a=null;for(let e of r)(!a||Math.abs(e.width-i)<Math.abs(a.width-i))&&(a={width:e.width,height:e.height});if(a){let e=xn(n,a);return t.embed({id:e,type:`Image`,format:`image/jpeg`,width:a.width,height:a.height})}}return null}function Cn(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(null),[a,o]=(0,p.useState)({width:0,height:0}),s=(0,p.useMemo)(()=>!r||!a.width||!a.height?null:xn(r,a),[a,r]);return r?(0,m.jsxs)(d.PaddedSidebarContainer,{children:[(0,m.jsxs)(`div`,{className:`mb-4`,children:[(0,m.jsx)(`div`,{className:`mb-2`,children:r[`@id`]||r.id}),(0,m.jsx)(`div`,{className:`flex gap-2 mb-4`,children:r.sizes?.map(e=>{let t=e.width===a.width;return(0,m.jsxs)(d.ActionButton,{primary:t,isDisabled:t,large:!0,onPress:()=>o(e),children:[e.width,`x`,e.height]},e.width)})}),s?(0,m.jsx)(`img`,{src:s,alt:`preview of selected resource`}):null]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,isDisabled:!s,onPress:()=>{r&&e.runCreate({service:r,width:a.width,height:a.height})},children:`Add thumbnail`})]}):(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.target),n=Object.fromEntries(t.entries()).url;if(n){let e=Q(n);if(!e)throw Error(`Invalid image service request`);fetch(e).then(e=>e.json()).then(e=>{i(e);let t=e.sizes?.[0];t&&o(t)})}},children:[(0,m.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?Q(t):``)},onBlur:e=>n(e.currentTarget.value?Q(e.currentTarget.value):``)})]})}),(0,m.jsx)(`div`,{children:(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Select size`})})]})})}const wn=(0,l.defineCreator)({id:`@manifest-editor/thumbnail-image`,create:Sn,label:`Thumbnail from service`,summary:`Add thumbnail from an image service`,icon:(0,m.jsx)(d.ScaledImageIcon,{}),render(e){return(0,m.jsx)(Cn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`format`],supports:{parentFields:[`thumbnail`]}});function Tn(){return(0,m.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{d:`M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z`})]})}async function En(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/html`})}function Dn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault();let r=new FormData(n.target),i=Object.fromEntries(r.entries());i.url&&e.runCreate({url:i.url,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create link`})]})})}const On=(0,l.defineCreator)({id:`@manifest-editor/web-page-creator`,create:En,label:`Web page`,summary:`Add link to an external web page`,icon:(0,m.jsx)(Tn,{}),render(e){return(0,m.jsx)(Dn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]}}),kn=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function $(e){let t=(e||``).match(kn);return t?t[1]:null}function An(e){return!!$(e.youtubeUrl)}async function jn(e,t){let n=$(e.youtubeUrl),r=t.embed({id:`https://www.youtube.com/watch?v=${n}`,type:`Video`,service:[{profile:`http://digirati.com/objectifier`,params:{data:`https://www.youtube.com/embed/${n}`}},{id:`https://www.youtube.com/watch?v=${n}`,profile:`https://www.youtube.com`}]});if(t.options.targetType===`Canvas`){let n=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[r],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]});return t.embed({id:n,type:`Canvas`,label:e.label||{en:[`Untitled YouTube canvas`]},height:e.height||1e3,width:e.width||1e3,duration:e.duration||1,items:[o]})}return t.options.targetType===`Annotation`?t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[r],target:t.getTarget()}):r}function Mn(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.youtubeUrl&&e.runCreate({youtubeUrl:r.youtubeUrl})},children:[(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to YouTube`}),(0,m.jsx)(f.Input,{id:`youtubeUrl`,name:`youtubeUrl`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Nn=(0,l.defineCreator)({id:`@manifest-editor/youtube`,create:jn,label:`YouTube`,summary:`Embed YouTube`,icon:(0,m.jsx)(d.YouTubeIcon,{}),resourceType:`ContentResource`,additionalTypes:[`Canvas`,`Annotation`],resourceFields:[`id`,`type`,`service`],render:e=>(0,m.jsx)(Mn,{...e}),supports:{onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},staticFields:{type:`Video`}});async function Pn(e,t){let n=e.output||[],r=[];for(let e of n){let{resource:n,parent:i,selector:a}=e,o=t.getPreviewVault(),s=(0,u.createThumbnailHelper)(o);if(n.type===`Manifest`){let e=n.id;X(e,`Could not find Manifest ID`);let i=await o.loadManifest(e),a=await s.getBestThumbnailAtSize(i,{width:256,height:256},!1);X(i,`Manifest not found`),r.push(t.embed({id:n.id,type:`Manifest`,label:i.label,summary:i.summary,thumbnail:a?.best?[{id:a.best.id,type:`Image`}]:void 0}));continue}if(n.type===`Collection`){let e=n.id;X(e,`Could not find Manifest ID`);let i=await o.loadManifest(e);X(i,`Collection not found`),r.push(t.embed({id:n.id,type:`Collection`,label:i.label}))}}return r}const Fn=(0,p.lazy)(()=>Promise.resolve().then(()=>require(`./manifest-browser-form.lazy-DnIXlrw4.cjs`))),In=(0,l.defineCreator)({id:`@manifest-editor/manifest-browser-creator`,create:Pn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,m.jsx)(d.IIIFBrowserIcon,{}),render(e){return(0,m.jsx)(c.t,{...e})},resourceType:`Manifest`,resourceFields:[`id`,`label`],additionalTypes:[`Collection`],supports:{parentTypes:[`Collection`],parentFieldMap:{Collection:[`items`]}},sideEffects:[],staticFields:{}});async function Ln(e,t,n){let r=t.generateId(`range`,n?{id:n,type:`Range`}:void 0);return t.embed({id:r,type:`Range`,label:e.label||{en:[`Untitled range`]},items:e.items||[]})}function Rn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const zn=(0,l.defineCreator)({id:`@manifest-editor/range-with-items`,create:Ln,label:`Range`,summary:`Add a new range`,icon:(0,m.jsx)(d.RangesIcon,{}),render(e){return(0,m.jsx)(Rn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Range`],parentFields:[`items`]},staticFields:{type:`Range`}});async function Bn(e,t,n){let r=t.generateId(`range`,n?{id:n,type:`Range`}:void 0);return t.embed({id:r,type:`Range`,label:e.label||{en:[`Table of Contents`]},items:(e.items||[]).map(e=>t.ref(e))})}function Vn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Hn=(0,l.defineCreator)({id:`@manifest-editor/range-top-level`,create:Bn,label:`Top Level Range`,summary:`Add a new top level range`,icon:(0,m.jsx)(d.RangesIcon,{}),render(e){return(0,m.jsx)(Vn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Manifest`],parentFields:[`structures`]},staticFields:{type:`Range`}}),Un=[gn,Bt,Z,Wt,$t,T,dn,j,Nn,hn,nn,bn,On,tn,Jt,an,O,_n,qt,wn,Hn,zn,ne];exports.CreateAudioAnnotationForm=w,exports.CreateCaptionedImageAnnotation=D,exports.CreateHTMLAnnotation=A,exports.CreateHTMLBodyForm=un,exports.CreateImageServerForm=K,exports.CreateImageServiceAnnotationForm=zt,exports.CreateImageUrlAnnotationForm=Ut,exports.CreateImageUrlForm=q,exports.CreateImageUrlListForm=J,exports.CreatePlaintextForm=yn,exports.CreateProviderForm=x,exports.CreateThumbnailForm=Cn,exports.CreateVideoAnnotationForm=Qt,exports.CreateWebPageForm=Dn,exports.IIIFBrowserCreatorForm=mn,exports.ManifestBrowserCreatorForm=Fn,exports.RangeWithItemsCreatorForm=Rn,exports.TopLevelRangeCreatorForm=Vn,exports.YouTubeForm=Mn,exports.allCreators=Un,exports.audioAnnotation=T,exports.captionedImageAnnotation=O,exports.createAudioAnnotation=C,exports.createCaptionedImageAnnotation=E,exports.createFromIIIFBrowserOutput=pn,exports.createFromManifestBrowserOutput=Pn,exports.createHtmlAnnotation=k,exports.createHtmlBody=ln,exports.createImageServer=Lt,exports.createImageServiceAnnotation=Rt,exports.createImageUrl=Vt,exports.createImageUrlAnnotation=Ht,exports.createImageUrlList=Gt,exports.createImageUrlListAnnotation=Kt,exports.createNoBodyAnnotation=Yt,exports.createPlaintext=vn,exports.createProvider=b,exports.createRangeTopLevel=Bn,exports.createRangeWithItems=Ln,exports.createThumbnail=Sn,exports.createVideoAnnotation=Zt,exports.createWebPage=En,exports.createYoutubeBody=jn,exports.emptyAnnotationPage=tn,exports.emptyCanvas=nn,exports.getYouTubeId=$,exports.htmlAnnotation=j,exports.htmlBodyCreator=dn,exports.iiifBrowserCreator=hn,exports.imageServiceAnnotation=Bt,exports.imageServiceCreator=gn,exports.imageUrlAnnotation=Wt,exports.imageUrlCreator=Z,exports.imageUrlListAnnotation=qt,exports.imageUrlListCreator=_n,exports.internalCanvas=an,exports.manifestBrowserCreator=In,exports.noBodyAnnotation=Jt,exports.plaintextCreator=bn,exports.providerCreator=ne,exports.rangeTopLevel=Hn,exports.rangeWithItems=zn,exports.t=s,exports.validateYouTube=An,exports.videoAnnotation=$t,exports.webPageCreator=On,exports.youTubeBodyCreator=Nn;