@astl/astrolabe 0.1.2 → 0.1.4

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 (109) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cdn/astrolabe-editor.js +3 -3
  3. package/dist/cdn/astrolabe-player.js +1 -1
  4. package/dist/cdn/astrolabe.js +1 -1
  5. package/dist/cdn/astrolabe.standalone.js +1094 -1060
  6. package/dist/cdn/chunks/{audio-B0LSIn5N.js → audio-Biof5aA3.js} +2 -2
  7. package/dist/cdn/chunks/{audio-B0LSIn5N.js.map → audio-Biof5aA3.js.map} +1 -1
  8. package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js → block-styles-CCtSFM4j.js} +2 -2
  9. package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js.map → block-styles-CCtSFM4j.js.map} +1 -1
  10. package/dist/cdn/chunks/{book-CHzDDaim.js → book-IFipARhv.js} +2 -2
  11. package/dist/cdn/chunks/{book-CHzDDaim.js.map → book-IFipARhv.js.map} +1 -1
  12. package/dist/cdn/chunks/{callout-QFLFLPc5.js → callout-CuajbbYY.js} +2 -2
  13. package/dist/cdn/chunks/{callout-QFLFLPc5.js.map → callout-CuajbbYY.js.map} +1 -1
  14. package/dist/cdn/chunks/{categorise-BO2tNVJ3.js → categorise-Cm6kXLXw.js} +2 -2
  15. package/dist/cdn/chunks/{categorise-BO2tNVJ3.js.map → categorise-Cm6kXLXw.js.map} +1 -1
  16. package/dist/cdn/chunks/{chip-styles-Dme5daTO.js → chip-styles--gboWK2Z.js} +2 -2
  17. package/dist/cdn/chunks/{chip-styles-Dme5daTO.js.map → chip-styles--gboWK2Z.js.map} +1 -1
  18. package/dist/cdn/chunks/{choice-CExBvqKj.js → choice-BSpB6LHl.js} +2 -2
  19. package/dist/cdn/chunks/{choice-CExBvqKj.js.map → choice-BSpB6LHl.js.map} +1 -1
  20. package/dist/cdn/chunks/{color-control-Cl5cuMSO.js → color-control-1kkdM8ns.js} +2 -2
  21. package/dist/cdn/chunks/{color-control-Cl5cuMSO.js.map → color-control-1kkdM8ns.js.map} +1 -1
  22. package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js → crossword-BdOAEPcL.js} +2 -2
  23. package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js.map → crossword-BdOAEPcL.js.map} +1 -1
  24. package/dist/cdn/chunks/{definitions-CNX90WtL.js → definitions-BybSa1mq.js} +2 -2
  25. package/dist/cdn/chunks/{definitions-CNX90WtL.js.map → definitions-BybSa1mq.js.map} +1 -1
  26. package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js → directive-helpers-US6zRjJ1.js} +2 -2
  27. package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js.map → directive-helpers-US6zRjJ1.js.map} +1 -1
  28. package/dist/cdn/chunks/{drop-vRXndjHu.js → drop-D4NQ0WK_.js} +2 -2
  29. package/dist/cdn/chunks/{drop-vRXndjHu.js.map → drop-D4NQ0WK_.js.map} +1 -1
  30. package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js → flash-cards-D4ebb5m6.js} +2 -2
  31. package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js.map → flash-cards-D4ebb5m6.js.map} +1 -1
  32. package/dist/cdn/chunks/{gap-lor-khst.js → gap-D-Sipuyu.js} +2 -2
  33. package/dist/cdn/chunks/{gap-lor-khst.js.map → gap-D-Sipuyu.js.map} +1 -1
  34. package/dist/cdn/chunks/{help-C-woafz5.js → help-CmCFuNXk.js} +2 -2
  35. package/dist/cdn/chunks/{help-C-woafz5.js.map → help-CmCFuNXk.js.map} +1 -1
  36. package/dist/cdn/chunks/{help-form-CDg3TCwI.js → help-form-Di2NtKDp.js} +14 -10
  37. package/dist/cdn/chunks/help-form-Di2NtKDp.js.map +1 -0
  38. package/dist/cdn/chunks/{hotspot-oel1Eelo.js → hotspot-B3bvqVzf.js} +2 -2
  39. package/dist/cdn/chunks/{hotspot-oel1Eelo.js.map → hotspot-B3bvqVzf.js.map} +1 -1
  40. package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js → image-drop-vLc2B7rF.js} +2 -2
  41. package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js.map → image-drop-vLc2B7rF.js.map} +1 -1
  42. package/dist/cdn/chunks/{image-label-Dm5shQSh.js → image-label-DsKxQDTQ.js} +2 -2
  43. package/dist/cdn/chunks/{image-label-Dm5shQSh.js.map → image-label-DsKxQDTQ.js.map} +1 -1
  44. package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js → inline-styles-CFNlb6f2.js} +2 -2
  45. package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js.map → inline-styles-CFNlb6f2.js.map} +1 -1
  46. package/dist/cdn/chunks/{insert-menu-7vANVmTK.js → insert-menu-DAQglwtG.js} +2 -2
  47. package/dist/cdn/chunks/{insert-menu-7vANVmTK.js.map → insert-menu-DAQglwtG.js.map} +1 -1
  48. package/dist/cdn/chunks/{issue-list-BT9qvnZU.js → issue-list-CzSmohtT.js} +2 -2
  49. package/dist/cdn/chunks/{issue-list-BT9qvnZU.js.map → issue-list-CzSmohtT.js.map} +1 -1
  50. package/dist/cdn/chunks/{live-jdiyYln2.js → live-qnReIRtj.js} +2 -2
  51. package/dist/cdn/chunks/{live-jdiyYln2.js.map → live-qnReIRtj.js.map} +1 -1
  52. package/dist/cdn/chunks/{long-answer-CtzClLAx.js → long-answer-NSWJiK0z.js} +2 -2
  53. package/dist/cdn/chunks/{long-answer-CtzClLAx.js.map → long-answer-NSWJiK0z.js.map} +1 -1
  54. package/dist/cdn/chunks/{mark-words-CpH3gTcX.js → mark-words-BKu-_uIl.js} +2 -2
  55. package/dist/cdn/chunks/{mark-words-CpH3gTcX.js.map → mark-words-BKu-_uIl.js.map} +1 -1
  56. package/dist/cdn/chunks/{match-DKE_4o-x.js → match-BpnJGW_5.js} +21 -13
  57. package/dist/cdn/chunks/match-BpnJGW_5.js.map +1 -0
  58. package/dist/cdn/chunks/{memory-B6hSyHyz.js → memory-BgTHujsU.js} +2 -2
  59. package/dist/cdn/chunks/{memory-B6hSyHyz.js.map → memory-BgTHujsU.js.map} +1 -1
  60. package/dist/cdn/chunks/messages-Qzse5KMX.js +2 -0
  61. package/dist/cdn/chunks/messages-Qzse5KMX.js.map +1 -0
  62. package/dist/cdn/chunks/{option-styles-WKzjKmCH.js → option-styles-B2sBX5Oz.js} +2 -2
  63. package/dist/cdn/chunks/{option-styles-WKzjKmCH.js.map → option-styles-B2sBX5Oz.js.map} +1 -1
  64. package/dist/cdn/chunks/{order-BhG_6IC-.js → order-B9gqH5wm.js} +2 -2
  65. package/dist/cdn/chunks/{order-BhG_6IC-.js.map → order-B9gqH5wm.js.map} +1 -1
  66. package/dist/cdn/chunks/{picture-view-BKnAyScQ.js → picture-view-Deodu_mb.js} +2 -2
  67. package/dist/cdn/chunks/{picture-view-BKnAyScQ.js.map → picture-view-Deodu_mb.js.map} +1 -1
  68. package/dist/cdn/chunks/{repeat-CY2W2URZ.js → repeat-BDXokpxQ.js} +2 -2
  69. package/dist/cdn/chunks/{repeat-CY2W2URZ.js.map → repeat-BDXokpxQ.js.map} +1 -1
  70. package/dist/cdn/chunks/{runtime-DxAbpr3S.js → runtime-C25QK5B0.js} +3 -3
  71. package/dist/cdn/chunks/{runtime-DxAbpr3S.js.map → runtime-C25QK5B0.js.map} +1 -1
  72. package/dist/cdn/chunks/{scan-jWgPnVxA.js → scan-BVhxT2Hw.js} +2 -2
  73. package/dist/cdn/chunks/{scan-jWgPnVxA.js.map → scan-BVhxT2Hw.js.map} +1 -1
  74. package/dist/cdn/chunks/{select-DTA3dJzr.js → select-DPpKJwSg.js} +2 -2
  75. package/dist/cdn/chunks/{select-DTA3dJzr.js.map → select-DPpKJwSg.js.map} +1 -1
  76. package/dist/cdn/chunks/select-QZ35cyns.js +2 -0
  77. package/dist/cdn/chunks/select-QZ35cyns.js.map +1 -0
  78. package/dist/cdn/chunks/{source-view-CZVxgTNQ.js → source-view-gqFlZzwR.js} +2 -2
  79. package/dist/cdn/chunks/{source-view-CZVxgTNQ.js.map → source-view-gqFlZzwR.js.map} +1 -1
  80. package/dist/cdn/chunks/{style-form-DUGbG_kL.js → style-form-DuR0EEum.js} +2 -2
  81. package/dist/cdn/chunks/{style-form-DUGbG_kL.js.map → style-form-DuR0EEum.js.map} +1 -1
  82. package/dist/cdn/chunks/{style-messages-qdf3pZbT.js → style-messages-B136zSom.js} +2 -2
  83. package/dist/cdn/chunks/{style-messages-qdf3pZbT.js.map → style-messages-B136zSom.js.map} +1 -1
  84. package/dist/cdn/chunks/{style-popups-BobgX1WK.js → style-popups-Bcl5imdP.js} +2 -2
  85. package/dist/cdn/chunks/{style-popups-BobgX1WK.js.map → style-popups-Bcl5imdP.js.map} +1 -1
  86. package/dist/cdn/chunks/{style-rules-D17QGzXk.js → style-rules-ozpLz2ec.js} +2 -2
  87. package/dist/cdn/chunks/{style-rules-D17QGzXk.js.map → style-rules-ozpLz2ec.js.map} +1 -1
  88. package/dist/cdn/chunks/{styled-Dmx5Yjv7.js → styled-bQqnDxBf.js} +2 -2
  89. package/dist/cdn/chunks/{styled-Dmx5Yjv7.js.map → styled-bQqnDxBf.js.map} +1 -1
  90. package/dist/cdn/chunks/{styles-CdJT6Pp9.js → styles-DiY3VA_T.js} +5 -5
  91. package/dist/cdn/chunks/styles-DiY3VA_T.js.map +1 -0
  92. package/dist/cdn/chunks/surface-CIz1z2oY.js +1059 -0
  93. package/dist/cdn/chunks/surface-CIz1z2oY.js.map +1 -0
  94. package/dist/cdn/chunks/{true-false-DP3MO599.js → true-false-C-S6RmZY.js} +2 -2
  95. package/dist/cdn/chunks/{true-false-DP3MO599.js.map → true-false-C-S6RmZY.js.map} +1 -1
  96. package/dist/cdn/chunks/{video-j9MCH6Kw.js → video-Dae8Gguf.js} +2 -2
  97. package/dist/cdn/chunks/{video-j9MCH6Kw.js.map → video-Dae8Gguf.js.map} +1 -1
  98. package/dist/cdn/chunks/{word-bank-ARjwUKZf.js → word-bank-CsIle0Ro.js} +2 -2
  99. package/dist/cdn/chunks/{word-bank-ARjwUKZf.js.map → word-bank-CsIle0Ro.js.map} +1 -1
  100. package/dist/cdn/chunks/{word-search-AHvM7yCJ.js → word-search-IOCwqo3y.js} +2 -2
  101. package/dist/cdn/chunks/{word-search-AHvM7yCJ.js.map → word-search-IOCwqo3y.js.map} +1 -1
  102. package/package.json +9 -9
  103. package/dist/cdn/chunks/help-form-CDg3TCwI.js.map +0 -1
  104. package/dist/cdn/chunks/match-DKE_4o-x.js.map +0 -1
  105. package/dist/cdn/chunks/messages-D1aJfyS_.js +0 -2
  106. package/dist/cdn/chunks/messages-D1aJfyS_.js.map +0 -1
  107. package/dist/cdn/chunks/styles-CdJT6Pp9.js.map +0 -1
  108. package/dist/cdn/chunks/surface-C6wtQkTY.js +0 -1037
  109. package/dist/cdn/chunks/surface-C6wtQkTY.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-form-Di2NtKDp.js","names":["en","pl","nothing","live","parseHtml","b","HINT_TAG","i","HELP_TAGS","A","FEEDBACK_VARIANTS","isElement","textContent","EXPLANATION_TAG","FEEDBACK_TAG","escapeAttribute","spaceBefore","attributeValue","escapeText","elementTree","applyEdits","EDITOR_NAMESPACE","kitStyles","AuthoringElement","l","inner","range","source","helpChildren","root","c","isVariant","value","readHelp","html","hints","explanation","feedback","child","content","when","helpSource","cost","help","h","text","writeHelp","first","cleared","added","last","at","gap","sep","a","lines","node","helpText","nodes","part","helpFormatted","plain","inline","depth","formatted","textHelp","helpMessages","pending","graded","authoring","tag","addHelp","selection","adapter","current","block","kind","next","field","FEEDBACK_ORDER","w","percentOf","n","inputValue","event","AstlHelpForm","changed","#drafts","#help","change","#write","to","from","moved","hint","index","#formatted","over","#dragged","on","#move","#text","#typed","x","#done","percent","label","e","set","remove","lang","dir","#hint","#area"],"sources":["../../../../editor/src/help.ts","../../../../editor/src/messages/help/en.json","../../../../editor/src/messages/help/pl.json","../../../../editor/src/elements/help-form.ts"],"sourcesContent":["/**\n * The help for students of one graded element, read from and written to its source HTML: its hints (in order, each\n * with its cost), its explanation and its feedback texts, its direct children. Writing replaces them all, after the\n * element's other children, and leaves everything else byte-identical. The help form edits plain text: a text becomes\n * paragraphs (text alone in an element in a line of text); a text not edited keeps its HTML.\n */\nimport {\n type ElementNode,\n EXPLANATION_TAG,\n FEEDBACK_TAG,\n FEEDBACK_VARIANTS,\n type FeedbackVariant,\n HELP_TAGS,\n HINT_TAG,\n isElement,\n type Node,\n textContent,\n} from '@astl/core';\nimport { parseHtml } from '@astl/engine';\nimport {\n applyEdits,\n attributeValue,\n type ElementRange,\n elementTree,\n escapeAttribute,\n escapeText,\n spaceBefore,\n} from './scan.js';\n\nexport interface HelpHint {\n /** Its content as written. */\n readonly html: string;\n /** Its `cost` attribute as written, null when it has none (free). */\n readonly cost: string | null;\n}\n\n/** An element's help. Contents are HTML as written; an absent explanation or feedback text is null or missing. */\nexport interface HelpValue {\n readonly hints: readonly HelpHint[];\n readonly explanation: string | null;\n readonly feedback: Readonly<Partial<Record<FeedbackVariant, string>>>;\n}\n\nconst inner = (source: string, range: ElementRange): string =>\n range.endTag === null && range.startTag.selfClosing\n ? ''\n : source.slice(range.startTag.end, range.endTag?.start ?? range.end);\n\nconst helpChildren = (root: ElementRange): ElementRange[] =>\n root.children.filter((c) => HELP_TAGS.has(c.name));\n\nconst isVariant = (value: string | null): value is FeedbackVariant =>\n FEEDBACK_VARIANTS.includes(value as FeedbackVariant);\n\n/** The help of the first element in `html`. Later duplicates of an explanation or a feedback text are left out. */\nexport function readHelp(html: string): HelpValue {\n const root = elementTree(html)[0];\n const hints: HelpHint[] = [];\n let explanation: string | null = null;\n const feedback: Partial<Record<FeedbackVariant, string>> = {};\n for (const child of root === undefined ? [] : helpChildren(root)) {\n const content = inner(html, child);\n if (child.name === HINT_TAG) hints.push({ html: content, cost: attributeValue(child.startTag, 'cost') });\n else if (child.name === EXPLANATION_TAG) explanation ??= content;\n else {\n const when = attributeValue(child.startTag, 'when');\n if (isVariant(when)) feedback[when] ??= content;\n }\n }\n return { hints, explanation, feedback };\n}\n\n/** The help as source: hints, the explanation, then the feedback texts in the order of `FEEDBACK_VARIANTS`. */\nfunction helpSource(help: HelpValue): string[] {\n const cost = (value: string | null) => (value === null ? '' : ` cost=\"${escapeAttribute(value)}\"`);\n return [\n ...help.hints.map((h) => `<${HINT_TAG}${cost(h.cost)}>${h.html}</${HINT_TAG}>`),\n ...(help.explanation === null ? [] : [`<${EXPLANATION_TAG}>${help.explanation}</${EXPLANATION_TAG}>`]),\n ...FEEDBACK_VARIANTS.flatMap((when) => {\n const text = help.feedback[when];\n return text === undefined ? [] : [`<${FEEDBACK_TAG} when=\"${when}\">${text}</${FEEDBACK_TAG}>`];\n }),\n ];\n}\n\n/** Replaces the help of the first element in `html` with `help`, after its other children. */\nexport function writeHelp(html: string, help: HelpValue): string {\n const first = elementTree(html)[0];\n if (first === undefined) return html;\n // Out first, then in: an insertion where a removal starts would shift it.\n const cleared = applyEdits(\n html,\n helpChildren(first).map((c) => ({ start: spaceBefore(html, c.start), end: c.end, text: '' })),\n );\n const added = helpSource(help);\n const root = elementTree(cleared)[0];\n if (root === undefined || added.length === 0) return cleared;\n const last = root.children.at(-1);\n if (last === undefined) {\n const at = root.endTag?.start ?? root.end;\n const closed = root.endTag === null && root.startTag.selfClosing;\n return closed\n ? `${cleared.slice(0, root.start)}${cleared.slice(root.start, spaceBefore(cleared, root.startTag.end - 2))}>${added.join('')}</${root.name}>${cleared.slice(root.end)}`\n : applyEdits(cleared, [{ start: at, end: at, text: added.join('') }]);\n }\n // On their own lines when the children are.\n const gap = cleared.slice(spaceBefore(cleared, last.start), last.start);\n const sep = /^\\s*$/.test(gap) ? gap : '';\n return applyEdits(cleared, [{ start: last.end, end: last.end, text: added.map((a) => sep + a).join('') }]);\n}\n\n/** The text of a node with its line breaks, as a field shows them (`textHelp` writes them back as `<br>`). */\nconst lines = (node: Node): string =>\n !isElement(node) ? textContent(node) : node.tag === 'br' ? '\\n' : node.children.map(lines).join('');\n\n/** What a help text says, for a text field: its paragraphs apart by a blank line, its line breaks kept. */\nexport function helpText(html: string): string {\n const blocks = (nodes: readonly Node[]): string[] =>\n nodes.flatMap((node) => {\n if (!isElement(node)) return [textContent(node)];\n return node.tag === 'p' || node.tag === 'li' ? [`\\n\\n${lines(node).trim()}\\n\\n`] : [lines(node)];\n });\n return blocks(parseHtml(html))\n .join('')\n .replace(/[ \\t]+/g, ' ')\n .split(/\\n{2,}/)\n .map((part) => part.trim())\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Whether a help text holds more than its field writes back (paragraphs of plain text, or text alone for an element in\n * a line of text): a change in the field keeps the words and drops the rest, so the form says so first.\n */\nexport function helpFormatted(html: string, inline: boolean): boolean {\n // What a field writes: paragraphs holding text and line breaks; text alone in a line of text.\n const plain = (node: ElementNode, depth: number): boolean =>\n !inline &&\n Object.keys(node.attrs).length === 0 &&\n (depth === 0 ? node.tag === 'p' : depth === 1 && node.tag === 'br');\n const formatted = (nodes: readonly Node[], depth: number): boolean =>\n nodes.some((node) => isElement(node) && (!plain(node, depth) || formatted(node.children, depth + 1)));\n return formatted(parseHtml(html), 0);\n}\n\n/** HTML from a field's text: paragraphs (blank lines part them), or text alone for an element in a line of text. */\nexport function textHelp(text: string, inline: boolean): string {\n if (inline) return escapeText(text.replace(/\\s+/g, ' ').trim());\n return text\n .split(/\\n\\s*\\n/)\n .map((part) => part.trim())\n .filter(Boolean)\n .map((part) => `<p>${escapeText(part).replace(/\\n/g, '<br>')}</p>`)\n .join('');\n}\n","{\n \"help.title\": \"Help for students\",\n \"help.hints\": \"Hints\",\n \"help.hintsNote\": \"Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.\",\n \"help.hintN\": \"Hint {n}\",\n \"help.cost\": \"Cost (% of the points)\",\n \"help.costN\": \"Hint {n}: cost (% of the points)\",\n \"help.addHint\": \"Add a hint\",\n \"help.up\": \"Up\",\n \"help.down\": \"Down\",\n \"help.upN\": \"Move hint {n} up\",\n \"help.downN\": \"Move hint {n} down\",\n \"help.removeN\": \"Remove hint {n}\",\n \"help.removeExplanation\": \"Remove the explanation\",\n \"help.removeFeedback\": \"Remove the feedback: {when}\",\n \"help.drag\": \"Drag to reorder\",\n \"help.explanationNote\": \"Students open it under \\\"Why?\\\" once their answer is checked. Leave it empty for none.\",\n \"help.feedbackNote\": \"Shown after a check, by the verdict. Leave a text empty for none.\",\n \"help.formatted\": \"This text has formatting. A change in this field keeps only the text.\"\n}\n","{\n \"help.title\": \"Pomoc dla ucznia\",\n \"help.hints\": \"Podpowiedzi\",\n \"help.hintsNote\": \"Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.\",\n \"help.hintN\": \"Podpowiedź {n}\",\n \"help.cost\": \"Koszt (% punktów)\",\n \"help.costN\": \"Podpowiedź {n}: koszt (% punktów)\",\n \"help.addHint\": \"Dodaj podpowiedź\",\n \"help.up\": \"W górę\",\n \"help.down\": \"W dół\",\n \"help.upN\": \"Przenieś podpowiedź {n} w górę\",\n \"help.downN\": \"Przenieś podpowiedź {n} w dół\",\n \"help.removeN\": \"Usuń podpowiedź {n}\",\n \"help.removeExplanation\": \"Usuń wyjaśnienie\",\n \"help.removeFeedback\": \"Usuń informację zwrotną: {when}\",\n \"help.drag\": \"Przeciągnij, aby zmienić kolejność\",\n \"help.explanationNote\": \"Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.\",\n \"help.feedbackNote\": \"Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.\",\n \"help.formatted\": \"Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.\"\n}\n","/**\n * `<astl-help-form>`: the inspector's \"Help for students\" section of a graded element: its hints in order, each with\n * its cost (Up, Down, a drag, Remove, Add), its explanation and its four feedback texts. Every edit rewrites the\n * element's help (`writeHelp`) through `EditorAdapter.replaceElement`. A module of its own, outside the editor's first\n * load (`loadHelpForm`), with its messages; `addHelp` is the insert menu's way in.\n */\nimport { type EditorAdapter, FEEDBACK_VARIANTS, type FeedbackVariant, type MessageCatalog } from '@astl/core';\nimport {\n type CSSResultGroup,\n css,\n html,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport type { Authoring } from '../authoring.js';\nimport { type HelpValue, helpFormatted, helpText, readHelp, textHelp, writeHelp } from '../help.js';\nimport en from '../messages/help/en.json' with { type: 'json' };\nimport pl from '../messages/help/pl.json' with { type: 'json' };\nimport { EDITOR_NAMESPACE } from '../messages.js';\nimport { AuthoringElement } from './base.js';\nimport { kitStyles } from './styles.js';\n\nconst helpMessages: readonly MessageCatalog[] = [\n { namespace: EDITOR_NAMESPACE, locale: 'en', messages: en },\n { namespace: EDITOR_NAMESPACE, locale: 'pl', messages: pl },\n];\n\n/** What the insert menu adds: a hint, the explanation, or the next feedback text the element lacks. */\nexport type HelpKind = 'hint' | 'explanation' | 'feedback';\n\n/** The field to focus once the form shows it (after an insert), by element id. */\nlet pending: { readonly element: string; readonly field: string } | null = null;\n\nconst graded = (authoring: Authoring, tag: string) => authoring.descriptor(tag)?.manifest.graded === true;\n\n/**\n * Adds help to the graded element at the cursor (and asks the form to focus it), or else to the page at the cursor.\n * Returns the HTML inserted on a page, or null when the element got it.\n */\nexport function addHelp(authoring: Authoring, adapter: EditorAdapter, kind: HelpKind): string | null {\n const selection = adapter.getSelection();\n const current = selection === null ? null : adapter.getElement(selection.id);\n if (selection === null || current === null || !graded(authoring, selection.tag)) {\n const block =\n kind === 'feedback'\n ? '<astl-feedback when=\"correct\"><p></p></astl-feedback>'\n : `<astl-${kind}><p></p></astl-${kind}>`;\n adapter.insert(block);\n return block;\n }\n const help = readHelp(current);\n let next: HelpValue;\n let field: string;\n if (kind === 'hint') {\n next = { ...help, hints: [...help.hints, { html: '', cost: null }] };\n field = `hint-${help.hints.length}`;\n } else if (kind === 'explanation') {\n next = { ...help, explanation: help.explanation ?? '' };\n field = 'explanation';\n } else {\n const when = FEEDBACK_ORDER.find((w) => help.feedback[w] === undefined) ?? 'correct';\n next = { ...help, feedback: { ...help.feedback, [when]: help.feedback[when] ?? '' } };\n field = `feedback-${when}`;\n }\n pending = { element: selection.id, field };\n adapter.replaceElement(selection.id, writeHelp(current, next));\n return null;\n}\n\n/** The order the menu fills feedback texts in: right and wrong first. */\nconst FEEDBACK_ORDER: readonly FeedbackVariant[] = ['correct', 'incorrect', 'omitted', 'partial'];\n\n/** A cost in percent of the points (0 to 100) from a `cost` attribute, or '' when there is none or it is not one. */\nconst percentOf = (cost: string | null): string => {\n if (cost === null) return '0';\n const n = Number(cost);\n return Number.isFinite(n) && n >= 0 && n <= 1 ? String(Math.round(n * 100)) : '';\n};\n\nconst inputValue = (event: Event) => (event.target as HTMLInputElement | HTMLTextAreaElement).value;\n\nexport class AstlHelpForm extends AuthoringElement {\n static override properties: PropertyDeclarations = {\n ...AuthoringElement.properties,\n element: {},\n inline: { type: Boolean },\n };\n\n static override styles: CSSResultGroup = [\n kitStyles,\n css`\n :host {\n display: block;\n }\n section {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n padding-block-start: var(--astl-space-3);\n border-block-start: var(--astl-outline-width) solid var(--astl-line);\n }\n h3 {\n margin: 0;\n font-size: 1rem;\n }\n fieldset,\n .field {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-1);\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n legend,\n label {\n padding: 0;\n font-weight: 600;\n }\n ol {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n li {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-1);\n padding: var(--astl-space-2);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-s);\n }\n li[data-over] {\n border-color: var(--astl-accent);\n }\n .row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-2);\n }\n .handle {\n cursor: grab;\n user-select: none;\n }\n .cost {\n display: flex;\n align-items: center;\n gap: var(--astl-space-1);\n font-weight: 400;\n }\n .cost input {\n inline-size: 6em;\n }\n textarea {\n field-sizing: content;\n min-block-size: 3lh;\n resize: vertical;\n }\n .delete {\n color: var(--astl-danger);\n }\n `,\n ];\n\n /** Source id of the element whose help this is. */\n declare element: string | null;\n /** The element sits in a line of text: its help holds text, not paragraphs. */\n declare inline: boolean;\n /** What the author is typing in a field, by field: the source has it cleaned, the field keeps it as typed. */\n #drafts = new Map<string, string>();\n #dragged: number | null = null;\n\n constructor() {\n super();\n this.element = null;\n this.inline = false;\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n super.willUpdate(changed);\n if (changed.has('authoring')) this.authoring?.addMessages(helpMessages);\n if (changed.has('element')) this.#drafts.clear();\n }\n\n protected override updated(): void {\n if (pending === null || pending.element !== this.element) return;\n const field = this.renderRoot.querySelector<HTMLElement>(`[data-help=\"${pending.field}\"]`);\n if (field === null) return;\n pending = null;\n field.focus();\n }\n\n #help(): { readonly html: string; readonly help: HelpValue } | null {\n const html = this.element === null ? null : (this.adapter?.getElement(this.element) ?? null);\n return html === null ? null : { html, help: readHelp(html) };\n }\n\n #write(change: (help: HelpValue) => HelpValue): void {\n const current = this.#help();\n if (current === null || this.element === null || this.adapter === null) return;\n const next = writeHelp(current.html, change(current.help));\n if (next !== current.html) this.adapter.replaceElement(this.element, next);\n }\n\n /** A text field's value: as typed while it is being edited, else what the source says. */\n #text(field: string, html: string): string {\n return this.#drafts.get(field) ?? helpText(html);\n }\n\n /** The note under a field whose text has formatting a change there would drop; null when there is none. */\n #formatted(field: string, source: string): TemplateResult | null {\n return helpFormatted(source, this.inline)\n ? html`<p class=\"note\" id=${`${field}-formatted`}>${this.t('help.formatted')}</p>`\n : null;\n }\n\n #typed(field: string, event: Event): string {\n const value = inputValue(event);\n this.#drafts.set(field, value);\n return textHelp(value, this.inline);\n }\n\n #done(field: string): void {\n this.#drafts.delete(field);\n this.requestUpdate();\n }\n\n #move(from: number, to: number): void {\n this.#write((help) => {\n if (to < 0 || to >= help.hints.length || from === to) return help;\n const hints = [...help.hints];\n const [moved] = hints.splice(from, 1);\n if (moved !== undefined) hints.splice(to, 0, moved);\n return { ...help, hints };\n });\n this.#drafts.clear();\n }\n\n #hint(help: HelpValue, index: number): TemplateResult {\n const hint = help.hints[index] as HelpValue['hints'][number];\n const n = index + 1;\n const field = `hint-${index}`;\n const last = index === help.hints.length - 1;\n const formatted = this.#formatted(field, hint.html);\n const over = (event: DragEvent, on: boolean) => {\n if (this.#dragged === null) return;\n event.preventDefault();\n (event.currentTarget as HTMLElement).toggleAttribute('data-over', on);\n };\n return html`<li\n @dragover=${(e: DragEvent) => over(e, true)}\n @dragleave=${(e: DragEvent) => over(e, false)}\n @drop=${(e: DragEvent) => {\n over(e, false);\n if (this.#dragged !== null) this.#move(this.#dragged, index);\n this.#dragged = null;\n }}\n >\n <div class=\"row\">\n <span\n class=\"handle\"\n draggable=\"true\"\n aria-hidden=\"true\"\n title=${this.t('help.drag')}\n @dragstart=${(e: DragEvent) => {\n this.#dragged = index;\n e.dataTransfer?.setData('text/plain', String(n));\n }}\n @dragend=${() => {\n this.#dragged = null;\n }}\n >⠿</span\n >\n <label for=${field}>${this.t('help.hintN', { n })}</label>\n </div>\n <textarea\n id=${field}\n data-help=${field}\n dir=\"auto\"\n aria-describedby=${formatted === null ? nothing : `${field}-formatted`}\n .value=${live(this.#text(field, hint.html))}\n @input=${(e: Event) => {\n const text = this.#typed(field, e);\n this.#write((h) => ({\n ...h,\n hints: h.hints.map((x, i) => (i === index ? { ...x, html: text } : x)),\n }));\n }}\n @change=${() => this.#done(field)}\n ></textarea>\n ${formatted ?? nothing}\n <div class=\"row\">\n <label class=\"cost\">\n ${this.t('help.cost')}\n <input\n type=\"number\"\n aria-label=${this.t('help.costN', { n })}\n min=\"0\"\n max=\"100\"\n step=\"5\"\n inputmode=\"numeric\"\n data-help=${`cost-${index}`}\n .value=${live(percentOf(hint.cost))}\n @change=${(e: Event) => {\n const percent = Number(inputValue(e));\n if (!Number.isFinite(percent) || percent < 0 || percent > 100) return;\n const cost = percent === 0 ? null : String(Math.round(percent) / 100);\n this.#write((h) => ({\n ...h,\n hints: h.hints.map((x, i) => (i === index ? { ...x, cost } : x)),\n }));\n }}\n />\n </label>\n <button type=\"button\" aria-label=${this.t('help.upN', { n })} aria-disabled=${String(index === 0)}\n @click=${() => this.#move(index, index - 1)}>${this.t('help.up')}</button>\n <button type=\"button\" aria-label=${this.t('help.downN', { n })} aria-disabled=${String(last)}\n @click=${() => this.#move(index, index + 1)}>${this.t('help.down')}</button>\n <button type=\"button\" class=\"delete\" aria-label=${this.t('help.removeN', { n })}\n @click=${() => {\n this.#drafts.clear();\n this.#write((h) => ({ ...h, hints: h.hints.filter((_, i) => i !== index) }));\n pending = {\n element: this.element ?? '',\n field: help.hints.length > 1 ? `hint-${Math.max(0, index - 1)}` : 'add-hint',\n };\n }}>${this.t('inspector.remove')}</button>\n </div>\n </li>`;\n }\n\n /**\n * A text field of the help: the explanation or a feedback text. While the element has it, \"Remove\" takes it away:\n * one the menu added stays empty, so clearing the field would not.\n */\n #area(\n field: string,\n label: string,\n remove: string,\n value: string | null | undefined,\n set: (html: string | null) => void,\n ): TemplateResult {\n const formatted = this.#formatted(field, value ?? '');\n return html`<div class=\"field\">\n <label for=${field}>${label}</label>\n <textarea\n id=${field}\n data-help=${field}\n dir=\"auto\"\n aria-describedby=${formatted === null ? nothing : `${field}-formatted`}\n .value=${live(this.#text(field, value ?? ''))}\n @input=${(e: Event) => {\n const text = this.#typed(field, e);\n set(text === '' ? null : text);\n }}\n @change=${() => this.#done(field)}\n ></textarea>\n ${formatted ?? nothing}\n ${\n value === null || value === undefined\n ? nothing\n : html`<div class=\"row\">\n <button type=\"button\" class=\"delete\" aria-label=${remove}\n @click=${() => {\n this.#drafts.delete(field);\n // The field stays, empty: the focus goes back to it.\n pending = { element: this.element ?? '', field };\n set(null);\n }}>${this.t('inspector.remove')}</button>\n </div>`\n }\n </div>`;\n }\n\n protected override render(): TemplateResult | typeof nothing {\n const current = this.#help();\n if (current === null || this.authoring === null) return nothing;\n const { help } = current;\n const { lang, dir } = this.ui;\n return html`<section class=\"kit\" part=\"help\" lang=${lang} dir=${dir} aria-labelledby=\"help-title\">\n <h3 id=\"help-title\">${this.t('help.title')}</h3>\n <fieldset aria-describedby=\"hints-note\">\n <legend>${this.t('help.hints')}</legend>\n <p class=\"note\" id=\"hints-note\">${this.t('help.hintsNote')}</p>\n ${help.hints.length === 0 ? nothing : html`<ol>${help.hints.map((_, i) => this.#hint(help, i))}</ol>`}\n <div class=\"row\">\n <button type=\"button\" data-help=\"add-hint\"\n @click=${() => {\n pending = { element: this.element ?? '', field: `hint-${help.hints.length}` };\n this.#write((h) => ({ ...h, hints: [...h.hints, { html: '', cost: null }] }));\n }}>${this.t('help.addHint')}</button>\n </div>\n </fieldset>\n ${this.#area(\n 'explanation',\n this.t('insert.explanation'),\n this.t('help.removeExplanation'),\n help.explanation,\n (text) => this.#write((h) => ({ ...h, explanation: text })),\n )}\n <p class=\"note\">${this.t('help.explanationNote')}</p>\n <fieldset aria-describedby=\"feedback-note\">\n <legend>${this.t('insert.feedback')}</legend>\n <p class=\"note\" id=\"feedback-note\">${this.t('help.feedbackNote')}</p>\n ${FEEDBACK_VARIANTS.map((when) =>\n this.#area(\n `feedback-${when}`,\n this.t(`help.when.${when}`),\n this.t('help.removeFeedback', { when: this.t(`help.when.${when}`) }),\n help.feedback[when],\n (text) =>\n this.#write((h) => {\n const feedback: Partial<Record<FeedbackVariant, string>> = { ...h.feedback };\n if (text === null) delete feedback[when];\n else feedback[when] = text;\n return { ...h, feedback };\n }),\n ),\n )}\n </fieldset>\n </section>`;\n }\n}\n"],"mappings":"A,0WA2CA,IAAMyB,GAAS,EA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MAAO,CAAC,GAAGA,EAAE,MAAO,CAAE,KAAM,GAAI,KAAM,IAAK,CAAC,CAAE,EAAE,CAC9E,EAAE,GAAG,KAAK,EAAE,cAAc,EAAE;;;QAGhC,KAAKqE,GACL,cACA,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,wBAAwB,EAC/BtE,EAAK,YACJ,GAAS,KAAK+C,GAAQ,IAAO,CAAE,GAAG9C,EAAG,YAAaC,CAAK,EAAE,CAC5D,EAAE;wBACgB,KAAK,EAAE,sBAAsB,EAAE;;kBAErC,KAAK,EAAE,iBAAiB,EAAE;6CACC,KAAK,EAAE,mBAAmB,EAAE;UAC/DnC,EAAkB,IAAK,GACvB,KAAKuG,GACH,YAAYzE,IACZ,KAAK,EAAE,aAAaA,GAAM,EAC1B,KAAK,EAAE,sBAAuB,CAAE,KAAM,KAAK,EAAE,aAAaA,GAAM,CAAE,CAAC,EACnEG,EAAK,SAASH,GACb,GACC,KAAKkD,GAAQ,GAAM,CACjB,IAAMrD,EAAqD,CAAE,GAAGO,EAAE,QAAS,EAG3E,OAFIC,IAAS,KAAM,OAAOR,EAASG,GAC9B,EAASA,GAAQK,EACf,CAAE,GAAGD,EAAG,UAAS,CAC1B,CAAC,CACL,CACF,EAAE;;eAGR,CACF,E"}
@@ -1,4 +1,4 @@
1
- import{C as e,E as t,T as n,b as r,hn as i,n as a,v as o,y as s}from"./runtime-DxAbpr3S.js";import{i as c,n as l,r as u,t as d}from"./picture-D10YRMYH.js";import{n as f,r as p,t as m}from"./hotspot-manifest-CNs1oiZ_.js";import{t as h}from"./live-jdiyYln2.js";import{t as g}from"./block-styles-CKo9x7Vt.js";import{i as _,n as v,o as y,r as b,t as x}from"./picture-view-BKnAyScQ.js";var S=`astl.hotspot`,C=[{namespace:S,locale:`en`,messages:f},{namespace:S,locale:`pl`,messages:m}];function w({region:e},t){if(e.shape===`rect`)return n`<rect class="shape" width="100" height="100"></rect>`;if(e.shape===`circle`)return n`<ellipse class="shape" cx="50" cy="50" rx="50" ry="50"></ellipse>`;let r=l(e,t),i=Math.max(r.right-r.left,1e-6),a=Math.max(r.bottom-r.top,1e-6),o=e.points.map(([e,t])=>`${(e-r.left)/i*100},${(t-r.top)/a*100}`);return n`<polygon class="shape" points=${o.join(` `)}></polygon>`}var T=class extends a{static manifest=p;static messages=C;static shadowRootOptions={...s.shadowRootOptions,slotAssignment:`manual`};static properties={picked:{state:!0},loaded:{state:!0}};static styles=[t`
1
+ import{C as e,E as t,T as n,b as r,hn as i,n as a,v as o,y as s}from"./runtime-C25QK5B0.js";import{i as c,n as l,r as u,t as d}from"./picture-D10YRMYH.js";import{n as f,r as p,t as m}from"./hotspot-manifest-CNs1oiZ_.js";import{t as h}from"./live-qnReIRtj.js";import{t as g}from"./block-styles-CCtSFM4j.js";import{i as _,n as v,o as y,r as b,t as x}from"./picture-view-Deodu_mb.js";var S=`astl.hotspot`,C=[{namespace:S,locale:`en`,messages:f},{namespace:S,locale:`pl`,messages:m}];function w({region:e},t){if(e.shape===`rect`)return n`<rect class="shape" width="100" height="100"></rect>`;if(e.shape===`circle`)return n`<ellipse class="shape" cx="50" cy="50" rx="50" ry="50"></ellipse>`;let r=l(e,t),i=Math.max(r.right-r.left,1e-6),a=Math.max(r.bottom-r.top,1e-6),o=e.points.map(([e,t])=>`${(e-r.left)/i*100},${(t-r.top)/a*100}`);return n`<polygon class="shape" points=${o.join(` `)}></polygon>`}var T=class extends a{static manifest=p;static messages=C;static shadowRootOptions={...s.shadowRootOptions,slotAssignment:`manual`};static properties={picked:{state:!0},loaded:{state:!0}};static styles=[t`
2
2
  fieldset {
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -151,4 +151,4 @@ background: CanvasText;
151
151
  >${this.t(`ui.solution`)}, ${this.t(`ui.missed`)}</span
152
152
  ></span
153
153
  >`}#r(e){if(this.disabled)return;if(this.picked.has(e)){let t=new Set(this.picked);t.delete(e),this.picked=t,this.emitChange({[e]:``});return}let t=this.multiple?[]:[...this.picked];this.picked=this.multiple?new Set([...this.picked,e]):new Set([e]),this.emitChange({...Object.fromEntries(t.map(e=>[e,``])),[e]:i})}},E={manifest:p,element:T,messages:C};export{E as hotspotElement};
154
- //# sourceMappingURL=hotspot-oel1Eelo.js.map
154
+ //# sourceMappingURL=hotspot-B3bvqVzf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hotspot-oel1Eelo.js","names":["en","pl","w","LitElement","live","nothing","ifDefined","b","i$1","w","A","FLAG_SELECTED","AstlElement","i","readRegion","boundsOf","centreOf","areaOf","en_default","hotspotManifest","pl_default","l","blockStyles","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","hotspotUiMessages","shapeOf","region","box","aspect","w$1","h","points","x","y","HotspotElement","id","known","next","value","answers","ui","multiple","areas","el","name","lower","a","layer","area","loaded","#renderRegion","#renderMarker","checked","verdict","solution","label","describedBy","index","#solutionMark","ref","place","#toggle","event","before","old","hotspotElement"],"sources":["../../../../components/src/hotspot/ui-messages.ts","../../../../components/src/hotspot/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.hotspot';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `hotspotMessages` would put the authoring strings into the element's chunk.\n */\nexport const hotspotUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import {\n type Answers,\n type ComponentManifest,\n FLAG_SELECTED,\n type MessageCatalog,\n type Units,\n} from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type SVGTemplateResult,\n svg,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { blockStyles } from '../block-styles.js';\nimport { areaOf, boundsOf, centreOf, type Region, readRegion } from '../picture.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, styles } from '../picture-view.js';\nimport { hotspotManifest } from './manifest.js';\nimport { hotspotUiMessages } from './ui-messages.js';\n\ninterface Area {\n readonly el: HTMLElement;\n readonly index: number;\n readonly region: Region;\n}\n\n/**\n * An area's shape in its own box: a rectangle fills it, a circle's box is square (so the circle stays round), a\n * polygon's points are placed in its bounding box.\n */\nfunction shapeOf({ region }: Area, aspect: number): SVGTemplateResult {\n if (region.shape === 'rect') return svg`<rect class=\"shape\" width=\"100\" height=\"100\"></rect>`;\n if (region.shape === 'circle')\n return svg`<ellipse class=\"shape\" cx=\"50\" cy=\"50\" rx=\"50\" ry=\"50\"></ellipse>`;\n const box = boundsOf(region, aspect);\n const w = Math.max(box.right - box.left, 1e-6);\n const h = Math.max(box.bottom - box.top, 1e-6);\n const points = region.points.map(([x, y]) => `${((x - box.left) / w) * 100},${((y - box.top) / h) * 100}`);\n return svg`<polygon class=\"shape\" points=${points.join(' ')}></polygon>`;\n}\n\n/**\n * `<astl-hotspot>`: the picture with an invisible native radio button (single) or checkbox (`multiple`) over each\n * area, so the browser gives the keyboard behaviour: Tab to the areas, Space picks; in a radio group the arrow keys\n * pick the next one. Picking a picked area again undoes it, with a radio too. A tap or a click on an area does the\n * same. A picked area gets a marker at its centre; areas are invisible otherwise (outlined under the pointer with\n * `outline`). Larger areas lie lower, so a small area inside a large one stays on top. Slots: one flag per area.\n */\nexport class HotspotElement extends AstlElement {\n static override manifest: ComponentManifest = hotspotManifest;\n static override messages: readonly MessageCatalog[] = hotspotUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n picked: { state: true },\n loaded: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The picture between the task and the group verdict line, which the fieldset's gap spaces.\n css`\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .group-verdict {\n margin-block: 0;\n }\n `,\n // An area's box takes the pointer on its shape only (the SVG shape), so a press next to a circle or a polygon\n // reaches the area below; no double-tap zoom on it, so a tap picks at once. A circle's box is square in pixels:\n // its radius is a share of the picture's width.\n css`\n .region {\n pointer-events: none;\n }\n .region[data-shape='circle'] {\n inline-size: calc(2 * var(--r));\n block-size: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n translate: 0 -50%;\n }\n .region svg {\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n overflow: visible;\n }\n .shape {\n fill: transparent;\n stroke: transparent;\n stroke-width: calc(2 * var(--astl-outline-width));\n vector-effect: non-scaling-stroke;\n pointer-events: all;\n cursor: pointer;\n touch-action: manipulation;\n }\n .region[data-locked] .shape {\n cursor: default;\n }\n :host([outline]) .region:not([data-locked]) .shape:hover,\n .region:has(:focus-visible) .shape {\n stroke: var(--astl-accent);\n }\n .region[data-solution] .shape {\n stroke: var(--astl-success);\n stroke-width: var(--astl-focus-width);\n }\n .region[data-solution]:not([data-picked]) .shape {\n stroke-dasharray: 2 4;\n stroke-linecap: round;\n }\n .region[data-solution] svg {\n filter: drop-shadow(0 0 1px var(--astl-surface)) drop-shadow(0 0 1px var(--astl-surface));\n }\n `,\n // A marker at a picked area's centre: a ring with a dot (a shape, never colour alone), or the verdict icon in a\n // ring of the verdict's colour and style. A right place left unpicked (missed) looks apart from a found one: its\n // outline dotted (above) and an empty ring, no tick; its own word (missed) is read. Neither takes the pointer: a\n // press goes to the area below. Both have a halo of the surface colour, so they show on light and dark pictures.\n css`\n .marker,\n .mark {\n --size: 1.75rem;\n box-sizing: border-box;\n display: grid;\n place-items: center;\n inline-size: var(--size);\n block-size: var(--size);\n border: var(--astl-focus-width) solid var(--astl-selected);\n border-radius: 50%;\n background: var(--astl-surface);\n color: var(--astl-selected);\n pointer-events: none;\n z-index: 100;\n }\n .dot {\n inline-size: 0.6rem;\n block-size: 0.6rem;\n border-radius: 50%;\n background: currentColor;\n }\n .marker[data-verdict] {\n background: var(--astl-verdict-soft);\n }\n .marker .astl-verdict-icon,\n .mark .astl-verdict-icon {\n inline-size: 1rem;\n block-size: 1rem;\n }\n .mark {\n border-color: var(--astl-success);\n background: transparent;\n }\n .marker,\n .mark {\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n }\n @media (forced-colors: active) {\n .shape {\n stroke: transparent;\n }\n :host([outline]) .region:not([data-locked]) .shape:hover,\n .region:has(:focus-visible) .shape,\n .region[data-solution] .shape {\n stroke: Highlight;\n }\n .dot {\n background: CanvasText;\n }\n }\n `,\n pictureStyles,\n blockStyles,\n ];\n\n /** Picked area ids. */\n declare protected picked: ReadonlySet<string>;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n\n constructor() {\n super();\n this.picked = new Set();\n this.loaded = null;\n }\n\n get multiple(): boolean {\n return this.booleanAttribute('multiple');\n }\n\n /** `<astl-hotspot-region>` children, in view order (reading order of their centres). */\n get regions(): readonly HTMLElement[] {\n return this.childElements('astl-hotspot-region');\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.regions.map((region) => region.id);\n }\n\n getAnswers(): Answers {\n return this.id === '' ? {} : Object.fromEntries([...this.picked].map((id) => [id, FLAG_SELECTED]));\n }\n\n /** Flags other than \"true\" clear an area; with one right place, a picked area replaces the one before. */\n setAnswers(answers: Answers): void {\n const known = new Set(this.regions.map((region) => region.id));\n let next = new Set(this.picked);\n for (const [id, value] of Object.entries(answers)) {\n if (!known.has(id)) continue;\n if (value !== FLAG_SELECTED) next.delete(id);\n else if (this.multiple) next.add(id);\n else next = new Set([id]);\n }\n this.picked = next;\n }\n\n units(): Units {\n return { answered: this.picked.size > 0 ? 1 : 0, total: 1 };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const multiple = this.multiple;\n const aspect = aspectOf(this, this.loaded);\n const areas: Area[] = this.regions.map((el, index) => ({\n el,\n index,\n region: readRegion((name) => el.getAttribute(name)),\n }));\n // Larger areas lie lower, so a small area inside a large one stays on top and can be picked.\n const lower = [...areas].sort((a, b) => areaOf(b.region, aspect) - areaOf(a.region, aspect));\n const layer = new Map(lower.map((area, i) => [area.el.id, i + 1]));\n return html`<fieldset part=\"hotspot\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t(multiple ? 'ui.multiple' : 'ui.single')}</bdi></span>\n </legend>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n ${renderPicture(\n this,\n aspect,\n (loaded) => {\n this.loaded = loaded;\n },\n [\n ...areas.map((area) => this.#renderRegion(area, aspect, layer.get(area.el.id) ?? 0)),\n ...areas.map((area) => this.#renderMarker(area)),\n ],\n {\n role: multiple ? 'group' : 'radiogroup',\n label: this.getAttribute('alt') ?? '',\n describedBy: this.disabled ? undefined : 'instructions',\n },\n )}\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n /** Whether the solution marks an area: a right place left unpicked (a picked one has its marker). */\n #solutionMark(id: string): boolean {\n return this.solution?.[id] === FLAG_SELECTED && !this.picked.has(id);\n }\n\n #renderRegion(area: Area, aspect: number, layer: number): TemplateResult {\n const { el, index, region } = area;\n const id = el.id;\n const checked = this.picked.has(id);\n const verdict = checked ? this.slotVerdict(id) : null;\n const solution = this.solution?.[id] === FLAG_SELECTED;\n const label = el.getAttribute('label')?.trim() ?? '';\n const describedBy = [\n verdict === null ? '' : `verdict-${index}`,\n this.#solutionMark(id) ? `solution-${index}` : '',\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const box = boundsOf(region, aspect);\n const place =\n region.shape === 'circle'\n ? percent({ x: region.x - region.r, y: region.y, r: region.r })\n : percent({ x: box.left, y: box.top, w: box.right - box.left, h: box.bottom - box.top });\n return html`<div\n class=\"region box astl-ring\"\n part=\"region\"\n data-region=${id}\n data-shape=${region.shape}\n ?data-picked=${checked}\n ?data-solution=${solution}\n ?data-locked=${this.disabled}\n ${styles({ ...place, 'z-index': String(layer) })}\n @click=${() => this.#toggle(id)}\n >\n <input\n class=\"astl-vh\"\n type=${this.multiple ? 'checkbox' : 'radio'}\n name=\"hotspot\"\n value=${id}\n .checked=${live(checked)}\n ?disabled=${this.disabled}\n aria-label=${label || this.t('ui.area', { n: index + 1 })}\n lang=${label === '' ? this.uiLanguage.lang : nothing}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n @click=${(event: MouseEvent) => {\n event.stopPropagation();\n this.#toggle(id);\n }}\n @change=${(event: Event) => {\n // An arrow key in a radio group checks the next radio; a click is not promised for it.\n if ((event.target as HTMLInputElement).checked && !this.picked.has(id)) this.#toggle(id);\n }}\n @keyup=${(event: KeyboardEvent) => {\n // Space on a checked radio does nothing natively: here it undoes the pick, as on a checkbox. Prevented, so\n // the browser does not click the radio it finds unchecked by then.\n if (event.key !== ' ' || this.multiple || !checked) return;\n event.preventDefault();\n this.#toggle(id);\n }}\n />\n <svg viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\" aria-hidden=\"true\" focusable=\"false\">\n ${shapeOf(area, aspect)}\n </svg>\n </div>`;\n }\n\n #renderMarker({ el, index, region }: Area): TemplateResult | typeof nothing {\n const id = el.id;\n const [x, y] = centreOf(region);\n if (this.picked.has(id)) {\n const verdict = this.slotVerdict(id);\n return html`<span\n class=\"marker point astl-box\"\n part=\"marker\"\n data-marker=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ${styles(percent({ x, y }))}\n >${\n verdict === null\n ? html`<span class=\"dot\"></span>`\n : this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${index}` })\n }</span\n >`;\n }\n if (!this.#solutionMark(id)) return nothing;\n const ui = this.uiLanguage;\n return html`<span class=\"mark point\" part=\"solution\" data-mark=${id} ${styles(percent({ x, y }))}\n ><span class=\"astl-vh\" id=\"solution-${index}\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.solution')}, ${this.t('ui.missed')}</span\n ></span\n >`;\n }\n\n /** Picks area `id`, or undoes its pick; with one right place, a new pick replaces the one before. */\n #toggle(id: string): void {\n if (this.disabled) return;\n if (this.picked.has(id)) {\n const next = new Set(this.picked);\n next.delete(id);\n this.picked = next;\n this.emitChange({ [id]: '' });\n return;\n }\n const before = this.multiple ? [] : [...this.picked];\n this.picked = this.multiple ? new Set([...this.picked, id]) : new Set([id]);\n this.emitChange({ ...Object.fromEntries(before.map((old) => [old, ''])), [id]: FLAG_SELECTED });\n }\n}\n\nexport const hotspotElement: ElementRegistration = {\n manifest: hotspotManifest,\n element: HotspotElement,\n messages: hotspotUiMessages,\n};\n"],"mappings":"A,6XAIA,IAAM4B,EAAY,eAMLC,EAA+C,CAC1D,CAAE,YAAW,OAAQ,KAAM,SAAU7B,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECwBA,SAAS6B,EAAQ,CAAE,UAAgB,EAAmC,CACpE,GAAIC,EAAO,QAAU,OAAQ,MAAO,EAAG,uDACvC,GAAIA,EAAO,QAAU,SACnB,MAAO,EAAG,oEACZ,IAAMC,EAAMjB,EAASgB,EAAQE,CAAM,EAC7B/B,EAAI,KAAK,IAAI8B,EAAI,MAAQA,EAAI,KAAM,IAAI,EACvCG,EAAI,KAAK,IAAIH,EAAI,OAASA,EAAI,IAAK,IAAI,EACvCI,EAASL,EAAO,OAAO,KAAK,CAACM,EAAGC,KAAO,IAAKD,EAAIL,EAAI,MAAQ9B,EAAK,IAAI,IAAKoC,EAAIN,EAAI,KAAOG,EAAK,KAAK,EACzG,MAAO,EAAG,iCAAiCC,EAAO,KAAK,GAAG,EAAE,YAC9D,CASA,IAAaG,EAAb,cAAoC3B,CAAY,CAC9C,OAAgB,SAA8BO,EAC9C,OAAgB,SAAsCU,EACtD,OAAgB,kBAAoC,CAClD,GAAG1B,EAAW,kBACd,eAAgB,QACl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G,KAAK,OAAQ5B,CAAE,CAAC,EAAI,IAAI,IAAI,CAACA,CAAE,CAAC,EAC1E,KAAK,WAAW,CAAE,GAAG,OAAO,YAAY4B,EAAO,IAAK,GAAQ,CAACC,EAAK,EAAE,CAAC,CAAC,GAAI7B,GAAK7B,CAAc,CAAC,CAChG,CACF,EAEa2D,EAAsC,CACjD,SAAUnD,EACV,QAASoB,EACT,SAAUV,CACZ,E"}
1
+ {"version":3,"file":"hotspot-B3bvqVzf.js","names":["en","pl","w","LitElement","live","nothing","ifDefined","b","i$1","w","A","FLAG_SELECTED","AstlElement","i","readRegion","boundsOf","centreOf","areaOf","en_default","hotspotManifest","pl_default","l","blockStyles","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","hotspotUiMessages","shapeOf","region","box","aspect","w$1","h","points","x","y","HotspotElement","id","known","next","value","answers","ui","multiple","areas","el","name","lower","a","layer","area","loaded","#renderRegion","#renderMarker","checked","verdict","solution","label","describedBy","index","#solutionMark","ref","place","#toggle","event","before","old","hotspotElement"],"sources":["../../../../components/src/hotspot/ui-messages.ts","../../../../components/src/hotspot/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.hotspot';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `hotspotMessages` would put the authoring strings into the element's chunk.\n */\nexport const hotspotUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import {\n type Answers,\n type ComponentManifest,\n FLAG_SELECTED,\n type MessageCatalog,\n type Units,\n} from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type SVGTemplateResult,\n svg,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { blockStyles } from '../block-styles.js';\nimport { areaOf, boundsOf, centreOf, type Region, readRegion } from '../picture.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, styles } from '../picture-view.js';\nimport { hotspotManifest } from './manifest.js';\nimport { hotspotUiMessages } from './ui-messages.js';\n\ninterface Area {\n readonly el: HTMLElement;\n readonly index: number;\n readonly region: Region;\n}\n\n/**\n * An area's shape in its own box: a rectangle fills it, a circle's box is square (so the circle stays round), a\n * polygon's points are placed in its bounding box.\n */\nfunction shapeOf({ region }: Area, aspect: number): SVGTemplateResult {\n if (region.shape === 'rect') return svg`<rect class=\"shape\" width=\"100\" height=\"100\"></rect>`;\n if (region.shape === 'circle')\n return svg`<ellipse class=\"shape\" cx=\"50\" cy=\"50\" rx=\"50\" ry=\"50\"></ellipse>`;\n const box = boundsOf(region, aspect);\n const w = Math.max(box.right - box.left, 1e-6);\n const h = Math.max(box.bottom - box.top, 1e-6);\n const points = region.points.map(([x, y]) => `${((x - box.left) / w) * 100},${((y - box.top) / h) * 100}`);\n return svg`<polygon class=\"shape\" points=${points.join(' ')}></polygon>`;\n}\n\n/**\n * `<astl-hotspot>`: the picture with an invisible native radio button (single) or checkbox (`multiple`) over each\n * area, so the browser gives the keyboard behaviour: Tab to the areas, Space picks; in a radio group the arrow keys\n * pick the next one. Picking a picked area again undoes it, with a radio too. A tap or a click on an area does the\n * same. A picked area gets a marker at its centre; areas are invisible otherwise (outlined under the pointer with\n * `outline`). Larger areas lie lower, so a small area inside a large one stays on top. Slots: one flag per area.\n */\nexport class HotspotElement extends AstlElement {\n static override manifest: ComponentManifest = hotspotManifest;\n static override messages: readonly MessageCatalog[] = hotspotUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n picked: { state: true },\n loaded: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The picture between the task and the group verdict line, which the fieldset's gap spaces.\n css`\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .group-verdict {\n margin-block: 0;\n }\n `,\n // An area's box takes the pointer on its shape only (the SVG shape), so a press next to a circle or a polygon\n // reaches the area below; no double-tap zoom on it, so a tap picks at once. A circle's box is square in pixels:\n // its radius is a share of the picture's width.\n css`\n .region {\n pointer-events: none;\n }\n .region[data-shape='circle'] {\n inline-size: calc(2 * var(--r));\n block-size: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n translate: 0 -50%;\n }\n .region svg {\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n overflow: visible;\n }\n .shape {\n fill: transparent;\n stroke: transparent;\n stroke-width: calc(2 * var(--astl-outline-width));\n vector-effect: non-scaling-stroke;\n pointer-events: all;\n cursor: pointer;\n touch-action: manipulation;\n }\n .region[data-locked] .shape {\n cursor: default;\n }\n :host([outline]) .region:not([data-locked]) .shape:hover,\n .region:has(:focus-visible) .shape {\n stroke: var(--astl-accent);\n }\n .region[data-solution] .shape {\n stroke: var(--astl-success);\n stroke-width: var(--astl-focus-width);\n }\n .region[data-solution]:not([data-picked]) .shape {\n stroke-dasharray: 2 4;\n stroke-linecap: round;\n }\n .region[data-solution] svg {\n filter: drop-shadow(0 0 1px var(--astl-surface)) drop-shadow(0 0 1px var(--astl-surface));\n }\n `,\n // A marker at a picked area's centre: a ring with a dot (a shape, never colour alone), or the verdict icon in a\n // ring of the verdict's colour and style. A right place left unpicked (missed) looks apart from a found one: its\n // outline dotted (above) and an empty ring, no tick; its own word (missed) is read. Neither takes the pointer: a\n // press goes to the area below. Both have a halo of the surface colour, so they show on light and dark pictures.\n css`\n .marker,\n .mark {\n --size: 1.75rem;\n box-sizing: border-box;\n display: grid;\n place-items: center;\n inline-size: var(--size);\n block-size: var(--size);\n border: var(--astl-focus-width) solid var(--astl-selected);\n border-radius: 50%;\n background: var(--astl-surface);\n color: var(--astl-selected);\n pointer-events: none;\n z-index: 100;\n }\n .dot {\n inline-size: 0.6rem;\n block-size: 0.6rem;\n border-radius: 50%;\n background: currentColor;\n }\n .marker[data-verdict] {\n background: var(--astl-verdict-soft);\n }\n .marker .astl-verdict-icon,\n .mark .astl-verdict-icon {\n inline-size: 1rem;\n block-size: 1rem;\n }\n .mark {\n border-color: var(--astl-success);\n background: transparent;\n }\n .marker,\n .mark {\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n }\n @media (forced-colors: active) {\n .shape {\n stroke: transparent;\n }\n :host([outline]) .region:not([data-locked]) .shape:hover,\n .region:has(:focus-visible) .shape,\n .region[data-solution] .shape {\n stroke: Highlight;\n }\n .dot {\n background: CanvasText;\n }\n }\n `,\n pictureStyles,\n blockStyles,\n ];\n\n /** Picked area ids. */\n declare protected picked: ReadonlySet<string>;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n\n constructor() {\n super();\n this.picked = new Set();\n this.loaded = null;\n }\n\n get multiple(): boolean {\n return this.booleanAttribute('multiple');\n }\n\n /** `<astl-hotspot-region>` children, in view order (reading order of their centres). */\n get regions(): readonly HTMLElement[] {\n return this.childElements('astl-hotspot-region');\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.regions.map((region) => region.id);\n }\n\n getAnswers(): Answers {\n return this.id === '' ? {} : Object.fromEntries([...this.picked].map((id) => [id, FLAG_SELECTED]));\n }\n\n /** Flags other than \"true\" clear an area; with one right place, a picked area replaces the one before. */\n setAnswers(answers: Answers): void {\n const known = new Set(this.regions.map((region) => region.id));\n let next = new Set(this.picked);\n for (const [id, value] of Object.entries(answers)) {\n if (!known.has(id)) continue;\n if (value !== FLAG_SELECTED) next.delete(id);\n else if (this.multiple) next.add(id);\n else next = new Set([id]);\n }\n this.picked = next;\n }\n\n units(): Units {\n return { answered: this.picked.size > 0 ? 1 : 0, total: 1 };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const multiple = this.multiple;\n const aspect = aspectOf(this, this.loaded);\n const areas: Area[] = this.regions.map((el, index) => ({\n el,\n index,\n region: readRegion((name) => el.getAttribute(name)),\n }));\n // Larger areas lie lower, so a small area inside a large one stays on top and can be picked.\n const lower = [...areas].sort((a, b) => areaOf(b.region, aspect) - areaOf(a.region, aspect));\n const layer = new Map(lower.map((area, i) => [area.el.id, i + 1]));\n return html`<fieldset part=\"hotspot\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t(multiple ? 'ui.multiple' : 'ui.single')}</bdi></span>\n </legend>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n ${renderPicture(\n this,\n aspect,\n (loaded) => {\n this.loaded = loaded;\n },\n [\n ...areas.map((area) => this.#renderRegion(area, aspect, layer.get(area.el.id) ?? 0)),\n ...areas.map((area) => this.#renderMarker(area)),\n ],\n {\n role: multiple ? 'group' : 'radiogroup',\n label: this.getAttribute('alt') ?? '',\n describedBy: this.disabled ? undefined : 'instructions',\n },\n )}\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n /** Whether the solution marks an area: a right place left unpicked (a picked one has its marker). */\n #solutionMark(id: string): boolean {\n return this.solution?.[id] === FLAG_SELECTED && !this.picked.has(id);\n }\n\n #renderRegion(area: Area, aspect: number, layer: number): TemplateResult {\n const { el, index, region } = area;\n const id = el.id;\n const checked = this.picked.has(id);\n const verdict = checked ? this.slotVerdict(id) : null;\n const solution = this.solution?.[id] === FLAG_SELECTED;\n const label = el.getAttribute('label')?.trim() ?? '';\n const describedBy = [\n verdict === null ? '' : `verdict-${index}`,\n this.#solutionMark(id) ? `solution-${index}` : '',\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const box = boundsOf(region, aspect);\n const place =\n region.shape === 'circle'\n ? percent({ x: region.x - region.r, y: region.y, r: region.r })\n : percent({ x: box.left, y: box.top, w: box.right - box.left, h: box.bottom - box.top });\n return html`<div\n class=\"region box astl-ring\"\n part=\"region\"\n data-region=${id}\n data-shape=${region.shape}\n ?data-picked=${checked}\n ?data-solution=${solution}\n ?data-locked=${this.disabled}\n ${styles({ ...place, 'z-index': String(layer) })}\n @click=${() => this.#toggle(id)}\n >\n <input\n class=\"astl-vh\"\n type=${this.multiple ? 'checkbox' : 'radio'}\n name=\"hotspot\"\n value=${id}\n .checked=${live(checked)}\n ?disabled=${this.disabled}\n aria-label=${label || this.t('ui.area', { n: index + 1 })}\n lang=${label === '' ? this.uiLanguage.lang : nothing}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n @click=${(event: MouseEvent) => {\n event.stopPropagation();\n this.#toggle(id);\n }}\n @change=${(event: Event) => {\n // An arrow key in a radio group checks the next radio; a click is not promised for it.\n if ((event.target as HTMLInputElement).checked && !this.picked.has(id)) this.#toggle(id);\n }}\n @keyup=${(event: KeyboardEvent) => {\n // Space on a checked radio does nothing natively: here it undoes the pick, as on a checkbox. Prevented, so\n // the browser does not click the radio it finds unchecked by then.\n if (event.key !== ' ' || this.multiple || !checked) return;\n event.preventDefault();\n this.#toggle(id);\n }}\n />\n <svg viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\" aria-hidden=\"true\" focusable=\"false\">\n ${shapeOf(area, aspect)}\n </svg>\n </div>`;\n }\n\n #renderMarker({ el, index, region }: Area): TemplateResult | typeof nothing {\n const id = el.id;\n const [x, y] = centreOf(region);\n if (this.picked.has(id)) {\n const verdict = this.slotVerdict(id);\n return html`<span\n class=\"marker point astl-box\"\n part=\"marker\"\n data-marker=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ${styles(percent({ x, y }))}\n >${\n verdict === null\n ? html`<span class=\"dot\"></span>`\n : this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${index}` })\n }</span\n >`;\n }\n if (!this.#solutionMark(id)) return nothing;\n const ui = this.uiLanguage;\n return html`<span class=\"mark point\" part=\"solution\" data-mark=${id} ${styles(percent({ x, y }))}\n ><span class=\"astl-vh\" id=\"solution-${index}\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.solution')}, ${this.t('ui.missed')}</span\n ></span\n >`;\n }\n\n /** Picks area `id`, or undoes its pick; with one right place, a new pick replaces the one before. */\n #toggle(id: string): void {\n if (this.disabled) return;\n if (this.picked.has(id)) {\n const next = new Set(this.picked);\n next.delete(id);\n this.picked = next;\n this.emitChange({ [id]: '' });\n return;\n }\n const before = this.multiple ? [] : [...this.picked];\n this.picked = this.multiple ? new Set([...this.picked, id]) : new Set([id]);\n this.emitChange({ ...Object.fromEntries(before.map((old) => [old, ''])), [id]: FLAG_SELECTED });\n }\n}\n\nexport const hotspotElement: ElementRegistration = {\n manifest: hotspotManifest,\n element: HotspotElement,\n messages: hotspotUiMessages,\n};\n"],"mappings":"A,6XAIA,IAAM4B,EAAY,eAMLC,EAA+C,CAC1D,CAAE,YAAW,OAAQ,KAAM,SAAU7B,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECwBA,SAAS6B,EAAQ,CAAE,UAAgB,EAAmC,CACpE,GAAIC,EAAO,QAAU,OAAQ,MAAO,EAAG,uDACvC,GAAIA,EAAO,QAAU,SACnB,MAAO,EAAG,oEACZ,IAAMC,EAAMjB,EAASgB,EAAQE,CAAM,EAC7B/B,EAAI,KAAK,IAAI8B,EAAI,MAAQA,EAAI,KAAM,IAAI,EACvCG,EAAI,KAAK,IAAIH,EAAI,OAASA,EAAI,IAAK,IAAI,EACvCI,EAASL,EAAO,OAAO,KAAK,CAACM,EAAGC,KAAO,IAAKD,EAAIL,EAAI,MAAQ9B,EAAK,IAAI,IAAKoC,EAAIN,EAAI,KAAOG,EAAK,KAAK,EACzG,MAAO,EAAG,iCAAiCC,EAAO,KAAK,GAAG,EAAE,YAC9D,CASA,IAAaG,EAAb,cAAoC3B,CAAY,CAC9C,OAAgB,SAA8BO,EAC9C,OAAgB,SAA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KAAK,MAAM,EACnD,KAAK,OAAS,KAAK,SAAW,IAAI,IAAI,CAAC,GAAG,KAAK,OAAQ5B,CAAE,CAAC,EAAI,IAAI,IAAI,CAACA,CAAE,CAAC,EAC1E,KAAK,WAAW,CAAE,GAAG,OAAO,YAAY4B,EAAO,IAAK,GAAQ,CAACC,EAAK,EAAE,CAAC,CAAC,GAAI7B,GAAK7B,CAAc,CAAC,CAChG,CACF,EAEa2D,EAAsC,CACjD,SAAUnD,EACV,QAASoB,EACT,SAAUV,CACZ,E"}
@@ -1,4 +1,4 @@
1
- import{C as e,D as t,E as n,T as r,b as i,h as a,n as o,v as s,y as c}from"./runtime-DxAbpr3S.js";import{i as l,r as u}from"./picture-D10YRMYH.js";import{n as d,r as f,t as p}from"./image-drop-manifest-BZ6hCoAd.js";import{t as m}from"./pick-and-place-DVQIPYuL.js";import{t as h}from"./block-styles-CKo9x7Vt.js";import{t as g}from"./repeat-CY2W2URZ.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./picture-view-BKnAyScQ.js";var C=`astl.image-drop`,w=[{namespace:C,locale:`en`,messages:d},{namespace:C,locale:`pl`,messages:p}],T=``,E=250,D=r`<path d="M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`,O=e=>{let t=e?.cloneNode(!0);for(let e of t?.querySelectorAll(`img`)??[])e.replaceWith(` ${e.alt} `);return(t?.textContent??``).replace(/\s+/g,` `).trim()},k=class extends o{static manifest=f;static messages=w;static shadowRootOptions={...c.shadowRootOptions,slotAssignment:`manual`};static properties={placed:{state:!0},loaded:{state:!0},compact:{state:!0}};static styles=[n`
1
+ import{C as e,D as t,E as n,T as r,b as i,h as a,n as o,v as s,y as c}from"./runtime-C25QK5B0.js";import{i as l,r as u}from"./picture-D10YRMYH.js";import{n as d,r as f,t as p}from"./image-drop-manifest-BZ6hCoAd.js";import{t as m}from"./pick-and-place-DVQIPYuL.js";import{t as h}from"./block-styles-CCtSFM4j.js";import{t as g}from"./repeat-BDXokpxQ.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./picture-view-Deodu_mb.js";var C=`astl.image-drop`,w=[{namespace:C,locale:`en`,messages:d},{namespace:C,locale:`pl`,messages:p}],T=``,E=250,D=r`<path d="M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`,O=e=>{let t=e?.cloneNode(!0);for(let e of t?.querySelectorAll(`img`)??[])e.replaceWith(` ${e.alt} `);return(t?.textContent??``).replace(/\s+/g,` `).trim()},k=class extends o{static manifest=f;static messages=w;static shadowRootOptions={...c.shadowRootOptions,slotAssignment:`manual`};static properties={placed:{state:!0},loaded:{state:!0},compact:{state:!0}};static styles=[n`
2
2
  fieldset {
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -292,4 +292,4 @@ outline: var(--astl-outline-width) solid CanvasText;
292
292
  <bdi lang=${s(g===``?void 0:g)}>${O(m)}</bdi>
293
293
  </p>`}
294
294
  </div>`}updated(){let e=this.#t;if(e===null)return;this.#t=null;let t=this.#l(e)?`button[data-zone="${CSS.escape(e)}"]`:`button[data-label="${CSS.escape(e)}"]`;this.renderRoot.querySelector(t)?.focus()}#l(e){return this.zones.some(t=>t.id===e)}#u(e){for(let[t,n]of this.placed)if(n===e)return t;return null}#d(e){return this.labels.find(t=>t.id===e)}#f(e,t=this.zones.indexOf(e)){let n=e?.getAttribute(`label`)?.trim()??``;return n===``?this.t(`ui.zone`,{n:t+1}):this.t(`ui.zoneNamed`,{n:t+1,name:n})}#p(e,t=this.zones.indexOf(e)){let n=e?.getAttribute(`label`)?.trim()??``,r=this.placed.get(e?.id??``),i=t+1;if(r===void 0)return this.t(n===``?`ui.zoneEmpty`:`ui.zoneEmptyNamed`,{n:i,name:n});let a=O(this.#d(r));return this.t(n===``?`ui.zoneHolds`:`ui.zoneHoldsNamed`,{n:i,label:a,name:n})}#m(e,t){let n=this.#r;if(!n.tap(t)||this.disabled)return;let r=n.picked,i=this.placed.get(e);if(r!==null&&!this.#l(r))n.put(e);else if(r===null&&i!==void 0){let t=new Map(this.placed);t.delete(e),this.placed=t,this.emitChange({[e]:``}),this.announce(this.t(`ui.announce.back`,{label:O(this.#d(i))}))}else n.click(t,e)}#h(e,t,n){let r=this.#u(e),i=this.labels.filter(e=>this.#u(e.id)===null).map(e=>e.id),a=this.renderRoot.activeElement!==null,o=new Map(this.placed),s={};r!==null&&(o.delete(r),s[r]=``);let c=t===T?void 0:o.get(t);if(this.#n=c!==void 0&&c!==e?c:null,t!==T&&(o.set(t,e),s[t]=e),this.placed=o,this.emitChange(s),a&&n&&r===null&&t!==T){let n=i.indexOf(e);this.#t=i[n+1]??i[n-1]??t}}#g(e,t,n){let r=e=>this.#f(this.zones.find(t=>t.id===e)),i=e=>O(this.#d(e)),a=e=>this.#p(this.zones.find(t=>t.id===e)),o=(e,t)=>{let n=this.#n;return n===null?this.t(`ui.announce.put`,{label:i(e),zone:r(t),placed:this.placed.size,total:this.zones.length}):this.t(`ui.announce.swap`,{label:i(e),zone:r(t),old:i(n)})};if(this.#l(t)){if(e===`pick`)return this.t(`ui.announce.wait`,{zone:r(t)});if(e===`cancel`)return this.t(`ui.announce.stayEmpty`,{zone:r(t)});if(e===`put`)return o(n,t);if(n===t)return a(t);let s=this.#u(n);return s===null?this.t(`ui.announce.label`,{label:i(n)}):this.t(`ui.announce.labelOn`,{label:i(n),zone:r(s)})}return e===`pick`?this.t(`ui.announce.pick`,{label:i(t)}):e===`cancel`?this.t(`ui.announce.cancel`,{label:i(t)}):e===`target`?n===T?this.t(`ui.announce.tray`):a(n):n===T?this.t(`ui.announce.back`,{label:i(t)}):o(t,n)}#_(e){let t=this.#r.picked;if(t===null||this.#l(t)||this.disabled)return;let n=e.composedPath(),r=n.slice(0,n.indexOf(e.currentTarget));if(r.some(e=>e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement))return;let i=r.find(e=>e instanceof HTMLElement&&e.dataset.zone!==void 0);i!==void 0&&this.#r.put(i.dataset.zone??T)}#v(e,t){for(let n of this.renderRoot.elementsFromPoint(e,t)){let e=n instanceof HTMLElement?n.closest(`[data-zone]`):null;if(e!==null&&this.renderRoot.contains(e))return e.dataset.zone??null}return null}},A={manifest:f,element:k,messages:w};export{A as imageDropElement};
295
- //# sourceMappingURL=image-drop-Dkprw0Kn.js.map
295
+ //# sourceMappingURL=image-drop-vLc2B7rF.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-drop-Dkprw0Kn.js","names":["en","pl","LitElement","unsafeCSS","repeat","nothing","ifDefined","b","r","i$1","w","A","verdictIcon","AstlElement","o","i","readRegion","centreOf","en_default","imageDropManifest","pl_default","PickAndPlace","blockStyles","c","renderSlide","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","imageDropUiMessages","TRAY","LONG_PRESS","MOVE_ICON","textOf","copy","el","img","ImageDropElement","#isZone","item","label","zone","#zoneOf","#zoneAt","x","y","#place","to","#message","moment","#observer","#small","compact","focused","#focusAfter","width","height","region","name","zones","labels","next","answers","other","held","#pick","ui","pick","tray","aspect","waiting","tapped","#onAreaClick","#renderLabel","loaded","#renderFrame","#renderZone","#renderSpot","id","event","target","marked","verdict","correct","mark","#label","describedBy","ref","content","holdsTarget","#holds","#activate","focus","selector","n","picked","from","l","changes","old","#swapped","follow","at","zoneName","#zoneName","labelText","holds","z","put","swapped","on","path","inside","node","imageDropElement"],"sources":["../../../../components/src/image-drop/ui-messages.ts","../../../../components/src/image-drop/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.image-drop';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `imageDropMessages` would put the authoring strings into the element's chunk.\n */\nexport const imageDropUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, verdictIcon } from '@astl/player';\nimport { PickAndPlace, type PickMoment } from '@astl/player/interaction';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n svg,\n type TemplateResult,\n unsafeCSS,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { centreOf, readRegion } from '../picture.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, renderSlide, styles } from '../picture-view.js';\nimport { imageDropManifest } from './manifest.js';\nimport { imageDropUiMessages } from './ui-messages.js';\n\n/** Where a label is when no zone holds it, as a destination: back in the tray. */\nconst TRAY = '';\n\n/** A touch held this long (ms) without moving starts a drag; a touch that moves sooner scrolls, a short one taps. */\nconst LONG_PRESS = 250;\n\n/** The minimum target, px (`--astl-target-min`): a zone's chip is at least two wide and one high. */\nconst TARGET = 44;\n\n/** Marks the picked label next to its other cues (lift, fill, `aria-pressed`): four arrows, \"this label moves\". */\nconst MOVE_ICON = svg`<path d=\"M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\n\n/** What a label says: its text, each picture by its alt text, as a screen reader reads it. */\nconst textOf = (el: Element | undefined): string => {\n const copy = el?.cloneNode(true) as Element | undefined;\n for (const img of copy?.querySelectorAll('img') ?? []) img.replaceWith(` ${img.alt} `);\n return (copy?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n};\n\n/**\n * `<astl-image-drop>`: a tray of labels and a picture with numbered zones, each zone a native button at its centre.\n * Labels are native toggle buttons (`aria-pressed` while picked). Ways to put a label on a zone, all announced:\n * - a label, then a zone: Space or Enter on the label, then the arrow keys to a zone and Enter (or Tab to the zone and\n * Enter); a tap on the label, then on the zone; or a drag onto the zone (with touch, after a long press);\n * - a zone, then a label: Enter on an empty zone makes it wait, the arrow keys choose a label and Enter puts it there.\n * A press on a filled zone sends its label back to the tray; a label put on a filled zone sends the old one back; a\n * placed label can be dragged on to another zone or back. Slots: one per zone, answered with the label's id. Zone\n * frames take palette colours by position; the light-DOM labels are slotted manually and never moved or changed.\n */\nexport class ImageDropElement extends AstlElement {\n static override manifest: ComponentManifest = imageDropManifest;\n static override messages: readonly MessageCatalog[] = imageDropUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n placed: { state: true },\n loaded: { state: true },\n compact: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The tray, the picture and the group verdict line in a column whose gaps space them.\n css`\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .group-verdict {\n margin-block: 0;\n }\n .tray {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-l);\n background: var(--astl-canvas);\n touch-action: manipulation;\n }\n .tray-label {\n font-size: var(--astl-size-ui);\n font-weight: 600;\n }\n .note {\n margin: 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n }\n .labels {\n display: flex;\n flex-wrap: wrap;\n gap: var(--astl-space-2);\n }\n `,\n // A chip (a label, or a zone's button) carries the border and the ring; its button is the target. Touches scroll\n // and zoom as usual on a chip (a long press drags, see LONG_PRESS).\n css`\n .chip {\n position: relative;\n display: inline-flex;\n align-items: center;\n max-inline-size: 100%;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface-raised);\n color: var(--astl-ink);\n transition:\n translate var(--astl-duration-fast),\n box-shadow var(--astl-duration-fast);\n }\n .chip:has(button:hover:not(:disabled)) {\n background: var(--astl-accent-soft);\n }\n .chip button {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--astl-space-2);\n max-inline-size: 100%;\n min-inline-size: var(--astl-target-min);\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-2);\n border: 0;\n border-radius: inherit;\n background: transparent;\n color: inherit;\n font: inherit;\n line-height: 1.3;\n text-align: start;\n overflow-wrap: anywhere;\n cursor: grab;\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n }\n .chip button:disabled {\n cursor: default;\n }\n .chip:not([data-verdict]):has(button:disabled) {\n border-color: var(--astl-line);\n }\n .move {\n flex: none;\n inline-size: 1.1em;\n block-size: 1.1em;\n color: var(--astl-selected);\n }\n `,\n // Picked (a label, or a zone waiting for one): lifted with a solid shadow edge and the theme's selection fill; in\n // hc also bold text (selected-* tokens). Never by colour alone, never like a verdict border. Where Enter or a drop\n // would put it: a doubled edge, which forced colours keep. A dragged chip takes no pointer events, so what is\n // under it counts.\n css`\n .chip[data-picked] {\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n box-shadow: 0 var(--astl-space-1) 0 0 var(--astl-selected);\n translate: 0 calc(-1 * var(--astl-space-1));\n font-weight: var(--astl-selected-weight);\n }\n [data-target],\n [data-over] {\n border-color: var(--astl-accent);\n outline: var(--astl-outline-width) solid var(--astl-accent);\n outline-offset: calc(-2 * var(--astl-outline-width));\n }\n .chip[data-target],\n .tray[data-target],\n .tray[data-over] {\n background: var(--astl-accent-soft);\n }\n .chip[data-dragging] {\n z-index: 200;\n box-shadow: 0 var(--astl-space-1) 0 0 var(--astl-outline);\n transition: none;\n pointer-events: none;\n }\n .chip[data-dragging] button {\n cursor: grabbing;\n }\n fieldset[data-picking] :is(.frame, .tray) {\n cursor: pointer;\n }\n @media (prefers-reduced-motion: reduce) {\n .chip {\n transition: none;\n }\n }\n `,\n // A zone: its frame on the picture in its palette colour, with a halo of the surface colour on both sides so it\n // shows on light and dark pictures in every theme, and no fill (a dark theme's fill would muddy the picture); its\n // button over its centre, kept inside the picture, with the zone's number and the label it holds. A frame holding\n // a label leaves the edge to the label's chip (two edges would read as the double border of a partial verdict).\n // Compact (a zone smaller than a chip, see #small): the frame shows the zone's number, and the buttons stand in a\n // numbered list under the picture, as the fields of astl-image-label do; there an empty zone is as wide as an empty\n // drop in running text past its number (5em), so it reads as a place to fill, not as a bare number.\n css`\n .frame {\n box-sizing: border-box;\n display: grid;\n place-items: center;\n border: calc(2 * var(--astl-outline-width)) solid var(--astl-group);\n border-radius: var(--astl-radius-s);\n box-shadow:\n 0 0 0 var(--astl-outline-width) var(--astl-surface),\n inset 0 0 0 var(--astl-outline-width) var(--astl-surface);\n touch-action: manipulation;\n }\n .frame[data-held] {\n border-color: transparent;\n box-shadow: none;\n }\n .zones {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .zones .spot {\n align-items: flex-start;\n }\n .zones .zone {\n min-inline-size: min(100%, calc(1.5rem + 5em + 2 * var(--astl-space-2)));\n }\n .zones .zone > button {\n flex: 1;\n }\n .slide .astl-solution {\n padding-inline: var(--astl-space-1);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n }\n .frame[data-target],\n .frame[data-over] {\n background: color-mix(in srgb, var(--astl-accent-soft) 60%, transparent);\n }\n .frame > .number {\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n }\n .spot {\n z-index: 100;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--astl-space-1);\n }\n .zone {\n border: calc(2 * var(--astl-outline-width)) solid var(--astl-group);\n background: var(--astl-surface);\n }\n .number {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n min-inline-size: 1.5rem;\n block-size: 1.5rem;\n border-radius: 999px;\n background: var(--astl-group);\n color: var(--astl-surface);\n font-weight: 700;\n forced-color-adjust: none;\n }\n .zone > .astl-verdict {\n padding-inline-end: var(--astl-space-2);\n }\n\n @media (forced-colors: active) {\n .frame {\n border-color: CanvasText;\n background: none;\n }\n .number {\n background: Canvas;\n color: CanvasText;\n outline: var(--astl-outline-width) solid CanvasText;\n }\n }\n `,\n // Palette slots of the zones, through an attribute: a strict Content Security Policy blocks inline styles.\n unsafeCSS(\n Array.from(\n { length: 8 },\n (_, i) =>\n `[data-palette='${i + 1}']{--astl-group:var(--astl-palette-${i + 1});--astl-group-soft:var(--astl-palette-${i + 1}-soft)}`,\n ).join(''),\n ),\n pictureStyles,\n blockStyles,\n ];\n\n /** Zone id to the id of the label on it. */\n declare protected placed: ReadonlyMap<string, string>;\n /** A zone is smaller than a chip: the buttons stand in a list under the picture (see #small). */\n declare protected compact: boolean;\n #observer: ResizeObserver | null = null;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n /** What to focus after the next render: a label that took a moved one's place in the tray, or a zone. */\n #focusAfter: string | null = null;\n /** The label a put sent back to the tray, for its announcement. */\n #swapped: string | null = null;\n readonly #pick: PickAndPlace<string> = new PickAndPlace<string>(this, {\n // A label goes back to the tray or onto a zone; a waiting zone takes one of the labels.\n destinations: (item) =>\n this.#isZone(item)\n ? [item, ...this.labels.map((label) => label.id)]\n : [TRAY, ...this.zones.map((zone) => zone.id)],\n current: (item) => (this.#isZone(item) ? item : (this.#zoneOf(item) ?? TRAY)),\n at: (x, y) => this.#zoneAt(x, y),\n commit: (item, to) => (this.#isZone(item) ? this.#place(to, item, false) : this.#place(item, to, true)),\n say: (moment, item, to) => this.#message(moment, item, to),\n wrap: true,\n box: '.chip',\n hold: LONG_PRESS,\n });\n\n constructor() {\n super();\n this.placed = new Map();\n this.loaded = null;\n this.compact = false;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // A new width (or a first one: an element rendered on a hidden page has none) may make a zone smaller or larger\n // than a chip.\n this.#observer ??= new ResizeObserver(() => {\n if (this.#small() !== this.compact) this.requestUpdate();\n });\n this.#observer.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#observer?.disconnect();\n }\n\n protected override willUpdate(): void {\n const compact = this.#small();\n if (compact === this.compact) return;\n // The zone buttons move between the picture and the list: the one with the focus keeps it.\n const focused = (this.renderRoot as ShadowRoot).activeElement;\n if (focused instanceof HTMLElement)\n this.#focusAfter ??= focused.dataset.zone ?? focused.dataset.label ?? null;\n this.compact = compact;\n }\n\n /**\n * Whether a zone is smaller than a chip (two targets wide, one high, for the zone's number and a label): its chip\n * would cover the picture around it and the next zone, so the buttons go to a list under the picture. Decided\n * before rendering, from the element's width (the picture's) and the zones in percent, so it never flips after a\n * render (a flip would replace the buttons under the keyboard).\n */\n #small(): boolean {\n // With the solution every zone may carry a line: they stand in the list, where each fits beside its zone.\n if (this.solution !== null) return true;\n const width = this.clientWidth;\n if (width === 0) return this.compact;\n const height = width / aspectOf(this, this.loaded);\n return this.zones.some((zone) => {\n const region = readRegion((name) => zone.getAttribute(name));\n return (width * region.width) / 100 < 2 * TARGET || (height * region.height) / 100 < TARGET + 8;\n });\n }\n\n get zones(): readonly HTMLElement[] {\n return this.childElements('astl-image-drop-zone');\n }\n\n /** The labels in rendered order: view order, or shuffled per attempt with a seed. */\n get labels(): readonly HTMLElement[] {\n return this.shuffled(this.childElements('astl-image-drop-label'));\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.zones.map((zone) => zone.id);\n }\n\n getAnswers(): Answers {\n return this.id === '' ? {} : Object.fromEntries(this.placed);\n }\n\n /** '' empties a zone; a label sits on one zone, so a later zone takes it from an earlier one. */\n setAnswers(answers: Answers): void {\n const zones = new Set(this.zones.map((zone) => zone.id));\n const labels = new Set(this.labels.map((label) => label.id));\n const next = new Map(this.placed);\n for (const [zone, label] of Object.entries(answers)) {\n if (!zones.has(zone)) continue;\n next.delete(zone);\n // An unknown label cannot be shown: the zone stays empty, as the player sends it.\n if (!labels.has(label)) continue;\n for (const [other, held] of next) if (held === label) next.delete(other);\n next.set(zone, label);\n }\n this.placed = next;\n this.#pick.reset();\n }\n\n units(): Units {\n return { answered: this.placed.size, total: this.zones.length };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const pick = this.#pick;\n const tray = this.labels.filter((label) => this.#zoneOf(label.id) === null);\n const aspect = aspectOf(this, this.loaded);\n const zones = this.zones;\n // Where Enter would put the picked label (a zone waiting for a label targets labels instead).\n const waiting = pick.picked !== null && this.#isZone(pick.picked);\n const tapped = (zone: string) => pick.picked !== null && !waiting && pick.target === zone;\n return html`<fieldset part=\"image-drop\" ?data-picking=${pick.picked !== null} @click=${this.#onAreaClick}>\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t('ui.hint')}</bdi></span>\n </legend>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n <div\n class=\"tray\"\n part=\"tray\"\n role=\"group\"\n aria-labelledby=\"tray\"\n data-zone=${TRAY}\n ?data-target=${tapped(TRAY)}\n ?data-over=${pick.dragging !== null && pick.over === TRAY}\n >\n <span class=\"tray-label\" id=\"tray\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.tray')}</span>\n ${\n tray.length === 0\n ? html`<p class=\"note\"><span lang=${ui.lang} dir=${ui.dir}>${this.t('ui.allPlaced')}</span></p>`\n : html`<div class=\"labels\">\n ${repeat(\n tray,\n (label) => label.id,\n (label) => this.#renderLabel(label.id),\n )}\n </div>`\n }\n </div>\n ${renderPicture(\n this,\n aspect,\n (loaded) => {\n this.loaded = loaded;\n },\n [\n ...zones.map((zone, i) => this.#renderFrame(zone, i, tapped(zone.id))),\n ...(this.compact ? [] : zones.map((zone, i) => this.#renderZone(zone, i, tapped(zone.id)))),\n ],\n { role: 'group', label: this.getAttribute('alt') ?? '' },\n )}\n ${\n this.compact\n ? html`<ol class=\"zones\" part=\"zones\">\n ${zones.map((zone, i) => html`<li>${this.#renderSpot(zone, i, tapped(zone.id))}</li>`)}\n </ol>`\n : nothing\n }\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n #renderLabel(id: string): TemplateResult {\n const pick = this.#pick;\n const waiting = pick.picked !== null && this.#isZone(pick.picked);\n return html`<span\n class=\"chip astl-ring\"\n part=\"label\"\n data-label=${id}\n ?data-picked=${pick.picked === id}\n ?data-target=${waiting && pick.target === id}\n ?data-dragging=${pick.dragging === id}\n >\n <button\n type=\"button\"\n data-label=${id}\n aria-pressed=${pick.picked === id ? 'true' : 'false'}\n aria-describedby=${this.disabled ? nothing : 'instructions'}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => pick.click(event, id, waiting ? id : undefined)}\n @keydown=${(event: KeyboardEvent) => pick.keydown(event, id)}\n @pointerdown=${(event: PointerEvent) => pick.pointerdown(event, id)}\n @touchmove=${pick.touchmove}\n >\n ${\n pick.picked === id\n ? html`<svg class=\"move\" viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">${MOVE_ICON}</svg>`\n : nothing\n }<slot data-label=${id}></slot>\n </button>\n </span>`;\n }\n\n #renderFrame(zone: HTMLElement, i: number, target: boolean): TemplateResult {\n const region = readRegion((name) => zone.getAttribute(name));\n const pick = this.#pick;\n return html`<div\n class=\"frame box\"\n part=\"zone\"\n data-zone=${zone.id}\n data-palette=${(i % 8) + 1}\n ?data-target=${target}\n ?data-over=${pick.dragging !== null && pick.over === zone.id}\n ?data-held=${!this.compact && this.placed.has(zone.id)}\n ${styles(percent({ x: region.x, y: region.y, w: region.width, h: region.height }))}\n >${this.compact ? html`<span class=\"number\" aria-hidden=\"true\">${i + 1}</span>` : nothing}</div>`;\n }\n\n /** A zone's button over its centre on the picture, kept inside the picture. */\n #renderZone(zone: HTMLElement, i: number, target: boolean): TemplateResult {\n const [x, y] = centreOf(readRegion((name) => zone.getAttribute(name)));\n return renderSlide(x, y, this.#renderSpot(zone, i, target));\n }\n\n /** A zone's button (its number and the label it holds) and its solution line. */\n #renderSpot(zone: HTMLElement, i: number, target: boolean): TemplateResult {\n const ui = this.uiLanguage;\n const pick = this.#pick;\n const id = zone.id;\n const label = this.placed.get(id);\n // Where zones are marked one by one, an empty one shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict = label === undefined ? (marked ? 'empty' : null) : this.slotVerdict(id);\n const correct = this.solution?.[id];\n // One clear indicator: a zone with its right label needs no solution mark.\n const mark = correct !== undefined && correct !== label ? this.#label(correct) : undefined;\n const describedBy = [\n this.disabled ? '' : 'instructions',\n verdict === null ? '' : `verdict-${i}`,\n mark === undefined ? '' : `solution-${i}`,\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const content = this.contentLang;\n // A zone waiting for a label may target the label this one holds.\n const holdsTarget =\n label !== undefined && pick.picked !== null && this.#isZone(pick.picked) && pick.target === label;\n return html`<div class=\"spot\" data-zone=${id} data-palette=${(i % 8) + 1}>\n <span\n class=\"chip zone astl-box astl-ring\"\n data-zone=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ?data-picked=${pick.picked === id}\n ?data-target=${target || holdsTarget || (pick.dragging !== null && pick.over === id)}\n ?data-dragging=${label !== undefined && pick.dragging === label}\n >\n <button\n type=\"button\"\n part=\"drop\"\n data-zone=${id}\n aria-pressed=${pick.picked === id ? 'true' : 'false'}\n aria-label=${this.#holds(zone, i)}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => this.#activate(id, event)}\n @keydown=${(event: KeyboardEvent) => pick.keydown(event, id)}\n @pointerdown=${(event: PointerEvent) => label !== undefined && pick.pointerdown(event, label)}\n @touchmove=${pick.touchmove}\n >\n <span class=\"number\" aria-hidden=\"true\">${i + 1}</span>\n ${label === undefined ? nothing : html`<slot data-label=${label}></slot>`}\n </button>\n ${this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${i}` })}\n </span>\n ${\n mark === undefined\n ? nothing\n : // A UI sentence around a content text: it reads in the UI's direction, the label keeps its language.\n html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${i}\" data-label=${mark.id} lang=${ui.lang} dir=${ui.dir}>\n ${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution')}</span>\n <bdi lang=${ifDefined(content === '' ? undefined : content)}>${textOf(mark)}</bdi>\n </p>`\n }\n </div>`;\n }\n\n protected override updated(): void {\n const focus = this.#focusAfter;\n if (focus === null) return;\n this.#focusAfter = null;\n const selector = this.#isZone(focus)\n ? `button[data-zone=\"${CSS.escape(focus)}\"]`\n : `button[data-label=\"${CSS.escape(focus)}\"]`;\n this.renderRoot.querySelector<HTMLElement>(selector)?.focus();\n }\n\n // Moving labels\n\n #isZone(id: string): boolean {\n return this.zones.some((zone) => zone.id === id);\n }\n\n /** The zone a label is on, or null in the tray. */\n #zoneOf(label: string): string | null {\n for (const [zone, held] of this.placed) if (held === label) return zone;\n return null;\n }\n\n #label(id: string): HTMLElement | undefined {\n return this.labels.find((label) => label.id === id);\n }\n\n /** A zone's name: its number, and its label when it has one. */\n #zoneName(zone: HTMLElement | undefined, i = this.zones.indexOf(zone as HTMLElement)): string {\n const name = zone?.getAttribute('label')?.trim() ?? '';\n return name === '' ? this.t('ui.zone', { n: i + 1 }) : this.t('ui.zoneNamed', { n: i + 1, name });\n }\n\n /**\n * A zone's button name: its number and what it holds (as the button shows them, so speech input can say what it\n * sees), then its label.\n */\n #holds(zone: HTMLElement | undefined, i = this.zones.indexOf(zone as HTMLElement)): string {\n const name = zone?.getAttribute('label')?.trim() ?? '';\n const held = this.placed.get(zone?.id ?? '');\n const n = i + 1;\n if (held === undefined) return this.t(name === '' ? 'ui.zoneEmpty' : 'ui.zoneEmptyNamed', { n, name });\n const label = textOf(this.#label(held));\n return this.t(name === '' ? 'ui.zoneHolds' : 'ui.zoneHoldsNamed', { n, label, name });\n }\n\n /** A press on a zone's button: put the picked label here; else send its label back, or wait for one. */\n #activate(zone: string, event: MouseEvent): void {\n const pick = this.#pick;\n if (!pick.tap(event) || this.disabled) return;\n const picked = pick.picked;\n const held = this.placed.get(zone);\n if (picked !== null && !this.#isZone(picked)) pick.put(zone);\n else if (picked === null && held !== undefined) {\n const next = new Map(this.placed);\n next.delete(zone);\n this.placed = next;\n this.emitChange({ [zone]: '' });\n this.announce(this.t('ui.announce.back', { label: textOf(this.#label(held)) }));\n } else pick.click(event, zone);\n }\n\n /**\n * Puts `label` on `zone` (or back in the tray), off the zone it was on; a label already there goes back to the tray.\n * `follow`: a label put from the tray hands the focus to the label that takes its place there (else to the zone).\n */\n #place(label: string, zone: string, follow: boolean): void {\n const from = this.#zoneOf(label);\n const tray = this.labels.filter((l) => this.#zoneOf(l.id) === null).map((l) => l.id);\n const focused = (this.renderRoot as ShadowRoot).activeElement !== null;\n const next = new Map(this.placed);\n const changes: Record<string, string> = {};\n if (from !== null) {\n next.delete(from);\n changes[from] = '';\n }\n const old = zone === TRAY ? undefined : next.get(zone);\n this.#swapped = old !== undefined && old !== label ? old : null;\n if (zone !== TRAY) {\n next.set(zone, label);\n changes[zone] = label;\n }\n this.placed = next;\n this.emitChange(changes);\n if (focused && follow && from === null && zone !== TRAY) {\n const at = tray.indexOf(label);\n this.#focusAfter = tray[at + 1] ?? tray[at - 1] ?? zone;\n }\n }\n\n /** The announcement of a moment: of a label, or of a zone waiting for one. */\n #message(moment: PickMoment, item: string, to: string): string {\n const zoneName = (id: string) => this.#zoneName(this.zones.find((zone) => zone.id === id));\n const labelText = (id: string) => textOf(this.#label(id));\n const holds = (zone: string) => this.#holds(this.zones.find((z) => z.id === zone));\n const put = (label: string, zone: string) => {\n const swapped = this.#swapped;\n return swapped === null\n ? this.t('ui.announce.put', {\n label: labelText(label),\n zone: zoneName(zone),\n placed: this.placed.size,\n total: this.zones.length,\n })\n : this.t('ui.announce.swap', {\n label: labelText(label),\n zone: zoneName(zone),\n old: labelText(swapped),\n });\n };\n if (this.#isZone(item)) {\n if (moment === 'pick') return this.t('ui.announce.wait', { zone: zoneName(item) });\n if (moment === 'cancel') return this.t('ui.announce.stayEmpty', { zone: zoneName(item) });\n if (moment === 'put') return put(to, item);\n if (to === item) return holds(item);\n const on = this.#zoneOf(to);\n return on === null\n ? this.t('ui.announce.label', { label: labelText(to) })\n : this.t('ui.announce.labelOn', { label: labelText(to), zone: zoneName(on) });\n }\n if (moment === 'pick') return this.t('ui.announce.pick', { label: labelText(item) });\n if (moment === 'cancel') return this.t('ui.announce.cancel', { label: labelText(item) });\n if (moment === 'target') return to === TRAY ? this.t('ui.announce.tray') : holds(to);\n return to === TRAY ? this.t('ui.announce.back', { label: labelText(item) }) : put(item, to);\n }\n\n /** Taps on a zone's frame or on the tray (not on a button) put the picked label there. */\n #onAreaClick(event: MouseEvent): void {\n const picked = this.#pick.picked;\n if (picked === null || this.#isZone(picked) || this.disabled) return;\n // Only what is inside the task: an element of the host page may carry `data-zone` too.\n const path = event.composedPath();\n const inside = path.slice(0, path.indexOf(event.currentTarget as EventTarget));\n if (inside.some((node) => node instanceof HTMLButtonElement || node instanceof HTMLAnchorElement)) return;\n const zone = inside.find(\n (node): node is HTMLElement => node instanceof HTMLElement && node.dataset.zone !== undefined,\n );\n if (zone !== undefined) this.#pick.put(zone.dataset.zone ?? TRAY);\n }\n\n /** The zone (or the tray) under a dragged label: hit testing, so the top one counts. */\n #zoneAt(x: number, y: number): string | null {\n for (const el of (this.renderRoot as ShadowRoot).elementsFromPoint(x, y)) {\n const zone = el instanceof HTMLElement ? el.closest<HTMLElement>('[data-zone]') : null;\n if (zone !== null && this.renderRoot.contains(zone)) return zone.dataset.zone ?? null;\n }\n return null;\n }\n}\n\nexport const imageDropElement: ElementRegistration = {\n manifest: imageDropManifest,\n element: ImageDropElement,\n messages: imageDropUiMessages,\n};\n"],"mappings":"A,kbAIA,IAAM8B,EAAY,kBAMLC,EAAiD,CAC5D,CAAE,YAAW,OAAQ,KAAM,SAAU/B,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECUM+B,EAAO,GAGPC,EAAa,IAMbC,EAAY,CAAG,yPAGfC,EAAU,GAAoC,CAClD,IAAMC,EAAOC,GAAI,UAAU,EAAI,EAC/B,IAAK,IAAMC,KAAOF,GAAM,iBAAiB,KAAK,GAAK,CAAC,EAAGE,EAAI,YAAY,IAAIA,EAAI,IAAI,EAAE,EACrF,OAAQF,GAAM,aAAe,GAAA,CAAI,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,CAC7D,EAYaG,EAAb,cAAsC1B,CAAY,CAChD,OAAgB,SAA8BM,EAC9C,OAAgB,SAAsCY,EACtD,OAAgB,kBAAoC,CAClD,GAAG7B,EAAW,kBACd,eAAgB,QAClB,EAEA,OAAgB,WAAmC,CACjD,OAAQ,CAAE,MAAO,EAAK,EACtB,OAAQ,CAAE,MAAO,EAAK,EACtB,QAAS,CAAE,MAAO,EAAK,CACzB,EAGA,OAAgB,OAAyB,CAEvC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsFHC,EACE,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verdictIcon","AstlElement","o","i","readRegion","centreOf","en_default","imageDropManifest","pl_default","PickAndPlace","blockStyles","c","renderSlide","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","imageDropUiMessages","TRAY","LONG_PRESS","MOVE_ICON","textOf","copy","el","img","ImageDropElement","#isZone","item","label","zone","#zoneOf","#zoneAt","x","y","#place","to","#message","moment","#observer","#small","compact","focused","#focusAfter","width","height","region","name","zones","labels","next","answers","other","held","#pick","ui","pick","tray","aspect","waiting","tapped","#onAreaClick","#renderLabel","loaded","#renderFrame","#renderZone","#renderSpot","id","event","target","marked","verdict","correct","mark","#label","describedBy","ref","content","holdsTarget","#holds","#activate","focus","selector","n","picked","from","l","changes","old","#swapped","follow","at","zoneName","#zoneName","labelText","holds","z","put","swapped","on","path","inside","node","imageDropElement"],"sources":["../../../../components/src/image-drop/ui-messages.ts","../../../../components/src/image-drop/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.image-drop';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `imageDropMessages` would put the authoring strings into the element's chunk.\n */\nexport const imageDropUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, verdictIcon } from '@astl/player';\nimport { PickAndPlace, type PickMoment } from '@astl/player/interaction';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n svg,\n type TemplateResult,\n unsafeCSS,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { centreOf, readRegion } from '../picture.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, renderSlide, styles } from '../picture-view.js';\nimport { imageDropManifest } from './manifest.js';\nimport { imageDropUiMessages } from './ui-messages.js';\n\n/** Where a label is when no zone holds it, as a destination: back in the tray. */\nconst TRAY = '';\n\n/** A touch held this long (ms) without moving starts a drag; a touch that moves sooner scrolls, a short one taps. */\nconst LONG_PRESS = 250;\n\n/** The minimum target, px (`--astl-target-min`): a zone's chip is at least two wide and one high. */\nconst TARGET = 44;\n\n/** Marks the picked label next to its other cues (lift, fill, `aria-pressed`): four arrows, \"this label moves\". */\nconst MOVE_ICON = svg`<path d=\"M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\n\n/** What a label says: its text, each picture by its alt text, as a screen reader reads it. */\nconst textOf = (el: Element | undefined): string => {\n const copy = el?.cloneNode(true) as Element | undefined;\n for (const img of copy?.querySelectorAll('img') ?? []) img.replaceWith(` ${img.alt} `);\n return (copy?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n};\n\n/**\n * `<astl-image-drop>`: a tray of labels and a picture with numbered zones, each zone a native button at its centre.\n * Labels are native toggle buttons (`aria-pressed` while picked). Ways to put a label on a zone, all announced:\n * - a label, then a zone: Space or Enter on the label, then the arrow keys to a zone and Enter (or Tab to the zone and\n * Enter); a tap on the label, then on the zone; or a drag onto the zone (with touch, after a long press);\n * - a zone, then a label: Enter on an empty zone makes it wait, the arrow keys choose a label and Enter puts it there.\n * A press on a filled zone sends its label back to the tray; a label put on a filled zone sends the old one back; a\n * placed label can be dragged on to another zone or back. Slots: one per zone, answered with the label's id. Zone\n * frames take palette colours by position; the light-DOM labels are slotted manually and never moved or changed.\n */\nexport class ImageDropElement extends AstlElement {\n static override manifest: ComponentManifest = imageDropManifest;\n static override messages: readonly MessageCatalog[] = imageDropUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n placed: { state: true },\n loaded: { state: true },\n compact: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The tray, the picture and the group verdict line in a column whose gaps space them.\n css`\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .group-verdict {\n margin-block: 0;\n }\n .tray {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-l);\n background: var(--astl-canvas);\n touch-action: manipulation;\n }\n .tray-label {\n font-size: var(--astl-size-ui);\n font-weight: 600;\n }\n .note {\n margin: 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n }\n .labels {\n display: flex;\n flex-wrap: wrap;\n gap: var(--astl-space-2);\n }\n `,\n // A chip (a label, or a zone's button) carries the border and the ring; its button is the target. Touches scroll\n // and zoom as usual on a chip (a long press drags, see LONG_PRESS).\n css`\n .chip {\n position: relative;\n display: inline-flex;\n align-items: center;\n max-inline-size: 100%;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface-raised);\n color: var(--astl-ink);\n transition:\n translate var(--astl-duration-fast),\n box-shadow var(--astl-duration-fast);\n }\n .chip:has(button:hover:not(:disabled)) {\n background: var(--astl-accent-soft);\n }\n .chip button {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--astl-space-2);\n max-inline-size: 100%;\n min-inline-size: var(--astl-target-min);\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-2);\n border: 0;\n border-radius: inherit;\n background: transparent;\n color: inherit;\n font: inherit;\n line-height: 1.3;\n text-align: start;\n overflow-wrap: anywhere;\n cursor: grab;\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n }\n .chip button:disabled {\n cursor: default;\n }\n .chip:not([data-verdict]):has(button:disabled) {\n border-color: var(--astl-line);\n }\n .move {\n flex: none;\n inline-size: 1.1em;\n block-size: 1.1em;\n color: var(--astl-selected);\n }\n `,\n // Picked (a label, or a zone waiting for one): lifted with a solid shadow edge and the theme's selection fill; in\n // hc also bold text (selected-* tokens). Never by colour alone, never like a verdict border. Where Enter or a drop\n // would put it: a doubled edge, which forced colours keep. A dragged chip takes no pointer events, so what is\n // under it counts.\n css`\n .chip[data-picked] {\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n box-shadow: 0 var(--astl-space-1) 0 0 var(--astl-selected);\n translate: 0 calc(-1 * var(--astl-space-1));\n font-weight: var(--astl-selected-weight);\n }\n [data-target],\n [data-over] {\n border-color: var(--astl-accent);\n outline: var(--astl-outline-width) solid var(--astl-accent);\n outline-offset: calc(-2 * var(--astl-outline-width));\n }\n .chip[data-target],\n .tray[data-target],\n .tray[data-over] {\n background: var(--astl-accent-soft);\n }\n .chip[data-dragging] {\n z-index: 200;\n box-shadow: 0 var(--astl-space-1) 0 0 var(--astl-outline);\n transition: none;\n pointer-events: none;\n }\n .chip[data-dragging] button {\n cursor: grabbing;\n }\n fieldset[data-picking] :is(.frame, .tray) {\n cursor: pointer;\n }\n @media (prefers-reduced-motion: reduce) {\n .chip {\n transition: none;\n }\n }\n `,\n // A zone: its frame on the picture in its palette colour, with a halo of the surface colour on both sides so it\n // shows on light and dark pictures in every theme, and no fill (a dark theme's fill would muddy the picture); its\n // button over its centre, kept inside the picture, with the zone's number and the label it holds. A frame holding\n // a label leaves the edge to the label's chip (two edges would read as the double border of a partial verdict).\n // Compact (a zone smaller than a chip, see #small): the frame shows the zone's number, and the buttons stand in a\n // numbered list under the picture, as the fields of astl-image-label do; there an empty zone is as wide as an empty\n // drop in running text past its number (5em), so it reads as a place to fill, not as a bare number.\n css`\n .frame {\n box-sizing: border-box;\n display: grid;\n place-items: center;\n border: calc(2 * var(--astl-outline-width)) solid var(--astl-group);\n border-radius: var(--astl-radius-s);\n box-shadow:\n 0 0 0 var(--astl-outline-width) var(--astl-surface),\n inset 0 0 0 var(--astl-outline-width) var(--astl-surface);\n touch-action: manipulation;\n }\n .frame[data-held] {\n border-color: transparent;\n box-shadow: none;\n }\n .zones {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .zones .spot {\n align-items: flex-start;\n }\n .zones .zone {\n min-inline-size: min(100%, calc(1.5rem + 5em + 2 * var(--astl-space-2)));\n }\n .zones .zone > button {\n flex: 1;\n }\n .slide .astl-solution {\n padding-inline: var(--astl-space-1);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n }\n .frame[data-target],\n .frame[data-over] {\n background: color-mix(in srgb, var(--astl-accent-soft) 60%, transparent);\n }\n .frame > .number {\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n }\n .spot {\n z-index: 100;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--astl-space-1);\n }\n .zone {\n border: calc(2 * var(--astl-outline-width)) solid var(--astl-group);\n background: var(--astl-surface);\n }\n .number {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n min-inline-size: 1.5rem;\n block-size: 1.5rem;\n border-radius: 999px;\n background: var(--astl-group);\n color: var(--astl-surface);\n font-weight: 700;\n forced-color-adjust: none;\n }\n .zone > .astl-verdict {\n padding-inline-end: var(--astl-space-2);\n }\n\n @media (forced-colors: active) {\n .frame {\n border-color: CanvasText;\n background: none;\n }\n .number {\n background: Canvas;\n color: CanvasText;\n outline: var(--astl-outline-width) solid CanvasText;\n }\n }\n `,\n // Palette slots of the zones, through an attribute: a strict Content Security Policy blocks inline styles.\n unsafeCSS(\n Array.from(\n { length: 8 },\n (_, i) =>\n `[data-palette='${i + 1}']{--astl-group:var(--astl-palette-${i + 1});--astl-group-soft:var(--astl-palette-${i + 1}-soft)}`,\n ).join(''),\n ),\n pictureStyles,\n blockStyles,\n ];\n\n /** Zone id to the id of the label on it. */\n declare protected placed: ReadonlyMap<string, string>;\n /** A zone is smaller than a chip: the buttons stand in a list under the picture (see #small). */\n declare protected compact: boolean;\n #observer: ResizeObserver | null = null;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n /** What to focus after the next render: a label that took a moved one's place in the tray, or a zone. */\n #focusAfter: string | null = null;\n /** The label a put sent back to the tray, for its announcement. */\n #swapped: string | null = null;\n readonly #pick: PickAndPlace<string> = new PickAndPlace<string>(this, {\n // A label goes back to the tray or onto a zone; a waiting zone takes one of the labels.\n destinations: (item) =>\n this.#isZone(item)\n ? [item, ...this.labels.map((label) => label.id)]\n : [TRAY, ...this.zones.map((zone) => zone.id)],\n current: (item) => (this.#isZone(item) ? item : (this.#zoneOf(item) ?? TRAY)),\n at: (x, y) => this.#zoneAt(x, y),\n commit: (item, to) => (this.#isZone(item) ? this.#place(to, item, false) : this.#place(item, to, true)),\n say: (moment, item, to) => this.#message(moment, item, to),\n wrap: true,\n box: '.chip',\n hold: LONG_PRESS,\n });\n\n constructor() {\n super();\n this.placed = new Map();\n this.loaded = null;\n this.compact = false;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // A new width (or a first one: an element rendered on a hidden page has none) may make a zone smaller or larger\n // than a chip.\n this.#observer ??= new ResizeObserver(() => {\n if (this.#small() !== this.compact) this.requestUpdate();\n });\n this.#observer.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#observer?.disconnect();\n }\n\n protected override willUpdate(): void {\n const compact = this.#small();\n if (compact === this.compact) return;\n // The zone buttons move between the picture and the list: the one with the focus keeps it.\n const focused = (this.renderRoot as ShadowRoot).activeElement;\n if (focused instanceof HTMLElement)\n this.#focusAfter ??= focused.dataset.zone ?? focused.dataset.label ?? null;\n this.compact = compact;\n }\n\n /**\n * Whether a zone is smaller than a chip (two targets wide, one high, for the zone's number and a label): its chip\n * would cover the picture around it and the next zone, so the buttons go to a list under the picture. Decided\n * before rendering, from the element's width (the picture's) and the zones in percent, so it never flips after a\n * render (a flip would replace the buttons under the keyboard).\n */\n #small(): boolean {\n // With the solution every zone may carry a line: they stand in the list, where each fits beside its zone.\n if (this.solution !== null) return true;\n const width = this.clientWidth;\n if (width === 0) return this.compact;\n const height = width / aspectOf(this, this.loaded);\n return this.zones.some((zone) => {\n const region = readRegion((name) => zone.getAttribute(name));\n return (width * region.width) / 100 < 2 * TARGET || (height * region.height) / 100 < TARGET + 8;\n });\n }\n\n get zones(): readonly HTMLElement[] {\n return this.childElements('astl-image-drop-zone');\n }\n\n /** The labels in rendered order: view order, or shuffled per attempt with a seed. */\n get labels(): readonly HTMLElement[] {\n return this.shuffled(this.childElements('astl-image-drop-label'));\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.zones.map((zone) => zone.id);\n }\n\n getAnswers(): Answers {\n return this.id === '' ? {} : Object.fromEntries(this.placed);\n }\n\n /** '' empties a zone; a label sits on one zone, so a later zone takes it from an earlier one. */\n setAnswers(answers: Answers): void {\n const zones = new Set(this.zones.map((zone) => zone.id));\n const labels = new Set(this.labels.map((label) => label.id));\n const next = new Map(this.placed);\n for (const [zone, label] of Object.entries(answers)) {\n if (!zones.has(zone)) continue;\n next.delete(zone);\n // An unknown label cannot be shown: the zone stays empty, as the player sends it.\n if (!labels.has(label)) continue;\n for (const [other, held] of next) if (held === label) next.delete(other);\n next.set(zone, label);\n }\n this.placed = next;\n this.#pick.reset();\n }\n\n units(): Units {\n return { answered: this.placed.size, total: this.zones.length };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const pick = this.#pick;\n const tray = this.labels.filter((label) => this.#zoneOf(label.id) === null);\n const aspect = aspectOf(this, this.loaded);\n const zones = this.zones;\n // Where Enter would put the picked label (a zone waiting for a label targets labels instead).\n const waiting = pick.picked !== null && this.#isZone(pick.picked);\n const tapped = (zone: string) => pick.picked !== null && !waiting && pick.target === zone;\n return html`<fieldset part=\"image-drop\" ?data-picking=${pick.picked !== null} @click=${this.#onAreaClick}>\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t('ui.hint')}</bdi></span>\n </legend>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n <div\n class=\"tray\"\n part=\"tray\"\n role=\"group\"\n aria-labelledby=\"tray\"\n data-zone=${TRAY}\n ?data-target=${tapped(TRAY)}\n ?data-over=${pick.dragging !== null && pick.over === TRAY}\n >\n <span class=\"tray-label\" id=\"tray\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.tray')}</span>\n ${\n tray.length === 0\n ? html`<p class=\"note\"><span lang=${ui.lang} dir=${ui.dir}>${this.t('ui.allPlaced')}</span></p>`\n : html`<div class=\"labels\">\n ${repeat(\n tray,\n (label) => label.id,\n (label) => this.#renderLabel(label.id),\n )}\n </div>`\n }\n </div>\n ${renderPicture(\n this,\n aspect,\n (loaded) => {\n this.loaded = loaded;\n },\n [\n ...zones.map((zone, i) => this.#renderFrame(zone, i, tapped(zone.id))),\n ...(this.compact ? [] : zones.map((zone, i) => this.#renderZone(zone, i, tapped(zone.id)))),\n ],\n { role: 'group', label: this.getAttribute('alt') ?? '' },\n )}\n ${\n this.compact\n ? html`<ol class=\"zones\" part=\"zones\">\n ${zones.map((zone, i) => html`<li>${this.#renderSpot(zone, i, tapped(zone.id))}</li>`)}\n </ol>`\n : nothing\n }\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n #renderLabel(id: string): TemplateResult {\n const pick = this.#pick;\n const waiting = pick.picked !== null && this.#isZone(pick.picked);\n return html`<span\n class=\"chip astl-ring\"\n part=\"label\"\n data-label=${id}\n ?data-picked=${pick.picked === id}\n ?data-target=${waiting && pick.target === id}\n ?data-dragging=${pick.dragging === id}\n >\n <button\n type=\"button\"\n data-label=${id}\n aria-pressed=${pick.picked === id ? 'true' : 'false'}\n aria-describedby=${this.disabled ? nothing : 'instructions'}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => pick.click(event, id, waiting ? id : undefined)}\n @keydown=${(event: KeyboardEvent) => pick.keydown(event, id)}\n @pointerdown=${(event: PointerEvent) => pick.pointerdown(event, id)}\n @touchmove=${pick.touchmove}\n >\n ${\n pick.picked === id\n ? html`<svg class=\"move\" viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">${MOVE_ICON}</svg>`\n : nothing\n }<slot data-label=${id}></slot>\n </button>\n </span>`;\n }\n\n #renderFrame(zone: HTMLElement, i: number, target: boolean): TemplateResult {\n const region = readRegion((name) => zone.getAttribute(name));\n const pick = this.#pick;\n return html`<div\n class=\"frame box\"\n part=\"zone\"\n data-zone=${zone.id}\n data-palette=${(i % 8) + 1}\n ?data-target=${target}\n ?data-over=${pick.dragging !== null && pick.over === zone.id}\n ?data-held=${!this.compact && this.placed.has(zone.id)}\n ${styles(percent({ x: region.x, y: region.y, w: region.width, h: region.height }))}\n >${this.compact ? html`<span class=\"number\" aria-hidden=\"true\">${i + 1}</span>` : nothing}</div>`;\n }\n\n /** A zone's button over its centre on the picture, kept inside the picture. */\n #renderZone(zone: HTMLElement, i: number, target: boolean): TemplateResult {\n const [x, y] = centreOf(readRegion((name) => zone.getAttribute(name)));\n return renderSlide(x, y, this.#renderSpot(zone, i, target));\n }\n\n /** A zone's button (its number and the label it holds) and its solution line. */\n #renderSpot(zone: HTMLElement, i: number, target: boolean): TemplateResult {\n const ui = this.uiLanguage;\n const pick = this.#pick;\n const id = zone.id;\n const label = this.placed.get(id);\n // Where zones are marked one by one, an empty one shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict = label === undefined ? (marked ? 'empty' : null) : this.slotVerdict(id);\n const correct = this.solution?.[id];\n // One clear indicator: a zone with its right label needs no solution mark.\n const mark = correct !== undefined && correct !== label ? this.#label(correct) : undefined;\n const describedBy = [\n this.disabled ? '' : 'instructions',\n verdict === null ? '' : `verdict-${i}`,\n mark === undefined ? '' : `solution-${i}`,\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const content = this.contentLang;\n // A zone waiting for a label may target the label this one holds.\n const holdsTarget =\n label !== undefined && pick.picked !== null && this.#isZone(pick.picked) && pick.target === label;\n return html`<div class=\"spot\" data-zone=${id} data-palette=${(i % 8) + 1}>\n <span\n class=\"chip zone astl-box astl-ring\"\n data-zone=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ?data-picked=${pick.picked === id}\n ?data-target=${target || holdsTarget || (pick.dragging !== null && pick.over === id)}\n ?data-dragging=${label !== undefined && pick.dragging === label}\n >\n <button\n type=\"button\"\n part=\"drop\"\n data-zone=${id}\n aria-pressed=${pick.picked === id ? 'true' : 'false'}\n aria-label=${this.#holds(zone, i)}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => this.#activate(id, event)}\n @keydown=${(event: KeyboardEvent) => pick.keydown(event, id)}\n @pointerdown=${(event: PointerEvent) => label !== undefined && pick.pointerdown(event, label)}\n @touchmove=${pick.touchmove}\n >\n <span class=\"number\" aria-hidden=\"true\">${i + 1}</span>\n ${label === undefined ? nothing : html`<slot data-label=${label}></slot>`}\n </button>\n ${this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${i}` })}\n </span>\n ${\n mark === undefined\n ? nothing\n : // A UI sentence around a content text: it reads in the UI's direction, the label keeps its language.\n html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${i}\" data-label=${mark.id} lang=${ui.lang} dir=${ui.dir}>\n ${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution')}</span>\n <bdi lang=${ifDefined(content === '' ? undefined : content)}>${textOf(mark)}</bdi>\n </p>`\n }\n </div>`;\n }\n\n protected override updated(): void {\n const focus = this.#focusAfter;\n if (focus === null) return;\n this.#focusAfter = null;\n const selector = this.#isZone(focus)\n ? `button[data-zone=\"${CSS.escape(focus)}\"]`\n : `button[data-label=\"${CSS.escape(focus)}\"]`;\n this.renderRoot.querySelector<HTMLElement>(selector)?.focus();\n }\n\n // Moving labels\n\n #isZone(id: string): boolean {\n return this.zones.some((zone) => zone.id === id);\n }\n\n /** The zone a label is on, or null in the tray. */\n #zoneOf(label: string): string | null {\n for (const [zone, held] of this.placed) if (held === label) return zone;\n return null;\n }\n\n #label(id: string): HTMLElement | undefined {\n return this.labels.find((label) => label.id === id);\n }\n\n /** A zone's name: its number, and its label when it has one. */\n #zoneName(zone: HTMLElement | undefined, i = this.zones.indexOf(zone as HTMLElement)): string {\n const name = zone?.getAttribute('label')?.trim() ?? '';\n return name === '' ? this.t('ui.zone', { n: i + 1 }) : this.t('ui.zoneNamed', { n: i + 1, name });\n }\n\n /**\n * A zone's button name: its number and what it holds (as the button shows them, so speech input can say what it\n * sees), then its label.\n */\n #holds(zone: HTMLElement | undefined, i = this.zones.indexOf(zone as HTMLElement)): string {\n const name = zone?.getAttribute('label')?.trim() ?? '';\n const held = this.placed.get(zone?.id ?? '');\n const n = i + 1;\n if (held === undefined) return this.t(name === '' ? 'ui.zoneEmpty' : 'ui.zoneEmptyNamed', { n, name });\n const label = textOf(this.#label(held));\n return this.t(name === '' ? 'ui.zoneHolds' : 'ui.zoneHoldsNamed', { n, label, name });\n }\n\n /** A press on a zone's button: put the picked label here; else send its label back, or wait for one. */\n #activate(zone: string, event: MouseEvent): void {\n const pick = this.#pick;\n if (!pick.tap(event) || this.disabled) return;\n const picked = pick.picked;\n const held = this.placed.get(zone);\n if (picked !== null && !this.#isZone(picked)) pick.put(zone);\n else if (picked === null && held !== undefined) {\n const next = new Map(this.placed);\n next.delete(zone);\n this.placed = next;\n this.emitChange({ [zone]: '' });\n this.announce(this.t('ui.announce.back', { label: textOf(this.#label(held)) }));\n } else pick.click(event, zone);\n }\n\n /**\n * Puts `label` on `zone` (or back in the tray), off the zone it was on; a label already there goes back to the tray.\n * `follow`: a label put from the tray hands the focus to the label that takes its place there (else to the zone).\n */\n #place(label: string, zone: string, follow: boolean): void {\n const from = this.#zoneOf(label);\n const tray = this.labels.filter((l) => this.#zoneOf(l.id) === null).map((l) => l.id);\n const focused = (this.renderRoot as ShadowRoot).activeElement !== null;\n const next = new Map(this.placed);\n const changes: Record<string, string> = {};\n if (from !== null) {\n next.delete(from);\n changes[from] = '';\n }\n const old = zone === TRAY ? undefined : next.get(zone);\n this.#swapped = old !== undefined && old !== label ? old : null;\n if (zone !== TRAY) {\n next.set(zone, label);\n changes[zone] = label;\n }\n this.placed = next;\n this.emitChange(changes);\n if (focused && follow && from === null && zone !== TRAY) {\n const at = tray.indexOf(label);\n this.#focusAfter = tray[at + 1] ?? tray[at - 1] ?? zone;\n }\n }\n\n /** The announcement of a moment: of a label, or of a zone waiting for one. */\n #message(moment: PickMoment, item: string, to: string): string {\n const zoneName = (id: string) => this.#zoneName(this.zones.find((zone) => zone.id === id));\n const labelText = (id: string) => textOf(this.#label(id));\n const holds = (zone: string) => this.#holds(this.zones.find((z) => z.id === zone));\n const put = (label: string, zone: string) => {\n const swapped = this.#swapped;\n return swapped === null\n ? this.t('ui.announce.put', {\n label: labelText(label),\n zone: zoneName(zone),\n placed: this.placed.size,\n total: this.zones.length,\n })\n : this.t('ui.announce.swap', {\n label: labelText(label),\n zone: zoneName(zone),\n old: labelText(swapped),\n });\n };\n if (this.#isZone(item)) {\n if (moment === 'pick') return this.t('ui.announce.wait', { zone: zoneName(item) });\n if (moment === 'cancel') return this.t('ui.announce.stayEmpty', { zone: zoneName(item) });\n if (moment === 'put') return put(to, item);\n if (to === item) return holds(item);\n const on = this.#zoneOf(to);\n return on === null\n ? this.t('ui.announce.label', { label: labelText(to) })\n : this.t('ui.announce.labelOn', { label: labelText(to), zone: zoneName(on) });\n }\n if (moment === 'pick') return this.t('ui.announce.pick', { label: labelText(item) });\n if (moment === 'cancel') return this.t('ui.announce.cancel', { label: labelText(item) });\n if (moment === 'target') return to === TRAY ? this.t('ui.announce.tray') : holds(to);\n return to === TRAY ? this.t('ui.announce.back', { label: labelText(item) }) : put(item, to);\n }\n\n /** Taps on a zone's frame or on the tray (not on a button) put the picked label there. */\n #onAreaClick(event: MouseEvent): void {\n const picked = this.#pick.picked;\n if (picked === null || this.#isZone(picked) || this.disabled) return;\n // Only what is inside the task: an element of the host page may carry `data-zone` too.\n const path = event.composedPath();\n const inside = path.slice(0, path.indexOf(event.currentTarget as EventTarget));\n if (inside.some((node) => node instanceof HTMLButtonElement || node instanceof HTMLAnchorElement)) return;\n const zone = inside.find(\n (node): node is HTMLElement => node instanceof HTMLElement && node.dataset.zone !== undefined,\n );\n if (zone !== undefined) this.#pick.put(zone.dataset.zone ?? TRAY);\n }\n\n /** The zone (or the tray) under a dragged label: hit testing, so the top one counts. */\n #zoneAt(x: number, y: number): string | null {\n for (const el of (this.renderRoot as ShadowRoot).elementsFromPoint(x, y)) {\n const zone = el instanceof HTMLElement ? el.closest<HTMLElement>('[data-zone]') : null;\n if (zone !== null && this.renderRoot.contains(zone)) return zone.dataset.zone ?? null;\n }\n return null;\n }\n}\n\nexport const imageDropElement: ElementRegistration = {\n manifest: imageDropManifest,\n element: ImageDropElement,\n messages: imageDropUiMessages,\n};\n"],"mappings":"A,kbAIA,IAAM8B,EAAY,kBAMLC,EAAiD,CAC5D,CAAE,YAAW,OAAQ,KAAM,SAAU/B,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECUM+B,EAAO,GAGPC,EAAa,IAMbC,EAAY,CAAG,yPAGfC,EAAU,GAAoC,CAClD,IAAMC,EAAOC,GAAI,UAAU,EAAI,EAC/B,IAAK,IAAMC,KAAOF,GAAM,iBAAiB,KAAK,GAAK,CAAC,EAAGE,EAAI,YAAY,IAAIA,EAAI,IAAI,EAAE,EACrF,OAAQF,GAAM,aAAe,GAAA,CAAI,QAAQ,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,mBAAqBA,aAAgB,iBAAiB,EAAG,OACnG,IAAMxE,EAAOuE,EAAO,KACjB,GAA8BC,aAAgB,aAAeA,EAAK,QAAQ,OAAS,IAAA,EACtF,EACIxE,IAAS,IAAA,IAAW,KAAKwB,GAAM,IAAIxB,EAAK,QAAQ,MAAQX,CAAI,CAClE,CAGA,GAAQ,EAAW,EAA0B,CAC3C,IAAK,IAAMK,KAAO,KAAK,WAA0B,kBAAkBS,EAAGC,CAAC,EAAG,CACxE,IAAMJ,EAAON,aAAc,YAAcA,EAAG,QAAqB,aAAa,EAAI,KAClF,GAAIM,IAAS,MAAQ,KAAK,WAAW,SAASA,CAAI,EAAG,OAAOA,EAAK,QAAQ,MAAQ,IACnF,CACA,OAAO,IACT,CACF,EAEayE,EAAwC,CACnD,SAAUjG,EACV,QAASoB,EACT,SAAUR,CACZ,E"}
@@ -1,4 +1,4 @@
1
- import{C as e,E as t,b as n,h as r,n as i,v as a,y as o}from"./runtime-DxAbpr3S.js";import{n as s,r as c,t as l}from"./image-label-manifest--1CLRJzd.js";import{t as u}from"./live-jdiyYln2.js";import{t as d}from"./block-styles-CKo9x7Vt.js";import{t as f}from"./repeat-CY2W2URZ.js";import{i as p,n as m,o as h,r as g,t as _}from"./picture-view-BKnAyScQ.js";var v=`astl.image-label`,y=[{namespace:v,locale:`en`,messages:s},{namespace:v,locale:`pl`,messages:l}],b=500,x=class extends i{static manifest=c;static messages=y;static shadowRootOptions={...o.shadowRootOptions,slotAssignment:`manual`};static properties={values:{state:!0},active:{state:!0},loaded:{state:!0}};static styles=[t`
1
+ import{C as e,E as t,b as n,h as r,n as i,v as a,y as o}from"./runtime-C25QK5B0.js";import{n as s,r as c,t as l}from"./image-label-manifest--1CLRJzd.js";import{t as u}from"./live-qnReIRtj.js";import{t as d}from"./block-styles-CCtSFM4j.js";import{t as f}from"./repeat-BDXokpxQ.js";import{i as p,n as m,o as h,r as g,t as _}from"./picture-view-Deodu_mb.js";var v=`astl.image-label`,y=[{namespace:v,locale:`en`,messages:s},{namespace:v,locale:`pl`,messages:l}],b=500,x=class extends i{static manifest=c;static messages=y;static shadowRootOptions={...o.shadowRootOptions,slotAssignment:`manual`};static properties={values:{state:!0},active:{state:!0},loaded:{state:!0}};static styles=[t`
2
2
  fieldset {
3
3
  container-type: inline-size;
4
4
  }
@@ -174,4 +174,4 @@ margin-inline-start: calc(2rem + var(--astl-space-2));
174
174
  <bdi lang=${a(f===``?void 0:f)}>${l}</bdi>
175
175
  </p>`}
176
176
  </li>`}#t(e,t){this.disabled||t===(this.values.get(e)??``)||(this.values=new Map(this.values).set(e,t),this.emitChange({[e]:t}))}},S={manifest:c,element:x,messages:y};export{S as imageLabelElement};
177
- //# sourceMappingURL=image-label-Dm5shQSh.js.map
177
+ //# sourceMappingURL=image-label-DsKxQDTQ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-label-Dm5shQSh.js","names":["en","pl","LitElement","repeat","ifDefined","nothing","live","b","i$1","A","verdictIcon","AstlElement","o","i","en_default","imageLabelManifest","pl_default","l","blockStyles","c","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","imageLabelUiMessages","MAX_LENGTH","ImageLabelElement","pin","value","pins","next","id","answers","ui","loaded","#renderField","marked","verdict","solution","describedBy","ref","content","#type","event","imageLabelElement"],"sources":["../../../../components/src/image-label/ui-messages.ts","../../../../components/src/image-label/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.image-label';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `imageLabelMessages` would put the authoring strings into the element's chunk.\n */\nexport const imageLabelUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, verdictIcon } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, styles } from '../picture-view.js';\nimport { imageLabelManifest } from './manifest.js';\nimport { imageLabelUiMessages } from './ui-messages.js';\n\n/** Longest answer a field takes, as on a gap. */\nconst MAX_LENGTH = 500;\n\n/**\n * `<astl-image-label>`: the picture with numbered pins, and a native text field per pin beside it (below it when the\n * element is narrow). Focusing a field highlights its pin; pressing a pin focuses its field. Pins are for the pointer\n * only and hidden from assistive technology: the fields carry the numbers and the state. Locked, the fields are read\n * only, so the answers stay readable and focusable. Slots: one per pin, its typed answer.\n */\nexport class ImageLabelElement extends AstlElement {\n static override manifest: ComponentManifest = imageLabelManifest;\n static override messages: readonly MessageCatalog[] = imageLabelUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n values: { state: true },\n active: { state: true },\n loaded: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The picture and the fields side by side where the element has the room, one under the other otherwise.\n css`\n fieldset {\n container-type: inline-size;\n }\n .layout {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: var(--astl-space-3);\n align-items: start;\n }\n @container (inline-size >= 34rem) {\n .layout {\n grid-template-columns: minmax(0, 3fr) minmax(12rem, 2fr);\n }\n }\n .group-verdict {\n margin-block: var(--astl-space-3) 0;\n }\n `,\n // A pin: its number in a round badge on the picture, kept inside it, with a halo of the surface colour so it shows\n // on light and dark pictures, smaller on a small picture (a pin is no target); a press focuses its field. Its\n // field's focus lifts it in the selection look (bigger, filled), never by colour alone.\n css`\n .pin {\n --size: 2rem;\n box-sizing: border-box;\n display: grid;\n place-items: center;\n inline-size: var(--size);\n block-size: var(--size);\n border: var(--astl-focus-width) solid var(--astl-outline);\n border-radius: 50%;\n background: var(--astl-surface);\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n color: var(--astl-ink);\n font-size: var(--astl-size-ui);\n font-weight: 700;\n cursor: pointer;\n touch-action: manipulation;\n transition: scale var(--astl-duration-fast);\n }\n .pin[data-active] {\n border-color: var(--astl-selected);\n background: var(--astl-selected);\n color: var(--astl-surface);\n scale: 1.25;\n z-index: 1;\n forced-color-adjust: none;\n }\n @container (inline-size < 34rem) {\n .pin {\n --size: 1.5rem;\n border-width: var(--astl-outline-width);\n font-size: var(--astl-size-small);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .pin {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .pin[data-active] {\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n }\n `,\n // A field per pin: its number, the field and its verdict icon on one line, the solution under it. The icon's\n // column is kept in every row, so all fields end on one line and none shrinks when the answers are checked.\n css`\n .answers {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .row {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) 1.1em;\n align-items: center;\n gap: var(--astl-space-2);\n min-block-size: var(--astl-target-min);\n }\n .number {\n display: grid;\n place-items: center;\n min-inline-size: 2rem;\n block-size: 2rem;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: 50%;\n font-weight: 700;\n }\n .control {\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-inline: var(--astl-space-2);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n }\n .control {\n text-overflow: ellipsis;\n }\n .control[readonly] {\n cursor: default;\n }\n .control[readonly]:not([data-verdict]) {\n border-color: transparent;\n border-block-end-color: var(--astl-outline);\n border-radius: 0;\n background: transparent;\n }\n .control[data-verdict] {\n background: var(--astl-verdict-soft);\n }\n .control::placeholder {\n color: var(--astl-ink-muted);\n opacity: 1;\n }\n .astl-solution {\n margin-block-start: var(--astl-space-1);\n margin-inline-start: calc(2rem + var(--astl-space-2));\n }\n `,\n pictureStyles,\n blockStyles,\n ];\n\n /** Typed answers by pin id. */\n declare protected values: ReadonlyMap<string, string>;\n /** The pin whose field has the focus. */\n declare protected active: string | null;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n\n constructor() {\n super();\n this.values = new Map();\n this.active = null;\n this.loaded = null;\n }\n\n /** `<astl-image-label-pin>` children, in view order. */\n get pins(): readonly HTMLElement[] {\n return this.childElements('astl-image-label-pin');\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.pins.map((pin) => pin.id);\n }\n\n getAnswers(): Answers {\n if (this.id === '') return {};\n return Object.fromEntries([...this.values].filter(([, value]) => value !== ''));\n }\n\n setAnswers(answers: Answers): void {\n const pins = new Set(this.pins.map((pin) => pin.id));\n const next = new Map(this.values);\n for (const [id, value] of Object.entries(answers)) if (pins.has(id)) next.set(id, value);\n this.values = next;\n }\n\n units(): Units {\n const answered = this.pins.filter((pin) => (this.values.get(pin.id) ?? '').trim() !== '').length;\n return { answered, total: this.pins.length };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const pins = this.pins;\n return html`<fieldset part=\"image-label\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t('ui.hint')}</bdi></span>\n </legend>\n <div class=\"layout\">\n ${renderPicture(\n this,\n aspectOf(this, this.loaded),\n (loaded) => {\n this.loaded = loaded;\n },\n pins.map(\n (pin, i) => html`<span\n class=\"pin point\"\n part=\"pin\"\n aria-hidden=\"true\"\n data-pin=${pin.id}\n ?data-active=${this.active === pin.id}\n ${styles(percent({ x: Number(pin.getAttribute('x')) || 0, y: Number(pin.getAttribute('y')) || 0 }))}\n @click=${() => this.renderRoot.querySelector<HTMLInputElement>(`input[data-pin=\"${CSS.escape(pin.id)}\"]`)?.focus()}\n >${i + 1}</span\n >`,\n ),\n { alt: this.getAttribute('alt') ?? '' },\n )}\n <ol class=\"answers\" part=\"answers\">\n ${repeat(\n pins,\n (pin) => pin.id,\n (pin, i) => this.#renderField(pin.id, i),\n )}\n </ol>\n </div>\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n #renderField(id: string, i: number): TemplateResult {\n const ui = this.uiLanguage;\n // Where fields are marked one by one, an empty one shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict = this.slotVerdict(id) ?? (marked && (this.values.get(id) ?? '') === '' ? 'empty' : null);\n // A correct answer needs no correction: the solution shows for wrong and empty fields only.\n const solution = verdict === 'correct' ? undefined : this.solution?.[id];\n const describedBy = [\n verdict === null ? '' : `verdict-${i}`,\n solution === undefined ? '' : `solution-${i}`,\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const content = this.contentLang;\n return html`<li>\n <label class=\"row\">\n <span class=\"number\" aria-hidden=\"true\">${i + 1}</span>\n <input\n part=\"input\"\n class=\"control astl-box\"\n type=\"text\"\n data-pin=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n maxlength=${MAX_LENGTH}\n lang=${ifDefined(content === '' ? undefined : content)}\n spellcheck=\"false\"\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n ?readonly=${this.disabled}\n aria-label=${this.t('ui.input', { n: i + 1 })}\n aria-invalid=${verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n .value=${live(this.values.get(id) ?? '')}\n @input=${(event: Event) => this.#type(id, (event.target as HTMLInputElement).value)}\n @focus=${() => {\n this.active = id;\n }}\n @blur=${() => {\n if (this.active === id) this.active = null;\n }}\n />\n ${this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${i}` })}\n </label>\n ${\n solution === undefined\n ? nothing\n : html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${i}\" lang=${ui.lang} dir=${ui.dir}>\n ${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution')}</span>\n <bdi lang=${ifDefined(content === '' ? undefined : content)}>${solution}</bdi>\n </p>`\n }\n </li>`;\n }\n\n #type(id: string, value: string): void {\n if (this.disabled || value === (this.values.get(id) ?? '')) return;\n this.values = new Map(this.values).set(id, value);\n this.emitChange({ [id]: value });\n }\n}\n\nexport const imageLabelElement: ElementRegistration = {\n manifest: imageLabelManifest,\n element: ImageLabelElement,\n messages: imageLabelUiMessages,\n};\n"],"mappings":"A,mWAIA,IAAMyB,EAAY,mBAMLC,EAAkD,CAC7D,CAAE,YAAW,OAAQ,KAAM,SAAU1B,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECOM0B,EAAa,IAQNC,EAAb,cAAuCjB,CAAY,CACjD,OAAgB,SAA8BI,EAC9C,OAAgB,SAAsCW,EACtD,OAAgB,kBAAoC,CAClD,GAAGxB,EAAW,kBACd,eAAgB,QAClB,EAEA,OAAgB,WAAmC,CACjD,OAAQ,CAAE,MAAO,EAAK,EACtB,OAAQ,CAAE,MAAO,EAAK,EACtB,OAAQ,CAAE,MAAO,EAAK,CACxB,EAGA,OAAgB,OAAyB,CAEvC,CAAG;;;;;;;;;;;;;;;;;;EAsBH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DHqB,EACAL,CACF,EASA,aAAc,CACZ,MAAM,EACN,KAAK,OAAS,IAAI,IAClB,KAAK,OAAS,KACd,KAAK,OAAS,IAChB,CAGA,IAAI,MAA+B,CACjC,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,KAAK,SAAWA,IAAI,KAAK,OAAS,KACxC,EAAE;;UAEF,KAAK,cAAcM,EAAS,CAAE,WAAY,GAAM,GAAI,WAAW,GAAI,CAAC,EAAE;;QAGxEC,IAAa,IAAA,GACTnC,EACA,CAAI,yDAAyD,EAAE,SAAS8B,EAAG,KAAK,OAAOA,EAAG,IAAI;gBAC1FzB,EAAY,SAAS,EAAE,oCAAoC,KAAK,EAAE,aAAa,EAAE;0BACvEN,EAAUuC,IAAY,GAAK,IAAA,GAAYA,CAAO,EAAE,GAAGH,EAAS;kBAE/E;UAEL,CAEA,GAAM,EAAY,EAAqB,CACjC,KAAK,UAAYV,KAAW,KAAK,OAAO,IAAIG,CAAE,GAAK,MACvD,KAAK,OAAS,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,IAAIA,EAAIH,CAAK,EAChD,KAAK,WAAW,EAAGG,GAAKH,CAAM,CAAC,EACjC,CACF,EAEagB,EAAyC,CACpD,SAAU/B,EACV,QAASa,EACT,SAAUF,CACZ,E"}
1
+ {"version":3,"file":"image-label-DsKxQDTQ.js","names":["en","pl","LitElement","repeat","ifDefined","nothing","live","b","i$1","A","verdictIcon","AstlElement","o","i","en_default","imageLabelManifest","pl_default","l","blockStyles","c","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","imageLabelUiMessages","MAX_LENGTH","ImageLabelElement","pin","value","pins","next","id","answers","ui","loaded","#renderField","marked","verdict","solution","describedBy","ref","content","#type","event","imageLabelElement"],"sources":["../../../../components/src/image-label/ui-messages.ts","../../../../components/src/image-label/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.image-label';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `imageLabelMessages` would put the authoring strings into the element's chunk.\n */\nexport const imageLabelUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, verdictIcon } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, styles } from '../picture-view.js';\nimport { imageLabelManifest } from './manifest.js';\nimport { imageLabelUiMessages } from './ui-messages.js';\n\n/** Longest answer a field takes, as on a gap. */\nconst MAX_LENGTH = 500;\n\n/**\n * `<astl-image-label>`: the picture with numbered pins, and a native text field per pin beside it (below it when the\n * element is narrow). Focusing a field highlights its pin; pressing a pin focuses its field. Pins are for the pointer\n * only and hidden from assistive technology: the fields carry the numbers and the state. Locked, the fields are read\n * only, so the answers stay readable and focusable. Slots: one per pin, its typed answer.\n */\nexport class ImageLabelElement extends AstlElement {\n static override manifest: ComponentManifest = imageLabelManifest;\n static override messages: readonly MessageCatalog[] = imageLabelUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n values: { state: true },\n active: { state: true },\n loaded: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The picture and the fields side by side where the element has the room, one under the other otherwise.\n css`\n fieldset {\n container-type: inline-size;\n }\n .layout {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: var(--astl-space-3);\n align-items: start;\n }\n @container (inline-size >= 34rem) {\n .layout {\n grid-template-columns: minmax(0, 3fr) minmax(12rem, 2fr);\n }\n }\n .group-verdict {\n margin-block: var(--astl-space-3) 0;\n }\n `,\n // A pin: its number in a round badge on the picture, kept inside it, with a halo of the surface colour so it shows\n // on light and dark pictures, smaller on a small picture (a pin is no target); a press focuses its field. Its\n // field's focus lifts it in the selection look (bigger, filled), never by colour alone.\n css`\n .pin {\n --size: 2rem;\n box-sizing: border-box;\n display: grid;\n place-items: center;\n inline-size: var(--size);\n block-size: var(--size);\n border: var(--astl-focus-width) solid var(--astl-outline);\n border-radius: 50%;\n background: var(--astl-surface);\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n color: var(--astl-ink);\n font-size: var(--astl-size-ui);\n font-weight: 700;\n cursor: pointer;\n touch-action: manipulation;\n transition: scale var(--astl-duration-fast);\n }\n .pin[data-active] {\n border-color: var(--astl-selected);\n background: var(--astl-selected);\n color: var(--astl-surface);\n scale: 1.25;\n z-index: 1;\n forced-color-adjust: none;\n }\n @container (inline-size < 34rem) {\n .pin {\n --size: 1.5rem;\n border-width: var(--astl-outline-width);\n font-size: var(--astl-size-small);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .pin {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .pin[data-active] {\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n }\n `,\n // A field per pin: its number, the field and its verdict icon on one line, the solution under it. The icon's\n // column is kept in every row, so all fields end on one line and none shrinks when the answers are checked.\n css`\n .answers {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .row {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) 1.1em;\n align-items: center;\n gap: var(--astl-space-2);\n min-block-size: var(--astl-target-min);\n }\n .number {\n display: grid;\n place-items: center;\n min-inline-size: 2rem;\n block-size: 2rem;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: 50%;\n font-weight: 700;\n }\n .control {\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-inline: var(--astl-space-2);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n }\n .control {\n text-overflow: ellipsis;\n }\n .control[readonly] {\n cursor: default;\n }\n .control[readonly]:not([data-verdict]) {\n border-color: transparent;\n border-block-end-color: var(--astl-outline);\n border-radius: 0;\n background: transparent;\n }\n .control[data-verdict] {\n background: var(--astl-verdict-soft);\n }\n .control::placeholder {\n color: var(--astl-ink-muted);\n opacity: 1;\n }\n .astl-solution {\n margin-block-start: var(--astl-space-1);\n margin-inline-start: calc(2rem + var(--astl-space-2));\n }\n `,\n pictureStyles,\n blockStyles,\n ];\n\n /** Typed answers by pin id. */\n declare protected values: ReadonlyMap<string, string>;\n /** The pin whose field has the focus. */\n declare protected active: string | null;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n\n constructor() {\n super();\n this.values = new Map();\n this.active = null;\n this.loaded = null;\n }\n\n /** `<astl-image-label-pin>` children, in view order. */\n get pins(): readonly HTMLElement[] {\n return this.childElements('astl-image-label-pin');\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.pins.map((pin) => pin.id);\n }\n\n getAnswers(): Answers {\n if (this.id === '') return {};\n return Object.fromEntries([...this.values].filter(([, value]) => value !== ''));\n }\n\n setAnswers(answers: Answers): void {\n const pins = new Set(this.pins.map((pin) => pin.id));\n const next = new Map(this.values);\n for (const [id, value] of Object.entries(answers)) if (pins.has(id)) next.set(id, value);\n this.values = next;\n }\n\n units(): Units {\n const answered = this.pins.filter((pin) => (this.values.get(pin.id) ?? '').trim() !== '').length;\n return { answered, total: this.pins.length };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const pins = this.pins;\n return html`<fieldset part=\"image-label\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t('ui.hint')}</bdi></span>\n </legend>\n <div class=\"layout\">\n ${renderPicture(\n this,\n aspectOf(this, this.loaded),\n (loaded) => {\n this.loaded = loaded;\n },\n pins.map(\n (pin, i) => html`<span\n class=\"pin point\"\n part=\"pin\"\n aria-hidden=\"true\"\n data-pin=${pin.id}\n ?data-active=${this.active === pin.id}\n ${styles(percent({ x: Number(pin.getAttribute('x')) || 0, y: Number(pin.getAttribute('y')) || 0 }))}\n @click=${() => this.renderRoot.querySelector<HTMLInputElement>(`input[data-pin=\"${CSS.escape(pin.id)}\"]`)?.focus()}\n >${i + 1}</span\n >`,\n ),\n { alt: this.getAttribute('alt') ?? '' },\n )}\n <ol class=\"answers\" part=\"answers\">\n ${repeat(\n pins,\n (pin) => pin.id,\n (pin, i) => this.#renderField(pin.id, i),\n )}\n </ol>\n </div>\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n #renderField(id: string, i: number): TemplateResult {\n const ui = this.uiLanguage;\n // Where fields are marked one by one, an empty one shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict = this.slotVerdict(id) ?? (marked && (this.values.get(id) ?? '') === '' ? 'empty' : null);\n // A correct answer needs no correction: the solution shows for wrong and empty fields only.\n const solution = verdict === 'correct' ? undefined : this.solution?.[id];\n const describedBy = [\n verdict === null ? '' : `verdict-${i}`,\n solution === undefined ? '' : `solution-${i}`,\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const content = this.contentLang;\n return html`<li>\n <label class=\"row\">\n <span class=\"number\" aria-hidden=\"true\">${i + 1}</span>\n <input\n part=\"input\"\n class=\"control astl-box\"\n type=\"text\"\n data-pin=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n maxlength=${MAX_LENGTH}\n lang=${ifDefined(content === '' ? undefined : content)}\n spellcheck=\"false\"\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n ?readonly=${this.disabled}\n aria-label=${this.t('ui.input', { n: i + 1 })}\n aria-invalid=${verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n .value=${live(this.values.get(id) ?? '')}\n @input=${(event: Event) => this.#type(id, (event.target as HTMLInputElement).value)}\n @focus=${() => {\n this.active = id;\n }}\n @blur=${() => {\n if (this.active === id) this.active = null;\n }}\n />\n ${this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${i}` })}\n </label>\n ${\n solution === undefined\n ? nothing\n : html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${i}\" lang=${ui.lang} dir=${ui.dir}>\n ${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution')}</span>\n <bdi lang=${ifDefined(content === '' ? undefined : content)}>${solution}</bdi>\n </p>`\n }\n </li>`;\n }\n\n #type(id: string, value: string): void {\n if (this.disabled || value === (this.values.get(id) ?? '')) return;\n this.values = new Map(this.values).set(id, value);\n this.emitChange({ [id]: value });\n }\n}\n\nexport const imageLabelElement: ElementRegistration = {\n manifest: imageLabelManifest,\n element: ImageLabelElement,\n messages: imageLabelUiMessages,\n};\n"],"mappings":"A,mWAIA,IAAMyB,EAAY,mBAMLC,EAAkD,CAC7D,CAAE,YAAW,OAAQ,KAAM,SAAU1B,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECOM0B,EAAa,IAQNC,EAAb,cAAuCjB,CAAY,CACjD,OAAgB,SAA8BI,EAC9C,OAAgB,SAAsCW,EACtD,OAAgB,kBAAoC,CAClD,GAAGxB,EAAW,kBACd,eAAgB,QAClB,EAEA,OAAgB,WAAmC,CACjD,OAAQ,CAAE,MAAO,EAAK,EACtB,OAAQ,CAAE,MAAO,EAAK,EACtB,OAAQ,CAAE,MAAO,EAAK,CACxB,EAGA,OAAgB,OAAyB,CAEvC,CAAG;;;;;;;;;;;;;;;;;;EAsBH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DHqB,EACAL,CACF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AE;mBAC/B,GAAiB,KAAKW,GAAMX,EAAKY,EAAM,OAA4B,KAAK,EAAE;uBACrE,CACb,KAAK,OAASZ,CAChB,EAAE;sBACY,CACR,KAAK,SAAWA,IAAI,KAAK,OAAS,KACxC,EAAE;;UAEF,KAAK,cAAcM,EAAS,CAAE,WAAY,GAAM,GAAI,WAAW,GAAI,CAAC,EAAE;;QAGxEC,IAAa,IAAA,GACTnC,EACA,CAAI,yDAAyD,EAAE,SAAS8B,EAAG,KAAK,OAAOA,EAAG,IAAI;gBAC1FzB,EAAY,SAAS,EAAE,oCAAoC,KAAK,EAAE,aAAa,EAAE;0BACvEN,EAAUuC,IAAY,GAAK,IAAA,GAAYA,CAAO,EAAE,GAAGH,EAAS;kBAE/E;UAEL,CAEA,GAAM,EAAY,EAAqB,CACjC,KAAK,UAAYV,KAAW,KAAK,OAAO,IAAIG,CAAE,GAAK,MACvD,KAAK,OAAS,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,IAAIA,EAAIH,CAAK,EAChD,KAAK,WAAW,EAAGG,GAAKH,CAAM,CAAC,EACjC,CACF,EAEagB,EAAyC,CACpD,SAAU/B,EACV,QAASa,EACT,SAAUF,CACZ,E"}
@@ -1,4 +1,4 @@
1
- import{E as e,_ as t,g as n}from"./runtime-DxAbpr3S.js";var r=[t,n,e`
1
+ import{E as e,_ as t,g as n}from"./runtime-C25QK5B0.js";var r=[t,n,e`
2
2
  :host {
3
3
  display: inline;
4
4
  }
@@ -77,4 +77,4 @@ color: var(--astl-success);
77
77
  vertical-align: -0.15em;
78
78
  }
79
79
  `];export{r as t};
80
- //# sourceMappingURL=inline-styles-CTgXWnHb.js.map
80
+ //# sourceMappingURL=inline-styles-CFNlb6f2.js.map