@pie-element/placement-ordering 14.1.2-next.5 → 14.1.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 (108) hide show
  1. package/CHANGELOG.json +1312 -0
  2. package/CHANGELOG.md +2444 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +57 -0
  5. package/configure/CHANGELOG.json +952 -0
  6. package/configure/CHANGELOG.md +2139 -0
  7. package/configure/lib/choice-editor.js +252 -0
  8. package/configure/lib/choice-editor.js.map +1 -0
  9. package/configure/lib/choice-tile.js +205 -0
  10. package/configure/lib/choice-tile.js.map +1 -0
  11. package/configure/lib/defaults.js +211 -0
  12. package/configure/lib/defaults.js.map +1 -0
  13. package/configure/lib/design.js +427 -0
  14. package/configure/lib/design.js.map +1 -0
  15. package/configure/lib/help.js +14 -0
  16. package/configure/lib/help.js.map +1 -0
  17. package/configure/lib/index.js +155 -0
  18. package/configure/lib/index.js.map +1 -0
  19. package/configure/lib/utils.js +108 -0
  20. package/configure/lib/utils.js.map +1 -0
  21. package/configure/package.json +26 -0
  22. package/controller/CHANGELOG.json +517 -0
  23. package/controller/CHANGELOG.md +1518 -0
  24. package/controller/lib/defaults.js +29 -0
  25. package/controller/lib/defaults.js.map +1 -0
  26. package/controller/lib/index.js +285 -0
  27. package/controller/lib/index.js.map +1 -0
  28. package/controller/lib/scoring.js +109 -0
  29. package/controller/lib/scoring.js.map +1 -0
  30. package/controller/package.json +15 -0
  31. package/docs/config-schema.json +2964 -0
  32. package/docs/config-schema.json.md +2190 -0
  33. package/docs/demo/config.js +8 -0
  34. package/docs/demo/generate.js +50 -0
  35. package/docs/demo/index.html +1 -0
  36. package/docs/demo/session.js +7 -0
  37. package/docs/pie-schema.json +1613 -0
  38. package/docs/pie-schema.json.md +973 -0
  39. package/icon.png +0 -0
  40. package/lib/index.js +122 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/main.js +32 -0
  43. package/lib/main.js.map +1 -0
  44. package/lib/ordering.js +165 -0
  45. package/lib/ordering.js.map +1 -0
  46. package/lib/placement-ordering.js +419 -0
  47. package/lib/placement-ordering.js.map +1 -0
  48. package/lib/tile.js +259 -0
  49. package/lib/tile.js.map +1 -0
  50. package/lib/tiler.js +165 -0
  51. package/lib/tiler.js.map +1 -0
  52. package/lib/utils.js +18 -0
  53. package/lib/utils.js.map +1 -0
  54. package/package.json +21 -88
  55. package/configure.js +0 -2
  56. package/controller.js +0 -1
  57. package/dist/author/choice-editor.d.ts +0 -39
  58. package/dist/author/choice-editor.js +0 -156
  59. package/dist/author/choice-tile.d.ts +0 -40
  60. package/dist/author/choice-tile.js +0 -132
  61. package/dist/author/defaults.d.ts +0 -213
  62. package/dist/author/defaults.js +0 -159
  63. package/dist/author/design.d.ts +0 -21
  64. package/dist/author/design.js +0 -273
  65. package/dist/author/help.d.ts +0 -11
  66. package/dist/author/index.d.ts +0 -45
  67. package/dist/author/index.js +0 -85
  68. package/dist/author/utils.d.ts +0 -15
  69. package/dist/author/utils.js +0 -62
  70. package/dist/browser/author/index.js +0 -46600
  71. package/dist/browser/author/index.js.map +0 -1
  72. package/dist/browser/browser-DHPggtaA.js +0 -376
  73. package/dist/browser/browser-DHPggtaA.js.map +0 -1
  74. package/dist/browser/controller/index.js +0 -242
  75. package/dist/browser/controller/index.js.map +0 -1
  76. package/dist/browser/delivery/index.js +0 -1035
  77. package/dist/browser/delivery/index.js.map +0 -1
  78. package/dist/browser/dist-D9ARZhQk.js +0 -1426
  79. package/dist/browser/dist-D9ARZhQk.js.map +0 -1
  80. package/dist/browser/drag-provider-C1slTlsc.js +0 -10555
  81. package/dist/browser/drag-provider-C1slTlsc.js.map +0 -1
  82. package/dist/browser/placement-ordering.css +0 -2
  83. package/dist/controller/defaults.d.ts +0 -31
  84. package/dist/controller/defaults.js +0 -25
  85. package/dist/controller/index.d.ts +0 -29
  86. package/dist/controller/index.js +0 -123
  87. package/dist/controller/scoring.d.ts +0 -27
  88. package/dist/controller/scoring.js +0 -30
  89. package/dist/delivery/index.d.ts +0 -26
  90. package/dist/delivery/index.js +0 -70
  91. package/dist/delivery/main.d.ts +0 -19
  92. package/dist/delivery/main.js +0 -22
  93. package/dist/delivery/ordering.d.ts +0 -18
  94. package/dist/delivery/ordering.js +0 -93
  95. package/dist/delivery/placement-ordering.d.ts +0 -28
  96. package/dist/delivery/placement-ordering.js +0 -213
  97. package/dist/delivery/tile.d.ts +0 -28
  98. package/dist/delivery/tile.js +0 -165
  99. package/dist/delivery/tiler.d.ts +0 -42
  100. package/dist/delivery/tiler.js +0 -89
  101. package/dist/delivery/utils.d.ts +0 -9
  102. package/dist/delivery/utils.js +0 -8
  103. package/dist/index.d.ts +0 -1
  104. package/dist/index.iife.d.ts +0 -8
  105. package/dist/index.iife.js +0 -152
  106. package/dist/index.js +0 -2
  107. package/dist/runtime-support.d.ts +0 -12
  108. package/dist/runtime-support.js +0 -12
@@ -1,242 +0,0 @@
1
- import { a as e, h as t, k as n, l as r, m as i, n as a, r as o, s, t as c, u as l } from "../browser-DHPggtaA.js";
2
- import { t as u } from "../dist-D9ARZhQk.js";
3
- //#region ../../../node_modules/.bun/js-combinatorics@2.1.2/node_modules/js-combinatorics/combinatorics.js
4
- function d(e, t) {
5
- if (e < 0) throw RangeError(`${e} is out of range`);
6
- if (t < 0) throw RangeError(`${t} is out of range`);
7
- if (t == 0) return 1n;
8
- if (e < t) return 0n;
9
- let [n, r, i] = [
10
- BigInt(e),
11
- BigInt(t),
12
- 1n
13
- ];
14
- for (; r--;) i *= n--;
15
- return i;
16
- }
17
- function f(e, t) {
18
- return t == 0 || e == t ? 1n : e < t ? 0n : d(e, t) / d(t, t);
19
- }
20
- var p = typeof crypto < "u" ? crypto : {};
21
- typeof p.randomBytes == "function" || p.getRandomValues;
22
- //#endregion
23
- //#region src/controller/scoring.ts
24
- var m = /* @__PURE__ */ n(c(), 1), h = (0, m.default)("pie-elements:placement-ordering:controller"), g = (e) => /* @__PURE__ */ Error(`Cant score answer: ${e} it has duplicates and allowDuplicates is false`), _ = (e, n, r) => {
25
- if (r = {
26
- allowDuplicates: !1,
27
- orderMustBeComplete: !1,
28
- ...r
29
- }, !r.allowDuplicates && !o(a(e), e)) throw g(n);
30
- if (r.allowDuplicates === !1 && n.length !== a(n).length) return 0;
31
- if (n = r.allowDuplicates === !1 ? a(n) : n, h("answer:", n), !Array.isArray(e) || e.length === 0) throw Error("correct must be non empty an array");
32
- if (e.length === 1) return +!!o(e, n);
33
- if (!Array.isArray(n) || n.length < 2 || n.length > e.length || e.length !== n.length && r.orderMustBeComplete) return 0;
34
- let i = f(e, 2).toArray(), s = f(n, 2).toArray(), c = t(s, i, o), l = i.length - s.length, u = i.length, d = ((u - c.length - l) / u).toFixed(2);
35
- return parseFloat(d);
36
- }, v = (e) => e.correctResponse ? e.correctResponse.map((e) => e && e.id ? e.id : e) : [], y = (e) => {
37
- let t = (e.alternateResponses || []).map((e) => Array.isArray(e) ? e : e.response).filter((e) => e !== void 0);
38
- return [v(e), ...t];
39
- }, b = (e, t) => {
40
- let { value: n } = t || {};
41
- if (!n) return 0;
42
- let r = y(e), i = (e.configure && e.configure.removeTilesAfterPlacing) !== !1, a = 0;
43
- return r.forEach((e) => {
44
- let t = _(e, n, { allowDuplicates: i });
45
- t >= a && (a = t);
46
- }), a;
47
- }, x = {
48
- correct: {
49
- type: "default",
50
- default: "Correct",
51
- custom: "Correct"
52
- },
53
- incorrect: {
54
- type: "default",
55
- default: "Incorrect",
56
- custom: "Incorrect"
57
- },
58
- partial: {
59
- type: "default",
60
- default: "Nearly",
61
- custom: "Nearly"
62
- },
63
- unanswered: {
64
- type: "default",
65
- default: "You have not entered a response",
66
- custom: "You have not entered a response"
67
- }
68
- };
69
- function S(e) {
70
- return e === "partially-correct" ? "partial" : e;
71
- }
72
- function C(e, t = {}) {
73
- return new Promise((n) => {
74
- let r = {
75
- ...x,
76
- ...t
77
- }, i = S(e), a = r[i], o = x[i];
78
- w(a, o[a.type]).then(n);
79
- });
80
- }
81
- function w(e, t) {
82
- return new Promise((n) => {
83
- if (!e || e.type === "none") {
84
- n(void 0);
85
- return;
86
- }
87
- n(e[e.type] || t);
88
- });
89
- }
90
- //#endregion
91
- //#region ../../shared/controller-utils/dist/index.js
92
- var T = Object.defineProperty, E = /* @__PURE__ */ ((e, t) => {
93
- let n = {};
94
- for (var r in e) T(n, r, {
95
- get: e[r],
96
- enumerable: !0
97
- });
98
- return t || T(n, Symbol.toStringTag, { value: "Module" }), n;
99
- })({ enabled: () => D });
100
- function D(e, t, n) {
101
- return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n == "boolean" ? n : !0;
102
- }
103
- //#endregion
104
- //#region src/controller/defaults.ts
105
- var O = {
106
- choiceLabel: "",
107
- choiceLabelEnabled: !0,
108
- choices: [],
109
- correctResponse: [],
110
- feedbackEnabled: !1,
111
- numberedGuides: !1,
112
- orientation: "vertical",
113
- partialScoring: !0,
114
- placementArea: !1,
115
- prompt: "",
116
- promptEnabled: !0,
117
- rationale: "",
118
- rationaleEnabled: !0,
119
- removeTilesAfterPlacing: !0,
120
- scoringType: "auto",
121
- studentInstructionsEnabled: !0,
122
- targetLabel: "",
123
- teacherInstructions: "",
124
- teacherInstructionsEnabled: !0,
125
- toolbarEditorPosition: "bottom"
126
- }, k = (0, m.default)("@pie-element:placement-ordering:controller"), { translator: A } = u, j = () => /* @__PURE__ */ Error("Question is missing required array: correctResponse"), M = (e, t, n) => {
127
- let r = [], i = t?.value || [];
128
- e?.correctResponse;
129
- let a = e?.placementArea === !0;
130
- if (!i.length) return a ? r.push("Student did not place any tiles in the target area.") : r.push("Student did not reorder any tiles."), r.push("Final score: 0."), r;
131
- let s = y(e), c = {
132
- score: 0,
133
- response: []
134
- };
135
- s.forEach((e) => {
136
- let t = 0;
137
- i.forEach((n, r) => {
138
- e[r] === n && t++;
139
- }), t > c.score && (c = {
140
- score: t,
141
- response: e
142
- });
143
- });
144
- let l = c.score, u = i.length - l;
145
- l > 0 && r.push(`${l} tile(s) placed in the correct order.`), u > 0 && r.push(`${u} tile(s) placed in an incorrect order.`), s.some((e) => o(e, i));
146
- let d = E.enabled(e, n || {});
147
- d ? (r.push("Score calculated using partial scoring."), r.push("Each tile placed in the correct position contributes to the score.")) : (r.push("Score calculated using all-or-nothing scoring."), a ? r.push("Student must place all tiles in the correct positions within the target area to receive full credit.") : r.push("Student must arrange all tiles in the correct order to receive full credit."));
148
- let f = b(e, t), p = d ? f : +(f === 1);
149
- return r.push(`Final score: ${p}.`), r;
150
- };
151
- function N(e, t, n) {
152
- return new Promise((i, a) => {
153
- if (!t || r(t)) {
154
- i({
155
- score: 0,
156
- empty: !0,
157
- logTrace: ["Student did not interact with the placement-ordering item."]
158
- });
159
- return;
160
- }
161
- if (!e || !e.correctResponse || r(e.correctResponse)) a(j());
162
- else try {
163
- let r = b(e, t);
164
- i({
165
- score: E.enabled(e, n || {}) ? r : +(r === 1),
166
- logTrace: M(e, t, n)
167
- });
168
- } catch (e) {
169
- a(e);
170
- }
171
- });
172
- }
173
- function P(e = {}) {
174
- return new Promise((t) => {
175
- t({
176
- ...O,
177
- ...e
178
- });
179
- });
180
- }
181
- var F = (e) => ({
182
- ...O,
183
- rationaleEnabled: !0,
184
- feedbackEnabled: !1,
185
- promptEnabled: !0,
186
- teacherInstructionsEnabled: !0,
187
- studentInstructionsEnabled: !0,
188
- ...e
189
- });
190
- async function I(t, n, r) {
191
- let a = F(t), c = {};
192
- if (t.alternateResponses && i(t.alternateResponses, e) && (k("Deprecated structure of alternateResponses is in use"), console.error("Deprecated structure of alternateResponses is in use")), c.env = r, c.extraCSSRules = a.extraCSSRules, c.outcomes = [], c.completeLength = (a.correctResponse || []).length, c.choices = (a.choices || []).filter((e) => e.label), c.note = a.note, c.showNote = a.alternateResponses && a.alternateResponses.length > 0, c.language = a.language, k("[model] removing tileSize for the moment."), c.prompt = a.promptEnabled ? a.prompt : null, c.config = {
193
- orientation: a.orientation || "vertical",
194
- includeTargets: a.placementArea,
195
- choiceLabelEnabled: a.choiceLabelEnabled,
196
- targetLabel: a.targetLabel,
197
- choiceLabel: a.choiceLabel,
198
- showOrdering: a.numberedGuides,
199
- allowSameChoiceInTargets: !a.removeTilesAfterPlacing
200
- }, c.disabled = r.mode !== "gather", c.note ||= A.t("common:commonCorrectAnswerWithAlternates", { lng: a.language }), r.role === "instructor" && (r.mode === "view" || r.mode === "evaluate") ? (c.rationale = a.rationaleEnabled ? a.rationale : null, c.teacherInstructions = a.teacherInstructionsEnabled ? a.teacherInstructions : null) : (c.rationale = null, c.teacherInstructions = null), r.mode === "evaluate") {
201
- let e = n && n.value || [], i = y(a), u = i.reduce((t, n) => {
202
- let r = s(e, (e, t, r) => e + (Array.isArray(n) && n[r] === t ? 1 : 0), 0);
203
- return r > t.score ? {
204
- arr: n,
205
- score: r
206
- } : t;
207
- }, {
208
- arr: [],
209
- score: 0
210
- });
211
- c.outcomes = l(e, (e, t) => ({
212
- id: e,
213
- outcome: u.arr[t] === e ? "correct" : "incorrect"
214
- }));
215
- let d = i.some((t) => o(t, e)), f = b(t, n), p = f === 1, m = !p && E.enabled(a, r || {}) && f !== 0;
216
- return c.correctness = p ? "correct" : m ? "partial" : "incorrect", d || (c.correctResponse = v(a)), a.feedback || (a.feedbackEnabled = !1), c.feedback = a.feedbackEnabled ? await C(c.correctness, a.feedback) : void 0, c;
217
- } else return c;
218
- }
219
- var L = (e, t) => new Promise((n) => {
220
- t.mode !== "evaluate" && t.role === "instructor" ? n({
221
- id: "1",
222
- value: v(e)
223
- }) : n(null);
224
- }), R = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), z = (e = {}, t = {}) => {
225
- let { choices: n, correctResponse: i } = e, a = {};
226
- [
227
- "teacherInstructions",
228
- "prompt",
229
- "rationale"
230
- ].forEach((n) => {
231
- t[n]?.required && !R(e[n]) && (a[n] = "This field is required.");
232
- });
233
- let s = [...n || []].reverse(), c = {};
234
- return s.forEach((e, t) => {
235
- let { id: n, label: r } = e;
236
- R(r) ? s.slice(t + 1).some((e) => e.label === r) && (c[n] = "Content should be unique.") : c[n] = "Content should not be empty.";
237
- }), o((n || []).map((e) => e.id), (i || []).map((e) => e.id || e)) && (a.orderError = "The correct ordering should not be identical to the initial ordering."), r(c) || (a.choicesErrors = c), a;
238
- };
239
- //#endregion
240
- export { L as createCorrectResponseSession, P as createDefaultModel, M as getLogTrace, I as model, F as normalize, N as outcome, j as questionError, z as validate };
241
-
242
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../../node_modules/.bun/js-combinatorics@2.1.2/node_modules/js-combinatorics/combinatorics.js","../../../src/controller/scoring.ts","../../../../../shared/feedback/dist/index.js","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/defaults.ts","../../../src/controller/index.ts"],"sourcesContent":["/**\n * combinatorics.js\n *\n * Licensed under the MIT license.\n * http://www.opensource.org/licenses/mit-license.php\n *\n * @author: Dan Kogai <dankogai+github@gmail.com>\n *\n * References:\n * @link: http://www.ruby-doc.org/core-2.0/Array.html#method-i-combination\n * @link: http://www.ruby-doc.org/core-2.0/Array.html#method-i-permutation\n * @link: http://en.wikipedia.org/wiki/Factorial_number_system\n * @link: https://en.wikipedia.org/wiki/Combinatorial_number_system\n */\nexport const version = '2.1.2';\n/**\n * calculates `P(n, k)`.\n *\n * @link https://en.wikipedia.org/wiki/Permutation\n */\nexport function permutation(n, k) {\n if (n < 0)\n throw new RangeError(`${n} is out of range`);\n if (k < 0)\n throw new RangeError(`${k} is out of range`);\n if (0 == k)\n return 1n;\n if (n < k)\n return 0n;\n let [bn, bk, bp] = [BigInt(n), BigInt(k), 1n];\n while (bk--)\n bp *= bn--;\n return bp;\n}\n/**\n * calculates `C(n, k)`.\n *\n * @link https://en.wikipedia.org/wiki/Combination\n */\nexport function combination(n, k) {\n if (0 == k)\n return 1n;\n if (n == k)\n return 1n;\n if (n < k)\n return 0n;\n return permutation(n, k) / permutation(k, k);\n}\n/**\n * calculates `n!` === `P(n, n)`.\n *\n * @link https://en.wikipedia.org/wiki/Factorial\n */\nexport function factorial(n) {\n return permutation(n, n);\n}\n/**\n * returns the factoradic representation of `n`, least significant order.\n *\n * @link https://en.wikipedia.org/wiki/Factorial_number_system\n * @param {number} l the number of digits\n */\nexport function factoradic(n, l = 0) {\n if (n < 0)\n throw new RangeError(`${n} is out of range`);\n let [bn, bf] = [BigInt(n), 1n];\n if (!l) {\n for (l = 1; bf < bn; bf *= BigInt(++l))\n ;\n if (bn < bf)\n bf /= BigInt(l--);\n }\n else {\n bf = BigInt(factorial(l));\n }\n let digits = [0];\n for (; l; bf /= BigInt(l--)) {\n digits[l] = Number(bn / bf);\n bn %= bf;\n }\n return digits;\n}\n/**\n * `combinadic(n, k)` returns a function\n * that takes `m` as an argument and\n * returns the combinadics representation of `m` for `n C k`.\n *\n * @link https://en.wikipedia.org/wiki/Combinatorial_number_system\n */\nexport function combinadic(n, k) {\n const count = combination(n, k);\n const [bn, bk] = [BigInt(n), BigInt(k)];\n return (m) => {\n if (m < 0 || count <= m)\n throw new RangeError(`${m} is out of range`);\n let digits = [];\n let [ba, bb] = [bn, bk];\n let x = BigInt(count) - 1n - BigInt(m);\n for (let i = 0; i < k; i++) {\n ba--;\n while (x < combination(ba, bb))\n ba--;\n digits.push(Number(bn - 1n - ba));\n x -= combination(ba, bb);\n bb--;\n }\n return digits;\n };\n}\n/**\n *\n */\nconst _crypto = typeof crypto !== 'undefined' ? crypto : {};\nconst _randomBytes = typeof _crypto['randomBytes'] === 'function'\n ? (len) => Uint8Array.from(_crypto['randomBytes'](len))\n : typeof _crypto['getRandomValues'] === 'function'\n ? (len) => _crypto['getRandomValues'](new Uint8Array(len))\n : (len) => Uint8Array.from(Array(len), () => Math.random() * 256);\n/**\n * returns random integer `n` where `min` <= `n` < `max`:\n *\n * if the argument is `BigInt` the result is also `BigInt`.\n *\n * @param {anyint} min\n * @param {anyint} max\n */\nexport function randomInteger(min = 0, max = Math.pow(2, 53)) {\n let ctor = min.constructor;\n if (arguments.length === 0) {\n return Math.floor(Math.random() * ctor(max));\n }\n if (arguments.length == 1) {\n [min, max] = [ctor(0), min];\n }\n if (typeof min == 'number') { // number\n [min, max] = [Math.ceil(Number(min)), Math.ceil(Number(max))];\n return Math.floor(Math.random() * (max - min)) + min;\n }\n const mag = ctor(max) - ctor(min);\n const len = mag.toString(16).length;\n const u8s = _randomBytes(len);\n const rnd = u8s.reduce((a, v) => ((a << ctor(8)) + ctor(v)), ctor(0));\n return ((ctor(rnd) * mag) >> ctor(len * 8)) + ctor(min);\n}\n;\n/**\n * Base Class of `js-combinatorics`\n */\nclass _CBase {\n /**\n * does `new`\n * @param args\n */\n static of(...args) {\n return new (Function.prototype.bind.apply(this, [null].concat(args)));\n }\n /**\n * Same as `of` but takes a single array `arg`\n *\n * cf. https://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible\n */\n static from(arg) {\n return new (Function.prototype.bind.apply(this, [null].concat(arg)));\n }\n /**\n * Common iterator\n */\n [Symbol.iterator]() {\n return function* (it, len) {\n for (let i = 0n; i < len; i++)\n yield it.at(i);\n }(this, this.length);\n }\n /**\n * returns `[...this]`.\n */\n toArray() {\n return [...this];\n }\n /**\n * @deprecated\n * tells wether you need `BigInt` to access all elements.\n */\n get isBig() {\n return Number.MAX_SAFE_INTEGER < this.length;\n }\n /**\n * @deprecated\n * tells wether it is safe to work on this instance.\n *\n * * always `true` unless your platform does not support `BigInt`.\n * * if not, `true` iff `.isBig` is `false`.\n */\n get isSafe() {\n return typeof BigInt !== 'undefined' || !this.isBig;\n }\n /**\n * check n for nth\n */\n _check(n) {\n if (n < 0) {\n if (this.length < -n)\n throw new RangeError(`${n} is out of range`);\n return BigInt(this.length) + BigInt(n);\n }\n if (this.length <= n)\n throw new RangeError(`${n} is out of range`);\n return n;\n }\n /**\n * get the `n`th element of the iterator.\n * negative `n` goes backwards\n * like `Array.prototype.at()`\n * @link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at\n */\n at(n) { return undefined; }\n /**\n * an alias of `at`\n */\n nth(n) { return this.at(n); }\n /**\n * the seed iterable\n */\n seed;\n /**\n * the size (# of elements) of each element.\n */\n size;\n /**\n * the number of elements\n */\n length;\n /**\n * pick random element\n */\n sample() {\n return this.at(randomInteger(this.length));\n }\n /**\n * an infinite steam of random elements\n */\n samples() {\n return function* (it) {\n while (true)\n yield it.sample();\n }(this);\n }\n}\n/**\n * Permutation\n */\nexport class Permutation extends _CBase {\n constructor(seed, size = 0) {\n super();\n this.seed = [...seed];\n this.size = 0 < size ? size : this.seed.length;\n this.length = permutation(this.seed.length, this.size);\n Object.freeze(this);\n }\n at(n) {\n n = this._check(n);\n if (n === undefined)\n return undefined;\n const offset = this.seed.length - this.size;\n const skip = factorial(offset);\n let digits = factoradic(BigInt(n) * BigInt(skip), this.seed.length);\n let source = this.seed.slice();\n let result = [];\n for (let i = this.seed.length - 1; offset <= i; i--) {\n result.push(source.splice(digits[i], 1)[0]);\n }\n return result;\n }\n}\n/**\n * Combination\n */\nexport class Combination extends _CBase {\n comb;\n constructor(seed, size = 0) {\n super();\n this.seed = [...seed];\n this.size = 0 < size ? size : this.seed.length;\n this.size = size;\n this.length = combination(this.seed.length, this.size);\n this.comb = combinadic(this.seed.length, this.size);\n Object.freeze(this);\n }\n /**\n * returns an iterator which is more efficient\n * than the default iterator that uses .nth\n *\n * @link https://en.wikipedia.org/wiki/Combinatorial_number_system#Applications\n */\n bitwiseIterator() {\n // [Symbol.iterator]() {\n // console.log('overriding _CBase');\n const inc = (x) => {\n if (x <= 0n)\n return 0n;\n const u = x & -x;\n const v = u + x;\n return v + (((v ^ x) / u) >> 2n);\n };\n let x = (1n << BigInt(this.size)) - 1n; // 0b11...1\n return function* (it, len) {\n for (let i = 0n; i < BigInt(len); i++, x = inc(x)) {\n let result = [];\n for (let y = x, j = 0; 0n < y; y >>= 1n, j++) {\n if (y & 1n)\n result.push(it.seed[j]);\n }\n // console.log(`x = ${x}`);\n yield result;\n }\n }(this, this.length);\n }\n at(n) {\n n = this._check(n);\n if (n === undefined)\n return undefined;\n let result = [];\n for (let i of this.comb(n)) {\n result.push(this.seed[i]);\n }\n return result;\n }\n}\n/**\n * Base N\n */\nexport class BaseN extends _CBase {\n base;\n constructor(seed, size = 1) {\n if (size < 1)\n throw new RangeError(`${size} is out of range`);\n super();\n this.seed = [...seed];\n this.size = size;\n let base = this.seed.length;\n this.base = base;\n this.length = BigInt(base) ** BigInt(size);\n Object.freeze(this);\n }\n at(n) {\n n = this._check(n);\n if (n === undefined)\n return undefined;\n let bn = BigInt(n);\n const bb = BigInt(this.base);\n let result = [];\n for (let i = 0; i < this.size; i++) {\n let bd = bn % bb;\n result.push(this.seed[Number(bd)]);\n bn -= bd;\n bn /= bb;\n }\n return result;\n }\n}\n/**\n * Power Set\n */\nexport class PowerSet extends _CBase {\n constructor(seed) {\n super();\n this.seed = [...seed];\n const length = 1n << BigInt(this.seed.length);\n this.length = length;\n Object.freeze(this);\n }\n at(n) {\n n = this._check(n);\n if (n === undefined)\n return undefined;\n let bn = BigInt(n);\n let result = [];\n for (let bi = 0n; bn; bn >>= 1n, bi++)\n if (bn & 1n)\n result.push(this.seed[Number(bi)]);\n return result;\n }\n}\n/**\n * Cartesian Product\n */\nexport class CartesianProduct extends _CBase {\n constructor(...args) {\n super();\n this.seed = args.map(v => [...v]);\n this.size = this.seed.length;\n const length = this.seed.reduce((a, v) => a * BigInt(v.length), 1n);\n this.length = length;\n Object.freeze(this);\n }\n at(n) {\n n = this._check(n);\n if (n === undefined)\n return undefined;\n let bn = BigInt(n);\n let result = [];\n for (let i = 0; i < this.size; i++) {\n const base = this.seed[i].length;\n const bb = BigInt(base);\n const bd = bn % bb;\n result.push(this.seed[i][Number(bd)]);\n bn -= bd;\n bn /= bb;\n }\n return result;\n }\n}\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/placement-ordering/controller/src/scoring.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nimport { differenceWith, isEqual, uniq } from '@pie-element/shared-lodash';\nimport { combination } from 'js-combinatorics';\nimport debug from 'debug';\n\nconst log = debug('pie-elements:placement-ordering:controller');\n\nexport const illegalArgumentError = (answer) =>\n new Error(`Cant score answer: ${answer} it has duplicates and allowDuplicates is false`);\nexport const pairwiseCombinationScore = (correct, answer, opts) => {\n opts = { allowDuplicates: false, orderMustBeComplete: false, ...opts };\n\n if (!opts.allowDuplicates && !isEqual(uniq(correct), correct)) {\n throw illegalArgumentError(answer);\n }\n\n if (opts.allowDuplicates === false && answer.length !== uniq(answer).length) {\n return 0;\n }\n\n answer = opts.allowDuplicates !== false ? answer : uniq(answer);\n\n log('answer:', answer);\n if (!Array.isArray(correct) || correct.length === 0) {\n throw new Error('correct must be non empty an array');\n }\n\n if (correct.length === 1) {\n return isEqual(correct, answer) ? 1 : 0;\n }\n\n if (!Array.isArray(answer) || answer.length < 2) {\n return 0;\n }\n\n if (answer.length > correct.length) {\n return 0;\n }\n\n if (correct.length !== answer.length && opts.orderMustBeComplete) {\n return 0;\n }\n\n const correctCombo = combination(correct, 2).toArray();\n const answerCombo = combination(answer, 2).toArray();\n\n const diff = differenceWith(answerCombo, correctCombo, isEqual);\n\n const comboLengthDiff = correctCombo.length - answerCombo.length;\n\n const total = correctCombo.length;\n const actual = total - diff.length - comboLengthDiff;\n\n const n = (actual / total).toFixed(2);\n\n return parseFloat(n);\n};\n\n/**\n * Flattens the correctResponse into an array of ordered identifiers representing the\n * correct response.\n */\nexport const flattenCorrect = (question) =>\n question.correctResponse ? question.correctResponse.map((r) => (r && r.id ? r.id : r)) : [];\n\n/**\n * Returns all correct responses for this question\n * @param question - array\n */\nexport const getAllCorrectResponses = (question) => {\n const alternates = (question.alternateResponses || [])\n .map((alternate) => {\n if (Array.isArray(alternate)) {\n return alternate;\n }\n\n return alternate.response;\n })\n .filter((item) => item !== undefined);\n\n return [flattenCorrect(question), ...alternates];\n};\n\n/**\n * Returns the score for a session. If weighted scoring is present in the correctResponse\n * field for the question, this will be used. If partial scoring is present in the question\n * model, this will be used. Otherwise the default scoring mechanism (0 for any incorrect, 1\n * for all correct) will be used.\n */\n\nexport const score = (question, session) => {\n const { value } = session || {};\n\n if (!value) {\n return 0;\n }\n\n const allCorrectResponse = getAllCorrectResponses(question);\n const allowDuplicates = (question.configure && question.configure.removeTilesAfterPlacing) !== false;\n\n /**\n * We require this to be the case - locking\n */\n //const orderMustBeComplete = true;\n\n let bestScore = 0;\n\n allCorrectResponse.forEach((cr) => {\n const currentScore = pairwiseCombinationScore(cr, value, {\n allowDuplicates,\n });\n\n if (currentScore >= bestScore) {\n bestScore = currentScore;\n }\n });\n\n return bestScore;\n};\n","//#region src/defaults.ts\nvar e = {\n\tcorrect: {\n\t\ttype: \"default\",\n\t\tdefault: \"Correct\",\n\t\tcustom: \"Correct\"\n\t},\n\tincorrect: {\n\t\ttype: \"default\",\n\t\tdefault: \"Incorrect\",\n\t\tcustom: \"Incorrect\"\n\t},\n\tpartial: {\n\t\ttype: \"default\",\n\t\tdefault: \"Nearly\",\n\t\tcustom: \"Nearly\"\n\t},\n\tunanswered: {\n\t\ttype: \"default\",\n\t\tdefault: \"You have not entered a response\",\n\t\tcustom: \"You have not entered a response\"\n\t}\n};\n//#endregion\n//#region src/utils.ts\nfunction t(e) {\n\treturn e === \"partially-correct\" ? \"partial\" : e;\n}\n//#endregion\n//#region src/index.ts\nfunction n(n, i = {}) {\n\treturn new Promise((a) => {\n\t\tlet o = {\n\t\t\t...e,\n\t\t\t...i\n\t\t}, s = t(n), c = o[s], l = e[s];\n\t\tr(c, l[c.type]).then(a);\n\t});\n}\nfunction r(e, t) {\n\treturn new Promise((n) => {\n\t\tif (!e || e.type === \"none\") {\n\t\t\tn(void 0);\n\t\t\treturn;\n\t\t}\n\t\tn(e[e.type] || t);\n\t});\n}\nfunction i(n, r = {}) {\n\tlet i = {\n\t\t...e,\n\t\t...r\n\t}, o = t(n), s = i[o], c = e[o];\n\treturn a(s, c[s.type]);\n}\nfunction a(e, t) {\n\tif (!(!e || e.type === \"none\")) return e[e.type] || t;\n}\n//#endregion\nexport { e as defaultFeedback, a as getActualFeedback, i as getActualFeedbackForCorrectness, r as getFeedback, n as getFeedbackForCorrectness, t as normalizeCorrectness };\n","//#region \\0rolldown/runtime.js\nvar e = Object.defineProperty, t = (t, n) => {\n\tlet r = {};\n\tfor (var i in t) e(r, i, {\n\t\tget: t[i],\n\t\tenumerable: !0\n\t});\n\treturn n || e(r, Symbol.toStringTag, { value: \"Module\" }), r;\n};\n//#endregion\n//#region src/persistence.ts\nfunction n(e) {\n\treturn Array.isArray(e) ? e.filter((e) => e != null) : [];\n}\nfunction r(e) {\n\tlet t = [...e];\n\tfor (let e = t.length - 1; e > 0; e--) {\n\t\tlet n = Math.floor(Math.random() * (e + 1));\n\t\t[t[e], t[n]] = [t[n], t[e]];\n\t}\n\treturn t;\n}\nfunction i(e) {\n\treturn e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == \"object\" ? Object.keys(e).length === 0 : !1;\n}\nasync function a(e, t, a, o = \"value\") {\n\tlet s = n(t?.data?.shuffledValues ?? t?.shuffledValues ?? []);\n\tif (!t) {\n\t\tconsole.warn(\"Unable to save shuffled choices because there's no session.\");\n\t\treturn;\n\t}\n\tif (!i(s)) return n(s.map((t) => e.find((e) => e[o] === t)));\n\tlet c = r(e);\n\tif (a && typeof a == \"function\") try {\n\t\tlet e = n(c.map((e) => e[o]));\n\t\ti(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(c)}, key: ${o}`) : t.id && t.element && await a(t.id, t.element, { shuffledValues: e });\n\t} catch (e) {\n\t\tconsole.warn(\"Unable to save shuffled order for choices\"), console.error(e);\n\t}\n\telse console.warn(\"Unable to save shuffled choices, shuffle will happen every time.\");\n\treturn c;\n}\nfunction o(e, t, n) {\n\treturn !!(e.lockChoiceOrder || n[\"@pie-element\"]?.lockChoiceOrder || (n.role ?? \"student\") === \"instructor\");\n}\n//#endregion\n//#region src/partial-scoring.ts\nvar s = /* @__PURE__ */ t({ enabled: () => c });\nfunction c(e, t, n) {\n\treturn e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n == \"boolean\" ? n : !0;\n}\n//#endregion\nexport { a as getShuffledChoices, o as lockChoices, s as partialScoring };\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/placement-ordering/controller/src/defaults.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nexport default {\n choiceLabel: '',\n choiceLabelEnabled: true,\n choices: [],\n correctResponse: [],\n feedbackEnabled: false,\n numberedGuides: false,\n orientation: 'vertical',\n partialScoring: true,\n placementArea: false,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n removeTilesAfterPlacing: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n targetLabel: '',\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n};\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/placement-ordering/controller/src/index.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nimport { flattenCorrect, getAllCorrectResponses, score } from './scoring.js';\n\nimport { every, isArray, isEmpty, isEqual, map, reduce } from '@pie-element/shared-lodash';\nimport { getFeedbackForCorrectness } from '@pie-element/shared-feedback';\nimport { partialScoring } from '@pie-element/shared-controller-utils';\nimport debug from 'debug';\n\nimport defaults from './defaults.js';\n\nconst log = debug('@pie-element:placement-ordering:controller');\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nexport const questionError = () => new Error('Question is missing required array: correctResponse');\n\n/**\n * Generates detailed trace log for placement-ordering scoring evaluation\n * @param {Object} question - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array<string>} traceLog\n */\nexport const getLogTrace = (question, session, env) => {\n const traceLog = [];\n\n const value = session?.value || [];\n const correctResponse = question?.correctResponse || [];\n const hasPlacementArea = question?.placementArea === true;\n\n if (!value.length) {\n if (hasPlacementArea) {\n traceLog.push('Student did not place any tiles in the target area.');\n } else {\n traceLog.push('Student did not reorder any tiles.');\n }\n traceLog.push('Final score: 0.');\n return traceLog;\n }\n\n const allCorrectResponses = getAllCorrectResponses(question);\n\n let bestMatch = { score: 0, response: [] };\n\n allCorrectResponses.forEach((cr) => {\n let matchCount = 0;\n value.forEach((v, idx) => {\n if (cr[idx] === v) {\n matchCount++;\n }\n });\n\n if (matchCount > bestMatch.score) {\n bestMatch = { score: matchCount, response: cr };\n }\n });\n\n const correctCount = bestMatch.score;\n const incorrectCount = value.length - correctCount;\n\n if (correctCount > 0) {\n traceLog.push(`${correctCount} tile(s) placed in the correct order.`);\n }\n\n if (incorrectCount > 0) {\n traceLog.push(`${incorrectCount} tile(s) placed in an incorrect order.`);\n }\n\n const isFullyCorrect = allCorrectResponses.some((cr) => isEqual(cr, value));\n\n const partialScoringEnabled = partialScoring.enabled(question, env || {});\n\n if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push(\n 'Each tile placed in the correct position contributes to the score.',\n );\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n if (hasPlacementArea) {\n traceLog.push(\n 'Student must place all tiles in the correct positions within the target area to receive full credit.',\n );\n } else {\n traceLog.push(\n 'Student must arrange all tiles in the correct order to receive full credit.',\n );\n }\n }\n\n const rawScore = score(question, session);\n const finalScore = partialScoringEnabled ? rawScore : rawScore === 1 ? 1 : 0;\n\n traceLog.push(`Final score: ${finalScore}.`);\n\n return traceLog;\n};\n\nexport function outcome(question, session, env) {\n return new Promise((resolve, reject) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n logTrace: ['Student did not interact with the placement-ordering item.'] \n });\n return;\n }\n\n if (!question || !question.correctResponse || isEmpty(question.correctResponse)) {\n reject(questionError());\n } else {\n try {\n const s = score(question, session);\n const finalScore = partialScoring.enabled(question, env || {}) ? s : s === 1 ? 1 : 0;\n resolve({\n score: finalScore,\n logTrace: getLogTrace(question, session, env)\n });\n } catch (e) {\n reject(e);\n }\n }\n });\n}\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n}\n\nexport const normalize = (question) => ({\n ...defaults,\n rationaleEnabled: true,\n feedbackEnabled: false,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const base = {};\n\n if (question.alternateResponses && every(question.alternateResponses, isArray)) {\n log('Deprecated structure of alternateResponses is in use');\n // eslint-disable-next-line no-console\n console.error('Deprecated structure of alternateResponses is in use');\n }\n\n base.env = env;\n base.extraCSSRules = normalizedQuestion.extraCSSRules;\n base.outcomes = [];\n base.completeLength = (normalizedQuestion.correctResponse || []).length;\n base.choices = (normalizedQuestion.choices || []).filter((choice) => choice.label);\n base.note = normalizedQuestion.note;\n base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0;\n base.language = normalizedQuestion.language;\n\n log('[model] removing tileSize for the moment.');\n\n base.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null;\n base.config = {\n orientation: normalizedQuestion.orientation || 'vertical',\n includeTargets: normalizedQuestion.placementArea,\n choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled,\n targetLabel: normalizedQuestion.targetLabel,\n choiceLabel: normalizedQuestion.choiceLabel,\n showOrdering: normalizedQuestion.numberedGuides,\n allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing,\n };\n\n base.disabled = env.mode !== 'gather';\n\n if (!base.note) {\n base.note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n base.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate') {\n const value = (session && session.value) || [];\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n\n const bestSetOfResponses = allCorrectResponses.reduce(\n (info, cr) => {\n const currentScore = reduce(value, (acc, c, idx) => acc + (Array.isArray(cr) && cr[idx] === c ? 1 : 0), 0);\n\n if (currentScore > info.score) {\n return {\n arr: cr,\n score: currentScore,\n };\n }\n\n return info;\n },\n { arr: [], score: 0 },\n );\n\n base.outcomes = map(value, (c, idx) => {\n return {\n id: c,\n outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect',\n };\n });\n\n const isResponseCorrect = allCorrectResponses.some((response) => isEqual(response, value));\n const responseScore = score(question, session);\n const isCorrect = responseScore === 1;\n const isPartialCorrect = !isCorrect && partialScoring.enabled(normalizedQuestion, env || {}) && responseScore !== 0;\n\n base.correctness = isCorrect ? 'correct' : isPartialCorrect ? 'partial' : 'incorrect';\n\n if (!isResponseCorrect) {\n base.correctResponse = flattenCorrect(normalizedQuestion);\n }\n\n // requirement made in PD-2182\n if (!normalizedQuestion.feedback) {\n normalizedQuestion.feedbackEnabled = false;\n }\n\n const feedback = normalizedQuestion.feedbackEnabled\n ? await getFeedbackForCorrectness(base.correctness, normalizedQuestion.feedback)\n : undefined;\n\n base.feedback = feedback;\n return base;\n } else {\n return base;\n }\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({\n id: '1',\n value: flattenCorrect(question),\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, correctResponse } = model;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const reversedChoices = [...(choices || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { id, label } = choice;\n\n if (!getContent(label)) {\n choicesErrors[id] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Content should be unique.';\n }\n }\n });\n\n const choicesIds = (choices || []).map((choice) => choice.id);\n const correctResponseIds = (correctResponse || []).map((response) => response.id || response);\n\n if (isEqual(choicesIds, correctResponseIds)) {\n errors.orderError = 'The correct ordering should not be identical to the initial ordering.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n"],"x_google_ignoreList":[0],"mappings":";;;AAoBA,SAAgB,EAAY,GAAG,GAAG;CAC9B,IAAI,IAAI,GACJ,MAAU,WAAW,GAAG,EAAE,iBAAiB;CAC/C,IAAI,IAAI,GACJ,MAAU,WAAW,GAAG,EAAE,iBAAiB;CAC/C,IAAS,KAAL,GACA,OAAO;CACX,IAAI,IAAI,GACJ,OAAO;CACX,IAAI,CAAC,GAAI,GAAI,KAAM;EAAC,OAAO,CAAC;EAAG,OAAO,CAAC;EAAG;CAAE;CAC5C,OAAO,MACH,KAAM;CACV,OAAO;AACX;AAMA,SAAgB,EAAY,GAAG,GAAG;CAO9B,OANS,KAAL,KAEA,KAAK,IACE,KAC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