@seedprotocol/licensing 0.0.0-stage → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +60 -2
  3. package/dist/canonicalJson.d.ts +11 -0
  4. package/dist/canonicalJson.d.ts.map +1 -0
  5. package/dist/catalog/cc/chooser.d.ts +4 -0
  6. package/dist/catalog/cc/chooser.d.ts.map +1 -0
  7. package/dist/catalog/cc/index.d.ts +3 -0
  8. package/dist/catalog/cc/index.d.ts.map +1 -0
  9. package/dist/catalog/cc/modules.d.ts +4 -0
  10. package/dist/catalog/cc/modules.d.ts.map +1 -0
  11. package/dist/catalog/cc/urls.d.ts +21 -0
  12. package/dist/catalog/cc/urls.d.ts.map +1 -0
  13. package/dist/catalog/cc.js +251 -0
  14. package/dist/catalog/cc.js.map +1 -0
  15. package/dist/catalog/chooser.d.ts +27 -0
  16. package/dist/catalog/chooser.d.ts.map +1 -0
  17. package/dist/catalog/createLicenseCatalog.d.ts +7 -0
  18. package/dist/catalog/createLicenseCatalog.d.ts.map +1 -0
  19. package/dist/catalog/types.d.ts +42 -0
  20. package/dist/catalog/types.d.ts.map +1 -0
  21. package/dist/deed/en.d.ts +10 -0
  22. package/dist/deed/en.d.ts.map +1 -0
  23. package/dist/deed/renderDeed.d.ts +33 -0
  24. package/dist/deed/renderDeed.d.ts.map +1 -0
  25. package/dist/deed/rules.d.ts +19 -0
  26. package/dist/deed/rules.d.ts.map +1 -0
  27. package/dist/deed/summarySentence.d.ts +9 -0
  28. package/dist/deed/summarySentence.d.ts.map +1 -0
  29. package/dist/errors.d.ts +22 -0
  30. package/dist/errors.d.ts.map +1 -0
  31. package/dist/fromUrl.d.ts +7 -0
  32. package/dist/fromUrl.d.ts.map +1 -0
  33. package/dist/hash.d.ts +8 -0
  34. package/dist/hash.d.ts.map +1 -0
  35. package/dist/index.d.ts +19 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +204 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/spdx/list.generated.d.ts +5 -0
  40. package/dist/spdx/list.generated.d.ts.map +1 -0
  41. package/dist/spdx/parse.d.ts +33 -0
  42. package/dist/spdx/parse.d.ts.map +1 -0
  43. package/dist/terms.d.ts +102 -0
  44. package/dist/terms.d.ts.map +1 -0
  45. package/dist/urls-DDyEMdyz.js +337 -0
  46. package/dist/urls-DDyEMdyz.js.map +1 -0
  47. package/dist/validate.d.ts +20 -0
  48. package/dist/validate.d.ts.map +1 -0
  49. package/package.json +72 -4
  50. package/terms.schema.json +174 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The SPDX id a license URL names, or null. Reads Creative Commons license, deed and legal-code
3
+ * URLs of any version and jurisdiction port, CC0, spdx.org license pages, and the catalog's own
4
+ * URLs. An id is returned only when the SPDX list has it. Never throws.
5
+ */
6
+ export declare function fromUrl(url: string): string | null;
7
+ //# sourceMappingURL=fromUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromUrl.d.ts","sourceRoot":"","sources":["../src/fromUrl.ts"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAuBlD"}
package/dist/hash.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { SeedLicenseTerms } from './terms.js';
2
+ /**
3
+ * The identity of a set of license terms: `0x` and the lowercase hex SHA-256 of their RFC 8785
4
+ * canonical JSON. Throws {@link InvalidLicenseTermsError} on terms that fail `validateTerms`, so an
5
+ * invalid object never gets a hash.
6
+ */
7
+ export declare function termsHash(terms: SeedLicenseTerms): `0x${string}`;
8
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,MAAM,EAAE,CAIhE"}
@@ -0,0 +1,19 @@
1
+ export { canonicalJson } from './canonicalJson.js';
2
+ export { CanonicalJsonError, InvalidLicenseTermsError, UnsupportedLocaleError } from './errors.js';
3
+ export { renderDeed } from './deed/renderDeed.js';
4
+ export type { Deed, DeedLine, RenderDeedOptions } from './deed/renderDeed.js';
5
+ export type { DeedSection, RuleId } from './deed/rules.js';
6
+ export { summarySentence } from './deed/summarySentence.js';
7
+ export { termsHash } from './hash.js';
8
+ export { fromUrl } from './fromUrl.js';
9
+ export { parseSpdx, isKnownSpdxId } from './spdx/parse.js';
10
+ export type { SpdxNode, SpdxParseResult } from './spdx/parse.js';
11
+ export { SPDX_LIST_VERSION } from './spdx/list.generated.js';
12
+ export { TERMS_PROFILE } from './terms.js';
13
+ export type { Action, Constraint, Rule, Duty, SeedLicenseTerms } from './terms.js';
14
+ export { createLicenseCatalog } from './catalog/createLicenseCatalog.js';
15
+ export type { Domain, LicenseCatalog, LicenseModule } from './catalog/types.js';
16
+ export type { Chooser, ChooserQuestion } from './catalog/chooser.js';
17
+ export { validateTerms } from './validate.js';
18
+ export type { TermsValidationError, TermsValidationResult } from './validate.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACvD,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC5E,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,204 @@
1
+ import { c as e, d as t, f as n, g as r, h as i, i as a, l as o, m as s, p as c, s as l, u } from "./urls-DDyEMdyz.js";
2
+ //#region src/deed/en.ts
3
+ var d = {
4
+ "use-any-purpose": "Use it for any purpose.",
5
+ share: "Share it: copy and redistribute it in any medium or format.",
6
+ adapt: "Adapt it: remix, transform and build on it, and share what you make.",
7
+ "commercial-use": "Use it commercially.",
8
+ attribution: "Give credit: name the creator, link to the license and say if you changed it.",
9
+ "include-notice": "Keep the copyright and license notices that come with it.",
10
+ "share-alike": "Share adaptations under the same license.",
11
+ "no-conditions": "Nothing. You don't need to give credit.",
12
+ noncommercial: "Use it for commercial purposes.",
13
+ "no-derivatives": "Share adapted versions. You may adapt it for your own use.",
14
+ "permission-required": "Republish, share or adapt it without the rights holder's permission.",
15
+ "lasts-copyright-term": "The license lasts as long as the copyright does.",
16
+ "ends-on-breach": "It ends if you break its terms. The legal text says how it can be restored.",
17
+ irrevocable: "The creator can't withdraw it from anything already shared under it.",
18
+ "as-is": "No warranties: it comes as is, and the creator doesn't promise to hold every right you might need."
19
+ }, f = "Further conditions apply; see the legal text.", p = (e, t) => `This summary is not the license; the legal text at ${e} (sha256 ${t}) governs.`, m = "Exceptions and limitations to copyright, such as fair use, still apply.", h = "Moral rights, privacy and publicity rights are not covered.", g = "What counts as non-commercial is defined by the legal text, not this summary.", _ = [
20
+ "use-any-purpose",
21
+ "share",
22
+ "adapt",
23
+ "commercial-use",
24
+ "attribution",
25
+ "include-notice",
26
+ "share-alike",
27
+ "no-conditions",
28
+ "noncommercial",
29
+ "no-derivatives",
30
+ "permission-required",
31
+ "lasts-copyright-term",
32
+ "ends-on-breach",
33
+ "irrevocable",
34
+ "as-is"
35
+ ], v = {
36
+ "use-any-purpose": "youCan",
37
+ share: "youCan",
38
+ adapt: "youCan",
39
+ "commercial-use": "youCan",
40
+ attribution: "youMust",
41
+ "include-notice": "youMust",
42
+ "share-alike": "youMust",
43
+ "no-conditions": "youMust",
44
+ noncommercial: "youCannot",
45
+ "no-derivatives": "youCannot",
46
+ "permission-required": "youCannot",
47
+ "lasts-copyright-term": "whenTimeRunsOut",
48
+ "ends-on-breach": "whenTimeRunsOut",
49
+ irrevocable: "creatorPromises",
50
+ "as-is": "creatorPromises"
51
+ };
52
+ function y(e) {
53
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e, t, n = "work") => e.findIndex((e) => e.action === t && (e.target ?? "work") === n && !e.constraints?.length), o = (t, n) => a(e.permissions, t, n), s = (t, n) => a(e.prohibitions, t, n), c = (e, ...t) => t.forEach((t) => e.add(t)), l = o("use");
54
+ l >= 0 && (t.add("use-any-purpose"), c(n, l));
55
+ let u = o("reproduce"), d = o("distribute");
56
+ u >= 0 && d >= 0 && (t.add("share"), c(n, u, d));
57
+ let f = o("derive"), p = o("distribute", "adaptation");
58
+ f >= 0 && p >= 0 && (t.add("adapt"), c(n, f, p));
59
+ let m = o("commercialize");
60
+ m >= 0 && (t.add("commercial-use"), c(n, m)), e.duties.forEach((e, n) => {
61
+ let r = {
62
+ attribute: "attribution",
63
+ includeNotice: "include-notice",
64
+ shareAlike: "share-alike"
65
+ }[e.duty];
66
+ r && !(e.duty === "shareAlike" && e.license) && (t.add(r), c(i, n));
67
+ });
68
+ let h = e.permissions.length > 0;
69
+ h && e.duties.length === 0 && t.add("no-conditions");
70
+ let g = s("commercialize");
71
+ g >= 0 && (t.add("noncommercial"), c(r, g));
72
+ let v = s("distribute", "adaptation");
73
+ v >= 0 && (t.add("no-derivatives"), c(r, v), f >= 0 && c(n, f)), h || t.add("permission-required"), h && (e.grant.duration === "copyright-term" && t.add("lasts-copyright-term"), e.grant.revocableFor === "breach-only" && t.add("ends-on-breach"), t.add("irrevocable"), e.grant.warranty === "as-is" && t.add("as-is"));
74
+ let y = /* @__PURE__ */ new Set();
75
+ return e.permissions.some((e, t) => !n.has(t)) && y.add("youCan"), e.duties.some((e, t) => !i.has(t)) && y.add("youMust"), e.prohibitions.some((e, t) => !r.has(t)) && y.add("youCannot"), (e.transition || e.postTerm || h && e.grant.duration !== "copyright-term") && y.add("whenTimeRunsOut"), h && e.grant.warranty !== "as-is" && y.add("creatorPromises"), {
76
+ rules: _.filter((e) => t.has(e)),
77
+ uncovered: [...y]
78
+ };
79
+ }
80
+ //#endregion
81
+ //#region src/deed/renderDeed.ts
82
+ function b(e) {
83
+ if (e !== "en") throw new r(e);
84
+ }
85
+ function x(e, t) {
86
+ b(t.locale);
87
+ let { rules: n, uncovered: r } = y(e), i = {
88
+ youCan: [],
89
+ youMust: [],
90
+ youCannot: [],
91
+ whenTimeRunsOut: [],
92
+ creatorPromises: []
93
+ };
94
+ for (let e of n) i[v[e]].push({
95
+ rule: e,
96
+ text: d[e]
97
+ });
98
+ for (let e of r) i[e].push({
99
+ rule: "see-legal-text",
100
+ text: f
101
+ });
102
+ let a = e.permissions.length > 0 && e.duties.length === 0 && e.grant.revocableFor === "never" ? [m] : [m, h];
103
+ n.includes("noncommercial") && a.push(g);
104
+ let o = {
105
+ template: "seed-deed/1.0.0",
106
+ reviewed: !1,
107
+ disclaimer: p(t.legalLocation ?? e.legal.canonicalUrl, e.legal.sha256),
108
+ ...i,
109
+ notCovered: a
110
+ };
111
+ return t.stewardDeedUrl && (o.stewardDeedUrl = t.stewardDeedUrl), o;
112
+ }
113
+ //#endregion
114
+ //#region src/deed/summarySentence.ts
115
+ function S(e, t) {
116
+ b(t.locale);
117
+ let { rules: n, uncovered: r } = y(e), i = (e) => n.includes(e), a = r.length > 0 ? " Other conditions apply." : "";
118
+ return i("permission-required") ? `Others need permission to republish this.${a}` : i("no-conditions") && i("use-any-purpose") ? `Anyone may use it for any purpose, with no conditions.${a}` : `Anyone may ${[
119
+ i("adapt") ? "republish and adapt it" : i("no-derivatives") ? "republish it unchanged" : "republish it",
120
+ i("commercial-use") ? ", including commercially," : "",
121
+ i("attribution") ? " with credit" : "",
122
+ i("share-alike") ? ", if they share adaptations under the same license" : "",
123
+ i("noncommercial") ? ", but not commercially" : ""
124
+ ].join("").replace(/,$/, "")}.${a}`;
125
+ }
126
+ //#endregion
127
+ //#region src/fromUrl.ts
128
+ var C = /^\/licenses\/(by|by-sa|by-nc|by-nc-sa|by-nd|by-nc-nd)\/(\d+\.\d+)(?:\/([a-z]{2,3}))?(?:\/(?:deed\.[a-z-]+|legalcode(?:\.[a-z-]+)?))?$/, w = /^\/publicdomain\/zero\/1\.0(?:\/(?:deed\.[a-z-]+|legalcode(?:\.[a-z-]+)?))?$/, T = /^\/licenses\/([A-Za-z0-9.+-]+?)(?:\.html|\.json)?$/;
129
+ function E(e, t = !1) {
130
+ let n = e.hostname.toLowerCase().replace(/^www\./, ""), r = e.pathname.replace(/\/+$/, "");
131
+ return {
132
+ host: n,
133
+ path: t ? r : r.toLowerCase()
134
+ };
135
+ }
136
+ var D;
137
+ function O() {
138
+ if (!D) {
139
+ D = /* @__PURE__ */ new Map();
140
+ for (let [e, t] of a()) {
141
+ let { host: n, path: r } = E(new URL(e));
142
+ D.set(n + r, t);
143
+ }
144
+ }
145
+ return D;
146
+ }
147
+ function k(e) {
148
+ let t;
149
+ try {
150
+ t = new URL(e.trim());
151
+ } catch {
152
+ return null;
153
+ }
154
+ if (t.protocol !== "http:" && t.protocol !== "https:") return null;
155
+ let { host: n, path: r } = E(t);
156
+ if (n === "creativecommons.org") {
157
+ let e = C.exec(r);
158
+ if (e) {
159
+ let [, t, n, r] = e;
160
+ return u(`CC-${t}-${n}${r ? `-${r}` : ""}`) ?? null;
161
+ }
162
+ if (w.test(r)) return "CC0-1.0";
163
+ }
164
+ if (n === "spdx.org") {
165
+ let e = T.exec(E(t, !0).path);
166
+ if (e) return u(e[1]) ?? null;
167
+ }
168
+ return O().get(n + r) ?? null;
169
+ }
170
+ //#endregion
171
+ //#region src/catalog/createLicenseCatalog.ts
172
+ function A(t) {
173
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
174
+ for (let a of t) {
175
+ if (n.has(a.id)) throw Error(`Duplicate license module id ${a.id}`);
176
+ if (r.has(a.spdx)) throw Error(`Duplicate SPDX id ${a.spdx} (${a.id})`);
177
+ n.set(a.id, a), r.set(a.spdx, a);
178
+ let t;
179
+ try {
180
+ t = a.toTerms();
181
+ } catch (e) {
182
+ throw Error(`License module ${a.id}: toTerms failed: ${e.message}`);
183
+ }
184
+ let o = e(t);
185
+ if (!o.ok) throw Error(`License module ${a.id} has invalid terms: ${o.errors.map((e) => `${e.path} ${e.message}`).join("; ")}`);
186
+ i.set(l(o.terms), a);
187
+ }
188
+ return {
189
+ list: (e) => e?.domain ? t.filter((t) => t.domains.includes(e.domain)) : [...t],
190
+ get: (e) => n.get(e),
191
+ bySpdx: (e) => r.get(e),
192
+ byTermsHash: (e) => {
193
+ let t = i.get(e.toLowerCase());
194
+ return t ? {
195
+ module: t,
196
+ terms: t.toTerms()
197
+ } : void 0;
198
+ }
199
+ };
200
+ }
201
+ //#endregion
202
+ export { s as CanonicalJsonError, i as InvalidLicenseTermsError, n as SPDX_LIST_VERSION, o as TERMS_PROFILE, r as UnsupportedLocaleError, c as canonicalJson, A as createLicenseCatalog, k as fromUrl, u as isKnownSpdxId, t as parseSpdx, x as renderDeed, S as summarySentence, l as termsHash, e as validateTerms };
203
+
204
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["validateTerms","parseSpdx","SPDX_LIST_VERSION","UnsupportedLocaleError","InvalidLicenseTermsError","catalogUrlTable","TERMS_PROFILE","CanonicalJsonError","canonicalJson","termsHash","EN_RULE_TEXT","EN_SEE_LEGAL_TEXT","enDisclaimer","location","sha256","EN_EXCEPTIONS_NOTE","EN_MORAL_RIGHTS_NOTE","EN_NONCOMMERCIAL_NOTE","RULE_IDS","SECTION_OF","deriveRules","fired","claimedPermissions","claimedProhibitions","claimedDuties","find","list","r","action","target","permit","terms","prohibit","claim","indexes","set","i","use","reproduce","distribute","derive","distributeAdaptation","commercialize","rule","duty","hasPermissions","noCommercial","noAdaptations","uncovered","id","assertLocale","locale","renderDeed","options","sections","rules","section","notCovered","deed","summarySentence","has","tail","CC_LICENSE","CC_ZERO","SPDX_PAGE","normalize","host","url","path","keepCase","table","catalogUrls","spdx","fromUrl","parsed","license","code","version","port","isKnownSpdxId","page","createLicenseCatalog","byId","bySpdx","byHash","module","modules","error","result","filter","m","hash"],"sources":["../src/deed/en.ts","../src/deed/rules.ts","../src/deed/renderDeed.ts","../src/deed/summarySentence.ts","../src/fromUrl.ts","../src/catalog/createLicenseCatalog.ts"],"sourcesContent":["import type { RuleId } from './rules'\n\n/** Deed template seed-deed/1.0.0, English. Draft copy, not yet reviewed by counsel. */\nexport const EN_RULE_TEXT: Record<RuleId, string> = {\n 'use-any-purpose': 'Use it for any purpose.',\n share: 'Share it: copy and redistribute it in any medium or format.',\n adapt: 'Adapt it: remix, transform and build on it, and share what you make.',\n 'commercial-use': 'Use it commercially.',\n attribution: 'Give credit: name the creator, link to the license and say if you changed it.',\n 'include-notice': 'Keep the copyright and license notices that come with it.',\n 'share-alike': 'Share adaptations under the same license.',\n 'no-conditions': \"Nothing. You don't need to give credit.\",\n noncommercial: 'Use it for commercial purposes.',\n 'no-derivatives': 'Share adapted versions. You may adapt it for your own use.',\n 'permission-required': \"Republish, share or adapt it without the rights holder's permission.\",\n 'lasts-copyright-term': 'The license lasts as long as the copyright does.',\n 'ends-on-breach': 'It ends if you break its terms. The legal text says how it can be restored.',\n irrevocable: \"The creator can't withdraw it from anything already shared under it.\",\n 'as-is': \"No warranties: it comes as is, and the creator doesn't promise to hold every right you might need.\",\n}\n\nexport const EN_SEE_LEGAL_TEXT = 'Further conditions apply; see the legal text.'\n\nexport const enDisclaimer = (location: string, sha256: string) =>\n `This summary is not the license; the legal text at ${location} (sha256 ${sha256}) governs.`\n\nexport const EN_EXCEPTIONS_NOTE = 'Exceptions and limitations to copyright, such as fair use, still apply.'\n\n/** Left out for a waiver such as CC0, which waives these rights too. */\nexport const EN_MORAL_RIGHTS_NOTE = 'Moral rights, privacy and publicity rights are not covered.'\n\nexport const EN_NONCOMMERCIAL_NOTE = 'What counts as non-commercial is defined by the legal text, not this summary.'\n","import type { Rule, SeedLicenseTerms } from '../terms'\n\nexport type DeedSection = 'youCan' | 'youMust' | 'youCannot' | 'whenTimeRunsOut' | 'creatorPromises'\n\nexport const RULE_IDS = [\n 'use-any-purpose',\n 'share',\n 'adapt',\n 'commercial-use',\n 'attribution',\n 'include-notice',\n 'share-alike',\n 'no-conditions',\n 'noncommercial',\n 'no-derivatives',\n 'permission-required',\n 'lasts-copyright-term',\n 'ends-on-breach',\n 'irrevocable',\n 'as-is',\n] as const\nexport type RuleId = (typeof RULE_IDS)[number]\n\nexport const SECTION_OF: Record<RuleId, DeedSection> = {\n 'use-any-purpose': 'youCan',\n share: 'youCan',\n adapt: 'youCan',\n 'commercial-use': 'youCan',\n attribution: 'youMust',\n 'include-notice': 'youMust',\n 'share-alike': 'youMust',\n 'no-conditions': 'youMust',\n noncommercial: 'youCannot',\n 'no-derivatives': 'youCannot',\n 'permission-required': 'youCannot',\n 'lasts-copyright-term': 'whenTimeRunsOut',\n 'ends-on-breach': 'whenTimeRunsOut',\n irrevocable: 'creatorPromises',\n 'as-is': 'creatorPromises',\n}\n\nexport type DerivedRules = {\n /** In vocabulary order. */\n rules: RuleId[]\n /** Sections holding a term no rule covers. */\n uncovered: DeedSection[]\n}\n\n/**\n * Which rules the terms trigger. Each rule claims the term elements it describes; a permission,\n * prohibition or duty that no rule claims, or any transition or post-term block, is reported as\n * uncovered so the deed points to the legal text instead of leaving it out. A rule with\n * constraints is never claimed: the 1.0.0 vocabulary has no sentences for constraints.\n */\nexport function deriveRules(terms: SeedLicenseTerms): DerivedRules {\n const fired = new Set<RuleId>()\n const claimedPermissions = new Set<number>()\n const claimedProhibitions = new Set<number>()\n const claimedDuties = new Set<number>()\n\n const find = (list: Rule[], action: string, target = 'work') =>\n list.findIndex((r) => r.action === action && (r.target ?? 'work') === target && !r.constraints?.length)\n const permit = (action: string, target?: string) => find(terms.permissions, action, target)\n const prohibit = (action: string, target?: string) => find(terms.prohibitions, action, target)\n const claim = (set: Set<number>, ...indexes: number[]) => indexes.forEach((i) => set.add(i))\n\n const use = permit('use')\n if (use >= 0) {\n fired.add('use-any-purpose')\n claim(claimedPermissions, use)\n }\n const reproduce = permit('reproduce')\n const distribute = permit('distribute')\n if (reproduce >= 0 && distribute >= 0) {\n fired.add('share')\n claim(claimedPermissions, reproduce, distribute)\n }\n const derive = permit('derive')\n const distributeAdaptation = permit('distribute', 'adaptation')\n if (derive >= 0 && distributeAdaptation >= 0) {\n fired.add('adapt')\n claim(claimedPermissions, derive, distributeAdaptation)\n }\n const commercialize = permit('commercialize')\n if (commercialize >= 0) {\n fired.add('commercial-use')\n claim(claimedPermissions, commercialize)\n }\n\n terms.duties.forEach((duty, i) => {\n const rule = ({ attribute: 'attribution', includeNotice: 'include-notice', shareAlike: 'share-alike' } as const)[\n duty.duty as 'attribute' | 'includeNotice' | 'shareAlike'\n ]\n // A share-alike duty naming another license needs the legal text.\n if (rule && !(duty.duty === 'shareAlike' && duty.license)) {\n fired.add(rule)\n claim(claimedDuties, i)\n }\n })\n\n const hasPermissions = terms.permissions.length > 0\n if (hasPermissions && terms.duties.length === 0) fired.add('no-conditions')\n\n const noCommercial = prohibit('commercialize')\n if (noCommercial >= 0) {\n fired.add('noncommercial')\n claim(claimedProhibitions, noCommercial)\n }\n const noAdaptations = prohibit('distribute', 'adaptation')\n if (noAdaptations >= 0) {\n fired.add('no-derivatives')\n claim(claimedProhibitions, noAdaptations)\n // Making an adaptation for yourself stays allowed; the no-derivatives sentence says so.\n if (derive >= 0) claim(claimedPermissions, derive)\n }\n if (!hasPermissions) fired.add('permission-required')\n\n if (hasPermissions) {\n if (terms.grant.duration === 'copyright-term') fired.add('lasts-copyright-term')\n if (terms.grant.revocableFor === 'breach-only') fired.add('ends-on-breach')\n fired.add('irrevocable')\n if (terms.grant.warranty === 'as-is') fired.add('as-is')\n }\n\n const uncovered = new Set<DeedSection>()\n if (terms.permissions.some((_, i) => !claimedPermissions.has(i))) uncovered.add('youCan')\n if (terms.duties.some((_, i) => !claimedDuties.has(i))) uncovered.add('youMust')\n if (terms.prohibitions.some((_, i) => !claimedProhibitions.has(i))) uncovered.add('youCannot')\n if (terms.transition || terms.postTerm || (hasPermissions && terms.grant.duration !== 'copyright-term')) uncovered.add('whenTimeRunsOut')\n if (hasPermissions && terms.grant.warranty !== 'as-is') uncovered.add('creatorPromises')\n\n return { rules: RULE_IDS.filter((id) => fired.has(id)), uncovered: [...uncovered] }\n}\n","import { UnsupportedLocaleError } from '../errors'\nimport type { SeedLicenseTerms } from '../terms'\nimport { EN_EXCEPTIONS_NOTE, EN_MORAL_RIGHTS_NOTE, EN_NONCOMMERCIAL_NOTE, EN_RULE_TEXT, EN_SEE_LEGAL_TEXT, enDisclaimer } from './en'\nimport { deriveRules, SECTION_OF, type DeedSection, type RuleId } from './rules'\n\nexport type DeedLine = { rule: RuleId | 'see-legal-text'; text: string }\n\nexport interface Deed {\n template: 'seed-deed/1.0.0'\n /** False until counsel reviews the sentence templates. */\n reviewed: false\n disclaimer: string\n youCan: DeedLine[]\n youMust: DeedLine[]\n youCannot: DeedLine[]\n whenTimeRunsOut: DeedLine[]\n creatorPromises: DeedLine[]\n notCovered: string[]\n stewardDeedUrl?: string\n}\n\nexport type RenderDeedOptions = {\n locale: 'en'\n /** Where the legal text is served; default `terms.legal.canonicalUrl`. */\n legalLocation?: string\n /** The steward's own deed, passed through for the UI to link. */\n stewardDeedUrl?: string\n}\n\nexport function assertLocale(locale: string): void {\n if (locale !== 'en') throw new UnsupportedLocaleError(locale)\n}\n\n/**\n * The plain-language summary of license terms, as data. Every line names the rule it came from;\n * a term no rule covers becomes one \"see the legal text\" line in its section.\n */\nexport function renderDeed(terms: SeedLicenseTerms, options: RenderDeedOptions): Deed {\n assertLocale(options.locale)\n const { rules, uncovered } = deriveRules(terms)\n const sections: Record<DeedSection, DeedLine[]> = {\n youCan: [],\n youMust: [],\n youCannot: [],\n whenTimeRunsOut: [],\n creatorPromises: [],\n }\n for (const rule of rules) sections[SECTION_OF[rule]].push({ rule, text: EN_RULE_TEXT[rule] })\n for (const section of uncovered) sections[section].push({ rule: 'see-legal-text', text: EN_SEE_LEGAL_TEXT })\n\n // A waiver: everything permitted, nothing owed, never withdrawn (CC0 1.0 §2 waives moral rights too).\n const waiver = terms.permissions.length > 0 && terms.duties.length === 0 && terms.grant.revocableFor === 'never'\n const notCovered: string[] = waiver ? [EN_EXCEPTIONS_NOTE] : [EN_EXCEPTIONS_NOTE, EN_MORAL_RIGHTS_NOTE]\n if (rules.includes('noncommercial')) notCovered.push(EN_NONCOMMERCIAL_NOTE)\n\n const deed: Deed = {\n template: 'seed-deed/1.0.0',\n reviewed: false,\n disclaimer: enDisclaimer(options.legalLocation ?? terms.legal.canonicalUrl, terms.legal.sha256),\n ...sections,\n notCovered,\n }\n if (options.stewardDeedUrl) deed.stewardDeedUrl = options.stewardDeedUrl\n return deed\n}\n","import type { SeedLicenseTerms } from '../terms'\nimport { assertLocale } from './renderDeed'\nimport { deriveRules } from './rules'\n\n/**\n * One sentence that says what others may do, built from the same rules as the deed. Terms with a\n * condition the rules don't cover end with \"Other conditions apply.\" rather than leaving it out.\n */\nexport function summarySentence(terms: SeedLicenseTerms, options: { locale: 'en' }): string {\n assertLocale(options.locale)\n const { rules, uncovered } = deriveRules(terms)\n const has = (rule: (typeof rules)[number]) => rules.includes(rule)\n const tail = uncovered.length > 0 ? ' Other conditions apply.' : ''\n\n if (has('permission-required')) return `Others need permission to republish this.${tail}`\n if (has('no-conditions') && has('use-any-purpose')) return `Anyone may use it for any purpose, with no conditions.${tail}`\n\n const verb = has('adapt') ? 'republish and adapt it' : has('no-derivatives') ? 'republish it unchanged' : 'republish it'\n const parts = [\n verb,\n has('commercial-use') ? ', including commercially,' : '',\n has('attribution') ? ' with credit' : '',\n has('share-alike') ? ', if they share adaptations under the same license' : '',\n has('noncommercial') ? ', but not commercially' : '',\n ]\n return `Anyone may ${parts.join('').replace(/,$/, '')}.${tail}`\n}\n","import { catalogUrlTable } from './catalog/cc/urls'\nimport { isKnownSpdxId } from './spdx/parse'\n\nconst CC_LICENSE = /^\\/licenses\\/(by|by-sa|by-nc|by-nc-sa|by-nd|by-nc-nd)\\/(\\d+\\.\\d+)(?:\\/([a-z]{2,3}))?(?:\\/(?:deed\\.[a-z-]+|legalcode(?:\\.[a-z-]+)?))?$/\nconst CC_ZERO = /^\\/publicdomain\\/zero\\/1\\.0(?:\\/(?:deed\\.[a-z-]+|legalcode(?:\\.[a-z-]+)?))?$/\nconst SPDX_PAGE = /^\\/licenses\\/([A-Za-z0-9.+-]+?)(?:\\.html|\\.json)?$/\n\n/** host without `www.`, then the path without a trailing slash, lowercased unless asked. */\nfunction normalize(url: URL, keepCase = false): { host: string; path: string } {\n const host = url.hostname.toLowerCase().replace(/^www\\./, '')\n const path = url.pathname.replace(/\\/+$/, '')\n return { host, path: keepCase ? path : path.toLowerCase() }\n}\n\nlet table: Map<string, string> | undefined\nfunction catalogUrls(): Map<string, string> {\n if (!table) {\n table = new Map()\n for (const [url, spdx] of catalogUrlTable()) {\n const { host, path } = normalize(new URL(url))\n table.set(host + path, spdx)\n }\n }\n return table\n}\n\n/**\n * The SPDX id a license URL names, or null. Reads Creative Commons license, deed and legal-code\n * URLs of any version and jurisdiction port, CC0, spdx.org license pages, and the catalog's own\n * URLs. An id is returned only when the SPDX list has it. Never throws.\n */\nexport function fromUrl(url: string): string | null {\n let parsed: URL\n try {\n parsed = new URL(url.trim())\n } catch {\n return null\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null\n const { host, path } = normalize(parsed)\n\n if (host === 'creativecommons.org') {\n const license = CC_LICENSE.exec(path)\n if (license) {\n const [, code, version, port] = license\n return isKnownSpdxId(`CC-${code}-${version}${port ? `-${port}` : ''}`) ?? null\n }\n if (CC_ZERO.test(path)) return 'CC0-1.0'\n }\n if (host === 'spdx.org') {\n const page = SPDX_PAGE.exec(normalize(parsed, true).path)\n if (page) return isKnownSpdxId(page[1]!) ?? null\n }\n return catalogUrls().get(host + path) ?? null\n}\n","import { termsHash } from '../hash'\nimport { validateTerms } from '../validate'\nimport type { LicenseCatalog, LicenseModule } from './types'\n\n/**\n * An index over the modules given. Throws on a duplicate id or SPDX id, and on a module whose terms\n * fail `validateTerms`, naming the module.\n */\nexport function createLicenseCatalog(modules: readonly LicenseModule<any>[]): LicenseCatalog {\n const byId = new Map<string, LicenseModule<any>>()\n const bySpdx = new Map<string, LicenseModule<any>>()\n const byHash = new Map<string, LicenseModule<any>>()\n\n for (const module of modules) {\n if (byId.has(module.id)) throw new Error(`Duplicate license module id ${module.id}`)\n if (bySpdx.has(module.spdx)) throw new Error(`Duplicate SPDX id ${module.spdx} (${module.id})`)\n byId.set(module.id, module)\n bySpdx.set(module.spdx, module)\n let terms: unknown\n try {\n terms = module.toTerms()\n } catch (error) {\n throw new Error(`License module ${module.id}: toTerms failed: ${(error as Error).message}`)\n }\n const result = validateTerms(terms)\n if (!result.ok) {\n throw new Error(`License module ${module.id} has invalid terms: ${result.errors.map((e) => `${e.path} ${e.message}`).join('; ')}`)\n }\n byHash.set(termsHash(result.terms), module)\n }\n\n return {\n list: (filter) => (filter?.domain ? modules.filter((m) => m.domains.includes(filter.domain!)) : [...modules]),\n get: (id) => byId.get(id),\n bySpdx: (spdx) => bySpdx.get(spdx),\n byTermsHash: (hash) => {\n const module = byHash.get(hash.toLowerCase())\n return module ? { module, terms: module.toTerms() } : undefined\n },\n }\n}\n"],"mappings":";;AAGA,IAAaU,IAAuC;CAClD,mBAAmB;CACnB,OAAO;CACP,OAAO;CACP,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,uBAAuB;CACvB,wBAAwB;CACxB,kBAAkB;CAClB,aAAa;CACb,SAAS;AACX,GAEaC,IAAoB,iDAEpBC,KAAgB,GAAkB,MAC7C,sDAAsDC,EAAS,WAAWC,EAAO,aAEtEC,IAAqB,2EAGrBC,IAAuB,+DAEvBC,IAAwB,iFC3BxBC,IAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAGaC,IAA0C;CACrD,mBAAmB;CACnB,OAAO;CACP,OAAO;CACP,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,uBAAuB;CACvB,wBAAwB;CACx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AYI,GAAQ,SAASH,EAAQ,QAAQ,MAAMI,EAAE,QAAQ,SAASD,EAAO,MAAO,CAAC,IAAI,CAAC,GAAGH,CAAO;EAC3G,MAAM,MAAOJ,EAAK,IAAIjC,CAAE;EACxB,SAAS,MAASkC,EAAO,IAAIX,CAAI;EACjC,cAAc,MAAS;GACrB,IAAMa,IAASD,EAAO,IAAIO,EAAK,YAAY,CAAC;GAC5C,OAAON,IAAS;IAAE;IAAQ,OAAOA,EAAO,QAAQ;GAAE,IAAI,KAAA;EACxD;CACF;AACF"}
@@ -0,0 +1,5 @@
1
+ export declare const SPDX_LIST_VERSION = "3.29.0";
2
+ export declare const LICENSE_IDS: readonly string[];
3
+ export declare const DEPRECATED_IDS: readonly string[];
4
+ export declare const EXCEPTION_IDS: readonly string[];
5
+ //# sourceMappingURL=list.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.generated.d.ts","sourceRoot":"","sources":["../../src/spdx/list.generated.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,WAAW,CAAA;AAEzC,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAquBxC,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAiC3C,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAuF1C,CAAA"}
@@ -0,0 +1,33 @@
1
+ export type SpdxNode = {
2
+ type: 'license';
3
+ id: string;
4
+ plus: boolean;
5
+ exception?: string;
6
+ } | {
7
+ type: 'ref';
8
+ id: string;
9
+ documentRef?: string;
10
+ } | {
11
+ type: 'and' | 'or';
12
+ left: SpdxNode;
13
+ right: SpdxNode;
14
+ };
15
+ export type SpdxParseResult = {
16
+ ok: true;
17
+ ast: SpdxNode;
18
+ ids: string[];
19
+ deprecated: string[];
20
+ } | {
21
+ ok: false;
22
+ error: string;
23
+ };
24
+ /** The id as the SPDX list spells it, matched case-insensitively, or undefined. Licenses only, not exceptions. */
25
+ export declare function isKnownSpdxId(id: string): string | undefined;
26
+ /**
27
+ * Parses an SPDX license expression (SPDX 3.0 annex): `AND`, `OR`, `WITH`, parentheses, the `+`
28
+ * suffix, `LicenseRef-` and `DocumentRef-…:LicenseRef-`. `WITH` binds tighter than `AND`, which
29
+ * binds tighter than `OR`. Operators must be uppercase. Ids match case-insensitively and come back
30
+ * as the list spells them.
31
+ */
32
+ export declare function parseSpdx(expression: string): SpdxParseResult;
33
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/spdx/parse.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAA;AAE3D,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GAChE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAYhC,kHAAkH;AAClH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5D;AAID;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CA8F7D"}
@@ -0,0 +1,102 @@
1
+ /** Identifies the closed ODRL 2.2 profile whose semantics these terms follow (ADR 0034). */
2
+ export declare const TERMS_PROFILE = "https://seedprotocol.io/odrl/seed-license/1";
3
+ export declare const ACTIONS: readonly ["use", "reproduce", "distribute", "derive", "commercialize", "seed:aiTrain", "seed:aiInput", "seed:aiIndex", "seed:search"];
4
+ export type Action = (typeof ACTIONS)[number];
5
+ export declare const USER_CLASSES: readonly ["commercial", "noncommercial", "education", "government", "personal"];
6
+ export type Constraint = {
7
+ name: 'purpose';
8
+ operator: 'eq' | 'neq';
9
+ value: string;
10
+ }
11
+ /** ISO 3166-1 alpha-2. */
12
+ | {
13
+ name: 'spatial';
14
+ operator: 'eq' | 'neq';
15
+ value: string;
16
+ }
17
+ /** Unix seconds. */
18
+ | {
19
+ name: 'dateTime';
20
+ operator: 'gte' | 'lt';
21
+ value: number;
22
+ }
23
+ /** Seconds. */
24
+ | {
25
+ name: 'elapsedTime';
26
+ operator: 'lte';
27
+ value: number;
28
+ } | {
29
+ name: 'count';
30
+ operator: 'lte';
31
+ value: number;
32
+ } | {
33
+ name: 'userClass';
34
+ operator: 'eq' | 'neq';
35
+ value: (typeof USER_CLASSES)[number];
36
+ };
37
+ export interface Rule {
38
+ action: Action;
39
+ /** What the rule applies to. Default 'work'. CC ND prohibits distributing adaptations, not making them. */
40
+ target?: 'work' | 'adaptation';
41
+ constraints?: Constraint[];
42
+ }
43
+ export type Duty = {
44
+ duty: 'attribute';
45
+ }
46
+ /** SPDX expression adaptations must use; default: the same license. */
47
+ | {
48
+ duty: 'shareAlike';
49
+ license?: string;
50
+ }
51
+ /** Keep the license text and copyright notice. */
52
+ | {
53
+ duty: 'includeNotice';
54
+ }
55
+ /** GPL; `network: true` for AGPL. */
56
+ | {
57
+ duty: 'discloseSource';
58
+ network?: boolean;
59
+ } | {
60
+ duty: 'stateChanges';
61
+ };
62
+ /**
63
+ * License terms: the reusable legal semantics of a license, without the economics of any offer.
64
+ * `termsHash` is the SHA-256 of their RFC 8785 canonical JSON.
65
+ */
66
+ export interface SeedLicenseTerms {
67
+ profile: typeof TERMS_PROFILE;
68
+ /** SPDX license expression. */
69
+ spdx: string;
70
+ /** `sha256`: 64 lowercase hex characters, no `0x`, of the legal text's bytes. Where the text is stored is not part of the terms. */
71
+ legal: {
72
+ sha256: string;
73
+ lang: string;
74
+ canonicalUrl: string;
75
+ };
76
+ permissions: Rule[];
77
+ prohibitions: Rule[];
78
+ duties: Duty[];
79
+ /** BUSL/FSL-style change of license: exactly one of `afterSeconds` and `at` (unix seconds). */
80
+ transition?: {
81
+ changeAt: {
82
+ afterSeconds?: number;
83
+ at?: number;
84
+ };
85
+ changeLicense: string;
86
+ };
87
+ postTerm?: {
88
+ derivatives: 'retain' | 'cease-distribution' | 'remove';
89
+ trainedModels: 'may-continue' | 'no-new-training';
90
+ };
91
+ grant: {
92
+ transferable: boolean;
93
+ sublicensable: boolean;
94
+ exclusive: false;
95
+ revocableFor: 'breach-only' | 'never';
96
+ warranty: 'as-is' | 'ownership';
97
+ /** 'copyright-term' for CC and most open licenses; seconds otherwise. */
98
+ duration: 'copyright-term' | number;
99
+ };
100
+ governingLaw?: string;
101
+ }
102
+ //# sourceMappingURL=terms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../src/terms.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,eAAO,MAAM,aAAa,gDAAgD,CAAA;AAE1E,eAAO,MAAM,OAAO,uIAUV,CAAA;AACV,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7C,eAAO,MAAM,YAAY,iFAAkF,CAAA;AAE3G,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC5D,0BAA0B;GACxB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAA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