@gramps-connect/story 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -2
- package/dist/editor.js +3539 -0
- package/dist/editor.js.map +7 -0
- package/dist/embed.js +43 -43
- package/dist/player.js +74 -13
- package/dist/player.js.map +2 -2
- package/dist/types/editor/DateField.d.ts +12 -0
- package/dist/types/editor/SlideList.d.ts +12 -0
- package/dist/types/editor/StoryEditor.d.ts +28 -0
- package/dist/types/editor/StoryTextField.d.ts +9 -0
- package/dist/types/editor/dates.d.ts +6 -0
- package/dist/types/editor/index.d.ts +7 -0
- package/dist/types/editor/model.d.ts +55 -0
- package/dist/types/editor/strings.d.ts +40 -0
- package/dist/types/player/MapBackground.d.ts +4 -0
- package/dist/types/player/StoryPlayer.d.ts +4 -1
- package/dist/types/player/geo.d.ts +8 -0
- package/package.json +21 -5
- package/src/editor/DateField.tsx +95 -0
- package/src/editor/SlideList.tsx +54 -0
- package/src/editor/StoryEditor.tsx +333 -0
- package/src/editor/StoryTextField.tsx +61 -0
- package/src/editor/dates.ts +21 -0
- package/src/editor/index.ts +10 -0
- package/src/editor/model.ts +167 -0
- package/src/editor/strings.ts +82 -0
- package/src/player/MapBackground.tsx +49 -18
- package/src/player/StoryPlayer.tsx +22 -3
- package/src/player/geo.ts +22 -0
package/dist/editor.js
ADDED
|
@@ -0,0 +1,3539 @@
|
|
|
1
|
+
// src/editor/StoryEditor.tsx
|
|
2
|
+
import { useCallback, useEffect as useEffect5, useMemo as useMemo2, useState as useState6 } from "react";
|
|
3
|
+
import {
|
|
4
|
+
ActionIcon,
|
|
5
|
+
Badge,
|
|
6
|
+
Box,
|
|
7
|
+
Button as Button2,
|
|
8
|
+
Divider,
|
|
9
|
+
Group as Group3,
|
|
10
|
+
Modal,
|
|
11
|
+
Popover,
|
|
12
|
+
Select,
|
|
13
|
+
Stack as Stack4,
|
|
14
|
+
Text as Text3,
|
|
15
|
+
TextInput as TextInput2,
|
|
16
|
+
Tooltip,
|
|
17
|
+
UnstyledButton as UnstyledButton2
|
|
18
|
+
} from "@mantine/core";
|
|
19
|
+
import { useMediaQuery } from "@mantine/hooks";
|
|
20
|
+
|
|
21
|
+
// spec/1.0/story.schema.json
|
|
22
|
+
var story_schema_default = {
|
|
23
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
24
|
+
$id: "https://dsblank.github.io/gramps-connect-stories/spec/1.0/story.schema.json",
|
|
25
|
+
title: "Gramps Connect Story, format 1.0",
|
|
26
|
+
description: "The story.json at the root of a .story.zip. See spec/1.0/README.md for the rules this schema can't express (every ref resolves, every src exists in the zip, unknown fields are ignored).",
|
|
27
|
+
type: "object",
|
|
28
|
+
required: ["format", "version", "title", "slides", "media"],
|
|
29
|
+
properties: {
|
|
30
|
+
$schema: { type: "string" },
|
|
31
|
+
format: { const: "gramps-connect-story" },
|
|
32
|
+
version: {
|
|
33
|
+
description: "MAJOR.MINOR. This schema validates any 1.x file: newer minor versions only add optional fields.",
|
|
34
|
+
type: "string",
|
|
35
|
+
pattern: "^1\\.(0|[1-9][0-9]*)$"
|
|
36
|
+
},
|
|
37
|
+
title: { type: "string", pattern: "\\S" },
|
|
38
|
+
language: {
|
|
39
|
+
description: `BCP 47 language tag of the story's text, e.g. "en", "de-CH".`,
|
|
40
|
+
type: "string",
|
|
41
|
+
pattern: "^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$"
|
|
42
|
+
},
|
|
43
|
+
created: {
|
|
44
|
+
description: "When the file was written, as an RFC 3339 date-time.",
|
|
45
|
+
type: "string",
|
|
46
|
+
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$"
|
|
47
|
+
},
|
|
48
|
+
generator: {
|
|
49
|
+
type: "object",
|
|
50
|
+
required: ["name"],
|
|
51
|
+
properties: {
|
|
52
|
+
name: { type: "string", pattern: "\\S" },
|
|
53
|
+
version: { type: "string" },
|
|
54
|
+
url: { type: "string" }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
authors: {
|
|
58
|
+
type: "array",
|
|
59
|
+
items: {
|
|
60
|
+
type: "object",
|
|
61
|
+
required: ["name"],
|
|
62
|
+
properties: {
|
|
63
|
+
name: { type: "string", pattern: "\\S" },
|
|
64
|
+
url: { type: "string" }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
license: {
|
|
69
|
+
description: "License of the story's content (text and media), as an SPDX identifier or free text.",
|
|
70
|
+
type: "string"
|
|
71
|
+
},
|
|
72
|
+
presentation: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
basemap: { enum: ["standard", "historical", "auto", "none"] }
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
slides: {
|
|
79
|
+
type: "array",
|
|
80
|
+
minItems: 1,
|
|
81
|
+
items: { $ref: "#/$defs/slide" }
|
|
82
|
+
},
|
|
83
|
+
media: {
|
|
84
|
+
description: "Every media file in the story, keyed by an id that slides and overlays refer to.",
|
|
85
|
+
type: "object",
|
|
86
|
+
propertyNames: { $ref: "#/$defs/id" },
|
|
87
|
+
additionalProperties: { $ref: "#/$defs/mediaItem" }
|
|
88
|
+
},
|
|
89
|
+
extensions: {
|
|
90
|
+
description: "Producer-specific data, keyed by namespace. Viewers ignore it.",
|
|
91
|
+
type: "object",
|
|
92
|
+
additionalProperties: { type: "object" }
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
$defs: {
|
|
96
|
+
id: {
|
|
97
|
+
type: "string",
|
|
98
|
+
pattern: "^[A-Za-z0-9_-]{1,64}$"
|
|
99
|
+
},
|
|
100
|
+
storyDate: {
|
|
101
|
+
type: "object",
|
|
102
|
+
required: ["text"],
|
|
103
|
+
properties: {
|
|
104
|
+
text: {
|
|
105
|
+
description: "The date as it should be shown, in the story's language.",
|
|
106
|
+
type: "string",
|
|
107
|
+
pattern: "\\S"
|
|
108
|
+
},
|
|
109
|
+
edtf: {
|
|
110
|
+
description: "Optional machine-readable form, in Extended Date/Time Format (ISO 8601-2).",
|
|
111
|
+
type: "string",
|
|
112
|
+
pattern: "\\S"
|
|
113
|
+
},
|
|
114
|
+
sortYear: {
|
|
115
|
+
description: "Optional year (proleptic Gregorian) that places the slide on the timeline.",
|
|
116
|
+
type: "integer"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
slide: {
|
|
121
|
+
type: "object",
|
|
122
|
+
required: ["id"],
|
|
123
|
+
properties: {
|
|
124
|
+
id: { $ref: "#/$defs/id" },
|
|
125
|
+
title: { type: "string" },
|
|
126
|
+
text: {
|
|
127
|
+
description: "Body text. Markup: **bold**, *italic*, line breaks. Nothing else is interpreted.",
|
|
128
|
+
type: "string"
|
|
129
|
+
},
|
|
130
|
+
date: { $ref: "#/$defs/storyDate" },
|
|
131
|
+
place: { $ref: "#/$defs/place" },
|
|
132
|
+
media: {
|
|
133
|
+
type: "array",
|
|
134
|
+
items: { $ref: "#/$defs/slideMedia" }
|
|
135
|
+
},
|
|
136
|
+
people: {
|
|
137
|
+
type: "array",
|
|
138
|
+
items: {
|
|
139
|
+
type: "object",
|
|
140
|
+
required: ["name"],
|
|
141
|
+
properties: {
|
|
142
|
+
name: { type: "string", pattern: "\\S" },
|
|
143
|
+
role: { type: "string" }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
slideMedia: {
|
|
150
|
+
type: "object",
|
|
151
|
+
required: ["ref"],
|
|
152
|
+
properties: {
|
|
153
|
+
ref: { $ref: "#/$defs/id" },
|
|
154
|
+
caption: { type: "string" },
|
|
155
|
+
credit: { type: "string" }
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
place: {
|
|
159
|
+
type: "object",
|
|
160
|
+
properties: {
|
|
161
|
+
name: { type: "string" },
|
|
162
|
+
lat: { type: "number", minimum: -90, maximum: 90 },
|
|
163
|
+
lon: { type: "number", minimum: -180, maximum: 180 },
|
|
164
|
+
geometry: {
|
|
165
|
+
description: "Optional GeoJSON (RFC 7946) object drawn under the slide's pin: a FeatureCollection, Feature, or bare geometry.",
|
|
166
|
+
type: "object",
|
|
167
|
+
required: ["type"],
|
|
168
|
+
properties: { type: { type: "string" } },
|
|
169
|
+
additionalProperties: true
|
|
170
|
+
},
|
|
171
|
+
overlays: {
|
|
172
|
+
type: "array",
|
|
173
|
+
items: { $ref: "#/$defs/overlay" }
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
dependentRequired: {
|
|
177
|
+
lat: ["lon"],
|
|
178
|
+
lon: ["lat"]
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
lonLat: {
|
|
182
|
+
type: "array",
|
|
183
|
+
prefixItems: [
|
|
184
|
+
{ type: "number", minimum: -180, maximum: 180 },
|
|
185
|
+
{ type: "number", minimum: -90, maximum: 90 }
|
|
186
|
+
],
|
|
187
|
+
minItems: 2,
|
|
188
|
+
maxItems: 2
|
|
189
|
+
},
|
|
190
|
+
overlay: {
|
|
191
|
+
type: "object",
|
|
192
|
+
required: ["media", "corners"],
|
|
193
|
+
properties: {
|
|
194
|
+
media: { $ref: "#/$defs/id" },
|
|
195
|
+
corners: {
|
|
196
|
+
description: "[lon, lat] of the image's top-left, top-right, bottom-right and bottom-left corners.",
|
|
197
|
+
type: "array",
|
|
198
|
+
items: { $ref: "#/$defs/lonLat" },
|
|
199
|
+
minItems: 4,
|
|
200
|
+
maxItems: 4
|
|
201
|
+
},
|
|
202
|
+
opacity: { type: "number", minimum: 0, maximum: 1 },
|
|
203
|
+
order: {
|
|
204
|
+
description: "Stacking order among a slide's overlays; lower is drawn first.",
|
|
205
|
+
type: "integer"
|
|
206
|
+
},
|
|
207
|
+
date: { $ref: "#/$defs/storyDate" }
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
mediaItem: {
|
|
211
|
+
type: "object",
|
|
212
|
+
required: ["src", "mime"],
|
|
213
|
+
properties: {
|
|
214
|
+
src: {
|
|
215
|
+
description: 'Path of the file inside the zip, relative to its root. No leading slash, no ".." segments.',
|
|
216
|
+
type: "string",
|
|
217
|
+
pattern: "^(?!/)(?!.*(^|/)\\.\\.?(/|$))[^\\\\]+$"
|
|
218
|
+
},
|
|
219
|
+
mime: {
|
|
220
|
+
type: "string",
|
|
221
|
+
pattern: "^[a-z]+/[A-Za-z0-9.+-]+$"
|
|
222
|
+
},
|
|
223
|
+
width: { type: "integer", minimum: 1 },
|
|
224
|
+
height: { type: "integer", minimum: 1 },
|
|
225
|
+
alt: { type: "string" }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/generated/schemaValidator.js
|
|
232
|
+
var validate = validate20;
|
|
233
|
+
var schema31 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://dsblank.github.io/gramps-connect-stories/spec/1.0/story.schema.json", "title": "Gramps Connect Story, format 1.0", "description": "The story.json at the root of a .story.zip. See spec/1.0/README.md for the rules this schema can't express (every ref resolves, every src exists in the zip, unknown fields are ignored).", "type": "object", "required": ["format", "version", "title", "slides", "media"], "properties": { "$schema": { "type": "string" }, "format": { "const": "gramps-connect-story" }, "version": { "description": "MAJOR.MINOR. This schema validates any 1.x file: newer minor versions only add optional fields.", "type": "string", "pattern": "^1\\.(0|[1-9][0-9]*)$" }, "title": { "type": "string", "pattern": "\\S" }, "language": { "description": `BCP 47 language tag of the story's text, e.g. "en", "de-CH".`, "type": "string", "pattern": "^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$" }, "created": { "description": "When the file was written, as an RFC 3339 date-time.", "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$" }, "generator": { "type": "object", "required": ["name"], "properties": { "name": { "type": "string", "pattern": "\\S" }, "version": { "type": "string" }, "url": { "type": "string" } } }, "authors": { "type": "array", "items": { "type": "object", "required": ["name"], "properties": { "name": { "type": "string", "pattern": "\\S" }, "url": { "type": "string" } } } }, "license": { "description": "License of the story's content (text and media), as an SPDX identifier or free text.", "type": "string" }, "presentation": { "type": "object", "properties": { "basemap": { "enum": ["standard", "historical", "auto", "none"] } } }, "slides": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/slide" } }, "media": { "description": "Every media file in the story, keyed by an id that slides and overlays refer to.", "type": "object", "propertyNames": { "$ref": "#/$defs/id" }, "additionalProperties": { "$ref": "#/$defs/mediaItem" } }, "extensions": { "description": "Producer-specific data, keyed by namespace. Viewers ignore it.", "type": "object", "additionalProperties": { "type": "object" } } }, "$defs": { "id": { "type": "string", "pattern": "^[A-Za-z0-9_-]{1,64}$" }, "storyDate": { "type": "object", "required": ["text"], "properties": { "text": { "description": "The date as it should be shown, in the story's language.", "type": "string", "pattern": "\\S" }, "edtf": { "description": "Optional machine-readable form, in Extended Date/Time Format (ISO 8601-2).", "type": "string", "pattern": "\\S" }, "sortYear": { "description": "Optional year (proleptic Gregorian) that places the slide on the timeline.", "type": "integer" } } }, "slide": { "type": "object", "required": ["id"], "properties": { "id": { "$ref": "#/$defs/id" }, "title": { "type": "string" }, "text": { "description": "Body text. Markup: **bold**, *italic*, line breaks. Nothing else is interpreted.", "type": "string" }, "date": { "$ref": "#/$defs/storyDate" }, "place": { "$ref": "#/$defs/place" }, "media": { "type": "array", "items": { "$ref": "#/$defs/slideMedia" } }, "people": { "type": "array", "items": { "type": "object", "required": ["name"], "properties": { "name": { "type": "string", "pattern": "\\S" }, "role": { "type": "string" } } } } } }, "slideMedia": { "type": "object", "required": ["ref"], "properties": { "ref": { "$ref": "#/$defs/id" }, "caption": { "type": "string" }, "credit": { "type": "string" } } }, "place": { "type": "object", "properties": { "name": { "type": "string" }, "lat": { "type": "number", "minimum": -90, "maximum": 90 }, "lon": { "type": "number", "minimum": -180, "maximum": 180 }, "geometry": { "description": "Optional GeoJSON (RFC 7946) object drawn under the slide's pin: a FeatureCollection, Feature, or bare geometry.", "type": "object", "required": ["type"], "properties": { "type": { "type": "string" } }, "additionalProperties": true }, "overlays": { "type": "array", "items": { "$ref": "#/$defs/overlay" } } }, "dependentRequired": { "lat": ["lon"], "lon": ["lat"] } }, "lonLat": { "type": "array", "prefixItems": [{ "type": "number", "minimum": -180, "maximum": 180 }, { "type": "number", "minimum": -90, "maximum": 90 }], "minItems": 2, "maxItems": 2 }, "overlay": { "type": "object", "required": ["media", "corners"], "properties": { "media": { "$ref": "#/$defs/id" }, "corners": { "description": "[lon, lat] of the image's top-left, top-right, bottom-right and bottom-left corners.", "type": "array", "items": { "$ref": "#/$defs/lonLat" }, "minItems": 4, "maxItems": 4 }, "opacity": { "type": "number", "minimum": 0, "maximum": 1 }, "order": { "description": "Stacking order among a slide's overlays; lower is drawn first.", "type": "integer" }, "date": { "$ref": "#/$defs/storyDate" } } }, "mediaItem": { "type": "object", "required": ["src", "mime"], "properties": { "src": { "description": 'Path of the file inside the zip, relative to its root. No leading slash, no ".." segments.', "type": "string", "pattern": "^(?!/)(?!.*(^|/)\\.\\.?(/|$))[^\\\\]+$" }, "mime": { "type": "string", "pattern": "^[a-z]+/[A-Za-z0-9.+-]+$" }, "width": { "type": "integer", "minimum": 1 }, "height": { "type": "integer", "minimum": 1 }, "alt": { "type": "string" } } } } };
|
|
234
|
+
var pattern4 = new RegExp("^1\\.(0|[1-9][0-9]*)$", "u");
|
|
235
|
+
var pattern5 = new RegExp("\\S", "u");
|
|
236
|
+
var pattern6 = new RegExp("^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$", "u");
|
|
237
|
+
var pattern7 = new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$", "u");
|
|
238
|
+
var pattern10 = new RegExp("^[A-Za-z0-9_-]{1,64}$", "u");
|
|
239
|
+
var pattern19 = new RegExp("^(?!/)(?!.*(^|/)\\.\\.?(/|$))[^\\\\]+$", "u");
|
|
240
|
+
var pattern20 = new RegExp("^[a-z]+/[A-Za-z0-9.+-]+$", "u");
|
|
241
|
+
function validate23(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
242
|
+
let vErrors = null;
|
|
243
|
+
let errors = 0;
|
|
244
|
+
const evaluated0 = validate23.evaluated;
|
|
245
|
+
if (evaluated0.dynamicProps) {
|
|
246
|
+
evaluated0.props = void 0;
|
|
247
|
+
}
|
|
248
|
+
if (evaluated0.dynamicItems) {
|
|
249
|
+
evaluated0.items = void 0;
|
|
250
|
+
}
|
|
251
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
252
|
+
if (data.media === void 0) {
|
|
253
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "media" }, message: "must have required property 'media'" };
|
|
254
|
+
if (vErrors === null) {
|
|
255
|
+
vErrors = [err0];
|
|
256
|
+
} else {
|
|
257
|
+
vErrors.push(err0);
|
|
258
|
+
}
|
|
259
|
+
errors++;
|
|
260
|
+
}
|
|
261
|
+
if (data.corners === void 0) {
|
|
262
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "corners" }, message: "must have required property 'corners'" };
|
|
263
|
+
if (vErrors === null) {
|
|
264
|
+
vErrors = [err1];
|
|
265
|
+
} else {
|
|
266
|
+
vErrors.push(err1);
|
|
267
|
+
}
|
|
268
|
+
errors++;
|
|
269
|
+
}
|
|
270
|
+
if (data.media !== void 0) {
|
|
271
|
+
let data0 = data.media;
|
|
272
|
+
if (typeof data0 === "string") {
|
|
273
|
+
if (!pattern10.test(data0)) {
|
|
274
|
+
const err2 = { instancePath: instancePath + "/media", schemaPath: "#/$defs/id/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]{1,64}$" }, message: 'must match pattern "^[A-Za-z0-9_-]{1,64}$"' };
|
|
275
|
+
if (vErrors === null) {
|
|
276
|
+
vErrors = [err2];
|
|
277
|
+
} else {
|
|
278
|
+
vErrors.push(err2);
|
|
279
|
+
}
|
|
280
|
+
errors++;
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
const err3 = { instancePath: instancePath + "/media", schemaPath: "#/$defs/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
284
|
+
if (vErrors === null) {
|
|
285
|
+
vErrors = [err3];
|
|
286
|
+
} else {
|
|
287
|
+
vErrors.push(err3);
|
|
288
|
+
}
|
|
289
|
+
errors++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (data.corners !== void 0) {
|
|
293
|
+
let data1 = data.corners;
|
|
294
|
+
if (Array.isArray(data1)) {
|
|
295
|
+
if (data1.length > 4) {
|
|
296
|
+
const err4 = { instancePath: instancePath + "/corners", schemaPath: "#/properties/corners/maxItems", keyword: "maxItems", params: { limit: 4 }, message: "must NOT have more than 4 items" };
|
|
297
|
+
if (vErrors === null) {
|
|
298
|
+
vErrors = [err4];
|
|
299
|
+
} else {
|
|
300
|
+
vErrors.push(err4);
|
|
301
|
+
}
|
|
302
|
+
errors++;
|
|
303
|
+
}
|
|
304
|
+
if (data1.length < 4) {
|
|
305
|
+
const err5 = { instancePath: instancePath + "/corners", schemaPath: "#/properties/corners/minItems", keyword: "minItems", params: { limit: 4 }, message: "must NOT have fewer than 4 items" };
|
|
306
|
+
if (vErrors === null) {
|
|
307
|
+
vErrors = [err5];
|
|
308
|
+
} else {
|
|
309
|
+
vErrors.push(err5);
|
|
310
|
+
}
|
|
311
|
+
errors++;
|
|
312
|
+
}
|
|
313
|
+
const len0 = data1.length;
|
|
314
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
315
|
+
let data2 = data1[i0];
|
|
316
|
+
if (Array.isArray(data2)) {
|
|
317
|
+
if (data2.length > 2) {
|
|
318
|
+
const err6 = { instancePath: instancePath + "/corners/" + i0, schemaPath: "#/$defs/lonLat/maxItems", keyword: "maxItems", params: { limit: 2 }, message: "must NOT have more than 2 items" };
|
|
319
|
+
if (vErrors === null) {
|
|
320
|
+
vErrors = [err6];
|
|
321
|
+
} else {
|
|
322
|
+
vErrors.push(err6);
|
|
323
|
+
}
|
|
324
|
+
errors++;
|
|
325
|
+
}
|
|
326
|
+
if (data2.length < 2) {
|
|
327
|
+
const err7 = { instancePath: instancePath + "/corners/" + i0, schemaPath: "#/$defs/lonLat/minItems", keyword: "minItems", params: { limit: 2 }, message: "must NOT have fewer than 2 items" };
|
|
328
|
+
if (vErrors === null) {
|
|
329
|
+
vErrors = [err7];
|
|
330
|
+
} else {
|
|
331
|
+
vErrors.push(err7);
|
|
332
|
+
}
|
|
333
|
+
errors++;
|
|
334
|
+
}
|
|
335
|
+
const len1 = data2.length;
|
|
336
|
+
if (len1 > 0) {
|
|
337
|
+
let data3 = data2[0];
|
|
338
|
+
if (typeof data3 == "number" && isFinite(data3)) {
|
|
339
|
+
if (data3 > 180 || isNaN(data3)) {
|
|
340
|
+
const err8 = { instancePath: instancePath + "/corners/" + i0 + "/0", schemaPath: "#/$defs/lonLat/prefixItems/0/maximum", keyword: "maximum", params: { comparison: "<=", limit: 180 }, message: "must be <= 180" };
|
|
341
|
+
if (vErrors === null) {
|
|
342
|
+
vErrors = [err8];
|
|
343
|
+
} else {
|
|
344
|
+
vErrors.push(err8);
|
|
345
|
+
}
|
|
346
|
+
errors++;
|
|
347
|
+
}
|
|
348
|
+
if (data3 < -180 || isNaN(data3)) {
|
|
349
|
+
const err9 = { instancePath: instancePath + "/corners/" + i0 + "/0", schemaPath: "#/$defs/lonLat/prefixItems/0/minimum", keyword: "minimum", params: { comparison: ">=", limit: -180 }, message: "must be >= -180" };
|
|
350
|
+
if (vErrors === null) {
|
|
351
|
+
vErrors = [err9];
|
|
352
|
+
} else {
|
|
353
|
+
vErrors.push(err9);
|
|
354
|
+
}
|
|
355
|
+
errors++;
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
const err10 = { instancePath: instancePath + "/corners/" + i0 + "/0", schemaPath: "#/$defs/lonLat/prefixItems/0/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
359
|
+
if (vErrors === null) {
|
|
360
|
+
vErrors = [err10];
|
|
361
|
+
} else {
|
|
362
|
+
vErrors.push(err10);
|
|
363
|
+
}
|
|
364
|
+
errors++;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (len1 > 1) {
|
|
368
|
+
let data4 = data2[1];
|
|
369
|
+
if (typeof data4 == "number" && isFinite(data4)) {
|
|
370
|
+
if (data4 > 90 || isNaN(data4)) {
|
|
371
|
+
const err11 = { instancePath: instancePath + "/corners/" + i0 + "/1", schemaPath: "#/$defs/lonLat/prefixItems/1/maximum", keyword: "maximum", params: { comparison: "<=", limit: 90 }, message: "must be <= 90" };
|
|
372
|
+
if (vErrors === null) {
|
|
373
|
+
vErrors = [err11];
|
|
374
|
+
} else {
|
|
375
|
+
vErrors.push(err11);
|
|
376
|
+
}
|
|
377
|
+
errors++;
|
|
378
|
+
}
|
|
379
|
+
if (data4 < -90 || isNaN(data4)) {
|
|
380
|
+
const err12 = { instancePath: instancePath + "/corners/" + i0 + "/1", schemaPath: "#/$defs/lonLat/prefixItems/1/minimum", keyword: "minimum", params: { comparison: ">=", limit: -90 }, message: "must be >= -90" };
|
|
381
|
+
if (vErrors === null) {
|
|
382
|
+
vErrors = [err12];
|
|
383
|
+
} else {
|
|
384
|
+
vErrors.push(err12);
|
|
385
|
+
}
|
|
386
|
+
errors++;
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
const err13 = { instancePath: instancePath + "/corners/" + i0 + "/1", schemaPath: "#/$defs/lonLat/prefixItems/1/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
390
|
+
if (vErrors === null) {
|
|
391
|
+
vErrors = [err13];
|
|
392
|
+
} else {
|
|
393
|
+
vErrors.push(err13);
|
|
394
|
+
}
|
|
395
|
+
errors++;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
const err14 = { instancePath: instancePath + "/corners/" + i0, schemaPath: "#/$defs/lonLat/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
400
|
+
if (vErrors === null) {
|
|
401
|
+
vErrors = [err14];
|
|
402
|
+
} else {
|
|
403
|
+
vErrors.push(err14);
|
|
404
|
+
}
|
|
405
|
+
errors++;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
const err15 = { instancePath: instancePath + "/corners", schemaPath: "#/properties/corners/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
410
|
+
if (vErrors === null) {
|
|
411
|
+
vErrors = [err15];
|
|
412
|
+
} else {
|
|
413
|
+
vErrors.push(err15);
|
|
414
|
+
}
|
|
415
|
+
errors++;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (data.opacity !== void 0) {
|
|
419
|
+
let data5 = data.opacity;
|
|
420
|
+
if (typeof data5 == "number" && isFinite(data5)) {
|
|
421
|
+
if (data5 > 1 || isNaN(data5)) {
|
|
422
|
+
const err16 = { instancePath: instancePath + "/opacity", schemaPath: "#/properties/opacity/maximum", keyword: "maximum", params: { comparison: "<=", limit: 1 }, message: "must be <= 1" };
|
|
423
|
+
if (vErrors === null) {
|
|
424
|
+
vErrors = [err16];
|
|
425
|
+
} else {
|
|
426
|
+
vErrors.push(err16);
|
|
427
|
+
}
|
|
428
|
+
errors++;
|
|
429
|
+
}
|
|
430
|
+
if (data5 < 0 || isNaN(data5)) {
|
|
431
|
+
const err17 = { instancePath: instancePath + "/opacity", schemaPath: "#/properties/opacity/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
432
|
+
if (vErrors === null) {
|
|
433
|
+
vErrors = [err17];
|
|
434
|
+
} else {
|
|
435
|
+
vErrors.push(err17);
|
|
436
|
+
}
|
|
437
|
+
errors++;
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
const err18 = { instancePath: instancePath + "/opacity", schemaPath: "#/properties/opacity/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
441
|
+
if (vErrors === null) {
|
|
442
|
+
vErrors = [err18];
|
|
443
|
+
} else {
|
|
444
|
+
vErrors.push(err18);
|
|
445
|
+
}
|
|
446
|
+
errors++;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (data.order !== void 0) {
|
|
450
|
+
let data6 = data.order;
|
|
451
|
+
if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) {
|
|
452
|
+
const err19 = { instancePath: instancePath + "/order", schemaPath: "#/properties/order/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
453
|
+
if (vErrors === null) {
|
|
454
|
+
vErrors = [err19];
|
|
455
|
+
} else {
|
|
456
|
+
vErrors.push(err19);
|
|
457
|
+
}
|
|
458
|
+
errors++;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (data.date !== void 0) {
|
|
462
|
+
let data7 = data.date;
|
|
463
|
+
if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
|
|
464
|
+
if (data7.text === void 0) {
|
|
465
|
+
const err20 = { instancePath: instancePath + "/date", schemaPath: "#/$defs/storyDate/required", keyword: "required", params: { missingProperty: "text" }, message: "must have required property 'text'" };
|
|
466
|
+
if (vErrors === null) {
|
|
467
|
+
vErrors = [err20];
|
|
468
|
+
} else {
|
|
469
|
+
vErrors.push(err20);
|
|
470
|
+
}
|
|
471
|
+
errors++;
|
|
472
|
+
}
|
|
473
|
+
if (data7.text !== void 0) {
|
|
474
|
+
let data8 = data7.text;
|
|
475
|
+
if (typeof data8 === "string") {
|
|
476
|
+
if (!pattern5.test(data8)) {
|
|
477
|
+
const err21 = { instancePath: instancePath + "/date/text", schemaPath: "#/$defs/storyDate/properties/text/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
478
|
+
if (vErrors === null) {
|
|
479
|
+
vErrors = [err21];
|
|
480
|
+
} else {
|
|
481
|
+
vErrors.push(err21);
|
|
482
|
+
}
|
|
483
|
+
errors++;
|
|
484
|
+
}
|
|
485
|
+
} else {
|
|
486
|
+
const err22 = { instancePath: instancePath + "/date/text", schemaPath: "#/$defs/storyDate/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
487
|
+
if (vErrors === null) {
|
|
488
|
+
vErrors = [err22];
|
|
489
|
+
} else {
|
|
490
|
+
vErrors.push(err22);
|
|
491
|
+
}
|
|
492
|
+
errors++;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (data7.edtf !== void 0) {
|
|
496
|
+
let data9 = data7.edtf;
|
|
497
|
+
if (typeof data9 === "string") {
|
|
498
|
+
if (!pattern5.test(data9)) {
|
|
499
|
+
const err23 = { instancePath: instancePath + "/date/edtf", schemaPath: "#/$defs/storyDate/properties/edtf/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
500
|
+
if (vErrors === null) {
|
|
501
|
+
vErrors = [err23];
|
|
502
|
+
} else {
|
|
503
|
+
vErrors.push(err23);
|
|
504
|
+
}
|
|
505
|
+
errors++;
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
const err24 = { instancePath: instancePath + "/date/edtf", schemaPath: "#/$defs/storyDate/properties/edtf/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
509
|
+
if (vErrors === null) {
|
|
510
|
+
vErrors = [err24];
|
|
511
|
+
} else {
|
|
512
|
+
vErrors.push(err24);
|
|
513
|
+
}
|
|
514
|
+
errors++;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (data7.sortYear !== void 0) {
|
|
518
|
+
let data10 = data7.sortYear;
|
|
519
|
+
if (!(typeof data10 == "number" && (!(data10 % 1) && !isNaN(data10)) && isFinite(data10))) {
|
|
520
|
+
const err25 = { instancePath: instancePath + "/date/sortYear", schemaPath: "#/$defs/storyDate/properties/sortYear/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
521
|
+
if (vErrors === null) {
|
|
522
|
+
vErrors = [err25];
|
|
523
|
+
} else {
|
|
524
|
+
vErrors.push(err25);
|
|
525
|
+
}
|
|
526
|
+
errors++;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
const err26 = { instancePath: instancePath + "/date", schemaPath: "#/$defs/storyDate/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
531
|
+
if (vErrors === null) {
|
|
532
|
+
vErrors = [err26];
|
|
533
|
+
} else {
|
|
534
|
+
vErrors.push(err26);
|
|
535
|
+
}
|
|
536
|
+
errors++;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
const err27 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
541
|
+
if (vErrors === null) {
|
|
542
|
+
vErrors = [err27];
|
|
543
|
+
} else {
|
|
544
|
+
vErrors.push(err27);
|
|
545
|
+
}
|
|
546
|
+
errors++;
|
|
547
|
+
}
|
|
548
|
+
validate23.errors = vErrors;
|
|
549
|
+
return errors === 0;
|
|
550
|
+
}
|
|
551
|
+
validate23.evaluated = { "props": { "media": true, "corners": true, "opacity": true, "order": true, "date": true }, "dynamicProps": false, "dynamicItems": false };
|
|
552
|
+
function validate22(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
553
|
+
let vErrors = null;
|
|
554
|
+
let errors = 0;
|
|
555
|
+
const evaluated0 = validate22.evaluated;
|
|
556
|
+
if (evaluated0.dynamicProps) {
|
|
557
|
+
evaluated0.props = void 0;
|
|
558
|
+
}
|
|
559
|
+
if (evaluated0.dynamicItems) {
|
|
560
|
+
evaluated0.items = void 0;
|
|
561
|
+
}
|
|
562
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
563
|
+
if (data.name !== void 0) {
|
|
564
|
+
if (typeof data.name !== "string") {
|
|
565
|
+
const err0 = { instancePath: instancePath + "/name", schemaPath: "#/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
566
|
+
if (vErrors === null) {
|
|
567
|
+
vErrors = [err0];
|
|
568
|
+
} else {
|
|
569
|
+
vErrors.push(err0);
|
|
570
|
+
}
|
|
571
|
+
errors++;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (data.lat !== void 0) {
|
|
575
|
+
let data1 = data.lat;
|
|
576
|
+
if (typeof data1 == "number" && isFinite(data1)) {
|
|
577
|
+
if (data1 > 90 || isNaN(data1)) {
|
|
578
|
+
const err1 = { instancePath: instancePath + "/lat", schemaPath: "#/properties/lat/maximum", keyword: "maximum", params: { comparison: "<=", limit: 90 }, message: "must be <= 90" };
|
|
579
|
+
if (vErrors === null) {
|
|
580
|
+
vErrors = [err1];
|
|
581
|
+
} else {
|
|
582
|
+
vErrors.push(err1);
|
|
583
|
+
}
|
|
584
|
+
errors++;
|
|
585
|
+
}
|
|
586
|
+
if (data1 < -90 || isNaN(data1)) {
|
|
587
|
+
const err2 = { instancePath: instancePath + "/lat", schemaPath: "#/properties/lat/minimum", keyword: "minimum", params: { comparison: ">=", limit: -90 }, message: "must be >= -90" };
|
|
588
|
+
if (vErrors === null) {
|
|
589
|
+
vErrors = [err2];
|
|
590
|
+
} else {
|
|
591
|
+
vErrors.push(err2);
|
|
592
|
+
}
|
|
593
|
+
errors++;
|
|
594
|
+
}
|
|
595
|
+
} else {
|
|
596
|
+
const err3 = { instancePath: instancePath + "/lat", schemaPath: "#/properties/lat/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
597
|
+
if (vErrors === null) {
|
|
598
|
+
vErrors = [err3];
|
|
599
|
+
} else {
|
|
600
|
+
vErrors.push(err3);
|
|
601
|
+
}
|
|
602
|
+
errors++;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (data.lon !== void 0) {
|
|
606
|
+
let data2 = data.lon;
|
|
607
|
+
if (typeof data2 == "number" && isFinite(data2)) {
|
|
608
|
+
if (data2 > 180 || isNaN(data2)) {
|
|
609
|
+
const err4 = { instancePath: instancePath + "/lon", schemaPath: "#/properties/lon/maximum", keyword: "maximum", params: { comparison: "<=", limit: 180 }, message: "must be <= 180" };
|
|
610
|
+
if (vErrors === null) {
|
|
611
|
+
vErrors = [err4];
|
|
612
|
+
} else {
|
|
613
|
+
vErrors.push(err4);
|
|
614
|
+
}
|
|
615
|
+
errors++;
|
|
616
|
+
}
|
|
617
|
+
if (data2 < -180 || isNaN(data2)) {
|
|
618
|
+
const err5 = { instancePath: instancePath + "/lon", schemaPath: "#/properties/lon/minimum", keyword: "minimum", params: { comparison: ">=", limit: -180 }, message: "must be >= -180" };
|
|
619
|
+
if (vErrors === null) {
|
|
620
|
+
vErrors = [err5];
|
|
621
|
+
} else {
|
|
622
|
+
vErrors.push(err5);
|
|
623
|
+
}
|
|
624
|
+
errors++;
|
|
625
|
+
}
|
|
626
|
+
} else {
|
|
627
|
+
const err6 = { instancePath: instancePath + "/lon", schemaPath: "#/properties/lon/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
628
|
+
if (vErrors === null) {
|
|
629
|
+
vErrors = [err6];
|
|
630
|
+
} else {
|
|
631
|
+
vErrors.push(err6);
|
|
632
|
+
}
|
|
633
|
+
errors++;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (data.geometry !== void 0) {
|
|
637
|
+
let data3 = data.geometry;
|
|
638
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
639
|
+
if (data3.type === void 0) {
|
|
640
|
+
const err7 = { instancePath: instancePath + "/geometry", schemaPath: "#/properties/geometry/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
641
|
+
if (vErrors === null) {
|
|
642
|
+
vErrors = [err7];
|
|
643
|
+
} else {
|
|
644
|
+
vErrors.push(err7);
|
|
645
|
+
}
|
|
646
|
+
errors++;
|
|
647
|
+
}
|
|
648
|
+
if (data3.type !== void 0) {
|
|
649
|
+
if (typeof data3.type !== "string") {
|
|
650
|
+
const err8 = { instancePath: instancePath + "/geometry/type", schemaPath: "#/properties/geometry/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
651
|
+
if (vErrors === null) {
|
|
652
|
+
vErrors = [err8];
|
|
653
|
+
} else {
|
|
654
|
+
vErrors.push(err8);
|
|
655
|
+
}
|
|
656
|
+
errors++;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
} else {
|
|
660
|
+
const err9 = { instancePath: instancePath + "/geometry", schemaPath: "#/properties/geometry/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
661
|
+
if (vErrors === null) {
|
|
662
|
+
vErrors = [err9];
|
|
663
|
+
} else {
|
|
664
|
+
vErrors.push(err9);
|
|
665
|
+
}
|
|
666
|
+
errors++;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (data.overlays !== void 0) {
|
|
670
|
+
let data5 = data.overlays;
|
|
671
|
+
if (Array.isArray(data5)) {
|
|
672
|
+
const len0 = data5.length;
|
|
673
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
674
|
+
if (!validate23(data5[i0], { instancePath: instancePath + "/overlays/" + i0, parentData: data5, parentDataProperty: i0, rootData, dynamicAnchors })) {
|
|
675
|
+
vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors);
|
|
676
|
+
errors = vErrors.length;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
} else {
|
|
680
|
+
const err10 = { instancePath: instancePath + "/overlays", schemaPath: "#/properties/overlays/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
681
|
+
if (vErrors === null) {
|
|
682
|
+
vErrors = [err10];
|
|
683
|
+
} else {
|
|
684
|
+
vErrors.push(err10);
|
|
685
|
+
}
|
|
686
|
+
errors++;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (data.lat !== void 0) {
|
|
690
|
+
if (data.lon === void 0) {
|
|
691
|
+
const err11 = { instancePath, schemaPath: "#/dependentRequired", keyword: "dependentRequired", params: {
|
|
692
|
+
property: "lat",
|
|
693
|
+
missingProperty: "lon",
|
|
694
|
+
depsCount: 1,
|
|
695
|
+
deps: "lon"
|
|
696
|
+
}, message: "must have property lon when property lat is present" };
|
|
697
|
+
if (vErrors === null) {
|
|
698
|
+
vErrors = [err11];
|
|
699
|
+
} else {
|
|
700
|
+
vErrors.push(err11);
|
|
701
|
+
}
|
|
702
|
+
errors++;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (data.lon !== void 0) {
|
|
706
|
+
if (data.lat === void 0) {
|
|
707
|
+
const err12 = { instancePath, schemaPath: "#/dependentRequired", keyword: "dependentRequired", params: {
|
|
708
|
+
property: "lon",
|
|
709
|
+
missingProperty: "lat",
|
|
710
|
+
depsCount: 1,
|
|
711
|
+
deps: "lat"
|
|
712
|
+
}, message: "must have property lat when property lon is present" };
|
|
713
|
+
if (vErrors === null) {
|
|
714
|
+
vErrors = [err12];
|
|
715
|
+
} else {
|
|
716
|
+
vErrors.push(err12);
|
|
717
|
+
}
|
|
718
|
+
errors++;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
} else {
|
|
722
|
+
const err13 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
723
|
+
if (vErrors === null) {
|
|
724
|
+
vErrors = [err13];
|
|
725
|
+
} else {
|
|
726
|
+
vErrors.push(err13);
|
|
727
|
+
}
|
|
728
|
+
errors++;
|
|
729
|
+
}
|
|
730
|
+
validate22.errors = vErrors;
|
|
731
|
+
return errors === 0;
|
|
732
|
+
}
|
|
733
|
+
validate22.evaluated = { "props": { "name": true, "lat": true, "lon": true, "geometry": true, "overlays": true }, "dynamicProps": false, "dynamicItems": false };
|
|
734
|
+
function validate26(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
735
|
+
let vErrors = null;
|
|
736
|
+
let errors = 0;
|
|
737
|
+
const evaluated0 = validate26.evaluated;
|
|
738
|
+
if (evaluated0.dynamicProps) {
|
|
739
|
+
evaluated0.props = void 0;
|
|
740
|
+
}
|
|
741
|
+
if (evaluated0.dynamicItems) {
|
|
742
|
+
evaluated0.items = void 0;
|
|
743
|
+
}
|
|
744
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
745
|
+
if (data.ref === void 0) {
|
|
746
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "ref" }, message: "must have required property 'ref'" };
|
|
747
|
+
if (vErrors === null) {
|
|
748
|
+
vErrors = [err0];
|
|
749
|
+
} else {
|
|
750
|
+
vErrors.push(err0);
|
|
751
|
+
}
|
|
752
|
+
errors++;
|
|
753
|
+
}
|
|
754
|
+
if (data.ref !== void 0) {
|
|
755
|
+
let data0 = data.ref;
|
|
756
|
+
if (typeof data0 === "string") {
|
|
757
|
+
if (!pattern10.test(data0)) {
|
|
758
|
+
const err1 = { instancePath: instancePath + "/ref", schemaPath: "#/$defs/id/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]{1,64}$" }, message: 'must match pattern "^[A-Za-z0-9_-]{1,64}$"' };
|
|
759
|
+
if (vErrors === null) {
|
|
760
|
+
vErrors = [err1];
|
|
761
|
+
} else {
|
|
762
|
+
vErrors.push(err1);
|
|
763
|
+
}
|
|
764
|
+
errors++;
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
const err2 = { instancePath: instancePath + "/ref", schemaPath: "#/$defs/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
768
|
+
if (vErrors === null) {
|
|
769
|
+
vErrors = [err2];
|
|
770
|
+
} else {
|
|
771
|
+
vErrors.push(err2);
|
|
772
|
+
}
|
|
773
|
+
errors++;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (data.caption !== void 0) {
|
|
777
|
+
if (typeof data.caption !== "string") {
|
|
778
|
+
const err3 = { instancePath: instancePath + "/caption", schemaPath: "#/properties/caption/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
779
|
+
if (vErrors === null) {
|
|
780
|
+
vErrors = [err3];
|
|
781
|
+
} else {
|
|
782
|
+
vErrors.push(err3);
|
|
783
|
+
}
|
|
784
|
+
errors++;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (data.credit !== void 0) {
|
|
788
|
+
if (typeof data.credit !== "string") {
|
|
789
|
+
const err4 = { instancePath: instancePath + "/credit", schemaPath: "#/properties/credit/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
790
|
+
if (vErrors === null) {
|
|
791
|
+
vErrors = [err4];
|
|
792
|
+
} else {
|
|
793
|
+
vErrors.push(err4);
|
|
794
|
+
}
|
|
795
|
+
errors++;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
} else {
|
|
799
|
+
const err5 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
800
|
+
if (vErrors === null) {
|
|
801
|
+
vErrors = [err5];
|
|
802
|
+
} else {
|
|
803
|
+
vErrors.push(err5);
|
|
804
|
+
}
|
|
805
|
+
errors++;
|
|
806
|
+
}
|
|
807
|
+
validate26.errors = vErrors;
|
|
808
|
+
return errors === 0;
|
|
809
|
+
}
|
|
810
|
+
validate26.evaluated = { "props": { "ref": true, "caption": true, "credit": true }, "dynamicProps": false, "dynamicItems": false };
|
|
811
|
+
function validate21(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
812
|
+
let vErrors = null;
|
|
813
|
+
let errors = 0;
|
|
814
|
+
const evaluated0 = validate21.evaluated;
|
|
815
|
+
if (evaluated0.dynamicProps) {
|
|
816
|
+
evaluated0.props = void 0;
|
|
817
|
+
}
|
|
818
|
+
if (evaluated0.dynamicItems) {
|
|
819
|
+
evaluated0.items = void 0;
|
|
820
|
+
}
|
|
821
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
822
|
+
if (data.id === void 0) {
|
|
823
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
|
|
824
|
+
if (vErrors === null) {
|
|
825
|
+
vErrors = [err0];
|
|
826
|
+
} else {
|
|
827
|
+
vErrors.push(err0);
|
|
828
|
+
}
|
|
829
|
+
errors++;
|
|
830
|
+
}
|
|
831
|
+
if (data.id !== void 0) {
|
|
832
|
+
let data0 = data.id;
|
|
833
|
+
if (typeof data0 === "string") {
|
|
834
|
+
if (!pattern10.test(data0)) {
|
|
835
|
+
const err1 = { instancePath: instancePath + "/id", schemaPath: "#/$defs/id/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]{1,64}$" }, message: 'must match pattern "^[A-Za-z0-9_-]{1,64}$"' };
|
|
836
|
+
if (vErrors === null) {
|
|
837
|
+
vErrors = [err1];
|
|
838
|
+
} else {
|
|
839
|
+
vErrors.push(err1);
|
|
840
|
+
}
|
|
841
|
+
errors++;
|
|
842
|
+
}
|
|
843
|
+
} else {
|
|
844
|
+
const err2 = { instancePath: instancePath + "/id", schemaPath: "#/$defs/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
845
|
+
if (vErrors === null) {
|
|
846
|
+
vErrors = [err2];
|
|
847
|
+
} else {
|
|
848
|
+
vErrors.push(err2);
|
|
849
|
+
}
|
|
850
|
+
errors++;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
if (data.title !== void 0) {
|
|
854
|
+
if (typeof data.title !== "string") {
|
|
855
|
+
const err3 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
856
|
+
if (vErrors === null) {
|
|
857
|
+
vErrors = [err3];
|
|
858
|
+
} else {
|
|
859
|
+
vErrors.push(err3);
|
|
860
|
+
}
|
|
861
|
+
errors++;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
if (data.text !== void 0) {
|
|
865
|
+
if (typeof data.text !== "string") {
|
|
866
|
+
const err4 = { instancePath: instancePath + "/text", schemaPath: "#/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
867
|
+
if (vErrors === null) {
|
|
868
|
+
vErrors = [err4];
|
|
869
|
+
} else {
|
|
870
|
+
vErrors.push(err4);
|
|
871
|
+
}
|
|
872
|
+
errors++;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
if (data.date !== void 0) {
|
|
876
|
+
let data3 = data.date;
|
|
877
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
878
|
+
if (data3.text === void 0) {
|
|
879
|
+
const err5 = { instancePath: instancePath + "/date", schemaPath: "#/$defs/storyDate/required", keyword: "required", params: { missingProperty: "text" }, message: "must have required property 'text'" };
|
|
880
|
+
if (vErrors === null) {
|
|
881
|
+
vErrors = [err5];
|
|
882
|
+
} else {
|
|
883
|
+
vErrors.push(err5);
|
|
884
|
+
}
|
|
885
|
+
errors++;
|
|
886
|
+
}
|
|
887
|
+
if (data3.text !== void 0) {
|
|
888
|
+
let data4 = data3.text;
|
|
889
|
+
if (typeof data4 === "string") {
|
|
890
|
+
if (!pattern5.test(data4)) {
|
|
891
|
+
const err6 = { instancePath: instancePath + "/date/text", schemaPath: "#/$defs/storyDate/properties/text/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
892
|
+
if (vErrors === null) {
|
|
893
|
+
vErrors = [err6];
|
|
894
|
+
} else {
|
|
895
|
+
vErrors.push(err6);
|
|
896
|
+
}
|
|
897
|
+
errors++;
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
const err7 = { instancePath: instancePath + "/date/text", schemaPath: "#/$defs/storyDate/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
901
|
+
if (vErrors === null) {
|
|
902
|
+
vErrors = [err7];
|
|
903
|
+
} else {
|
|
904
|
+
vErrors.push(err7);
|
|
905
|
+
}
|
|
906
|
+
errors++;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
if (data3.edtf !== void 0) {
|
|
910
|
+
let data5 = data3.edtf;
|
|
911
|
+
if (typeof data5 === "string") {
|
|
912
|
+
if (!pattern5.test(data5)) {
|
|
913
|
+
const err8 = { instancePath: instancePath + "/date/edtf", schemaPath: "#/$defs/storyDate/properties/edtf/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
914
|
+
if (vErrors === null) {
|
|
915
|
+
vErrors = [err8];
|
|
916
|
+
} else {
|
|
917
|
+
vErrors.push(err8);
|
|
918
|
+
}
|
|
919
|
+
errors++;
|
|
920
|
+
}
|
|
921
|
+
} else {
|
|
922
|
+
const err9 = { instancePath: instancePath + "/date/edtf", schemaPath: "#/$defs/storyDate/properties/edtf/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
923
|
+
if (vErrors === null) {
|
|
924
|
+
vErrors = [err9];
|
|
925
|
+
} else {
|
|
926
|
+
vErrors.push(err9);
|
|
927
|
+
}
|
|
928
|
+
errors++;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (data3.sortYear !== void 0) {
|
|
932
|
+
let data6 = data3.sortYear;
|
|
933
|
+
if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) {
|
|
934
|
+
const err10 = { instancePath: instancePath + "/date/sortYear", schemaPath: "#/$defs/storyDate/properties/sortYear/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
935
|
+
if (vErrors === null) {
|
|
936
|
+
vErrors = [err10];
|
|
937
|
+
} else {
|
|
938
|
+
vErrors.push(err10);
|
|
939
|
+
}
|
|
940
|
+
errors++;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
} else {
|
|
944
|
+
const err11 = { instancePath: instancePath + "/date", schemaPath: "#/$defs/storyDate/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
945
|
+
if (vErrors === null) {
|
|
946
|
+
vErrors = [err11];
|
|
947
|
+
} else {
|
|
948
|
+
vErrors.push(err11);
|
|
949
|
+
}
|
|
950
|
+
errors++;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
if (data.place !== void 0) {
|
|
954
|
+
if (!validate22(data.place, { instancePath: instancePath + "/place", parentData: data, parentDataProperty: "place", rootData, dynamicAnchors })) {
|
|
955
|
+
vErrors = vErrors === null ? validate22.errors : vErrors.concat(validate22.errors);
|
|
956
|
+
errors = vErrors.length;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (data.media !== void 0) {
|
|
960
|
+
let data8 = data.media;
|
|
961
|
+
if (Array.isArray(data8)) {
|
|
962
|
+
const len0 = data8.length;
|
|
963
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
964
|
+
if (!validate26(data8[i0], { instancePath: instancePath + "/media/" + i0, parentData: data8, parentDataProperty: i0, rootData, dynamicAnchors })) {
|
|
965
|
+
vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
|
|
966
|
+
errors = vErrors.length;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
} else {
|
|
970
|
+
const err12 = { instancePath: instancePath + "/media", schemaPath: "#/properties/media/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
971
|
+
if (vErrors === null) {
|
|
972
|
+
vErrors = [err12];
|
|
973
|
+
} else {
|
|
974
|
+
vErrors.push(err12);
|
|
975
|
+
}
|
|
976
|
+
errors++;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (data.people !== void 0) {
|
|
980
|
+
let data10 = data.people;
|
|
981
|
+
if (Array.isArray(data10)) {
|
|
982
|
+
const len1 = data10.length;
|
|
983
|
+
for (let i1 = 0; i1 < len1; i1++) {
|
|
984
|
+
let data11 = data10[i1];
|
|
985
|
+
if (data11 && typeof data11 == "object" && !Array.isArray(data11)) {
|
|
986
|
+
if (data11.name === void 0) {
|
|
987
|
+
const err13 = { instancePath: instancePath + "/people/" + i1, schemaPath: "#/properties/people/items/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property 'name'" };
|
|
988
|
+
if (vErrors === null) {
|
|
989
|
+
vErrors = [err13];
|
|
990
|
+
} else {
|
|
991
|
+
vErrors.push(err13);
|
|
992
|
+
}
|
|
993
|
+
errors++;
|
|
994
|
+
}
|
|
995
|
+
if (data11.name !== void 0) {
|
|
996
|
+
let data12 = data11.name;
|
|
997
|
+
if (typeof data12 === "string") {
|
|
998
|
+
if (!pattern5.test(data12)) {
|
|
999
|
+
const err14 = { instancePath: instancePath + "/people/" + i1 + "/name", schemaPath: "#/properties/people/items/properties/name/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
1000
|
+
if (vErrors === null) {
|
|
1001
|
+
vErrors = [err14];
|
|
1002
|
+
} else {
|
|
1003
|
+
vErrors.push(err14);
|
|
1004
|
+
}
|
|
1005
|
+
errors++;
|
|
1006
|
+
}
|
|
1007
|
+
} else {
|
|
1008
|
+
const err15 = { instancePath: instancePath + "/people/" + i1 + "/name", schemaPath: "#/properties/people/items/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1009
|
+
if (vErrors === null) {
|
|
1010
|
+
vErrors = [err15];
|
|
1011
|
+
} else {
|
|
1012
|
+
vErrors.push(err15);
|
|
1013
|
+
}
|
|
1014
|
+
errors++;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (data11.role !== void 0) {
|
|
1018
|
+
if (typeof data11.role !== "string") {
|
|
1019
|
+
const err16 = { instancePath: instancePath + "/people/" + i1 + "/role", schemaPath: "#/properties/people/items/properties/role/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1020
|
+
if (vErrors === null) {
|
|
1021
|
+
vErrors = [err16];
|
|
1022
|
+
} else {
|
|
1023
|
+
vErrors.push(err16);
|
|
1024
|
+
}
|
|
1025
|
+
errors++;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
} else {
|
|
1029
|
+
const err17 = { instancePath: instancePath + "/people/" + i1, schemaPath: "#/properties/people/items/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1030
|
+
if (vErrors === null) {
|
|
1031
|
+
vErrors = [err17];
|
|
1032
|
+
} else {
|
|
1033
|
+
vErrors.push(err17);
|
|
1034
|
+
}
|
|
1035
|
+
errors++;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
} else {
|
|
1039
|
+
const err18 = { instancePath: instancePath + "/people", schemaPath: "#/properties/people/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1040
|
+
if (vErrors === null) {
|
|
1041
|
+
vErrors = [err18];
|
|
1042
|
+
} else {
|
|
1043
|
+
vErrors.push(err18);
|
|
1044
|
+
}
|
|
1045
|
+
errors++;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
} else {
|
|
1049
|
+
const err19 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1050
|
+
if (vErrors === null) {
|
|
1051
|
+
vErrors = [err19];
|
|
1052
|
+
} else {
|
|
1053
|
+
vErrors.push(err19);
|
|
1054
|
+
}
|
|
1055
|
+
errors++;
|
|
1056
|
+
}
|
|
1057
|
+
validate21.errors = vErrors;
|
|
1058
|
+
return errors === 0;
|
|
1059
|
+
}
|
|
1060
|
+
validate21.evaluated = { "props": { "id": true, "title": true, "text": true, "date": true, "place": true, "media": true, "people": true }, "dynamicProps": false, "dynamicItems": false };
|
|
1061
|
+
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1062
|
+
;
|
|
1063
|
+
let vErrors = null;
|
|
1064
|
+
let errors = 0;
|
|
1065
|
+
const evaluated0 = validate20.evaluated;
|
|
1066
|
+
if (evaluated0.dynamicProps) {
|
|
1067
|
+
evaluated0.props = void 0;
|
|
1068
|
+
}
|
|
1069
|
+
if (evaluated0.dynamicItems) {
|
|
1070
|
+
evaluated0.items = void 0;
|
|
1071
|
+
}
|
|
1072
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1073
|
+
if (data.format === void 0) {
|
|
1074
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "format" }, message: "must have required property 'format'" };
|
|
1075
|
+
if (vErrors === null) {
|
|
1076
|
+
vErrors = [err0];
|
|
1077
|
+
} else {
|
|
1078
|
+
vErrors.push(err0);
|
|
1079
|
+
}
|
|
1080
|
+
errors++;
|
|
1081
|
+
}
|
|
1082
|
+
if (data.version === void 0) {
|
|
1083
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
1084
|
+
if (vErrors === null) {
|
|
1085
|
+
vErrors = [err1];
|
|
1086
|
+
} else {
|
|
1087
|
+
vErrors.push(err1);
|
|
1088
|
+
}
|
|
1089
|
+
errors++;
|
|
1090
|
+
}
|
|
1091
|
+
if (data.title === void 0) {
|
|
1092
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
1093
|
+
if (vErrors === null) {
|
|
1094
|
+
vErrors = [err2];
|
|
1095
|
+
} else {
|
|
1096
|
+
vErrors.push(err2);
|
|
1097
|
+
}
|
|
1098
|
+
errors++;
|
|
1099
|
+
}
|
|
1100
|
+
if (data.slides === void 0) {
|
|
1101
|
+
const err3 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "slides" }, message: "must have required property 'slides'" };
|
|
1102
|
+
if (vErrors === null) {
|
|
1103
|
+
vErrors = [err3];
|
|
1104
|
+
} else {
|
|
1105
|
+
vErrors.push(err3);
|
|
1106
|
+
}
|
|
1107
|
+
errors++;
|
|
1108
|
+
}
|
|
1109
|
+
if (data.media === void 0) {
|
|
1110
|
+
const err4 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "media" }, message: "must have required property 'media'" };
|
|
1111
|
+
if (vErrors === null) {
|
|
1112
|
+
vErrors = [err4];
|
|
1113
|
+
} else {
|
|
1114
|
+
vErrors.push(err4);
|
|
1115
|
+
}
|
|
1116
|
+
errors++;
|
|
1117
|
+
}
|
|
1118
|
+
if (data.$schema !== void 0) {
|
|
1119
|
+
if (typeof data.$schema !== "string") {
|
|
1120
|
+
const err5 = { instancePath: instancePath + "/$schema", schemaPath: "#/properties/%24schema/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1121
|
+
if (vErrors === null) {
|
|
1122
|
+
vErrors = [err5];
|
|
1123
|
+
} else {
|
|
1124
|
+
vErrors.push(err5);
|
|
1125
|
+
}
|
|
1126
|
+
errors++;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
if (data.format !== void 0) {
|
|
1130
|
+
if ("gramps-connect-story" !== data.format) {
|
|
1131
|
+
const err6 = { instancePath: instancePath + "/format", schemaPath: "#/properties/format/const", keyword: "const", params: { allowedValue: "gramps-connect-story" }, message: "must be equal to constant" };
|
|
1132
|
+
if (vErrors === null) {
|
|
1133
|
+
vErrors = [err6];
|
|
1134
|
+
} else {
|
|
1135
|
+
vErrors.push(err6);
|
|
1136
|
+
}
|
|
1137
|
+
errors++;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
if (data.version !== void 0) {
|
|
1141
|
+
let data2 = data.version;
|
|
1142
|
+
if (typeof data2 === "string") {
|
|
1143
|
+
if (!pattern4.test(data2)) {
|
|
1144
|
+
const err7 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/pattern", keyword: "pattern", params: { pattern: "^1\\.(0|[1-9][0-9]*)$" }, message: 'must match pattern "^1\\.(0|[1-9][0-9]*)$"' };
|
|
1145
|
+
if (vErrors === null) {
|
|
1146
|
+
vErrors = [err7];
|
|
1147
|
+
} else {
|
|
1148
|
+
vErrors.push(err7);
|
|
1149
|
+
}
|
|
1150
|
+
errors++;
|
|
1151
|
+
}
|
|
1152
|
+
} else {
|
|
1153
|
+
const err8 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1154
|
+
if (vErrors === null) {
|
|
1155
|
+
vErrors = [err8];
|
|
1156
|
+
} else {
|
|
1157
|
+
vErrors.push(err8);
|
|
1158
|
+
}
|
|
1159
|
+
errors++;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (data.title !== void 0) {
|
|
1163
|
+
let data3 = data.title;
|
|
1164
|
+
if (typeof data3 === "string") {
|
|
1165
|
+
if (!pattern5.test(data3)) {
|
|
1166
|
+
const err9 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
1167
|
+
if (vErrors === null) {
|
|
1168
|
+
vErrors = [err9];
|
|
1169
|
+
} else {
|
|
1170
|
+
vErrors.push(err9);
|
|
1171
|
+
}
|
|
1172
|
+
errors++;
|
|
1173
|
+
}
|
|
1174
|
+
} else {
|
|
1175
|
+
const err10 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1176
|
+
if (vErrors === null) {
|
|
1177
|
+
vErrors = [err10];
|
|
1178
|
+
} else {
|
|
1179
|
+
vErrors.push(err10);
|
|
1180
|
+
}
|
|
1181
|
+
errors++;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
if (data.language !== void 0) {
|
|
1185
|
+
let data4 = data.language;
|
|
1186
|
+
if (typeof data4 === "string") {
|
|
1187
|
+
if (!pattern6.test(data4)) {
|
|
1188
|
+
const err11 = { instancePath: instancePath + "/language", schemaPath: "#/properties/language/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$" }, message: 'must match pattern "^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$"' };
|
|
1189
|
+
if (vErrors === null) {
|
|
1190
|
+
vErrors = [err11];
|
|
1191
|
+
} else {
|
|
1192
|
+
vErrors.push(err11);
|
|
1193
|
+
}
|
|
1194
|
+
errors++;
|
|
1195
|
+
}
|
|
1196
|
+
} else {
|
|
1197
|
+
const err12 = { instancePath: instancePath + "/language", schemaPath: "#/properties/language/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1198
|
+
if (vErrors === null) {
|
|
1199
|
+
vErrors = [err12];
|
|
1200
|
+
} else {
|
|
1201
|
+
vErrors.push(err12);
|
|
1202
|
+
}
|
|
1203
|
+
errors++;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (data.created !== void 0) {
|
|
1207
|
+
let data5 = data.created;
|
|
1208
|
+
if (typeof data5 === "string") {
|
|
1209
|
+
if (!pattern7.test(data5)) {
|
|
1210
|
+
const err13 = { instancePath: instancePath + "/created", schemaPath: "#/properties/created/pattern", keyword: "pattern", params: { pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$" }, message: 'must match pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$"' };
|
|
1211
|
+
if (vErrors === null) {
|
|
1212
|
+
vErrors = [err13];
|
|
1213
|
+
} else {
|
|
1214
|
+
vErrors.push(err13);
|
|
1215
|
+
}
|
|
1216
|
+
errors++;
|
|
1217
|
+
}
|
|
1218
|
+
} else {
|
|
1219
|
+
const err14 = { instancePath: instancePath + "/created", schemaPath: "#/properties/created/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1220
|
+
if (vErrors === null) {
|
|
1221
|
+
vErrors = [err14];
|
|
1222
|
+
} else {
|
|
1223
|
+
vErrors.push(err14);
|
|
1224
|
+
}
|
|
1225
|
+
errors++;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
if (data.generator !== void 0) {
|
|
1229
|
+
let data6 = data.generator;
|
|
1230
|
+
if (data6 && typeof data6 == "object" && !Array.isArray(data6)) {
|
|
1231
|
+
if (data6.name === void 0) {
|
|
1232
|
+
const err15 = { instancePath: instancePath + "/generator", schemaPath: "#/properties/generator/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property 'name'" };
|
|
1233
|
+
if (vErrors === null) {
|
|
1234
|
+
vErrors = [err15];
|
|
1235
|
+
} else {
|
|
1236
|
+
vErrors.push(err15);
|
|
1237
|
+
}
|
|
1238
|
+
errors++;
|
|
1239
|
+
}
|
|
1240
|
+
if (data6.name !== void 0) {
|
|
1241
|
+
let data7 = data6.name;
|
|
1242
|
+
if (typeof data7 === "string") {
|
|
1243
|
+
if (!pattern5.test(data7)) {
|
|
1244
|
+
const err16 = { instancePath: instancePath + "/generator/name", schemaPath: "#/properties/generator/properties/name/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
1245
|
+
if (vErrors === null) {
|
|
1246
|
+
vErrors = [err16];
|
|
1247
|
+
} else {
|
|
1248
|
+
vErrors.push(err16);
|
|
1249
|
+
}
|
|
1250
|
+
errors++;
|
|
1251
|
+
}
|
|
1252
|
+
} else {
|
|
1253
|
+
const err17 = { instancePath: instancePath + "/generator/name", schemaPath: "#/properties/generator/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1254
|
+
if (vErrors === null) {
|
|
1255
|
+
vErrors = [err17];
|
|
1256
|
+
} else {
|
|
1257
|
+
vErrors.push(err17);
|
|
1258
|
+
}
|
|
1259
|
+
errors++;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
if (data6.version !== void 0) {
|
|
1263
|
+
if (typeof data6.version !== "string") {
|
|
1264
|
+
const err18 = { instancePath: instancePath + "/generator/version", schemaPath: "#/properties/generator/properties/version/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1265
|
+
if (vErrors === null) {
|
|
1266
|
+
vErrors = [err18];
|
|
1267
|
+
} else {
|
|
1268
|
+
vErrors.push(err18);
|
|
1269
|
+
}
|
|
1270
|
+
errors++;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
if (data6.url !== void 0) {
|
|
1274
|
+
if (typeof data6.url !== "string") {
|
|
1275
|
+
const err19 = { instancePath: instancePath + "/generator/url", schemaPath: "#/properties/generator/properties/url/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1276
|
+
if (vErrors === null) {
|
|
1277
|
+
vErrors = [err19];
|
|
1278
|
+
} else {
|
|
1279
|
+
vErrors.push(err19);
|
|
1280
|
+
}
|
|
1281
|
+
errors++;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
} else {
|
|
1285
|
+
const err20 = { instancePath: instancePath + "/generator", schemaPath: "#/properties/generator/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1286
|
+
if (vErrors === null) {
|
|
1287
|
+
vErrors = [err20];
|
|
1288
|
+
} else {
|
|
1289
|
+
vErrors.push(err20);
|
|
1290
|
+
}
|
|
1291
|
+
errors++;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (data.authors !== void 0) {
|
|
1295
|
+
let data10 = data.authors;
|
|
1296
|
+
if (Array.isArray(data10)) {
|
|
1297
|
+
const len0 = data10.length;
|
|
1298
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
1299
|
+
let data11 = data10[i0];
|
|
1300
|
+
if (data11 && typeof data11 == "object" && !Array.isArray(data11)) {
|
|
1301
|
+
if (data11.name === void 0) {
|
|
1302
|
+
const err21 = { instancePath: instancePath + "/authors/" + i0, schemaPath: "#/properties/authors/items/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property 'name'" };
|
|
1303
|
+
if (vErrors === null) {
|
|
1304
|
+
vErrors = [err21];
|
|
1305
|
+
} else {
|
|
1306
|
+
vErrors.push(err21);
|
|
1307
|
+
}
|
|
1308
|
+
errors++;
|
|
1309
|
+
}
|
|
1310
|
+
if (data11.name !== void 0) {
|
|
1311
|
+
let data12 = data11.name;
|
|
1312
|
+
if (typeof data12 === "string") {
|
|
1313
|
+
if (!pattern5.test(data12)) {
|
|
1314
|
+
const err22 = { instancePath: instancePath + "/authors/" + i0 + "/name", schemaPath: "#/properties/authors/items/properties/name/pattern", keyword: "pattern", params: { pattern: "\\S" }, message: 'must match pattern "\\S"' };
|
|
1315
|
+
if (vErrors === null) {
|
|
1316
|
+
vErrors = [err22];
|
|
1317
|
+
} else {
|
|
1318
|
+
vErrors.push(err22);
|
|
1319
|
+
}
|
|
1320
|
+
errors++;
|
|
1321
|
+
}
|
|
1322
|
+
} else {
|
|
1323
|
+
const err23 = { instancePath: instancePath + "/authors/" + i0 + "/name", schemaPath: "#/properties/authors/items/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1324
|
+
if (vErrors === null) {
|
|
1325
|
+
vErrors = [err23];
|
|
1326
|
+
} else {
|
|
1327
|
+
vErrors.push(err23);
|
|
1328
|
+
}
|
|
1329
|
+
errors++;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
if (data11.url !== void 0) {
|
|
1333
|
+
if (typeof data11.url !== "string") {
|
|
1334
|
+
const err24 = { instancePath: instancePath + "/authors/" + i0 + "/url", schemaPath: "#/properties/authors/items/properties/url/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1335
|
+
if (vErrors === null) {
|
|
1336
|
+
vErrors = [err24];
|
|
1337
|
+
} else {
|
|
1338
|
+
vErrors.push(err24);
|
|
1339
|
+
}
|
|
1340
|
+
errors++;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
} else {
|
|
1344
|
+
const err25 = { instancePath: instancePath + "/authors/" + i0, schemaPath: "#/properties/authors/items/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1345
|
+
if (vErrors === null) {
|
|
1346
|
+
vErrors = [err25];
|
|
1347
|
+
} else {
|
|
1348
|
+
vErrors.push(err25);
|
|
1349
|
+
}
|
|
1350
|
+
errors++;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
} else {
|
|
1354
|
+
const err26 = { instancePath: instancePath + "/authors", schemaPath: "#/properties/authors/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1355
|
+
if (vErrors === null) {
|
|
1356
|
+
vErrors = [err26];
|
|
1357
|
+
} else {
|
|
1358
|
+
vErrors.push(err26);
|
|
1359
|
+
}
|
|
1360
|
+
errors++;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
if (data.license !== void 0) {
|
|
1364
|
+
if (typeof data.license !== "string") {
|
|
1365
|
+
const err27 = { instancePath: instancePath + "/license", schemaPath: "#/properties/license/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1366
|
+
if (vErrors === null) {
|
|
1367
|
+
vErrors = [err27];
|
|
1368
|
+
} else {
|
|
1369
|
+
vErrors.push(err27);
|
|
1370
|
+
}
|
|
1371
|
+
errors++;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
if (data.presentation !== void 0) {
|
|
1375
|
+
let data15 = data.presentation;
|
|
1376
|
+
if (data15 && typeof data15 == "object" && !Array.isArray(data15)) {
|
|
1377
|
+
if (data15.basemap !== void 0) {
|
|
1378
|
+
let data16 = data15.basemap;
|
|
1379
|
+
if (!(data16 === "standard" || data16 === "historical" || data16 === "auto" || data16 === "none")) {
|
|
1380
|
+
const err28 = { instancePath: instancePath + "/presentation/basemap", schemaPath: "#/properties/presentation/properties/basemap/enum", keyword: "enum", params: { allowedValues: schema31.properties.presentation.properties.basemap.enum }, message: "must be equal to one of the allowed values" };
|
|
1381
|
+
if (vErrors === null) {
|
|
1382
|
+
vErrors = [err28];
|
|
1383
|
+
} else {
|
|
1384
|
+
vErrors.push(err28);
|
|
1385
|
+
}
|
|
1386
|
+
errors++;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
} else {
|
|
1390
|
+
const err29 = { instancePath: instancePath + "/presentation", schemaPath: "#/properties/presentation/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1391
|
+
if (vErrors === null) {
|
|
1392
|
+
vErrors = [err29];
|
|
1393
|
+
} else {
|
|
1394
|
+
vErrors.push(err29);
|
|
1395
|
+
}
|
|
1396
|
+
errors++;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
if (data.slides !== void 0) {
|
|
1400
|
+
let data17 = data.slides;
|
|
1401
|
+
if (Array.isArray(data17)) {
|
|
1402
|
+
if (data17.length < 1) {
|
|
1403
|
+
const err30 = { instancePath: instancePath + "/slides", schemaPath: "#/properties/slides/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
1404
|
+
if (vErrors === null) {
|
|
1405
|
+
vErrors = [err30];
|
|
1406
|
+
} else {
|
|
1407
|
+
vErrors.push(err30);
|
|
1408
|
+
}
|
|
1409
|
+
errors++;
|
|
1410
|
+
}
|
|
1411
|
+
const len1 = data17.length;
|
|
1412
|
+
for (let i1 = 0; i1 < len1; i1++) {
|
|
1413
|
+
if (!validate21(data17[i1], { instancePath: instancePath + "/slides/" + i1, parentData: data17, parentDataProperty: i1, rootData, dynamicAnchors })) {
|
|
1414
|
+
vErrors = vErrors === null ? validate21.errors : vErrors.concat(validate21.errors);
|
|
1415
|
+
errors = vErrors.length;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
} else {
|
|
1419
|
+
const err31 = { instancePath: instancePath + "/slides", schemaPath: "#/properties/slides/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1420
|
+
if (vErrors === null) {
|
|
1421
|
+
vErrors = [err31];
|
|
1422
|
+
} else {
|
|
1423
|
+
vErrors.push(err31);
|
|
1424
|
+
}
|
|
1425
|
+
errors++;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
if (data.media !== void 0) {
|
|
1429
|
+
let data19 = data.media;
|
|
1430
|
+
if (data19 && typeof data19 == "object" && !Array.isArray(data19)) {
|
|
1431
|
+
for (const key0 in data19) {
|
|
1432
|
+
const _errs38 = errors;
|
|
1433
|
+
if (typeof key0 === "string") {
|
|
1434
|
+
if (!pattern10.test(key0)) {
|
|
1435
|
+
const err32 = { instancePath: instancePath + "/media", schemaPath: "#/$defs/id/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]{1,64}$" }, message: 'must match pattern "^[A-Za-z0-9_-]{1,64}$"', propertyName: key0 };
|
|
1436
|
+
if (vErrors === null) {
|
|
1437
|
+
vErrors = [err32];
|
|
1438
|
+
} else {
|
|
1439
|
+
vErrors.push(err32);
|
|
1440
|
+
}
|
|
1441
|
+
errors++;
|
|
1442
|
+
}
|
|
1443
|
+
} else {
|
|
1444
|
+
const err33 = { instancePath: instancePath + "/media", schemaPath: "#/$defs/id/type", keyword: "type", params: { type: "string" }, message: "must be string", propertyName: key0 };
|
|
1445
|
+
if (vErrors === null) {
|
|
1446
|
+
vErrors = [err33];
|
|
1447
|
+
} else {
|
|
1448
|
+
vErrors.push(err33);
|
|
1449
|
+
}
|
|
1450
|
+
errors++;
|
|
1451
|
+
}
|
|
1452
|
+
var valid8 = _errs38 === errors;
|
|
1453
|
+
if (!valid8) {
|
|
1454
|
+
const err34 = { instancePath: instancePath + "/media", schemaPath: "#/properties/media/propertyNames", keyword: "propertyNames", params: { propertyName: key0 }, message: "property name must be valid" };
|
|
1455
|
+
if (vErrors === null) {
|
|
1456
|
+
vErrors = [err34];
|
|
1457
|
+
} else {
|
|
1458
|
+
vErrors.push(err34);
|
|
1459
|
+
}
|
|
1460
|
+
errors++;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
for (const key1 in data19) {
|
|
1464
|
+
let data20 = data19[key1];
|
|
1465
|
+
if (data20 && typeof data20 == "object" && !Array.isArray(data20)) {
|
|
1466
|
+
if (data20.src === void 0) {
|
|
1467
|
+
const err35 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/$defs/mediaItem/required", keyword: "required", params: { missingProperty: "src" }, message: "must have required property 'src'" };
|
|
1468
|
+
if (vErrors === null) {
|
|
1469
|
+
vErrors = [err35];
|
|
1470
|
+
} else {
|
|
1471
|
+
vErrors.push(err35);
|
|
1472
|
+
}
|
|
1473
|
+
errors++;
|
|
1474
|
+
}
|
|
1475
|
+
if (data20.mime === void 0) {
|
|
1476
|
+
const err36 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/$defs/mediaItem/required", keyword: "required", params: { missingProperty: "mime" }, message: "must have required property 'mime'" };
|
|
1477
|
+
if (vErrors === null) {
|
|
1478
|
+
vErrors = [err36];
|
|
1479
|
+
} else {
|
|
1480
|
+
vErrors.push(err36);
|
|
1481
|
+
}
|
|
1482
|
+
errors++;
|
|
1483
|
+
}
|
|
1484
|
+
if (data20.src !== void 0) {
|
|
1485
|
+
let data21 = data20.src;
|
|
1486
|
+
if (typeof data21 === "string") {
|
|
1487
|
+
if (!pattern19.test(data21)) {
|
|
1488
|
+
const err37 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/src", schemaPath: "#/$defs/mediaItem/properties/src/pattern", keyword: "pattern", params: { pattern: "^(?!/)(?!.*(^|/)\\.\\.?(/|$))[^\\\\]+$" }, message: 'must match pattern "^(?!/)(?!.*(^|/)\\.\\.?(/|$))[^\\\\]+$"' };
|
|
1489
|
+
if (vErrors === null) {
|
|
1490
|
+
vErrors = [err37];
|
|
1491
|
+
} else {
|
|
1492
|
+
vErrors.push(err37);
|
|
1493
|
+
}
|
|
1494
|
+
errors++;
|
|
1495
|
+
}
|
|
1496
|
+
} else {
|
|
1497
|
+
const err38 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/src", schemaPath: "#/$defs/mediaItem/properties/src/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1498
|
+
if (vErrors === null) {
|
|
1499
|
+
vErrors = [err38];
|
|
1500
|
+
} else {
|
|
1501
|
+
vErrors.push(err38);
|
|
1502
|
+
}
|
|
1503
|
+
errors++;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
if (data20.mime !== void 0) {
|
|
1507
|
+
let data22 = data20.mime;
|
|
1508
|
+
if (typeof data22 === "string") {
|
|
1509
|
+
if (!pattern20.test(data22)) {
|
|
1510
|
+
const err39 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/mime", schemaPath: "#/$defs/mediaItem/properties/mime/pattern", keyword: "pattern", params: { pattern: "^[a-z]+/[A-Za-z0-9.+-]+$" }, message: 'must match pattern "^[a-z]+/[A-Za-z0-9.+-]+$"' };
|
|
1511
|
+
if (vErrors === null) {
|
|
1512
|
+
vErrors = [err39];
|
|
1513
|
+
} else {
|
|
1514
|
+
vErrors.push(err39);
|
|
1515
|
+
}
|
|
1516
|
+
errors++;
|
|
1517
|
+
}
|
|
1518
|
+
} else {
|
|
1519
|
+
const err40 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/mime", schemaPath: "#/$defs/mediaItem/properties/mime/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1520
|
+
if (vErrors === null) {
|
|
1521
|
+
vErrors = [err40];
|
|
1522
|
+
} else {
|
|
1523
|
+
vErrors.push(err40);
|
|
1524
|
+
}
|
|
1525
|
+
errors++;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
if (data20.width !== void 0) {
|
|
1529
|
+
let data23 = data20.width;
|
|
1530
|
+
if (!(typeof data23 == "number" && (!(data23 % 1) && !isNaN(data23)) && isFinite(data23))) {
|
|
1531
|
+
const err41 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/width", schemaPath: "#/$defs/mediaItem/properties/width/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1532
|
+
if (vErrors === null) {
|
|
1533
|
+
vErrors = [err41];
|
|
1534
|
+
} else {
|
|
1535
|
+
vErrors.push(err41);
|
|
1536
|
+
}
|
|
1537
|
+
errors++;
|
|
1538
|
+
}
|
|
1539
|
+
if (typeof data23 == "number" && isFinite(data23)) {
|
|
1540
|
+
if (data23 < 1 || isNaN(data23)) {
|
|
1541
|
+
const err42 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/width", schemaPath: "#/$defs/mediaItem/properties/width/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
1542
|
+
if (vErrors === null) {
|
|
1543
|
+
vErrors = [err42];
|
|
1544
|
+
} else {
|
|
1545
|
+
vErrors.push(err42);
|
|
1546
|
+
}
|
|
1547
|
+
errors++;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
if (data20.height !== void 0) {
|
|
1552
|
+
let data24 = data20.height;
|
|
1553
|
+
if (!(typeof data24 == "number" && (!(data24 % 1) && !isNaN(data24)) && isFinite(data24))) {
|
|
1554
|
+
const err43 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/height", schemaPath: "#/$defs/mediaItem/properties/height/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1555
|
+
if (vErrors === null) {
|
|
1556
|
+
vErrors = [err43];
|
|
1557
|
+
} else {
|
|
1558
|
+
vErrors.push(err43);
|
|
1559
|
+
}
|
|
1560
|
+
errors++;
|
|
1561
|
+
}
|
|
1562
|
+
if (typeof data24 == "number" && isFinite(data24)) {
|
|
1563
|
+
if (data24 < 1 || isNaN(data24)) {
|
|
1564
|
+
const err44 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/height", schemaPath: "#/$defs/mediaItem/properties/height/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
1565
|
+
if (vErrors === null) {
|
|
1566
|
+
vErrors = [err44];
|
|
1567
|
+
} else {
|
|
1568
|
+
vErrors.push(err44);
|
|
1569
|
+
}
|
|
1570
|
+
errors++;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
if (data20.alt !== void 0) {
|
|
1575
|
+
if (typeof data20.alt !== "string") {
|
|
1576
|
+
const err45 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/alt", schemaPath: "#/$defs/mediaItem/properties/alt/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1577
|
+
if (vErrors === null) {
|
|
1578
|
+
vErrors = [err45];
|
|
1579
|
+
} else {
|
|
1580
|
+
vErrors.push(err45);
|
|
1581
|
+
}
|
|
1582
|
+
errors++;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
} else {
|
|
1586
|
+
const err46 = { instancePath: instancePath + "/media/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/$defs/mediaItem/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1587
|
+
if (vErrors === null) {
|
|
1588
|
+
vErrors = [err46];
|
|
1589
|
+
} else {
|
|
1590
|
+
vErrors.push(err46);
|
|
1591
|
+
}
|
|
1592
|
+
errors++;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
} else {
|
|
1596
|
+
const err47 = { instancePath: instancePath + "/media", schemaPath: "#/properties/media/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1597
|
+
if (vErrors === null) {
|
|
1598
|
+
vErrors = [err47];
|
|
1599
|
+
} else {
|
|
1600
|
+
vErrors.push(err47);
|
|
1601
|
+
}
|
|
1602
|
+
errors++;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
if (data.extensions !== void 0) {
|
|
1606
|
+
let data26 = data.extensions;
|
|
1607
|
+
if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
|
|
1608
|
+
for (const key2 in data26) {
|
|
1609
|
+
let data27 = data26[key2];
|
|
1610
|
+
if (!(data27 && typeof data27 == "object" && !Array.isArray(data27))) {
|
|
1611
|
+
const err48 = { instancePath: instancePath + "/extensions/" + key2.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/extensions/additionalProperties/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1612
|
+
if (vErrors === null) {
|
|
1613
|
+
vErrors = [err48];
|
|
1614
|
+
} else {
|
|
1615
|
+
vErrors.push(err48);
|
|
1616
|
+
}
|
|
1617
|
+
errors++;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
const err49 = { instancePath: instancePath + "/extensions", schemaPath: "#/properties/extensions/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1622
|
+
if (vErrors === null) {
|
|
1623
|
+
vErrors = [err49];
|
|
1624
|
+
} else {
|
|
1625
|
+
vErrors.push(err49);
|
|
1626
|
+
}
|
|
1627
|
+
errors++;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
} else {
|
|
1631
|
+
const err50 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1632
|
+
if (vErrors === null) {
|
|
1633
|
+
vErrors = [err50];
|
|
1634
|
+
} else {
|
|
1635
|
+
vErrors.push(err50);
|
|
1636
|
+
}
|
|
1637
|
+
errors++;
|
|
1638
|
+
}
|
|
1639
|
+
validate20.errors = vErrors;
|
|
1640
|
+
return errors === 0;
|
|
1641
|
+
}
|
|
1642
|
+
validate20.evaluated = { "props": { "$schema": true, "format": true, "version": true, "title": true, "language": true, "created": true, "generator": true, "authors": true, "license": true, "presentation": true, "slides": true, "media": true, "extensions": true }, "dynamicProps": false, "dynamicItems": false };
|
|
1643
|
+
|
|
1644
|
+
// src/version.ts
|
|
1645
|
+
var FORMAT_ID = "gramps-connect-story";
|
|
1646
|
+
var FORMAT_VERSION = "1.0";
|
|
1647
|
+
var CURRENT_MAJOR = 1;
|
|
1648
|
+
var UPGRADERS = {};
|
|
1649
|
+
var SUPPORTED_FORMAT_MAJORS = Object.freeze(
|
|
1650
|
+
Array.from({ length: CURRENT_MAJOR }, (_, i) => i + 1).filter(
|
|
1651
|
+
(major) => major === CURRENT_MAJOR || UPGRADERS[major] !== void 0
|
|
1652
|
+
)
|
|
1653
|
+
);
|
|
1654
|
+
function parseVersion(version) {
|
|
1655
|
+
if (typeof version !== "string") return null;
|
|
1656
|
+
const match = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.exec(version);
|
|
1657
|
+
if (!match) return null;
|
|
1658
|
+
return { major: Number(match[1]), minor: Number(match[2]) };
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// src/validate.ts
|
|
1662
|
+
var SCHEMA_MINOR = 0;
|
|
1663
|
+
function validate2(doc, files) {
|
|
1664
|
+
const errors = [];
|
|
1665
|
+
const warnings = [];
|
|
1666
|
+
if (!validate(doc)) {
|
|
1667
|
+
for (const err of validate.errors ?? []) {
|
|
1668
|
+
errors.push({ path: err.instancePath, message: describeSchemaError(err) });
|
|
1669
|
+
}
|
|
1670
|
+
return { valid: false, errors, warnings };
|
|
1671
|
+
}
|
|
1672
|
+
const story = doc;
|
|
1673
|
+
const slideIds = /* @__PURE__ */ new Set();
|
|
1674
|
+
const usedMedia2 = /* @__PURE__ */ new Set();
|
|
1675
|
+
const checkRef = (key, path) => {
|
|
1676
|
+
usedMedia2.add(key);
|
|
1677
|
+
if (!Object.prototype.hasOwnProperty.call(story.media, key)) {
|
|
1678
|
+
errors.push({ path, message: `refers to media "${key}", which isn't in "media".` });
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
story.slides.forEach((slide, i) => {
|
|
1682
|
+
if (slideIds.has(slide.id)) {
|
|
1683
|
+
errors.push({ path: `/slides/${i}/id`, message: `duplicate slide id "${slide.id}".` });
|
|
1684
|
+
}
|
|
1685
|
+
slideIds.add(slide.id);
|
|
1686
|
+
slide.media?.forEach((m, j) => checkRef(m.ref, `/slides/${i}/media/${j}/ref`));
|
|
1687
|
+
slide.place?.overlays?.forEach((o, j) => checkRef(o.media, `/slides/${i}/place/overlays/${j}/media`));
|
|
1688
|
+
});
|
|
1689
|
+
for (const [key, item] of Object.entries(story.media)) {
|
|
1690
|
+
const path = `/media/${escapePointer(key)}`;
|
|
1691
|
+
if (files && !files.has(item.src)) {
|
|
1692
|
+
errors.push({ path: `${path}/src`, message: `file "${item.src}" is not in the zip.` });
|
|
1693
|
+
}
|
|
1694
|
+
if (!usedMedia2.has(key)) {
|
|
1695
|
+
warnings.push({ path, message: `media "${key}" isn't used by any slide or overlay.` });
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
const version = parseVersion(story.version);
|
|
1699
|
+
if (version && version.major === CURRENT_MAJOR && version.minor <= SCHEMA_MINOR) {
|
|
1700
|
+
findUnknownFields(story, story_schema_default, "", warnings);
|
|
1701
|
+
}
|
|
1702
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
1703
|
+
}
|
|
1704
|
+
function describeSchemaError(err) {
|
|
1705
|
+
if (err.keyword === "pattern" && err.params.pattern === "\\S") return "must not be empty.";
|
|
1706
|
+
if (err.keyword === "required") return `is missing required field "${String(err.params.missingProperty)}".`;
|
|
1707
|
+
if (err.keyword === "const") return `must be ${JSON.stringify(err.params.allowedValue)}.`;
|
|
1708
|
+
if (err.keyword === "enum") return `must be one of ${err.params.allowedValues.map((v) => JSON.stringify(v)).join(", ")}.`;
|
|
1709
|
+
return `${err.message ?? "is invalid"}.`;
|
|
1710
|
+
}
|
|
1711
|
+
function escapePointer(key) {
|
|
1712
|
+
return key.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
1713
|
+
}
|
|
1714
|
+
function resolveRef(node, root) {
|
|
1715
|
+
if (!node.$ref) return node;
|
|
1716
|
+
const name = node.$ref.replace(/^#\/\$defs\//, "");
|
|
1717
|
+
return root.$defs[name];
|
|
1718
|
+
}
|
|
1719
|
+
function findUnknownFields(value, node, path, warnings, root = story_schema_default) {
|
|
1720
|
+
node = resolveRef(node, root);
|
|
1721
|
+
if (Array.isArray(value)) {
|
|
1722
|
+
value.forEach((item, i) => {
|
|
1723
|
+
const itemNode = node.prefixItems?.[i] ?? node.items;
|
|
1724
|
+
if (itemNode) findUnknownFields(item, itemNode, `${path}/${i}`, warnings, root);
|
|
1725
|
+
});
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
if (typeof value !== "object" || value === null) return;
|
|
1729
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1730
|
+
const childPath = `${path}/${escapePointer(key)}`;
|
|
1731
|
+
const known = node.properties?.[key];
|
|
1732
|
+
if (known) {
|
|
1733
|
+
findUnknownFields(child, known, childPath, warnings, root);
|
|
1734
|
+
} else if (typeof node.additionalProperties === "object") {
|
|
1735
|
+
findUnknownFields(child, node.additionalProperties, childPath, warnings, root);
|
|
1736
|
+
} else if (node.properties && node.additionalProperties !== true) {
|
|
1737
|
+
warnings.push({ path: childPath, message: `unknown field "${key}" (ignored).` });
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
// src/player/StoryPlayer.tsx
|
|
1743
|
+
import { useEffect as useEffect3, useMemo, useRef as useRef3, useState as useState3 } from "react";
|
|
1744
|
+
|
|
1745
|
+
// src/player/dates.ts
|
|
1746
|
+
var DATE = /^(-?\d{4})(?:-(\d{2}|XX))?(?:-(\d{2}|XX))?[~?%]?$/;
|
|
1747
|
+
function yearOf(part) {
|
|
1748
|
+
const match = DATE.exec(part.trim());
|
|
1749
|
+
return match ? Number(match[1]) : null;
|
|
1750
|
+
}
|
|
1751
|
+
function edtfYearRange(edtf) {
|
|
1752
|
+
if (!edtf) return null;
|
|
1753
|
+
const value = edtf.trim();
|
|
1754
|
+
const set = /^\[(.+)\.\.(.+)\]$/.exec(value);
|
|
1755
|
+
if (set) {
|
|
1756
|
+
const min = yearOf(set[1]);
|
|
1757
|
+
const max = yearOf(set[2]);
|
|
1758
|
+
return min !== null && max !== null ? { min: Math.min(min, max), max: Math.max(min, max) } : null;
|
|
1759
|
+
}
|
|
1760
|
+
if (value.includes("/")) {
|
|
1761
|
+
const [startText, endText] = value.split("/");
|
|
1762
|
+
const openStart = startText === ".." || startText === "";
|
|
1763
|
+
const openEnd = endText === ".." || endText === "";
|
|
1764
|
+
const start = openStart ? void 0 : yearOf(startText);
|
|
1765
|
+
const end = openEnd ? void 0 : yearOf(endText);
|
|
1766
|
+
if (start === null || end === null) return null;
|
|
1767
|
+
if (start === void 0 && end === void 0) return null;
|
|
1768
|
+
if (start !== void 0 && end !== void 0) return { min: Math.min(start, end), max: Math.max(start, end) };
|
|
1769
|
+
return { min: start, max: end };
|
|
1770
|
+
}
|
|
1771
|
+
const year = yearOf(value);
|
|
1772
|
+
return year === null ? null : { min: year, max: year };
|
|
1773
|
+
}
|
|
1774
|
+
function dateCoversYear(date, year) {
|
|
1775
|
+
if (!date || year === null) return true;
|
|
1776
|
+
const range = edtfYearRange(date.edtf);
|
|
1777
|
+
if (!range) return true;
|
|
1778
|
+
if (range.min !== void 0 && year < range.min) return false;
|
|
1779
|
+
if (range.max !== void 0 && year > range.max) return false;
|
|
1780
|
+
return true;
|
|
1781
|
+
}
|
|
1782
|
+
function timelineYear(date) {
|
|
1783
|
+
if (!date) return null;
|
|
1784
|
+
const match = date.edtf ? DATE.exec(date.edtf.trim()) : null;
|
|
1785
|
+
const sortYear = date.sortYear ?? (match ? Number(match[1]) : void 0);
|
|
1786
|
+
if (sortYear === void 0) return null;
|
|
1787
|
+
if (!match || Number(match[1]) !== sortYear) return sortYear;
|
|
1788
|
+
const month = match[2] && match[2] !== "XX" ? Number(match[2]) : 0;
|
|
1789
|
+
const day = match[3] && match[3] !== "XX" ? Number(match[3]) : 0;
|
|
1790
|
+
if (!month) return sortYear;
|
|
1791
|
+
return sortYear + (month - 1) / 12 + (day ? (day - 1) / 365 : 0);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
// src/player/geo.ts
|
|
1795
|
+
function visit(coords, bounds) {
|
|
1796
|
+
if (!Array.isArray(coords)) return;
|
|
1797
|
+
if (coords.length >= 2 && typeof coords[0] === "number" && typeof coords[1] === "number") {
|
|
1798
|
+
const [lon, lat] = coords;
|
|
1799
|
+
bounds[0] = Math.min(bounds[0], lon);
|
|
1800
|
+
bounds[1] = Math.min(bounds[1], lat);
|
|
1801
|
+
bounds[2] = Math.max(bounds[2], lon);
|
|
1802
|
+
bounds[3] = Math.max(bounds[3], lat);
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
for (const child of coords) visit(child, bounds);
|
|
1806
|
+
}
|
|
1807
|
+
function visitGeoJson(node, bounds) {
|
|
1808
|
+
if (!node || typeof node !== "object") return;
|
|
1809
|
+
const obj = node;
|
|
1810
|
+
if (obj.coordinates !== void 0) visit(obj.coordinates, bounds);
|
|
1811
|
+
if (obj.geometry) visitGeoJson(obj.geometry, bounds);
|
|
1812
|
+
for (const g of obj.geometries ?? []) visitGeoJson(g, bounds);
|
|
1813
|
+
for (const f of obj.features ?? []) visitGeoJson(f, bounds);
|
|
1814
|
+
}
|
|
1815
|
+
function placeBounds(place) {
|
|
1816
|
+
if (!place) return null;
|
|
1817
|
+
const bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
1818
|
+
visitGeoJson(place.geometry, bounds);
|
|
1819
|
+
for (const overlay of place.overlays ?? []) visit(overlay.corners, bounds);
|
|
1820
|
+
return Number.isFinite(bounds[0]) ? bounds : null;
|
|
1821
|
+
}
|
|
1822
|
+
function placeCenter(place) {
|
|
1823
|
+
if (place?.lat !== void 0 && place.lon !== void 0) return [place.lon, place.lat];
|
|
1824
|
+
const bounds = placeBounds(place);
|
|
1825
|
+
return bounds ? [(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2] : null;
|
|
1826
|
+
}
|
|
1827
|
+
function storyPlaces(places) {
|
|
1828
|
+
const bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
1829
|
+
const points = /* @__PURE__ */ new Map();
|
|
1830
|
+
for (const place of places) {
|
|
1831
|
+
const center = placeCenter(place);
|
|
1832
|
+
if (!center) continue;
|
|
1833
|
+
points.set(`${center[0].toFixed(5)},${center[1].toFixed(5)}`, center);
|
|
1834
|
+
visit(center, bounds);
|
|
1835
|
+
const box = placeBounds(place);
|
|
1836
|
+
if (box) visit([[box[0], box[1]], [box[2], box[3]]], bounds);
|
|
1837
|
+
}
|
|
1838
|
+
return points.size ? { points: [...points.values()], bounds } : null;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
// src/player/MapBackground.tsx
|
|
1842
|
+
import { useEffect, useRef, useState } from "react";
|
|
1843
|
+
import * as maplibregl from "maplibre-gl";
|
|
1844
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
1845
|
+
|
|
1846
|
+
// src/player/mapStyles.ts
|
|
1847
|
+
import { filterByDate } from "@openhistoricalmap/maplibre-gl-dates";
|
|
1848
|
+
var STYLE_LIGHT = "https://tiles.openfreemap.org/styles/liberty";
|
|
1849
|
+
var STYLE_DARK = "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json";
|
|
1850
|
+
var OHM_STYLE = "https://www.openhistoricalmap.org/map-styles/main/main.json";
|
|
1851
|
+
function mapStyleKey(dark, ohmYear) {
|
|
1852
|
+
return ohmYear != null ? "ohm" : dark ? "dark" : "light";
|
|
1853
|
+
}
|
|
1854
|
+
function mapStyleUrl(dark, ohmYear) {
|
|
1855
|
+
return ohmYear != null ? OHM_STYLE : dark ? STYLE_DARK : STYLE_LIGHT;
|
|
1856
|
+
}
|
|
1857
|
+
function crossfadeStyleSwap(map, styleUrl, beforeSwap, duration = 300) {
|
|
1858
|
+
const container = map.getContainer();
|
|
1859
|
+
if (!container.style.zIndex) container.style.zIndex = "0";
|
|
1860
|
+
let snapshotUrl = null;
|
|
1861
|
+
try {
|
|
1862
|
+
snapshotUrl = map.getCanvas().toDataURL("image/png");
|
|
1863
|
+
} catch {
|
|
1864
|
+
}
|
|
1865
|
+
beforeSwap();
|
|
1866
|
+
map.setStyle(styleUrl);
|
|
1867
|
+
if (!snapshotUrl) return;
|
|
1868
|
+
const overlay = document.createElement("img");
|
|
1869
|
+
overlay.src = snapshotUrl;
|
|
1870
|
+
overlay.alt = "";
|
|
1871
|
+
Object.assign(overlay.style, {
|
|
1872
|
+
position: "absolute",
|
|
1873
|
+
inset: "0",
|
|
1874
|
+
width: "100%",
|
|
1875
|
+
height: "100%",
|
|
1876
|
+
zIndex: "5",
|
|
1877
|
+
pointerEvents: "none",
|
|
1878
|
+
transition: `opacity ${duration}ms ease`
|
|
1879
|
+
});
|
|
1880
|
+
container.appendChild(overlay);
|
|
1881
|
+
map.once("idle", () => {
|
|
1882
|
+
requestAnimationFrame(() => {
|
|
1883
|
+
overlay.style.opacity = "0";
|
|
1884
|
+
});
|
|
1885
|
+
window.setTimeout(() => overlay.remove(), duration + 50);
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
function applyOhmYear(map, year) {
|
|
1889
|
+
filterByDate(map, String(Math.round(year)));
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// src/player/theme.ts
|
|
1893
|
+
function defaultColors(dark) {
|
|
1894
|
+
return dark ? { surface: "#242424", text: "#c9c9c9", muted: "#828282", border: "#424242", mark: "#3987e5", panel: "rgb(20,20,20)" } : { surface: "#ffffff", text: "#000000", muted: "#868e96", border: "#dee2e6", mark: "#2a78d6", panel: "rgb(255,255,255)" };
|
|
1895
|
+
}
|
|
1896
|
+
var PIN_PATH_D = "M12 0C7.03 0 3 4.03 3 9c0 6.25 9 15 9 15s9-8.75 9-15c0-4.97-4.03-9-9-9z";
|
|
1897
|
+
|
|
1898
|
+
// src/player/MapBackground.tsx
|
|
1899
|
+
import { jsx } from "react/jsx-runtime";
|
|
1900
|
+
var SHAPE_SOURCE = "story-shape";
|
|
1901
|
+
var FILL_LAYER = "story-shape-fill";
|
|
1902
|
+
var LINE_LAYER = "story-shape-line";
|
|
1903
|
+
var POINT_LAYER = "story-shape-points";
|
|
1904
|
+
var LABEL_LAYER = "story-shape-labels";
|
|
1905
|
+
var OVERLAY_PREFIX = "story-overlay-";
|
|
1906
|
+
var PLACES_SOURCE = "story-places";
|
|
1907
|
+
var PLACES_LAYER = "story-places-dots";
|
|
1908
|
+
var OVERVIEW_PADDING = 60;
|
|
1909
|
+
var EMPTY = { type: "FeatureCollection", features: [] };
|
|
1910
|
+
function moveCamera(map, slide, duration) {
|
|
1911
|
+
if (slide.overview) {
|
|
1912
|
+
const [west, south, east, north] = slide.overview.bounds;
|
|
1913
|
+
map.fitBounds([[west, south], [east, north]], { maxZoom: 9, padding: OVERVIEW_PADDING, duration });
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
const place = slide.place;
|
|
1917
|
+
const bounds = placeBounds(place);
|
|
1918
|
+
if (bounds) {
|
|
1919
|
+
map.fitBounds([[bounds[0], bounds[1]], [bounds[2], bounds[3]]], { maxZoom: 17, duration });
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
const center = placeCenter(place);
|
|
1923
|
+
if (center) map.flyTo({ center, zoom: 9, essential: true, duration });
|
|
1924
|
+
}
|
|
1925
|
+
function placeMarker(marker, slide) {
|
|
1926
|
+
if (!marker) return;
|
|
1927
|
+
const center = placeCenter(slide.place);
|
|
1928
|
+
if (center) marker.setLngLat(center);
|
|
1929
|
+
marker.setOpacity(slide.overview ? 0 : center ? 1 : 0.4);
|
|
1930
|
+
}
|
|
1931
|
+
var placeDots = (overview) => ({
|
|
1932
|
+
type: "FeatureCollection",
|
|
1933
|
+
features: (overview?.points ?? []).map((coordinates) => ({
|
|
1934
|
+
type: "Feature",
|
|
1935
|
+
properties: {},
|
|
1936
|
+
geometry: { type: "Point", coordinates }
|
|
1937
|
+
}))
|
|
1938
|
+
});
|
|
1939
|
+
function MapBackground({ initialCenter, current, dark, colors, panelFraction, ohmYear, resolveMedia }) {
|
|
1940
|
+
const [containerEl, setContainerEl] = useState(null);
|
|
1941
|
+
const mapRef = useRef(null);
|
|
1942
|
+
const markerRef = useRef(null);
|
|
1943
|
+
const [ready, setReady] = useState(false);
|
|
1944
|
+
const darkRef = useRef(dark);
|
|
1945
|
+
darkRef.current = dark;
|
|
1946
|
+
const ohmYearRef = useRef(ohmYear);
|
|
1947
|
+
ohmYearRef.current = ohmYear;
|
|
1948
|
+
const colorsRef = useRef(colors);
|
|
1949
|
+
colorsRef.current = colors;
|
|
1950
|
+
const overlayDatesRef = useRef(/* @__PURE__ */ new Map());
|
|
1951
|
+
const appliedStyleKeyRef = useRef(mapStyleKey(dark, ohmYear));
|
|
1952
|
+
const currentRef = useRef(current);
|
|
1953
|
+
currentRef.current = current;
|
|
1954
|
+
useEffect(() => {
|
|
1955
|
+
if (!containerEl) return;
|
|
1956
|
+
setReady(false);
|
|
1957
|
+
appliedStyleKeyRef.current = mapStyleKey(darkRef.current, ohmYearRef.current);
|
|
1958
|
+
const map = new maplibregl.Map({
|
|
1959
|
+
container: containerEl,
|
|
1960
|
+
style: mapStyleUrl(darkRef.current, ohmYearRef.current),
|
|
1961
|
+
zoom: 5,
|
|
1962
|
+
attributionControl: { compact: true },
|
|
1963
|
+
// So crossfadeStyleSwap's snapshot has the last frame in it.
|
|
1964
|
+
canvasContextAttributes: { preserveDrawingBuffer: true }
|
|
1965
|
+
});
|
|
1966
|
+
mapRef.current = map;
|
|
1967
|
+
map.on("style.load", () => setReady(true));
|
|
1968
|
+
map.setPadding({ top: 0, bottom: 0, left: 0, right: containerEl.clientWidth * panelFraction });
|
|
1969
|
+
const start = currentRef.current;
|
|
1970
|
+
map.jumpTo({ center: placeCenter(start.place) ?? initialCenter });
|
|
1971
|
+
moveCamera(map, start, 0);
|
|
1972
|
+
map.on("load", () => {
|
|
1973
|
+
const c = colorsRef.current;
|
|
1974
|
+
const el = document.createElement("div");
|
|
1975
|
+
el.style.width = "26px";
|
|
1976
|
+
el.style.height = "26px";
|
|
1977
|
+
el.style.transition = "opacity 300ms";
|
|
1978
|
+
el.innerHTML = `<svg viewBox="0 0 24 24" width="26" height="26"><path d="${PIN_PATH_D}" fill="${c.mark}" stroke="${c.surface}" stroke-width="1.5" /></svg>`;
|
|
1979
|
+
markerRef.current = new maplibregl.Marker({ element: el, anchor: "bottom" }).setLngLat(initialCenter).addTo(map);
|
|
1980
|
+
placeMarker(markerRef.current, currentRef.current);
|
|
1981
|
+
});
|
|
1982
|
+
return () => {
|
|
1983
|
+
markerRef.current?.remove();
|
|
1984
|
+
markerRef.current = null;
|
|
1985
|
+
map.remove();
|
|
1986
|
+
mapRef.current = null;
|
|
1987
|
+
};
|
|
1988
|
+
}, [containerEl]);
|
|
1989
|
+
useEffect(() => {
|
|
1990
|
+
const map = mapRef.current;
|
|
1991
|
+
const key = mapStyleKey(dark, ohmYear);
|
|
1992
|
+
if (!map || appliedStyleKeyRef.current === key) return;
|
|
1993
|
+
appliedStyleKeyRef.current = key;
|
|
1994
|
+
crossfadeStyleSwap(map, mapStyleUrl(dark, ohmYear), () => setReady(false));
|
|
1995
|
+
}, [dark, ohmYear]);
|
|
1996
|
+
useEffect(() => {
|
|
1997
|
+
const map = mapRef.current;
|
|
1998
|
+
if (!map || !ready || ohmYear == null) return;
|
|
1999
|
+
applyOhmYear(map, ohmYear);
|
|
2000
|
+
}, [ready, ohmYear]);
|
|
2001
|
+
useEffect(() => {
|
|
2002
|
+
const map = mapRef.current;
|
|
2003
|
+
if (!map || !ready || map.getSource(SHAPE_SOURCE)) return;
|
|
2004
|
+
const c = colorsRef.current;
|
|
2005
|
+
map.addSource(SHAPE_SOURCE, { type: "geojson", data: EMPTY });
|
|
2006
|
+
const color = ["coalesce", ["get", "color"], c.mark];
|
|
2007
|
+
map.addLayer({
|
|
2008
|
+
id: FILL_LAYER,
|
|
2009
|
+
type: "fill",
|
|
2010
|
+
source: SHAPE_SOURCE,
|
|
2011
|
+
filter: ["==", ["geometry-type"], "Polygon"],
|
|
2012
|
+
paint: { "fill-color": color, "fill-opacity": 0.25 }
|
|
2013
|
+
});
|
|
2014
|
+
map.addLayer({
|
|
2015
|
+
id: LINE_LAYER,
|
|
2016
|
+
type: "line",
|
|
2017
|
+
source: SHAPE_SOURCE,
|
|
2018
|
+
filter: ["any", ["==", ["geometry-type"], "Polygon"], ["==", ["geometry-type"], "LineString"]],
|
|
2019
|
+
paint: { "line-color": color, "line-width": 2 }
|
|
2020
|
+
});
|
|
2021
|
+
map.addLayer({
|
|
2022
|
+
id: POINT_LAYER,
|
|
2023
|
+
type: "circle",
|
|
2024
|
+
source: SHAPE_SOURCE,
|
|
2025
|
+
// A named point is a label (next layer), drawn as text only.
|
|
2026
|
+
filter: ["all", ["==", ["geometry-type"], "Point"], ["!", ["has", "name"]]],
|
|
2027
|
+
paint: { "circle-radius": 5, "circle-color": color, "circle-stroke-width": 1, "circle-stroke-color": c.surface }
|
|
2028
|
+
});
|
|
2029
|
+
map.addLayer({
|
|
2030
|
+
id: LABEL_LAYER,
|
|
2031
|
+
type: "symbol",
|
|
2032
|
+
source: SHAPE_SOURCE,
|
|
2033
|
+
filter: ["all", ["==", ["geometry-type"], "Point"], ["has", "name"]],
|
|
2034
|
+
layout: {
|
|
2035
|
+
"text-field": ["get", "name"],
|
|
2036
|
+
"text-size": 12,
|
|
2037
|
+
"text-font": ["Noto Sans Regular"],
|
|
2038
|
+
"text-anchor": "left",
|
|
2039
|
+
"text-offset": [0.6, 0]
|
|
2040
|
+
},
|
|
2041
|
+
paint: {
|
|
2042
|
+
"text-color": ["coalesce", ["get", "color"], c.text],
|
|
2043
|
+
"text-halo-color": c.surface,
|
|
2044
|
+
"text-halo-width": 1.5
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
map.addSource(PLACES_SOURCE, { type: "geojson", data: EMPTY });
|
|
2048
|
+
map.addLayer({
|
|
2049
|
+
id: PLACES_LAYER,
|
|
2050
|
+
type: "circle",
|
|
2051
|
+
source: PLACES_SOURCE,
|
|
2052
|
+
paint: { "circle-radius": 6, "circle-color": c.mark, "circle-stroke-width": 2, "circle-stroke-color": c.surface }
|
|
2053
|
+
});
|
|
2054
|
+
}, [ready]);
|
|
2055
|
+
const place = current.place;
|
|
2056
|
+
useEffect(() => {
|
|
2057
|
+
const map = mapRef.current;
|
|
2058
|
+
if (!map || !ready) return;
|
|
2059
|
+
const source = map.getSource(SHAPE_SOURCE);
|
|
2060
|
+
source?.setData(place?.geometry ?? EMPTY);
|
|
2061
|
+
const dots = map.getSource(PLACES_SOURCE);
|
|
2062
|
+
dots?.setData(placeDots(current.overview));
|
|
2063
|
+
}, [ready, current.key, place, current.overview]);
|
|
2064
|
+
useEffect(() => {
|
|
2065
|
+
const map = mapRef.current;
|
|
2066
|
+
if (!map) return;
|
|
2067
|
+
placeMarker(markerRef.current, current);
|
|
2068
|
+
moveCamera(map, current, 900);
|
|
2069
|
+
}, [current.key]);
|
|
2070
|
+
const overlayKey = JSON.stringify(place?.overlays ?? []);
|
|
2071
|
+
useEffect(() => {
|
|
2072
|
+
const map = mapRef.current;
|
|
2073
|
+
const overlays = place?.overlays ?? [];
|
|
2074
|
+
if (!map || !ready || overlays.length === 0) return;
|
|
2075
|
+
let cancelled = false;
|
|
2076
|
+
const added = [];
|
|
2077
|
+
(async () => {
|
|
2078
|
+
const sorted = overlays.map((overlay, i) => ({ overlay, i })).sort((a, b) => (a.overlay.order ?? a.i) - (b.overlay.order ?? b.i));
|
|
2079
|
+
for (const { overlay, i } of sorted) {
|
|
2080
|
+
const url = await resolveMedia(overlay.media);
|
|
2081
|
+
if (cancelled) return;
|
|
2082
|
+
if (!url) continue;
|
|
2083
|
+
const id = `${OVERLAY_PREFIX}${i}`;
|
|
2084
|
+
if (map.getSource(id)) continue;
|
|
2085
|
+
map.addSource(id, { type: "image", url, coordinates: overlay.corners });
|
|
2086
|
+
map.addLayer({ id, type: "raster", source: id }, FILL_LAYER);
|
|
2087
|
+
map.setPaintProperty(id, "raster-opacity", overlay.opacity ?? 1);
|
|
2088
|
+
overlayDatesRef.current.set(id, overlay.date);
|
|
2089
|
+
map.setLayoutProperty(id, "visibility", dateCoversYear(overlay.date, ohmYearRef.current) ? "visible" : "none");
|
|
2090
|
+
added.push(id);
|
|
2091
|
+
}
|
|
2092
|
+
})();
|
|
2093
|
+
return () => {
|
|
2094
|
+
cancelled = true;
|
|
2095
|
+
for (const id of added) {
|
|
2096
|
+
overlayDatesRef.current.delete(id);
|
|
2097
|
+
if (map.getLayer(id)) map.removeLayer(id);
|
|
2098
|
+
if (map.getSource(id)) map.removeSource(id);
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
}, [overlayKey, ready]);
|
|
2102
|
+
useEffect(() => {
|
|
2103
|
+
const map = mapRef.current;
|
|
2104
|
+
if (!map || !ready) return;
|
|
2105
|
+
for (const [id, date] of overlayDatesRef.current) {
|
|
2106
|
+
if (!map.getLayer(id)) continue;
|
|
2107
|
+
map.setLayoutProperty(id, "visibility", dateCoversYear(date, ohmYear) ? "visible" : "none");
|
|
2108
|
+
}
|
|
2109
|
+
}, [ohmYear, ready]);
|
|
2110
|
+
return /* @__PURE__ */ jsx("div", { ref: setContainerEl, style: { position: "absolute", inset: 0 } });
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
// src/player/MapModeControl.tsx
|
|
2114
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2115
|
+
function MapModeControl({ mode, onModeChange, autoYear, year, onYearChange, yearBounds, strings, colors }) {
|
|
2116
|
+
const modes = [["auto", strings.auto], ["standard", strings.standard], ["historical", strings.historical]];
|
|
2117
|
+
const font = { fontSize: 12, fontFamily: "inherit" };
|
|
2118
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10, whiteSpace: "nowrap" }, children: [
|
|
2119
|
+
/* @__PURE__ */ jsx2("div", { role: "radiogroup", "aria-label": strings.mapMode, style: { display: "flex", border: `1px solid ${colors.border}`, borderRadius: 6, overflow: "hidden", background: colors.surface }, children: modes.map(([value, label]) => /* @__PURE__ */ jsx2(
|
|
2120
|
+
"button",
|
|
2121
|
+
{
|
|
2122
|
+
type: "button",
|
|
2123
|
+
role: "radio",
|
|
2124
|
+
"aria-checked": mode === value,
|
|
2125
|
+
onClick: () => onModeChange(value),
|
|
2126
|
+
style: {
|
|
2127
|
+
...font,
|
|
2128
|
+
padding: "4px 10px",
|
|
2129
|
+
border: "none",
|
|
2130
|
+
cursor: "pointer",
|
|
2131
|
+
background: mode === value ? colors.mark : "transparent",
|
|
2132
|
+
color: mode === value ? "#ffffff" : colors.text
|
|
2133
|
+
},
|
|
2134
|
+
children: label
|
|
2135
|
+
},
|
|
2136
|
+
value
|
|
2137
|
+
)) }),
|
|
2138
|
+
mode === "auto" && /* @__PURE__ */ jsx2("span", { style: { ...font, color: colors.muted }, children: autoYear != null ? strings.historicalMapYear(autoYear) : strings.noDateStandardMap }),
|
|
2139
|
+
mode === "historical" && /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
2140
|
+
/* @__PURE__ */ jsx2(
|
|
2141
|
+
"input",
|
|
2142
|
+
{
|
|
2143
|
+
type: "range",
|
|
2144
|
+
min: yearBounds[0],
|
|
2145
|
+
max: yearBounds[1],
|
|
2146
|
+
step: 1,
|
|
2147
|
+
value: year,
|
|
2148
|
+
onChange: (e) => onYearChange(Number(e.currentTarget.value)),
|
|
2149
|
+
"aria-label": strings.historicalYear,
|
|
2150
|
+
style: { width: 150, accentColor: colors.mark }
|
|
2151
|
+
}
|
|
2152
|
+
),
|
|
2153
|
+
/* @__PURE__ */ jsx2(
|
|
2154
|
+
"input",
|
|
2155
|
+
{
|
|
2156
|
+
type: "number",
|
|
2157
|
+
min: yearBounds[0],
|
|
2158
|
+
max: yearBounds[1],
|
|
2159
|
+
step: 1,
|
|
2160
|
+
value: year,
|
|
2161
|
+
onChange: (e) => {
|
|
2162
|
+
const value = Number(e.currentTarget.value);
|
|
2163
|
+
if (Number.isFinite(value) && e.currentTarget.value !== "") onYearChange(Math.round(value));
|
|
2164
|
+
},
|
|
2165
|
+
"aria-label": strings.historicalYear,
|
|
2166
|
+
style: { ...font, width: 70, padding: "3px 4px", border: `1px solid ${colors.border}`, borderRadius: 4, background: colors.surface, color: colors.text }
|
|
2167
|
+
}
|
|
2168
|
+
)
|
|
2169
|
+
] })
|
|
2170
|
+
] });
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
// src/player/text.ts
|
|
2174
|
+
var MARKERS = /\*\*([^\n]+?)\*\*|\*([^\n]+?)\*/g;
|
|
2175
|
+
function parseLine(line) {
|
|
2176
|
+
const spans = [];
|
|
2177
|
+
let last = 0;
|
|
2178
|
+
for (const match of line.matchAll(MARKERS)) {
|
|
2179
|
+
const index = match.index ?? 0;
|
|
2180
|
+
if (index > last) spans.push({ text: line.slice(last, index) });
|
|
2181
|
+
if (match[1] !== void 0) spans.push({ text: match[1], bold: true });
|
|
2182
|
+
else spans.push({ text: match[2], italic: true });
|
|
2183
|
+
last = index + match[0].length;
|
|
2184
|
+
}
|
|
2185
|
+
if (last < line.length) spans.push({ text: line.slice(last) });
|
|
2186
|
+
return spans;
|
|
2187
|
+
}
|
|
2188
|
+
function parseStoryText(text) {
|
|
2189
|
+
return text.replace(/\r\n?/g, "\n").split(/\n[ \t]*\n+/).map((paragraph) => paragraph.replace(/^\n+|\n+$/g, "")).filter((paragraph) => paragraph.length > 0).map((paragraph) => paragraph.split("\n").map(parseLine));
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
// src/player/strings.ts
|
|
2193
|
+
var ENGLISH = {
|
|
2194
|
+
previous: "Previous",
|
|
2195
|
+
next: "Next",
|
|
2196
|
+
close: "Close",
|
|
2197
|
+
mapMode: "Map",
|
|
2198
|
+
auto: "Auto",
|
|
2199
|
+
standard: "Standard",
|
|
2200
|
+
historical: "Historical",
|
|
2201
|
+
historicalMapYear: (year) => `Historical map, ${year}`,
|
|
2202
|
+
noDateStandardMap: "No date here \u2014 standard map",
|
|
2203
|
+
historicalYear: "Historical map year"
|
|
2204
|
+
};
|
|
2205
|
+
var TABLE = {
|
|
2206
|
+
en: ENGLISH,
|
|
2207
|
+
de: {
|
|
2208
|
+
previous: "Zur\xFCck",
|
|
2209
|
+
next: "Weiter",
|
|
2210
|
+
close: "Schlie\xDFen",
|
|
2211
|
+
mapMode: "Karte",
|
|
2212
|
+
auto: "Automatisch",
|
|
2213
|
+
standard: "Standard",
|
|
2214
|
+
historical: "Historisch",
|
|
2215
|
+
historicalMapYear: (year) => `Historische Karte, ${year}`,
|
|
2216
|
+
noDateStandardMap: "Kein Datum hier \u2014 Standardkarte",
|
|
2217
|
+
historicalYear: "Jahr der historischen Karte"
|
|
2218
|
+
},
|
|
2219
|
+
es: {
|
|
2220
|
+
previous: "Anterior",
|
|
2221
|
+
next: "Siguiente",
|
|
2222
|
+
close: "Cerrar",
|
|
2223
|
+
mapMode: "Mapa",
|
|
2224
|
+
auto: "Autom\xE1tico",
|
|
2225
|
+
standard: "Est\xE1ndar",
|
|
2226
|
+
historical: "Hist\xF3rico",
|
|
2227
|
+
historicalMapYear: (year) => `Mapa hist\xF3rico, ${year}`,
|
|
2228
|
+
noDateStandardMap: "Sin fecha aqu\xED \u2014 mapa est\xE1ndar",
|
|
2229
|
+
historicalYear: "A\xF1o del mapa hist\xF3rico"
|
|
2230
|
+
},
|
|
2231
|
+
fr: {
|
|
2232
|
+
previous: "Pr\xE9c\xE9dent",
|
|
2233
|
+
next: "Suivant",
|
|
2234
|
+
close: "Fermer",
|
|
2235
|
+
mapMode: "Carte",
|
|
2236
|
+
auto: "Auto",
|
|
2237
|
+
standard: "Standard",
|
|
2238
|
+
historical: "Historique",
|
|
2239
|
+
historicalMapYear: (year) => `Carte historique, ${year}`,
|
|
2240
|
+
noDateStandardMap: "Pas de date ici \u2014 carte standard",
|
|
2241
|
+
historicalYear: "Ann\xE9e de la carte historique"
|
|
2242
|
+
},
|
|
2243
|
+
nl: {
|
|
2244
|
+
previous: "Vorige",
|
|
2245
|
+
next: "Volgende",
|
|
2246
|
+
close: "Sluiten",
|
|
2247
|
+
mapMode: "Kaart",
|
|
2248
|
+
auto: "Automatisch",
|
|
2249
|
+
standard: "Standaard",
|
|
2250
|
+
historical: "Historisch",
|
|
2251
|
+
historicalMapYear: (year) => `Historische kaart, ${year}`,
|
|
2252
|
+
noDateStandardMap: "Geen datum hier \u2014 standaardkaart",
|
|
2253
|
+
historicalYear: "Jaar van de historische kaart"
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
function stringsFor(...languages) {
|
|
2257
|
+
for (const tag of languages) {
|
|
2258
|
+
const base = tag?.toLowerCase().split(/[-_]/)[0];
|
|
2259
|
+
if (base && TABLE[base]) return TABLE[base];
|
|
2260
|
+
}
|
|
2261
|
+
return ENGLISH;
|
|
2262
|
+
}
|
|
2263
|
+
var PLAYER_LANGUAGES = Object.keys(TABLE);
|
|
2264
|
+
|
|
2265
|
+
// src/player/TimelineStrip.tsx
|
|
2266
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
2267
|
+
|
|
2268
|
+
// src/player/timelineLayout.ts
|
|
2269
|
+
function storyDomain(years) {
|
|
2270
|
+
const min = Math.min(...years);
|
|
2271
|
+
const max = Math.max(...years);
|
|
2272
|
+
if (max - min < 1) return [min - 5, min + 5];
|
|
2273
|
+
const padding = (max - min) * 0.05;
|
|
2274
|
+
return [min - padding, max + padding];
|
|
2275
|
+
}
|
|
2276
|
+
function xForYear(year, domain, width) {
|
|
2277
|
+
const [start, end] = domain;
|
|
2278
|
+
const span = end - start;
|
|
2279
|
+
if (!(span > 0)) return width / 2;
|
|
2280
|
+
return (year - start) / span * width;
|
|
2281
|
+
}
|
|
2282
|
+
var TICK_STEPS = [1e3, 500, 250, 100, 50, 25, 10, 5, 2, 1];
|
|
2283
|
+
var TARGET_TICKS = 8;
|
|
2284
|
+
function axisTicks(domain, width) {
|
|
2285
|
+
const [start, end] = domain;
|
|
2286
|
+
const span = end - start;
|
|
2287
|
+
if (!(span > 0) || width <= 0) return [];
|
|
2288
|
+
const step = TICK_STEPS.find((candidate) => span / candidate >= TARGET_TICKS) ?? 1;
|
|
2289
|
+
const ticks = [];
|
|
2290
|
+
for (let year = Math.ceil(start / step) * step; year < end; year += step) {
|
|
2291
|
+
ticks.push({ x: (year - start) / span * width, label: tickLabel(year) });
|
|
2292
|
+
}
|
|
2293
|
+
return ticks;
|
|
2294
|
+
}
|
|
2295
|
+
function tickLabel(year) {
|
|
2296
|
+
const whole = Math.floor(year);
|
|
2297
|
+
return whole < 0 ? `${-whole} BC` : String(whole);
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
// src/player/TimelineStrip.tsx
|
|
2301
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2302
|
+
var TIMELINE_HEIGHT = 70;
|
|
2303
|
+
var MARGIN = 28;
|
|
2304
|
+
var AXIS_Y = 42;
|
|
2305
|
+
var LABEL_Y = 62;
|
|
2306
|
+
var CURRENT_SCALE = 0.95;
|
|
2307
|
+
function TimelineStrip({ points, currentIndex, onSelect, colors }) {
|
|
2308
|
+
const containerRef = useRef2(null);
|
|
2309
|
+
const [width, setWidth] = useState2(0);
|
|
2310
|
+
useEffect2(() => {
|
|
2311
|
+
const el = containerRef.current;
|
|
2312
|
+
if (!el) return;
|
|
2313
|
+
const observer = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));
|
|
2314
|
+
observer.observe(el);
|
|
2315
|
+
return () => observer.disconnect();
|
|
2316
|
+
}, []);
|
|
2317
|
+
const plotWidth = Math.max(0, width - MARGIN * 2);
|
|
2318
|
+
const domain = storyDomain(points.map((p) => p.year));
|
|
2319
|
+
const ticks = plotWidth > 0 ? axisTicks(domain, plotWidth) : [];
|
|
2320
|
+
return /* @__PURE__ */ jsx3(
|
|
2321
|
+
"div",
|
|
2322
|
+
{
|
|
2323
|
+
ref: containerRef,
|
|
2324
|
+
style: {
|
|
2325
|
+
position: "absolute",
|
|
2326
|
+
left: 0,
|
|
2327
|
+
right: 0,
|
|
2328
|
+
bottom: 0,
|
|
2329
|
+
height: TIMELINE_HEIGHT,
|
|
2330
|
+
background: colors.surface,
|
|
2331
|
+
// Above the slide panel, whose fading background would otherwise
|
|
2332
|
+
// wash out any dot beneath it.
|
|
2333
|
+
zIndex: 2
|
|
2334
|
+
},
|
|
2335
|
+
children: width > 0 && /* @__PURE__ */ jsxs2("svg", { width, height: TIMELINE_HEIGHT, style: { display: "block", overflow: "visible" }, children: [
|
|
2336
|
+
/* @__PURE__ */ jsx3("line", { x1: MARGIN, y1: AXIS_Y, x2: width - MARGIN, y2: AXIS_Y, stroke: colors.border, strokeWidth: 1 }),
|
|
2337
|
+
ticks.map((tick) => /* @__PURE__ */ jsx3("text", { x: MARGIN + tick.x, y: LABEL_Y, fontSize: 15, fill: colors.muted, textAnchor: "middle", children: tick.label }, tick.x)),
|
|
2338
|
+
points.map((point) => {
|
|
2339
|
+
const cx = MARGIN + xForYear(point.year, domain, plotWidth);
|
|
2340
|
+
const current = point.index === currentIndex;
|
|
2341
|
+
return current ? /* @__PURE__ */ jsx3(
|
|
2342
|
+
"path",
|
|
2343
|
+
{
|
|
2344
|
+
d: PIN_PATH_D,
|
|
2345
|
+
transform: `translate(${cx - 12 * CURRENT_SCALE} ${AXIS_Y - 24 * CURRENT_SCALE}) scale(${CURRENT_SCALE})`,
|
|
2346
|
+
fill: colors.mark,
|
|
2347
|
+
stroke: colors.text,
|
|
2348
|
+
strokeWidth: 1.5,
|
|
2349
|
+
style: { cursor: "pointer" },
|
|
2350
|
+
onClick: () => onSelect(point.index),
|
|
2351
|
+
children: /* @__PURE__ */ jsx3("title", { children: tickLabel(point.year) })
|
|
2352
|
+
},
|
|
2353
|
+
point.index
|
|
2354
|
+
) : /* @__PURE__ */ jsx3(
|
|
2355
|
+
"circle",
|
|
2356
|
+
{
|
|
2357
|
+
cx,
|
|
2358
|
+
cy: AXIS_Y,
|
|
2359
|
+
r: 3.5,
|
|
2360
|
+
fill: colors.mark,
|
|
2361
|
+
stroke: colors.surface,
|
|
2362
|
+
strokeWidth: 1.5,
|
|
2363
|
+
style: { cursor: "pointer" },
|
|
2364
|
+
onClick: () => onSelect(point.index),
|
|
2365
|
+
children: /* @__PURE__ */ jsx3("title", { children: tickLabel(point.year) })
|
|
2366
|
+
},
|
|
2367
|
+
point.index
|
|
2368
|
+
);
|
|
2369
|
+
})
|
|
2370
|
+
] })
|
|
2371
|
+
}
|
|
2372
|
+
);
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
// src/player/StoryPlayer.tsx
|
|
2376
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2377
|
+
var PANEL_FRACTION = 0.62;
|
|
2378
|
+
var BAR_HEIGHT = 56;
|
|
2379
|
+
function initialMapMode(story) {
|
|
2380
|
+
return story.presentation?.basemap === "historical" ? "auto" : "standard";
|
|
2381
|
+
}
|
|
2382
|
+
function SlideText({ text, colors }) {
|
|
2383
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: parseStoryText(text).map((lines, p) => /* @__PURE__ */ jsx4("p", { dir: "auto", style: { margin: "0 0 0.6em", color: colors.text, lineHeight: 1.55 }, children: lines.map((spans, l) => /* @__PURE__ */ jsxs3("span", { children: [
|
|
2384
|
+
l > 0 && /* @__PURE__ */ jsx4("br", {}),
|
|
2385
|
+
spans.map((span, s) => {
|
|
2386
|
+
if (span.bold) return /* @__PURE__ */ jsx4("b", { children: span.text }, s);
|
|
2387
|
+
if (span.italic) return /* @__PURE__ */ jsx4("i", { children: span.text }, s);
|
|
2388
|
+
return /* @__PURE__ */ jsx4("span", { children: span.text }, s);
|
|
2389
|
+
})
|
|
2390
|
+
] }, l)) }, p)) });
|
|
2391
|
+
}
|
|
2392
|
+
function SlidePhoto({ mediaKey, item, caption, credit, resolveMedia, colors }) {
|
|
2393
|
+
const [src, setSrc] = useState3(null);
|
|
2394
|
+
useEffect3(() => {
|
|
2395
|
+
setSrc(null);
|
|
2396
|
+
let cancelled = false;
|
|
2397
|
+
resolveMedia(mediaKey, item).then((url) => {
|
|
2398
|
+
if (!cancelled) setSrc(url);
|
|
2399
|
+
}, () => {
|
|
2400
|
+
});
|
|
2401
|
+
return () => {
|
|
2402
|
+
cancelled = true;
|
|
2403
|
+
};
|
|
2404
|
+
}, [mediaKey, item, resolveMedia]);
|
|
2405
|
+
if (!src) return null;
|
|
2406
|
+
return /* @__PURE__ */ jsxs3("figure", { style: { margin: 0, display: "flex", flexDirection: "column", alignItems: "center", gap: 4 }, children: [
|
|
2407
|
+
/* @__PURE__ */ jsx4(
|
|
2408
|
+
"img",
|
|
2409
|
+
{
|
|
2410
|
+
src,
|
|
2411
|
+
alt: item.alt ?? "",
|
|
2412
|
+
width: item.width,
|
|
2413
|
+
height: item.height,
|
|
2414
|
+
style: { maxHeight: "42vh", maxWidth: "100%", width: "auto", height: "auto", objectFit: "contain", borderRadius: 4 }
|
|
2415
|
+
}
|
|
2416
|
+
),
|
|
2417
|
+
(caption || credit) && /* @__PURE__ */ jsx4("figcaption", { style: { fontSize: 13, color: colors.muted }, children: [caption, credit && `\xA9 ${credit}`].filter(Boolean).join(" \xB7 ") })
|
|
2418
|
+
] });
|
|
2419
|
+
}
|
|
2420
|
+
function SlideContent({ slide, story, resolveMedia, colors }) {
|
|
2421
|
+
const photo = slide?.media?.find((m) => Object.prototype.hasOwnProperty.call(story.media, m.ref));
|
|
2422
|
+
const eyebrow = [slide?.date?.text, slide?.place?.name].filter(Boolean).join(" \xB7 ");
|
|
2423
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
2424
|
+
photo && /* @__PURE__ */ jsx4(
|
|
2425
|
+
SlidePhoto,
|
|
2426
|
+
{
|
|
2427
|
+
mediaKey: photo.ref,
|
|
2428
|
+
item: story.media[photo.ref],
|
|
2429
|
+
caption: photo.caption,
|
|
2430
|
+
credit: photo.credit,
|
|
2431
|
+
resolveMedia,
|
|
2432
|
+
colors
|
|
2433
|
+
}
|
|
2434
|
+
),
|
|
2435
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: 4, alignItems: "center", maxWidth: 640, textAlign: "center" }, children: [
|
|
2436
|
+
eyebrow && /* @__PURE__ */ jsx4("div", { dir: "auto", style: { fontSize: 14, color: colors.muted }, children: eyebrow }),
|
|
2437
|
+
slide?.title && /* @__PURE__ */ jsx4("div", { dir: "auto", style: { fontSize: 20, fontWeight: 700, color: colors.text }, children: slide.title }),
|
|
2438
|
+
slide?.text && /* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(SlideText, { text: slide.text, colors }) })
|
|
2439
|
+
] })
|
|
2440
|
+
] });
|
|
2441
|
+
}
|
|
2442
|
+
function RoundButton({ label, onClick, disabled, size, children, style }) {
|
|
2443
|
+
return /* @__PURE__ */ jsx4(
|
|
2444
|
+
"button",
|
|
2445
|
+
{
|
|
2446
|
+
type: "button",
|
|
2447
|
+
"aria-label": label,
|
|
2448
|
+
title: label,
|
|
2449
|
+
onClick,
|
|
2450
|
+
disabled,
|
|
2451
|
+
style: {
|
|
2452
|
+
width: size,
|
|
2453
|
+
height: size,
|
|
2454
|
+
borderRadius: "50%",
|
|
2455
|
+
border: "none",
|
|
2456
|
+
background: "#25262b",
|
|
2457
|
+
color: "#ffffff",
|
|
2458
|
+
fontSize: size >= 48 ? 22 : 18,
|
|
2459
|
+
cursor: disabled ? "default" : "pointer",
|
|
2460
|
+
opacity: disabled ? 0.35 : 0.8,
|
|
2461
|
+
display: "flex",
|
|
2462
|
+
alignItems: "center",
|
|
2463
|
+
justifyContent: "center",
|
|
2464
|
+
padding: 0,
|
|
2465
|
+
fontFamily: "inherit",
|
|
2466
|
+
...style
|
|
2467
|
+
},
|
|
2468
|
+
children
|
|
2469
|
+
}
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
function NavArrows({ index, total, onPrev, onNext, variant, strings, colors }) {
|
|
2473
|
+
if (variant === "edge") {
|
|
2474
|
+
const edge = { position: "absolute", top: "50%", transform: "translateY(-50%)", zIndex: 2 };
|
|
2475
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
2476
|
+
/* @__PURE__ */ jsx4(RoundButton, { label: strings.previous, size: 56, disabled: index === 0, onClick: onPrev, style: { ...edge, left: 24 }, children: "\u2190" }),
|
|
2477
|
+
/* @__PURE__ */ jsx4(RoundButton, { label: strings.next, size: 56, disabled: index === total - 1, onClick: onNext, style: { ...edge, right: 24 }, children: "\u2192" })
|
|
2478
|
+
] });
|
|
2479
|
+
}
|
|
2480
|
+
return /* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 16, marginTop: 16 }, children: [
|
|
2481
|
+
/* @__PURE__ */ jsx4(RoundButton, { label: strings.previous, size: 34, disabled: index === 0, onClick: onPrev, children: "\u2190" }),
|
|
2482
|
+
/* @__PURE__ */ jsxs3("span", { style: { fontSize: 14, color: colors.muted }, children: [
|
|
2483
|
+
index + 1,
|
|
2484
|
+
" / ",
|
|
2485
|
+
total
|
|
2486
|
+
] }),
|
|
2487
|
+
/* @__PURE__ */ jsx4(RoundButton, { label: strings.next, size: 34, disabled: index === total - 1, onClick: onNext, children: "\u2192" })
|
|
2488
|
+
] });
|
|
2489
|
+
}
|
|
2490
|
+
function StoryPlayer({
|
|
2491
|
+
story,
|
|
2492
|
+
resolveMedia,
|
|
2493
|
+
dark = false,
|
|
2494
|
+
colors: colorOverrides,
|
|
2495
|
+
strings: stringOverrides,
|
|
2496
|
+
onClose,
|
|
2497
|
+
keyboard = true,
|
|
2498
|
+
onSlideChange,
|
|
2499
|
+
renderMapModeControl,
|
|
2500
|
+
brand,
|
|
2501
|
+
actions,
|
|
2502
|
+
initialSlide = 0
|
|
2503
|
+
}) {
|
|
2504
|
+
const colors = useMemo(() => ({ ...defaultColors(dark), ...colorOverrides }), [dark, colorOverrides]);
|
|
2505
|
+
const strings = useMemo(
|
|
2506
|
+
() => ({
|
|
2507
|
+
...stringsFor(story.language, typeof navigator === "undefined" ? void 0 : navigator.language),
|
|
2508
|
+
...stringOverrides
|
|
2509
|
+
}),
|
|
2510
|
+
[story.language, stringOverrides]
|
|
2511
|
+
);
|
|
2512
|
+
const rootRef = useRef3(null);
|
|
2513
|
+
const slides = story.slides;
|
|
2514
|
+
const [index, setIndex] = useState3(initialSlide);
|
|
2515
|
+
const slide = slides[index];
|
|
2516
|
+
useEffect3(() => {
|
|
2517
|
+
setIndex(Math.min(Math.max(initialSlide, 0), Math.max(slides.length - 1, 0)));
|
|
2518
|
+
}, [story, initialSlide, slides.length]);
|
|
2519
|
+
const datedSlides = useMemo(() => {
|
|
2520
|
+
const points = [];
|
|
2521
|
+
slides.forEach((s, i) => {
|
|
2522
|
+
const year = timelineYear(s.date);
|
|
2523
|
+
if (year !== null) points.push({ index: i, year });
|
|
2524
|
+
});
|
|
2525
|
+
return points;
|
|
2526
|
+
}, [slides]);
|
|
2527
|
+
const showTimeline = datedSlides.length >= 2;
|
|
2528
|
+
const [mapMode, setMapMode] = useState3(() => initialMapMode(story));
|
|
2529
|
+
const [historicalYear, setHistoricalYear] = useState3(() => (/* @__PURE__ */ new Date()).getFullYear());
|
|
2530
|
+
const currentYear = timelineYear(slide?.date);
|
|
2531
|
+
const autoYear = currentYear !== null ? Math.floor(currentYear) : null;
|
|
2532
|
+
const yearBounds = useMemo(() => {
|
|
2533
|
+
if (datedSlides.length === 0) {
|
|
2534
|
+
const thisYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2535
|
+
return [thisYear - 200, thisYear];
|
|
2536
|
+
}
|
|
2537
|
+
const years = datedSlides.map((d) => d.year);
|
|
2538
|
+
return [Math.floor(Math.min(...years)), Math.ceil(Math.max(...years))];
|
|
2539
|
+
}, [datedSlides]);
|
|
2540
|
+
const wasHistoricalRef = useRef3(false);
|
|
2541
|
+
useEffect3(() => {
|
|
2542
|
+
if (mapMode === "historical" && !wasHistoricalRef.current) setHistoricalYear(autoYear ?? yearBounds[1]);
|
|
2543
|
+
wasHistoricalRef.current = mapMode === "historical";
|
|
2544
|
+
}, [mapMode, autoYear, yearBounds]);
|
|
2545
|
+
const ohmYear = mapMode === "standard" ? null : mapMode === "auto" ? autoYear : historicalYear;
|
|
2546
|
+
const goPrev = () => setIndex((i) => Math.max(i - 1, 0));
|
|
2547
|
+
const goNext = () => setIndex((i) => Math.min(i + 1, slides.length - 1));
|
|
2548
|
+
const onSlideChangeRef = useRef3(onSlideChange);
|
|
2549
|
+
onSlideChangeRef.current = onSlideChange;
|
|
2550
|
+
useEffect3(() => {
|
|
2551
|
+
onSlideChangeRef.current?.(index);
|
|
2552
|
+
}, [index]);
|
|
2553
|
+
useEffect3(() => {
|
|
2554
|
+
if (!keyboard) return;
|
|
2555
|
+
const target = keyboard === "focus" ? rootRef.current : window;
|
|
2556
|
+
if (!target) return;
|
|
2557
|
+
function onKey(e) {
|
|
2558
|
+
const key = e.key;
|
|
2559
|
+
const from = e.target;
|
|
2560
|
+
if (from && (from.tagName === "INPUT" || from.tagName === "TEXTAREA" || from.isContentEditable)) return;
|
|
2561
|
+
if (key === "ArrowRight") setIndex((i) => Math.min(i + 1, slides.length - 1));
|
|
2562
|
+
if (key === "ArrowLeft") setIndex((i) => Math.max(i - 1, 0));
|
|
2563
|
+
}
|
|
2564
|
+
target.addEventListener("keydown", onKey);
|
|
2565
|
+
return () => target.removeEventListener("keydown", onKey);
|
|
2566
|
+
}, [keyboard, slides.length]);
|
|
2567
|
+
const swipeStart = useRef3(null);
|
|
2568
|
+
const swipeHandlers = {
|
|
2569
|
+
onTouchStart: (e) => {
|
|
2570
|
+
const t = e.touches[0];
|
|
2571
|
+
swipeStart.current = e.touches.length === 1 ? { x: t.clientX, y: t.clientY } : null;
|
|
2572
|
+
},
|
|
2573
|
+
onTouchEnd: (e) => {
|
|
2574
|
+
const start = swipeStart.current;
|
|
2575
|
+
swipeStart.current = null;
|
|
2576
|
+
const t = e.changedTouches[0];
|
|
2577
|
+
if (!start || !t) return;
|
|
2578
|
+
const dx = t.clientX - start.x;
|
|
2579
|
+
const dy = t.clientY - start.y;
|
|
2580
|
+
if (Math.abs(dx) < 50 || Math.abs(dx) < Math.abs(dy) * 1.5) return;
|
|
2581
|
+
if (dx < 0) goNext();
|
|
2582
|
+
else goPrev();
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
const places = useMemo(() => storyPlaces(slides.map((s) => s.place)), [slides]);
|
|
2586
|
+
const mapSlide = useMemo(() => ({
|
|
2587
|
+
key: slide?.id ?? String(index),
|
|
2588
|
+
place: slide?.place,
|
|
2589
|
+
// The opening card, with no place of its own, shows where the story goes.
|
|
2590
|
+
overview: index === 0 && !placeCenter(slide?.place) ? places : null
|
|
2591
|
+
}), [slide, index, places]);
|
|
2592
|
+
const firstCenter = useMemo(() => {
|
|
2593
|
+
if (story.presentation?.basemap === "none") return null;
|
|
2594
|
+
for (const s of slides) {
|
|
2595
|
+
const center = placeCenter(s.place);
|
|
2596
|
+
if (center) return center;
|
|
2597
|
+
}
|
|
2598
|
+
return null;
|
|
2599
|
+
}, [story, slides]);
|
|
2600
|
+
const modeControlProps = {
|
|
2601
|
+
mode: mapMode,
|
|
2602
|
+
onModeChange: setMapMode,
|
|
2603
|
+
autoYear,
|
|
2604
|
+
year: historicalYear,
|
|
2605
|
+
onYearChange: setHistoricalYear,
|
|
2606
|
+
yearBounds
|
|
2607
|
+
};
|
|
2608
|
+
const mediaResolver = useMemo(() => (key) => {
|
|
2609
|
+
const item = Object.prototype.hasOwnProperty.call(story.media, key) ? story.media[key] : void 0;
|
|
2610
|
+
return item ? resolveMedia(key, item) : Promise.resolve(null);
|
|
2611
|
+
}, [story, resolveMedia]);
|
|
2612
|
+
const content = /* @__PURE__ */ jsx4(SlideContent, { slide, story, resolveMedia, colors });
|
|
2613
|
+
const timeline = showTimeline && /* @__PURE__ */ jsx4(TimelineStrip, { points: datedSlides, currentIndex: index, onSelect: setIndex, colors });
|
|
2614
|
+
return /* @__PURE__ */ jsxs3(
|
|
2615
|
+
"div",
|
|
2616
|
+
{
|
|
2617
|
+
ref: rootRef,
|
|
2618
|
+
lang: story.language,
|
|
2619
|
+
tabIndex: keyboard === "focus" ? 0 : void 0,
|
|
2620
|
+
style: {
|
|
2621
|
+
position: "relative",
|
|
2622
|
+
width: "100%",
|
|
2623
|
+
height: "100%",
|
|
2624
|
+
overflow: "hidden",
|
|
2625
|
+
background: colors.surface,
|
|
2626
|
+
color: colors.text
|
|
2627
|
+
},
|
|
2628
|
+
children: [
|
|
2629
|
+
/* @__PURE__ */ jsx4(
|
|
2630
|
+
"div",
|
|
2631
|
+
{
|
|
2632
|
+
style: {
|
|
2633
|
+
position: "absolute",
|
|
2634
|
+
top: 0,
|
|
2635
|
+
left: 0,
|
|
2636
|
+
right: 0,
|
|
2637
|
+
height: BAR_HEIGHT,
|
|
2638
|
+
zIndex: 3,
|
|
2639
|
+
background: dark ? "rgba(20,20,20,0.55)" : "rgba(255,255,255,0.55)"
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
),
|
|
2643
|
+
/* @__PURE__ */ jsxs3(
|
|
2644
|
+
"div",
|
|
2645
|
+
{
|
|
2646
|
+
dir: "auto",
|
|
2647
|
+
style: {
|
|
2648
|
+
position: "absolute",
|
|
2649
|
+
top: 0,
|
|
2650
|
+
left: 20,
|
|
2651
|
+
height: BAR_HEIGHT,
|
|
2652
|
+
maxWidth: "26%",
|
|
2653
|
+
zIndex: 3,
|
|
2654
|
+
display: "flex",
|
|
2655
|
+
alignItems: "center",
|
|
2656
|
+
gap: 10,
|
|
2657
|
+
fontWeight: 600
|
|
2658
|
+
},
|
|
2659
|
+
children: [
|
|
2660
|
+
brand && /* @__PURE__ */ jsx4("span", { style: { flex: "none", display: "flex" }, children: brand }),
|
|
2661
|
+
/* @__PURE__ */ jsx4("span", { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: story.title })
|
|
2662
|
+
]
|
|
2663
|
+
}
|
|
2664
|
+
),
|
|
2665
|
+
firstCenter && /* @__PURE__ */ jsx4(
|
|
2666
|
+
"div",
|
|
2667
|
+
{
|
|
2668
|
+
style: {
|
|
2669
|
+
position: "absolute",
|
|
2670
|
+
top: 0,
|
|
2671
|
+
left: 0,
|
|
2672
|
+
right: 0,
|
|
2673
|
+
height: BAR_HEIGHT,
|
|
2674
|
+
zIndex: 3,
|
|
2675
|
+
display: "flex",
|
|
2676
|
+
alignItems: "center",
|
|
2677
|
+
justifyContent: "center",
|
|
2678
|
+
pointerEvents: "none"
|
|
2679
|
+
},
|
|
2680
|
+
children: /* @__PURE__ */ jsx4("div", { style: { pointerEvents: "auto" }, children: renderMapModeControl ? renderMapModeControl(modeControlProps) : /* @__PURE__ */ jsx4(MapModeControl, { ...modeControlProps, strings, colors }) })
|
|
2681
|
+
}
|
|
2682
|
+
),
|
|
2683
|
+
actions && /* @__PURE__ */ jsx4(
|
|
2684
|
+
"div",
|
|
2685
|
+
{
|
|
2686
|
+
style: {
|
|
2687
|
+
position: "absolute",
|
|
2688
|
+
top: 0,
|
|
2689
|
+
right: onClose ? 60 : 12,
|
|
2690
|
+
height: BAR_HEIGHT,
|
|
2691
|
+
zIndex: 3,
|
|
2692
|
+
display: "flex",
|
|
2693
|
+
alignItems: "center",
|
|
2694
|
+
gap: 8
|
|
2695
|
+
},
|
|
2696
|
+
children: actions
|
|
2697
|
+
}
|
|
2698
|
+
),
|
|
2699
|
+
onClose && /* @__PURE__ */ jsx4(
|
|
2700
|
+
RoundButton,
|
|
2701
|
+
{
|
|
2702
|
+
label: strings.close,
|
|
2703
|
+
size: 36,
|
|
2704
|
+
onClick: onClose,
|
|
2705
|
+
style: { position: "absolute", top: 10, right: 12, zIndex: 3 },
|
|
2706
|
+
children: "\xD7"
|
|
2707
|
+
}
|
|
2708
|
+
),
|
|
2709
|
+
firstCenter ? /* @__PURE__ */ jsxs3("div", { style: { position: "absolute", inset: 0 }, children: [
|
|
2710
|
+
/* @__PURE__ */ jsx4(
|
|
2711
|
+
MapBackground,
|
|
2712
|
+
{
|
|
2713
|
+
initialCenter: firstCenter,
|
|
2714
|
+
current: mapSlide,
|
|
2715
|
+
dark,
|
|
2716
|
+
colors,
|
|
2717
|
+
panelFraction: PANEL_FRACTION,
|
|
2718
|
+
ohmYear,
|
|
2719
|
+
resolveMedia: mediaResolver
|
|
2720
|
+
}
|
|
2721
|
+
),
|
|
2722
|
+
/* @__PURE__ */ jsx4(
|
|
2723
|
+
"div",
|
|
2724
|
+
{
|
|
2725
|
+
style: {
|
|
2726
|
+
position: "absolute",
|
|
2727
|
+
top: 0,
|
|
2728
|
+
bottom: 0,
|
|
2729
|
+
right: 0,
|
|
2730
|
+
width: `${PANEL_FRACTION * 100}%`,
|
|
2731
|
+
zIndex: 1,
|
|
2732
|
+
padding: `${BAR_HEIGHT}px 32px ${showTimeline ? TIMELINE_HEIGHT : 32}px`,
|
|
2733
|
+
boxSizing: "border-box",
|
|
2734
|
+
display: "flex",
|
|
2735
|
+
flexDirection: "column",
|
|
2736
|
+
justifyContent: "center",
|
|
2737
|
+
alignItems: "center",
|
|
2738
|
+
gap: 16,
|
|
2739
|
+
overflowY: "auto",
|
|
2740
|
+
// Transparent where the panel starts, mid-screen, and solid
|
|
2741
|
+
// well before the centered content, so text never sits on map.
|
|
2742
|
+
background: `linear-gradient(to right, transparent 0%, ${colors.panel} 22%)`
|
|
2743
|
+
},
|
|
2744
|
+
...swipeHandlers,
|
|
2745
|
+
children: content
|
|
2746
|
+
}
|
|
2747
|
+
),
|
|
2748
|
+
/* @__PURE__ */ jsx4(NavArrows, { index, total: slides.length, onPrev: goPrev, onNext: goNext, variant: "edge", strings, colors }),
|
|
2749
|
+
timeline
|
|
2750
|
+
] }) : /* @__PURE__ */ jsxs3(
|
|
2751
|
+
"div",
|
|
2752
|
+
{
|
|
2753
|
+
style: {
|
|
2754
|
+
position: "absolute",
|
|
2755
|
+
inset: 0,
|
|
2756
|
+
overflowY: "auto",
|
|
2757
|
+
boxSizing: "border-box",
|
|
2758
|
+
padding: `${BAR_HEIGHT + 16}px 24px ${showTimeline ? TIMELINE_HEIGHT + 16 : 24}px`,
|
|
2759
|
+
display: "flex",
|
|
2760
|
+
flexDirection: "column",
|
|
2761
|
+
alignItems: "center",
|
|
2762
|
+
justifyContent: "center",
|
|
2763
|
+
gap: 16
|
|
2764
|
+
},
|
|
2765
|
+
...swipeHandlers,
|
|
2766
|
+
children: [
|
|
2767
|
+
content,
|
|
2768
|
+
/* @__PURE__ */ jsx4(NavArrows, { index, total: slides.length, onPrev: goPrev, onNext: goNext, variant: "inline", strings, colors }),
|
|
2769
|
+
timeline
|
|
2770
|
+
]
|
|
2771
|
+
}
|
|
2772
|
+
)
|
|
2773
|
+
]
|
|
2774
|
+
}
|
|
2775
|
+
);
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
// src/editor/dates.ts
|
|
2779
|
+
import { loadLocale, parseDate, resolveLocaleCode, toEdtf } from "@gramps-connect/gramps-date";
|
|
2780
|
+
var suggestEdtf = async (text, language) => {
|
|
2781
|
+
if (!text.trim()) return void 0;
|
|
2782
|
+
const code = language && resolveLocaleCode(language.replace(/-/g, "_")) || "en";
|
|
2783
|
+
if (code !== "en" && !await loadLocale(code)) return void 0;
|
|
2784
|
+
try {
|
|
2785
|
+
return toEdtf(parseDate(text, { locale: code }));
|
|
2786
|
+
} catch {
|
|
2787
|
+
return void 0;
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
|
|
2791
|
+
// src/editor/DateField.tsx
|
|
2792
|
+
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
2793
|
+
import { Anchor, Group, Stack, Text, TextInput } from "@mantine/core";
|
|
2794
|
+
|
|
2795
|
+
// src/editor/model.ts
|
|
2796
|
+
function blankStory(title, language) {
|
|
2797
|
+
return {
|
|
2798
|
+
format: FORMAT_ID,
|
|
2799
|
+
version: FORMAT_VERSION,
|
|
2800
|
+
title,
|
|
2801
|
+
...language ? { language } : {},
|
|
2802
|
+
slides: [{ id: "s0", title }],
|
|
2803
|
+
media: {}
|
|
2804
|
+
};
|
|
2805
|
+
}
|
|
2806
|
+
function nextSlideId(doc) {
|
|
2807
|
+
let max = -1;
|
|
2808
|
+
for (const slide of doc.slides) {
|
|
2809
|
+
const match = /^s(\d+)$/.exec(slide.id);
|
|
2810
|
+
if (match) max = Math.max(max, Number(match[1]));
|
|
2811
|
+
}
|
|
2812
|
+
let n = max + 1;
|
|
2813
|
+
const ids = new Set(doc.slides.map((s) => s.id));
|
|
2814
|
+
while (ids.has(`s${n}`)) n += 1;
|
|
2815
|
+
return `s${n}`;
|
|
2816
|
+
}
|
|
2817
|
+
function withSlides(doc, slides) {
|
|
2818
|
+
return { ...doc, slides };
|
|
2819
|
+
}
|
|
2820
|
+
function addSlide(doc, index) {
|
|
2821
|
+
const slides = [...doc.slides];
|
|
2822
|
+
const at = Math.min(Math.max(index + 1, 0), slides.length);
|
|
2823
|
+
slides.splice(at, 0, { id: nextSlideId(doc) });
|
|
2824
|
+
return { doc: withSlides(doc, slides), index: at };
|
|
2825
|
+
}
|
|
2826
|
+
function duplicateSlide(doc, index) {
|
|
2827
|
+
const slides = [...doc.slides];
|
|
2828
|
+
const copy = structuredClone(slides[index]);
|
|
2829
|
+
copy.id = nextSlideId(doc);
|
|
2830
|
+
slides.splice(index + 1, 0, copy);
|
|
2831
|
+
return { doc: withSlides(doc, slides), index: index + 1 };
|
|
2832
|
+
}
|
|
2833
|
+
function deleteSlide(doc, index) {
|
|
2834
|
+
if (doc.slides.length <= 1) return { doc, index };
|
|
2835
|
+
const slides = doc.slides.filter((_, i) => i !== index);
|
|
2836
|
+
return { doc: withSlides(doc, slides), index: Math.min(index, slides.length - 1) };
|
|
2837
|
+
}
|
|
2838
|
+
function moveSlide(doc, from, to) {
|
|
2839
|
+
if (from === to || to < 0 || to >= doc.slides.length) return doc;
|
|
2840
|
+
const slides = [...doc.slides];
|
|
2841
|
+
const [slide] = slides.splice(from, 1);
|
|
2842
|
+
slides.splice(to, 0, slide);
|
|
2843
|
+
return withSlides(doc, slides);
|
|
2844
|
+
}
|
|
2845
|
+
function patched(base, patch) {
|
|
2846
|
+
const next = { ...base };
|
|
2847
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
2848
|
+
if (value === void 0) delete next[key];
|
|
2849
|
+
else next[key] = value;
|
|
2850
|
+
}
|
|
2851
|
+
return next;
|
|
2852
|
+
}
|
|
2853
|
+
function updateSlide(doc, index, patch) {
|
|
2854
|
+
const slides = [...doc.slides];
|
|
2855
|
+
slides[index] = patched(slides[index], patch);
|
|
2856
|
+
return withSlides(doc, slides);
|
|
2857
|
+
}
|
|
2858
|
+
function updateStory(doc, patch) {
|
|
2859
|
+
return patched(doc, patch);
|
|
2860
|
+
}
|
|
2861
|
+
function slideDate(previous, text, edtf) {
|
|
2862
|
+
if (!text.trim()) return void 0;
|
|
2863
|
+
const next = patched(previous ?? { text }, { text, edtf: edtf || void 0 });
|
|
2864
|
+
if (next.edtf !== previous?.edtf) delete next.sortYear;
|
|
2865
|
+
return next;
|
|
2866
|
+
}
|
|
2867
|
+
function usedMedia(doc) {
|
|
2868
|
+
const used = /* @__PURE__ */ new Set();
|
|
2869
|
+
for (const slide of doc.slides) {
|
|
2870
|
+
for (const m of slide.media ?? []) used.add(m.ref);
|
|
2871
|
+
for (const o of slide.place?.overlays ?? []) used.add(o.media);
|
|
2872
|
+
}
|
|
2873
|
+
return used;
|
|
2874
|
+
}
|
|
2875
|
+
function pruneMedia(doc, files) {
|
|
2876
|
+
const used = usedMedia(doc);
|
|
2877
|
+
const media = Object.fromEntries(Object.entries(doc.media).filter(([key]) => used.has(key)));
|
|
2878
|
+
const srcs = new Set(Object.values(media).map((m) => m.src));
|
|
2879
|
+
return {
|
|
2880
|
+
doc: { ...doc, media },
|
|
2881
|
+
files: new Map([...files].filter(([path]) => srcs.has(path)))
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
function storyFileName(title) {
|
|
2885
|
+
const safe = title.replace(/[\\/:*?"<>|\u0000-\u001f]+/g, " ").replace(/\s+/g, " ").trim().slice(0, 120);
|
|
2886
|
+
return `${safe || "story"}.story.zip`;
|
|
2887
|
+
}
|
|
2888
|
+
var COALESCE_MS = 1500;
|
|
2889
|
+
var MAX_STEPS = 200;
|
|
2890
|
+
function startHistory(doc) {
|
|
2891
|
+
return { past: [], present: doc, future: [] };
|
|
2892
|
+
}
|
|
2893
|
+
function record(history, next, key, now = Date.now()) {
|
|
2894
|
+
if (next === history.present) return history;
|
|
2895
|
+
const coalesce = key !== void 0 && key === history.lastKey && history.lastAt !== void 0 && now - history.lastAt < COALESCE_MS;
|
|
2896
|
+
const past = coalesce ? history.past : [...history.past, history.present].slice(-MAX_STEPS);
|
|
2897
|
+
return { past, present: next, future: [], lastKey: key, lastAt: now };
|
|
2898
|
+
}
|
|
2899
|
+
function undo(history) {
|
|
2900
|
+
const previous = history.past[history.past.length - 1];
|
|
2901
|
+
if (!previous) return history;
|
|
2902
|
+
return { past: history.past.slice(0, -1), present: previous, future: [history.present, ...history.future] };
|
|
2903
|
+
}
|
|
2904
|
+
function redo(history) {
|
|
2905
|
+
const [next, ...future] = history.future;
|
|
2906
|
+
if (!next) return history;
|
|
2907
|
+
return { past: [...history.past, history.present], present: next, future };
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
// src/editor/DateField.tsx
|
|
2911
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2912
|
+
function DateField({ value, language, parse, strings, onChange }) {
|
|
2913
|
+
const [following, setFollowing] = useState4(value?.edtf ? null : true);
|
|
2914
|
+
const latest = useRef4(value);
|
|
2915
|
+
latest.current = value;
|
|
2916
|
+
const request = useRef4(0);
|
|
2917
|
+
useEffect4(() => {
|
|
2918
|
+
if (following !== null) return;
|
|
2919
|
+
let live = true;
|
|
2920
|
+
void parse(value?.text ?? "", language).then((edtf2) => {
|
|
2921
|
+
if (live) setFollowing(edtf2 === value?.edtf);
|
|
2922
|
+
});
|
|
2923
|
+
return () => {
|
|
2924
|
+
live = false;
|
|
2925
|
+
};
|
|
2926
|
+
}, []);
|
|
2927
|
+
const follow = (text) => {
|
|
2928
|
+
const id = ++request.current;
|
|
2929
|
+
void parse(text, language).then((edtf2) => {
|
|
2930
|
+
if (id !== request.current || latest.current?.text !== text) return;
|
|
2931
|
+
onChange(slideDate(latest.current, text, edtf2));
|
|
2932
|
+
});
|
|
2933
|
+
};
|
|
2934
|
+
const onText = (text) => {
|
|
2935
|
+
onChange(slideDate(latest.current, text, latest.current?.edtf));
|
|
2936
|
+
if (following !== false) follow(text);
|
|
2937
|
+
};
|
|
2938
|
+
const edtf = value?.edtf ?? "";
|
|
2939
|
+
const understood = !edtf || edtfYearRange(edtf) !== null;
|
|
2940
|
+
let note;
|
|
2941
|
+
if (edtf && !understood) note = strings.preciseDateNotUnderstood;
|
|
2942
|
+
else if (!edtf) note = strings.noPreciseDate;
|
|
2943
|
+
else if (following) note = strings.preciseDateFollows;
|
|
2944
|
+
else note = strings.preciseDateHint;
|
|
2945
|
+
return /* @__PURE__ */ jsxs4(Stack, { gap: 6, children: [
|
|
2946
|
+
/* @__PURE__ */ jsx5(
|
|
2947
|
+
TextInput,
|
|
2948
|
+
{
|
|
2949
|
+
label: strings.date,
|
|
2950
|
+
description: strings.dateHint,
|
|
2951
|
+
value: value?.text ?? "",
|
|
2952
|
+
onChange: (e) => onText(e.currentTarget.value)
|
|
2953
|
+
}
|
|
2954
|
+
),
|
|
2955
|
+
value?.text && /* @__PURE__ */ jsxs4(Group, { gap: "sm", align: "flex-end", wrap: "nowrap", children: [
|
|
2956
|
+
/* @__PURE__ */ jsx5(
|
|
2957
|
+
TextInput,
|
|
2958
|
+
{
|
|
2959
|
+
label: strings.preciseDate,
|
|
2960
|
+
size: "xs",
|
|
2961
|
+
w: 200,
|
|
2962
|
+
value: edtf,
|
|
2963
|
+
error: !understood,
|
|
2964
|
+
styles: { input: { fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace" } },
|
|
2965
|
+
onChange: (e) => {
|
|
2966
|
+
setFollowing(false);
|
|
2967
|
+
onChange(slideDate(latest.current, latest.current?.text ?? "", e.currentTarget.value.trim() || void 0));
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
),
|
|
2971
|
+
/* @__PURE__ */ jsxs4(Stack, { gap: 0, pb: 4, children: [
|
|
2972
|
+
/* @__PURE__ */ jsx5(Text, { size: "xs", c: understood ? "dimmed" : "red", children: note }),
|
|
2973
|
+
following === false && /* @__PURE__ */ jsx5(Anchor, { component: "button", type: "button", size: "xs", onClick: () => {
|
|
2974
|
+
setFollowing(true);
|
|
2975
|
+
follow(value.text);
|
|
2976
|
+
}, children: strings.matchDateAsWritten })
|
|
2977
|
+
] })
|
|
2978
|
+
] })
|
|
2979
|
+
] });
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
// src/editor/SlideList.tsx
|
|
2983
|
+
import { useState as useState5 } from "react";
|
|
2984
|
+
import { Stack as Stack2, UnstyledButton } from "@mantine/core";
|
|
2985
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2986
|
+
function SlideList({ items, selected, onSelect, onMove, getKey, renderItem, label }) {
|
|
2987
|
+
const [dragging, setDragging] = useState5(null);
|
|
2988
|
+
const [over, setOver] = useState5(null);
|
|
2989
|
+
const end = () => {
|
|
2990
|
+
setDragging(null);
|
|
2991
|
+
setOver(null);
|
|
2992
|
+
};
|
|
2993
|
+
return /* @__PURE__ */ jsx6(Stack2, { gap: 4, role: "listbox", "aria-label": label, children: items.map((item, i) => {
|
|
2994
|
+
const isSelected = i === selected;
|
|
2995
|
+
const dropLine = over === i && dragging !== null && dragging !== i ? dragging < i ? { borderBottom: "2px solid var(--mantine-primary-color-filled)" } : { borderTop: "2px solid var(--mantine-primary-color-filled)" } : {};
|
|
2996
|
+
return /* @__PURE__ */ jsx6(
|
|
2997
|
+
UnstyledButton,
|
|
2998
|
+
{
|
|
2999
|
+
role: "option",
|
|
3000
|
+
"aria-selected": isSelected,
|
|
3001
|
+
draggable: true,
|
|
3002
|
+
onClick: () => onSelect(i),
|
|
3003
|
+
onDragStart: (e) => {
|
|
3004
|
+
setDragging(i);
|
|
3005
|
+
e.dataTransfer.effectAllowed = "move";
|
|
3006
|
+
e.dataTransfer.setData("text/plain", String(i));
|
|
3007
|
+
},
|
|
3008
|
+
onDragOver: (e) => {
|
|
3009
|
+
if (dragging === null) return;
|
|
3010
|
+
e.preventDefault();
|
|
3011
|
+
setOver(i);
|
|
3012
|
+
},
|
|
3013
|
+
onDrop: (e) => {
|
|
3014
|
+
e.preventDefault();
|
|
3015
|
+
if (dragging !== null && dragging !== i) onMove(dragging, i);
|
|
3016
|
+
end();
|
|
3017
|
+
},
|
|
3018
|
+
onDragEnd: end,
|
|
3019
|
+
style: {
|
|
3020
|
+
display: "block",
|
|
3021
|
+
width: "100%",
|
|
3022
|
+
padding: "6px 8px",
|
|
3023
|
+
borderRadius: 6,
|
|
3024
|
+
background: isSelected ? "var(--mantine-primary-color-light)" : void 0,
|
|
3025
|
+
opacity: dragging === i ? 0.5 : 1,
|
|
3026
|
+
...dropLine
|
|
3027
|
+
},
|
|
3028
|
+
children: renderItem(item, i)
|
|
3029
|
+
},
|
|
3030
|
+
getKey(item, i)
|
|
3031
|
+
);
|
|
3032
|
+
}) });
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
// src/editor/StoryTextField.tsx
|
|
3036
|
+
import { useRef as useRef5 } from "react";
|
|
3037
|
+
import { Button, Group as Group2, Stack as Stack3, Text as Text2, Textarea } from "@mantine/core";
|
|
3038
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3039
|
+
function applyMarker(el, marker, value, onChange) {
|
|
3040
|
+
const start = el.selectionStart ?? value.length;
|
|
3041
|
+
const end = el.selectionEnd ?? value.length;
|
|
3042
|
+
if (start === end) {
|
|
3043
|
+
onChange(value.slice(0, start) + marker + marker + value.slice(end));
|
|
3044
|
+
requestAnimationFrame(() => {
|
|
3045
|
+
el.focus();
|
|
3046
|
+
el.setSelectionRange(start + marker.length, start + marker.length);
|
|
3047
|
+
});
|
|
3048
|
+
return;
|
|
3049
|
+
}
|
|
3050
|
+
const selected = value.slice(start, end);
|
|
3051
|
+
const alreadyWrapped = selected.length > marker.length * 2 && selected.startsWith(marker) && selected.endsWith(marker);
|
|
3052
|
+
const replacement = alreadyWrapped ? selected.slice(marker.length, selected.length - marker.length) : `${marker}${selected}${marker}`;
|
|
3053
|
+
onChange(value.slice(0, start) + replacement + value.slice(end));
|
|
3054
|
+
}
|
|
3055
|
+
function StoryTextField({ label, value, onChange, boldLabel = "Bold", italicLabel = "Italic", minRows = 3 }) {
|
|
3056
|
+
const ref = useRef5(null);
|
|
3057
|
+
return /* @__PURE__ */ jsxs5(Stack3, { gap: 4, children: [
|
|
3058
|
+
/* @__PURE__ */ jsxs5(Group2, { gap: "xs", children: [
|
|
3059
|
+
/* @__PURE__ */ jsx7(Text2, { size: "sm", fw: 500, children: label }),
|
|
3060
|
+
/* @__PURE__ */ jsx7(
|
|
3061
|
+
Button,
|
|
3062
|
+
{
|
|
3063
|
+
variant: "default",
|
|
3064
|
+
size: "compact-xs",
|
|
3065
|
+
fw: 700,
|
|
3066
|
+
"aria-label": boldLabel,
|
|
3067
|
+
title: boldLabel,
|
|
3068
|
+
onClick: () => ref.current && applyMarker(ref.current, "**", value, onChange),
|
|
3069
|
+
children: "B"
|
|
3070
|
+
}
|
|
3071
|
+
),
|
|
3072
|
+
/* @__PURE__ */ jsx7(
|
|
3073
|
+
Button,
|
|
3074
|
+
{
|
|
3075
|
+
variant: "default",
|
|
3076
|
+
size: "compact-xs",
|
|
3077
|
+
fs: "italic",
|
|
3078
|
+
"aria-label": italicLabel,
|
|
3079
|
+
title: italicLabel,
|
|
3080
|
+
onClick: () => ref.current && applyMarker(ref.current, "*", value, onChange),
|
|
3081
|
+
children: "i"
|
|
3082
|
+
}
|
|
3083
|
+
)
|
|
3084
|
+
] }),
|
|
3085
|
+
/* @__PURE__ */ jsx7(
|
|
3086
|
+
Textarea,
|
|
3087
|
+
{
|
|
3088
|
+
ref,
|
|
3089
|
+
"aria-label": label,
|
|
3090
|
+
autosize: true,
|
|
3091
|
+
minRows,
|
|
3092
|
+
maxRows: 14,
|
|
3093
|
+
value,
|
|
3094
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
3095
|
+
}
|
|
3096
|
+
)
|
|
3097
|
+
] });
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
// src/editor/strings.ts
|
|
3101
|
+
var EDITOR_ENGLISH = {
|
|
3102
|
+
story: "Story",
|
|
3103
|
+
storySettings: "Title, language and map",
|
|
3104
|
+
title: "Title",
|
|
3105
|
+
language: "Language",
|
|
3106
|
+
languageHint: "The language the story is written in, e.g. en, de or fr-CA. Dates are read in it.",
|
|
3107
|
+
map: "Map",
|
|
3108
|
+
mapStandard: "Today's map",
|
|
3109
|
+
mapHistorical: "Historical maps for each slide's year",
|
|
3110
|
+
mapAuto: "Viewer's choice",
|
|
3111
|
+
mapNone: "No map",
|
|
3112
|
+
slides: "Slides",
|
|
3113
|
+
untitledSlide: "Untitled slide",
|
|
3114
|
+
addSlide: "Add slide",
|
|
3115
|
+
duplicateSlide: "Duplicate",
|
|
3116
|
+
deleteSlide: "Delete",
|
|
3117
|
+
moveUp: "Move up",
|
|
3118
|
+
moveDown: "Move down",
|
|
3119
|
+
slideTitle: "Title",
|
|
3120
|
+
text: "Text",
|
|
3121
|
+
bold: "Bold",
|
|
3122
|
+
italic: "Italic",
|
|
3123
|
+
date: "Date",
|
|
3124
|
+
dateHint: "As readers should see it, e.g. about 1850, 3 May 1850, between 1850 and 1860.",
|
|
3125
|
+
preciseDate: "Precise date (EDTF)",
|
|
3126
|
+
preciseDateHint: "Places the slide on the timeline and picks historical maps.",
|
|
3127
|
+
preciseDateFollows: "Worked out from the date as written.",
|
|
3128
|
+
preciseDateNotUnderstood: "Not a date the timeline can use.",
|
|
3129
|
+
matchDateAsWritten: "Work it out from the date",
|
|
3130
|
+
noPreciseDate: "None: this slide stays off the timeline.",
|
|
3131
|
+
place: "Place",
|
|
3132
|
+
photos: "Photos",
|
|
3133
|
+
undo: "Undo",
|
|
3134
|
+
redo: "Redo",
|
|
3135
|
+
present: "Present",
|
|
3136
|
+
preview: "Preview",
|
|
3137
|
+
problems: (count) => count === 1 ? "1 problem to fix before saving" : `${count} problems to fix before saving`,
|
|
3138
|
+
openingSlide: "Opening slide"
|
|
3139
|
+
};
|
|
3140
|
+
|
|
3141
|
+
// src/editor/StoryEditor.tsx
|
|
3142
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3143
|
+
var BAR_HEIGHT2 = 56;
|
|
3144
|
+
var STORY = -1;
|
|
3145
|
+
function issueSlide(issue) {
|
|
3146
|
+
const match = /^\/slides\/(\d+)/.exec(issue.path);
|
|
3147
|
+
return match ? Number(match[1]) : STORY;
|
|
3148
|
+
}
|
|
3149
|
+
function Thumb({ doc, slide, resolveMedia }) {
|
|
3150
|
+
const ref = slide.media?.[0]?.ref;
|
|
3151
|
+
const item = ref && Object.prototype.hasOwnProperty.call(doc.media, ref) ? doc.media[ref] : void 0;
|
|
3152
|
+
const [url, setUrl] = useState6(null);
|
|
3153
|
+
useEffect5(() => {
|
|
3154
|
+
let live = true;
|
|
3155
|
+
setUrl(null);
|
|
3156
|
+
if (ref && item) void resolveMedia(ref, item).then((u) => {
|
|
3157
|
+
if (live) setUrl(u);
|
|
3158
|
+
});
|
|
3159
|
+
return () => {
|
|
3160
|
+
live = false;
|
|
3161
|
+
};
|
|
3162
|
+
}, [ref, item, resolveMedia]);
|
|
3163
|
+
return /* @__PURE__ */ jsx8(
|
|
3164
|
+
Box,
|
|
3165
|
+
{
|
|
3166
|
+
w: 40,
|
|
3167
|
+
h: 40,
|
|
3168
|
+
style: { flex: "none", borderRadius: 4, background: "var(--mantine-color-default-hover)", overflow: "hidden" },
|
|
3169
|
+
children: url && /* @__PURE__ */ jsx8("img", { src: url, alt: "", style: { width: "100%", height: "100%", objectFit: "cover", display: "block" } })
|
|
3170
|
+
}
|
|
3171
|
+
);
|
|
3172
|
+
}
|
|
3173
|
+
function StoryEditor({
|
|
3174
|
+
initialStory,
|
|
3175
|
+
files,
|
|
3176
|
+
resolveMedia,
|
|
3177
|
+
onChange,
|
|
3178
|
+
toolbar,
|
|
3179
|
+
brand,
|
|
3180
|
+
dark = false,
|
|
3181
|
+
strings: stringOverrides,
|
|
3182
|
+
playerStrings,
|
|
3183
|
+
parseDateText = suggestEdtf
|
|
3184
|
+
}) {
|
|
3185
|
+
const strings = useMemo2(() => ({ ...EDITOR_ENGLISH, ...stringOverrides }), [stringOverrides]);
|
|
3186
|
+
const [history, setHistory] = useState6(() => startHistory(initialStory));
|
|
3187
|
+
const [selected, setSelected] = useState6(0);
|
|
3188
|
+
const [presenting, setPresenting] = useState6(false);
|
|
3189
|
+
const [problemsOpen, setProblemsOpen] = useState6(false);
|
|
3190
|
+
const wide = useMediaQuery("(min-width: 1000px)", true);
|
|
3191
|
+
const doc = history.present;
|
|
3192
|
+
const apply = useCallback((next, key) => {
|
|
3193
|
+
setHistory((h) => record(h, next, key));
|
|
3194
|
+
}, []);
|
|
3195
|
+
useEffect5(() => {
|
|
3196
|
+
onChange?.(doc);
|
|
3197
|
+
}, [doc, onChange]);
|
|
3198
|
+
const index = selected === STORY ? STORY : Math.min(selected, doc.slides.length - 1);
|
|
3199
|
+
const slide = index === STORY ? void 0 : doc.slides[index];
|
|
3200
|
+
const setSlide = (patch, key) => {
|
|
3201
|
+
if (index !== STORY) apply(updateSlide(history.present, index, patch), `${slide.id}:${key}`);
|
|
3202
|
+
};
|
|
3203
|
+
const issues = useMemo2(() => validate2(doc, files).errors, [doc, files]);
|
|
3204
|
+
useEffect5(() => {
|
|
3205
|
+
const onKey = (e) => {
|
|
3206
|
+
if (!(e.ctrlKey || e.metaKey) || e.altKey) return;
|
|
3207
|
+
const target = e.target;
|
|
3208
|
+
if (target?.closest("input, textarea, [contenteditable=true]")) return;
|
|
3209
|
+
const key = e.key.toLowerCase();
|
|
3210
|
+
if (key === "z" && !e.shiftKey) {
|
|
3211
|
+
e.preventDefault();
|
|
3212
|
+
setHistory(undo);
|
|
3213
|
+
} else if (key === "z" && e.shiftKey || key === "y") {
|
|
3214
|
+
e.preventDefault();
|
|
3215
|
+
setHistory(redo);
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
3218
|
+
window.addEventListener("keydown", onKey);
|
|
3219
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
3220
|
+
}, []);
|
|
3221
|
+
const slideActions = slide && /* @__PURE__ */ jsxs6(Group3, { gap: 6, children: [
|
|
3222
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: strings.moveUp, children: /* @__PURE__ */ jsx8(
|
|
3223
|
+
ActionIcon,
|
|
3224
|
+
{
|
|
3225
|
+
variant: "default",
|
|
3226
|
+
"aria-label": strings.moveUp,
|
|
3227
|
+
disabled: index === 0,
|
|
3228
|
+
onClick: () => {
|
|
3229
|
+
apply(moveSlide(doc, index, index - 1));
|
|
3230
|
+
setSelected(index - 1);
|
|
3231
|
+
},
|
|
3232
|
+
children: "\u2191"
|
|
3233
|
+
}
|
|
3234
|
+
) }),
|
|
3235
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: strings.moveDown, children: /* @__PURE__ */ jsx8(
|
|
3236
|
+
ActionIcon,
|
|
3237
|
+
{
|
|
3238
|
+
variant: "default",
|
|
3239
|
+
"aria-label": strings.moveDown,
|
|
3240
|
+
disabled: index === doc.slides.length - 1,
|
|
3241
|
+
onClick: () => {
|
|
3242
|
+
apply(moveSlide(doc, index, index + 1));
|
|
3243
|
+
setSelected(index + 1);
|
|
3244
|
+
},
|
|
3245
|
+
children: "\u2193"
|
|
3246
|
+
}
|
|
3247
|
+
) }),
|
|
3248
|
+
/* @__PURE__ */ jsx8(Button2, { variant: "default", size: "xs", onClick: () => {
|
|
3249
|
+
const r = duplicateSlide(doc, index);
|
|
3250
|
+
apply(r.doc);
|
|
3251
|
+
setSelected(r.index);
|
|
3252
|
+
}, children: strings.duplicateSlide }),
|
|
3253
|
+
/* @__PURE__ */ jsx8(
|
|
3254
|
+
Button2,
|
|
3255
|
+
{
|
|
3256
|
+
variant: "default",
|
|
3257
|
+
size: "xs",
|
|
3258
|
+
color: "red",
|
|
3259
|
+
disabled: doc.slides.length <= 1,
|
|
3260
|
+
onClick: () => {
|
|
3261
|
+
const r = deleteSlide(doc, index);
|
|
3262
|
+
apply(r.doc);
|
|
3263
|
+
setSelected(r.index);
|
|
3264
|
+
},
|
|
3265
|
+
children: strings.deleteSlide
|
|
3266
|
+
}
|
|
3267
|
+
)
|
|
3268
|
+
] });
|
|
3269
|
+
const storyForm = /* @__PURE__ */ jsxs6(Stack4, { gap: "md", children: [
|
|
3270
|
+
/* @__PURE__ */ jsx8(Text3, { fw: 600, size: "lg", children: strings.story }),
|
|
3271
|
+
/* @__PURE__ */ jsx8(
|
|
3272
|
+
TextInput2,
|
|
3273
|
+
{
|
|
3274
|
+
label: strings.title,
|
|
3275
|
+
required: true,
|
|
3276
|
+
value: doc.title,
|
|
3277
|
+
onChange: (e) => apply(updateStory(doc, { title: e.currentTarget.value }), "story:title")
|
|
3278
|
+
}
|
|
3279
|
+
),
|
|
3280
|
+
/* @__PURE__ */ jsx8(
|
|
3281
|
+
TextInput2,
|
|
3282
|
+
{
|
|
3283
|
+
label: strings.language,
|
|
3284
|
+
description: strings.languageHint,
|
|
3285
|
+
w: 260,
|
|
3286
|
+
value: doc.language ?? "",
|
|
3287
|
+
onChange: (e) => apply(updateStory(doc, { language: e.currentTarget.value.trim() || void 0 }), "story:language")
|
|
3288
|
+
}
|
|
3289
|
+
),
|
|
3290
|
+
/* @__PURE__ */ jsx8(
|
|
3291
|
+
Select,
|
|
3292
|
+
{
|
|
3293
|
+
label: strings.map,
|
|
3294
|
+
w: 320,
|
|
3295
|
+
allowDeselect: false,
|
|
3296
|
+
data: [
|
|
3297
|
+
{ value: "auto", label: strings.mapAuto },
|
|
3298
|
+
{ value: "standard", label: strings.mapStandard },
|
|
3299
|
+
{ value: "historical", label: strings.mapHistorical },
|
|
3300
|
+
{ value: "none", label: strings.mapNone }
|
|
3301
|
+
],
|
|
3302
|
+
value: doc.presentation?.basemap ?? "auto",
|
|
3303
|
+
onChange: (value) => value && apply(updateStory(doc, {
|
|
3304
|
+
presentation: { ...doc.presentation, basemap: value }
|
|
3305
|
+
}))
|
|
3306
|
+
}
|
|
3307
|
+
)
|
|
3308
|
+
] });
|
|
3309
|
+
const slideForm = slide && /* @__PURE__ */ jsxs6(Stack4, { gap: "md", children: [
|
|
3310
|
+
/* @__PURE__ */ jsxs6(Group3, { justify: "space-between", wrap: "wrap", gap: "xs", children: [
|
|
3311
|
+
/* @__PURE__ */ jsx8(Text3, { fw: 600, size: "lg", children: index === 0 ? strings.openingSlide : `${index + 1} / ${doc.slides.length}` }),
|
|
3312
|
+
slideActions
|
|
3313
|
+
] }),
|
|
3314
|
+
/* @__PURE__ */ jsx8(
|
|
3315
|
+
TextInput2,
|
|
3316
|
+
{
|
|
3317
|
+
label: strings.slideTitle,
|
|
3318
|
+
value: slide.title ?? "",
|
|
3319
|
+
onChange: (e) => setSlide({ title: e.currentTarget.value || void 0 }, "title")
|
|
3320
|
+
}
|
|
3321
|
+
),
|
|
3322
|
+
/* @__PURE__ */ jsx8(
|
|
3323
|
+
DateField,
|
|
3324
|
+
{
|
|
3325
|
+
value: slide.date,
|
|
3326
|
+
language: doc.language,
|
|
3327
|
+
parse: parseDateText,
|
|
3328
|
+
strings,
|
|
3329
|
+
onChange: (date) => setSlide({ date }, "date")
|
|
3330
|
+
}
|
|
3331
|
+
),
|
|
3332
|
+
/* @__PURE__ */ jsx8(
|
|
3333
|
+
StoryTextField,
|
|
3334
|
+
{
|
|
3335
|
+
label: strings.text,
|
|
3336
|
+
value: slide.text ?? "",
|
|
3337
|
+
boldLabel: strings.bold,
|
|
3338
|
+
italicLabel: strings.italic,
|
|
3339
|
+
minRows: 5,
|
|
3340
|
+
onChange: (text) => setSlide({ text: text || void 0 }, "text")
|
|
3341
|
+
}
|
|
3342
|
+
),
|
|
3343
|
+
slide.place && /* @__PURE__ */ jsxs6(Stack4, { gap: 2, children: [
|
|
3344
|
+
/* @__PURE__ */ jsx8(Text3, { size: "sm", fw: 500, children: strings.place }),
|
|
3345
|
+
/* @__PURE__ */ jsxs6(Text3, { size: "sm", children: [
|
|
3346
|
+
slide.place.name ?? "",
|
|
3347
|
+
slide.place.lat !== void 0 && slide.place.lon !== void 0 && /* @__PURE__ */ jsxs6(Text3, { span: true, c: "dimmed", size: "sm", children: [
|
|
3348
|
+
" ",
|
|
3349
|
+
slide.place.lat.toFixed(4),
|
|
3350
|
+
", ",
|
|
3351
|
+
slide.place.lon.toFixed(4)
|
|
3352
|
+
] })
|
|
3353
|
+
] })
|
|
3354
|
+
] }),
|
|
3355
|
+
slide.media && slide.media.length > 0 && /* @__PURE__ */ jsxs6(Stack4, { gap: 4, children: [
|
|
3356
|
+
/* @__PURE__ */ jsx8(Text3, { size: "sm", fw: 500, children: strings.photos }),
|
|
3357
|
+
/* @__PURE__ */ jsx8(Group3, { gap: "sm", children: slide.media.map((m, i) => /* @__PURE__ */ jsxs6(Group3, { gap: "xs", wrap: "nowrap", children: [
|
|
3358
|
+
/* @__PURE__ */ jsx8(Thumb, { doc, slide: { id: "", media: [m] }, resolveMedia }),
|
|
3359
|
+
/* @__PURE__ */ jsx8(Text3, { size: "xs", c: "dimmed", maw: 200, lineClamp: 2, children: m.caption ?? "" })
|
|
3360
|
+
] }, i)) })
|
|
3361
|
+
] })
|
|
3362
|
+
] }, slide.id);
|
|
3363
|
+
const list = /* @__PURE__ */ jsxs6(Stack4, { gap: "xs", children: [
|
|
3364
|
+
/* @__PURE__ */ jsxs6(
|
|
3365
|
+
UnstyledButton2,
|
|
3366
|
+
{
|
|
3367
|
+
onClick: () => setSelected(STORY),
|
|
3368
|
+
style: { padding: "8px", borderRadius: 6, background: index === STORY ? "var(--mantine-primary-color-light)" : void 0 },
|
|
3369
|
+
children: [
|
|
3370
|
+
/* @__PURE__ */ jsx8(Text3, { fw: 600, size: "sm", children: strings.story }),
|
|
3371
|
+
/* @__PURE__ */ jsx8(Text3, { size: "xs", c: "dimmed", children: strings.storySettings })
|
|
3372
|
+
]
|
|
3373
|
+
}
|
|
3374
|
+
),
|
|
3375
|
+
/* @__PURE__ */ jsx8(Divider, { label: strings.slides, labelPosition: "left" }),
|
|
3376
|
+
/* @__PURE__ */ jsx8(
|
|
3377
|
+
SlideList,
|
|
3378
|
+
{
|
|
3379
|
+
label: strings.slides,
|
|
3380
|
+
items: doc.slides,
|
|
3381
|
+
selected: index,
|
|
3382
|
+
onSelect: setSelected,
|
|
3383
|
+
onMove: (from, to) => {
|
|
3384
|
+
apply(moveSlide(doc, from, to));
|
|
3385
|
+
setSelected(to);
|
|
3386
|
+
},
|
|
3387
|
+
getKey: (s) => s.id,
|
|
3388
|
+
renderItem: (s, i) => /* @__PURE__ */ jsxs6(Group3, { gap: "sm", wrap: "nowrap", children: [
|
|
3389
|
+
/* @__PURE__ */ jsx8(Thumb, { doc, slide: s, resolveMedia }),
|
|
3390
|
+
/* @__PURE__ */ jsxs6(Box, { style: { minWidth: 0 }, children: [
|
|
3391
|
+
/* @__PURE__ */ jsx8(Text3, { size: "sm", fw: 500, truncate: true, dir: "auto", c: s.title ? void 0 : "dimmed", children: s.title || strings.untitledSlide }),
|
|
3392
|
+
/* @__PURE__ */ jsx8(Text3, { size: "xs", c: "dimmed", truncate: true, children: i === 0 ? strings.openingSlide : s.date?.text ?? "" })
|
|
3393
|
+
] })
|
|
3394
|
+
] })
|
|
3395
|
+
}
|
|
3396
|
+
),
|
|
3397
|
+
/* @__PURE__ */ jsxs6(
|
|
3398
|
+
Button2,
|
|
3399
|
+
{
|
|
3400
|
+
variant: "light",
|
|
3401
|
+
size: "xs",
|
|
3402
|
+
mt: 4,
|
|
3403
|
+
onClick: () => {
|
|
3404
|
+
const r = addSlide(doc, index === STORY ? doc.slides.length - 1 : index);
|
|
3405
|
+
apply(r.doc);
|
|
3406
|
+
setSelected(r.index);
|
|
3407
|
+
},
|
|
3408
|
+
children: [
|
|
3409
|
+
"+ ",
|
|
3410
|
+
strings.addSlide
|
|
3411
|
+
]
|
|
3412
|
+
}
|
|
3413
|
+
)
|
|
3414
|
+
] });
|
|
3415
|
+
const preview = /* @__PURE__ */ jsx8(Box, { style: { position: "relative", height: wide ? "100%" : 460, borderRadius: 8, overflow: "hidden", border: "1px solid var(--mantine-color-default-border)" }, children: /* @__PURE__ */ jsx8(
|
|
3416
|
+
StoryPlayer,
|
|
3417
|
+
{
|
|
3418
|
+
story: doc,
|
|
3419
|
+
resolveMedia,
|
|
3420
|
+
dark,
|
|
3421
|
+
strings: playerStrings,
|
|
3422
|
+
keyboard: false,
|
|
3423
|
+
initialSlide: index === STORY ? 0 : index,
|
|
3424
|
+
onSlideChange: (i) => {
|
|
3425
|
+
if (i !== index && index !== STORY) setSelected(i);
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
) });
|
|
3429
|
+
const column = (children, width) => /* @__PURE__ */ jsx8(
|
|
3430
|
+
Box,
|
|
3431
|
+
{
|
|
3432
|
+
style: {
|
|
3433
|
+
width,
|
|
3434
|
+
flex: width ? "none" : 1,
|
|
3435
|
+
minWidth: 0,
|
|
3436
|
+
padding: 16,
|
|
3437
|
+
overflowY: wide ? "auto" : void 0,
|
|
3438
|
+
height: wide ? "100%" : void 0
|
|
3439
|
+
},
|
|
3440
|
+
children
|
|
3441
|
+
}
|
|
3442
|
+
);
|
|
3443
|
+
return /* @__PURE__ */ jsxs6(Box, { style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
|
|
3444
|
+
/* @__PURE__ */ jsxs6(
|
|
3445
|
+
Group3,
|
|
3446
|
+
{
|
|
3447
|
+
h: BAR_HEIGHT2,
|
|
3448
|
+
px: "md",
|
|
3449
|
+
gap: "sm",
|
|
3450
|
+
wrap: "nowrap",
|
|
3451
|
+
justify: "space-between",
|
|
3452
|
+
style: { flex: "none", borderBottom: "1px solid var(--mantine-color-default-border)" },
|
|
3453
|
+
children: [
|
|
3454
|
+
/* @__PURE__ */ jsxs6(Group3, { gap: "sm", wrap: "nowrap", style: { minWidth: 0 }, children: [
|
|
3455
|
+
brand,
|
|
3456
|
+
/* @__PURE__ */ jsx8(Text3, { fw: 600, truncate: true, dir: "auto", children: doc.title })
|
|
3457
|
+
] }),
|
|
3458
|
+
/* @__PURE__ */ jsxs6(Group3, { gap: "xs", wrap: "nowrap", children: [
|
|
3459
|
+
issues.length > 0 && /* @__PURE__ */ jsxs6(Popover, { opened: problemsOpen, onChange: setProblemsOpen, width: 360, position: "bottom-end", withArrow: true, children: [
|
|
3460
|
+
/* @__PURE__ */ jsx8(Popover.Target, { children: /* @__PURE__ */ jsx8(Badge, { color: "red", variant: "light", style: { cursor: "pointer" }, onClick: () => setProblemsOpen((o) => !o), children: strings.problems(issues.length) }) }),
|
|
3461
|
+
/* @__PURE__ */ jsx8(Popover.Dropdown, { children: /* @__PURE__ */ jsx8(Stack4, { gap: 6, children: issues.map((issue, i) => {
|
|
3462
|
+
const at = issueSlide(issue);
|
|
3463
|
+
return /* @__PURE__ */ jsxs6(UnstyledButton2, { onClick: () => {
|
|
3464
|
+
setSelected(at);
|
|
3465
|
+
setProblemsOpen(false);
|
|
3466
|
+
}, children: [
|
|
3467
|
+
/* @__PURE__ */ jsx8(Text3, { size: "sm", fw: 500, children: at === STORY ? strings.story : doc.slides[at]?.title || `${strings.untitledSlide} ${at + 1}` }),
|
|
3468
|
+
/* @__PURE__ */ jsxs6(Text3, { size: "xs", c: "dimmed", children: [
|
|
3469
|
+
issue.path,
|
|
3470
|
+
" ",
|
|
3471
|
+
issue.message
|
|
3472
|
+
] })
|
|
3473
|
+
] }, i);
|
|
3474
|
+
}) }) })
|
|
3475
|
+
] }),
|
|
3476
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: strings.undo, children: /* @__PURE__ */ jsx8(ActionIcon, { variant: "default", size: "lg", "aria-label": strings.undo, disabled: history.past.length === 0, onClick: () => setHistory(undo), children: "\u21B6" }) }),
|
|
3477
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: strings.redo, children: /* @__PURE__ */ jsx8(ActionIcon, { variant: "default", size: "lg", "aria-label": strings.redo, disabled: history.future.length === 0, onClick: () => setHistory(redo), children: "\u21B7" }) }),
|
|
3478
|
+
/* @__PURE__ */ jsx8(Button2, { variant: "default", onClick: () => setPresenting(true), children: strings.present }),
|
|
3479
|
+
toolbar
|
|
3480
|
+
] })
|
|
3481
|
+
]
|
|
3482
|
+
}
|
|
3483
|
+
),
|
|
3484
|
+
/* @__PURE__ */ jsxs6(
|
|
3485
|
+
Box,
|
|
3486
|
+
{
|
|
3487
|
+
style: {
|
|
3488
|
+
flex: 1,
|
|
3489
|
+
minHeight: 0,
|
|
3490
|
+
display: "flex",
|
|
3491
|
+
flexDirection: wide ? "row" : "column",
|
|
3492
|
+
overflowY: wide ? void 0 : "auto"
|
|
3493
|
+
},
|
|
3494
|
+
children: [
|
|
3495
|
+
column(list, wide ? 280 : void 0),
|
|
3496
|
+
column(index === STORY ? storyForm : slideForm, wide ? "min(520px, 36%)" : void 0),
|
|
3497
|
+
column(preview)
|
|
3498
|
+
]
|
|
3499
|
+
}
|
|
3500
|
+
),
|
|
3501
|
+
/* @__PURE__ */ jsx8(Modal, { opened: presenting, onClose: () => setPresenting(false), fullScreen: true, withCloseButton: false, padding: 0, children: /* @__PURE__ */ jsx8(Box, { style: { position: "fixed", inset: 0 }, children: /* @__PURE__ */ jsx8(
|
|
3502
|
+
StoryPlayer,
|
|
3503
|
+
{
|
|
3504
|
+
story: doc,
|
|
3505
|
+
resolveMedia,
|
|
3506
|
+
dark,
|
|
3507
|
+
strings: playerStrings,
|
|
3508
|
+
initialSlide: index === STORY ? 0 : index,
|
|
3509
|
+
onClose: () => setPresenting(false)
|
|
3510
|
+
}
|
|
3511
|
+
) }) })
|
|
3512
|
+
] });
|
|
3513
|
+
}
|
|
3514
|
+
export {
|
|
3515
|
+
COALESCE_MS,
|
|
3516
|
+
DateField,
|
|
3517
|
+
EDITOR_ENGLISH,
|
|
3518
|
+
SlideList,
|
|
3519
|
+
StoryEditor,
|
|
3520
|
+
StoryTextField,
|
|
3521
|
+
addSlide,
|
|
3522
|
+
blankStory,
|
|
3523
|
+
deleteSlide,
|
|
3524
|
+
duplicateSlide,
|
|
3525
|
+
moveSlide,
|
|
3526
|
+
nextSlideId,
|
|
3527
|
+
pruneMedia,
|
|
3528
|
+
record,
|
|
3529
|
+
redo,
|
|
3530
|
+
slideDate,
|
|
3531
|
+
startHistory,
|
|
3532
|
+
storyFileName,
|
|
3533
|
+
suggestEdtf,
|
|
3534
|
+
undo,
|
|
3535
|
+
updateSlide,
|
|
3536
|
+
updateStory,
|
|
3537
|
+
usedMedia
|
|
3538
|
+
};
|
|
3539
|
+
//# sourceMappingURL=editor.js.map
|