@pie-element/multiple-choice 13.3.8 → 13.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [13.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@13.3.8...@pie-element/multiple-choice@13.4.0) (2026-08-21)
7
+
8
+ ### Bug Fixes
9
+
10
+ - move [@pie-lib](https://github.com/pie-lib) deps back to latest, off next prereleases PIE-927 ([a53e012](https://github.com/pie-framework/pie-elements/commit/a53e0127eb4ac95ece54e1e2bd669ae4974f4251))
11
+ - read the prompt container by class, not by the id pie-lib removed PIE-927 ([aaaf6c2](https://github.com/pie-framework/pie-elements/commit/aaaf6c2f189de3b39f9de85969aeb2e50376c548))
12
+ - **theming:** move the grey palette reads onto --pie-\* tokens PIE-856 ([d7d005b](https://github.com/pie-framework/pie-elements/commit/d7d005bf081843335b4b0377852f2ecd075cb62d)), closes [#000000](https://github.com/pie-framework/pie-elements/issues/000000) [#E0E1E6](https://github.com/pie-framework/pie-elements/issues/E0E1E6) [#646464](https://github.com/pie-framework/pie-elements/issues/646464) [#616161](https://github.com/pie-framework/pie-elements/issues/616161) [#E0E1E6](https://github.com/pie-framework/pie-elements/issues/E0E1E6) [#C0C3](https://github.com/pie-framework/pie-elements/issues/C0C3)
13
+
14
+ ### Features
15
+
16
+ - bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
17
+
6
18
  ## [13.3.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@13.3.7...@pie-element/multiple-choice@13.3.8) (2026-08-19)
7
19
 
8
20
  ### Bug Fixes
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@10.1.11...@pie-element/multiple-choice-configure@10.2.0) (2026-08-21)
7
+
8
+ ### Features
9
+
10
+ - bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
11
+
6
12
  ## [10.1.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@10.1.10...@pie-element/multiple-choice-configure@10.1.11) (2026-08-19)
7
13
 
8
14
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-configure",
3
- "version": "10.1.11",
3
+ "version": "10.2.0",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -10,9 +10,9 @@
10
10
  "@mui/icons-material": "^7.3.4",
11
11
  "@mui/material": "^7.3.4",
12
12
  "@pie-framework/pie-configure-events": "^1.3.0",
13
- "@pie-lib/config-ui": "13.0.15",
14
- "@pie-lib/editable-html-tip-tap": "2.1.13",
15
- "@pie-lib/render-ui": "6.1.3",
13
+ "@pie-lib/config-ui": "13.0.16",
14
+ "@pie-lib/editable-html-tip-tap": "2.1.14",
15
+ "@pie-lib/render-ui": "7.0.0",
16
16
  "debug": "^4.1.1",
17
17
  "lodash-es": "^4.17.23",
18
18
  "prop-types": "^15.8.1",
package/lib/choice.js CHANGED
@@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _styles = require("@mui/material/styles");
12
12
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
13
+ var _renderUi = require("@pie-lib/render-ui");
13
14
  var _choiceInput = _interopRequireDefault(require("./choice-input"));
14
15
  const ChoiceContainer = (0, _styles.styled)(_Box.default, {
15
16
  shouldForwardProp: prop => prop !== 'noBorder' && prop !== 'horizontalLayout'
@@ -22,7 +23,13 @@ const ChoiceContainer = (0, _styles.styled)(_Box.default, {
22
23
  paddingBottom: `calc(${theme.spacing(1)} + 2px)`,
23
24
  paddingLeft: `calc(${theme.spacing(1)} + 2px)`,
24
25
  paddingRight: `calc(${theme.spacing(1)} + 2px)`,
25
- borderBottom: noBorder ? 'none' : `1px solid ${theme.palette.grey[300]}`,
26
+ /*
27
+ * The separator between answer choices. MUI's grey[300] does not follow `--pie-*`,
28
+ * so it stayed #e0e0e0 on every scheme -- about 1.1:1 against black-on-rose's own
29
+ * background, which is where George reported it. `--pie-border` is stepped per
30
+ * scheme and holds at least 3.23:1 everywhere.
31
+ */
32
+ borderBottom: noBorder ? 'none' : `1px solid ${_renderUi.color.border()}`,
26
33
  ...(horizontalLayout && {
27
34
  paddingRight: theme.spacing(2.5),
28
35
  '& label': {
package/lib/choice.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_Box","_choiceInput","ChoiceContainer","styled","Box","shouldForwardProp","prop","theme","noBorder","horizontalLayout","paddingTop","spacing","paddingBottom","paddingLeft","paddingRight","borderBottom","palette","grey","marginRight","Choice","React","Component","constructor","args","_defineProperty2","default","isHovered","disabled","checked","props","setState","choice","onChoiceChanged","render","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","correctness","displayKey","choicesLayout","gridColumns","isSelectionButtonBelow","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","tagName","state","choiceClass","feedback","choiceProps","onChange","normalizeStrokeWidth","width","trimmed","String","trim","test","hasSelectedStroke","hasHoverStroke","currentStrokeColor","currentStrokeWidth","currentBackgroundColor","hasStroke","strokeStyle","border","borderRadius","choiceBackground","createElement","className","key","style","backgroundColor","onMouseEnter","handleMouseEnter","onMouseLeave","handleMouseLeave","component","exports","propTypes","PropTypes","oneOf","object","bool","isRequired","func","number","string","_default"],"sources":["../src/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\n\nimport ChoiceInput from './choice-input';\n\nconst ChoiceContainer = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'noBorder' && prop !== 'horizontalLayout',\n})(({ theme, noBorder, horizontalLayout }) => ({\n paddingTop: theme.spacing(2.5),\n paddingBottom: `calc(${theme.spacing(1)} + 2px)`,\n paddingLeft: `calc(${theme.spacing(1)} + 2px)`,\n paddingRight: `calc(${theme.spacing(1)} + 2px)`,\n borderBottom: noBorder ? 'none' : `1px solid ${theme.palette.grey[300]}`,\n ...(horizontalLayout && {\n paddingRight: theme.spacing(2.5),\n '& label': {\n marginRight: theme.spacing(1),\n },\n }),\n}));\n\nexport class Choice extends React.Component {\n static propTypes = {};\n\n state = {\n isHovered: false,\n };\n\n handleMouseEnter = () => {\n const { disabled, checked } = this.props;\n\n if (!disabled && !checked) {\n this.setState({ isHovered: true });\n }\n };\n\n handleMouseLeave = () => {\n this.setState({ isHovered: false });\n };\n\n onChange = (choice) => {\n const { disabled, onChoiceChanged } = this.props;\n\n if (!disabled) {\n onChoiceChanged(choice);\n }\n };\n\n render() {\n const {\n choice,\n index,\n choicesLength,\n showCorrect,\n isEvaluateMode,\n choiceMode,\n disabled,\n checked,\n correctness,\n displayKey,\n choicesLayout,\n gridColumns,\n isSelectionButtonBelow,\n selectedAnswerBackgroundColor,\n selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n hoverAnswerBackgroundColor,\n hoverAnswerStrokeColor,\n hoverAnswerStrokeWidth,\n tagName\n } = this.props;\n \n const { isHovered } = this.state;\n const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');\n\n const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;\n\n const choiceProps = {\n ...choice,\n checked,\n choiceMode,\n disabled,\n feedback,\n correctness,\n displayKey,\n index,\n choicesLayout,\n gridColumns,\n onChange: this.onChange,\n isEvaluateMode,\n isSelectionButtonBelow,\n selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n tagName,\n };\n\n const normalizeStrokeWidth = (width) => {\n if (!width) return '2px'; // default\n const trimmed = String(width).trim();\n \n // add 'px' if the value is a number\n if (/^\\d+(\\.\\d+)?$/.test(trimmed)) {\n return `${trimmed}px`;\n }\n\n return trimmed;\n };\n\n const hasSelectedStroke = selectedAnswerStrokeColor && selectedAnswerStrokeColor !== 'initial';\n const hasHoverStroke = hoverAnswerStrokeColor && hoverAnswerStrokeColor !== 'initial';\n \n let currentStrokeColor = 'transparent';\n let currentStrokeWidth = '2px';\n let currentBackgroundColor = 'initial';\n \n if ((hasSelectedStroke || hasHoverStroke)) {\n if (checked && hasSelectedStroke) {\n // selected state takes priority when selected stroke is configured\n currentStrokeColor = selectedAnswerStrokeColor;\n currentStrokeWidth = selectedAnswerStrokeWidth;\n } else if (isHovered && !disabled && hasHoverStroke) {\n // hover state when not selected and not disabled, and hover stroke is configured\n currentStrokeColor = hoverAnswerStrokeColor;\n currentStrokeWidth = hoverAnswerStrokeWidth;\n }\n }\n \n if (checked && selectedAnswerBackgroundColor && selectedAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = selectedAnswerBackgroundColor;\n } else if (isHovered && !disabled && hoverAnswerBackgroundColor && hoverAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = hoverAnswerBackgroundColor;\n }\n\n const hasStroke = hasSelectedStroke || hasHoverStroke;\n const strokeStyle = hasStroke ? {\n border: `${normalizeStrokeWidth(currentStrokeWidth)} solid ${currentStrokeColor}`,\n borderRadius: '8px',\n } : {};\n\n const noBorder = index === choicesLength - 1 || choicesLayout !== 'vertical' || hasStroke;\n const horizontalLayout = choicesLayout === 'horizontal';\n\n const choiceBackground = currentBackgroundColor !== 'initial' ? currentBackgroundColor : 'initial';\n\n return (\n <div \n className={choiceClass} \n key={index} \n style={{ backgroundColor: choiceBackground, ...strokeStyle }}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <ChoiceContainer \n component=\"div\"\n noBorder={noBorder}\n horizontalLayout={horizontalLayout}\n >\n <ChoiceInput {...choiceProps} />\n </ChoiceContainer>\n </div>\n );\n }\n}\n\nChoice.propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n choice: PropTypes.object,\n disabled: PropTypes.bool.isRequired,\n onChoiceChanged: PropTypes.func,\n index: PropTypes.number,\n choicesLength: PropTypes.number,\n showCorrect: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n checked: PropTypes.bool,\n correctness: PropTypes.string,\n displayKey: PropTypes.string,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n selectedAnswerStrokeColor: PropTypes.string,\n selectedAnswerStrokeWidth: PropTypes.string,\n hoverAnswerBackgroundColor: PropTypes.string,\n hoverAnswerStrokeColor: PropTypes.string,\n hoverAnswerStrokeWidth: PropTypes.string,\n tagName: PropTypes.string,\n isSelectionButtonBelow: PropTypes.bool,\n};\n\nexport default Choice;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,MAAMK,eAAe,GAAG,IAAAC,cAAM,EAACC,YAAG,EAAE;EAClCC,iBAAiB,EAAGC,IAAI,IAAKA,IAAI,KAAK,UAAU,IAAIA,IAAI,KAAK;AAC/D,CAAC,CAAC,CAAC,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAiB,CAAC,MAAM;EAC7CC,UAAU,EAAEH,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C,KAAK,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;EAClE3C,WAAW,EAAE0C,kBAAS,CAACO,MAAM;EAC7B/C,6BAA6B,EAAEwC,kBAAS,CAACO,MAAM;EAC/C9C,yBAAyB,EAAEuC,kBAAS,CAACO,MAAM;EAC3C7C,yBAAyB,EAAEsC,kBAAS,CAACO,MAAM;EAC3C5C,0BAA0B,EAAEqC,kBAAS,CAACO,MAAM;EAC5C3C,sBAAsB,EAAEoC,kBAAS,CAACO,MAAM;EACxC1C,sBAAsB,EAAEmC,kBAAS,CAACO,MAAM;EACxCzC,OAAO,EAAEkC,kBAAS,CAACO,MAAM;EACzBhD,sBAAsB,EAAEyC,kBAAS,CAACG;AACpC,CAAC;AAAC,IAAAK,QAAA,GAAAV,OAAA,CAAAzD,OAAA,GAEaN,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_Box","_renderUi","_choiceInput","ChoiceContainer","styled","Box","shouldForwardProp","prop","theme","noBorder","horizontalLayout","paddingTop","spacing","paddingBottom","paddingLeft","paddingRight","borderBottom","color","border","marginRight","Choice","React","Component","constructor","args","_defineProperty2","default","isHovered","disabled","checked","props","setState","choice","onChoiceChanged","render","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","correctness","displayKey","choicesLayout","gridColumns","isSelectionButtonBelow","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","tagName","state","choiceClass","feedback","choiceProps","onChange","normalizeStrokeWidth","width","trimmed","String","trim","test","hasSelectedStroke","hasHoverStroke","currentStrokeColor","currentStrokeWidth","currentBackgroundColor","hasStroke","strokeStyle","borderRadius","choiceBackground","createElement","className","key","style","backgroundColor","onMouseEnter","handleMouseEnter","onMouseLeave","handleMouseLeave","component","exports","propTypes","PropTypes","oneOf","object","bool","isRequired","func","number","string","_default"],"sources":["../src/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport { color } from '@pie-lib/render-ui';\n\nimport ChoiceInput from './choice-input';\n\nconst ChoiceContainer = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'noBorder' && prop !== 'horizontalLayout',\n})(({ theme, noBorder, horizontalLayout }) => ({\n paddingTop: theme.spacing(2.5),\n paddingBottom: `calc(${theme.spacing(1)} + 2px)`,\n paddingLeft: `calc(${theme.spacing(1)} + 2px)`,\n paddingRight: `calc(${theme.spacing(1)} + 2px)`,\n /*\n * The separator between answer choices. MUI's grey[300] does not follow `--pie-*`,\n * so it stayed #e0e0e0 on every scheme -- about 1.1:1 against black-on-rose's own\n * background, which is where George reported it. `--pie-border` is stepped per\n * scheme and holds at least 3.23:1 everywhere.\n */\n borderBottom: noBorder ? 'none' : `1px solid ${color.border()}`,\n ...(horizontalLayout && {\n paddingRight: theme.spacing(2.5),\n '& label': {\n marginRight: theme.spacing(1),\n },\n }),\n}));\n\nexport class Choice extends React.Component {\n static propTypes = {};\n\n state = {\n isHovered: false,\n };\n\n handleMouseEnter = () => {\n const { disabled, checked } = this.props;\n\n if (!disabled && !checked) {\n this.setState({ isHovered: true });\n }\n };\n\n handleMouseLeave = () => {\n this.setState({ isHovered: false });\n };\n\n onChange = (choice) => {\n const { disabled, onChoiceChanged } = this.props;\n\n if (!disabled) {\n onChoiceChanged(choice);\n }\n };\n\n render() {\n const {\n choice,\n index,\n choicesLength,\n showCorrect,\n isEvaluateMode,\n choiceMode,\n disabled,\n checked,\n correctness,\n displayKey,\n choicesLayout,\n gridColumns,\n isSelectionButtonBelow,\n selectedAnswerBackgroundColor,\n selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n hoverAnswerBackgroundColor,\n hoverAnswerStrokeColor,\n hoverAnswerStrokeWidth,\n tagName\n } = this.props;\n \n const { isHovered } = this.state;\n const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');\n\n const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;\n\n const choiceProps = {\n ...choice,\n checked,\n choiceMode,\n disabled,\n feedback,\n correctness,\n displayKey,\n index,\n choicesLayout,\n gridColumns,\n onChange: this.onChange,\n isEvaluateMode,\n isSelectionButtonBelow,\n selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n tagName,\n };\n\n const normalizeStrokeWidth = (width) => {\n if (!width) return '2px'; // default\n const trimmed = String(width).trim();\n \n // add 'px' if the value is a number\n if (/^\\d+(\\.\\d+)?$/.test(trimmed)) {\n return `${trimmed}px`;\n }\n\n return trimmed;\n };\n\n const hasSelectedStroke = selectedAnswerStrokeColor && selectedAnswerStrokeColor !== 'initial';\n const hasHoverStroke = hoverAnswerStrokeColor && hoverAnswerStrokeColor !== 'initial';\n \n let currentStrokeColor = 'transparent';\n let currentStrokeWidth = '2px';\n let currentBackgroundColor = 'initial';\n \n if ((hasSelectedStroke || hasHoverStroke)) {\n if (checked && hasSelectedStroke) {\n // selected state takes priority when selected stroke is configured\n currentStrokeColor = selectedAnswerStrokeColor;\n currentStrokeWidth = selectedAnswerStrokeWidth;\n } else if (isHovered && !disabled && hasHoverStroke) {\n // hover state when not selected and not disabled, and hover stroke is configured\n currentStrokeColor = hoverAnswerStrokeColor;\n currentStrokeWidth = hoverAnswerStrokeWidth;\n }\n }\n \n if (checked && selectedAnswerBackgroundColor && selectedAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = selectedAnswerBackgroundColor;\n } else if (isHovered && !disabled && hoverAnswerBackgroundColor && hoverAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = hoverAnswerBackgroundColor;\n }\n\n const hasStroke = hasSelectedStroke || hasHoverStroke;\n const strokeStyle = hasStroke ? {\n border: `${normalizeStrokeWidth(currentStrokeWidth)} solid ${currentStrokeColor}`,\n borderRadius: '8px',\n } : {};\n\n const noBorder = index === choicesLength - 1 || choicesLayout !== 'vertical' || hasStroke;\n const horizontalLayout = choicesLayout === 'horizontal';\n\n const choiceBackground = currentBackgroundColor !== 'initial' ? currentBackgroundColor : 'initial';\n\n return (\n <div \n className={choiceClass} \n key={index} \n style={{ backgroundColor: choiceBackground, ...strokeStyle }}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\n <ChoiceContainer \n component=\"div\"\n noBorder={noBorder}\n horizontalLayout={horizontalLayout}\n >\n <ChoiceInput {...choiceProps} />\n </ChoiceContainer>\n </div>\n );\n }\n}\n\nChoice.propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n choice: PropTypes.object,\n disabled: PropTypes.bool.isRequired,\n onChoiceChanged: PropTypes.func,\n index: PropTypes.number,\n choicesLength: PropTypes.number,\n showCorrect: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n checked: PropTypes.bool,\n correctness: PropTypes.string,\n displayKey: PropTypes.string,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n selectedAnswerStrokeColor: PropTypes.string,\n selectedAnswerStrokeWidth: PropTypes.string,\n hoverAnswerBackgroundColor: PropTypes.string,\n hoverAnswerStrokeColor: PropTypes.string,\n hoverAnswerStrokeWidth: PropTypes.string,\n tagName: PropTypes.string,\n isSelectionButtonBelow: PropTypes.bool,\n};\n\nexport default Choice;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAMM,eAAe,GAAG,IAAAC,cAAM,EAACC,YAAG,EAAE;EAClCC,iBAAiB,EA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kBAAS,CAACG,IAAI;EAC9B1D,OAAO,EAAEuD,kBAAS,CAACG,IAAI;EACvB/C,WAAW,EAAE4C,kBAAS,CAACO,MAAM;EAC7BlD,UAAU,EAAE2C,kBAAS,CAACO,MAAM;EAC5BjD,aAAa,EAAE0C,kBAAS,CAACC,KAAK,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;EAClE1C,WAAW,EAAEyC,kBAAS,CAACO,MAAM;EAC7B9C,6BAA6B,EAAEuC,kBAAS,CAACO,MAAM;EAC/C7C,yBAAyB,EAAEsC,kBAAS,CAACO,MAAM;EAC3C5C,yBAAyB,EAAEqC,kBAAS,CAACO,MAAM;EAC3C3C,0BAA0B,EAAEoC,kBAAS,CAACO,MAAM;EAC5C1C,sBAAsB,EAAEmC,kBAAS,CAACO,MAAM;EACxCzC,sBAAsB,EAAEkC,kBAAS,CAACO,MAAM;EACxCxC,OAAO,EAAEiC,kBAAS,CAACO,MAAM;EACzB/C,sBAAsB,EAAEwC,kBAAS,CAACG;AACpC,CAAC;AAAC,IAAAK,QAAA,GAAAV,OAAA,CAAAxD,OAAA,GAEaN,MAAM","ignoreList":[]}
package/lib/index.js CHANGED
@@ -27,7 +27,7 @@ const isComplete = (session, model, audioComplete, elementContext) => {
27
27
  if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
28
28
  if (elementContext) {
29
29
  const audio = elementContext.querySelector('audio');
30
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
30
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
31
31
 
32
32
  // only require audio completion if audio exists and is inside the prompt
33
33
  if (audio && isInsidePrompt) {
@@ -257,7 +257,7 @@ class MultipleChoice extends HTMLElement {
257
257
  if (mutation.type === 'childList') {
258
258
  if (this._audioInitialized) return;
259
259
  const audio = this.querySelector('audio');
260
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
260
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
261
261
  if (!this._model) return;
262
262
  if (!this._model.autoplayAudioEnabled) return;
263
263
  if (audio && !isInsidePrompt) return;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_lodashEs","_debug","_piePlayerEvents","_mathRendering","_renderUi","_sessionUpdater","_utils","log","debug","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","audio","querySelector","isInsidePrompt","closest","value","choiceMode","minSelections","maxSelections","selections","length","exceedsMaxSelections","exports","getPlayerAttributes","element","player","baseHeadingLevel","undefined","includeSrHeading","getRaw","camelCaseName","hyphenatedName","allLowerName","raw","getAttribute","levelRaw","level","parseInt","Number","isFinite","srRaw","resolveHeadingProps","fromPlayer","_baseHeadingLevel","_includeSrHeading","MultipleChoice","HTMLElement","constructor","_defineProperty2","default","_mathRenderPending","requestAnimationFrame","_mathObserver","disconnect","renderMath","setTimeout","observe","childList","subtree","_model","_session","_options","_boundHandleKeyDown","handleKeyDown","bind","_keyboardEventsEnabled","_audioInitialized","_root","_rerender","debounce","React","createElement","Main","options","onChoiceChanged","_onChange","onShowCorrectToggle","setAttribute","setLangAttribute","_initMathObserver","createRoot","render","keyboardEventsEnabled","enableKeyboardEvents","leading","trailing","_dispatchResponseChanged","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","_dispatchModelSet","ModelSetEvent","MutationObserver","_scheduleMathRender","_disconnectMathObserver","language","lang","slice","s","o","data","updateSessionValue","_createAudioInfoToast","info","document","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","_initPlayerObserver","observer","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","paused","addEventListener","handlePlaying","updateSessionMetadata","audioStartTime","Date","getTime","handleEnded","audioEndTime","_audio","_handlePlaying","_handleEnded","_enableAudio","window","_playerObserver","attributes","attributeFilter","_disconnectPlayerObserver","disconnectedCallback","unmount","event","mode","keyToIndex","key","numOffset","letterOffset","test","charCodeAt","choiceIndex","choices","currentValue","choiceId","alreadySelected","includes","newValue","selected","selector"],"sources":["../src/index.js"],"sourcesContent":["import Main from './main';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from 'lodash-es';\nimport debug from 'debug';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { updateSessionValue, updateSessionMetadata } from './session-updater';\nimport { exceedsMaxSelections } from './utils';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session, model, audioComplete, elementContext) => {\n const { autoplayAudioEnabled, completeAudioEnabled } = model || {};\n\n // check audio completion if audio settings are enabled and audio actually exists\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const { choiceMode, minSelections = 1, maxSelections } = model || {};\n const selections = session.value.length || 0;\n\n if (choiceMode === 'radio') {\n return !!selections;\n }\n\n if (selections < minSelections || exceedsMaxSelections(selections, maxSelections)) {\n return false;\n }\n\n return true;\n};\n\nfunction getPlayerAttributes(element) {\n const player =\n element.closest('pie-player') ||\n element.closest('pie-item-player');\n\n if (!player) {\n return { baseHeadingLevel: undefined, includeSrHeading: true };\n }\n\n const getRaw = (camelCaseName, hyphenatedName, allLowerName) => {\n let raw = player[camelCaseName];\n\n // fallback in case someone sets via HTML attribute manually\n if (raw == null) {\n raw =\n player.getAttribute(hyphenatedName) ??\n player.getAttribute(allLowerName);\n }\n\n return raw;\n };\n\n const levelRaw = getRaw('baseHeadingLevel', 'base-heading-level', 'baseheadinglevel');\n const level = parseInt(levelRaw, 10);\n const baseHeadingLevel = Number.isFinite(level) && level >= 1 && level <= 6 ? level : undefined;\n\n const srRaw = getRaw('includeSrHeading', 'include-sr-heading', 'includesrheading');\n const includeSrHeading = srRaw == null ? true : srRaw !== false && srRaw !== 'false';\n\n return { baseHeadingLevel, includeSrHeading };\n}\n\n// Resolves heading attributes for a custom element, preferring explicit instance\n// properties (set by a parent element such as EBSR) over player-level attributes.\nfunction resolveHeadingProps(element) {\n const fromPlayer = getPlayerAttributes(element);\n\n return {\n baseHeadingLevel: element._baseHeadingLevel !== undefined ? element._baseHeadingLevel : fromPlayer.baseHeadingLevel,\n includeSrHeading: element._includeSrHeading !== undefined ? element._includeSrHeading : fromPlayer.includeSrHeading,\n };\n}\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._options = null; // added for ebsr print mode detection\n this.audioComplete = false;\n this._boundHandleKeyDown = this.handleKeyDown.bind(this);\n this._keyboardEventsEnabled = false;\n this._audioInitialized = false;\n this._root = null;\n this._mathObserver = null;\n this._mathRenderPending = false;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n options: this._options,\n onChoiceChanged: this._onChange.bind(this),\n onShowCorrectToggle: this.onShowCorrectToggle.bind(this),\n ...resolveHeadingProps(this),\n });\n\n //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender\n this.setAttribute(\n 'aria-label',\n this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',\n );\n this.setAttribute('role', 'region');\n this.setLangAttribute();\n\n this._initMathObserver();\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n\n if (this._model.keyboardEventsEnabled === true && !this._keyboardEventsEnabled) {\n this.enableKeyboardEvents();\n }\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n ),\n );\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n this._model !== undefined,\n ),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n _scheduleMathRender = () => {\n if (this._mathRenderPending) return;\n this._mathRenderPending = true;\n\n requestAnimationFrame(() => {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n }\n log('render complete - render math');\n renderMath(this);\n this._mathRenderPending = false;\n setTimeout(() => {\n if (this._mathObserver) {\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n }, 50);\n });\n };\n\n _initMathObserver() {\n if (this._mathObserver) return;\n this._mathObserver = new MutationObserver(this._scheduleMathRender);\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n\n _disconnectMathObserver() {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n this._mathObserver = null;\n }\n }\n\n onShowCorrectToggle() {\n renderMath(this);\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio\n this._audioInitialized = false;\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n get options() {\n return this._options;\n }\n\n set options(o) {\n this._options = o;\n this._rerender();\n }\n\n set baseHeadingLevel(level) {\n this._baseHeadingLevel = level;\n this._rerender();\n }\n\n set includeSrHeading(value) {\n this._includeSrHeading = value;\n this._rerender();\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._initMathObserver();\n this._initPlayerObserver();\n this._rerender();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });\n this.audioComplete = true;\n this._dispatchResponseChanged();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n enableKeyboardEvents() {\n if (!this._keyboardEventsEnabled) {\n window.addEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = true;\n }\n }\n\n _initPlayerObserver() {\n const player = this.closest('pie-player') || this.closest('pie-item-player');\n if (!player) return;\n\n this._playerObserver = new MutationObserver(() => {\n this._rerender();\n });\n this._playerObserver.observe(player, {\n attributes: true,\n attributeFilter: ['base-heading-level', 'baseheadinglevel', 'include-sr-heading', 'includesrheading'],\n });\n }\n\n _disconnectPlayerObserver() {\n if (this._playerObserver) {\n this._playerObserver.disconnect();\n this._playerObserver = null;\n }\n }\n\n disconnectedCallback() {\n this._disconnectMathObserver();\n this._disconnectPlayerObserver();\n if (this._keyboardEventsEnabled) {\n window.removeEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = false;\n }\n\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n\n /**\n * Handles global keyboard events for selecting or toggling multiple-choice answers.\n * Maps keys (1-9, 0, a-j, A-J) to choices and updates the session state accordingly.\n * Ensures valid key presses toggle or select the appropriate choice based on the model.\n */\n handleKeyDown(event) {\n if (!this._model || !this._session) {\n return;\n }\n\n const { mode } = this._model;\n if (mode !== 'gather') {\n return;\n }\n\n const keyToIndex = (key) => {\n const numOffset = key >= '1' && key <= '9' ? key - '1' : key === '0' ? 9 : -1;\n const letterOffset = /^[a-jA-J]$/.test(key) ? key.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) : -1;\n return numOffset >= 0 ? numOffset : letterOffset;\n };\n\n const choiceIndex = keyToIndex(event.key);\n\n if (choiceIndex === undefined || choiceIndex <= -1 || choiceIndex >= this._model.choices?.length) {\n return;\n }\n\n const currentValue = this._session.value || [];\n const choiceId = this._model.choices[choiceIndex].value;\n\n const alreadySelected = currentValue.includes(choiceId);\n const newValue = {\n value: choiceId,\n selected: this._model.choiceMode === 'radio' ? true : !alreadySelected,\n selector: 'Keyboard',\n };\n\n this._onChange(newValue);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAEA,MAAMU,GAAG,GAAG,IAAAC,cAAK,EAAC,wBAAwB,CAAC;AAEpC,MAAMC,UAAU,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,aAAa,EAAEC,cAAc,KAAK;EAC3E,MAAM;IAAEC,oBAAoB;IAAEC;EAAqB,CAAC,GAAGJ,KAAK,IAAI,CAAC,CAAC;;EAElE;EACA,IAAIG,oBAAoB,IAAIC,oBAAoB,IAAI,CAACH,aAAa,EAAE;IAClE,IAAIC,cAAc,EAAE;MAClB,MAAMG,KAAK,GAAGH,cAAc,C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ACyJ,eAAe;MACtEI,QAAQ,EAAE;IACZ,CAAC;IAED,IAAI,CAAClG,SAAS,CAACgG,QAAQ,CAAC;EAC1B;AACF;AAACrJ,OAAA,CAAA2B,OAAA,GAAAJ,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_lodashEs","_debug","_piePlayerEvents","_mathRendering","_renderUi","_sessionUpdater","_utils","log","debug","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","audio","querySelector","isInsidePrompt","closest","value","choiceMode","minSelections","maxSelections","selections","length","exceedsMaxSelections","exports","getPlayerAttributes","element","player","baseHeadingLevel","undefined","includeSrHeading","getRaw","camelCaseName","hyphenatedName","allLowerName","raw","getAttribute","levelRaw","level","parseInt","Number","isFinite","srRaw","resolveHeadingProps","fromPlayer","_baseHeadingLevel","_includeSrHeading","MultipleChoice","HTMLElement","constructor","_defineProperty2","default","_mathRenderPending","requestAnimationFrame","_mathObserver","disconnect","renderMath","setTimeout","observe","childList","subtree","_model","_session","_options","_boundHandleKeyDown","handleKeyDown","bind","_keyboardEventsEnabled","_audioInitialized","_root","_rerender","debounce","React","createElement","Main","options","onChoiceChanged","_onChange","onShowCorrectToggle","setAttribute","setLangAttribute","_initMathObserver","createRoot","render","keyboardEventsEnabled","enableKeyboardEvents","leading","trailing","_dispatchResponseChanged","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","_dispatchModelSet","ModelSetEvent","MutationObserver","_scheduleMathRender","_disconnectMathObserver","language","lang","slice","s","o","data","updateSessionValue","_createAudioInfoToast","info","document","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","_initPlayerObserver","observer","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","paused","addEventListener","handlePlaying","updateSessionMetadata","audioStartTime","Date","getTime","handleEnded","audioEndTime","_audio","_handlePlaying","_handleEnded","_enableAudio","window","_playerObserver","attributes","attributeFilter","_disconnectPlayerObserver","disconnectedCallback","unmount","event","mode","keyToIndex","key","numOffset","letterOffset","test","charCodeAt","choiceIndex","choices","currentValue","choiceId","alreadySelected","includes","newValue","selected","selector"],"sources":["../src/index.js"],"sourcesContent":["import Main from './main';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from 'lodash-es';\nimport debug from 'debug';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { updateSessionValue, updateSessionMetadata } from './session-updater';\nimport { exceedsMaxSelections } from './utils';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session, model, audioComplete, elementContext) => {\n const { autoplayAudioEnabled, completeAudioEnabled } = model || {};\n\n // check audio completion if audio settings are enabled and audio actually exists\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('.preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const { choiceMode, minSelections = 1, maxSelections } = model || {};\n const selections = session.value.length || 0;\n\n if (choiceMode === 'radio') {\n return !!selections;\n }\n\n if (selections < minSelections || exceedsMaxSelections(selections, maxSelections)) {\n return false;\n }\n\n return true;\n};\n\nfunction getPlayerAttributes(element) {\n const player =\n element.closest('pie-player') ||\n element.closest('pie-item-player');\n\n if (!player) {\n return { baseHeadingLevel: undefined, includeSrHeading: true };\n }\n\n const getRaw = (camelCaseName, hyphenatedName, allLowerName) => {\n let raw = player[camelCaseName];\n\n // fallback in case someone sets via HTML attribute manually\n if (raw == null) {\n raw =\n player.getAttribute(hyphenatedName) ??\n player.getAttribute(allLowerName);\n }\n\n return raw;\n };\n\n const levelRaw = getRaw('baseHeadingLevel', 'base-heading-level', 'baseheadinglevel');\n const level = parseInt(levelRaw, 10);\n const baseHeadingLevel = Number.isFinite(level) && level >= 1 && level <= 6 ? level : undefined;\n\n const srRaw = getRaw('includeSrHeading', 'include-sr-heading', 'includesrheading');\n const includeSrHeading = srRaw == null ? true : srRaw !== false && srRaw !== 'false';\n\n return { baseHeadingLevel, includeSrHeading };\n}\n\n// Resolves heading attributes for a custom element, preferring explicit instance\n// properties (set by a parent element such as EBSR) over player-level attributes.\nfunction resolveHeadingProps(element) {\n const fromPlayer = getPlayerAttributes(element);\n\n return {\n baseHeadingLevel: element._baseHeadingLevel !== undefined ? element._baseHeadingLevel : fromPlayer.baseHeadingLevel,\n includeSrHeading: element._includeSrHeading !== undefined ? element._includeSrHeading : fromPlayer.includeSrHeading,\n };\n}\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._options = null; // added for ebsr print mode detection\n this.audioComplete = false;\n this._boundHandleKeyDown = this.handleKeyDown.bind(this);\n this._keyboardEventsEnabled = false;\n this._audioInitialized = false;\n this._root = null;\n this._mathObserver = null;\n this._mathRenderPending = false;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n options: this._options,\n onChoiceChanged: this._onChange.bind(this),\n onShowCorrectToggle: this.onShowCorrectToggle.bind(this),\n ...resolveHeadingProps(this),\n });\n\n //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender\n this.setAttribute(\n 'aria-label',\n this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',\n );\n this.setAttribute('role', 'region');\n this.setLangAttribute();\n\n this._initMathObserver();\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n\n if (this._model.keyboardEventsEnabled === true && !this._keyboardEventsEnabled) {\n this.enableKeyboardEvents();\n }\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n ),\n );\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n this._model !== undefined,\n ),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n _scheduleMathRender = () => {\n if (this._mathRenderPending) return;\n this._mathRenderPending = true;\n\n requestAnimationFrame(() => {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n }\n log('render complete - render math');\n renderMath(this);\n this._mathRenderPending = false;\n setTimeout(() => {\n if (this._mathObserver) {\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n }, 50);\n });\n };\n\n _initMathObserver() {\n if (this._mathObserver) return;\n this._mathObserver = new MutationObserver(this._scheduleMathRender);\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n\n _disconnectMathObserver() {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n this._mathObserver = null;\n }\n }\n\n onShowCorrectToggle() {\n renderMath(this);\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio\n this._audioInitialized = false;\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n get options() {\n return this._options;\n }\n\n set options(o) {\n this._options = o;\n this._rerender();\n }\n\n set baseHeadingLevel(level) {\n this._baseHeadingLevel = level;\n this._rerender();\n }\n\n set includeSrHeading(value) {\n this._includeSrHeading = value;\n this._rerender();\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._initMathObserver();\n this._initPlayerObserver();\n this._rerender();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('.preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });\n this.audioComplete = true;\n this._dispatchResponseChanged();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n enableKeyboardEvents() {\n if (!this._keyboardEventsEnabled) {\n window.addEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = true;\n }\n }\n\n _initPlayerObserver() {\n const player = this.closest('pie-player') || this.closest('pie-item-player');\n if (!player) return;\n\n this._playerObserver = new MutationObserver(() => {\n this._rerender();\n });\n this._playerObserver.observe(player, {\n attributes: true,\n attributeFilter: ['base-heading-level', 'baseheadinglevel', 'include-sr-heading', 'includesrheading'],\n });\n }\n\n _disconnectPlayerObserver() {\n if (this._playerObserver) {\n this._playerObserver.disconnect();\n this._playerObserver = null;\n }\n }\n\n disconnectedCallback() {\n this._disconnectMathObserver();\n this._disconnectPlayerObserver();\n if (this._keyboardEventsEnabled) {\n window.removeEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = false;\n }\n\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n\n /**\n * Handles global keyboard events for selecting or toggling multiple-choice answers.\n * Maps keys (1-9, 0, a-j, A-J) to choices and updates the session state accordingly.\n * Ensures valid key presses toggle or select the appropriate choice based on the model.\n */\n handleKeyDown(event) {\n if (!this._model || !this._session) {\n return;\n }\n\n const { mode } = this._model;\n if (mode !== 'gather') {\n return;\n }\n\n const keyToIndex = (key) => {\n const numOffset = key >= '1' && key <= '9' ? key - '1' : key === '0' ? 9 : -1;\n const letterOffset = /^[a-jA-J]$/.test(key) ? key.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) : -1;\n return numOffset >= 0 ? numOffset : letterOffset;\n };\n\n const choiceIndex = keyToIndex(event.key);\n\n if (choiceIndex === undefined || choiceIndex <= -1 || choiceIndex >= this._model.choices?.length) {\n return;\n }\n\n const currentValue = this._session.value || [];\n const choiceId = this._model.choices[choiceIndex].value;\n\n const alreadySelected = currentValue.includes(choiceId);\n const newValue = {\n value: choiceId,\n selected: this._model.choiceMode === 'radio' ? true : !alreadySelected,\n selector: 'Keyboard',\n };\n\n this._onChange(newValue);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAEA,MAAMU,GAAG,GAAG,IAAAC,cAAK,EAAC,wBAAwB,CAAC;AAEpC,MAAMC,UAAU,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,aAAa,EAAEC,cAAc,KAAK;EAC3E,MAAM;IAAEC,oBAAoB;IAAEC;EAAqB,CAAC,GAAGJ,KAAK,IAAI,CAAC,CAAC;;EAElE;EACA,IAAIG,oBAAoB,IAAIC,oBAAoB,IAAI,CAACH,aA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E,IAAI,CAACjH,MAAM,CAAC3C,UAAU,KAAK,OAAO,GAAG,IAAI,GAAG,CAACyJ,eAAe;MACtEI,QAAQ,EAAE;IACZ,CAAC;IAED,IAAI,CAAClG,SAAS,CAACgG,QAAQ,CAAC;EAC1B;AACF;AAACrJ,OAAA,CAAA2B,OAAA,GAAAJ,cAAA","ignoreList":[]}
@@ -1 +1 @@
1
- import{_dll_react as e,_dll_prop_types as t,_dll_mui__material_styles as n,_dll_pie_lib__render_ui as o,_dll_mui__material as i,_dll_mui__icons_material as r,_dll_debug as a,_dll_react_dom_client as s}from"../../../@pie-lib/shared-module@^5.2.14/module/index.js";import{_dll_pie_lib__config_ui as l}from"../../../@pie-lib/config-module@^4.0.19/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as c}from"../../../@pie-lib/editable-html-module@^7.1.16/module/index.js";var u={};Object.defineProperty(u,"__esModule",{value:!0});class d extends CustomEvent{constructor(e,t=!1){super(d.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}d.TYPE="model.updated";var h=u.ModelUpdatedEvent=d;class p extends CustomEvent{constructor(e,t){super(p.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}p.TYPE="delete.image";var g=u.DeleteImageEvent=p;class f extends CustomEvent{constructor(e){super(f.TYPE,{bubbles:!0,detail:e}),this.handler=e}}f.TYPE="insert.image";var b=u.InsertImageEvent=f;class m extends CustomEvent{constructor(e,t){super(m.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}m.TYPE="delete.sound";var _=u.DeleteSoundEvent=m;class y extends CustomEvent{constructor(e){super(y.TYPE,{bubbles:!0,detail:e}),this.handler=e}}y.TYPE="insert.sound";var C=u.InsertSoundEvent=y,v="object"==typeof global&&global&&global.Object===Object&&global,E="object"==typeof self&&self&&self.Object===Object&&self,j=v||E||Function("return this")(),A=j.Symbol,S=Object.prototype,x=S.hasOwnProperty,w=S.toString,O=A?A.toStringTag:void 0,P=Object.prototype.toString,I=A?A.toStringTag:void 0;function k(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":I&&I in Object(e)?function(e){var t=x.call(e,O),n=e[O];try{e[O]=void 0;var o=!0}catch(e){}var i=w.call(e);return o&&(t?e[O]=n:delete e[O]),i}(e):function(e){return P.call(e)}(e)}function M(e){return null!=e&&"object"==typeof e}var T=Array.isArray;function z(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function R(e){return e}function L(e){if(!z(e))return!1;var t=k(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var D,q=j["__core-js_shared__"],F=(D=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+D:"",U=Function.prototype.toString,$=/^\[object .+?Constructor\]$/,B=Function.prototype,W=Object.prototype,Y=B.toString,H=W.hasOwnProperty,N=RegExp("^"+Y.call(H).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function G(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!z(e)||(t=e,F&&F in t))&&(L(e)?N:$).test(function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}(n)?n:void 0}var V,J,K,Q=Object.create,X=function(){function e(){}return function(t){if(!z(t))return{};if(Q)return Q(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),Z=Date.now,ee=function(){try{var e=G(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),te=ee,ne=te?function(e,t){return te(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:R,oe=(V=ne,J=0,K=0,function(){var e=Z(),t=16-(e-K);if(K=e,t>0){if(++J>=800)return arguments[0]}else J=0;return V.apply(void 0,arguments)}),ie=/^(?:0|[1-9]\d*)$/;function re(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&ie.test(e))&&e>-1&&e%1==0&&e<t}function ae(e,t,n){"__proto__"==t&&te?te(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function se(e,t){return e===t||e!=e&&t!=t}var le=Object.prototype.hasOwnProperty;function ce(e,t,n){var o=e[t];le.call(e,t)&&se(o,n)&&(void 0!==n||t in e)||ae(e,t,n)}var ue=Math.max;function de(e,t){return oe(function(e,t,n){return t=ue(void 0===t?e.length-1:t,0),function(){for(var o=arguments,i=-1,r=ue(o.length-t,0),a=Array(r);++i<r;)a[i]=o[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=o[i];return s[t]=n(a),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,s)}}(e,t,R),e+"")}function he(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function pe(e){return null!=e&&he(e.length)&&!L(e)}function ge(e,t,n){if(!z(n))return!1;var o=typeof t;return!!("number"==o?pe(n)&&re(t,n.length):"string"==o&&t in n)&&se(n[t],e)}var fe=Object.prototype;function be(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||fe)}function me(e){return M(e)&&"[object Arguments]"==k(e)}var _e=Object.prototype,ye=_e.hasOwnProperty,Ce=_e.propertyIsEnumerable,ve=me(function(){return arguments}())?me:function(e){return M(e)&&ye.call(e,"callee")&&!Ce.call(e,"callee")},Ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,je=Ee&&"object"==typeof module&&module&&!module.nodeType&&module,Ae=je&&je.exports===Ee?j.Buffer:void 0,Se=(Ae?Ae.isBuffer:void 0)||function(){return!1},xe={};xe["[object Float32Array]"]=xe["[object Float64Array]"]=xe["[object Int8Array]"]=xe["[object Int16Array]"]=xe["[object Int32Array]"]=xe["[object Uint8Array]"]=xe["[object Uint8ClampedArray]"]=xe["[object Uint16Array]"]=xe["[object Uint32Array]"]=!0,xe["[object Arguments]"]=xe["[object Array]"]=xe["[object ArrayBuffer]"]=xe["[object Boolean]"]=xe["[object DataView]"]=xe["[object Date]"]=xe["[object Error]"]=xe["[object Function]"]=xe["[object Map]"]=xe["[object Number]"]=xe["[object Object]"]=xe["[object RegExp]"]=xe["[object Set]"]=xe["[object String]"]=xe["[object WeakMap]"]=!1;var we="object"==typeof exports&&exports&&!exports.nodeType&&exports,Oe=we&&"object"==typeof module&&module&&!module.nodeType&&module,Pe=Oe&&Oe.exports===we&&v.process,Ie=function(){try{return Oe&&Oe.require&&Oe.require("util").types||Pe&&Pe.binding&&Pe.binding("util")}catch(e){}}(),ke=Ie&&Ie.isTypedArray,Me=ke?function(e){return function(t){return e(t)}}(ke):function(e){return M(e)&&he(e.length)&&!!xe[k(e)]},Te=Me,ze=Object.prototype.hasOwnProperty;var Re=Object.prototype.hasOwnProperty;function Le(e){return pe(e)?function(e,t){var n=T(e),o=!n&&ve(e),i=!n&&!o&&Se(e),r=!n&&!o&&!i&&Te(e),a=n||o||i||r,s=a?function(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}(e.length,String):[],l=s.length;for(var c in e)!t&&!ze.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||re(c,l))||s.push(c);return s}(e,!0):function(e){if(!z(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=be(e),n=[];for(var o in e)("constructor"!=o||!t&&Re.call(e,o))&&n.push(o);return n}(e)}var De=G(Object,"create"),qe=Object.prototype.hasOwnProperty,Fe=Object.prototype.hasOwnProperty;function Ue(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function $e(e,t){for(var n=e.length;n--;)if(se(e[n][0],t))return n;return-1}Ue.prototype.clear=function(){this.__data__=De?De(null):{},this.size=0},Ue.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ue.prototype.get=function(e){var t=this.__data__;if(De){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return qe.call(t,e)?t[e]:void 0},Ue.prototype.has=function(e){var t=this.__data__;return De?void 0!==t[e]:Fe.call(t,e)},Ue.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=De&&void 0===t?"__lodash_hash_undefined__":t,this};var Be=Array.prototype.splice;function We(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}We.prototype.clear=function(){this.__data__=[],this.size=0},We.prototype.delete=function(e){var t=this.__data__,n=$e(t,e);return!(n<0||(n==t.length-1?t.pop():Be.call(t,n,1),--this.size,0))},We.prototype.get=function(e){var t=this.__data__,n=$e(t,e);return n<0?void 0:t[n][1]},We.prototype.has=function(e){return $e(this.__data__,e)>-1},We.prototype.set=function(e,t){var n=this.__data__,o=$e(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this};var Ye=G(j,"Map");function He(e,t){var n,o,i=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function Ne(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}Ne.prototype.clear=function(){this.size=0,this.__data__={hash:new Ue,map:new(Ye||We),string:new Ue}},Ne.prototype.delete=function(e){var t=He(this,e).delete(e);return this.size-=t?1:0,t},Ne.prototype.get=function(e){return He(this,e).get(e)},Ne.prototype.has=function(e){return He(this,e).has(e)},Ne.prototype.set=function(e,t){var n=He(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this};var Ge=function(e,t){return function(n){return e(t(n))}}(Object.getPrototypeOf,Object),Ve=Ge,Je=Function.prototype,Ke=Object.prototype,Qe=Je.toString,Xe=Ke.hasOwnProperty,Ze=Qe.call(Object);function et(e){var t=this.__data__=new We(e);this.size=t.size}et.prototype.clear=function(){this.__data__=new We,this.size=0},et.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},et.prototype.get=function(e){return this.__data__.get(e)},et.prototype.has=function(e){return this.__data__.has(e)},et.prototype.set=function(e,t){var n=this.__data__;if(n instanceof We){var o=n.__data__;if(!Ye||o.length<199)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new Ne(o)}return n.set(e,t),this.size=n.size,this};var tt="object"==typeof exports&&exports&&!exports.nodeType&&exports,nt=tt&&"object"==typeof module&&module&&!module.nodeType&&module,ot=nt&&nt.exports===tt?j.Buffer:void 0,it=(ot&&ot.allocUnsafe,j.Uint8Array);var rt=Object.prototype,at=rt.hasOwnProperty,st=de(function(e,t){e=Object(e);var n=-1,o=t.length,i=o>2?t[2]:void 0;for(i&&ge(t[0],t[1],i)&&(o=1);++n<o;)for(var r=t[n],a=Le(r),s=-1,l=a.length;++s<l;){var c=a[s],u=e[c];(void 0===u||se(u,rt[c])&&!at.call(e,c))&&(e[c]=r[c])}return e});function lt(e,t,n){(void 0!==n&&!se(e[t],n)||void 0===n&&!(t in e))&&ae(e,t,n)}function ct(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function ut(e,t,n,o,i,r,a){var s=ct(e,n),l=ct(t,n),c=a.get(l);if(c)lt(e,n,c);else{var u,d=r?r(s,l,n+"",e,t,a):void 0,h=void 0===d;if(h){var p=T(l),g=!p&&Se(l),f=!p&&!g&&Te(l);d=l,p||g||f?T(s)?d=s:M(u=s)&&pe(u)?d=function(e,t){var n=-1,o=e.length;for(t||(t=Array(o));++n<o;)t[n]=e[n];return t}(s):g?(h=!1,d=function(e){return e.slice()}(l)):f?(h=!1,d=function(e,t){var n,o,i=t?(o=new(n=e.buffer).constructor(n.byteLength),new it(o).set(new it(n)),o):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}(l,!0)):d=[]:function(e){if(!M(e)||"[object Object]"!=k(e))return!1;var t=Ve(e);if(null===t)return!0;var n=Xe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Qe.call(n)==Ze}(l)||ve(l)?(d=s,ve(s)?d=function(e){return function(e,t,n){var o=!n;n||(n={});for(var i=-1,r=t.length;++i<r;){var a=t[i],s=void 0;void 0===s&&(s=e[a]),o?ae(n,a,s):ce(n,a,s)}return n}(e,Le(e))}(s):z(s)&&!L(s)||(d=function(e){return"function"!=typeof e.constructor||be(e)?{}:X(Ve(e))}(l))):h=!1}h&&(a.set(l,d),i(d,l,o,r,a),a.delete(l)),lt(e,n,d)}}function dt(e,t,n,o,i){e!==t&&function(e,t,n){for(var o=-1,i=Object(e),r=n(e),a=r.length;a--;){var s=r[++o];if(!1===t(i[s],s,i))break}}(t,function(r,a){if(i||(i=new et),z(r))ut(e,t,a,n,dt,o,i);else{var s=o?o(ct(e,a),r,a+"",e,t,i):void 0;void 0===s&&(s=r),lt(e,a,s)}},Le)}var ht,pt=(ht=function(e,t,n){dt(e,t,n)},de(function(e,t){var n=-1,o=t.length,i=o>1?t[o-1]:void 0,r=o>2?t[2]:void 0;for(i=ht.length>3&&"function"==typeof i?(o--,i):void 0,r&&ge(t[0],t[1],r)&&(i=o<3?void 0:i,o=1),e=Object(e);++n<o;){var a=t[n];a&&ht(e,a,n)}return e}));const gt=e,ft=t,{styled:bt}=n,{color:mt}=o,{Button:_t}=i,{Tooltip:yt}=i,{Typography:Ct}=i,{Box:vt}=i,{Info:Et}=r,jt=c,{AlertDialog:At}=l,{InputContainer:St}=l,{ChoiceConfiguration:xt}=l,{settings:wt}=l,{layout:Ot}=l,{choiceUtils:Pt}=l;function It(e){let t,n=e[0],o=1;for(;o<e.length;){const i=e[o],r=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=r(n)):"call"!==i&&"optionalCall"!==i||(n=r((...e)=>n.call(t,...e)),t=void 0)}return n}const{Panel:kt,toggle:Mt,radio:Tt,dropdown:zt}=wt,Rt=bt(St)(({theme:e})=>({width:"100%",paddingTop:e.spacing(2),marginBottom:e.spacing(2)})),Lt=bt(St)(({theme:e})=>({flex:1,marginTop:e.spacing(1.5),paddingTop:e.spacing(2),marginLeft:e.spacing(3.5)})),Dt=bt(St)(({theme:e})=>({display:"flex",flexDirection:"column",marginBottom:e.spacing(1),width:"100%"})),qt=bt(_t)(({theme:e})=>({marginTop:e.spacing(1),float:"right"})),Ft=bt(qt)({cursor:"not-allowed",pointerEvents:"all",backgroundColor:mt.disabled(),"&:hover":{backgroundColor:mt.disabled()},"&:focus":{backgroundColor:mt.disabled()}}),Ut=bt(vt)({display:"flex",alignItems:"center"}),$t=bt(Ct)(({theme:e})=>({fontSize:e.typography.fontSize+2,marginRight:e.spacing(1)})),Bt=bt(yt)(({theme:e})=>({"& .MuiTooltip-tooltip":{fontSize:e.typography.fontSize-2,whiteSpace:"pre",maxWidth:"500px"}})),Wt=bt("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)})),Yt=e=>{const{model:t,configuration:n,onPromptChanged:o,onChoiceChanged:i,onRemoveChoice:r,onAddChoice:a,imageSupport:s,uploadSoundSupport:l,onChangeModel:c,onConfigurationChanged:u,onTeacherInstructionsChanged:d}=e,{addChoiceButton:h={},contentDimensions:p={},feedback:g={},deleteChoice:f={},choiceMode:b={},choicePrefix:m={},partialScoring:_={},lockChoiceOrder:y={},teacherInstructions:C={},studentInstructions:v={},rationale:E={},scoringType:j={},sequentialChoiceLabels:A={},settingsPanelDisabled:S,choicesLayout:x,spellCheck:w={},gridColumns:O,maxImageWidth:P={},maxImageHeight:I={},prompt:k={},withRubric:M={},mathMlOptions:T={},language:z={},languageChoices:R={}}=n||{};let{maxAnswerChoices:L}=n||{};const{limitChoicesNumber:D,teacherInstructionsEnabled:q,rationaleEnabled:F,feedbackEnabled:U,promptEnabled:$,spellCheckEnabled:B,choices:W,errors:Y,toolbarEditorPosition:H,extraCSSRules:N}=t||{},{answerChoices:G,choices:V,correctResponse:J,prompt:K,rationale:Q,teacherInstructions:X}=Y||{},Z=It([W,"optionalAccess",e=>e.length])?Array.from({length:W.length},(e,t)=>`${t+1}`):[],{baseInputConfiguration:ee={}}=n,te={position:"top"===H?"top":"bottom"};D&&(L=9);const ne=(e={})=>({...ee,...e}),oe=(e=>{const{minAnswerChoices:t,maxAnswerChoices:n}=e;return`Validation requirements:\nThere should be at least ${t} `+(n?`and at most ${n} `:"")+"answer choices defined.\nEvery answer choice should be non-blank and unique.\nA correct answer must be defined."})(n),ie=P&&P.prompt,re=I&&I.prompt,ae=L&&It([W,"optionalAccess",e=>e.length])>=L?`Only ${L} allowed maximum`:"",se={choiceMode:b.settings&&Tt(b.label,["checkbox","radio"]),"sequentialChoiceLabels.enabled":A.settings&&Mt(A.label,!0),choicePrefix:m.settings&&Tt(m.label,["numbers","letters"]),partialScoring:_.settings&&Mt(_.label),lockChoiceOrder:y.settings&&Mt(y.label),feedbackEnabled:g.settings&&Mt(g.label),choicesLayout:x.settings&&zt(x.label,["vertical","grid","horizontal"]),gridColumns:x.settings&&"grid"===t.choicesLayout&&Z.length>0&&zt(O.label,Z),"language.enabled":z.settings&&Mt(z.label,!0),language:z.settings&&z.enabled&&zt(R.label,R.options)},le={teacherInstructionsEnabled:C.settings&&Mt(C.label),studentInstructionsEnabled:v.settings&&Mt(v.label),promptEnabled:k.settings&&Mt(k.label),rationaleEnabled:E.settings&&Mt(E.label),spellCheckEnabled:w.settings&&Mt(w.label),scoringType:j.settings&&Tt(j.label,["auto","rubric"]),rubricEnabled:It([M,"optionalAccess",e=>e.settings])&&Mt(It([M,"optionalAccess",e=>e.label]))};return gt.createElement(Ot.ConfigLayout,{dimensions:p,hideSettings:S,extraCSSRules:N,classes:{},settings:gt.createElement(kt,{model:t,onChangeModel:c,configuration:n,onChangeConfiguration:u,groups:{Settings:se,Properties:le}})},q&&gt.createElement(Rt,{label:C.label},gt.createElement(jt,{markup:t.teacherInstructions||"",onChange:d,imageSupport:s,nonEmpty:!1,disableUnderline:!0,error:X,toolbarOpts:te,pluginProps:ne(It([n,"optionalAccess",e=>e.teacherInstructions,"optionalAccess",e=>e.inputConfiguration])),spellCheck:B,maxImageWidth:P&&P.teacherInstructions||ie,maxImageHeight:I&&I.teacherInstructions||re,uploadSoundSupport:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:T}),X&&gt.createElement(Wt,null,X)),$&&gt.createElement(Rt,{label:k.label},gt.createElement(jt,{markup:t.prompt,onChange:o,imageSupport:s,nonEmpty:!1,disableUnderline:!0,error:K,toolbarOpts:te,pluginProps:ne(It([n,"optionalAccess",e=>e.prompt,"optionalAccess",e=>e.inputConfiguration])),spellCheck:B,maxImageWidth:P&&P.prompt,maxImageHeight:I&&I.prompt,uploadSoundSupport:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:T}),K&&gt.createElement(Wt,null,K)),gt.createElement(Ut,null,gt.createElement($t,{component:"div"},"Choices"),gt.createElement(Bt,{disableFocusListener:!0,disableTouchListener:!0,placement:"right",title:oe},gt.createElement(Et,{fontSize:"small",color:"primary"}))),W.map((e,o)=>gt.createElement(Dt,{key:`choice-${o}`},gt.createElement(xt,{key:o,index:o+1,useLetterOrdering:"letters"===t.choicePrefix,mode:t.choiceMode,data:e,defaultFeedback:{},imageSupport:s,disableImageAlignmentButtons:!0,onDelete:()=>r(o),onChange:e=>i(o,e),allowFeedBack:U,allowDelete:f.settings,noLabels:!0,pluginOpts:ne(It([n,"optionalAccess",e=>e.choices,"optionalAccess",e=>e.inputConfiguration])),toolbarOpts:te,spellCheck:B,error:It([V,"optionalAccess",t=>t[e.value]])||null,noCorrectAnswerError:J,maxImageWidth:P&&P.choices||ie,maxImageHeight:I&&I.choices||re,uploadSoundSupport:l,mathMlOptions:T}),F&&gt.createElement(Lt,{key:`rationale-${o}`,label:E.label},gt.createElement(jt,{markup:e.rationale||"",onChange:t=>i(o,{...e,rationale:t}),imageSupport:s,error:It([Q,"optionalAccess",t=>t[e.value]])||null,toolbarOpts:te,pluginProps:ne(It([n,"optionalAccess",e=>e.rationale,"optionalAccess",e=>e.inputConfiguration])),spellCheck:B,maxImageWidth:P&&P.rationale||ie,maxImageHeight:I&&I.rationale||re,uploadSoundSupport:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:T}),It([Q,"optionalAccess",t=>t[e.value]])&&gt.createElement(Wt,null,It([Q,"optionalAccess",t=>t[e.value]]))))),J&&gt.createElement(Wt,null,J),G&&gt.createElement(Wt,null,G),h.settings&&gt.createElement(Bt,{title:ae},L&&It([W,"optionalAccess",e=>e.length])>=L?gt.createElement(Ft,{variant:"contained",color:"primary",onClick:a,disabled:!0},h.label):gt.createElement(qt,{variant:"contained",color:"primary",onClick:a},h.label)))};class Ht extends gt.Component{constructor(...e){super(...e),Ht.prototype.__init.call(this),Ht.prototype.__init2.call(this),Ht.prototype.__init3.call(this),Ht.prototype.__init4.call(this),Ht.prototype.__init5.call(this),Ht.prototype.__init6.call(this),Ht.prototype.__init7.call(this)}static __initStatic(){this.propTypes={model:ft.object.isRequired,configuration:ft.object.isRequired,disableSidePanel:ft.bool,onModelChanged:ft.func.isRequired,onConfigurationChanged:ft.func.isRequired,imageSupport:ft.shape({add:ft.func.isRequired,delete:ft.func.isRequired})}}__init(){this.state={showWarning:!1}}__init2(){this.onRemoveChoice=e=>{const{model:t,configuration:n,onModelChanged:o}=this.props,{minAnswerChoices:i}=n||{};i&&t.choices.length===i?this.setState({showWarning:!0}):(t.choices.splice(e,1),o({choices:t.choices}))}}__init3(){this.onAddChoice=()=>{const{model:e,configuration:t,onModelChanged:n}=this.props;let{maxAnswerChoices:o}=t||{};const{limitChoicesNumber:i}=e||{};i&&(o=9),o&&e.choices.length>=o||(e.choices.push({label:"",value:Pt.firstAvailableIndex(e.choices.map(e=>e.value),0),feedback:{type:"none"}}),n({choices:e.choices}))}}__init4(){this.onChoiceChanged=(e,t)=>{const{model:n,onModelChanged:o}=this.props;t.correct&&"radio"===n.choiceMode&&(n.choices=n.choices.map(e=>pt({},e,{correct:!1}))),n.choices.splice(e,1,t),o({choices:n.choices})}}__init5(){this.onPromptChanged=e=>{this.props.onModelChanged({prompt:e})}}__init6(){this.onTeacherInstructionsChanged=e=>{this.props.onModelChanged({teacherInstructions:e})}}__init7(){this.onModelChanged=(e,t)=>{const{onModelChanged:n}=this.props;if("choiceMode"===t){if("radio"===e.choiceMode){let t=!1;e.choices=e.choices.map(e=>t?(e.correct=!1,e):(e.correct&&(t=!0),e))}n({choiceMode:e.choiceMode,choices:e.choices},!0)}else n(e)}}render(){const{configuration:{minAnswerChoices:e}={}}=this.props,{showWarning:t}=this.state;return gt.createElement(gt.Fragment,null,gt.createElement(At,{open:t,title:"Warning",text:`There can't be less than ${e||0} choices.`,onConfirm:()=>this.setState({showWarning:!1})}),gt.createElement(Yt,{...this.props,onChangeModel:this.onModelChanged,onRemoveChoice:this.onRemoveChoice,onChoiceChanged:this.onChoiceChanged,onAddChoice:this.onAddChoice,onPromptChanged:this.onPromptChanged,onTeacherInstructionsChanged:this.onTeacherInstructionsChanged}))}}Ht.__initStatic();var Nt={choiceMode:"checkbox",choicePrefix:"letters",choices:[],choicesLayout:"vertical",feedbackEnabled:!1,gridColumns:2,lockChoiceOrder:!0,partialScoring:!0,prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,scoringType:"auto",studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom",selectedAnswerBackgroundColor:"initial",keyboardEventsEnabled:!1},Gt={baseInputConfiguration:{h3:{disabled:!0},audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},choices:{inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}}},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},choicesLayout:{settings:!1,label:"Choices Layout"},gridColumns:{label:"Grid columns"},answerChoiceCount:0,addChoiceButton:{settings:!0,label:"Add a Choice"},choiceMode:{settings:!0,label:"Response Type"},choicePrefix:{settings:!0,label:"Choice Labels"},deleteChoice:{settings:!0},feedback:{settings:!0,label:"Feedback"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},lockChoiceOrder:{settings:!0,label:"Lock Choice Order"},partialScoring:{settings:!1,label:"Allow Partial Scoring"},rationale:{settings:!0,label:"Rationale",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!1}},required:!1},scoringType:{settings:!1,label:"Scoring Type"},studentInstructions:{settings:!1,label:"Student Instructions"},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},toolbarEditorPosition:{settings:!1,label:"Toolbar Editor Position"},minAnswerChoices:2,maxAnswerChoices:5,maxImageWidth:{teacherInstructions:300,prompt:300,rationale:636,choices:900},maxImageHeight:{teacherInstructions:300,prompt:300,rationale:300,choices:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]}};const Vt=e,{createRoot:Jt}=s,Kt=a,{choiceUtils:Qt}=l;function Xt(e){let t,n=e[0],o=1;for(;o<e.length;){const i=e[o],r=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=r(n)):"call"!==i&&"optionalCall"!==i||(n=r((...e)=>n.call(t,...e)),t=void 0)}return n}const Zt=Kt("multiple-choice:configure"),en=(e,t=0)=>{if(!e||0===e.length){let e=[];for(let n=0;n<t;n++)e.push({value:`${n}`,label:"",feedback:{type:"none",value:""}});return e}return e},tn=(e,t)=>{const n=st(e,Gt);return{configuration:n,model:{...t,choices:en(t&&t.choices||[],n&&n.answerChoiceCount)}}};class nn extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>{const t=Qt.normalizeChoices({...Nt,...e,choices:en(e&&e.choices||[])});return t.choicesLayout=e.choicesLayout||!1===e.verticalMode&&"horizontal"||Nt.choicesLayout,t}}constructor(){super(),this._root=null,this._reactContainer=null,this._model=nn.createDefaultModel(),this._configuration=Gt,this.onModelChanged=this.onModelChanged.bind(this),this.onConfigurationChanged=this.onConfigurationChanged.bind(this)}set model(e){this._model=nn.createDefaultModel(e),this._render()}set configuration(e){const t=tn(e,this._model);this.onModelChanged(t.model);const n={...Gt,...t.configuration};this._configuration=n,Xt([n,"optionalAccess",e=>e.language,"optionalAccess",e=>e.enabled])?Xt([n,"optionalAccess",e=>e.languageChoices,"optionalAccess",e=>e.options,"optionalAccess",e=>e.length])&&(this._model.language=Xt([n,"optionalAccess",e=>e.languageChoices,"access",e=>e.options,"access",e=>e[0],"access",e=>e.value])):n.language.settings&&this._model.language?(this._configuration.language.enabled=!0,this._configuration.languageChoices.options&&this._configuration.languageChoices.options.length||(this._configuration.languageChoices.options=[]),this._configuration.languageChoices.options.find(e=>e.value===this._model.language)||this._configuration.languageChoices.options.push({value:this._model.language,label:this._model.language})):delete this._model.language,this._render()}set disableSidePanel(e){this._disableSidePanel=e,this._render()}dispatchModelUpdated(e){const t=!!e;this.dispatchEvent(new h(this._model,t))}onModelChanged(e,t){this._model={...this._model,...e},this._render(),this.dispatchModelUpdated(t)}onConfigurationChanged(e){this._configuration=tn(e,this._model).configuration,this._model&&this.onModelChanged(this._model),this._render()}insertImage(e){this.dispatchEvent(new b(e))}onDeleteImage(e,t){this.dispatchEvent(new g(e,t))}insertSound(e){this.dispatchEvent(new C(e))}onDeleteSound(e,t){this.dispatchEvent(new _(e,t))}_render(){Zt("_render - Starting render"),Zt("_render - Model:",this._model?"present":"missing"),Zt("_render - Configuration:",this._configuration?"present":"missing"),Zt("_render - Root exists:",!!this._root);try{let e=Vt.createElement(Ht,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged,onConfigurationChanged:this.onConfigurationChanged,disableSidePanel:this._disableSidePanel,imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(Zt("_render - Creating React container"),this._reactContainer=document.createElement("div"),this._reactContainer.className="pie-configure-wrapper",this.appendChild(this._reactContainer),Zt("_render - Creating new React root"),this._root=Jt(this._reactContainer),Zt("_render - React root created successfully")),Zt("_render - Calling root.render()"),this._root.render(e),Zt("_render - Render completed successfully")}catch(e){throw console.error("❌ [multiple-choice-configure] Render error:",e),console.error("Error stack:",e.stack),e}}connectedCallback(){Zt("connectedCallback - Component connected to DOM"),Zt("connectedCallback - Model:",this._model?"present":"missing"),Zt("connectedCallback - Configuration:",this._configuration?"present":"missing"),this._render()}disconnectedCallback(){Zt("disconnectedCallback - Component disconnected from DOM"),this._root&&(Zt("disconnectedCallback - Unmounting React root"),this._root.unmount(),this._root=null),this._reactContainer&&(this._reactContainer=null)}}nn.__initStatic();export{nn as default};
1
+ import{_dll_react as e,_dll_prop_types as t,_dll_mui__material_styles as n,_dll_pie_lib__render_ui as o,_dll_mui__material as i,_dll_mui__icons_material as r,_dll_debug as a,_dll_react_dom_client as s}from"../../../@pie-lib/shared-module@6.0.0/module/index.js";import{_dll_pie_lib__config_ui as l}from"../../../@pie-lib/config-module@5.0.0/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as c}from"../../../@pie-lib/editable-html-module@8.0.0/module/index.js";var u={};Object.defineProperty(u,"__esModule",{value:!0});class d extends CustomEvent{constructor(e,t=!1){super(d.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}d.TYPE="model.updated";var h=u.ModelUpdatedEvent=d;class p extends CustomEvent{constructor(e,t){super(p.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}p.TYPE="delete.image";var g=u.DeleteImageEvent=p;class f extends CustomEvent{constructor(e){super(f.TYPE,{bubbles:!0,detail:e}),this.handler=e}}f.TYPE="insert.image";var b=u.InsertImageEvent=f;class m extends CustomEvent{constructor(e,t){super(m.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}m.TYPE="delete.sound";var _=u.DeleteSoundEvent=m;class y extends CustomEvent{constructor(e){super(y.TYPE,{bubbles:!0,detail:e}),this.handler=e}}y.TYPE="insert.sound";var C=u.InsertSoundEvent=y,v="object"==typeof global&&global&&global.Object===Object&&global,E="object"==typeof self&&self&&self.Object===Object&&self,j=v||E||Function("return this")(),A=j.Symbol,S=Object.prototype,x=S.hasOwnProperty,w=S.toString,O=A?A.toStringTag:void 0,P=Object.prototype.toString,I=A?A.toStringTag:void 0;function k(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":I&&I in Object(e)?function(e){var t=x.call(e,O),n=e[O];try{e[O]=void 0;var o=!0}catch(e){}var i=w.call(e);return o&&(t?e[O]=n:delete e[O]),i}(e):function(e){return P.call(e)}(e)}function M(e){return null!=e&&"object"==typeof e}var T=Array.isArray;function z(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function R(e){return e}function L(e){if(!z(e))return!1;var t=k(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var D,q=j["__core-js_shared__"],F=(D=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+D:"",U=Function.prototype.toString,$=/^\[object .+?Constructor\]$/,B=Function.prototype,W=Object.prototype,Y=B.toString,H=W.hasOwnProperty,N=RegExp("^"+Y.call(H).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function G(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!z(e)||(t=e,F&&F in t))&&(L(e)?N:$).test(function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}(n)?n:void 0}var V,J,K,Q=Object.create,X=function(){function e(){}return function(t){if(!z(t))return{};if(Q)return Q(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),Z=Date.now,ee=function(){try{var e=G(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),te=ee,ne=te?function(e,t){return te(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:R,oe=(V=ne,J=0,K=0,function(){var e=Z(),t=16-(e-K);if(K=e,t>0){if(++J>=800)return arguments[0]}else J=0;return V.apply(void 0,arguments)}),ie=/^(?:0|[1-9]\d*)$/;function re(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&ie.test(e))&&e>-1&&e%1==0&&e<t}function ae(e,t,n){"__proto__"==t&&te?te(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function se(e,t){return e===t||e!=e&&t!=t}var le=Object.prototype.hasOwnProperty;function ce(e,t,n){var o=e[t];le.call(e,t)&&se(o,n)&&(void 0!==n||t in e)||ae(e,t,n)}var ue=Math.max;function de(e,t){return oe(function(e,t,n){return t=ue(void 0===t?e.length-1:t,0),function(){for(var o=arguments,i=-1,r=ue(o.length-t,0),a=Array(r);++i<r;)a[i]=o[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=o[i];return s[t]=n(a),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,s)}}(e,t,R),e+"")}function he(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function pe(e){return null!=e&&he(e.length)&&!L(e)}function ge(e,t,n){if(!z(n))return!1;var o=typeof t;return!!("number"==o?pe(n)&&re(t,n.length):"string"==o&&t in n)&&se(n[t],e)}var fe=Object.prototype;function be(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||fe)}function me(e){return M(e)&&"[object Arguments]"==k(e)}var _e=Object.prototype,ye=_e.hasOwnProperty,Ce=_e.propertyIsEnumerable,ve=me(function(){return arguments}())?me:function(e){return M(e)&&ye.call(e,"callee")&&!Ce.call(e,"callee")},Ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,je=Ee&&"object"==typeof module&&module&&!module.nodeType&&module,Ae=je&&je.exports===Ee?j.Buffer:void 0,Se=(Ae?Ae.isBuffer:void 0)||function(){return!1},xe={};xe["[object Float32Array]"]=xe["[object Float64Array]"]=xe["[object Int8Array]"]=xe["[object Int16Array]"]=xe["[object Int32Array]"]=xe["[object Uint8Array]"]=xe["[object Uint8ClampedArray]"]=xe["[object Uint16Array]"]=xe["[object Uint32Array]"]=!0,xe["[object Arguments]"]=xe["[object Array]"]=xe["[object ArrayBuffer]"]=xe["[object Boolean]"]=xe["[object DataView]"]=xe["[object Date]"]=xe["[object Error]"]=xe["[object Function]"]=xe["[object Map]"]=xe["[object Number]"]=xe["[object Object]"]=xe["[object RegExp]"]=xe["[object Set]"]=xe["[object String]"]=xe["[object WeakMap]"]=!1;var we="object"==typeof exports&&exports&&!exports.nodeType&&exports,Oe=we&&"object"==typeof module&&module&&!module.nodeType&&module,Pe=Oe&&Oe.exports===we&&v.process,Ie=function(){try{return Oe&&Oe.require&&Oe.require("util").types||Pe&&Pe.binding&&Pe.binding("util")}catch(e){}}(),ke=Ie&&Ie.isTypedArray,Me=ke?function(e){return function(t){return e(t)}}(ke):function(e){return M(e)&&he(e.length)&&!!xe[k(e)]},Te=Me,ze=Object.prototype.hasOwnProperty;var Re=Object.prototype.hasOwnProperty;function Le(e){return pe(e)?function(e,t){var n=T(e),o=!n&&ve(e),i=!n&&!o&&Se(e),r=!n&&!o&&!i&&Te(e),a=n||o||i||r,s=a?function(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}(e.length,String):[],l=s.length;for(var c in e)!t&&!ze.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||re(c,l))||s.push(c);return s}(e,!0):function(e){if(!z(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=be(e),n=[];for(var o in e)("constructor"!=o||!t&&Re.call(e,o))&&n.push(o);return n}(e)}var De=G(Object,"create"),qe=Object.prototype.hasOwnProperty,Fe=Object.prototype.hasOwnProperty;function Ue(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function $e(e,t){for(var n=e.length;n--;)if(se(e[n][0],t))return n;return-1}Ue.prototype.clear=function(){this.__data__=De?De(null):{},this.size=0},Ue.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ue.prototype.get=function(e){var t=this.__data__;if(De){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return qe.call(t,e)?t[e]:void 0},Ue.prototype.has=function(e){var t=this.__data__;return De?void 0!==t[e]:Fe.call(t,e)},Ue.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=De&&void 0===t?"__lodash_hash_undefined__":t,this};var Be=Array.prototype.splice;function We(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}We.prototype.clear=function(){this.__data__=[],this.size=0},We.prototype.delete=function(e){var t=this.__data__,n=$e(t,e);return!(n<0||(n==t.length-1?t.pop():Be.call(t,n,1),--this.size,0))},We.prototype.get=function(e){var t=this.__data__,n=$e(t,e);return n<0?void 0:t[n][1]},We.prototype.has=function(e){return $e(this.__data__,e)>-1},We.prototype.set=function(e,t){var n=this.__data__,o=$e(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this};var Ye=G(j,"Map");function He(e,t){var n,o,i=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function Ne(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}Ne.prototype.clear=function(){this.size=0,this.__data__={hash:new Ue,map:new(Ye||We),string:new Ue}},Ne.prototype.delete=function(e){var t=He(this,e).delete(e);return this.size-=t?1:0,t},Ne.prototype.get=function(e){return He(this,e).get(e)},Ne.prototype.has=function(e){return He(this,e).has(e)},Ne.prototype.set=function(e,t){var n=He(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this};var Ge=function(e,t){return function(n){return e(t(n))}}(Object.getPrototypeOf,Object),Ve=Ge,Je=Function.prototype,Ke=Object.prototype,Qe=Je.toString,Xe=Ke.hasOwnProperty,Ze=Qe.call(Object);function et(e){var t=this.__data__=new We(e);this.size=t.size}et.prototype.clear=function(){this.__data__=new We,this.size=0},et.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},et.prototype.get=function(e){return this.__data__.get(e)},et.prototype.has=function(e){return this.__data__.has(e)},et.prototype.set=function(e,t){var n=this.__data__;if(n instanceof We){var o=n.__data__;if(!Ye||o.length<199)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new Ne(o)}return n.set(e,t),this.size=n.size,this};var tt="object"==typeof exports&&exports&&!exports.nodeType&&exports,nt=tt&&"object"==typeof module&&module&&!module.nodeType&&module,ot=nt&&nt.exports===tt?j.Buffer:void 0,it=(ot&&ot.allocUnsafe,j.Uint8Array);var rt=Object.prototype,at=rt.hasOwnProperty,st=de(function(e,t){e=Object(e);var n=-1,o=t.length,i=o>2?t[2]:void 0;for(i&&ge(t[0],t[1],i)&&(o=1);++n<o;)for(var r=t[n],a=Le(r),s=-1,l=a.length;++s<l;){var c=a[s],u=e[c];(void 0===u||se(u,rt[c])&&!at.call(e,c))&&(e[c]=r[c])}return e});function lt(e,t,n){(void 0!==n&&!se(e[t],n)||void 0===n&&!(t in e))&&ae(e,t,n)}function ct(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function ut(e,t,n,o,i,r,a){var s=ct(e,n),l=ct(t,n),c=a.get(l);if(c)lt(e,n,c);else{var u,d=r?r(s,l,n+"",e,t,a):void 0,h=void 0===d;if(h){var p=T(l),g=!p&&Se(l),f=!p&&!g&&Te(l);d=l,p||g||f?T(s)?d=s:M(u=s)&&pe(u)?d=function(e,t){var n=-1,o=e.length;for(t||(t=Array(o));++n<o;)t[n]=e[n];return t}(s):g?(h=!1,d=function(e){return e.slice()}(l)):f?(h=!1,d=function(e,t){var n,o,i=t?(o=new(n=e.buffer).constructor(n.byteLength),new it(o).set(new it(n)),o):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}(l,!0)):d=[]:function(e){if(!M(e)||"[object Object]"!=k(e))return!1;var t=Ve(e);if(null===t)return!0;var n=Xe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Qe.call(n)==Ze}(l)||ve(l)?(d=s,ve(s)?d=function(e){return function(e,t,n){var o=!n;n||(n={});for(var i=-1,r=t.length;++i<r;){var a=t[i],s=void 0;void 0===s&&(s=e[a]),o?ae(n,a,s):ce(n,a,s)}return n}(e,Le(e))}(s):z(s)&&!L(s)||(d=function(e){return"function"!=typeof e.constructor||be(e)?{}:X(Ve(e))}(l))):h=!1}h&&(a.set(l,d),i(d,l,o,r,a),a.delete(l)),lt(e,n,d)}}function dt(e,t,n,o,i){e!==t&&function(e,t,n){for(var o=-1,i=Object(e),r=n(e),a=r.length;a--;){var s=r[++o];if(!1===t(i[s],s,i))break}}(t,function(r,a){if(i||(i=new et),z(r))ut(e,t,a,n,dt,o,i);else{var s=o?o(ct(e,a),r,a+"",e,t,i):void 0;void 0===s&&(s=r),lt(e,a,s)}},Le)}var ht,pt=(ht=function(e,t,n){dt(e,t,n)},de(function(e,t){var n=-1,o=t.length,i=o>1?t[o-1]:void 0,r=o>2?t[2]:void 0;for(i=ht.length>3&&"function"==typeof i?(o--,i):void 0,r&&ge(t[0],t[1],r)&&(i=o<3?void 0:i,o=1),e=Object(e);++n<o;){var a=t[n];a&&ht(e,a,n)}return e}));const gt=e,ft=t,{styled:bt}=n,{color:mt}=o,{Button:_t}=i,{Tooltip:yt}=i,{Typography:Ct}=i,{Box:vt}=i,{Info:Et}=r,jt=c,{AlertDialog:At}=l,{InputContainer:St}=l,{ChoiceConfiguration:xt}=l,{settings:wt}=l,{layout:Ot}=l,{choiceUtils:Pt}=l;function It(e){let t,n=e[0],o=1;for(;o<e.length;){const i=e[o],r=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=r(n)):"call"!==i&&"optionalCall"!==i||(n=r((...e)=>n.call(t,...e)),t=void 0)}return n}const{Panel:kt,toggle:Mt,radio:Tt,dropdown:zt}=wt,Rt=bt(St)(({theme:e})=>({width:"100%",paddingTop:e.spacing(2),marginBottom:e.spacing(2)})),Lt=bt(St)(({theme:e})=>({flex:1,marginTop:e.spacing(1.5),paddingTop:e.spacing(2),marginLeft:e.spacing(3.5)})),Dt=bt(St)(({theme:e})=>({display:"flex",flexDirection:"column",marginBottom:e.spacing(1),width:"100%"})),qt=bt(_t)(({theme:e})=>({marginTop:e.spacing(1),float:"right"})),Ft=bt(qt)({cursor:"not-allowed",pointerEvents:"all",backgroundColor:mt.disabled(),"&:hover":{backgroundColor:mt.disabled()},"&:focus":{backgroundColor:mt.disabled()}}),Ut=bt(vt)({display:"flex",alignItems:"center"}),$t=bt(Ct)(({theme:e})=>({fontSize:e.typography.fontSize+2,marginRight:e.spacing(1)})),Bt=bt(yt)(({theme:e})=>({"& .MuiTooltip-tooltip":{fontSize:e.typography.fontSize-2,whiteSpace:"pre",maxWidth:"500px"}})),Wt=bt("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)})),Yt=e=>{const{model:t,configuration:n,onPromptChanged:o,onChoiceChanged:i,onRemoveChoice:r,onAddChoice:a,imageSupport:s,uploadSoundSupport:l,onChangeModel:c,onConfigurationChanged:u,onTeacherInstructionsChanged:d}=e,{addChoiceButton:h={},contentDimensions:p={},feedback:g={},deleteChoice:f={},choiceMode:b={},choicePrefix:m={},partialScoring:_={},lockChoiceOrder:y={},teacherInstructions:C={},studentInstructions:v={},rationale:E={},scoringType:j={},sequentialChoiceLabels:A={},settingsPanelDisabled:S,choicesLayout:x,spellCheck:w={},gridColumns:O,maxImageWidth:P={},maxImageHeight:I={},prompt:k={},withRubric:M={},mathMlOptions:T={},language:z={},languageChoices:R={}}=n||{};let{maxAnswerChoices:L}=n||{};const{limitChoicesNumber:D,teacherInstructionsEnabled:q,rationaleEnabled:F,feedbackEnabled:U,promptEnabled:$,spellCheckEnabled:B,choices:W,errors:Y,toolbarEditorPosition:H,extraCSSRules:N}=t||{},{answerChoices:G,choices:V,correctResponse:J,prompt:K,rationale:Q,teacherInstructions:X}=Y||{},Z=It([W,"optionalAccess",e=>e.length])?Array.from({length:W.length},(e,t)=>`${t+1}`):[],{baseInputConfiguration:ee={}}=n,te={position:"top"===H?"top":"bottom"};D&&(L=9);const ne=(e={})=>({...ee,...e}),oe=(e=>{const{minAnswerChoices:t,maxAnswerChoices:n}=e;return`Validation requirements:\nThere should be at least ${t} `+(n?`and at most ${n} `:"")+"answer choices defined.\nEvery answer choice should be non-blank and unique.\nA correct answer must be defined."})(n),ie=P&&P.prompt,re=I&&I.prompt,ae=L&&It([W,"optionalAccess",e=>e.length])>=L?`Only ${L} allowed maximum`:"",se={choiceMode:b.settings&&Tt(b.label,["checkbox","radio"]),"sequentialChoiceLabels.enabled":A.settings&&Mt(A.label,!0),choicePrefix:m.settings&&Tt(m.label,["numbers","letters"]),partialScoring:_.settings&&Mt(_.label),lockChoiceOrder:y.settings&&Mt(y.label),feedbackEnabled:g.settings&&Mt(g.label),choicesLayout:x.settings&&zt(x.label,["vertical","grid","horizontal"]),gridColumns:x.settings&&"grid"===t.choicesLayout&&Z.length>0&&zt(O.label,Z),"language.enabled":z.settings&&Mt(z.label,!0),language:z.settings&&z.enabled&&zt(R.label,R.options)},le={teacherInstructionsEnabled:C.settings&&Mt(C.label),studentInstructionsEnabled:v.settings&&Mt(v.label),promptEnabled:k.settings&&Mt(k.label),rationaleEnabled:E.settings&&Mt(E.label),spellCheckEnabled:w.settings&&Mt(w.label),scoringType:j.settings&&Tt(j.label,["auto","rubric"]),rubricEnabled:It([M,"optionalAccess",e=>e.settings])&&Mt(It([M,"optionalAccess",e=>e.label]))};return gt.createElement(Ot.ConfigLayout,{dimensions:p,hideSettings:S,extraCSSRules:N,classes:{},settings:gt.createElement(kt,{model:t,onChangeModel:c,configuration:n,onChangeConfiguration:u,groups:{Settings:se,Properties:le}})},q&&gt.createElement(Rt,{label:C.label},gt.createElement(jt,{markup:t.teacherInstructions||"",onChange:d,imageSupport:s,nonEmpty:!1,disableUnderline:!0,error:X,toolbarOpts:te,pluginProps:ne(It([n,"optionalAccess",e=>e.teacherInstructions,"optionalAccess",e=>e.inputConfiguration])),spellCheck:B,maxImageWidth:P&&P.teacherInstructions||ie,maxImageHeight:I&&I.teacherInstructions||re,uploadSoundSupport:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:T}),X&&gt.createElement(Wt,null,X)),$&&gt.createElement(Rt,{label:k.label},gt.createElement(jt,{markup:t.prompt,onChange:o,imageSupport:s,nonEmpty:!1,disableUnderline:!0,error:K,toolbarOpts:te,pluginProps:ne(It([n,"optionalAccess",e=>e.prompt,"optionalAccess",e=>e.inputConfiguration])),spellCheck:B,maxImageWidth:P&&P.prompt,maxImageHeight:I&&I.prompt,uploadSoundSupport:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:T}),K&&gt.createElement(Wt,null,K)),gt.createElement(Ut,null,gt.createElement($t,{component:"div"},"Choices"),gt.createElement(Bt,{disableFocusListener:!0,disableTouchListener:!0,placement:"right",title:oe},gt.createElement(Et,{fontSize:"small",color:"primary"}))),W.map((e,o)=>gt.createElement(Dt,{key:`choice-${o}`},gt.createElement(xt,{key:o,index:o+1,useLetterOrdering:"letters"===t.choicePrefix,mode:t.choiceMode,data:e,defaultFeedback:{},imageSupport:s,disableImageAlignmentButtons:!0,onDelete:()=>r(o),onChange:e=>i(o,e),allowFeedBack:U,allowDelete:f.settings,noLabels:!0,pluginOpts:ne(It([n,"optionalAccess",e=>e.choices,"optionalAccess",e=>e.inputConfiguration])),toolbarOpts:te,spellCheck:B,error:It([V,"optionalAccess",t=>t[e.value]])||null,noCorrectAnswerError:J,maxImageWidth:P&&P.choices||ie,maxImageHeight:I&&I.choices||re,uploadSoundSupport:l,mathMlOptions:T}),F&&gt.createElement(Lt,{key:`rationale-${o}`,label:E.label},gt.createElement(jt,{markup:e.rationale||"",onChange:t=>i(o,{...e,rationale:t}),imageSupport:s,error:It([Q,"optionalAccess",t=>t[e.value]])||null,toolbarOpts:te,pluginProps:ne(It([n,"optionalAccess",e=>e.rationale,"optionalAccess",e=>e.inputConfiguration])),spellCheck:B,maxImageWidth:P&&P.rationale||ie,maxImageHeight:I&&I.rationale||re,uploadSoundSupport:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:T}),It([Q,"optionalAccess",t=>t[e.value]])&&gt.createElement(Wt,null,It([Q,"optionalAccess",t=>t[e.value]]))))),J&&gt.createElement(Wt,null,J),G&&gt.createElement(Wt,null,G),h.settings&&gt.createElement(Bt,{title:ae},L&&It([W,"optionalAccess",e=>e.length])>=L?gt.createElement(Ft,{variant:"contained",color:"primary",onClick:a,disabled:!0},h.label):gt.createElement(qt,{variant:"contained",color:"primary",onClick:a},h.label)))};class Ht extends gt.Component{constructor(...e){super(...e),Ht.prototype.__init.call(this),Ht.prototype.__init2.call(this),Ht.prototype.__init3.call(this),Ht.prototype.__init4.call(this),Ht.prototype.__init5.call(this),Ht.prototype.__init6.call(this),Ht.prototype.__init7.call(this)}static __initStatic(){this.propTypes={model:ft.object.isRequired,configuration:ft.object.isRequired,disableSidePanel:ft.bool,onModelChanged:ft.func.isRequired,onConfigurationChanged:ft.func.isRequired,imageSupport:ft.shape({add:ft.func.isRequired,delete:ft.func.isRequired})}}__init(){this.state={showWarning:!1}}__init2(){this.onRemoveChoice=e=>{const{model:t,configuration:n,onModelChanged:o}=this.props,{minAnswerChoices:i}=n||{};i&&t.choices.length===i?this.setState({showWarning:!0}):(t.choices.splice(e,1),o({choices:t.choices}))}}__init3(){this.onAddChoice=()=>{const{model:e,configuration:t,onModelChanged:n}=this.props;let{maxAnswerChoices:o}=t||{};const{limitChoicesNumber:i}=e||{};i&&(o=9),o&&e.choices.length>=o||(e.choices.push({label:"",value:Pt.firstAvailableIndex(e.choices.map(e=>e.value),0),feedback:{type:"none"}}),n({choices:e.choices}))}}__init4(){this.onChoiceChanged=(e,t)=>{const{model:n,onModelChanged:o}=this.props;t.correct&&"radio"===n.choiceMode&&(n.choices=n.choices.map(e=>pt({},e,{correct:!1}))),n.choices.splice(e,1,t),o({choices:n.choices})}}__init5(){this.onPromptChanged=e=>{this.props.onModelChanged({prompt:e})}}__init6(){this.onTeacherInstructionsChanged=e=>{this.props.onModelChanged({teacherInstructions:e})}}__init7(){this.onModelChanged=(e,t)=>{const{onModelChanged:n}=this.props;if("choiceMode"===t){if("radio"===e.choiceMode){let t=!1;e.choices=e.choices.map(e=>t?(e.correct=!1,e):(e.correct&&(t=!0),e))}n({choiceMode:e.choiceMode,choices:e.choices},!0)}else n(e)}}render(){const{configuration:{minAnswerChoices:e}={}}=this.props,{showWarning:t}=this.state;return gt.createElement(gt.Fragment,null,gt.createElement(At,{open:t,title:"Warning",text:`There can't be less than ${e||0} choices.`,onConfirm:()=>this.setState({showWarning:!1})}),gt.createElement(Yt,{...this.props,onChangeModel:this.onModelChanged,onRemoveChoice:this.onRemoveChoice,onChoiceChanged:this.onChoiceChanged,onAddChoice:this.onAddChoice,onPromptChanged:this.onPromptChanged,onTeacherInstructionsChanged:this.onTeacherInstructionsChanged}))}}Ht.__initStatic();var Nt={choiceMode:"checkbox",choicePrefix:"letters",choices:[],choicesLayout:"vertical",feedbackEnabled:!1,gridColumns:2,lockChoiceOrder:!0,partialScoring:!0,prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,scoringType:"auto",studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom",selectedAnswerBackgroundColor:"initial",keyboardEventsEnabled:!1},Gt={baseInputConfiguration:{h3:{disabled:!0},audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},choices:{inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}}},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},choicesLayout:{settings:!1,label:"Choices Layout"},gridColumns:{label:"Grid columns"},answerChoiceCount:0,addChoiceButton:{settings:!0,label:"Add a Choice"},choiceMode:{settings:!0,label:"Response Type"},choicePrefix:{settings:!0,label:"Choice Labels"},deleteChoice:{settings:!0},feedback:{settings:!0,label:"Feedback"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},lockChoiceOrder:{settings:!0,label:"Lock Choice Order"},partialScoring:{settings:!1,label:"Allow Partial Scoring"},rationale:{settings:!0,label:"Rationale",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!1}},required:!1},scoringType:{settings:!1,label:"Scoring Type"},studentInstructions:{settings:!1,label:"Student Instructions"},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},toolbarEditorPosition:{settings:!1,label:"Toolbar Editor Position"},minAnswerChoices:2,maxAnswerChoices:5,maxImageWidth:{teacherInstructions:300,prompt:300,rationale:636,choices:900},maxImageHeight:{teacherInstructions:300,prompt:300,rationale:300,choices:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]}};const Vt=e,{createRoot:Jt}=s,Kt=a,{choiceUtils:Qt}=l;function Xt(e){let t,n=e[0],o=1;for(;o<e.length;){const i=e[o],r=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=r(n)):"call"!==i&&"optionalCall"!==i||(n=r((...e)=>n.call(t,...e)),t=void 0)}return n}const Zt=Kt("multiple-choice:configure"),en=(e,t=0)=>{if(!e||0===e.length){let e=[];for(let n=0;n<t;n++)e.push({value:`${n}`,label:"",feedback:{type:"none",value:""}});return e}return e},tn=(e,t)=>{const n=st(e,Gt);return{configuration:n,model:{...t,choices:en(t&&t.choices||[],n&&n.answerChoiceCount)}}};class nn extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>{const t=Qt.normalizeChoices({...Nt,...e,choices:en(e&&e.choices||[])});return t.choicesLayout=e.choicesLayout||!1===e.verticalMode&&"horizontal"||Nt.choicesLayout,t}}constructor(){super(),this._root=null,this._reactContainer=null,this._model=nn.createDefaultModel(),this._configuration=Gt,this.onModelChanged=this.onModelChanged.bind(this),this.onConfigurationChanged=this.onConfigurationChanged.bind(this)}set model(e){this._model=nn.createDefaultModel(e),this._render()}set configuration(e){const t=tn(e,this._model);this.onModelChanged(t.model);const n={...Gt,...t.configuration};this._configuration=n,Xt([n,"optionalAccess",e=>e.language,"optionalAccess",e=>e.enabled])?Xt([n,"optionalAccess",e=>e.languageChoices,"optionalAccess",e=>e.options,"optionalAccess",e=>e.length])&&(this._model.language=Xt([n,"optionalAccess",e=>e.languageChoices,"access",e=>e.options,"access",e=>e[0],"access",e=>e.value])):n.language.settings&&this._model.language?(this._configuration.language.enabled=!0,this._configuration.languageChoices.options&&this._configuration.languageChoices.options.length||(this._configuration.languageChoices.options=[]),this._configuration.languageChoices.options.find(e=>e.value===this._model.language)||this._configuration.languageChoices.options.push({value:this._model.language,label:this._model.language})):delete this._model.language,this._render()}set disableSidePanel(e){this._disableSidePanel=e,this._render()}dispatchModelUpdated(e){const t=!!e;this.dispatchEvent(new h(this._model,t))}onModelChanged(e,t){this._model={...this._model,...e},this._render(),this.dispatchModelUpdated(t)}onConfigurationChanged(e){this._configuration=tn(e,this._model).configuration,this._model&&this.onModelChanged(this._model),this._render()}insertImage(e){this.dispatchEvent(new b(e))}onDeleteImage(e,t){this.dispatchEvent(new g(e,t))}insertSound(e){this.dispatchEvent(new C(e))}onDeleteSound(e,t){this.dispatchEvent(new _(e,t))}_render(){Zt("_render - Starting render"),Zt("_render - Model:",this._model?"present":"missing"),Zt("_render - Configuration:",this._configuration?"present":"missing"),Zt("_render - Root exists:",!!this._root);try{let e=Vt.createElement(Ht,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged,onConfigurationChanged:this.onConfigurationChanged,disableSidePanel:this._disableSidePanel,imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(Zt("_render - Creating React container"),this._reactContainer=document.createElement("div"),this._reactContainer.className="pie-configure-wrapper",this.appendChild(this._reactContainer),Zt("_render - Creating new React root"),this._root=Jt(this._reactContainer),Zt("_render - React root created successfully")),Zt("_render - Calling root.render()"),this._root.render(e),Zt("_render - Render completed successfully")}catch(e){throw console.error("❌ [multiple-choice-configure] Render error:",e),console.error("Error stack:",e.stack),e}}connectedCallback(){Zt("connectedCallback - Component connected to DOM"),Zt("connectedCallback - Model:",this._model?"present":"missing"),Zt("connectedCallback - Configuration:",this._configuration?"present":"missing"),this._render()}disconnectedCallback(){Zt("disconnectedCallback - Component disconnected from DOM"),this._root&&(Zt("disconnectedCallback - Unmounting React root"),this._root.unmount(),this._root=null),this._reactContainer&&(this._reactContainer=null)}}nn.__initStatic();export{nn as default};