@pie-element/multiple-choice 13.3.1 → 13.3.2

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,13 @@
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.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@13.3.1...@pie-element/multiple-choice@13.3.2) (2026-06-22)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
11
+ - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
12
+
6
13
  ## [13.3.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@13.3.0...@pie-element/multiple-choice@13.3.1) (2026-06-17)
7
14
 
8
15
  ### Bug Fixes
@@ -3,6 +3,13 @@
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.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@10.1.4...@pie-element/multiple-choice-configure@10.1.5) (2026-06-22)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
11
+ - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
12
+
6
13
  ## [10.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@10.1.3...@pie-element/multiple-choice-configure@10.1.4) (2026-06-17)
7
14
 
8
15
  ### Bug Fixes
@@ -174,6 +174,7 @@ class MultipleChoice extends HTMLElement {
174
174
  log('connectedCallback - Component connected to DOM');
175
175
  log('connectedCallback - Model:', this._model ? 'present' : 'missing');
176
176
  log('connectedCallback - Configuration:', this._configuration ? 'present' : 'missing');
177
+ this._render();
177
178
  }
178
179
  disconnectedCallback() {
179
180
  log('disconnectedCallback - Component disconnected from DOM');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_debug","_pieConfigureEvents","_main","_configUi","_lodashEs","_defaults","log","debug","generateFormattedChoices","choices","choiceCount","length","formattedChoices","i","push","value","label","feedback","type","prepareCustomizationObject","config","model","configuration","defaults","sensibleDefaults","answerChoiceCount","MultipleChoice","HTMLElement","constructor","_root","_reactContainer","_model","createDefaultModel","_configuration","onModelChanged","bind","onConfigurationChanged","s","_render","c","info","newConfiguration","language","enabled","languageChoices","options","settings","find","option","disableSidePanel","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","m","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","delete","uploadSoundSupport","document","className","appendChild","createRoot","render","error","console","stack","connectedCallback","disconnectedCallback","unmount","exports","default","_defineProperty2","normalizedModel","utils","normalizeChoices","choicesLayout","verticalMode"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport {\n DeleteImageEvent,\n InsertImageEvent,\n ModelUpdatedEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Main from './main';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport { defaults } from 'lodash-es';\n\nimport sensibleDefaults from './defaults';\n\nconst log = debug('multiple-choice:configure');\n\nconst generateFormattedChoices = (choices, choiceCount = 0) => {\n if (!choices || choices.length === 0) {\n let formattedChoices = [];\n\n for (let i = 0; i < choiceCount; i++) {\n formattedChoices.push({\n value: `${i}`,\n label: '',\n feedback: {\n type: 'none',\n value: '',\n },\n });\n }\n\n return formattedChoices;\n }\n\n return choices;\n};\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, sensibleDefaults.configuration);\n\n return {\n configuration,\n model: {\n ...model,\n choices: generateFormattedChoices(\n (model && model.choices) || [],\n configuration && configuration.answerChoiceCount,\n ),\n },\n };\n};\n\nexport default class MultipleChoice extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n const normalizedModel = utils.normalizeChoices({\n ...sensibleDefaults.model,\n ...model,\n choices: generateFormattedChoices((model && model.choices) || []),\n });\n\n // This is used for offering support for old models which have the property \"verticalMode\"\n normalizedModel.choicesLayout =\n model.choicesLayout || (model.verticalMode === false && 'horizontal') || sensibleDefaults.model.choicesLayout;\n\n return normalizedModel;\n };\n\n constructor() {\n super();\n this._root = null;\n this._reactContainer = null;\n this._model = MultipleChoice.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(s) {\n this._model = MultipleChoice.createDefaultModel(s);\n\n this._render();\n }\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n this.onModelChanged(info.model);\n\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...info.configuration,\n };\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = {\n ...this._model,\n ...m,\n };\n this._render();\n\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = prepareCustomizationObject(c, this._model).configuration;\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n }\n\n /** @param {done, progress, file} handler */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render - Starting render');\n log('_render - Model:', this._model ? 'present' : 'missing');\n log('_render - Configuration:', this._configuration ? 'present' : 'missing');\n log('_render - Root exists:', !!this._root);\n\n try {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n log('_render - Creating React container');\n\n // Create a container div for React to render into\n this._reactContainer = document.createElement('div');\n this._reactContainer.className = 'pie-configure-wrapper';\n this.appendChild(this._reactContainer);\n\n log('_render - Creating new React root');\n this._root = createRoot(this._reactContainer);\n log('_render - React root created successfully');\n }\n\n log('_render - Calling root.render()');\n this._root.render(element);\n log('_render - Render completed successfully');\n } catch (error) {\n console.error('❌ [multiple-choice-configure] Render error:', error);\n console.error('Error stack:', error.stack);\n throw error;\n }\n }\n\n connectedCallback() {\n log('connectedCallback - Component connected to DOM');\n log('connectedCallback - Model:', this._model ? 'present' : 'missing');\n log('connectedCallback - Configuration:', this._configuration ? 'present' : 'missing');\n }\n\n disconnectedCallback() {\n log('disconnectedCallback - Component disconnected from DOM');\n if (this._root) {\n log('disconnectedCallback - Unmounting React root');\n this._root.unmount();\n this._root = null;\n }\n if (this._reactContainer) {\n this._reactContainer = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAQA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,MAAMQ,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAE9C,MAAMC,wBAAwB,GAAGA,CAACC,OAAO,EAAEC,WAAW,GAAG,CAAC,KAAK;EAC7D,IAAI,CAACD,OAAO,IAAIA,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACpC,IAAIC,gBAAgB,GAAG,EAAE;IAEzB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,WAAW,EAAEG,CAAC,EAAE,EAAE;MACpCD,gBAAgB,CA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;AAAA,IAAA+D,gBAAA,CAAAD,OAAA,EAvLoB9D,cAAc,wBACL,CAACL,KAAK,GAAG,CAAC,CAAC,KAAK;EAC1C,MAAMqE,eAAe,GAAGC,qBAAK,CAACC,gBAAgB,CAAC;IAC7C,GAAGpE,iBAAgB,CAACH,KAAK;IACzB,GAAGA,KAAK;IACRZ,OAAO,EAAED,wBAAwB,CAAEa,KAAK,IAAIA,KAAK,CAACZ,OAAO,IAAK,EAAE;EAClE,CAAC,CAAC;;EAEF;EACAiF,eAAe,CAACG,aAAa,GAC3BxE,KAAK,CAACwE,aAAa,IAAKxE,KAAK,CAACyE,YAAY,KAAK,KAAK,IAAI,YAAa,IAAItE,iBAAgB,CAACH,KAAK,CAACwE,aAAa;EAE/G,OAAOH,eAAe;AACxB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_debug","_pieConfigureEvents","_main","_configUi","_lodashEs","_defaults","log","debug","generateFormattedChoices","choices","choiceCount","length","formattedChoices","i","push","value","label","feedback","type","prepareCustomizationObject","config","model","configuration","defaults","sensibleDefaults","answerChoiceCount","MultipleChoice","HTMLElement","constructor","_root","_reactContainer","_model","createDefaultModel","_configuration","onModelChanged","bind","onConfigurationChanged","s","_render","c","info","newConfiguration","language","enabled","languageChoices","options","settings","find","option","disableSidePanel","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","m","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","delete","uploadSoundSupport","document","className","appendChild","createRoot","render","error","console","stack","connectedCallback","disconnectedCallback","unmount","exports","default","_defineProperty2","normalizedModel","utils","normalizeChoices","choicesLayout","verticalMode"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport {\n DeleteImageEvent,\n InsertImageEvent,\n ModelUpdatedEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Main from './main';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport { defaults } from 'lodash-es';\n\nimport sensibleDefaults from './defaults';\n\nconst log = debug('multiple-choice:configure');\n\nconst generateFormattedChoices = (choices, choiceCount = 0) => {\n if (!choices || choices.length === 0) {\n let formattedChoices = [];\n\n for (let i = 0; i < choiceCount; i++) {\n formattedChoices.push({\n value: `${i}`,\n label: '',\n feedback: {\n type: 'none',\n value: '',\n },\n });\n }\n\n return formattedChoices;\n }\n\n return choices;\n};\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, sensibleDefaults.configuration);\n\n return {\n configuration,\n model: {\n ...model,\n choices: generateFormattedChoices(\n (model && model.choices) || [],\n configuration && configuration.answerChoiceCount,\n ),\n },\n };\n};\n\nexport default class MultipleChoice extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n const normalizedModel = utils.normalizeChoices({\n ...sensibleDefaults.model,\n ...model,\n choices: generateFormattedChoices((model && model.choices) || []),\n });\n\n // This is used for offering support for old models which have the property \"verticalMode\"\n normalizedModel.choicesLayout =\n model.choicesLayout || (model.verticalMode === false && 'horizontal') || sensibleDefaults.model.choicesLayout;\n\n return normalizedModel;\n };\n\n constructor() {\n super();\n this._root = null;\n this._reactContainer = null;\n this._model = MultipleChoice.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(s) {\n this._model = MultipleChoice.createDefaultModel(s);\n\n this._render();\n }\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n this.onModelChanged(info.model);\n\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...info.configuration,\n };\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = {\n ...this._model,\n ...m,\n };\n this._render();\n\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = prepareCustomizationObject(c, this._model).configuration;\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n }\n\n /** @param {done, progress, file} handler */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render - Starting render');\n log('_render - Model:', this._model ? 'present' : 'missing');\n log('_render - Configuration:', this._configuration ? 'present' : 'missing');\n log('_render - Root exists:', !!this._root);\n\n try {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n log('_render - Creating React container');\n\n // Create a container div for React to render into\n this._reactContainer = document.createElement('div');\n this._reactContainer.className = 'pie-configure-wrapper';\n this.appendChild(this._reactContainer);\n\n log('_render - Creating new React root');\n this._root = createRoot(this._reactContainer);\n log('_render - React root created successfully');\n }\n\n log('_render - Calling root.render()');\n this._root.render(element);\n log('_render - Render completed successfully');\n } catch (error) {\n console.error('❌ [multiple-choice-configure] Render error:', error);\n console.error('Error stack:', error.stack);\n throw error;\n }\n }\n\n connectedCallback() {\n log('connectedCallback - Component connected to DOM');\n log('connectedCallback - Model:', this._model ? 'present' : 'missing');\n log('connectedCallback - Configuration:', this._configuration ? 'present' : 'missing');\n this._render();\n }\n\n disconnectedCallback() {\n log('disconnectedCallback - Component disconnected from DOM');\n if (this._root) {\n log('disconnectedCallback - Unmounting React root');\n this._root.unmount();\n this._root = null;\n }\n if (this._reactContainer) {\n this._reactContainer = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAQA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,MAAMQ,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAE9C,MAAMC,wBAAwB,GAAGA,CAACC,OAAO,EAAEC,WAAW,GAAG,CAAC,KAAK;EAC7D,IAAI,CAACD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,CAAC;MACnD,IAAI,CAACuB,KAAK,CAACyD,OAAO,CAAC,CAAC;MACpB,IAAI,CAACzD,KAAK,GAAG,IAAI;IACnB;IACA,IAAI,IAAI,CAACC,eAAe,EAAE;MACxB,IAAI,CAACA,eAAe,GAAG,IAAI;IAC7B;EACF;AACF;AAACyD,OAAA,CAAAC,OAAA,GAAA9D,cAAA;AAAA,IAAA+D,gBAAA,CAAAD,OAAA,EAxLoB9D,cAAc,wBACL,CAACL,KAAK,GAAG,CAAC,CAAC,KAAK;EAC1C,MAAMqE,eAAe,GAAGC,qBAAK,CAACC,gBAAgB,CAAC;IAC7C,GAAGpE,iBAAgB,CAACH,KAAK;IACzB,GAAGA,KAAK;IACRZ,OAAO,EAAED,wBAAwB,CAAEa,KAAK,IAAIA,KAAK,CAACZ,OAAO,IAAK,EAAE;EAClE,CAAC,CAAC;;EAEF;EACAiF,eAAe,CAACG,aAAa,GAC3BxE,KAAK,CAACwE,aAAa,IAAKxE,KAAK,CAACyE,YAAY,KAAK,KAAK,IAAI,YAAa,IAAItE,iBAAgB,CAACH,KAAK,CAACwE,aAAa;EAE/G,OAAOH,eAAe;AACxB,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-configure",
3
- "version": "10.1.4",
3
+ "version": "10.1.5",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -10,8 +10,8 @@
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.8",
14
- "@pie-lib/editable-html-tip-tap": "2.1.6",
13
+ "@pie-lib/config-ui": "13.0.9",
14
+ "@pie-lib/editable-html-tip-tap": "2.1.7",
15
15
  "@pie-lib/render-ui": "6.1.2",
16
16
  "debug": "^4.1.1",
17
17
  "lodash-es": "^4.17.23",
package/lib/index.js CHANGED
@@ -361,6 +361,7 @@ class MultipleChoice extends HTMLElement {
361
361
  }
362
362
  if (this._root) {
363
363
  this._root.unmount();
364
+ this._root = null;
364
365
  }
365
366
  }
366
367
 
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","log","debug","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","audio","querySelector","isInsidePrompt","closest","value","choiceMode","minSelections","maxSelections","selections","length","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","newValue","selected","includes","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';\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 || 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 }\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 newValue = {\n value: choiceId,\n selected: !currentValue.includes(choiceId),\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;AAEA,MAAMS,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,CAACI,aAAa,CAAC,OAAO,CAAC;MACnD,MAAMC,cAAc,GAAGF,KAAK,IAAIA,KAAK,CAACG,OAAO,CAAC,iBAAiB,CA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Q,EAAE;MACrB;IACF;IAEA,MAAMC,UAAU,GAAIC,GAAG,IAAK;MAC1B,MAAMC,SAAS,GAAGD,GAAG,IAAI,GAAG,IAAIA,GAAG,IAAI,GAAG,GAAGA,GAAG,GAAG,GAAG,GAAGA,GAAG,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;MAC7E,MAAME,YAAY,GAAG,YAAY,CAACC,IAAI,CAACH,GAAG,CAAC,GAAGA,GAAG,CAACtE,WAAW,CAAC,CAAC,CAAC0E,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,CAACA,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;MACtG,OAAOH,SAAS,IAAI,CAAC,GAAGA,SAAS,GAAGC,YAAY;IAClD,CAAC;IAED,MAAMG,WAAW,GAAGN,UAAU,CAACF,KAAK,CAACG,GAAG,CAAC;IAEzC,IAAIK,WAAW,KAAK1I,SAAS,IAAI0I,WAAW,IAAI,CAAC,CAAC,IAAIA,WAAW,IAAI,IAAI,CAAC1G,MAAM,CAAC2G,OAAO,EAAEjJ,MAAM,EAAE;MAChG;IACF;IAEA,MAAMkJ,YAAY,GAAG,IAAI,CAAC3G,QAAQ,CAAC5C,KAAK,IAAI,EAAE;IAC9C,MAAMwJ,QAAQ,GAAG,IAAI,CAAC7G,MAAM,CAAC2G,OAAO,CAACD,WAAW,CAAC,CAACrJ,KAAK;IAEvD,MAAMyJ,QAAQ,GAAG;MACfzJ,KAAK,EAAEwJ,QAAQ;MACfE,QAAQ,EAAE,CAACH,YAAY,CAACI,QAAQ,CAACH,QAAQ,CAAC;MAC1CI,QAAQ,EAAE;IACZ,CAAC;IAED,IAAI,CAACjG,SAAS,CAAC8F,QAAQ,CAAC;EAC1B;AACF;AAACnJ,OAAA,CAAA2B,OAAA,GAAAJ,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_lodashEs","_debug","_piePlayerEvents","_mathRendering","_renderUi","_sessionUpdater","log","debug","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","audio","querySelector","isInsidePrompt","closest","value","choiceMode","minSelections","maxSelections","selections","length","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","newValue","selected","includes","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';\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 || 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 newValue = {\n value: choiceId,\n selected: !currentValue.includes(choiceId),\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;AAEA,MAAMS,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,CAACI,aAAa,CAAC,OAAO,CAAC;MACnD,MAAMC,cAAc,GAAGF,KAAK,IAAIA,KAAK,CAACG,OAAO,CAAC,iBAAiB,CAAC;;MAEhE;MACA,IAAIH,KAAK,IAAIE,cAAc,EAAE;QAC3B,OAAO,KAAK;MACd;IACF;EACF;EAEA,IAAI,CAACR,OAAO,IAAI,CAACA,OAAO,CAACU,KAAK,EAAE;IAC9B,OAAO,KAAK;EACd;EAEA,MAAM;IAAEC,UAAU;IAAEC,aAAa,GAAG,CAAC;IAAEC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CAAC,GAAG,CAAC,CAAC;MAC7E,MAAME,YAAY,GAAG,YAAY,CAACC,IAAI,CAACH,GAAG,CAAC,GAAGA,GAAG,CAACtE,WAAW,CAAC,CAAC,CAAC0E,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,CAACA,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;MACtG,OAAOH,SAAS,IAAI,CAAC,GAAGA,SAAS,GAAGC,YAAY;IAClD,CAAC;IAED,MAAMG,WAAW,GAAGN,UAAU,CAACF,KAAK,CAACG,GAAG,CAAC;IAEzC,IAAIK,WAAW,KAAK1I,SAAS,IAAI0I,WAAW,IAAI,CAAC,CAAC,IAAIA,WAAW,IAAI,IAAI,CAAC1G,MAAM,CAAC2G,OAAO,EAAEjJ,MAAM,EAAE;MAChG;IACF;IAEA,MAAMkJ,YAAY,GAAG,IAAI,CAAC3G,QAAQ,CAAC5C,KAAK,IAAI,EAAE;IAC9C,MAAMwJ,QAAQ,GAAG,IAAI,CAAC7G,MAAM,CAAC2G,OAAO,CAACD,WAAW,CAAC,CAACrJ,KAAK;IAEvD,MAAMyJ,QAAQ,GAAG;MACfzJ,KAAK,EAAEwJ,QAAQ;MACfE,QAAQ,EAAE,CAACH,YAAY,CAACI,QAAQ,CAACH,QAAQ,CAAC;MAC1CI,QAAQ,EAAE;IACZ,CAAC;IAED,IAAI,CAACjG,SAAS,CAAC8F,QAAQ,CAAC;EAC1B;AACF;AAACnJ,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.6/module/index.js";import{_dll_pie_lib__config_ui as l}from"../../../@pie-lib/config-module@^4.0.11/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as c}from"../../../@pie-lib/editable-html-module@^7.1.8/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")}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@^5.2.7/module/index.js";import{_dll_pie_lib__config_ui as l}from"../../../@pie-lib/config-module@^4.0.12/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as c}from"../../../@pie-lib/editable-html-module@^7.1.9/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};