UNPKG

scrivito-pisasales-questionnaire-builder

Version:
61 lines (60 loc) 1.54 kB
import { e as p, f as E, g, h as l, j as r, k as W, P as I, E as c, c as T, T as N, a as _, M as A, H as f, D as d, O as S } from "./scrivitoConfig-WST4rsmc.js"; const Q = (s) => s.widgets().filter( (t) => t.objClass() == p || t.objClass() == E || t.objClass() == g || t.objClass() == l ), U = (s) => { if (r(s)) return []; const o = []; for (const n of s) { if (n.objClass() !== W) { console.warn( `${n.objClass()} with ID ${n.id()} can not be converted to an AnswerOption.` ); continue; } const t = D(n); o.push(t); } return o; }, D = (s) => ({ text: s.get(N), identifier: s.get(T), externalId: s.get(c), position: s.get(I) }), C = (s) => { const o = s.get(c), n = s.get(N), t = s.get(_), e = s.get(A), i = s.get(f), a = s.get(d), O = s.get(T), u = s.get(I); return { externalId: o, text: n, type: t, mandatory: e, help: i, defaultValue: a, identifier: O, position: u }; }, R = (s) => { const o = { questions: [], answerOptions: /* @__PURE__ */ new Map(), questionWidgets: [], optionWidgets: [] }, n = Q(s); if (r(n)) return o; for (const t of n) { const e = C(t); if (o.questions.push(e), t.objClass() == E) { const i = t.get(S), a = U(i); r(a) || o.answerOptions.set(e.externalId, a), o.optionWidgets.push(...i); } } return { ...o, questionWidgets: n }; }; export { D as a, C as c, R as e, Q as g }; //# sourceMappingURL=extractQuestionsAndOptions-C6y_aX6L.js.map