@cognitiveproof/c2pa-react-ddex-component 0.1.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.
@@ -0,0 +1,845 @@
1
+ import e from "react";
2
+ import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
3
+ //#region src/components/Ddex/DDEX_Header.tsx
4
+ var i = "<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" role=\"img\" aria-label=\"DDEX\">\n <rect x=\"0.5\" y=\"0.5\" width=\"23\" height=\"23\" rx=\"5\" fill=\"#111827\"/>\n <path d=\"M8 16.6V7.7L17.2 6v9\" stroke=\"#ffffff\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <circle cx=\"6.2\" cy=\"16.6\" r=\"2\" fill=\"#ffffff\"/>\n <circle cx=\"15.4\" cy=\"15\" r=\"2\" fill=\"#ffffff\"/>\n</svg>", a = () => /* @__PURE__ */ r("div", {
5
+ className: "ddex-header",
6
+ children: [/* @__PURE__ */ n("div", {
7
+ className: "ddex-mark",
8
+ dangerouslySetInnerHTML: { __html: i }
9
+ }), /* @__PURE__ */ n("span", {
10
+ className: "ddex-header-title",
11
+ children: "DDEX Release Data"
12
+ })]
13
+ }), o = "org.mixotron.ddex";
14
+ function s(e) {
15
+ return e.assertions?.[o];
16
+ }
17
+ function c(e) {
18
+ return e?.ReleaseList?.Release?.[0];
19
+ }
20
+ function l(e, t) {
21
+ if (e && t) return t.find((t) => t.PartyReference === e)?.PartyName?.FullName;
22
+ }
23
+ function u(e, t) {
24
+ return !e || e.length === 0 ? "" : e.map((e) => l(e.ArtistPartyReference, t)).filter((e) => !!e).join(", ");
25
+ }
26
+ function d(e, t) {
27
+ let n = t?.ResourceList?.SoundRecording ?? [], r = e?.ReleaseResourceReferenceList;
28
+ return !r || r.length === 0 ? n : n.filter((e) => e.ResourceReference && r.includes(e.ResourceReference));
29
+ }
30
+ function f(e, t) {
31
+ let n = t?.DealList?.ReleaseDeal ?? [];
32
+ return e?.ReleaseReference ? n.filter((t) => t.DealReleaseReference === e.ReleaseReference) : n;
33
+ }
34
+ function p(e) {
35
+ let t = e?.WholesalePrice;
36
+ if (t?.Amount) return t.CurrencyCode ? `${t.Amount} ${t.CurrencyCode}` : t.Amount;
37
+ }
38
+ var m = {
39
+ SubscriptionModel: "Subscription",
40
+ PayAsYouGoModel: "Pay As You Go",
41
+ AdvertisementSupportedModel: "Ad Supported",
42
+ FreeOfChargeModel: "Free of Charge",
43
+ RightsClaimModel: "Rights Claim"
44
+ };
45
+ function h(e) {
46
+ if (e) return m[e] ?? w(e);
47
+ }
48
+ var g = {
49
+ OnDemandStream: "On-Demand Stream",
50
+ PermanentDownload: "Permanent Download",
51
+ ConditionalDownload: "Conditional Download",
52
+ NonInteractiveStream: "Non-Interactive Stream"
53
+ };
54
+ function _(e) {
55
+ return g[e] ?? w(e);
56
+ }
57
+ var v = {
58
+ Explicit: "Explicit",
59
+ NotExplicit: "Not Explicit",
60
+ ExplicitContentEdited: "Edited",
61
+ NoAdviceAvailable: "No Advice Available"
62
+ };
63
+ function y(e) {
64
+ if (e) return v[e] ?? w(e);
65
+ }
66
+ function b(e) {
67
+ return e.claimGenerator ?? e.claimGeneratorInfo?.[0]?.name ?? "Unknown";
68
+ }
69
+ function x(e) {
70
+ return e.split(" ").filter(Boolean).map((e) => e[0].toUpperCase()).join("").slice(0, 3) || "?";
71
+ }
72
+ function S(e) {
73
+ if (e) try {
74
+ return new Date(e).toLocaleDateString(void 0, {
75
+ year: "numeric",
76
+ month: "long",
77
+ day: "numeric"
78
+ });
79
+ } catch {
80
+ return e;
81
+ }
82
+ }
83
+ function C(e) {
84
+ if (e) try {
85
+ return new Date(e).toLocaleString(void 0, {
86
+ year: "numeric",
87
+ month: "long",
88
+ day: "numeric",
89
+ hour: "numeric",
90
+ minute: "2-digit"
91
+ });
92
+ } catch {
93
+ return e;
94
+ }
95
+ }
96
+ function w(e) {
97
+ return e.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (e) => e.toUpperCase());
98
+ }
99
+ function T(e) {
100
+ return e == null ? "" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? e.map((e) => T(e)).filter(Boolean).join(", ") : typeof e == "object" ? Object.entries(e).map(([e, t]) => `${w(e)}: ${T(t)}`).filter(Boolean).join("; ") : String(e);
101
+ }
102
+ //#endregion
103
+ //#region src/components/Ddex/levels/L1/DDEXL1.tsx
104
+ function E({ manifest: e, moreInfo: t, className: i }) {
105
+ let o = s(e), l = c(o), d = l?.DisplayTitleText ?? e.title, f = u(l?.DisplayArtist, o?.PartyList), p = b(e), m = x(d || p), h = l?.DisplayGenre, g = y(l?.ParentalWarningType), _ = l?.ParentalWarningType === "Explicit";
106
+ return /* @__PURE__ */ r("div", {
107
+ className: `ddex-card ${i ?? ""}`,
108
+ children: [
109
+ /* @__PURE__ */ n(a, {}),
110
+ /* @__PURE__ */ r("div", {
111
+ className: "ddex-container",
112
+ children: [e.thumbnail ? /* @__PURE__ */ n("img", {
113
+ src: e.thumbnail,
114
+ alt: "Thumbnail",
115
+ className: "ddex-thumbnail"
116
+ }) : /* @__PURE__ */ n("div", {
117
+ className: "ddex-square",
118
+ children: /* @__PURE__ */ n("span", {
119
+ className: "ddex-logo-text",
120
+ children: m
121
+ })
122
+ }), /* @__PURE__ */ r("div", {
123
+ className: "ddex-summary",
124
+ children: [/* @__PURE__ */ n("span", {
125
+ className: "ddex-media-title",
126
+ children: d
127
+ }), /* @__PURE__ */ n("span", {
128
+ className: "ddex-artist-name",
129
+ children: f || p
130
+ })]
131
+ })]
132
+ }),
133
+ !o && /* @__PURE__ */ n("div", {
134
+ className: "ddex-empty",
135
+ children: "No DDEX release data found."
136
+ }),
137
+ (h || g) && /* @__PURE__ */ r("div", {
138
+ className: "ddex-badges",
139
+ children: [h && /* @__PURE__ */ n("span", {
140
+ className: "ddex-badge",
141
+ children: h
142
+ }), g && /* @__PURE__ */ n("span", {
143
+ className: `ddex-badge ${_ ? "ddex-badge-warning" : ""}`,
144
+ children: g
145
+ })]
146
+ }),
147
+ t && /* @__PURE__ */ n("div", {
148
+ className: "ddex-action",
149
+ children: /* @__PURE__ */ n("button", {
150
+ onClick: t,
151
+ className: "ddex-button",
152
+ children: "More Info"
153
+ })
154
+ })
155
+ ]
156
+ });
157
+ }
158
+ //#endregion
159
+ //#region src/components/Ddex/levels/L2/DDEXL2.tsx
160
+ function D({ className: e, manifest: i, moreInfo: o }) {
161
+ let l = s(i), m = c(l), g = m?.DisplayTitleText ?? i.title, v = u(m?.DisplayArtist, l?.PartyList), C = b(i), w = x(g || C), T = m?.DisplayGenre, E = y(m?.ParentalWarningType), D = m?.ParentalWarningType === "Explicit", O = d(m, l), k = f(m, l);
162
+ return /* @__PURE__ */ r("div", {
163
+ className: `ddex-card ${e ?? ""}`,
164
+ children: [
165
+ /* @__PURE__ */ n(a, {}),
166
+ /* @__PURE__ */ r("div", {
167
+ className: "ddex-container",
168
+ children: [i.thumbnail ? /* @__PURE__ */ n("img", {
169
+ src: i.thumbnail,
170
+ alt: "Thumbnail",
171
+ className: "ddex-thumbnail"
172
+ }) : /* @__PURE__ */ n("div", {
173
+ className: "ddex-square",
174
+ children: /* @__PURE__ */ n("span", {
175
+ className: "ddex-logo-text",
176
+ children: w
177
+ })
178
+ }), /* @__PURE__ */ r("div", {
179
+ className: "ddex-summary",
180
+ children: [/* @__PURE__ */ n("span", {
181
+ className: "ddex-media-title",
182
+ children: g
183
+ }), /* @__PURE__ */ n("span", {
184
+ className: "ddex-artist-name",
185
+ children: v || C
186
+ })]
187
+ })]
188
+ }),
189
+ l ? /* @__PURE__ */ r(t, { children: [
190
+ (T || E) && /* @__PURE__ */ r("div", {
191
+ className: "ddex-badges",
192
+ children: [T && /* @__PURE__ */ n("span", {
193
+ className: "ddex-badge",
194
+ children: T
195
+ }), E && /* @__PURE__ */ n("span", {
196
+ className: `ddex-badge ${D ? "ddex-badge-warning" : ""}`,
197
+ children: E
198
+ })]
199
+ }),
200
+ m && (m.LabelName || m.ReleaseId?.UPC || m.CLine || m.PLine) && /* @__PURE__ */ r(t, { children: [
201
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
202
+ /* @__PURE__ */ n("div", {
203
+ className: "ddex-section-title",
204
+ children: "Release"
205
+ }),
206
+ m.LabelName && /* @__PURE__ */ r("div", {
207
+ className: "ddex-key-value",
208
+ children: [/* @__PURE__ */ n("div", {
209
+ className: "ddex-key-value-label",
210
+ children: "Label"
211
+ }), /* @__PURE__ */ n("div", {
212
+ className: "ddex-key-value-value",
213
+ children: m.LabelName
214
+ })]
215
+ }),
216
+ m.ReleaseId?.UPC && /* @__PURE__ */ r("div", {
217
+ className: "ddex-key-value",
218
+ children: [/* @__PURE__ */ n("div", {
219
+ className: "ddex-key-value-label",
220
+ children: "UPC"
221
+ }), /* @__PURE__ */ n("div", {
222
+ className: "ddex-key-value-value",
223
+ children: m.ReleaseId.UPC
224
+ })]
225
+ }),
226
+ m.CLine && /* @__PURE__ */ r("div", {
227
+ className: "ddex-key-value",
228
+ children: [/* @__PURE__ */ n("div", {
229
+ className: "ddex-key-value-label",
230
+ children: "℗ / © Line"
231
+ }), /* @__PURE__ */ n("div", {
232
+ className: "ddex-key-value-value",
233
+ children: m.CLine
234
+ })]
235
+ })
236
+ ] }),
237
+ O.length > 0 && /* @__PURE__ */ r(t, { children: [
238
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
239
+ /* @__PURE__ */ n("div", {
240
+ className: "ddex-section-title",
241
+ children: "Tracks"
242
+ }),
243
+ /* @__PURE__ */ n("div", {
244
+ className: "ddex-track-list",
245
+ children: O.map((e, t) => /* @__PURE__ */ r("div", {
246
+ className: "ddex-track-item",
247
+ children: [/* @__PURE__ */ n("div", {
248
+ className: "ddex-track-title",
249
+ children: e.DisplayTitleText
250
+ }), e.ISRC && /* @__PURE__ */ r("div", {
251
+ className: "ddex-track-isrc",
252
+ children: ["ISRC ", e.ISRC]
253
+ })]
254
+ }, e.ResourceReference ?? t))
255
+ })
256
+ ] }),
257
+ k.length > 0 && /* @__PURE__ */ r(t, { children: [
258
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
259
+ /* @__PURE__ */ n("div", {
260
+ className: "ddex-section-title",
261
+ children: "Deals"
262
+ }),
263
+ /* @__PURE__ */ n("div", {
264
+ className: "ddex-deal-list",
265
+ children: k.map((e, t) => {
266
+ let i = e.Deal?.DealTerms, a = p(i?.PriceInformation), o = h(i?.CommercialModelType), s = e.Deal?.Territory ?? [], c = S(i?.ValidityPeriod?.StartDate);
267
+ return /* @__PURE__ */ r("div", {
268
+ className: "ddex-deal-item",
269
+ children: [/* @__PURE__ */ r("div", {
270
+ className: "ddex-deal-row",
271
+ children: [o && /* @__PURE__ */ n("span", {
272
+ className: "ddex-badge",
273
+ children: o
274
+ }), (i?.UseType ?? []).map((e) => /* @__PURE__ */ n("span", {
275
+ className: "ddex-badge",
276
+ children: _(e)
277
+ }, e))]
278
+ }), /* @__PURE__ */ r("div", {
279
+ className: "ddex-deal-meta",
280
+ children: [
281
+ a && /* @__PURE__ */ n("span", { children: a }),
282
+ s.length > 0 && /* @__PURE__ */ n("span", { children: s.join(", ") }),
283
+ c && /* @__PURE__ */ r("span", { children: ["From ", c] })
284
+ ]
285
+ })]
286
+ }, t);
287
+ })
288
+ })
289
+ ] })
290
+ ] }) : /* @__PURE__ */ n("div", {
291
+ className: "ddex-empty",
292
+ children: "No DDEX release data found."
293
+ }),
294
+ o && /* @__PURE__ */ n("div", {
295
+ className: "ddex-action",
296
+ children: /* @__PURE__ */ n("button", {
297
+ onClick: o,
298
+ className: "ddex-button",
299
+ children: "More Info"
300
+ })
301
+ })
302
+ ]
303
+ });
304
+ }
305
+ //#endregion
306
+ //#region src/server/ddex/convert.ts
307
+ function O(e) {
308
+ let t = [
309
+ N(e),
310
+ I(e),
311
+ R(e),
312
+ z(e),
313
+ U(e)
314
+ ].filter(Boolean);
315
+ return `<?xml version="1.0" encoding="UTF-8"?>\n${t.length > 0 ? `<NewReleaseMessage>\n${M(t.join("\n"))}\n</NewReleaseMessage>` : "<NewReleaseMessage />"}\n`;
316
+ }
317
+ function k(e) {
318
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
319
+ }
320
+ function A(e, t) {
321
+ return t === void 0 || t === "" ? "" : `<${e}>${k(t)}</${e}>`;
322
+ }
323
+ function j(e, t) {
324
+ let n = t.filter(Boolean).join("\n");
325
+ return n ? `<${e}>\n${M(n)}\n</${e}>` : "";
326
+ }
327
+ function M(e) {
328
+ return e.split("\n").map((e) => e && ` ${e}`).join("\n");
329
+ }
330
+ function N(e) {
331
+ let t = e.MessageHeader;
332
+ return t ? j("MessageHeader", [A("MessageId", t.MessageId), A("MessageCreatedDateTime", t.MessageCreatedDateTime)]) : "";
333
+ }
334
+ function P(e) {
335
+ return e ? e.map((e) => j("DisplayArtist", [A("ArtistPartyReference", e.ArtistPartyReference)])) : [];
336
+ }
337
+ function F(e) {
338
+ return j("Party", [A("PartyReference", e.PartyReference), e.PartyName?.FullName ? j("PartyName", [A("FullName", e.PartyName.FullName)]) : ""]);
339
+ }
340
+ function I(e) {
341
+ let t = e.PartyList;
342
+ return !t || t.length === 0 ? "" : j("PartyList", t.map(F));
343
+ }
344
+ function L(e) {
345
+ return j("SoundRecording", [
346
+ A("ResourceReference", e.ResourceReference),
347
+ A("ISRC", e.ISRC),
348
+ A("DisplayTitleText", e.DisplayTitleText),
349
+ A("Duration", e.Duration),
350
+ ...P(e.DisplayArtist)
351
+ ]);
352
+ }
353
+ function R(e) {
354
+ let t = e.ResourceList?.SoundRecording;
355
+ return !t || t.length === 0 ? "" : j("ResourceList", t.map(L));
356
+ }
357
+ function ee(e) {
358
+ let t = Object.entries(e ?? {}).filter((e) => !!e[1]);
359
+ return t.length === 0 ? "" : j("ReleaseId", t.map(([e, t]) => A(e, t)));
360
+ }
361
+ function te(e) {
362
+ return !e || e.length === 0 ? "" : j("ReleaseResourceReferenceList", e.map((e) => A("ReleaseResourceReference", e)));
363
+ }
364
+ function ne(e) {
365
+ return j("Release", [
366
+ A("ReleaseReference", e.ReleaseReference),
367
+ ee(e.ReleaseId),
368
+ A("DisplayTitleText", e.DisplayTitleText),
369
+ ...P(e.DisplayArtist),
370
+ A("LabelName", e.LabelName),
371
+ A("DisplayGenre", e.DisplayGenre),
372
+ A("ParentalWarningType", e.ParentalWarningType),
373
+ A("CLine", e.CLine),
374
+ A("PLine", e.PLine),
375
+ te(e.ReleaseResourceReferenceList)
376
+ ]);
377
+ }
378
+ function z(e) {
379
+ let t = e.ReleaseList?.Release;
380
+ return !t || t.length === 0 ? "" : j("ReleaseList", t.map(ne));
381
+ }
382
+ function B(e) {
383
+ let t = e?.WholesalePrice;
384
+ return t?.Amount ? j("PriceInformation", [j("WholesalePrice", [A("Amount", t.Amount), A("CurrencyCode", t.CurrencyCode)])]) : "";
385
+ }
386
+ function V(e) {
387
+ return e ? j("DealTerms", [
388
+ A("CommercialModelType", e.CommercialModelType),
389
+ ...(e.UseType ?? []).map((e) => A("UseType", e)),
390
+ B(e.PriceInformation),
391
+ e.ValidityPeriod ? j("ValidityPeriod", [A("StartDate", e.ValidityPeriod.StartDate), A("EndDate", e.ValidityPeriod.EndDate)]) : ""
392
+ ]) : "";
393
+ }
394
+ function H(e) {
395
+ return j("ReleaseDeal", [A("DealReleaseReference", e.DealReleaseReference), e.Deal ? j("Deal", [...(e.Deal.Territory ?? []).map((e) => A("Territory", e)), V(e.Deal.DealTerms)]) : ""]);
396
+ }
397
+ function U(e) {
398
+ let t = e.DealList?.ReleaseDeal;
399
+ return !t || t.length === 0 ? "" : j("DealList", t.map(H));
400
+ }
401
+ function W(e) {
402
+ let t = G(e);
403
+ return {
404
+ MessageHeader: X(t),
405
+ PartyList: ie(t),
406
+ ResourceList: oe(t),
407
+ ReleaseList: le(t),
408
+ DealList: me(t)
409
+ };
410
+ }
411
+ function G(e) {
412
+ if (typeof DOMParser > "u") throw Error("xmlToDdexAssertion requires a DOMParser implementation (browser or a DOM-compatible environment).");
413
+ let t = new DOMParser().parseFromString(e, "application/xml"), n = t.getElementsByTagName("parsererror")[0];
414
+ if (n) throw Error(`Invalid DDEX XML: ${n.textContent ?? "unknown parse error"}`);
415
+ return t.documentElement;
416
+ }
417
+ function K(e, t) {
418
+ if (e) for (let n = 0; n < e.children.length; n++) {
419
+ let r = e.children[n];
420
+ if (r.tagName === t) return r;
421
+ }
422
+ }
423
+ function q(e, t) {
424
+ if (!e) return [];
425
+ let n = [];
426
+ for (let r = 0; r < e.children.length; r++) {
427
+ let i = e.children[r];
428
+ i.tagName === t && n.push(i);
429
+ }
430
+ return n;
431
+ }
432
+ function J(e) {
433
+ return e?.textContent?.trim() || void 0;
434
+ }
435
+ function Y(e, t) {
436
+ return J(K(e, t));
437
+ }
438
+ function X(e) {
439
+ let t = K(e, "MessageHeader");
440
+ if (!t) return;
441
+ let n = Y(t, "MessageId"), r = Y(t, "MessageCreatedDateTime");
442
+ if (n || r) return {
443
+ MessageId: n,
444
+ MessageCreatedDateTime: r
445
+ };
446
+ }
447
+ function Z(e) {
448
+ let t = q(e, "DisplayArtist").map((e) => Y(e, "ArtistPartyReference")).filter((e) => !!e).map((e) => ({ ArtistPartyReference: e }));
449
+ return t.length > 0 ? t : void 0;
450
+ }
451
+ function re(e) {
452
+ let t = Y(K(e, "PartyName"), "FullName");
453
+ return {
454
+ PartyReference: Y(e, "PartyReference"),
455
+ PartyName: t ? { FullName: t } : void 0
456
+ };
457
+ }
458
+ function ie(e) {
459
+ let t = K(e, "PartyList");
460
+ if (!t) return;
461
+ let n = q(t, "Party").map(re);
462
+ return n.length > 0 ? n : void 0;
463
+ }
464
+ function ae(e) {
465
+ return {
466
+ ResourceReference: Y(e, "ResourceReference"),
467
+ ISRC: Y(e, "ISRC"),
468
+ DisplayTitleText: Y(e, "DisplayTitleText"),
469
+ Duration: Y(e, "Duration"),
470
+ DisplayArtist: Z(e)
471
+ };
472
+ }
473
+ function oe(e) {
474
+ let t = K(e, "ResourceList");
475
+ if (!t) return;
476
+ let n = q(t, "SoundRecording").map(ae);
477
+ return n.length > 0 ? { SoundRecording: n } : void 0;
478
+ }
479
+ function se(e) {
480
+ let t = K(e, "ReleaseId");
481
+ if (!t) return;
482
+ let n = {};
483
+ for (let e = 0; e < t.children.length; e++) {
484
+ let r = t.children[e], i = J(r);
485
+ i && (n[r.tagName] = i);
486
+ }
487
+ return Object.keys(n).length > 0 ? n : void 0;
488
+ }
489
+ function Q(e) {
490
+ let t = K(e, "ReleaseResourceReferenceList");
491
+ if (!t) return;
492
+ let n = q(t, "ReleaseResourceReference").map(J).filter((e) => !!e);
493
+ return n.length > 0 ? n : void 0;
494
+ }
495
+ function ce(e) {
496
+ return {
497
+ ReleaseReference: Y(e, "ReleaseReference"),
498
+ ReleaseId: se(e),
499
+ DisplayTitleText: Y(e, "DisplayTitleText"),
500
+ DisplayArtist: Z(e),
501
+ LabelName: Y(e, "LabelName"),
502
+ DisplayGenre: Y(e, "DisplayGenre"),
503
+ ParentalWarningType: Y(e, "ParentalWarningType"),
504
+ CLine: Y(e, "CLine"),
505
+ PLine: Y(e, "PLine"),
506
+ ReleaseResourceReferenceList: Q(e)
507
+ };
508
+ }
509
+ function le(e) {
510
+ let t = K(e, "ReleaseList");
511
+ if (!t) return;
512
+ let n = q(t, "Release").map(ce);
513
+ return n.length > 0 ? { Release: n } : void 0;
514
+ }
515
+ function ue(e) {
516
+ let t = K(K(e, "PriceInformation"), "WholesalePrice");
517
+ if (!t) return;
518
+ let n = Y(t, "Amount"), r = Y(t, "CurrencyCode");
519
+ if (n || r) return { WholesalePrice: {
520
+ Amount: n,
521
+ CurrencyCode: r
522
+ } };
523
+ }
524
+ function de(e) {
525
+ let t = K(e, "DealTerms");
526
+ if (!t) return;
527
+ let n = q(t, "UseType").map(J).filter((e) => !!e), r = K(t, "ValidityPeriod"), i = Y(r, "StartDate"), a = Y(r, "EndDate");
528
+ return {
529
+ CommercialModelType: Y(t, "CommercialModelType"),
530
+ UseType: n.length > 0 ? n : void 0,
531
+ PriceInformation: ue(t),
532
+ ValidityPeriod: i || a ? {
533
+ StartDate: i,
534
+ EndDate: a
535
+ } : void 0
536
+ };
537
+ }
538
+ function fe(e) {
539
+ let t = q(e, "Territory").map(J).filter((e) => !!e), n = de(e);
540
+ if (t.length !== 0 || n) return {
541
+ Territory: t.length > 0 ? t : void 0,
542
+ DealTerms: n
543
+ };
544
+ }
545
+ function pe(e) {
546
+ let t = K(e, "Deal");
547
+ return {
548
+ DealReleaseReference: Y(e, "DealReleaseReference"),
549
+ Deal: t ? fe(t) : void 0
550
+ };
551
+ }
552
+ function me(e) {
553
+ let t = K(e, "DealList");
554
+ if (!t) return;
555
+ let n = q(t, "ReleaseDeal").map(pe);
556
+ return n.length > 0 ? { ReleaseDeal: n } : void 0;
557
+ }
558
+ //#endregion
559
+ //#region src/components/Ddex/levels/L3/DDEXL3.tsx
560
+ function he(e, t) {
561
+ let n = `${e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") || "ddex-release"}.xml`, r = new Blob([t], { type: "application/xml" }), i = URL.createObjectURL(r), a = document.createElement("a");
562
+ a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
563
+ }
564
+ function ge({ manifest: e, moreInfo: i, className: o }) {
565
+ let m = s(e), g = c(m), v = g?.DisplayTitleText ?? e.title, w = u(g?.DisplayArtist, m?.PartyList), T = b(e), E = x(v || T), D = g?.DisplayGenre, k = y(g?.ParentalWarningType), A = g?.ParentalWarningType === "Explicit", j = d(g, m), M = f(g, m), N = m?.PartyList ?? [], P = m?.MessageHeader;
566
+ return /* @__PURE__ */ r("div", {
567
+ className: `ddex-card ${o ?? ""}`,
568
+ children: [
569
+ /* @__PURE__ */ n(a, {}),
570
+ /* @__PURE__ */ r("div", {
571
+ className: "ddex-container",
572
+ children: [e.thumbnail ? /* @__PURE__ */ n("img", {
573
+ src: e.thumbnail,
574
+ alt: "Thumbnail",
575
+ className: "ddex-thumbnail"
576
+ }) : /* @__PURE__ */ n("div", {
577
+ className: "ddex-square",
578
+ children: /* @__PURE__ */ n("span", {
579
+ className: "ddex-logo-text",
580
+ children: E
581
+ })
582
+ }), /* @__PURE__ */ r("div", {
583
+ className: "ddex-summary",
584
+ children: [/* @__PURE__ */ n("span", {
585
+ className: "ddex-media-title",
586
+ children: v
587
+ }), /* @__PURE__ */ n("span", {
588
+ className: "ddex-artist-name",
589
+ children: w || T
590
+ })]
591
+ })]
592
+ }),
593
+ m ? /* @__PURE__ */ r(t, { children: [
594
+ (D || k) && /* @__PURE__ */ r("div", {
595
+ className: "ddex-badges",
596
+ children: [D && /* @__PURE__ */ n("span", {
597
+ className: "ddex-badge",
598
+ children: D
599
+ }), k && /* @__PURE__ */ n("span", {
600
+ className: `ddex-badge ${A ? "ddex-badge-warning" : ""}`,
601
+ children: k
602
+ })]
603
+ }),
604
+ g && /* @__PURE__ */ r(t, { children: [
605
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
606
+ /* @__PURE__ */ n("div", {
607
+ className: "ddex-section-title",
608
+ children: "Release"
609
+ }),
610
+ g.ReleaseReference && /* @__PURE__ */ r("div", {
611
+ className: "ddex-key-value",
612
+ children: [/* @__PURE__ */ n("div", {
613
+ className: "ddex-key-value-label",
614
+ children: "Release Reference"
615
+ }), /* @__PURE__ */ n("div", {
616
+ className: "ddex-key-value-value",
617
+ children: g.ReleaseReference
618
+ })]
619
+ }),
620
+ g.LabelName && /* @__PURE__ */ r("div", {
621
+ className: "ddex-key-value",
622
+ children: [/* @__PURE__ */ n("div", {
623
+ className: "ddex-key-value-label",
624
+ children: "Label"
625
+ }), /* @__PURE__ */ n("div", {
626
+ className: "ddex-key-value-value",
627
+ children: g.LabelName
628
+ })]
629
+ }),
630
+ g.ReleaseId?.UPC && /* @__PURE__ */ r("div", {
631
+ className: "ddex-key-value",
632
+ children: [/* @__PURE__ */ n("div", {
633
+ className: "ddex-key-value-label",
634
+ children: "UPC"
635
+ }), /* @__PURE__ */ n("div", {
636
+ className: "ddex-key-value-value",
637
+ children: g.ReleaseId.UPC
638
+ })]
639
+ }),
640
+ g.CLine && /* @__PURE__ */ r("div", {
641
+ className: "ddex-key-value",
642
+ children: [/* @__PURE__ */ n("div", {
643
+ className: "ddex-key-value-label",
644
+ children: "© Line"
645
+ }), /* @__PURE__ */ n("div", {
646
+ className: "ddex-key-value-value",
647
+ children: g.CLine
648
+ })]
649
+ }),
650
+ g.PLine && /* @__PURE__ */ r("div", {
651
+ className: "ddex-key-value",
652
+ children: [/* @__PURE__ */ n("div", {
653
+ className: "ddex-key-value-label",
654
+ children: "℗ Line"
655
+ }), /* @__PURE__ */ n("div", {
656
+ className: "ddex-key-value-value",
657
+ children: g.PLine
658
+ })]
659
+ })
660
+ ] }),
661
+ j.length > 0 && /* @__PURE__ */ r(t, { children: [
662
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
663
+ /* @__PURE__ */ n("div", {
664
+ className: "ddex-section-title",
665
+ children: "Tracks"
666
+ }),
667
+ /* @__PURE__ */ n("div", {
668
+ className: "ddex-track-list",
669
+ children: j.map((e, t) => /* @__PURE__ */ r("div", {
670
+ className: "ddex-track-item",
671
+ children: [/* @__PURE__ */ n("div", {
672
+ className: "ddex-track-title",
673
+ children: e.DisplayTitleText
674
+ }), /* @__PURE__ */ r("div", {
675
+ className: "ddex-track-meta",
676
+ children: [
677
+ u(e.DisplayArtist, m?.PartyList) && /* @__PURE__ */ n("span", { children: u(e.DisplayArtist, m?.PartyList) }),
678
+ e.ISRC && /* @__PURE__ */ r("span", { children: ["ISRC ", e.ISRC] }),
679
+ e.ResourceReference && /* @__PURE__ */ r("span", { children: ["Ref ", e.ResourceReference] })
680
+ ]
681
+ })]
682
+ }, e.ResourceReference ?? t))
683
+ })
684
+ ] }),
685
+ M.length > 0 && /* @__PURE__ */ r(t, { children: [
686
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
687
+ /* @__PURE__ */ n("div", {
688
+ className: "ddex-section-title",
689
+ children: "Deals"
690
+ }),
691
+ /* @__PURE__ */ n("div", {
692
+ className: "ddex-deal-list",
693
+ children: M.map((e, t) => {
694
+ let i = e.Deal?.DealTerms, a = p(i?.PriceInformation), o = h(i?.CommercialModelType), s = e.Deal?.Territory ?? [], c = S(i?.ValidityPeriod?.StartDate), l = S(i?.ValidityPeriod?.EndDate);
695
+ return /* @__PURE__ */ r("div", {
696
+ className: "ddex-deal-item",
697
+ children: [
698
+ /* @__PURE__ */ r("div", {
699
+ className: "ddex-deal-row",
700
+ children: [o && /* @__PURE__ */ n("span", {
701
+ className: "ddex-badge",
702
+ children: o
703
+ }), (i?.UseType ?? []).map((e) => /* @__PURE__ */ n("span", {
704
+ className: "ddex-badge",
705
+ children: _(e)
706
+ }, e))]
707
+ }),
708
+ a && /* @__PURE__ */ r("div", {
709
+ className: "ddex-key-value",
710
+ children: [/* @__PURE__ */ n("div", {
711
+ className: "ddex-key-value-label",
712
+ children: "Wholesale Price"
713
+ }), /* @__PURE__ */ n("div", {
714
+ className: "ddex-key-value-value",
715
+ children: a
716
+ })]
717
+ }),
718
+ s.length > 0 && /* @__PURE__ */ r("div", {
719
+ className: "ddex-key-value",
720
+ children: [/* @__PURE__ */ n("div", {
721
+ className: "ddex-key-value-label",
722
+ children: "Territory"
723
+ }), /* @__PURE__ */ n("div", {
724
+ className: "ddex-key-value-value",
725
+ children: s.join(", ")
726
+ })]
727
+ }),
728
+ (c || l) && /* @__PURE__ */ r("div", {
729
+ className: "ddex-key-value",
730
+ children: [/* @__PURE__ */ n("div", {
731
+ className: "ddex-key-value-label",
732
+ children: "Validity Period"
733
+ }), /* @__PURE__ */ r("div", {
734
+ className: "ddex-key-value-value",
735
+ children: [c ?? "—", l ? ` – ${l}` : ""]
736
+ })]
737
+ })
738
+ ]
739
+ }, t);
740
+ })
741
+ })
742
+ ] }),
743
+ N.length > 0 && /* @__PURE__ */ r(t, { children: [
744
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
745
+ /* @__PURE__ */ n("div", {
746
+ className: "ddex-section-title",
747
+ children: "Parties"
748
+ }),
749
+ /* @__PURE__ */ n("div", {
750
+ className: "ddex-party-list",
751
+ children: N.map((e, t) => /* @__PURE__ */ r("div", {
752
+ className: "ddex-party-item",
753
+ children: [/* @__PURE__ */ n("span", {
754
+ className: "ddex-party-name",
755
+ children: e.PartyName?.FullName ?? l(e.PartyReference, N) ?? "Unknown"
756
+ }), e.PartyReference && /* @__PURE__ */ n("span", {
757
+ className: "ddex-party-ref",
758
+ children: e.PartyReference
759
+ })]
760
+ }, e.PartyReference ?? t))
761
+ })
762
+ ] }),
763
+ P && (P.MessageId || P.MessageCreatedDateTime) && /* @__PURE__ */ r(t, { children: [
764
+ /* @__PURE__ */ n("div", { className: "ddex-divider" }),
765
+ /* @__PURE__ */ n("div", {
766
+ className: "ddex-section-title",
767
+ children: "Message"
768
+ }),
769
+ P.MessageId && /* @__PURE__ */ r("div", {
770
+ className: "ddex-key-value",
771
+ children: [/* @__PURE__ */ n("div", {
772
+ className: "ddex-key-value-label",
773
+ children: "Message ID"
774
+ }), /* @__PURE__ */ n("div", {
775
+ className: "ddex-key-value-value",
776
+ children: P.MessageId
777
+ })]
778
+ }),
779
+ P.MessageCreatedDateTime && /* @__PURE__ */ r("div", {
780
+ className: "ddex-key-value",
781
+ children: [/* @__PURE__ */ n("div", {
782
+ className: "ddex-key-value-label",
783
+ children: "Created"
784
+ }), /* @__PURE__ */ n("div", {
785
+ className: "ddex-key-value-value",
786
+ children: C(P.MessageCreatedDateTime)
787
+ })]
788
+ })
789
+ ] })
790
+ ] }) : /* @__PURE__ */ n("div", {
791
+ className: "ddex-empty",
792
+ children: "No DDEX release data found."
793
+ }),
794
+ m && /* @__PURE__ */ n("div", {
795
+ className: "ddex-action",
796
+ children: /* @__PURE__ */ n("button", {
797
+ onClick: () => he(v, O(m)),
798
+ className: "ddex-button ddex-button-secondary",
799
+ children: "Download DDEX"
800
+ })
801
+ }),
802
+ i && /* @__PURE__ */ n("div", {
803
+ className: "ddex-action",
804
+ children: /* @__PURE__ */ n("button", {
805
+ onClick: i,
806
+ className: "ddex-button",
807
+ children: "Small View"
808
+ })
809
+ })
810
+ ]
811
+ });
812
+ }
813
+ //#endregion
814
+ //#region src/components/Ddex/Ddex.tsx
815
+ var $ = ({ manifest: t, level: r, className: i }) => {
816
+ let [a, o] = e.useState(r || 1), c = t.manifestStore?.activeManifest, l = t.manifests.find((e) => e.id === c || e.instanceId === c) ?? (c ? t.manifestStore.manifests[c] : void 0) ?? t.manifests[0];
817
+ if (!l || !s(l)) return null;
818
+ switch (a) {
819
+ case 1: return /* @__PURE__ */ n(E, {
820
+ className: i,
821
+ manifest: l,
822
+ moreInfo: () => {
823
+ o(2);
824
+ }
825
+ });
826
+ case 2: return /* @__PURE__ */ n(D, {
827
+ className: i,
828
+ manifest: l,
829
+ moreInfo: () => {
830
+ o(3);
831
+ }
832
+ });
833
+ case 3: return /* @__PURE__ */ n(ge, {
834
+ className: i,
835
+ manifest: l,
836
+ moreInfo: () => {
837
+ o(1);
838
+ }
839
+ });
840
+ }
841
+ return /* @__PURE__ */ n("div", { children: "Level Of Detail Not Selected" });
842
+ };
843
+ $.knownAssertions = ["org.mixotron.ddex"];
844
+ //#endregion
845
+ export { $ as DDEXManifest, o as DDEX_ASSERTION_LABEL, O as ddexAssertionToXml, h as formatCommercialModel, S as formatDate, C as formatDateTime, w as formatLabel, y as formatParentalWarning, p as formatPrice, _ as formatUseType, T as formatValue, u as getArtistNames, b as getClaimGenerator, s as getDdexAssertion, f as getDealsForRelease, x as getInitials, c as getPrimaryRelease, d as getSoundRecordingsForRelease, l as resolvePartyName, W as xmlToDdexAssertion };