@doenet/doenetml 0.7.27-dev.649 → 0.7.27-dev.651

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/{AnswerResponseButton-D7YYHmWo.js → AnswerResponseButton-jd-bRHxQ.js} +2 -2
  2. package/{ClickTarget-D8u4xiP-.js → ClickTarget-DulY-v4Y.js} +1 -1
  3. package/{Description-Dx9FHDQ7.js → Description-D_T-WiYQ.js} +1 -1
  4. package/{EditorViewer-CKqqi3aE.js → EditorViewer-CHnkVeAi.js} +5 -5
  5. package/{GraphFrame-BUmDVS5D.js → GraphFrame-B4LasjFk.js} +2 -2
  6. package/{JSXGraphRenderer-Dp8XNwWC.js → JSXGraphRenderer-fPyUbg60.js} +1 -1
  7. package/{NonInlineMediaWrapper-DNef4URc.js → NonInlineMediaWrapper-6B5ZAmdu.js} +1 -1
  8. package/Viewer/renderers/subsetOfRealsInput.d.ts.map +1 -1
  9. package/{_error-Henad9wz.js → _error-B5-Lw17p.js} +2 -2
  10. package/{alert-Co9_Zsio.js → alert-B9fs5ZX-.js} +3 -3
  11. package/{angle-qFPs-qF6.js → angle-ClZI7eB5.js} +6 -6
  12. package/{answer-wqE1yXso.js → answer-B3G51FI7.js} +6 -6
  13. package/{asList-DE_l8knb.js → asList-BAZCNgjP.js} +2 -2
  14. package/{blockQuote-C1MUHNHU.js → blockQuote-CPz4IMB0.js} +3 -3
  15. package/{boolean-DRtK9rke.js → boolean-BKDszHBP.js} +2 -2
  16. package/{booleanInput-B0ZkzzS1.js → booleanInput-D4mncMh9.js} +7 -7
  17. package/{br-C1Fl2OhN.js → br-BrmtIADc.js} +2 -2
  18. package/{button-C07p5-IW.js → button-DsOJnk6V.js} +5 -5
  19. package/{c-D0KA9znJ.js → c-D51pIgNq.js} +3 -3
  20. package/{cell-C3Jxm2TE.js → cell-tctVCGFe.js} +3 -3
  21. package/{chart-DmQXw7Wj.js → chart-CSHOMod4.js} +4 -4
  22. package/{choiceInput-DB0DmIFM.js → choiceInput-Dx_YEK3b.js} +7 -7
  23. package/{circle-D3rFqOLP.js → circle-BHlIbdJT.js} +6 -6
  24. package/{cobwebPolyline-CIMEQTJn.js → cobwebPolyline-Sv2FSOoq.js} +4 -4
  25. package/{codeEditor-D6a3hBEE.js → codeEditor-oAl5fbxd.js} +2 -2
  26. package/{composites-BJOxtFqh.js → composites-BDORaURj.js} +1 -1
  27. package/{containerBlock-BdT0SlAl.js → containerBlock-7_RdOF0x.js} +4 -4
  28. package/{containerInline-BEbavSa4.js → containerInline-Cpb02JJE.js} +4 -4
  29. package/{curve-DKvJRJZp.js → curve-BWV5g6F_.js} +4 -4
  30. package/{delete-CRp4kgV6.js → delete-D7IIZ-sD.js} +3 -3
  31. package/{doenetml-B7YgEkww.js → doenetml-D8vZ_PHx.js} +3 -3
  32. package/doenetml-external-worker.js +2 -2
  33. package/doenetml-inline-worker.js +3 -3
  34. package/doenetml-worker/index.esm.js +1 -1
  35. package/doenetml-worker/index.js +1 -1
  36. package/{ellipsis-DKehl6Jp.js → ellipsis-Dkbr1F6G.js} +2 -2
  37. package/{em-qbY3uuHH.js → em-CiIZ0QOU.js} +3 -3
  38. package/{embed-DzQEPiqd.js → embed-DoKCarUJ.js} +2 -2
  39. package/{feedback-BK31fnrS.js → feedback-Dr4ViUcO.js} +4 -4
  40. package/{figure-Bseme70U.js → figure-AOriDSTq.js} +3 -3
  41. package/{fillPatterns-Bc-itiSM.js → fillPatterns-BI_dD3dO.js} +1 -1
  42. package/{footnote-DKLbEmlF.js → footnote-DWembFIa.js} +3 -3
  43. package/{fractionInput-D8jTYl83.js → fractionInput-Ce5y3f1y.js} +5 -5
  44. package/{graph-BngE5cxe.js → graph-BWlidiEv.js} +5 -5
  45. package/{hint-Dh-wZgI-.js → hint-Dqt_pBQx.js} +5 -5
  46. package/{hovercard-store-DO4yISkX.js → hovercard-store-DR8WJ_iF.js} +1 -1
  47. package/{hr-Bt8OY7iD.js → hr-BZCxTsxT.js} +2 -2
  48. package/{image-qqjYpg6H.js → image-Cvi0ZFAd.js} +8 -8
  49. package/{index-B1TCiY_f.js → index-CkO8C6Qi.js} +1 -1
  50. package/{index.es-TPkch2U6.js → index.es-BFSAB25_.js} +1 -1
  51. package/index.js +1 -1
  52. package/{inputLabel-Cs1CMX-q.js → inputLabel-DEiJARYO.js} +3 -3
  53. package/{insert-DrqsMDd-.js → insert-CRd6eZ6Z.js} +3 -3
  54. package/{label-CjreqKyI.js → label-BzSgdiyf.js} +9 -9
  55. package/{legend-DiDl0EsH.js → legend-4YvUonBF.js} +4 -4
  56. package/{line-B_U1Ae4B.js → line-B0Hr1hiT.js} +6 -6
  57. package/{lineFamilyDragHandlers-DqEm1HxF.js → lineFamilyDragHandlers-yEqKWtv4.js} +1 -1
  58. package/{lineSegment-Daevkxw0.js → lineSegment-DIQavz2W.js} +5 -5
  59. package/{list-CB941a28.js → list-DSbRuzX0.js} +4 -4
  60. package/{lq-CFqV_o0r.js → lq-D-hDn8I6.js} +2 -2
  61. package/{lsq-CyKYXsR6.js → lsq-WFYzQbR_.js} +2 -2
  62. package/{markupRenderer-B5ow3A7v.js → markupRenderer-BHcH7XW4.js} +1 -1
  63. package/{math-DESAdYNY.js → math-9ipYsK1O.js} +8 -8
  64. package/{mathInput-DfsQVwqE.js → mathInput-DjAz7iAb.js} +9 -9
  65. package/{mathInputSlots-BrrcZG0V.js → mathInputSlots-BLwwy3zM.js} +1 -1
  66. package/{matrixInput-Btc1aH0q.js → matrixInput-DXWAiEyw.js} +5 -5
  67. package/{mdash-Cxr1eMgH.js → mdash-B_qmaA5N.js} +2 -2
  68. package/{nbsp-D9EaA05X.js → nbsp-DSTIz9lr.js} +2 -2
  69. package/{ndash-J2nVccxt.js → ndash-DIDEyDVQ.js} +2 -2
  70. package/{number-XLQzxMnQ.js → number-gqt_QmBK.js} +8 -8
  71. package/{orbitalDiagram-4Hm9POl9.js → orbitalDiagram-CsmSBAmm.js} +2 -2
  72. package/{orbitalDiagramInput-De-KMtle.js → orbitalDiagramInput-_L3iCpvF.js} +2 -2
  73. package/{p-C9HA4vtR.js → p-BVDS0Z82.js} +4 -4
  74. package/package.json +1 -1
  75. package/{paginatorControls-B-ZC5EHv.js → paginatorControls-CdhphI9i.js} +2 -2
  76. package/{pegboard-DsrfuSI9.js → pegboard-XqFJYQR2.js} +3 -3
  77. package/{point-BgMPuCu9.js → point-D8MVTRjb.js} +6 -6
  78. package/{polygon-Ddq3F4qL.js → polygon-BMRgxRAm.js} +6 -6
  79. package/{polyline-DvrWa3hw.js → polyline-DrVPFk97.js} +5 -5
  80. package/{pre-HQzXPJZm.js → pre-CCavo6rV.js} +3 -3
  81. package/{prefigure-mSdit1v3.js → prefigure-D1TU89ND.js} +1 -1
  82. package/{pretzel-C7FFQwl-.js → pretzel-Ci6LMYP7.js} +4 -4
  83. package/{q-D8M2TT9O.js → q-DAtrD59K.js} +3 -3
  84. package/{ray-BSq679ZW.js → ray-BzzsI3ni.js} +5 -5
  85. package/{ref-CTbpmpt4.js → ref-CbtIuBV6.js} +3 -3
  86. package/{regionBetweenCurveXAxis-Dnv4q5HT.js → regionBetweenCurveXAxis-DJTv_wcJ.js} +5 -5
  87. package/{regionBetweenCurves-J8TYAiQE.js → regionBetweenCurves-BmQTnXGC.js} +5 -5
  88. package/{row-c9N5yFdD.js → row-Do8bpf7j.js} +2 -2
  89. package/{rq-tPOhpqqc.js → rq-jO7eoWFc.js} +2 -2
  90. package/{rsq-BMHVn1QN.js → rsq-CrJOK9r3.js} +2 -2
  91. package/{section-DOkLghJ1.js → section-Des0SqAh.js} +6 -6
  92. package/{sha256-8sXzDnE0-BfVXmeXa.js → sha256-8sXzDnE0-CgCDmaQw.js} +1 -1
  93. package/{sideBySide-DhmbKtKt.js → sideBySide-D67VUzm_.js} +2 -2
  94. package/{slider-ByExeA20.js → slider-CS3SAwUa.js} +4 -4
  95. package/{slopeField-CAMgLrX8.js → slopeField-UWDH1qdT.js} +2 -2
  96. package/{solution-DsPFL28w.js → solution-CD8o-q_c.js} +4 -4
  97. package/{spreadsheet-C2FleaWB.js → spreadsheet-CkR6qmVp.js} +2 -2
  98. package/{sq-BM8sI-i_.js → sq-BbRTcTOB.js} +3 -3
  99. package/style.css +3 -0
  100. package/{subsetOfRealsInput-B7eYWQIb.js → subsetOfRealsInput-BeyO8SZz.js} +3 -3
  101. package/{summaryStatistics-BxJzW6tf.js → summaryStatistics-B6dhFqSw.js} +2 -2
  102. package/{table-BGgizwL4.js → table-DOri6rVv.js} +2 -2
  103. package/{tabular-DD-U_c2j.js → tabular-DKhYyDKC.js} +2 -2
  104. package/{tag-DRPK8NxJ.js → tag-CxU24RNr.js} +2 -2
  105. package/{text-CxrayF2e.js → text-DvmLSjKe.js} +8 -8
  106. package/{textInput-vZJgVguQ.js → textInput-Cixst4Sn.js} +8 -8
  107. package/{tooltip-provider-C4v2PJ4S.js → tooltip-provider-D7EDS5HY.js} +2 -2
  108. package/{useAnchoredGraphDragHandler-MuB6CRjf.js → useAnchoredGraphDragHandler-Bg4DqLZT.js} +1 -1
  109. package/useDoenetRenderer-CNR6XAVz.js +114 -0
  110. package/{useFieldCurve-D3mdRiDS.js → useFieldCurve-C8OBi3vF.js} +2 -2
  111. package/{useSubmitActionWithDelay-C95MEHkn.js → useSubmitActionWithDelay--lbFfAgF.js} +2 -2
  112. package/{vector-5Hd-pAXC.js → vector-TNThnq4g.js} +6 -6
  113. package/{vectorField-Bw2xr9Tb.js → vectorField-DDrDftdS.js} +2 -2
  114. package/{video-et0DUivm.js → video-B2r7P6s-.js} +4 -4
  115. package/useDoenetRenderer-kwjSXJYx.js +0 -114
@@ -2781,5 +2781,5 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
2781
2781
  `};return lineEndings.LINE_ENDINGS=iA,lineEndings}var generator={},util={},capitalize={},hasRequiredCapitalize;function requireCapitalize(){return hasRequiredCapitalize||(hasRequiredCapitalize=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=function(nA){var rA=nA.trim();return rA.charAt(0).toUpperCase()+rA.slice(1)},AA=eA;iA.default=AA})(capitalize)),capitalize}var isNode={exports:{}},hasRequiredIsNode;function requireIsNode(){return hasRequiredIsNode||(hasRequiredIsNode=1,(function(iA,eA){Object.defineProperty(eA,"__esModule",{value:!0}),eA.default=void 0;var AA=function(){return!!iA.exports},tA=AA;eA.default=tA})(isNode,isNode.exports)),isNode.exports}var isReactNative={},hasRequiredIsReactNative;function requireIsReactNative(){return hasRequiredIsReactNative||(hasRequiredIsReactNative=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=function(){var nA=!1;try{nA=navigator.product==="ReactNative"}catch{nA=!1}return nA},AA=eA;iA.default=AA})(isReactNative)),isReactNative}var isWindows={},platforms={},hasRequiredPlatforms;function requirePlatforms(){if(hasRequiredPlatforms)return platforms;hasRequiredPlatforms=1,Object.defineProperty(platforms,"__esModule",{value:!0}),platforms.SUPPORTED_PLATFORMS=void 0;var iA={DARWIN:"darwin",LINUX:"linux",WIN32:"win32"};return platforms.SUPPORTED_PLATFORMS=iA,platforms}var hasRequiredIsWindows;function requireIsWindows(){return hasRequiredIsWindows||(hasRequiredIsWindows=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=requirePlatforms(),AA=function(){var rA=!1;try{rA=process.platform===eA.SUPPORTED_PLATFORMS.WIN32}catch{rA=!1}return rA},tA=AA;iA.default=tA})(isWindows)),isWindows}var makeArrayOfLength={},hasRequiredMakeArrayOfLength;function requireMakeArrayOfLength(){return hasRequiredMakeArrayOfLength||(hasRequiredMakeArrayOfLength=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=function(){var nA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return Array.apply(null,Array(nA)).map(function(rA,aA){return aA})},AA=eA;iA.default=AA})(makeArrayOfLength)),makeArrayOfLength}var makeArrayOfStrings={},hasRequiredMakeArrayOfStrings;function requireMakeArrayOfStrings(){return hasRequiredMakeArrayOfStrings||(hasRequiredMakeArrayOfStrings=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=AA(requireMakeArrayOfLength());function AA(rA){return rA&&rA.__esModule?rA:{default:rA}}var tA=function(aA,oA){var sA=(0,eA.default)(aA);return sA.map(function(){return oA()})},nA=tA;iA.default=nA})(makeArrayOfStrings)),makeArrayOfStrings}var hasRequiredUtil;function requireUtil(){return hasRequiredUtil||(hasRequiredUtil=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),Object.defineProperty(iA,"capitalize",{enumerable:!0,get:function(){return eA.default}}),Object.defineProperty(iA,"isNode",{enumerable:!0,get:function(){return AA.default}}),Object.defineProperty(iA,"isReactNative",{enumerable:!0,get:function(){return tA.default}}),Object.defineProperty(iA,"isWindows",{enumerable:!0,get:function(){return nA.default}}),Object.defineProperty(iA,"makeArrayOfLength",{enumerable:!0,get:function(){return rA.default}}),Object.defineProperty(iA,"makeArrayOfStrings",{enumerable:!0,get:function(){return aA.default}});var eA=oA(requireCapitalize()),AA=oA(requireIsNode()),tA=oA(requireIsReactNative()),nA=oA(requireIsWindows()),rA=oA(requireMakeArrayOfLength()),aA=oA(requireMakeArrayOfStrings());function oA(sA){return sA&&sA.__esModule?sA:{default:sA}}})(util)),util}var hasRequiredGenerator;function requireGenerator(){return hasRequiredGenerator||(hasRequiredGenerator=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=requireWords(),AA=requireUtil();function tA(lA,gA){if(!(lA instanceof gA))throw new TypeError("Cannot call a class as a function")}function nA(lA,gA){for(var cA=0;cA<gA.length;cA++){var IA=gA[cA];IA.enumerable=IA.enumerable||!1,IA.configurable=!0,"value"in IA&&(IA.writable=!0),Object.defineProperty(lA,IA.key,IA)}}function rA(lA,gA,cA){return gA&&nA(lA.prototype,gA),Object.defineProperty(lA,"prototype",{writable:!1}),lA}function aA(lA,gA,cA){return gA in lA?Object.defineProperty(lA,gA,{value:cA,enumerable:!0,configurable:!0,writable:!0}):lA[gA]=cA,lA}var oA=(function(){function lA(){var gA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},cA=gA.sentencesPerParagraph,IA=cA===void 0?{max:7,min:3}:cA,CA=gA.wordsPerSentence,uA=CA===void 0?{max:15,min:5}:CA,dA=gA.random;gA.seed;var pA=gA.words,mA=pA===void 0?eA.WORDS:pA;if(tA(this,lA),aA(this,"sentencesPerParagraph",void 0),aA(this,"wordsPerSentence",void 0),aA(this,"random",void 0),aA(this,"words",void 0),IA.min>IA.max)throw new Error("Minimum number of sentences per paragraph (".concat(IA.min,") cannot exceed maximum (").concat(IA.max,")."));if(uA.min>uA.max)throw new Error("Minimum number of words per sentence (".concat(uA.min,") cannot exceed maximum (").concat(uA.max,")."));this.sentencesPerParagraph=IA,this.words=mA,this.wordsPerSentence=uA,this.random=dA||Math.random}return rA(lA,[{key:"generateRandomInteger",value:function(cA,IA){return Math.floor(this.random()*(IA-cA+1)+cA)}},{key:"generateRandomWords",value:function(cA){var IA=this,CA=this.wordsPerSentence,uA=CA.min,dA=CA.max,pA=cA||this.generateRandomInteger(uA,dA);return(0,AA.makeArrayOfLength)(pA).reduce(function(mA,QA){return"".concat(IA.pluckRandomWord()," ").concat(mA)},"").trim()}},{key:"generateRandomSentence",value:function(cA){return"".concat((0,AA.capitalize)(this.generateRandomWords(cA)),".")}},{key:"generateRandomParagraph",value:function(cA){var IA=this,CA=this.sentencesPerParagraph,uA=CA.min,dA=CA.max,pA=cA||this.generateRandomInteger(uA,dA);return(0,AA.makeArrayOfLength)(pA).reduce(function(mA,QA){return"".concat(IA.generateRandomSentence()," ").concat(mA)},"").trim()}},{key:"pluckRandomWord",value:function(){var cA=0,IA=this.words.length-1,CA=this.generateRandomInteger(cA,IA);return this.words[CA]}}]),lA})(),sA=oA;iA.default=sA})(generator)),generator}var hasRequiredLoremIpsum;function requireLoremIpsum(){return hasRequiredLoremIpsum||(hasRequiredLoremIpsum=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),iA.default=void 0;var eA=requireFormats(),AA=requireLineEndings(),tA=rA(requireGenerator()),nA=requireUtil();function rA(IA){return IA&&IA.__esModule?IA:{default:IA}}function aA(IA,CA){if(!(IA instanceof CA))throw new TypeError("Cannot call a class as a function")}function oA(IA,CA){for(var uA=0;uA<CA.length;uA++){var dA=CA[uA];dA.enumerable=dA.enumerable||!1,dA.configurable=!0,"value"in dA&&(dA.writable=!0),Object.defineProperty(IA,dA.key,dA)}}function sA(IA,CA,uA){return CA&&oA(IA.prototype,CA),Object.defineProperty(IA,"prototype",{writable:!1}),IA}function lA(IA,CA,uA){return CA in IA?Object.defineProperty(IA,CA,{value:uA,enumerable:!0,configurable:!0,writable:!0}):IA[CA]=uA,IA}var gA=(function(){function IA(){var CA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},uA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:eA.FORMAT_PLAIN,dA=arguments.length>2?arguments[2]:void 0;if(aA(this,IA),this.format=uA,this.suffix=dA,lA(this,"generator",void 0),eA.FORMATS.indexOf(uA.toLowerCase())===-1)throw new Error("".concat(uA," is an invalid format. Please use ").concat(eA.FORMATS.join(" or "),"."));this.generator=new tA.default(CA)}return sA(IA,[{key:"getLineEnding",value:function(){return this.suffix?this.suffix:!(0,nA.isReactNative)()&&(0,nA.isNode)()&&(0,nA.isWindows)()?AA.LINE_ENDINGS.WIN32:AA.LINE_ENDINGS.POSIX}},{key:"formatString",value:function(uA){return this.format===eA.FORMAT_HTML?"<p>".concat(uA,"</p>"):uA}},{key:"formatStrings",value:function(uA){var dA=this;return uA.map(function(pA){return dA.formatString(pA)})}},{key:"generateWords",value:function(uA){return this.formatString(this.generator.generateRandomWords(uA))}},{key:"generateSentences",value:function(uA){return this.formatString(this.generator.generateRandomParagraph(uA))}},{key:"generateParagraphs",value:function(uA){var dA=this.generator.generateRandomParagraph.bind(this.generator);return this.formatStrings((0,nA.makeArrayOfStrings)(uA,dA)).join(this.getLineEnding())}}]),IA})(),cA=gA;iA.default=cA})(LoremIpsum)),LoremIpsum}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,(function(iA){Object.defineProperty(iA,"__esModule",{value:!0}),Object.defineProperty(iA,"LoremIpsum",{enumerable:!0,get:function(){return nA.default}}),iA.loremIpsum=void 0;var eA=requireFormats(),AA=requireUnits(),tA=requireWords(),nA=rA(requireLoremIpsum());function rA(oA){return oA&&oA.__esModule?oA:{default:oA}}var aA=function(){var sA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},lA=sA.count,gA=lA===void 0?1:lA,cA=sA.format,IA=cA===void 0?eA.FORMAT_PLAIN:cA,CA=sA.paragraphLowerBound,uA=CA===void 0?3:CA,dA=sA.paragraphUpperBound,pA=dA===void 0?7:dA,mA=sA.random,QA=sA.sentenceLowerBound,BA=QA===void 0?5:QA,hA=sA.sentenceUpperBound,DA=hA===void 0?15:hA,EA=sA.units,fA=EA===void 0?AA.UNIT_SENTENCES:EA,NA=sA.words,yA=NA===void 0?tA.WORDS:NA,bA=sA.suffix,wA=bA===void 0?"":bA,MA={random:mA,sentencesPerParagraph:{max:pA,min:uA},words:yA,wordsPerSentence:{max:DA,min:BA}},vA=new nA.default(MA,IA,wA);switch(fA){case AA.UNIT_PARAGRAPHS:case AA.UNIT_PARAGRAPH:return vA.generateParagraphs(gA);case AA.UNIT_SENTENCES:case AA.UNIT_SENTENCE:return vA.generateSentences(gA);case AA.UNIT_WORDS:case AA.UNIT_WORD:return vA.generateWords(gA);default:return""}};iA.loremIpsum=aA})(dist)),dist}var distExports=requireDist();class Lorem extends CompositeComponent{static componentType="lorem";static componentDocs={summary:"Generates lorem ipsum placeholder text"};static allowInSchemaAsComponent=["text","p"];static createsVariants=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.minSentencesPerParagraph={description:"Minimum number of sentences per generated paragraph.",createComponentOfType:"number",createStateVariable:"minSentencesPerParagraph",defaultValue:4,public:!0},eA.maxSentencesPerParagraph={description:"Maximum number of sentences per generated paragraph.",createComponentOfType:"number",createStateVariable:"maxSentencesPerParagraph",defaultValue:8,public:!0},eA.minWordsPerSentence={description:"Minimum number of words per generated sentence.",createComponentOfType:"number",createStateVariable:"minWordsPerSentence",defaultValue:4,public:!0},eA.maxWordsPerSentence={description:"Maximum number of words per generated sentence.",createComponentOfType:"number",createStateVariable:"maxWordsPerSentence",defaultValue:8,public:!0},eA.generateWords={createComponentOfType:"number",createStateVariable:"generateWords",defaultValue:null,description:"Number of words of lorem-ipsum to generate."},eA.generateSentences={createComponentOfType:"number",createStateVariable:"generateSentences",defaultValue:null,description:"Number of sentences of lorem-ipsum to generate."},eA.generateParagraphs={createComponentOfType:"number",createStateVariable:"generateParagraphs",defaultValue:null,description:"Number of paragraphs of lorem-ipsum to generate."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.readyToExpandWhenResolved={returnDependencies:()=>({minSentencesPerParagraph:{dependencyType:"stateVariable",variableName:"minSentencesPerParagraph"},maxSentencesPerParagraph:{dependencyType:"stateVariable",variableName:"maxSentencesPerParagraph"},minWordsPerSentence:{dependencyType:"stateVariable",variableName:"minWordsPerSentence"},maxWordsPerSentence:{dependencyType:"stateVariable",variableName:"maxWordsPerSentence"},generateWords:{dependencyType:"stateVariable",variableName:"generateWords"},generateSentences:{dependencyType:"stateVariable",variableName:"generateSentences"},generateParagraphs:{dependencyType:"stateVariable",variableName:"generateParagraphs"}}),markStale:()=>({updateReplacements:!0}),definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.isVariantComponent={returnDependencies:()=>({}),definition:()=>({setValue:{isVariantComponent:!0}})},eA.generatedVariantInfo={returnDependencies:({sharedParameters:AA,componentInfoObjects:tA})=>({variantSeed:{dependencyType:"value",value:AA.variantSeed}}),definition({dependencyValues:AA,componentIdx:tA}){return{setValue:{generatedVariantInfo:{seed:AA.variantSeed,meta:{createdBy:tA}}}}}},eA}static async createSerializedReplacements({component:eA,workspace:AA,nComponents:tA}){AA.replacementsCreated===void 0&&(AA.replacementsCreated=0);const nA={prefix:`${eA.stateId}|`,num:AA.replacementsCreated};let rA=[];const aA=new distExports.LoremIpsum({sentencesPerParagraph:{max:await eA.stateValues.maxSentencesPerParagraph,min:await eA.stateValues.minSentencesPerParagraph},wordsPerSentence:{max:await eA.stateValues.maxWordsPerSentence,min:await eA.stateValues.minWordsPerSentence},random:eA.sharedParameters.variantRng});let oA=[];if(await eA.stateValues.generateParagraphs!==null){let sA=await eA.stateValues.generateParagraphs;Number.isInteger(sA)&&sA>0&&(oA=aA.generateParagraphs(sA).split(`
2782
2782
  `).map(gA=>({type:"serialized",componentType:"p",componentIdx:tA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[gA]})))}else if(await eA.stateValues.generateSentences!==null){let sA=await eA.stateValues.generateSentences;if(Number.isInteger(sA)&&sA>0){let lA=aA.generateSentences(sA).split(". ");for(let gA of lA.slice(0,lA.length-1))oA.push({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[gA+"."]}),oA.push(" ");oA.push({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[lA[lA.length-1]]})}}else if(await eA.stateValues.generateWords!==null){let sA=await eA.stateValues.generateWords;if(Number.isInteger(sA)&&sA>0){let lA=aA.generateWords(sA).split(" ").map(gA=>({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[gA]}));oA.push(lA[0]);for(let gA of lA.slice(1))oA.push(" "),oA.push(gA)}}return AA.replacementsCreated=nA.num,{replacements:oA,diagnostics:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:nA}){let rA=[],aA=await this.createSerializedReplacements({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:nA});return rA.push(...aA.diagnostics),tA=aA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:aA.replacements}],diagnostics:rA,nComponents:tA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}}class UpdateValue extends InlineComponent{constructor(eA){super(eA),Object.assign(this.actions,{updateValue:this.updateValue.bind(this),updateValueIfTriggerNewlyTrue:this.updateValueIfTriggerNewlyTrue.bind(this),moveButton:this.moveButton.bind(this)})}static componentType="updateValue";static componentDocs={summary:"Updates one or more state variables on a target component"};static rendererType="button";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();eA.target={createReferences:!0,description:"Reference to the state variable that will be updated."},eA.type={createPrimitiveOfType:"string",createStateVariable:"type",defaultPrimitiveValue:"math",toLowerCase:!0,validValues:[{value:"math",description:"Treat the new value as a math expression."},{value:"number",description:"Treat the new value as a number."},{value:"boolean",description:"Treat the new value as a boolean."},{value:"text",description:"Treat the new value as text."}],description:"Component type used to interpret the new value."},eA.newValue={createComponentOfType:"_componentWithSelectableType",description:"New value to assign to the target."},eA.draggable={description:"Whether the update button can be dragged on a graph.",createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},Object.assign(eA,returnAnchorAttributes()),Object.assign(eA,returnLabelAttributes());let AA=returnStandardTriggeringAttributes("updateValueIfTriggerNewlyTrue");return Object.assign(eA,AA),eA.simplify={description:"Level of simplification applied to the new value.",createComponentOfType:"text",createStateVariable:"simplify",defaultValue:"none",public:!0,toLowerCase:!0,valueForTrue:"full",valueForFalse:"none",validValues:[{value:"none",description:"No simplification is applied."},{value:"full",description:"Fully simplify the new value."},{value:"numbers",description:"Simplify numeric subexpressions only, leaving symbolic structure intact."},{value:"numbersPreserveOrder",description:"Like `numbers`, but does not reorder commutative operands."},{value:"normalizeOrder",description:"Reorder commutative operands into a canonical form without simplifying values."}]},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA),addStandardTriggeringStateVariableDefinitions(eA,"updateValue");let tA=returnLabelStateVariableDefinitions();Object.assign(eA,tA),Object.assign(eA,returnRenderOnlyLabelChildDefinitions());let nA=returnAnchorStateVariableDefinition();return Object.assign(eA,nA),eA.clickAction={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{clickAction:"updateValue"}})},eA.targetComponentIdx={additionalStateVariablesDefined:["unresolvedPath","targetOriginalPath"],returnDependencies:()=>({target:{dependencyType:"attributeRefResolutions",attributeName:"target"}}),definition({dependencyValues:rA}){if(rA.target?.length===1){const aA=rA.target[0];return{setValue:{targetComponentIdx:aA.componentIdx,unresolvedPath:aA.unresolvedPath,targetOriginalPath:aA.originalPath}}}else return{setValue:{targetComponentIdx:null,unresolvedPath:null,targetOriginalPath:null}}}},eA.targetComponent={stateVariablesDeterminingDependencies:["targetComponentIdx"],returnDependencies({stateValues:rA}){return rA.targetComponentIdx!=null?{targetComponent:{dependencyType:"componentIdentity",componentIdx:rA.targetComponentIdx}}:{}},definition:function({dependencyValues:rA}){let aA=null;return rA.targetComponent&&(aA=rA.targetComponent),{setValue:{targetComponent:aA}}}},eA.targetIdentities={stateVariablesDeterminingDependencies:["targetComponent"],returnDependencies:function({stateValues:rA,componentInfoObjects:aA}){let oA={};return rA.targetComponent!==null&&(aA.isCompositeComponent({componentType:rA.targetComponent.componentType,includeNonStandard:!1})?oA.targets={dependencyType:"replacement",compositeIdx:rA.targetComponent.componentIdx,recursive:!0}:oA.targets={dependencyType:"stateVariable",variableName:"targetComponent"}),oA},definition({dependencyValues:rA}){let aA=null;rA.targets&&(aA=rA.targets,Array.isArray(aA)||(aA=[aA]));let oA=[];return(aA===null||aA.length===0)&&oA.push(codedDiagnostic({type:"warning",code:"doenet-w0043",args:{source:"updateValue"}})),{setValue:{targetIdentities:aA},sendDiagnostics:oA}}},eA.targets={stateVariablesDeterminingDependencies:["targetIdentities","unresolvedPath","targetOriginalPath"],returnDependencies:function({stateValues:rA}){let aA={targetIdentities:{dependencyType:"stateVariable",variableName:"targetIdentities"},unresolvedPath:{dependencyType:"stateVariable",variableName:"unresolvedPath"}};if(rA.targetIdentities!==null)for(let[oA,sA]of rA.targetIdentities.entries()){let lA;if(rA.unresolvedPath){let gA=rA.propIndex;gA&&(gA=[...gA]),lA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:sA.componentIdx,unresolvedPath:rA.unresolvedPath,referenceOriginalPath:rA.targetOriginalPath,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else lA={dependencyType:"stateVariable",componentIdx:sA.componentIdx,variableName:"value",returnAsComponentObject:!0,variablesOptional:!0};aA["target"+oA]=lA}return aA},definition({dependencyValues:rA}){let aA=null,oA=[];if(rA.targetIdentities!==null){aA=[];for(let sA in rA.targetIdentities){let lA=rA["target"+sA];if(lA==null){oA.push(codedDiagnostic({type:"warning",code:"doenet-w0043",args:{source:"updateValue"}}));continue}if(aA.push(lA),Object.keys(lA.stateValues)[0]===void 0)if(rA.unresolvedPath){let gA=rA.unresolvedPath[0].name;if(rA.unresolvedPath[0].index.length>0)for(const cA of rA.unresolvedPath[0].index)gA+="[idx]";oA.push(codedDiagnostic({type:"warning",code:"doenet-w0044",args:{source:"updateValue",property:gA,component:lA.componentType}}))}else oA.push(codedDiagnostic({type:"warning",code:"doenet-w0044",args:{source:"updateValue",property:"value",component:lA.componentType}}))}}return{setValue:{targets:aA},sendDiagnostics:oA}}},eA.newValue={returnDependencies:()=>({newValueAttr:{dependencyType:"attributeComponent",attributeName:"newValue",variableNames:["value"]},type:{dependencyType:"stateVariable",variableName:"type"},simplify:{dependencyType:"stateVariable",variableName:"simplify"}}),definition:function({dependencyValues:rA}){if(rA.newValueAttr===null)return{setValue:{newValue:null}};let aA=rA.newValueAttr.stateValues.value;return rA.type==="math"&&(aA=normalizeMathExpression({value:aA,simplify:rA.simplify})),{setValue:{newValue:aA}}}},eA}async updateValue({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let nA=await this.stateValues.targets,rA=await this.stateValues.newValue;if(nA===null||rA===null)return;let aA=[];for(let oA of nA){let sA=Object.keys(oA.stateValues)[0];sA!==void 0&&aA.push({updateType:"updateValue",componentIdx:oA.componentIdx,stateVariable:sA,value:rA})}return await this.coreFunctions.performUpdate({updateInstructions:aA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"selected",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{response:rA,responseText:rA.toString()}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}async updateValueIfTriggerNewlyTrue({stateValues:eA,previousValues:AA,actionId:tA}){if(await eA.triggerWhen&&AA.triggerWhen===!1&&!await this.stateValues.insideTriggerSet)return await this.updateValue({actionId:tA,skipRendererUpdate:!0})}async moveButton({x:eA,y:AA,z:tA,transient:nA,actionId:rA,sourceInformation:aA={},skipRendererUpdate:oA=!1}){return await moveGraphicalObjectWithAnchorAction({x:eA,y:AA,z:tA,transient:nA,actionId:rA,sourceInformation:aA,skipRendererUpdate:oA,componentIdx:this.componentIdx,componentType:this.componentType,coreFunctions:this.coreFunctions})}}class CallAction extends InlineComponent{constructor(eA){super(eA),Object.assign(this.actions,{callAction:this.callAction.bind(this),callActionIfTriggerNewlyTrue:this.callActionIfTriggerNewlyTrue.bind(this),moveButton:this.moveButton.bind(this)})}static componentType="callAction";static componentDocs={summary:"Triggers an action when clicked or in response to a specified user interaction"};static rendererType="button";static renderChildren=!0;static additionalSchemaChildren=["_base"];static keepChildrenSerialized({serializedComponent:eA,componentInfoObjects:AA}){if(eA.children===void 0)return[];{let tA=[];for(let[nA,rA]of eA.children.entries())AA.componentIsSpecifiedType(rA,"label")||tA.push(nA);return tA}}static createAttributesObject(){let eA=super.createAttributesObject();eA.target={createReferences:!0,description:"Reference to the component whose action will be invoked."},eA.actionName={createComponentOfType:"text",createStateVariable:"actionName",defaultValue:null,public:!0,description:"Name of the action to invoke on the target component."},eA.draggable={createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0,description:"Whether the action button can be dragged on a graph."},Object.assign(eA,returnLabelAttributes()),Object.assign(eA,returnAnchorAttributes());let AA=returnStandardTriggeringAttributes("callActionIfTriggerNewlyTrue");return Object.assign(eA,AA),eA.numbers={createComponentOfType:"numberList",description:"Numeric arguments passed to the invoked action."},eA.number={createComponentOfType:"number",description:"Numeric argument passed to the invoked action."},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA),addStandardTriggeringStateVariableDefinitions(eA,"callAction");let tA=returnLabelStateVariableDefinitions();Object.assign(eA,tA),Object.assign(eA,returnRenderOnlyLabelChildDefinitions());let nA=returnAnchorStateVariableDefinition();return Object.assign(eA,nA),eA.clickAction={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{clickAction:"callAction"}})},eA.targetComponentIdx={additionalStateVariablesDefined:["unresolvedPath","targetOriginalPath"],returnDependencies:()=>({target:{dependencyType:"attributeRefResolutions",attributeName:"target"}}),definition({dependencyValues:rA}){if(rA.target?.length===1){const aA=rA.target[0];if(aA.unresolvedPath==null)return{setValue:{targetComponentIdx:aA.componentIdx,unresolvedPath:aA.unresolvedPath,targetOriginalPath:aA.originalPath}}}return{setValue:{targetComponentIdx:null,unresolvedPath:null,targetOriginalPath:null}}}},eA}async callAction({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let nA=await this.stateValues.targetComponentIdx,rA=await this.stateValues.actionName;if(nA!=null&&rA!=null){let aA={sourceInformation:AA,skipRendererUpdate:!0};this.serializedChildren.length>0&&(aA.serializedComponents=deepClone(this.serializedChildren)),this.attributes.number&&(aA.number=await this.attributes.number.component.stateValues.value),this.attributes.numbers&&(aA.numbers=await this.attributes.numbers.component.stateValues.numbers),eA&&(aA.actionId=eA),(await this.coreFunctions.performAction({componentIdx:nA,actionName:rA,args:aA,event:{verb:"selected",object:{componentIdx:this.componentIdx,componentType:this.componentType}},caseInsensitiveMatch:!0}))?.actionUnavailable&&await this.warnActionUnavailable(rA),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}async warnActionUnavailable(eA){const AA=this.coreFunctions.doenetMLStringForReference(await this.stateValues.targetOriginalPath);AA&&this.coreFunctions.addDiagnostic(codedDiagnostic({type:"warning",code:"doenet-w0102",args:{action:eA,reference:`$${AA}`},position:this.position,sourceDoc:this.sourceDoc}))}async callActionIfTriggerNewlyTrue({stateValues:eA,previousValues:AA,actionId:tA}){if(eA.triggerWhen&&AA.triggerWhen===!1&&!await this.stateValues.insideTriggerSet)return await this.callAction({actionId:tA})}async moveButton({x:eA,y:AA,z:tA,transient:nA,actionId:rA,sourceInformation:aA={},skipRendererUpdate:oA=!1}){return await moveGraphicalObjectWithAnchorAction({x:eA,y:AA,z:tA,transient:nA,actionId:rA,sourceInformation:aA,skipRendererUpdate:oA,componentIdx:this.componentIdx,componentType:this.componentType,coreFunctions:this.coreFunctions})}}class triggerSet extends InlineComponent{constructor(eA){super(eA),Object.assign(this.actions,{triggerActions:this.triggerActions.bind(this),triggerActionsIfTriggerNewlyTrue:this.triggerActionsIfTriggerNewlyTrue.bind(this),moveButton:this.moveButton.bind(this)})}static componentType="triggerSet";static componentDocs={summary:"Groups a set of `<updateValue>` or `<callAction>` components which share a single trigger condition"};static rendererType="button";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();eA.draggable={description:"Whether the trigger set's button can be dragged on a graph.",createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},Object.assign(eA,returnAnchorAttributes()),Object.assign(eA,returnLabelAttributes());let AA=returnStandardTriggeringAttributes("triggerActionsIfTriggerNewlyTrue");return Object.assign(eA,AA),eA}static returnChildGroups(){return[{group:"updateValuesCallActions",componentTypes:["updateValue","callAction"]},{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA),addStandardTriggeringStateVariableDefinitions(eA,"triggerActions");let tA=returnLabelStateVariableDefinitions();Object.assign(eA,tA),Object.assign(eA,returnRenderOnlyLabelChildDefinitions());let nA=returnAnchorStateVariableDefinition();return Object.assign(eA,nA),eA.clickAction={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{clickAction:"triggerActions"}})},eA.updateValueAndActionsToTrigger={returnDependencies:()=>({updateValueAndCallActionChildren:{dependencyType:"child",childGroups:["updateValuesCallActions"]}}),definition({dependencyValues:rA}){return{setValue:{updateValueAndActionsToTrigger:rA.updateValueAndCallActionChildren}}}},eA}async triggerActions({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){for(let nA of await this.stateValues.updateValueAndActionsToTrigger)this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:nA.componentType,baseComponentType:"updateValue"})?await this.coreFunctions.performAction({componentIdx:nA.componentIdx,actionName:"updateValue",args:{actionId:eA,sourceInformation:AA,skipRendererUpdate:!0}}):this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:nA.componentType,baseComponentType:"callAction"})&&await this.coreFunctions.performAction({componentIdx:nA.componentIdx,actionName:"callAction",args:{actionId:eA,sourceInformation:AA,skipRendererUpdate:!0}});return await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}async triggerActionsIfTriggerNewlyTrue({stateValues:eA,previousValues:AA,actionId:tA}){if(eA.triggerWhen&&AA.triggerWhen===!1)return await this.triggerActions({actionId:tA,skipRendererUpdate:!0})}async moveButton({x:eA,y:AA,z:tA,transient:nA,actionId:rA,sourceInformation:aA={},skipRendererUpdate:oA=!1}){return await moveGraphicalObjectWithAnchorAction({x:eA,y:AA,z:tA,transient:nA,actionId:rA,sourceInformation:aA,skipRendererUpdate:oA,componentIdx:this.componentIdx,componentType:this.componentType,coreFunctions:this.coreFunctions})}}class FunctionIterates extends InlineComponent{static componentType="functionIterates";static componentDocs={summary:"List of values produced by iterating a function"};static rendererType=void 0;static variableForIndexAsProp="iterates";static createAttributesObject(){let eA=super.createAttributesObject();return eA.numIterates={description:"Number of iterations to compute.",createComponentOfType:"integer",createStateVariable:"numIterates",defaultValue:0,public:!0},eA.forceSymbolic={description:"Whether to force symbolic evaluation.",createComponentOfType:"boolean",createStateVariable:"forceSymbolic",defaultValue:!1,public:!0},eA.forceNumeric={description:"Whether to force numeric evaluation.",createComponentOfType:"boolean",createStateVariable:"forceNumeric",defaultValue:!1,public:!0},eA.initialValue={createComponentOfType:"math",createStateVariable:"initialValue",defaultValue:context.fromAst("_"),description:"Starting value passed to the function on the first iteration."},eA.function={createComponentOfType:"function",description:"The function to iterate."},Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.numDimensions={description:"Number of dimensions of each iterate.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["numInputs","numOutputs"]}}),definition({dependencyValues:AA}){if(AA.functionAttr)if(AA.functionAttr.stateValues.numInputs!==AA.functionAttr.stateValues.numOutputs){let tA=AA.functionAttr.stateValues.numInputs,nA=AA.functionAttr.stateValues.numOutputs,rA=codedDiagnostic({type:"warning",code:"doenet-w0056",args:{inputs:tA,outputs:nA},position:AA.functionAttr.position||void 0});return{setValue:{numDimensions:0},sendDiagnostics:[rA]}}else return{setValue:{numDimensions:AA.functionAttr.stateValues.numInputs}};else return{setValue:{numDimensions:0}}}},eA.allIterates={description:"All computed iterates of the function.",public:!0,shadowingInstructions:{createComponentOfType:"mathList",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["symbolicfs","numericalfs","symbolic"]},forceSymbolic:{dependencyType:"stateVariable",variableName:"forceSymbolic"},forceNumeric:{dependencyType:"stateVariable",variableName:"forceNumeric"},numDimensions:{dependencyType:"stateVariable",variableName:"numDimensions"},initialValue:{dependencyType:"stateVariable",variableName:"initialValue"},numIterates:{dependencyType:"stateVariable",variableName:"numIterates"}}),definition({dependencyValues:AA}){let tA=[],nA=AA.functionAttr,rA=AA.initialValue,aA=!AA.forceNumeric&&(nA.stateValues.symbolic||AA.forceSymbolic),oA=AA.numIterates;if(!nA||AA.numDimensions===0||!(AA.numDimensions===1||Array.isArray(rA.tree)&&vectorOperators.includes(rA.tree[0])&&rA.tree.length===AA.numDimensions+1))return tA=Array(oA).fill(context.fromAst("_")),{setValue:{allIterates:tA}};if(aA)if(AA.numDimensions===1){let sA=nA.stateValues.symbolicfs[0],lA=rA;for(let gA=0;gA<oA;gA++)lA=sA(lA),tA.push(lA)}else{let sA=nA.stateValues.symbolicfs,lA=rA.tree.slice(1).map(gA=>context.fromAst(gA));for(let gA=0;gA<oA;gA++){let cA=[];for(let IA=0;IA<AA.numDimensions;IA++)cA.push(sA[IA](...lA).tree);tA.push(context.fromAst(["vector",...cA])),lA=cA.map(IA=>context.fromAst(IA))}}else if(AA.numDimensions===1){let sA=nA.stateValues.numericalfs[0],lA=rA.evaluate_to_constant();if(!isNumericConstant(lA))tA=Array(oA).fill(context.fromAst("_"));else for(let gA=0;gA<oA;gA++)lA=sA(lA),tA.push(context.fromAst(lA))}else{let sA=nA.stateValues.numericalfs,lA=rA.tree.slice(1).map(gA=>evaluateToNumber(context.fromAst(gA)));for(let gA=0;gA<oA;gA++){let cA=[];for(let IA=0;IA<AA.numDimensions;IA++)cA.push(sA[IA](...lA));tA.push(context.fromAst(["vector",...cA])),lA=cA}}return{setValue:{allIterates:tA}}}},eA.allIteratesWithInitial={description:"All iterates including the initial value.",public:!0,shadowingInstructions:{createComponentOfType:"mathList",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({initialValue:{dependencyType:"stateVariable",variableName:"initialValue"},allIterates:{dependencyType:"stateVariable",variableName:"allIterates"}}),definition({dependencyValues:AA}){return{setValue:{allIteratesWithInitial:[AA.initialValue,...AA.allIterates]}}}},eA.iterates={description:"The list of iterate values.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},entryPrefixes:["iterate"],returnArraySizeDependencies:()=>({numIterates:{dependencyType:"stateVariable",variableName:"numIterates"}}),returnArraySize({dependencyValues:AA}){return[AA.numIterates]},returnArrayDependenciesByKey(){return{globalDependencies:{allIterates:{dependencyType:"stateVariable",variableName:"allIterates"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let nA={};for(let rA=0;rA<tA[0];rA++)nA[rA]=AA.allIterates[rA];return{setValue:{iterates:nA}}}},eA.finalIterate={description:"The last iterate value.",public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},stateVariablesDeterminingDependencies:["numIterates"],returnDependencies({stateValues:AA}){return!Number.isFinite(AA.numIterates)||AA.numIterates<0?{}:AA.numIterates>0?{finalIterate:{dependencyType:"stateVariable",variableName:`iterate${AA.numIterates}`}}:{finalIterate:{dependencyType:"stateVariable",variableName:"initialValue"}}},definition({dependencyValues:AA}){return{setValue:{finalIterate:AA.finalIterate}}}},eA}}class Module extends Group{static componentType="module";static componentDocs={summary:"A reusable group with parameterized attributes; can be copied elsewhere with new parameter values"};static acceptAnyAttribute=!0;static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.styleNumber,eA}}class ModuleAttributes extends CompositeComponent{static componentType="moduleAttributes";static componentDocs={summary:"Declares attributes accepted by an enclosing `<module>`"};static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static additionalSchemaChildren=["_base"];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.moduleIdx={returnDependencies:()=>({sourceCompositeIdentity:{dependencyType:"sourceCompositeIdentity"}}),definition({dependencyValues:AA}){let tA=null;return AA.sourceCompositeIdentity&&AA.sourceCompositeIdentity.componentType==="module"&&(tA=AA.sourceCompositeIdentity.componentIdx),{setValue:{moduleIdx:tA}}}},eA.serializedChildren={returnDependencies:()=>({serializedChildren:{dependencyType:"serializedChildren",doNotProxy:!0}}),definition:function({dependencyValues:AA}){return{setValue:{serializedChildren:AA.serializedChildren}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({componentIdentity:{dependencyType:"stateVariable",variableName:"moduleIdx"}}),definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,nComponents:nA,workspace:rA}){rA.replacementsCreated===void 0&&(rA.replacementsCreated=0);const aA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated},oA=[],sA=await eA.stateValues.moduleIdx;if(sA===null)return{replacements:[],diagnostics:oA,nComponents:nA};const lA=AA[sA],gA={};for(let dA in lA.attributes)gA[dA.toLowerCase()]=dA;const cA=Object.keys(lA.constructor.createAttributesObject()).map(dA=>dA.toLowerCase());cA.push("name");const IA=[],CA=deepClone(await eA.state.serializedChildren.value);for(const dA of CA){const pA=dA.attributes.name?.primitive?.value;if(!pA){IA.push(dA),oA.push(codedDiagnostic({type:"warning",code:"doenet-w0074",args:{component:dA.componentType},position:dA.position}));continue}let mA=gA[pA.toLowerCase()],QA=lA.attributes[mA];if(QA===void 0){IA.push(dA);continue}if(cA.includes(mA)){oA.push(codedDiagnostic({type:"warning",code:"doenet-w0075",args:{component:dA.componentType,name:pA},position:dA.position})),IA.push(dA);continue}if(QA.type!=="unresolved")throw Error("A module attribute that isn't an existing attribute must be unresolved!");const BA=deepClone(QA.children);setUnflattenedReferenceOrigins(BA,sA);const hA=expandUnflattenedToSerializedComponents({serializedComponents:BA,componentInfoObjects:tA,nComponents:nA,stateIdInfo:aA});oA.push(...hA.diagnostics),nA=hA.nComponents,dA.children=hA.components;const DA=applySugar({serializedComponents:[dA],componentInfoObjects:tA,nComponents:nA,stateIdInfo:aA});oA.push(...DA.diagnostics),nA=DA.nComponents,IA.push(DA.components[0])}const uA={type:"serialized",componentType:"setup",componentIdx:nA++,stateId:`${aA.prefix}${aA.num++}`,children:IA,attributes:{},doenetAttributes:{},state:{}};return rA.replacementsCreated=aA.num,{replacements:[uA],diagnostics:oA,nComponents:nA}}}class Footnote extends InlineComponent{static componentType="footnote";static renderChildren=!0;static componentDocs={summary:"Inline footnote whose body is shown on demand and is auto-numbered in the document"};static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"inlines",componentTypes:["_inline"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.text={description:"The footnote's body as plain text.",public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:function({dependencyValues:AA}){return{setValue:{text:textFromChildren(AA.inlineChildren)}}}},eA.footnoteTag={description:"The auto-generated marker (number) used to reference this footnote.",public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,mustEvaluate:!0,returnDependencies:()=>({footnoteCounter:{dependencyType:"counter",counterName:"footnote"}}),definition({dependencyValues:AA}){return{setValue:{footnoteTag:String(AA.footnoteCounter)}}}},eA}}class Caption extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="caption";static rendererType="containerInline";static canDisplayChildErrors=!0;static componentDocs={summary:"A caption attached to a figure or table"};static renderChildren=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"inlinesBlocks",componentTypes:["_inline","_block"]},{group:"errors",componentTypes:["_error"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.text={description:"The caption rendered as a plain text string.",public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlinesBlocks"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:function({dependencyValues:AA}){return{setValue:{text:textFromChildren(AA.inlineChildren)}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Endpoint extends Point{static componentType="endpoint";static rendererType="point";static componentDocs={summary:"A point that marks the endpoint of an interval, rendered open or closed"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.markerStyle={...eA.markerStyle,validValues:markerStyleValuesWithFillVariants},delete eA.markerFilled,eA.open={createComponentOfType:"boolean",createStateVariable:"open",defaultValue:!1,public:!0,forRenderer:!0,description:"Whether the endpoint is open (excluded) rather than closed (included)."},eA.switchable={createComponentOfType:"boolean",createStateVariable:"switchable",defaultValue:!1,public:!0,forRenderer:!0,description:"Whether the user can toggle the endpoint between open and closed by clicking it."},eA}async switchPoint({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(await this.stateValues.switchable)return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"open",value:!await this.stateValues.open}],actionId:eA,sourceInformation:AA,skipRendererUpdate:tA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{open:!await this.stateValues.open}}})}}function arrangementFromCopiedComponents(iA,eA){if(iA===void 0||iA.length!==eA.length)return null;const AA=new Map;for(const[rA,aA]of iA.entries()){let oA=AA.get(aA);oA===void 0&&(oA=[],AA.set(aA,oA)),oA.push(rA)}const tA=[],nA=new Map;for(const rA of eA){const aA=AA.get(rA),oA=nA.get(rA)??0;if(aA===void 0||oA>=aA.length)return null;tA.push(aA[oA]),nA.set(rA,oA+1)}return tA}function worthRearranging(iA){let eA=0;for(const[AA,tA]of iA.entries())tA===AA&&eA++;return eA*2>=iA.length}function replacementsMatchCopied(iA,eA){return iA.length===eA.length&&eA.every((AA,tA)=>iA[tA]?.shadows?.componentIdx===AA)}class Sort extends CompositeComponent{static componentType="sort";static componentDocs={summary:"Sorts a list according to a comparison function"};static takesIndex=!0;static allowInSchemaAnywhere=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.sortVectorsBy={groupName:"sorting",description:"Whether to sort vectors by component or by magnitude.",createComponentOfType:"text",createStateVariable:"sortVectorsBy",defaultValue:"displacement",public:!0,toLowerCase:!0,validValues:[{value:"displacement",description:"Sort vectors by their displacement components."},{value:"tail",description:"Sort vectors by the position of their tail point."}]},eA.sortByComponent={groupName:"sorting",description:"Index of the component to sort by (when sorting vectors).",createComponentOfType:"integer",createStateVariable:"sortByComponent",defaultValue:"1",public:!0},eA.sortByProp={createPrimitiveOfType:"string",highlighted:!0,groupName:"sorting",description:'Name of a property to sort by (e.g. "x" for sorting points by x-coordinate).'},eA.type={createPrimitiveOfType:"string",highlighted:!0,description:"Component type to sort bare string children as. Omit it and they are read as what they look like: every piece naming a number sorts by value, anything else sorts alphabetically.",validValues:[{value:"number",description:"Read bare strings as numbers, ordered by value."},{value:"math",description:"Read bare strings as math expressions, ordered by value."},{value:"text",description:"Read bare strings as text, ordered alphabetically."},{value:"boolean",description:"Read bare strings as booleans, ordered with false before true."}]},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asList",defaultValue:!0,highlighted:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoTypeSugarInstruction(this.componentType)),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnListValueStateVariableDefinitions({componentName:this.componentType,supportProps:!0})),eA.sortedValues={returnDependencies:()=>({listValues:{dependencyType:"stateVariable",variableName:"listValues"},allAreNumeric:{dependencyType:"stateVariable",variableName:"allAreNumeric"}}),definition({dependencyValues:AA}){let tA=[...AA.listValues];return tA.sort((nA,rA)=>compareExtractedValues(nA,rA,AA.allAreNumeric)),{setValue:{sortedValues:tA}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({sortedValues:{dependencyType:"stateVariable",variableName:"sortedValues"}}),markStale:()=>({updateReplacements:!0}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,workspace:nA,nComponents:rA}){let aA=[],oA=[],sA=[];nA.replacementsCreated===void 0&&(nA.replacementsCreated=0);const lA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated};for(let gA of await eA.stateValues.sortedValues){let cA;if(gA.listInd===void 0?cA=AA[gA.componentIdx]:cA=AA[gA.componentIdx].activeChildren[gA.listInd],cA){sA.push(cA.componentIdx);const IA=await cA.serialize(),CA=createNewComponentIndices([IA],rA,lA);rA=CA.nComponents,oA.push(CA.components[0])}}return oA=postProcessCopy({serializedComponents:oA,componentIdx:eA.componentIdx,addShadowDependencies:!0,markAsPrimaryShadow:!0}),nA.componentsCopied=sA,nA.replacementsCreated=lA.num,{replacements:oA,diagnostics:aA,nComponents:rA}}static async calculateReplacementChanges({component:eA,components:AA,componentInfoObjects:tA,workspace:nA,nComponents:rA}){let aA=[],oA=[];for(let CA of await eA.stateValues.sortedValues){let uA;CA.listInd===void 0?uA=AA[CA.componentIdx]:uA=AA[CA.componentIdx].activeChildren[CA.listInd],uA&&oA.push(uA.componentIdx)}const sA=replacementsMatchCopied(eA.replacements,nA.componentsCopied);if(sA&&oA.length==nA.componentsCopied.length&&nA.componentsCopied.every((CA,uA)=>CA===oA[uA]))return{replacementChanges:[],diagnostics:aA,nComponents:rA};const lA=arrangementFromCopiedComponents(nA.componentsCopied,oA);if(sA&&lA&&worthRearranging(lA))return nA.componentsCopied=oA,{replacementChanges:[{changeType:"rearrangeReplacements",arrangement:lA}],diagnostics:aA,nComponents:rA};let gA=await this.createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,workspace:nA,nComponents:rA}),cA=gA.replacements;return aA.push(...gA.diagnostics),rA=gA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:cA}],diagnostics:aA,nComponents:rA}}}class Shuffle extends CompositeComponent{static componentType="shuffle";static componentDocs={summary:"Randomly shuffles its children"};static takesIndex=!0;static allowInSchemaAnywhere=!0;static createsVariants=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.type={highlighted:!0,createPrimitiveOfType:"string",description:"Component type to read bare string children as. Omit it and they are read as what they look like: every piece naming a number makes them numbers, anything else makes them text.",validValues:[{value:"number",description:"Read bare strings as numbers."},{value:"math",description:"Read bare strings as math expressions."},{value:"text",description:"Read bare strings as text."},{value:"boolean",description:"Read bare strings as booleans."}]},eA.asList={highlighted:!0,createPrimitiveOfType:"boolean",createStateVariable:"asList",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoTypeSugarInstruction(this.componentType)),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.originalComponentIndices={additionalStateVariablesDefined:["numComponents"],returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["componentIndicesInList"],variablesOptional:!0}}),definition({dependencyValues:AA}){let tA=[];const nA=[];for(let rA of AA.children)typeof rA=="string"&&nA.push(codedDiagnostic({type:"warning",code:"doenet-w0015",args:{value:rA,component:"shuffle"}})),rA.stateValues?.componentIndicesInList?tA.push(...rA.stateValues.componentIndicesInList):tA.push(rA.componentIdx);return{setValue:{originalComponentIndices:tA,numComponents:tA.length},sendDiagnostics:nA}}},eA.componentOrder={returnDependencies({sharedParameters:AA}){return{variantSeed:{dependencyType:"value",value:AA.variantSeed},rngClass:{dependencyType:"value",value:AA.rngClass,doNotProxy:!0},numComponents:{dependencyType:"stateVariable",variableName:"numComponents"},variants:{dependencyType:"variants"}}},definition({dependencyValues:AA}){let tA=[],nA=AA.numComponents,rA=AA.variants?.desiredVariant?.indices;if(rA!==void 0)if(rA.length!==nA)tA.push(codedDiagnostic({type:"info",code:"doenet-i0006"}));else{if(rA=rA.map(Number),!rA.every(Number.isInteger))throw Error("All indices specified for shuffle must be integers");if(!rA.every(sA=>sA>=1&&sA<=nA))tA.push(codedDiagnostic({type:"info",code:"doenet-i0007",args:{component:"shuffle"}}));else return{setValue:{componentOrder:rA.filter(sA=>sA!==void 0)}}}let aA=AA.rngClass(AA.variantSeed+"co"),oA=[...Array(nA).keys()].map(sA=>sA+1);for(let sA=nA-1;sA>0;sA--){const lA=aA(),gA=Math.floor(lA*(sA+1));[oA[sA],oA[gA]]=[oA[gA],oA[sA]]}return{setValue:{componentOrder:oA},sendDiagnostics:tA}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({sortedValues:{dependencyType:"stateVariable",variableName:"componentOrder"}}),markStale:()=>({updateReplacements:!0}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({componentInfoObjects:AA,sharedParameters:tA})=>({variantSeed:{dependencyType:"value",value:tA.variantSeed},componentOrder:{dependencyType:"stateVariable",variableName:"componentOrder"},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(AA.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],useReplacementsForComposites:!0,recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:AA,componentIdx:tA}){let nA={seed:AA.variantSeed,meta:{createdBy:tA},indices:AA.componentOrder},rA=nA.subvariants=[];for(let aA of AA.variantDescendants)aA.stateValues.isVariantComponent?rA.push(aA.stateValues.generatedVariantInfo):aA.stateValues.generatedVariantInfo&&rA.push(...aA.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:nA,isVariantComponent:!0}}}},eA}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}static async createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,workspace:nA,nComponents:rA}){let aA=[],oA=[],sA=[];nA.replacementsCreated===void 0&&(nA.replacementsCreated=0);const lA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated};let gA=await eA.stateValues.originalComponentIndices;const cA=[];for(let IA of await eA.stateValues.componentOrder){let CA=AA[gA[IA-1]];CA&&(sA.push(CA.componentIdx),cA.push(CA))}return{replacements:oA,nComponents:rA}=await this.copyReplacementSources({component:eA,replacementSources:cA,nComponents:rA,stateIdInfo:lA}),nA.componentsCopied=sA,nA.replacementsCreated=lA.num,{replacements:oA,diagnostics:aA,nComponents:rA}}static async copyReplacementSources({component:eA,replacementSources:AA,nComponents:tA,stateIdInfo:nA}){let rA=[];for(const aA of AA){const oA=await aA.serialize(),sA=createNewComponentIndices([oA],tA,nA);tA=sA.nComponents,rA.push(...sA.components)}return rA=postProcessCopy({serializedComponents:rA,componentIdx:eA.componentIdx,addShadowDependencies:!0,markAsPrimaryShadow:!0}),{replacements:rA,nComponents:tA}}static async recreateMissingReplacements({component:eA,components:AA,workspace:tA,nComponents:nA,diagnostics:rA}){const aA=[],oA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated};let sA=0;for(const[lA,gA]of tA.componentsCopied.entries()){if(eA.replacements[sA]?.shadows?.componentIdx===gA){sA++;continue}const IA=AA[gA];if(!IA)continue;const CA=await this.copyReplacementSources({component:eA,replacementSources:[IA],nComponents:nA,stateIdInfo:oA});nA=CA.nComponents,aA.push({changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:lA,numberReplacementsToReplace:0,numberDeletedReplacementsToReplace:1,serializedReplacements:CA.replacements})}return tA.replacementsCreated=oA.num,{replacementChanges:aA,diagnostics:rA,nComponents:nA}}static async calculateReplacementChanges({component:eA,components:AA,componentInfoObjects:tA,workspace:nA,nComponents:rA}){let aA=[],oA=[],sA=await eA.stateValues.originalComponentIndices;for(let IA of await eA.stateValues.componentOrder){let CA=AA[sA[IA-1]];CA&&oA.push(CA.componentIdx)}if(oA.length==nA.componentsCopied.length&&nA.componentsCopied.every((IA,CA)=>IA===oA[CA]))return await this.recreateMissingReplacements({component:eA,components:AA,workspace:nA,nComponents:rA,diagnostics:aA});let lA=await this.createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,workspace:nA,nComponents:rA}),gA=lA.replacements;return aA.push(...lA.diagnostics),rA=lA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:gA}],diagnostics:aA,nComponents:rA}}static determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA}){let nA=0;for(let sA of eA.children)if(AA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_composite"}))if(sA.attributes.createComponentOfType?.primitive)if(sA.attributes.numComponents?.primitive!==void 0){let lA=Number(sA.attributes.numComponents?.primitive.value);if(Number.isInteger(lA)&&lA>=0)nA+=lA;else return{success:!1}}else nA++;else return{success:!1};else nA++;let rA=1;for(let sA=2;sA<=nA;sA++)rA*=sA;let aA=super.determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA});if(!aA.success)return{success:!1};let oA=aA.numVariants*rA;return oA>0?(eA.variants.numVariants=oA,eA.variants.uniqueVariantData={numVariantsByDescendant:eA.variants.uniqueVariantData.numVariantsByDescendant,numberOfPermutations:rA,numComponents:nA},{success:!0,numVariants:oA}):{success:!1}}static getUniqueVariant({serializedComponent:eA,variantIndex:AA,componentInfoObjects:tA}){let nA=eA.variants?.numVariants;if(nA===void 0)return{success:!1};if(!Number.isInteger(AA)||AA<1||AA>nA)return{success:!1};let rA=eA.variants.uniqueVariantData.numVariantsByDescendant,aA=eA.variants.descendantVariantComponents,oA=eA.variants.uniqueVariantData.numberOfPermutations,sA=eA.variants.uniqueVariantData.numComponents,lA=[...rA];lA.push(oA);let gA=enumerateCombinations({numberOfOptionsByIndex:lA,maxNumber:AA})[AA-1].map(QA=>QA+1),cA=gA.pop(),IA=gA,CA=[...Array(sA).keys()].map(QA=>QA+1),uA=enumeratePermutations({values:CA,maxNumber:cA})[cA-1],dA=!1,pA=[];for(let QA=0;QA<rA.length;QA++)if(rA[QA]>1){let BA=aA[QA],DA=tA.allComponentClasses[BA.componentType].getUniqueVariant({serializedComponent:BA,variantIndex:IA[QA],componentInfoObjects:tA});if(!DA.success)return{success:!1};pA.push(DA.desiredVariant),dA=!0}else pA.push({});let mA={indices:uA};return dA&&(mA.subvariants=pA),{success:!0,desiredVariant:mA}}}class SortIndices extends Sort{static componentType="sortIndices";static componentDocs={summary:"The indices that put a list in sorted order, rather than the sorted values"};static allowInSchemaAnywhere=!1;static allowInSchemaAsComponent=["number"];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.sortedIndices={returnDependencies:()=>({sortedValues:{dependencyType:"stateVariable",variableName:"sortedValues"},componentIndicesForValues:{dependencyType:"stateVariable",variableName:"componentIndicesForValues"}}),definition({dependencyValues:AA}){let tA=new Map;for(let[rA,aA]of AA.componentIndicesForValues.entries())tA.has(aA)||tA.set(aA,rA+1);let nA=[];for(let rA of AA.sortedValues){let aA=tA.get(rA.componentIdx);aA!==void 0&&nA.push(aA)}return{setValue:{sortedIndices:nA}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({sortedIndices:{dependencyType:"stateVariable",variableName:"sortedIndices"}}),markStale:()=>({updateReplacements:!0}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,componentInfoObjects:AA,workspace:tA,nComponents:nA}){return createValueListReplacements({component:eA,values:await eA.stateValues.sortedIndices,componentType:"number",componentInfoObjects:AA,workspace:tA,nComponents:nA})}static async calculateReplacementChanges({component:eA,componentInfoObjects:AA,workspace:tA,nComponents:nA}){return calculateValueListReplacementChanges({component:eA,values:await eA.stateValues.sortedIndices,componentType:"number",componentInfoObjects:AA,workspace:tA,nComponents:nA})}addOwnPotentialRendererTypes(eA,AA){super.addOwnPotentialRendererTypes(eA,AA),addReplacementRendererType({component:this,componentType:"number",rendererTypes:eA})}}class SolveEquations extends InlineComponent{static componentType="solveEquations";static componentDocs={summary:"Numerically solves a system of equations"};static rendererType=void 0;static variableForIndexAsProp="solutions";static createAttributesObject(){let eA=super.createAttributesObject();return eA.variables={createComponentOfType:"_variableNameList",description:"Names of the variables to solve for."},eA.numDiscretizationPoints={description:"Number of points used when searching for solutions numerically.",createComponentOfType:"number",createStateVariable:"numDiscretizationPoints",defaultValue:100,public:!0},eA.minVar={createComponentOfType:"number",createStateVariable:"minVar",defaultValue:null,description:"Lower bound of the variable's search range."},eA.maxVar={createComponentOfType:"number",createStateVariable:"maxVar",defaultValue:null,description:"Upper bound of the variable's search range."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){return tA.every(aA=>typeof aA=="string"||aA.extending&&"Ref"in aA.extending)?tA.length===1&&typeof tA[0]!="string"?{success:!1}:{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:nA}:{success:!1}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]},{group:"strings",componentTypes:["string"]}]}static returnStateVariableDefinitions(eA){let AA=super.returnStateVariableDefinitions(eA);return AA.variables={description:"The variables of the equations.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},entryPrefixes:["variable"],returnArraySizeDependencies:()=>({}),returnArraySize({dependencyValues:tA}){return[1]},returnArrayDependenciesByKey({arrayKeys:tA}){return{globalDependencies:{variablesAttr:{dependencyType:"attributeComponent",attributeName:"variables",variableNames:["variables"]}}}},arrayDefinitionByKey({globalDependencyValues:tA,arraySize:nA,arrayKeys:rA,usedDefault:aA}){let oA=[];return tA.variablesAttr!==null&&(oA=tA.variablesAttr.stateValues.variables),{setValue:{variables:returnNVariables(nA[0],oA)}}}},AA.variable={isAlias:!0,targetVariableName:"variable1",description:"The first variable being solved for."},AA.allSolutions={returnDependencies:()=>({mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},variables:{dependencyType:"stateVariable",variableName:"variables"},minVar:{dependencyType:"stateVariable",variableName:"minVar"},maxVar:{dependencyType:"stateVariable",variableName:"maxVar"},numDiscretizationPoints:{dependencyType:"stateVariable",variableName:"numDiscretizationPoints"}}),definition({dependencyValues:tA}){if(tA.mathChild.length===0)return{setValue:{allSolutions:[]}};let nA=tA.mathChild[0].stateValues.value;if(!(Array.isArray(nA.tree)&&nA.tree.length===3&&nA.tree[0]==="="))return{setValue:{allSolutions:[]}};let rA=tA.minVar,aA=tA.maxVar,oA=[],sA=tA.variables[0].subscripts_to_strings().tree,lA=context.fromAst(["+",nA.tree[1],["-",nA.tree[2]]]).subscripts_to_strings(),gA;try{gA=lA.f()}catch{let NA=[codedDiagnostic({type:"warning",code:"doenet-w0057",args:{equation:nA.toString()}})];return{setValue:{allSolutions:[]},sendDiagnostics:NA}}let cA=fA=>gA({[sA]:fA}),IA=fA=>normalizeMathExpression({value:lA.substitute({[sA]:fA}).strings_to_subscripts(),simplify:!0,expand:!0}).evaluate_to_constant(),CA=function(fA){try{return cA(fA)}catch{return NaN}},uA=function(fA){try{return cA(fA)}catch{return toNumberOrNaN(IA(fA))}};if(Number.isFinite(rA)||(rA=-10),Number.isFinite(aA)||(aA=10),rA>aA)return{setValue:{allSolutions:[]}};let dA=[rA,aA],pA=[rA];for(let fA=0;fA<dA.length-1;fA++){let NA=dA[fA],yA=dA[fA+1],bA=tA.numDiscretizationPoints,wA=(yA-NA)/bA;for(let MA=1;MA<bA;MA++)pA.push(NA+MA*wA);pA.push(yA)}let mA=2*pA[0]-pA[1],QA=2*pA[pA.length-1]-pA[pA.length-2];pA=[mA,...pA,QA];let BA=pA.map(uA),hA=pA[0],DA=BA[0];for(let fA=0;fA<pA.length;fA++){let NA=pA[fA],yA=BA[fA];if(!Number.isFinite(yA)||!Number.isFinite(DA)){let bA,wA;if(Number.isFinite(yA)?(bA=NA,wA=hA):Number.isFinite(DA)&&(bA=hA,wA=NA),bA!==void 0){for(;;){let MA=(bA+wA)/2;if(MA===bA||MA===wA)break;Number.isFinite(CA(MA))?bA=MA:wA=MA}[NA,hA].includes(bA)||(pA.splice(fA,0,bA),BA.splice(fA,0,CA(bA)))}}hA=NA,DA=yA}oA=[],hA=pA[0],DA=BA[0],DA===0&&oA.push(hA);for(let fA=1;fA<pA.length;fA++){let NA=pA[fA],yA=BA[fA];if(yA===0){let bA=!1;if(fA<pA.length-1){let wA=pA[fA+1],MA=BA[fA+1],vA=hA,OA=DA;if(DA*MA>0){for(let FA=0;FA<10;FA++)if(hA=.1*hA+.9*NA,wA=.1*wA+.9*NA,DA=CA(hA),MA=CA(wA),DA*MA<0){DA*OA<0?(oA.push(eA.fzero(CA,[vA,hA])),oA.push(NA)):(oA.includes(NA)||oA.push(NA),NA=wA,yA=MA),bA=!0;break}}}!bA&&!oA.includes(NA)&&oA.push(NA)}else if(yA*DA<0)oA.push(eA.fzero(CA,[hA,NA]));else if(DA!==0&&fA<pA.length-1){let bA=pA[fA+1],wA=BA[fA+1];if((DA-yA)*(wA-yA)>0&&(yA>0&&DA>yA||yA<0&&DA<yA)){let MA;DA>yA?MA=CA:MA=OA=>-CA(OA);let vA=eA.fminbr(MA,[hA,bA],void 0,1e-10);if(vA.success){let OA=vA.x,FA=CA(OA);FA*DA<0?(oA.push(eA.fzero(CA,[hA,OA])),NA=OA,yA=FA):FA===0&&oA.push(OA)}}}hA=NA,DA=yA}return oA=oA.filter(fA=>fA>=rA&&fA<=aA),{setValue:{allSolutions:oA.map(fA=>context.fromAst(fA))}}}},AA.numSolutions={description:"The number of numerical solutions found.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({allSolutions:{dependencyType:"stateVariable",variableName:"allSolutions"}}),definition({dependencyValues:tA}){return{setValue:{numSolutions:tA.allSolutions.length}}}},AA.solutions={description:"The numerical solutions of the equations.",public:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["solution"],returnArraySizeDependencies:()=>({numSolutions:{dependencyType:"stateVariable",variableName:"numSolutions"}}),returnArraySize({dependencyValues:tA}){return[tA.numSolutions]},returnArrayDependenciesByKey(){return{globalDependencies:{allSolutions:{dependencyType:"stateVariable",variableName:"allSolutions"}}}},arrayDefinitionByKey({globalDependencyValues:tA}){let nA={};for(let rA=0;rA<tA.__array_size[0];rA++)nA[rA]=tA.allSolutions[rA];return{setValue:{solutions:nA}}}},AA}}class PostponeRenderContainer extends Group{static componentType="_postponeRenderContainer";static componentDocs={summary:"Internal container that postpones rendering of its children."};static inSchemaOnlyInheritAs=[];static allowInSchemaAnywhere=!1;static renderedDefault=!1;static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.rendered,eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.rendered={returnDependencies:()=>({parentRendered:{dependencyType:"parentStateVariable",variableName:"rendered"}}),markStale:()=>({updateReplacements:!0}),definition({dependencyValues:AA}){return{setValue:{rendered:!!AA.parentRendered}}}},eA}static async calculateReplacementChanges({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:nA}){let rA=[];if(await eA.stateValues.rendered&&eA.replacements.length===0){let aA=await this.createSerializedReplacements({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:nA}),oA=aA.replacements;return rA.push(...aA.diagnostics),tA=aA.nComponents,oA.length>0?{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:0,serializedReplacements:oA}],diagnostics:rA,nComponents:tA}:{replacementChanges:[],diagnostics:rA,nComponents:tA}}else return{replacementChanges:[],diagnostics:rA,nComponents:tA}}}class SubsetOfReals extends MathComponent{static componentType="subsetOfReals";static componentDocs={summary:"A subset of the real numbers, defined by intervals and points"};static rendererType="math";static primaryStateVariableForDefinition="subsetValue";static stateVariableToBeShadowed="subsetValue";static createAttributesObject(){let eA=super.createAttributesObject();return eA.createIntervals.defaultValue=!0,eA.variable={createComponentOfType:"_variableName",createStateVariable:"variable",defaultValue:context.fromAst("x"),description:"Name of the variable used when expressing the subset."},eA.displayMode={description:"How the subset is displayed.",createComponentOfType:"text",createStateVariable:"displayMode",defaultValue:"intervals",public:!0,toLowerCase:!0,validValues:[{value:"intervals",description:"Display the subset using interval notation (e.g., `(0, 1]`)."},{value:"inequalities",description:"Display the subset using inequalities (e.g., `0 < x ≤ 1`)."}]},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();renameStateVariable({stateVariableDefinitions:eA,oldName:"unnormalizedValue",newName:"unnormalizedValuePreliminary"}),eA.value.shadowingInstructions.createComponentOfType="math",eA.haveSingleSubsetChild={returnDependencies:()=>({mathChildren:{dependencyType:"child",childGroups:["maths"]}}),definition({dependencyValues:tA,componentInfoObjects:nA}){return{setValue:{haveSingleSubsetChild:tA.mathChildren.length===1&&tA.mathChildren.filter(aA=>nA.isInheritedComponentType({inheritedComponentType:aA.componentType,baseComponentType:"subsetOfReals"})).length===1}}}},eA.subsetValue={stateVariablesDeterminingDependencies:["haveSingleSubsetChild"],returnDependencies({stateValues:tA}){let nA={haveSingleSubsetChild:{dependencyType:"stateVariable",variableName:"haveSingleSubsetChild"}};return tA.haveSingleSubsetChild?nA.subsetChild={dependencyType:"child",childGroups:["maths"],variableNames:["subsetValue"]}:(nA.unnormalizedValuePreliminary={dependencyType:"stateVariable",variableName:"unnormalizedValuePreliminary"},nA.variable={dependencyType:"stateVariable",variableName:"variable"}),nA},definition({dependencyValues:tA}){let nA;return tA.haveSingleSubsetChild?nA=tA.subsetChild[0].stateValues.subsetValue:nA=buildSubsetFromMathExpression(tA.unnormalizedValuePreliminary,tA.variable),{setValue:{subsetValue:nA}}},async inverseDefinition({desiredStateVariableValues:tA,dependencyValues:nA,stateValues:rA}){return nA.haveSingleSubsetChild?{success:!0,instructions:[{setDependency:"subsetChild",desiredValue:tA.subsetValue,childIndex:0,variableIndex:0}]}:{success:!0,instructions:[{setDependency:"unnormalizedValuePreliminary",desiredValue:mathExpressionFromSubsetValue({subsetValue:tA.subsetValue,variable:nA.variable,displayMode:await rA.displayMode})}]}}},eA.unnormalizedValue={returnDependencies:()=>({subsetValue:{dependencyType:"stateVariable",variableName:"subsetValue"},displayMode:{dependencyType:"stateVariable",variableName:"displayMode"},variable:{dependencyType:"stateVariable",variableName:"variable"}}),definition({dependencyValues:tA}){return{setValue:{unnormalizedValue:mathExpressionFromSubsetValue(tA)}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:nA}){return{success:!0,instructions:[{setDependency:"subsetValue",desiredValue:buildSubsetFromMathExpression(tA.unnormalizedValue,nA.variable)}]}}};const AA=returnPointsIntervalsFromSubsetStateVariableDefinitions();return Object.assign(eA,AA),eA}}function returnPointsIntervalsFromSubsetStateVariableDefinitions(){let iA={};return iA.pointsFromSubset={additionalStateVariablesDefined:["intervalsFromSubset"],returnDependencies:()=>({subsetValue:{dependencyType:"stateVariable",variableName:"subsetValue"}}),definition({dependencyValues:eA}){let{points:AA,intervals:tA}=determinePointAndIntervalsFromSubset(eA.subsetValue);return{setValue:{pointsFromSubset:AA,intervalsFromSubset:tA}}}},iA.points={additionalStateVariablesDefined:[{variableName:"pointsClosed",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"boolean"},description:"Whether each boundary point of the subset is a closed (included) endpoint."}],description:"The boundary points that delimit the subset.",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["point"],returnArraySizeDependencies:()=>({pointsFromSubset:{dependencyType:"stateVariable",variableName:"pointsFromSubset"}}),returnArraySize({dependencyValues:eA}){return[eA.pointsFromSubset.length]},returnArrayDependenciesByKey(){return{globalDependencies:{pointsFromSubset:{dependencyType:"stateVariable",variableName:"pointsFromSubset"}}}},arrayDefinitionByKey({globalDependencyValues:eA,arrayKeys:AA}){let tA={},nA={};for(let rA of AA){let aA=eA.pointsFromSubset[rA];tA[rA]=context.fromAst(aA.value),nA[rA]=aA.inSubset}return{setValue:{points:tA,pointsClosed:nA}}}},iA.allIntervals={additionalStateVariablesDefined:["allIsolatedPoints"],returnDependencies:()=>({subsetValue:{dependencyType:"stateVariable",variableName:"subsetValue"}}),definition({dependencyValues:eA}){let AA=[],tA=[],nA=mergeIntervals(eA.subsetValue);for(let rA of nA)rA.type==="closedInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!0,!0]])):rA.type==="openClosedInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!1,!0]])):rA.type==="closedOpenInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!0,!1]])):rA.type==="openInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!1,!1]])):rA.type==="realLine"?AA.push(context.fromAst(["interval",["tuple",-1/0,1/0],["tuple",!1,!1]])):rA.type==="singleton"&&tA.push(rA.element);return{setValue:{allIntervals:AA,allIsolatedPoints:tA}}}},iA.intervals={description:"The intervals (non-degenerate components) of the subset.",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["interval"],returnArraySizeDependencies:()=>({allIntervals:{dependencyType:"stateVariable",variableName:"allIntervals"}}),returnArraySize({dependencyValues:eA}){return[eA.allIntervals.length]},returnArrayDependenciesByKey(){return{globalDependencies:{allIntervals:{dependencyType:"stateVariable",variableName:"allIntervals"}}}},arrayDefinitionByKey({globalDependencyValues:eA}){return{setValue:{intervals:eA.allIntervals}}}},iA.isolatedPoints={description:"The isolated (non-interval) points of the subset.",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["isolatedPoint"],returnArraySizeDependencies:()=>({allIsolatedPoints:{dependencyType:"stateVariable",variableName:"allIsolatedPoints"}}),returnArraySize({dependencyValues:eA}){return[eA.allIsolatedPoints.length]},returnArrayDependenciesByKey(){return{globalDependencies:{allIsolatedPoints:{dependencyType:"stateVariable",variableName:"allIsolatedPoints"}}}},arrayDefinitionByKey({globalDependencyValues:eA}){return{setValue:{isolatedPoints:eA.allIsolatedPoints}}}},iA}function determinePointAndIntervalsFromSubset(iA){function eA(rA,aA){let oA=[],sA=[];if(rA.points&&(oA=rA.points),rA.intervals&&(sA=rA.intervals),aA.points){let lA=oA.map(gA=>gA.value);for(let gA of aA.points){let cA=lA.indexOf(gA.value);cA===-1?oA.push(gA):oA[cA].inSubset||=gA.inSubset}}return aA.intervals&&sA.push(...aA.intervals),{points:oA,intervals:sA}}function AA(rA){if(rA===null||rA.isEmpty())return{};if(rA.type==="union"){let aA=[],oA=[];for(let sA of rA.subsets){let lA=AA(sA);({points:aA,intervals:oA}=eA({points:aA,intervals:oA},lA))}return{points:aA,intervals:oA}}else{if(rA.type==="realLine")return{intervals:[[-1/0,1/0]]};if(rA.type==="singleton")return{points:[{value:rA.element,inSubset:!0}]};if(rA.type==="openInterval"){let aA=[[rA.left,rA.right]],oA=[];return Number.isFinite(rA.left)&&oA.push({value:rA.left,inSubset:!1}),Number.isFinite(rA.right)&&oA.push({value:rA.right,inSubset:!1}),{intervals:aA,points:oA}}}return{}}let{points:tA,intervals:nA}=AA(iA);return tA||=[],nA||=[],tA.sort((rA,aA)=>rA.value-aA.value),nA.sort((rA,aA)=>rA[0]-aA[0]),{points:tA,intervals:nA}}class SubsetOfRealsInput extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{addPoint:this.addPoint.bind(this),deletePoint:this.deletePoint.bind(this),movePoint:this.movePoint.bind(this),togglePoint:this.togglePoint.bind(this),toggleInterval:this.toggleInterval.bind(this),clear:this.clear.bind(this),setToR:this.setToR.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="subsetOfRealsInput";static componentDocs={summary:"An interactive number-line widget for entering a subset of real numbers (block-level; does not inherit from Input)"};static variableForImplicitProp="subsetValue";static createAttributesObject(){let eA=super.createAttributesObject();return eA.xMin={description:"Left endpoint of the visible number line.",createComponentOfType:"number",createStateVariable:"xMin",defaultValue:-10,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.xMax={description:"Right endpoint of the visible number line.",createComponentOfType:"number",createStateVariable:"xMax",defaultValue:10,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.width={description:"Display width of the input.",createComponentOfType:"componentSize",createStateVariable:"width",defaultValue:800,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.height={description:"Display height of the input.",createComponentOfType:"componentSize",createStateVariable:"height",defaultValue:300,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.xlabel={description:"Label rendered for the x axis.",createComponentOfType:"text",createStateVariable:"xlabel",defaultValue:"",public:!0,forRenderer:!0,excludeFromSchema:!0},eA.dx={description:"Tick spacing along the number line.",createComponentOfType:"number",createStateVariable:"dx",defaultValue:.5,public:!0,excludeFromSchema:!0},eA.variable={description:"Variable name displayed on the number line.",createComponentOfType:"_variableName",createStateVariable:"variable",defaultValue:context.fromAst("x"),public:!0},eA.format={description:"Input format used for parsing entered subsets.",createComponentOfType:"text",createStateVariable:"format",defaultValue:"text",public:!0,toLowerCase:!0,validValues:[{value:"text",description:"Parse entered subsets as plain-text notation."},{value:"latex",description:"Parse entered subsets as LaTeX notation."}]},eA.prefill={description:"Initial subset displayed in the input.",createComponentOfType:"text",createStateVariable:"prefill",defaultValue:"",public:!0},eA.bindValueTo={createComponentOfType:"subsetOfReals",description:"Two-way binding target for the input's value."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();eA.subsetValue={description:"The current subset of the reals entered by the user.",public:!0,shadowingInstructions:{createComponentOfType:"subsetOfReals",addAttributeComponentsShadowingStateVariables:{variable:{stateVariableToShadow:"variable"}}},hasEssential:!0,returnDependencies:()=>({bindValueTo:{dependencyType:"attributeComponent",attributeName:"bindValueTo",variableNames:["subsetValue"]},prefill:{dependencyType:"stateVariable",variableName:"prefill"},variable:{dependencyType:"stateVariable",variableName:"variable"},format:{dependencyType:"stateVariable",variableName:"format"}}),definition:function({dependencyValues:tA}){return tA.bindValueTo?{setValue:{subsetValue:tA.bindValueTo.stateValues.subsetValue}}:{useEssentialOrDefaultValue:{subsetValue:{get defaultValue(){return parseValueIntoSubset({inputString:tA.prefill,format:tA.format,variable:tA.variable})}}}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:nA}){return nA.bindValueTo?{success:!0,instructions:[{setDependency:"bindValueTo",desiredValue:tA.subsetValue,variableIndex:0}]}:{success:!0,instructions:[{setEssentialValue:"subsetValue",value:tA.subsetValue}]}}},eA.additionalPoints={defaultValue:[],hasEssential:!0,returnDependencies:()=>({}),definition(){return{useEssentialOrDefaultValue:{additionalPoints:!0}}},inverseDefinition({desiredStateVariableValues:tA}){return tA.additionalPoints.every(Number.isFinite)?{success:!0,instructions:[{setEssentialValue:"additionalPoints",value:[...tA.additionalPoints].sort((nA,rA)=>nA-rA)}]}:{success:!1}}},eA.pointsDisplayed={additionalStateVariablesDefined:[{variableName:"intervalsDisplayed",forRenderer:!0}],forRenderer:!0,returnDependencies:()=>({pointsFromSubset:{dependencyType:"stateVariable",variableName:"pointsFromSubset"},intervalsFromSubset:{dependencyType:"stateVariable",variableName:"intervalsFromSubset"},additionalPoints:{dependencyType:"stateVariable",variableName:"additionalPoints"}}),definition({dependencyValues:tA}){let nA=[...tA.pointsFromSubset],rA=[...tA.intervalsFromSubset],aA=[...tA.additionalPoints].sort((uA,dA)=>uA-dA),oA=[],sA=[],lA=0,gA=1/0,cA=0;aA.length>0&&(gA=aA[0]);let IA=rA[0],CA=-1/0;nA.push({value:1/0,inSubset:!1});for(let uA of nA){let dA=!1;for(IA&&IA[0]<uA.value&&(dA=!0);gA<uA.value;)gA!==CA&&(oA.push({value:gA,inSubset:dA,isAdditional:!0,additionalPointInd:cA}),sA.push({left:CA,right:gA,inSubset:dA}),CA=gA),cA++,gA=aA[cA],gA===void 0&&(gA=1/0);oA.push(uA),sA.push({left:CA,right:uA.value,inSubset:dA}),CA=uA.value,dA&&(lA++,IA=rA[lA])}return oA=oA.slice(0,oA.length-1),{setValue:{pointsDisplayed:oA,intervalsDisplayed:sA}}}};const AA=returnPointsIntervalsFromSubsetStateVariableDefinitions();return Object.assign(eA,AA),eA}async addPoint({value:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){let rA=await this.stateValues.dx,aA=Math.round(Math.max(await this.stateValues.xMin,Math.min(await this.stateValues.xMax,eA))/rA)*rA,oA=[...await this.stateValues.pointsFromSubset],sA=[...await this.stateValues.intervalsFromSubset],lA=[...await this.stateValues.additionalPoints];if(!lA.includes(aA)&&!oA.map(cA=>cA.value).includes(aA)){let cA=!1;for(let IA of sA)if(IA[0]<aA&&IA[1]>aA){cA=!0;break}if(cA)return lA.push(aA),await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:lA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:nA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{addedPoint:aA,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:lA}}});{oA.push({value:aA,inSubset:!0});let IA=await this.createUpdateInstructions({intervalsFromSubset:sA,pointsFromSubset:oA,modifiedAdditionalPoints:!1,additionalPoints:lA});return await this.coreFunctions.performUpdate({updateInstructions:IA,actionId:AA,sourceInformation:tA,skipRendererUpdate:nA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{addedPoint:aA,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:lA}}})}}}async deletePoint({pointInd:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){let rA=await this.stateValues.pointsDisplayed[eA],aA=[...await this.stateValues.additionalPoints],oA=[...await this.stateValues.pointsFromSubset],sA=[...await this.stateValues.intervalsFromSubset];if(rA.isAdditional)return aA.splice(rA.additionalPointInd,1),await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:aA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:nA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{deletedPoint:rA.value,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:aA}}});{let lA=!1,gA=oA.map(uA=>uA.value).indexOf(rA.value),cA=sA.map(uA=>uA[1]).indexOf(rA.value),IA=sA.map(uA=>uA[0]).indexOf(rA.value);if(cA!==-1)if(IA!==-1)sA[cA]=[sA[cA][0],sA[IA][1]],sA.splice(IA,1),oA.splice(gA,1);else{let uA=(await this.stateValues.pointsDisplayed)[eA-1];uA&&uA.isAdditional?(sA[cA]=[sA[cA][0],uA.value],aA.splice(uA.additionalPointInd,1),lA=!0,oA.splice(gA,1,uA)):(sA.splice(cA,1),oA.splice(gA,1),uA&&!uA.inSubset&&sA.map(pA=>pA[1]).indexOf(uA.value)===-1&&(aA.push(uA.value),lA=!0))}else if(IA!==-1){let uA=(await this.stateValues.pointsDisplayed)[eA+1];uA&&uA.isAdditional?(sA[IA]=[uA.value,sA[IA][1]],aA.splice(uA.additionalPointInd,1),lA=!0,oA.splice(gA,1,uA)):(sA.splice(IA,1),oA.splice(gA,1),uA&&!uA.inSubset&&sA.map(pA=>pA[0]).indexOf(uA.value)===-1&&(aA.push(uA.value),lA=!0))}else oA.splice(gA,1);let CA=await this.createUpdateInstructions({intervalsFromSubset:sA,pointsFromSubset:oA,modifiedAdditionalPoints:lA,additionalPoints:aA});return await this.coreFunctions.performUpdate({updateInstructions:CA,actionId:AA,sourceInformation:tA,skipRendererUpdate:nA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{deletedPoint:rA.value,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:aA}}})}}async createUpdateInstructions({intervalsFromSubset:eA,pointsFromSubset:AA,modifiedAdditionalPoints:tA,additionalPoints:nA}){let rA=await this.stateValues.dx,aA=gA=>Math.round(gA/rA)*rA,oA=[];for(let gA of eA)oA.push(subsetOfReals.OpenInterval(aA(gA[0]),aA(gA[1])));for(let gA of AA)gA.inSubset&&oA.push(subsetOfReals.Singleton(aA(gA.value)));let sA;oA.length===0?sA=subsetOfReals.EmptySet():oA.length===1?sA=oA[0]:sA=subsetOfReals.Union(oA);let lA=[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"subsetValue",value:sA}];return tA&&lA.push({componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:nA.map(aA)}),lA}async movePoint({pointInd:eA,value:AA,transient:tA,actionId:nA,sourceInformation:rA={},skipRendererUpdate:aA=!1}){let oA=await this.stateValues.dx,sA=Math.round(Math.max(await this.stateValues.xMin,Math.min(await this.stateValues.xMax,AA))/oA)*oA,lA=await this.stateValues.pointsDisplayed,gA=lA[eA],cA=lA[eA-1];cA&&(sA=Math.max(sA,cA.value+oA));let IA=lA[eA+1];IA&&(sA=Math.min(sA,IA.value-oA));let CA=[...await this.stateValues.additionalPoints],uA=[...await this.stateValues.pointsFromSubset],dA=[...await this.stateValues.intervalsFromSubset];if(gA.isAdditional)return CA[gA.additionalPointInd]=sA,tA?await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:CA}],transient:!0,actionId:nA,sourceInformation:rA,skipRendererUpdate:aA}):await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:CA}],actionId:nA,sourceInformation:rA,skipRendererUpdate:aA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{movedPoint:sA,intervalsFromSubset:dA,pointsFromSubset:uA,additionalPoints:CA}}});{let pA=uA.map(hA=>hA.value).indexOf(gA.value),mA=dA.map(hA=>hA[1]).indexOf(gA.value),QA=dA.map(hA=>hA[0]).indexOf(gA.value);uA[pA]={value:sA,inSubset:uA[pA].inSubset},mA!==-1&&(dA[mA]=[dA[mA][0],sA]),QA!==-1&&(dA[QA]=[sA,dA[QA][1]]);let BA=await this.createUpdateInstructions({intervalsFromSubset:dA,pointsFromSubset:uA,modifiedAdditionalPoints:!1});return tA?await this.coreFunctions.performUpdate({updateInstructions:BA,transient:!0,actionId:nA,sourceInformation:rA,skipRendererUpdate:aA}):await this.coreFunctions.performUpdate({updateInstructions:BA,actionId:nA,sourceInformation:rA,skipRendererUpdate:aA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{movedPoint:sA,intervalsFromSubset:dA,pointsFromSubset:uA,additionalPoints:CA}}})}}async togglePoint({pointInd:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){let rA=(await this.stateValues.pointsDisplayed)[eA],aA=[...await this.stateValues.pointsFromSubset],oA=[...await this.stateValues.intervalsFromSubset],sA=[...await this.stateValues.additionalPoints],lA=!1;if(rA.isAdditional)if(sA.splice(rA.additionalPointInd,1),lA=!0,rA.inSubset){for(let[cA,IA]of oA.entries())if(IA[0]<rA.value&&IA[1]>rA.value){let CA=[[IA[0],rA.value],[rA.value,IA[1]]];oA.splice(cA,1,...CA);break}}else aA.push({value:rA.value,inSubset:!0});else{let cA=aA.map(uA=>uA.value).indexOf(rA.value),IA=oA.map(uA=>uA[1]).indexOf(rA.value),CA=oA.map(uA=>uA[0]).indexOf(rA.value);IA!==-1?CA!==-1?(oA[IA]=[oA[IA][0],oA[CA][1]],oA.splice(CA,1),aA.splice(cA,1),sA.push(rA.value),lA=!0):aA[cA]={value:rA.value,inSubset:!rA.inSubset}:CA!==-1?aA[cA]={value:rA.value,inSubset:!rA.inSubset}:(aA.splice(cA,1),sA.push(rA.value),lA=!0)}let gA=await this.createUpdateInstructions({intervalsFromSubset:oA,pointsFromSubset:aA,modifiedAdditionalPoints:lA,additionalPoints:sA});return await this.coreFunctions.performUpdate({updateInstructions:gA,actionId:AA,sourceInformation:tA,skipRendererUpdate:nA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{toggledPoint:rA.value,intervalsFromSubset:oA,pointsFromSubset:aA,additionalPoints:sA}}})}async toggleInterval({intervalInd:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){let rA=(await this.stateValues.intervalsDisplayed)[eA],aA=await this.stateValues.pointsDisplayed,oA=aA[eA-1],sA=aA[eA],lA=[...await this.stateValues.pointsFromSubset],gA=[...await this.stateValues.intervalsFromSubset],cA=[...await this.stateValues.additionalPoints],IA=!1;if(rA.inSubset){let uA,dA;for(let[pA,mA]of gA.entries())if(mA[0]<=rA.left&&mA[1]>=rA.right){dA=mA,uA=pA;break}if(rA.left===dA[0])if(rA.right===dA[1]){if(gA.splice(uA,1),oA&&!oA.inSubset&&gA.map(mA=>mA[1]).indexOf(oA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(oA.value);lA.splice(mA,1),cA.push(oA.value),IA=!0}if(sA&&!sA.inSubset&&gA.map(mA=>mA[0]).indexOf(sA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(sA.value);lA.splice(mA,1),cA.push(sA.value),IA=!0}}else{if(gA[uA]=[rA.right,dA[1]],oA&&!oA.inSubset&&gA.map(mA=>mA[1]).indexOf(oA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(oA.value);lA.splice(mA,1),cA.push(oA.value),IA=!0}lA.push({value:sA.value,inSubset:!0}),cA.splice(sA.additionalPointInd,1),IA=!0}else if(rA.right===dA[1]){if(gA[uA]=[dA[0],rA.left],sA&&!sA.inSubset&&gA.map(mA=>mA[0]).indexOf(sA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(sA.value);lA.splice(mA,1),cA.push(sA.value),IA=!0}lA.push({value:oA.value,inSubset:!0}),cA.splice(oA.additionalPointInd,1),IA=!0}else{let pA=[[dA[0],rA.left],[rA.right,dA[1]]];gA.splice(uA,1,...pA),lA.push({value:oA.value,inSubset:!0}),lA.push({value:sA.value,inSubset:!0}),cA.splice(sA.additionalPointInd,1),cA.splice(oA.additionalPointInd,1),IA=!0}}else{let uA=gA.map(pA=>pA[1]).indexOf(rA.left),dA=gA.map(pA=>pA[0]).indexOf(rA.right);if(uA===-1)dA===-1?(gA.push([rA.left,rA.right]),sA&&sA.isAdditional&&(cA.splice(sA.additionalPointInd,1),IA=!0),oA&&oA.isAdditional&&(cA.splice(oA.additionalPointInd,1),IA=!0)):(sA.inSubset?(gA[dA]=[rA.left,gA[dA][1]],cA.push(sA.value),IA=!0):gA.push([rA.left,rA.right]),oA&&oA.isAdditional&&(cA.splice(oA.additionalPointInd,1),IA=!0));else if(dA===-1)oA.inSubset?(gA[uA]=[gA[uA][0],rA.right],cA.push(oA.value),IA=!0):gA.push([rA.left,rA.right]),sA&&sA.isAdditional&&(cA.splice(sA.additionalPointInd,1),IA=!0);else if(oA.inSubset)if(sA.inSubset){let pA=[gA[uA][0],gA[dA][1]];gA.splice(uA,2,pA),cA.push(oA.value),cA.push(sA.value),IA=!0}else gA[uA]=[gA[uA][0],rA.right],cA.push(oA.value),IA=!0;else sA.inSubset?(gA[dA]=[rA.left,gA[dA][1]],cA.push(sA.value),IA=!0):gA.push([rA.left,rA.right])}let CA=await this.createUpdateInstructions({intervalsFromSubset:gA,pointsFromSubset:lA,modifiedAdditionalPoints:IA,additionalPoints:cA});return await this.coreFunctions.performUpdate({updateInstructions:CA,actionId:AA,sourceInformation:tA,skipRendererUpdate:nA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{toggledInterval:[rA.left,rA.right],intervalsFromSubset:gA,pointsFromSubset:lA,additionalPoints:cA}}})}async clear({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let nA=await this.createUpdateInstructions({intervalsFromSubset:[],pointsFromSubset:[],modifiedAdditionalPoints:!0,additionalPoints:[]});return await this.coreFunctions.performUpdate({updateInstructions:nA,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{cleared:!0,intervalsFromSubset:[],pointsFromSubset:[],additionalPoints:[]}}})}async setToR({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let nA=await this.createUpdateInstructions({intervalsFromSubset:[[-1/0,1/0]],pointsFromSubset:[],modifiedAdditionalPoints:!0,additionalPoints:[]});return await this.coreFunctions.performUpdate({updateInstructions:nA,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{setToR:!0,intervalsFromSubset:[[-1/0,1/0]],pointsFromSubset:[],additionalPoints:[]}}})}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}function parseValueIntoSubset({inputString:iA,format:eA,variable:AA}){if(!iA)return subsetOfReals.EmptySet();let tA;if(eA==="latex")try{tA=context.fromLatex(iA)}catch{return subsetOfReals.EmptySet()}else if(eA==="text")try{tA=context.fromText(iA)}catch{return subsetOfReals.EmptySet()}return buildSubsetFromMathExpression(tA,AA)}class Split extends CompositeComponent{static componentType="split";static componentDocs={summary:"Splits a string or list into pieces"};static allowInSchemaAsComponent=["text"];static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.type={createPrimitiveOfType:"string",createStateVariable:"type",defaultPrimitiveValue:"text",toLowerCase:!0,validValues:[{value:"text",description:"Split text values."}],description:"Type of value being split."},eA.splitBy={createComponentOfType:"text",createStateVariable:"splitBy",defaultValue:"letter",toLowerCase:!0,validValues:[{value:"letter",description:"Split into individual characters."},{value:"word",description:"Split into whitespace-separated words."},{value:"comma",description:"Split on comma boundaries."}],description:"How to break the input string into pieces."},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asList",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static returnSugarInstructions(){let eA=[];function AA({matchedChildren:tA,componentAttributes:nA,nComponents:rA,stateIdInfo:aA}){let oA=nA.type?.value;return["text"].includes(oA)||(oA="text"),{success:!0,newChildren:[{type:"serialized",componentType:oA,componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:rA}}return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.originalValue={returnDependencies:()=>({child:{dependencyType:"child",childGroups:["anything"],variableNames:["value"]}}),definition({dependencyValues:AA}){return AA.child.length>0?{setValue:{originalValue:AA.child[0].stateValues.value}}:{setValue:{originalValue:null}}},inverseDefinition({desiredStateVariableValues:AA,dependencyValues:tA}){return tA.child.length>0?{success:!0,instructions:[{setDependency:"child",desiredValue:AA.originalValue,childIndex:0,variableIndex:0}]}:{success:!1}}},eA.allSplitValues={returnDependencies:()=>({type:{dependencyType:"stateVariable",variableName:"type"},originalValue:{dependencyType:"stateVariable",variableName:"originalValue"},splitBy:{dependencyType:"stateVariable",variableName:"splitBy"}}),definition({dependencyValues:AA}){if(AA.originalValue===null)return{setValue:{allSplitValues:[]}};let tA=[];return AA.splitBy==="letter"?tA=[...AA.originalValue]:AA.splitBy==="word"?tA=AA.originalValue.split(/\s+/):AA.splitBy==="comma"?tA=AA.originalValue.split(/\s*,\s*/):tA=[AA.originalValue],{setValue:{allSplitValues:tA}}}},eA.numValues={returnDependencies:()=>({allSplitValues:{dependencyType:"stateVariable",variableName:"allSplitValues"}}),definition({dependencyValues:AA}){return{setValue:{numValues:AA.allSplitValues.length}}}},eA.values={isArray:!0,entryPrefixes:["value"],returnArraySizeDependencies:()=>({numValues:{dependencyType:"stateVariable",variableName:"numValues"}}),returnArraySize({dependencyValues:AA}){return[AA.numValues]},returnArrayDependenciesByKey(){return{globalDependencies:{allSplitValues:{dependencyType:"stateVariable",variableName:"allSplitValues"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arrayKeys:tA}){let nA={};for(let rA of tA)nA[rA]=AA.allSplitValues[rA];return{setValue:{values:nA}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({values:{dependencyType:"stateVariable",variableName:"values"}}),markStale:()=>({updateReplacements:!0}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){tA.replacementsCreated===void 0&&(tA.replacementsCreated=0);const nA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated},rA=[],aA=await eA.stateValues.values,oA=aA.map((sA,lA)=>({type:"serialized",componentType:"text",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},children:[],state:{value:sA},downstreamDependencies:{[eA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:eA.componentIdx,propVariable:`value${lA+1}`}]}}));return tA.values=[...aA],tA.replacementsCreated=nA.num,{replacements:oA,diagnostics:rA,nComponents:AA}}static async calculateReplacementChanges({component:eA,components:AA,workspace:tA,nComponents:nA}){let rA=[];const aA=await eA.stateValues.values;if(aA.length===tA.values.length&&tA.values.every((gA,cA)=>gA===aA[cA]))return{replacementChanges:[],diagnostics:rA,nComponents:nA};let oA=await this.createSerializedReplacements({component:eA,components:AA,workspace:tA,nComponents:nA}),sA=oA.replacements;return rA.push(...oA.diagnostics),nA=oA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:sA}],diagnostics:rA,nComponents:nA}}}const{matrix,transpose,multiply,lusolve,subset,index}=context.math;class BestFitLine extends Line{static componentType="bestFitLine";static componentDocs={summary:"The best-fit line for a set of points"};static rendererType="line";static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.draggable,delete eA.equation,delete eA.through,delete eA.slope,eA.data={createComponentOfType:"pointList",description:"The data points to fit a line to."},eA}static additionalSchemaChildren=[];static returnSugarInstructions(){return[]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.draggable={description:"Whether the line can be dragged (always false for a best-fit line).",shadowingInstructions:{createComponentOfType:"boolean"},public:!0,forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{draggable:!1}})},eA.numDimensions={description:"Number of dimensions of the line (always 2 for a best-fit line).",public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({}),definition:()=>({setValue:{numDimensions:2}})},delete eA.numPointsPrescribed,delete eA.basedOnSlope,delete eA.basedOnParallel,delete eA.basedOnPerpendicular,delete eA.distForSecondPt,delete eA.essentialPoint1x,delete eA.essentialPoint1y,delete eA.equationIdentity,delete eA.equation.stateVariablesDeterminingDependencies,eA.equation.returnDependencies=()=>({data:{dependencyType:"attributeComponent",attributeName:"data",variableNames:["points","numDimensions"]},variables:{dependencyType:"stateVariable",variableName:"variables"}}),eA.equation.definition=function({dependencyValues:AA}){if(!AA.data||AA.data.stateValues.numDimensions<2||AA.data.stateValues.points.length<1){let dA=context.fromAst("_");return{setValue:{equation:dA,coeff0:dA,coeffvar1:dA,coeffvar2:dA}}}let tA=[],nA=[];for(let dA of AA.data.stateValues.points){let pA=dA.slice(0,2).map(mA=>mA&&mA.evaluate_to_constant());pA.every(Number.isFinite)&&(tA.push([1,pA[0]]),nA.push([pA[1]]))}if(tA.length===0){let dA=context.fromAst("_");return{setValue:{equation:dA,coeff0:dA,coeffvar1:dA,coeffvar2:dA}}}tA=matrix(tA),nA=matrix(nA);let rA=transpose(tA),aA=multiply(rA,nA),oA=multiply(rA,tA),sA=lusolve(oA,aA),lA=context.fromAst(subset(sA,index(0,0))),gA=context.fromAst(subset(sA,index(1,0))),cA=context.fromAst(-1),IA=AA.variables,CA=context.fromAst(["+",["*","a","x"],"c"]).substitute({a:gA,c:lA,x:IA[0]}).simplify();return{setValue:{equation:context.fromAst(["=",IA[1].tree,"r"]).substitute({r:CA}),coeff0:lA,coeffvar1:gA,coeffvar2:cA}}},delete eA.equation.inverseDefinition,delete eA.points.stateVariablesDeterminingDependencies,eA.points.returnArrayDependenciesByKey=function(){return{globalDependencies:{coeff0:{dependencyType:"stateVariable",variableName:"coeff0"},coeffvar1:{dependencyType:"stateVariable",variableName:"coeffvar1"},coeffvar2:{dependencyType:"stateVariable",variableName:"coeffvar2"},variables:{dependencyType:"stateVariable",variableName:"variables"},lastPointsFromInverting:{dependencyType:"stateVariable",variableName:"lastPointsFromInverting"}}}},eA.data={description:"The data points used to compute the best-fit line.",public:!0,isLocation:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="datumX"?[]:[["point",{componentType:"mathList",isAttributeNamed:"xs"}]]}},isArray:!0,numDimensions:2,entryPrefixes:["datumX","datum"],returnEntryDimensions:AA=>AA==="datum"?1:0,getArrayKeysFromVarName({arrayEntryPrefix:AA,varEnding:tA,arraySize:nA}){if(AA==="datumX"){let rA=tA.split("_").map(aA=>Number(aA)-1);return rA.length===2&&rA.every((aA,oA)=>Number.isInteger(aA)&&aA>=0)?nA?rA.every((aA,oA)=>aA<nA[oA])?[String(rA)]:[]:[String(rA)]:[]}else{let rA=Number(tA)-1;return Number.isInteger(rA)&&rA>=0?nA?rA<nA[0]?Array.from(Array(nA[1]),(aA,oA)=>rA+","+oA):[]:[rA+",0"]:[]}},arrayVarNameFromPropIndex(AA,tA){if(tA==="data")return AA.length===1?"datum"+AA[0]:`datumX${AA[0]}_${AA[1]}`;if(tA.slice(0,5)==="datum"){let nA=Number(tA.slice(5));if(Number.isInteger(nA)&&nA>0)return`datumX${nA}_${AA[0]}`}return null},returnArraySizeDependencies:()=>({data:{dependencyType:"attributeComponent",attributeName:"data",variableNames:["numPoints","numDimensions"]}}),returnArraySize({dependencyValues:AA}){let tA=AA.data;return tA?[tA.stateValues.numPoints,tA.stateValues.numDimensions]:[0,0]},returnArrayDependenciesByKey(){return{globalDependencies:{data:{dependencyType:"attributeComponent",attributeName:"data",variableNames:["points"]}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA=AA.data.stateValues.points,nA={};for(let rA in tA){let aA=tA[rA];for(let oA in tA)nA[`${rA},${oA}`]=aA[oA]}return{setValue:{data:nA}}}},eA}}class RegionBetweenCurveXAxis extends GraphicalComponent{static componentType="regionBetweenCurveXAxis";static styleOverrideCategories=["fill"];static componentDocs={summary:"A region bounded between a curve and the x-axis"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.boundaryValues={description:"Boundary values defining the region's left/right edges.",createComponentOfType:"numberList",createStateVariable:"boundaryValues",defaultValue:[0,1],forRenderer:!0,public:!0},eA.function={createComponentOfType:"function",description:"The function whose graph bounds the region."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"region",noun:"region"})),eA.function={additionalStateVariablesDefined:[{variableName:"haveFunction",forRenderer:!0},{variableName:"fDefinition",forRenderer:!0}],returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["numericalfs","numInputs","numOutputs","fDefinition"]}}),definition({dependencyValues:AA}){return AA.functionAttr===null||AA.functionAttr.stateValues.numInputs!==1||AA.functionAttr.stateValues.numOutputs!==1?{setValue:{function:()=>NaN,haveFunction:!1,fDefinition:{}}}:{setValue:{function:AA.functionAttr.stateValues.numericalfs[0],haveFunction:!0,fDefinition:AA.functionAttr.stateValues.fDefinition}}}},eA.nearestPoint={returnDependencies:()=>({function:{dependencyType:"stateVariable",variableName:"function"},boundaryValues:{dependencyType:"stateVariable",variableName:"boundaryValues"},haveFunction:{dependencyType:"stateVariable",variableName:"haveFunction"}}),definition({dependencyValues:AA}){if(!AA.haveFunction)return{setValue:{nearestPoint:()=>({})}};const tA=Math.min(AA.boundaryValues[0],AA.boundaryValues[1]),nA=Math.max(AA.boundaryValues[0],AA.boundaryValues[1]),rA=AA.function;return{setValue:{nearestPoint:function({variables:oA}){let sA=oA.x1?.evaluate_to_constant(),lA=oA.x2?.evaluate_to_constant();if(!(Number.isFinite(sA)&&Number.isFinite(lA)))return{};sA=Math.max(tA,Math.min(nA,sA));let[gA,cA]=[0,rA(sA)].sort((IA,CA)=>IA-CA);return lA=Math.max(gA,Math.min(cA,lA)),{x1:sA,x2:lA}}}}}},eA}}class RegionBetweenCurves extends GraphicalComponent{static componentType="regionBetweenCurves";static styleOverrideCategories=["fill"];static componentDocs={summary:"A region bounded between two curves"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.boundaryValues={description:"Boundary values defining the region's edges.",createComponentOfType:"numberList",createStateVariable:"boundaryValues",defaultValue:[0,1],forRenderer:!0,public:!0},eA.flipFunctions={description:"Whether to swap the role of x and y for the input functions.",createComponentOfType:"boolean",createStateVariable:"flipFunctions",defaultValue:!1,public:!0,forRenderer:!0},eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"functions",componentTypes:["function"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"region",noun:"region"})),eA.functions={additionalStateVariablesDefined:[{variableName:"haveFunctions",forRenderer:!0},{variableName:"fDefinitions",forRenderer:!0}],returnDependencies:()=>({functions:{dependencyType:"child",childGroups:["functions"],variableNames:["numericalfs","numInputs","numOutputs","fDefinition"]}}),definition({dependencyValues:AA}){return AA.functions.length<2||AA.functions[0].stateValues.numInputs!==1||AA.functions[0].stateValues.numOutputs!==1||AA.functions[1].stateValues.numInputs!==1||AA.functions[1].stateValues.numOutputs!==1?{setValue:{functions:[()=>NaN,()=>NaN],haveFunctions:!1,fDefinitions:[{},{}]}}:{setValue:{functions:[AA.functions[0].stateValues.numericalfs[0],AA.functions[1].stateValues.numericalfs[0]],haveFunctions:!0,fDefinitions:[AA.functions[0].stateValues.fDefinition,AA.functions[1].stateValues.fDefinition]}}}},eA.nearestPoint={returnDependencies:()=>({functions:{dependencyType:"stateVariable",variableName:"functions"},boundaryValues:{dependencyType:"stateVariable",variableName:"boundaryValues"},flipFunctions:{dependencyType:"stateVariable",variableName:"flipFunctions"},haveFunctions:{dependencyType:"stateVariable",variableName:"haveFunctions"}}),definition({dependencyValues:AA}){if(!AA.haveFunctions)return{setValue:{nearestPoint:()=>({})}};const tA=Math.min(AA.boundaryValues[0],AA.boundaryValues[1]),nA=Math.max(AA.boundaryValues[0],AA.boundaryValues[1]),rA=AA.functions[0],aA=AA.functions[1];return{setValue:{nearestPoint:function({variables:sA}){let lA=sA.x1?.evaluate_to_constant(),gA=sA.x2?.evaluate_to_constant();if(!(Number.isFinite(lA)&&Number.isFinite(gA)))return{};AA.flipFunctions&&([lA,gA]=[gA,lA]),lA=Math.max(tA,Math.min(nA,lA));let[cA,IA]=[rA(lA),aA(lA)].sort((CA,uA)=>CA-uA);return gA=Math.max(cA,Math.min(IA,gA)),AA.flipFunctions&&([lA,gA]=[gA,lA]),{x1:lA,x2:gA}}}}}},eA}}function returnFieldFunctionChildGroup(){return{group:"functions",componentTypes:["function"]}}function returnFieldVariablesAttribute(){return{variables:{createComponentOfType:"_variableNameList",description:'Names of the variables a bare expression is read as a function of. Defaults to "x y". Ignored when the function is given as a <function> child, which names its own variables.'}}}function returnFieldLatticeAttributes({markNoun:iA,markLengthDefault:eA,markLengthDescription:AA}){return{dx:{createComponentOfType:"number",createStateVariable:"dx",defaultValue:1,public:!0,forRenderer:!0,description:`Horizontal spacing between ${iA}.`},dy:{createComponentOfType:"number",createStateVariable:"dy",defaultValue:1,public:!0,forRenderer:!0,description:`Vertical spacing between ${iA}.`},xoffset:{createComponentOfType:"number",createStateVariable:"xoffset",defaultValue:0,public:!0,forRenderer:!0,description:"Horizontal offset of the lattice origin."},yoffset:{createComponentOfType:"number",createStateVariable:"yoffset",defaultValue:0,public:!0,forRenderer:!0,description:"Vertical offset of the lattice origin."},markLength:{createComponentOfType:"number",createStateVariable:"markLength",defaultValue:eA,public:!0,forRenderer:!0,description:AA},maxMarks:{createComponentOfType:"number",createStateVariable:"maxMarks",defaultValue:2500,public:!0,forRenderer:!0,description:`Upper bound on how many ${iA} are drawn. Zooming out past this coarsens the lattice rather than drawing an unbounded number of ${iA}.`}}}function returnFieldFunctionStateVariableDefinitions({numOutputs:iA}){const eA=iA===1,AA=eA?"slopeField":"vectorField",tA=eA?"vectorField":"slopeField",nA=eA?2:1;return{haveFunction:{forRenderer:!0,additionalStateVariablesDefined:[{variableName:"fDefinitions",forRenderer:!0}],returnDependencies:()=>({functionChildren:{dependencyType:"child",childGroups:["functions"],variableNames:["numOutputs","fDefinitions"]}}),definition({dependencyValues:rA}){const aA=rA.functionChildren[0]??null;if(aA===null||aA.stateValues.numOutputs!==iA){const oA=[];if(aA!==null){const sA=aA.stateValues.numOutputs;oA.push(codedDiagnostic({type:"warning",code:"doenet-w0122",args:{component:AA,expected:iA,found:sA,alternative:sA===nA?tA:"none"},position:aA.position||void 0}))}return{setValue:{haveFunction:!1,fDefinitions:Array.from({length:iA},()=>({}))},sendDiagnostics:oA}}return{setValue:{haveFunction:!0,fDefinitions:aA.stateValues.fDefinitions}}}}}}class SlopeField extends GraphicalComponent{static componentType="slopeField";static styleOverrideCategories=["line"];static includeLabels=!1;static componentDocs={summary:"A slope field for a differential equation y' = f(x,y), drawn as tick marks on a lattice"};static additionalSchemaChildren=["math","number","string"];static returnChildGroups(){let eA=super.returnChildGroups();return eA.push(returnFieldFunctionChildGroup()),eA}static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnFieldVariablesAttribute(),returnFieldLatticeAttributes({markNoun:"marks",markLengthDefault:20,markLengthDescription:"Length of each mark, in pixels. Marks keep this length whatever the axis scaling, so slopes are drawn at their true visual angle."})),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"line",noun:"slope-field"}),returnFieldFunctionStateVariableDefinitions({numOutputs:1})),eA}}class VectorField extends GraphicalComponent{static componentType="vectorField";static styleOverrideCategories=["line"];static includeLabels=!1;static componentDocs={summary:"A vector field drawn as arrows on a lattice, from a function with two outputs"};static additionalSchemaChildren=["math","number","string"];static returnChildGroups(){let eA=super.returnChildGroups();return eA.push(returnFieldFunctionChildGroup()),eA}static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnFieldVariablesAttribute(),returnFieldLatticeAttributes({markNoun:"arrows",markLengthDefault:24,markLengthDescription:"Length in pixels of the longest arrow, or of every arrow when normalize is set. Arrows keep this length whatever the axis scaling."})),eA.normalize={createComponentOfType:"boolean",createStateVariable:"normalize",defaultValue:!1,public:!0,forRenderer:!0,description:"Draw every arrow the same length, showing direction only rather than magnitude."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"line",noun:"vector-field"}),returnFieldFunctionStateVariableDefinitions({numOutputs:2})),eA}}class RegionHalfPlane extends GraphicalComponent{static componentType="regionHalfPlane";static componentDocs={summary:"A half-plane region bounded by a line"};static rendererType=void 0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.horizontal={description:"Whether the half-plane extends horizontally, bounded by the vertical line x = boundaryValue. If false, the half-plane extends vertically, bounded by the horizontal line y = boundaryValue.",createComponentOfType:"boolean",createStateVariable:"horizontal",defaultValue:!0,public:!0},eA.boundaryValue={description:"Position of the bounding line: x = boundaryValue when horizontal is true, y = boundaryValue when horizontal is false.",createComponentOfType:"number",createStateVariable:"boundaryValue",defaultValue:0,public:!0},eA.greaterThan={description:"Whether the region is the side where the inequality is greater than the boundary.",createComponentOfType:"boolean",createStateVariable:"greaterThan",defaultValue:!0,public:!0},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.nearestPoint={returnDependencies:()=>({horizontal:{dependencyType:"stateVariable",variableName:"horizontal"},boundaryValue:{dependencyType:"stateVariable",variableName:"boundaryValue"},greaterThan:{dependencyType:"stateVariable",variableName:"greaterThan"}}),definition({dependencyValues:AA}){let tA=AA.boundaryValue;return{setValue:{nearestPoint:function({variables:nA,scales:rA}){if(!Number.isFinite(tA))return{};if(AA.horizontal)if(AA.greaterThan)if(nA.x1<tA){let aA=Object.assign({},nA);return aA.x1=tA,aA}else return{};else if(nA.x1>tA){let aA=Object.assign({},nA);return aA.x1=tA,aA}else return{};else if(AA.greaterThan)if(nA.x2<tA){let aA=Object.assign({},nA);return aA.x2=tA,aA}else return{};else if(nA.x2>tA){let aA=Object.assign({},nA);return aA.x2=tA,aA}else return{}}}}}},eA}}class CodeEditor extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{updateImmediateValue:inputUpdateImmediateValue.bind(this),updateValue:inputUpdateValue.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="codeEditor";static componentDocs={summary:"An interactive DoenetML code editor"};static variableForImplicitProp="value";static renderChildren=!0;static ignoreVariantsFromChildren=!0;static processWhenJustUpdatedForNewComponent=!0;static ignoreErrorsFromChildren=!0;static get stateVariablesShadowedForReference(){return["value"]}static createAttributesObject(){let eA=super.createAttributesObject();return eA.prefill={description:"Initial code shown in the editor before the user types.",createComponentOfType:"text",createStateVariable:"prefill",defaultValue:"",public:!0},eA.bindValueTo={createComponentOfType:"text",description:"Two-way binding target for the input's value."},eA.width={description:'Editor width (e.g. "100%" or "600px").',createComponentOfType:"componentSize",createStateVariable:"width",defaultValue:{size:"100",isAbsolute:!1},forRenderer:!0,public:!0},eA.height={description:'Editor height (e.g. "500px").',createComponentOfType:"componentSize",createStateVariable:"height",defaultValue:{size:400,isAbsolute:!0},forRenderer:!0,public:!0},eA.viewerRatio={createComponentOfType:"number",description:"Fraction of the editor area allotted to the live viewer."},eA.showResults={description:"Whether to render the results panel alongside the editor.",createComponentOfType:"boolean",createStateVariable:"showResults",defaultValue:!1,forRenderer:!0,public:!0},eA.showFormatter={description:"Whether to show a code formatter button.",createComponentOfType:"boolean",createStateVariable:"showFormatter",defaultValue:!1,forRenderer:!0,public:!0},eA.resultsLocation={description:"Position of the results panel relative to the editor.",createComponentOfType:"text",createStateVariable:"resultsLocation",defaultValue:"bottom",forRenderer:!0,public:!0,toLowerCase:!0,validValues:[{value:"bottom",description:"Place the results panel below the editor."},{value:"start",description:"Place the results panel before the editor: to its left in a left-to-right document, to its right in a right-to-left one."},{value:"end",description:"Place the results panel after the editor: to its right in a left-to-right document, to its left in a right-to-left one."}]},eA.readOnly={description:"Whether the editor is read-only.",createComponentOfType:"boolean",createStateVariable:"readOnly",defaultValue:!1,forRenderer:!0,public:!0},eA.initialOpenTab={description:"Which diagnostics/responses tab to open initially.",createComponentOfType:"text",createStateVariable:"initialOpenTab",defaultValue:"first",forRenderer:!0,public:!0,toLowerCase:!0,validValues:[{value:"none",description:"Panel starts closed."},{value:"first",description:"Open the first available tab."},{value:"errors",description:"Open the errors tab."},{value:"warnings",description:"Open the warnings tab."},{value:"info",description:"Open the info tab."},{value:"accessibility",description:"Open the accessibility tab."},{value:"responses",description:"Open the responses tab."},{value:"help",description:"Open the help tab."}]},eA.renderedName={createPrimitiveOfType:"string",description:"Name to assign to the dynamically-rendered DoenetML output."},eA.staticName={createPrimitiveOfType:"string",description:"Name to assign to the static DoenetML source."},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnInputValueChangedStateVariableDefinitions({valueChangedDescription:"Whether the value has been changed from its initial state.",immediateValueChangedDescription:"Whether the value, including in-progress edits, has been changed from its initial state."})),eA.prefillFromChildren={returnDependencies:()=>({childrenDoenetML:{dependencyType:"doenetML",displayOnlyChildren:!0}}),definition({dependencyValues:AA}){let tA=AA.childrenDoenetML;return tA&&(tA+=`
2783
2783
  `),{setValue:{prefillFromChildren:tA}}}},eA.value={description:"The code value of the input.",public:!0,shadowingInstructions:{createComponentOfType:"text"},hasEssential:!0,forRenderer:!0,returnDependencies:()=>({bindValueTo:{dependencyType:"attributeComponent",attributeName:"bindValueTo",variableNames:["value"]},prefill:{dependencyType:"stateVariable",variableName:"prefill"},prefillFromChildren:{dependencyType:"stateVariable",variableName:"prefillFromChildren"},valueChanged:{dependencyType:"stateVariable",variableName:"valueChanged",onlyToSetInInverseDefinition:!0},immediateValueChanged:{dependencyType:"stateVariable",variableName:"immediateValueChanged",onlyToSetInInverseDefinition:!0}}),definition:function({dependencyValues:AA,usedDefault:tA}){return AA.bindValueTo?{setValue:{value:AA.bindValueTo.stateValues.value}}:{useEssentialOrDefaultValue:{value:{variablesToCheck:"value",get defaultValue(){return tA.prefill?AA.prefillFromChildren:AA.prefill}}}}},inverseDefinition:function({desiredStateVariableValues:AA,dependencyValues:tA}){let nA=[{setDependency:"valueChanged",desiredValue:!0},{setDependency:"immediateValueChanged",desiredValue:!0}];return tA.bindValueTo?nA.push({setDependency:"bindValueTo",desiredValue:AA.value,variableIndex:0}):nA.push({setEssentialValue:"value",value:AA.value}),{success:!0,instructions:nA}}},Object.assign(eA,returnImmediateValueStateVariableDefinition({description:"The code value reflecting the user's in-progress edits.",createComponentOfType:"text"})),eA.text={description:"The current code as a plain text string.",public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({value:{dependencyType:"stateVariable",variableName:"value"}}),definition:function({dependencyValues:AA}){return{setValue:{text:AA.value}}}},eA.componentType={returnDependencies:()=>({}),definition:()=>({setValue:{componentType:"text"}})},eA.allChildren={returnDependencies:()=>({allChildren:{dependencyType:"child",childGroups:["anything"]}}),definition({dependencyValues:AA}){return{setValue:{allChildren:AA.allChildren}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class HasSameFactoring extends BooleanComponent{static componentType="hasSameFactoring";static componentDocs={summary:"Boolean condition that tests for equivalent factoring"};static rendererType="boolean";static createAttributesObject(){let eA=super.createAttributesObject();return eA.variable={createComponentOfType:"_variableName",createStateVariable:"variable",defaultValue:context.fromAst("x"),description:"Variable used when comparing factored expressions."},eA.restrictDivision={createComponentOfType:"boolean",createStateVariable:"restrictDivision",defaultValue:!1,description:"Whether to disallow dividing through to match factored forms."},eA.monomialFactorMustMatch={createComponentOfType:"boolean",createStateVariable:"monomialFactorMustMatch",defaultValue:!1,description:"Whether monomial factors must match exactly (implies restrictDivision)."},eA.allowOnlySignDifferences={createComponentOfType:"boolean",createStateVariable:"allowOnlySignDifferences",defaultValue:!1,description:"Whether to count factorizations as equivalent when they differ only by sign."},eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.parsedExpression,delete eA.mathChildrenByCode,eA.value={public:!0,description:"Whether the input math expressions share the same factoring.",shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},allowedErrorInNumbers:{dependencyType:"stateVariable",variableName:"allowedErrorInNumbers"},includeErrorInNumberExponents:{dependencyType:"stateVariable",variableName:"includeErrorInNumberExponents"},allowedErrorIsAbsolute:{dependencyType:"stateVariable",variableName:"allowedErrorIsAbsolute"},numSignErrorsMatched:{dependencyType:"stateVariable",variableName:"numSignErrorsMatched"},variable:{dependencyType:"stateVariable",variableName:"variable"},restrictDivision:{dependencyType:"stateVariable",variableName:"restrictDivision"},monomialFactorMustMatch:{dependencyType:"stateVariable",variableName:"monomialFactorMustMatch"},allowOnlySignDifferences:{dependencyType:"stateVariable",variableName:"allowOnlySignDifferences"}}),definition:function({dependencyValues:AA}){if(AA.mathChildren.length!==2)return{setValue:{value:!1}};let tA=AA.mathChildren[0].stateValues.value,nA=AA.mathChildren[1].stateValues.value;if(checkEquality({object1:tA,object2:nA,isUnordered:!1,partialMatches:!1,symbolicEquality:!1,allowedErrorInNumbers:AA.allowedErrorInNumbers,includeErrorInNumberExponents:AA.includeErrorInNumberExponents,allowedErrorIsAbsolute:AA.allowedErrorIsAbsolute,numSignErrorsMatched:AA.numSignErrorsMatched}).fraction_equal!==1)return{setValue:{value:!1}};if(Array.isArray(tA.tree)&&tA.tree[0]==="-"&&(tA=context.fromAst(tA.tree[1])),Array.isArray(nA.tree)&&nA.tree[0]==="-"&&(nA=context.fromAst(nA.tree[1])),!AA.restrictDivision&&!AA.monomialFactorMustMatch&&!AA.allowOnlySignDifferences&&(Array.isArray(tA.tree)&&tA.tree[0]==="/"&&context.fromAst(tA.tree[2]).variables().length===0&&(tA=context.fromAst(tA.tree[1]),Array.isArray(tA.tree)&&tA.tree[0]==="-"&&(tA=context.fromAst(tA.tree[1]))),Array.isArray(nA.tree)&&nA.tree[0]==="/"&&context.fromAst(nA.tree[2]).variables().length===0&&(nA=context.fromAst(nA.tree[1]),Array.isArray(nA.tree)&&nA.tree[0]==="-"&&(nA=context.fromAst(nA.tree[1])))),tA=context.fromAst(expandPositiveIntegerPowers(tA.tree)),nA=context.fromAst(expandPositiveIntegerPowers(nA.tree)),Array.isArray(tA.tree)&&tA.tree[0]==="*"){if(!(Array.isArray(nA.tree)&&nA.tree[0]==="*"))return{setValue:{value:!1}}}else return Array.isArray(nA.tree)&&nA.tree[0]==="*"?{setValue:{value:!1}}:{setValue:{value:!0}};if(AA.monomialFactorMustMatch||AA.allowOnlySignDifferences){let uA=findMonomialFromFactors(tA.tree.slice(1)),dA=findMonomialFromFactors(nA.tree.slice(1));if(!uA.equals(dA)){let pA=context.fromAst(["-",dA.tree]);if(!uA.equals(pA))return{setValue:{value:!1}}}}if(AA.allowOnlySignDifferences){let uA=normalizeFactorSigns(tA),dA=normalizeFactorSigns(nA);return{setValue:{value:uA.equalsViaSyntax(dA,{allowed_error_in_numbers:AA.allowedErrorInNumbers,include_error_in_number_exponents:AA.includeErrorInNumberExponents,allowed_error_is_absolute:AA.allowedErrorIsAbsolute})}}}let aA=tA.tree.slice(1).filter(uA=>context.fromAst(uA).variables().length>0),oA=nA.tree.slice(1).filter(uA=>context.fromAst(uA).variables().length>0);if(aA.length!==oA.length)return{setValue:{value:!1}};let sA=0,lA=0,gA=0,cA=0,IA=AA.variable.subscripts_to_strings().tree;for(let uA of aA){let dA=context.fromAst(uA).subscripts_to_strings().derivative(IA).derivative(IA).simplify();if(dA.tree===0)lA++;else if(dA.variables().length===0)sA++;else return{setValue:{value:!1}}}for(let uA of oA){let dA=context.fromAst(uA).subscripts_to_strings().derivative(IA).derivative(IA).simplify();if(dA.tree===0)cA++;else if(dA.variables().length===0)gA++;else return{setValue:{value:!1}}}return{setValue:{value:lA===cA&&sA===gA}}}},eA}}function expandPositiveIntegerPowers(iA){if(!Array.isArray(iA))return iA;if(iA[0]==="^"){let eA=iA[1],AA=iA[2];Number.isInteger(AA)&&AA>0&&(iA=["*",...Array(AA).fill(eA)])}if(iA[0]==="*"){let eA=iA;iA=["*"];for(let AA of eA.slice(1))if(Array.isArray(AA)&&AA[0]==="^"){let tA=AA[1],nA=AA[2];Number.isInteger(nA)&&nA>0?iA.push(...Array(nA).fill(tA)):iA.push(AA)}else iA.push(AA)}return iA}function findMonomialFromFactors(iA){let eA=[],AA=!1;for(let nA of iA)if(typeof nA=="string"||context.fromAst(nA).variables().length===0){if(!AA){if(eA.length>0)return context.fromAst("_");AA=!0}eA.push(nA)}else AA=!1;let tA;return eA.length===0?tA=1:eA.length===1?tA=eA[0]:tA=["*",...eA],context.fromAst(tA)}function normalizeFactorSigns(iA){let eA=iA.simplify().tree;if(eA[0]==="-"&&(eA=eA[1]),eA[0]!=="*")return context.fromAst(eA).simplify();let AA=["*"];for(let tA of eA.slice(1))if(typeof tA=="number")tA<0?AA.push(-tA):AA.push(tA);else if(!Array.isArray(tA))AA.push(tA);else if(tA[0]==="-")AA.push(tA[1]);else if(tA[0]==="+"){let nA=!1,rA=tA[1];if(typeof rA=="number")rA<0&&(nA=!0);else if(Array.isArray(rA)){if(rA[0]==="-")nA=!0;else if(rA[0]==="*"){let aA=rA[1];typeof aA=="number"?aA<0&&(nA=!0):Array.isArray(aA)&&aA[0]==="-"&&(nA=!0)}}nA?AA.push(context.fromAst(["-",tA]).simplify().tree):AA.push(tA)}else AA.push(tA);return context.fromAst(AA).simplify()}class DataFrame extends BaseComponent{static componentType="dataFrame";static excludeFromSchema=!0;static componentDocs={summary:"A 2D table of typed data values."};static rendererType=void 0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.source={description:"URL or identifier of the data source.",createComponentOfType:"text",createStateVariable:"source",required:!0,public:!0,forRenderer:!0},eA.hasHeader={description:"Whether the first row of data contains column headers.",createComponentOfType:"boolean",createStateVariable:"hasHeader",defaultValue:!0,public:!0},eA.columnTypes={createComponentOfType:"textList",createStateVariable:"columnTypesPrelim",defaultValue:[],description:"Override the inferred type of each column."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.cid={forRenderer:!0,returnDependencies:()=>({source:{dependencyType:"stateVariable",variableName:"source"}}),definition:function({dependencyValues:AA}){if(!AA.source||AA.source.substring(0,7).toLowerCase()!=="doenet:")return{setValue:{cid:null}};let tA=null,nA=AA.source.match(/[:&]cid=([^&]+)/i);return nA&&(tA=nA[1]),{setValue:{cid:tA}}}},eA.dataFrame={stateVariablesDeterminingDependencies:["cid","source"],additionalStateVariablesDefined:[{variableName:"numRows",public:!0,description:"The number of rows in the data frame.",shadowingInstructions:{createComponentOfType:"integer"}},{variableName:"numColumns",public:!0,description:"The number of columns in the data frame.",shadowingInstructions:{createComponentOfType:"integer"}},{variableName:"columnTypes",public:!0,description:"The data type of each column in the data frame.",shadowingInstructions:{createComponentOfType:"textList"}},{variableName:"columnNames",public:!0,description:"The name of each column in the data frame.",shadowingInstructions:{createComponentOfType:"textList"}}],returnDependencies:({stateValues:AA})=>({fileContents:{dependencyType:"file",cid:AA.cid,uri:AA.source,fileType:"csv"},hasHeader:{dependencyType:"stateVariable",variableName:"hasHeader"},columnTypesPrelim:{dependencyType:"stateVariable",variableName:"columnTypesPrelim"}}),definition:function({dependencyValues:AA,componentIdx:tA}){let nA=[],rA=[],aA=AA.fileContents.trim().split(`
2784
- `).map(IA=>IA.trim().split(",").map(CA=>CA.trim())),oA=aA[0]?.length,sA=!1;for(let IA of aA.slice(1))if(IA.length!==oA){sA=!0;break}if(sA){let IA=codedDiagnostic({type:"warning",code:"doenet-w0066",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:rA},sendDiagnostics:[IA]}}let lA={},gA=[];if(AA.hasHeader?(lA.columnNames=aA[0].map(IA=>(['"',"'"].includes(IA[0])&&IA[IA.length-1]===IA[0]&&(IA=IA.substring(1,IA.length-1)),IA)),gA=aA.slice(1)):(lA.columnNames=[...Array(oA).keys()].map(IA=>`col${IA+1}`),gA=aA),[...new Set(lA.columnNames)].length<lA.columnNames){let IA=codedDiagnostic({type:"warning",code:"doenet-w0067",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:rA},sendDiagnostics:[IA]}}if(lA.columnNames.includes("")){let IA=codedDiagnostic({type:"warning",code:"doenet-w0068",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:rA},sendDiagnostics:[IA]}}let cA=gA.length;lA.shape=[cA,oA];for(let IA=0;IA<oA;IA++){let CA=AA.columnTypesPrelim[IA]?.toLowerCase();if(["number","string"].includes(CA)||(CA="auto"),CA==="auto"){let uA=!1;for(let dA=0;dA<cA;dA++){let pA=gA[dA][IA];if(pA!==""){let mA=Number(pA);if(!Number.isFinite(mA)){uA=!0;break}}}uA?CA="string":CA="number"}if(CA==="number")for(let uA=0;uA<cA;uA++)gA[uA][IA]===""?gA[uA][IA]=null:gA[uA][IA]=Number(gA[uA][IA]);else for(let uA=0;uA<cA;uA++){let dA=gA[uA][IA];['"',"'"].includes(dA[0])&&dA[dA.length-1]===dA[0]&&(dA=dA.substring(1,dA.length-1)),gA[uA][IA]=dA}nA.push(CA)}return lA.data=gA,lA.columnTypes=nA,{setValue:{dataFrame:lA,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:lA.columnNames}}}},eA.means={description:"Mean of each numeric column in the data frame.",public:!0,shadowingInstructions:{createComponentOfType:"number"},isArray:!0,entryPrefixes:["mean"],returnArraySizeDependencies:()=>({numColumns:{dependencyType:"stateVariable",variableName:"numColumns"}}),returnArraySize({dependencyValues:AA}){return[AA.numColumns]},returnArrayDependenciesByKey(){return{globalDependencies:{dataFrame:{dependencyType:"stateVariable",variableName:"dataFrame"},numColumns:{dependencyType:"stateVariable",variableName:"numColumns"},numRows:{dependencyType:"stateVariable",variableName:"numRows"},columnTypes:{dependencyType:"stateVariable",variableName:"columnTypes"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arrayKeys:tA}){let nA={};for(let rA of tA){let aA=0,oA=0;if(AA.columnTypes[rA]==="number"){for(let sA=0;sA<AA.numRows;sA++){let lA=AA.dataFrame.data[sA][rA];lA!==null&&(aA+=lA,oA++)}aA/=oA}else aA=NaN;nA[rA]=aA}return{setValue:{means:nA}}}},eA}}const{mean,std,variance}=context.math,STATISTICS=[{value:"mean",description:"The arithmetic mean of the values.",compute:mean},{value:"stdev",description:"The sample standard deviation.",compute:std},{value:"variance",description:"The sample variance.",compute:variance},{value:"stderr",description:"The standard error of the mean."},{value:"count",description:"The number of non-missing values."},{value:"minimum",description:"The smallest value.",compute:smallest},{value:"quartile1",description:"The first quartile (25th percentile).",compute:quartile1},{value:"median",description:"The median value.",compute:median},{value:"quartile3",description:"The third quartile (75th percentile).",compute:quartile3},{value:"maximum",description:"The largest value.",compute:largest},{value:"range",description:"The maximum minus the minimum."},{value:"sum",description:"The sum of the values.",compute:iA=>iA.reduce((eA,AA)=>eA+AA)}],FIVE_NUMBER_SUMMARY=["minimum","quartile1","median","quartile3","maximum"],DEFAULT_STATISTICS=["mean","stdev","count","minimum","quartile1","median","quartile3","maximum"];function returnColumnStatisticDefinition({value:iA,description:eA,compute:AA}){return{description:eA,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){const nA=tA.dataColumn;return{setValue:{[iA]:nA.length?AA(nA):null}}}}}function displayedStatistic(iA,eA,AA){return eA===null?null:iA==="count"?eA:roundForDisplay({value:numberToMathExpression(eA),dependencyValues:AA}).toString(buildNumberDisplayParameters(AA))}class SummaryStatistics extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="summaryStatistics";static componentDocs={summary:"Summary statistics (mean, median, etc.) for a list of numbers."};static createAttributesObject(){let eA=super.createAttributesObject();return eA.statisticsToDisplay={createComponentOfType:"textList",createStateVariable:"statisticsToDisplayPrelim",defaultValue:["default"],toLowerCase:!0,highlighted:!0,validValues:[{value:"default",description:`The default selection: ${DEFAULT_STATISTICS.join(", ")}.`},{value:"all",description:"Every statistic listed here."},{value:"fiveNumberSummary",description:`The five-number summary: ${FIVE_NUMBER_SUMMARY.join(", ")}.`},...STATISTICS.map(({value:AA,description:tA})=>({value:AA,description:tA}))],description:'Which summary statistics to display (or "default" / "all" / "fiveNumberSummary").'},Object.assign(eA,returnNumberDisplayAttributes()),eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoMathsBySpacesSugarInstruction()),eA}static returnChildGroups(){return[{group:"numbers",componentTypes:["number"]},{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.statisticsToDisplay={description:"Which summary statistics to display.",public:!0,shadowingInstructions:{createComponentOfType:"textList"},returnDependencies:()=>({statisticsToDisplayPrelim:{dependencyType:"stateVariable",variableName:"statisticsToDisplayPrelim"}}),definition:function({dependencyValues:tA}){const nA=STATISTICS.map(sA=>sA.value),rA=tA.statisticsToDisplayPrelim,aA=new Set;for(const sA of rA)if(sA==="default")for(const lA of DEFAULT_STATISTICS)aA.add(lA);else if(sA==="all")for(const lA of nA)aA.add(lA);else if(sA==="fivenumbersummary")for(const lA of FIVE_NUMBER_SUMMARY)aA.add(lA);else aA.add(sA);return{setValue:{statisticsToDisplay:nA.filter(sA=>aA.has(sA))}}}},eA.dataColumn={description:"The numeric values being summarized.",returnDependencies:()=>({valueChildren:{dependencyType:"child",childGroups:["numbers","maths"],variableNames:["value"]}}),definition({dependencyValues:tA}){const nA=[];for(let rA of tA.valueChildren){const aA=rA.stateValues.value,oA=typeof aA?.evaluate_to_constant=="function"?aA.evaluate_to_constant():aA;Number.isFinite(oA)&&nA.push(oA)}return{setValue:{dataColumn:nA}}}};const AA={};AA.count={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){return{setValue:{count:tA.dataColumn.length}}}},AA.stderr={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({stdev:{dependencyType:"stateVariable",variableName:"stdev"},count:{dependencyType:"stateVariable",variableName:"count"}}),definition({dependencyValues:tA}){let nA=null;return tA.stdev!==null&&(nA=tA.stdev/Math.sqrt(tA.count)),{setValue:{stderr:nA}}}},AA.range={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({minimum:{dependencyType:"stateVariable",variableName:"minimum"},maximum:{dependencyType:"stateVariable",variableName:"maximum"}}),definition({dependencyValues:tA}){let nA=null;return tA.minimum!==null&&(nA=tA.maximum-tA.minimum),{setValue:{range:nA}}}};for(let tA of STATISTICS)eA[tA.value]={...tA.compute?returnColumnStatisticDefinition(tA):{description:tA.description,...AA[tA.value]},highlighted:!0};return eA.summaryStatistics={description:"The statistics being displayed, as the table should show them, keyed by statistic.",forRenderer:!0,stateVariablesDeterminingDependencies:["statisticsToDisplay"],returnDependencies({stateValues:tA}){let nA={};for(let rA of["displayDigits","displayDecimals","displaySmallAsZero","padZeros","avoidScientificNotation"])nA[rA]={dependencyType:"stateVariable",variableName:rA};for(let rA of tA.statisticsToDisplay)nA[rA]={dependencyType:"stateVariable",variableName:rA};return nA},definition({dependencyValues:tA}){let nA={};for(let{value:rA}of STATISTICS){const aA=tA[rA];aA!==void 0&&(nA[rA]=displayedStatistic(rA,aA,tA))}return{setValue:{summaryStatistics:nA}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Legend extends GraphicalComponent{static componentType="legend";static componentDocs={summary:"A legend describing the contents of a graph"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.layer.defaultValue=1,eA.position={description:"Position of the legend on the graph.",createComponentOfType:"text",createStateVariable:"position",defaultValue:"upperRight",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"upperRight",description:"Place the legend in the upper-right corner."},{value:"upperLeft",description:"Place the legend in the upper-left corner."},{value:"lowerRight",description:"Place the legend in the lower-right corner."},{value:"lowerLeft",description:"Place the legend in the lower-left corner."}]},eA.boxed={description:"Whether to draw an opaque box behind the legend so that graph contents passing behind it stay hidden.",createComponentOfType:"boolean",createStateVariable:"boxed",defaultValue:!1,public:!0,forRenderer:!0},eA.displayClosedSwatches={description:"Whether to render closed/filled swatches in the legend.",createComponentOfType:"boolean",createStateVariable:"displayClosedSwatches",defaultValue:!1,public:!0},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.graphicalElementNames={returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["graphicalDescendants"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphicalElementNames:AA.graphAncestor.stateValues.graphicalDescendants.map(tA=>tA.componentIdx)}}:{setValue:{graphicalElementNames:null}}}},eA.legendElements={forRenderer:!0,stateVariablesDeterminingDependencies:["graphicalElementNames"],returnDependencies:({stateValues:AA})=>{let tA={labelChildren:{dependencyType:"child",childGroups:["labels"],variableNames:["value","hasLatex","forObjectComponentIdx"]},displayClosedSwatches:{dependencyType:"stateVariable",variableName:"displayClosedSwatches"}};if(AA.graphicalElementNames){tA.numGraphicalElements={dependencyType:"value",value:AA.graphicalElementNames.length};for(let[nA,rA]of AA.graphicalElementNames.entries())tA[`graphicalElement${nA}`]={dependencyType:"multipleStateVariables",componentIdx:rA,variableNames:["selectedStyle","styleNumber","filled"],variablesOptional:!0},tA[`graphicalElement${nA}AdapterSource`]={dependencyType:"adapterSource",componentIdx:rA},tA[`graphicalElement${nA}ShadowSource`]={dependencyType:"shadowSource",componentIdx:rA}}return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){let nA=[];if(AA.numGraphicalElements>0){let rA=[],aA=[],oA=[],sA=[];for(let IA=0;IA<AA.numGraphicalElements;IA++){let CA=AA[`graphicalElement${IA}`],uA=AA[`graphicalElement${IA}AdapterSource`];uA&&(CA={...CA},CA.componentIdx=uA.componentIdx);let dA=AA[`graphicalElement${IA}ShadowSource`];if(dA){const pA=JSON.parse(JSON.stringify(CA));pA.componentIdx=dA.componentIdx,sA.push(pA)}sA.push(CA)}let lA=sA.map(IA=>IA.componentIdx),gA=[],cA={};for(let IA of AA.labelChildren){let CA={value:IA.stateValues.value,hasLatex:IA.stateValues.hasLatex};if(IA.stateValues.forObjectComponentIdx){cA[IA.stateValues.forObjectComponentIdx]=CA;let uA=lA.indexOf(IA.stateValues.forObjectComponentIdx);if(uA!==-1){let dA=sA[uA];tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})?rA.push(dA.stateValues.styleNumber):AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath?aA.push(dA.stateValues.styleNumber):dA.componentType!=="legend"&&oA.push(dA.stateValues.styleNumber)}}gA.push({labelInfo:CA,forObject:IA.stateValues.forObjectComponentIdx})}for(let IA of gA){let CA;if(IA.forObject){let uA=lA.indexOf(IA.forObject);uA!==-1&&(CA=sA[uA],sA.splice(uA,1),lA.splice(uA,1))}else for(let uA=0;uA<sA.length;uA++){let dA=sA[uA];if(!(dA.componentIdx in cA)){if(tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})){if(!rA.includes(dA.stateValues.styleNumber)){CA=dA;break}}else if(AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath){if(!aA.includes(dA.stateValues.styleNumber)){CA=dA;break}}else if(dA.componentType!=="legend"&&!oA.includes(dA.stateValues.styleNumber)){CA=dA;break}}}if(CA){let uA=CA.stateValues.selectedStyle,dA=CA.stateValues.styleNumber;tA.isInheritedComponentType({inheritedComponentType:CA.componentType,baseComponentType:"point"})?(rA.push(dA),nA.push({swatchType:"marker",markerStyle:uA.markerStyle,markerColor:uA.markerColor,markerColorDarkMode:uA.markerColorDarkMode,markerSize:uA.markerSize,lineOpacity:uA.lineOpacity,label:IA.labelInfo})):AA.displayClosedSwatches&&tA.allComponentClasses[CA.componentType].representsClosedPath?(aA.push(dA),nA.push({swatchType:"rectangle",lineStyle:uA.lineStyle,lineColor:uA.lineColor,lineColorDarkMode:uA.lineColorDarkMode,lineWidth:uA.lineWidth,lineOpacity:uA.lineOpacity,fillColor:uA.fillColor,fillColorDarkMode:uA.fillColorDarkMode,filled:CA.stateValues.filled,fillOpacity:uA.fillOpacity,label:IA.labelInfo})):(oA.push(dA),nA.push({swatchType:"line",lineStyle:uA.lineStyle,lineColor:uA.lineColor,lineColorDarkMode:uA.lineColorDarkMode,lineWidth:uA.lineWidth,lineOpacity:uA.lineOpacity,label:IA.labelInfo}))}}}return{setValue:{legendElements:nA}}}},eA.graphLimits={forRenderer:!0,returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["xMin","xMax","yMin","yMax"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphLimits:AA.graphAncestor.stateValues}}:{setValue:{graphLimits:null}}}},eA}}function parameterKey(iA){if(isValidVariable({tree:iA}))return typeof iA=="string"?"s"+iA:"t"+JSON.stringify(iA)}function replacePlaceholders(iA,eA){let AA=eA(iA);return AA!==void 0?AA:Array.isArray(iA)?[iA[0],...iA.slice(1).map(tA=>replacePlaceholders(tA,eA))]:iA}class MatchesPattern extends BooleanComponent{static componentType="matchesPattern";static componentDocs={summary:"Boolean condition that tests whether input matches a math pattern"};static rendererType="boolean";static createAttributesObject(){let eA=super.createAttributesObject();return eA.pattern={createComponentOfType:"math",description:"Math expression pattern to match against.",highlighted:!0},eA.parameters={createComponentOfType:"_variableNameList",description:"Variables in the pattern that act as placeholders. Repeating one in the pattern requires the same subexpression at each occurrence. When specified, blanks in the pattern are matched literally.",highlighted:!0},eA.allowImplicitIdentities={description:"Whether to allow implicit identity transformations when matching.",createComponentOfType:"boolean",createStateVariable:"allowImplicitIdentities",defaultValue:!1,public:!0,highlighted:!0},eA.allowPermutations={description:"Whether to allow permutations of operands when matching.",createComponentOfType:"boolean",createStateVariable:"allowPermutations",defaultValue:!0,public:!0,highlighted:!0},eA.requireNumericMatches={description:"Whether numeric placeholders must match numbers.",createComponentOfType:"boolean",createStateVariable:"requireNumericMatches",defaultValue:!1,public:!0,highlighted:!0},eA.requireVariableMatches={description:"Whether variable placeholders must match variables.",createComponentOfType:"boolean",createStateVariable:"requireVariableMatches",defaultValue:!1,public:!0,highlighted:!0},eA.excludeMatches={description:"Patterns whose matches are excluded.",createComponentOfType:"mathList",createStateVariable:"excludeMatches",defaultValue:[],public:!0,highlighted:!0},eA.matchExpressionWithBlanks={description:"Whether to allow expressions with blanks to match.",createComponentOfType:"boolean",createStateVariable:"matchExpressionWithBlanks",defaultValue:!1,public:!0,highlighted:!0},eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,componentInfoObjects:nA,nComponents:rA,stateIdInfo:aA}){return tA.length===0||tA.length===1&&nA.componentIsSpecifiedType(tA[0],"math")?{success:!1}:{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.parsedExpression,delete eA.mathChildrenByCode,eA.pattern={additionalStateVariablesDefined:["patternVariables"],returnDependencies:()=>({patternAttr:{dependencyType:"attributeComponent",attributeName:"pattern",variableNames:["value"]},parametersAttr:{dependencyType:"attributeComponent",attributeName:"parameters",variableNames:["variables"]}}),definition({dependencyValues:AA}){let tA=[];if(!AA.patternAttr)return{setValue:{pattern:BLANK,patternVariables:tA}};let nA=AA.patternAttr.stateValues.value,rA=nA.variables(),aA=703;function oA(){let dA=numberToLetters(aA);for(aA++;rA.includes(dA);)dA=numberToLetters(aA),aA++;return dA}if(!AA.parametersAttr)return{setValue:{pattern:replacePlaceholders(nA.tree,pA=>{if(pA!==BLANK)return;let mA=oA();return tA.push(mA),mA}),patternVariables:tA}};let sA=AA.parametersAttr.position||void 0,lA=[],gA=new Map,cA=new Map;for(let dA of AA.parametersAttr.stateValues.variables){let pA=parameterKey(dA.tree);if(pA===void 0||gA.has(pA))continue;let mA=oA();gA.set(pA,mA),cA.set(mA,dA.toString()),tA.push(mA)}let IA=new Set,CA=replacePlaceholders(nA.tree,dA=>{let pA=gA.get(parameterKey(dA));return pA!==void 0&&IA.add(pA),pA}),uA=[...cA].filter(([dA])=>!IA.has(dA)).map(([dA,pA])=>pA);return uA.length>0&&lA.push(codedDiagnostic({type:"warning",code:"doenet-w0117",args:{parameters:uA},position:sA})),{setValue:{pattern:CA,patternVariables:tA},sendDiagnostics:lA}}},eA.value={description:"Whether the input matches the pattern.",additionalStateVariablesDefined:[{variableName:"allPatternMatches"}],public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({pattern:{dependencyType:"stateVariable",variableName:"pattern"},patternVariables:{dependencyType:"stateVariable",variableName:"patternVariables"},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},allowImplicitIdentities:{dependencyType:"stateVariable",variableName:"allowImplicitIdentities"},allowPermutations:{dependencyType:"stateVariable",variableName:"allowPermutations"},requireNumericMatches:{dependencyType:"stateVariable",variableName:"requireNumericMatches"},requireVariableMatches:{dependencyType:"stateVariable",variableName:"requireVariableMatches"},excludeMatches:{dependencyType:"stateVariable",variableName:"excludeMatches"},matchExpressionWithBlanks:{dependencyType:"stateVariable",variableName:"matchExpressionWithBlanks"}}),definition:function({dependencyValues:AA}){if(AA.mathChildren.length===0)return{setValue:{value:!1,allPatternMatches:[]}};let tA=AA.mathChildren[0].stateValues.value;if(treeContainsBlank(tA.tree)&&!AA.matchExpressionWithBlanks)return{setValue:{value:!1,allPatternMatches:[]}};let nA="any";AA.requireNumericMatches?nA="number":AA.requireVariableMatches&&(nA="variable");let rA={};AA.patternVariables.forEach(gA=>rA[gA]=nA);let aA={variables:rA,allow_permutations:AA.allowPermutations};AA.allowImplicitIdentities&&(aA.allow_implicit_identities=AA.patternVariables);let oA=tA.match(AA.pattern,aA),sA=!1,lA=[];return oA&&(Object.values(oA).map(gA=>context.fromAst(gA)).some(gA=>AA.excludeMatches.some(cA=>gA.variables().some(IA=>cA.equalsViaSyntax(context.fromAst(IA)))))||(sA=!0,lA=AA.patternVariables.map(gA=>context.fromAst(oA[gA]??BLANK)))),{setValue:{value:sA,allPatternMatches:lA}}}},eA.numMatches={description:"The number of matches found.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}),definition({dependencyValues:AA}){return{setValue:{numMatches:AA.allPatternMatches.length},checkForActualChange:{numMatches:!0}}}},eA.patternMatches={description:"The list of matched sub-expressions.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,numDimensions:1,entryPrefixes:["patternMatch"],returnArraySizeDependencies:()=>({numMatches:{dependencyType:"stateVariable",variableName:"numMatches"}}),returnArraySize({dependencyValues:AA}){return[AA.numMatches]},returnArrayDependenciesByKey(){return{globalDependencies:{allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA={};for(let nA=0;nA<AA.__array_size[0];nA++)tA[nA]=AA.allPatternMatches[nA];return{setValue:{patternMatches:tA}}}},eA}}class Matrix extends MathComponent{static componentType="matrix";static componentDocs={summary:"A matrix of math values",childAliases:{row:"matrixRow",column:"matrixColumn"}};static rendererType="math";static additionalSchemaChildren=["row","column"];static returnChildGroups(){return[{group:"rows",componentTypes:["matrixRow"]},{group:"columns",componentTypes:["matrixColumn"]},{group:"maths",componentTypes:["math"],excludeFromSchema:!0}]}static createAttributesObject(){let eA=super.createAttributesObject();return eA.defaultEntry={createComponentOfType:"math",createStateVariable:"defaultEntry",defaultValue:context.fromAst(0),description:"Value used for entries that aren't explicitly specified."},eA.numRows={createComponentOfType:"integer",description:"Number of rows in the matrix."},eA.numColumns={createComponentOfType:"integer",description:"Number of columns in the matrix."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,componentInfoObjects:nA,nComponents:rA,stateIdInfo:aA}){if(tA.length===0)return{success:!1};let oA=[],sA=!1;for(let lA of tA)typeof lA!="string"&&(lA.doenetAttributes||(lA.doenetAttributes={}),lA.componentType==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.componentType="matrixColumn",sA=!0):lA.componentType==="row"?(lA.doenetAttributes.createNameFromComponentType="row",lA.componentType="matrixRow",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.attributes.createComponentOfType.primitive.value="matrixColumn",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="row"&&(lA.doenetAttributes.createNameFromComponentType="row",lA.attributes.createComponentOfType.primitive.value="matrixRow",sA=!0),oA.push(lA));return sA||(tA.length>1||!nA.componentIsSpecifiedType(tA[0],"math"))&&(oA=[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}]),{success:!0,newChildren:oA,nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.codePre,delete eA.mathChildrenFunctionSymbols,delete eA.expressionWithCodes,delete eA.mathChildrenWithCanBeModified,delete eA.codesAdjacentToStrings,delete eA.canBeModified,delete eA.mathChildrenByVectorComponent,Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.unordered={description:"Whether matrix entries should be treated as unordered.",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({}),definition(){return{setValue:{unordered:!1}}}},eA.matrixSizePre={returnDependencies:()=>({rowChildren:{dependencyType:"child",childGroups:["rows"],variableNames:["numComponents"]},colChildren:{dependencyType:"child",childGroups:["columns"],variableNames:["numComponents"]},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["matrixSize"]},numRowsAttr:{dependencyType:"attributeComponent",attributeName:"numRows",variableNames:["value"]},numColumnsAttr:{dependencyType:"attributeComponent",attributeName:"numColumns",variableNames:["value"]}}),definition({dependencyValues:AA}){let tA=null,nA=null;return AA.numRowsAttr&&(tA=AA.numRowsAttr.stateValues.value,Number.isFinite(tA)&&tA>0||(tA=null)),AA.numColumnsAttr&&(nA=AA.numColumnsAttr.stateValues.value,Number.isFinite(nA)&&nA>0||(nA=null)),AA.rowChildren.length>0?(tA===null&&(tA=AA.rowChildren.length),nA===null&&(nA=Math.max(1,...AA.rowChildren.map(rA=>rA.stateValues.numComponents)))):AA.colChildren.length>0?(nA===null&&(nA=AA.colChildren.length),tA===null&&(tA=Math.max(1,...AA.colChildren.map(rA=>rA.stateValues.numComponents)))):AA.mathChildren.length===1?(tA===null&&(tA=AA.mathChildren[0].stateValues.matrixSize[0]),nA===null&&(nA=AA.mathChildren[0].stateValues.matrixSize[1])):tA===null?nA===null?(tA=0,nA=0):tA=1:nA===null&&(nA=1),{setValue:{matrixSizePre:[tA,nA]}}}},eA.matrixPre={isArray:!0,numDimensions:2,hasEssential:!0,returnArraySizeDependencies:()=>({matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),returnArraySize({dependencyValues:AA}){return AA.matrixSizePre},returnArrayDependenciesByKey:({arrayKeys:AA})=>{let tA={defaultEntry:{dependencyType:"stateVariable",variableName:"defaultEntry"},rowChildIdentities:{dependencyType:"child",childGroups:["rows"]},colChildIdentities:{dependencyType:"child",childGroups:["columns"]}},nA={};for(let rA of AA){let[aA,oA]=rA.split(",");nA[rA]={rowChild:{dependencyType:"child",childGroups:["rows"],childIndices:[aA],variableNames:["math"+(Number(oA)+1)]},colChild:{dependencyType:"child",childGroups:["columns"],childIndices:[oA],variableNames:["math"+(Number(aA)+1)]},mathChild:{dependencyType:"child",childGroups:["maths"],childIndices:[0],variableNames:["matrixEntry"+(Number(aA)+1)+"_"+(Number(oA)+1)]}}}return{globalDependencies:tA,dependenciesByKey:nA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:nA,arraySize:rA}){let aA={},oA={},sA=AA.rowChildIdentities.length>0,lA=AA.colChildIdentities.length>0;for(let gA of nA){let[cA,IA]=gA.split(","),CA;sA?CA=tA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]:lA?CA=tA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]:CA=tA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)],CA===void 0?oA[gA]={defaultValue:AA.defaultEntry}:aA[gA]=CA}return{setValue:{matrixPre:aA},useEssentialOrDefaultValue:{matrixPre:oA}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:nA,dependencyNamesByKey:rA}){let aA=[],oA={},sA=tA.rowChildIdentities.length>0,lA=tA.colChildIdentities.length>0;for(let gA in AA.matrixPre){let[cA,IA]=gA.split(",");sA?nA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].rowChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):lA?nA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].colChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):nA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].mathChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0})}return Object.keys(oA).length>0&&aA.push({setEssentialValue:"matrixPre",value:oA}),{success:!0,instructions:aA}}},eA.unnormalizedValue={returnDependencies:()=>({matrixPre:{dependencyType:"stateVariable",variableName:"matrixPre"},matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),hasEssential:!0,defaultValue:context.fromAst(["matrix",["tuple",0,0],["tuple"]]),definition({dependencyValues:AA}){let tA=["tuple"];for(let rA=0;rA<AA.matrixSizePre[0];rA++)tA.push(["tuple",...AA.matrixPre[rA].map(aA=>aA.tree)]);return{setValue:{unnormalizedValue:context.fromAst(["matrix",["tuple",...AA.matrixSizePre],tA])}}},inverseDefinition({dependencyValues:AA,desiredStateVariableValues:tA}){let nA=tA.unnormalizedValue.tree;if(!(Array.isArray(nA)&&nA[0]==="matrix"&&nA[1]?.[1]===AA.matrixSizePre[0]&&nA[1]?.[2]===AA.matrixSizePre[1]))return{success:!1};let rA={};for(let aA=0;aA<AA.matrixSizePre[0];aA++)for(let oA=0;oA<AA.matrixSizePre[1];oA++)rA[`${aA},${oA}`]=context.fromAst(nA[2][aA+1][oA+1]);return{success:!0,instructions:[{setDependency:"matrixPre",desiredValue:rA}]}}},eA.canBeModified={returnDependencies:()=>({modifyIndirectly:{dependencyType:"stateVariable",variableName:"modifyIndirectly"},fixed:{dependencyType:"stateVariable",variableName:"fixed"}}),definition({dependencyValues:AA}){return{setValue:{canBeModified:AA.modifyIndirectly&&!AA.fixed}}}},eA}}const{eigs,square,abs,divide}=context.math;class EigenDecomposition extends BaseComponent{static componentType="eigenDecomposition";static rendererType=void 0;static componentDocs={summary:"Computes the eigenvalues and eigenvectors of a square matrix"};static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.decomposition={description:"The eigendecomposition of the matrix as a list of eigenvalue/eigenvector pairs.",additionalStateVariablesDefined:[{variableName:"numEigenvectors",description:"The number of eigenvectors found in the decomposition.",public:!0,shadowingInstructions:{createComponentOfType:"integer"}}],returnDependencies:()=>({mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]}}),definition({dependencyValues:AA}){if(AA.mathChild.length===0)return{setValue:{decomposition:null,numEigenvectors:0}};let tA=AA.mathChild[0].stateValues.value.tree;if(!Array.isArray(tA)||tA[0]!=="matrix")return{setValue:{decomposition:null,numEigenvectors:0}};let nA=tA[1][1],rA=tA[1][2];if(!(Number.isInteger(nA)&&rA===nA))return{setValue:{decomposition:null,numEigenvectors:0}};let aA=[];for(let sA=0;sA<nA;sA++){let lA=[],gA=tA[2][sA+1]||[];for(let cA=0;cA<rA;cA++){let IA=gA[cA+1];if(IA==null)return{setValue:{decomposition:null,numEigenvectors:0}};if(typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number")lA.push(IA);else try{IA=context.fromAst(IA).evaluate_to_constant(),typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number"?lA.push(IA):lA.push(NaN)}catch{lA.push(NaN)}}aA.push(lA)}let oA;try{oA=eigs(aA)}catch(sA){console.error("Could nt calculate eigenvalues of matrix",sA);let lA=codedDiagnostic({type:"warning",code:"doenet-w0059"});return{setValue:{decomposition:null,numEigenvectors:0},sendDiagnostics:[lA]}}return{setValue:{decomposition:oA,numEigenvectors:oA.eigenvectors.length}}}},eA.eigenvalues={description:"The eigenvalues of the matrix.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},entryPrefixes:["eigenvalue"],returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA;return AA.decomposition?tA=AA.decomposition.values.length:tA=0,[tA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let nA=[];for(let rA=0;rA<tA[0];rA++)nA.push(AA.decomposition.values[rA]);return{setValue:{eigenvalues:nA}}}},eA.eigenvectors={description:"The eigenvectors of the matrix, as a 2D array (one column per eigenvalue).",isArray:!0,public:!0,numDimensions:2,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="eigenvectorX"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},getArrayKeysFromVarName({arrayEntryPrefix:AA,varEnding:tA,arraySize:nA}){if(AA==="eigenvectorX"){let rA=tA.split("_").map(aA=>Number(aA)-1);return rA.length===2&&rA.every((aA,oA)=>Number.isInteger(aA)&&aA>=0)?nA?rA.every((aA,oA)=>aA<nA[oA])?[String(rA)]:[]:[String(rA)]:[]}else{let rA=Number(tA)-1;return Number.isInteger(rA)&&rA>=0?nA?rA<nA[0]?Array.from(Array(nA[1]),(aA,oA)=>rA+","+oA):[]:[rA+",0"]:[]}},arrayVarNameFromPropIndex(AA,tA){if(tA==="eigenvectors")return AA.length===1?"eigenvector"+AA[0]:`eigenvectorX${AA[0]}_${AA[1]}`;if(tA.slice(0,11)==="eigenvector"){let nA=Number(tA.slice(11));if(Number.isInteger(nA)&&nA>0)return`eigenvectorX${nA}_${AA[0]}`}return null},indexAliases:[[],["x","y","z"]],entryPrefixes:["eigenvectorX","eigenvector"],returnEntryDimensions:AA=>AA==="eigenvector"?1:0,returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA,nA;return AA.decomposition?(tA=AA.decomposition.eigenvectors.length,nA=AA.decomposition.eigenvectors[0].vector.length):(tA=0,nA=0),[tA,nA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let nA={};for(let rA=0;rA<tA[0];rA++){let aA=[],oA=0;for(let sA=0;sA<tA[1];sA++){let lA=AA.decomposition.eigenvectors[rA].vector[sA];aA.push(lA),oA+=square(abs(lA))}oA=Math.sqrt(oA),aA=aA.map(sA=>divide(sA,oA));for(let sA=0;sA<tA[1];sA++)nA[`${rA},${sA}`]=aA[sA]}return{setValue:{eigenvectors:nA}}}},eA}}class Latex extends Text{static componentType="latex";static componentDocs={summary:"A snippet of LaTeX that can be rendered as math"};static rendererType="text";static createAttributesObject(){let eA=super.createAttributesObject();return eA.isLatex.defaultValue=!0,eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA[0].componentTypes.push("math","m","md"),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.value.returnDependencies=()=>({mathTextLikeChildren:{dependencyType:"child",childGroups:["textLike"],variableNames:["text","latex"],variablesOptional:!0}}),eA.value.definition=function({dependencyValues:AA}){if(AA.mathTextLikeChildren.length===0)return{useEssentialOrDefaultValue:{value:!0}};let tA=[];for(let rA of AA.mathTextLikeChildren)if(typeof rA=="string"){let aA=rA.trim();aA&&tA.push(aA)}else if(rA.stateValues.latex!==void 0){let aA=rA.stateValues.latex.trim();aA&&tA.push(aA)}else{let aA=rA.stateValues.text.trim();aA&&tA.push(aA)}return{setValue:{value:tA.join(" ")}}},eA.value.inverseDefinition=function({desiredStateVariableValues:AA,dependencyValues:tA}){let nA=tA.mathTextLikeChildren.length;return nA>1?{success:!1}:nA===1?{success:!0,instructions:[{setDependency:"textLikeChildren",desiredValue:AA.value,childIndex:0,variableIndex:tA.textLikeChildren[0].stateValues?.latex===void 0?0:1}]}:{success:!0,instructions:[{setEssentialValue:"value",value:AA.value===null?"":String(AA.value)}]}},eA.latex={isAlias:!0,targetVariableName:"value",description:"The LaTeX content as a string."},eA}}class BlockQuote extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="blockQuote";static rendererType="blockQuote";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static componentDocs={summary:"A block-level quotation"};static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Description extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="description";static componentDocs={summary:"Extra information about an enclosing component, shown to all users in a popup or disclosure"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static inSchemaOnlyInheritAs=[];static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}const{mod:mod$1}=context.math;function findAttractedSegmentPointsSub({point1:iA,point2:eA,scales:AA,threshold2:tA,numericalNearestPointFunction:nA,numericalNearestPointAsLineFunction:rA,verifyNotOneSided:aA=!0}){let oA=1e-6,sA=oA**2,lA=rA(iA,AA);if(!lA)return{success:!1};let gA=lA.reduce((IA,CA,uA)=>IA+Math.pow(CA-iA[uA],2),0);if(gA>=tA)return{success:!1};let cA=rA(eA,AA);if(!cA)return{success:!1};if(gA=cA.reduce((IA,CA,uA)=>IA+Math.pow(CA-eA[uA],2),0),gA>=tA)return{success:!1};if(aA){let IA=nA(iA,AA),CA=IA&&IA.every((pA,mA)=>Math.abs(pA-lA[mA])<oA),uA=nA(eA,AA),dA=uA&&uA.every((pA,mA)=>Math.abs(pA-cA[mA])<oA);if(!(CA||dA)&&(gA=IA.reduce((pA,mA,QA)=>pA+Math.pow(mA-uA[QA],2),0),gA<sA))return{success:!1}}return{success:!0,nearestPoint1:lA,nearestPoint2:cA}}function findAttractedSegmentPoints({point1:iA,point2:eA,allowRotation:AA,scales:tA,threshold2:nA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA}){let oA=findAttractedSegmentPointsSub({point1:iA,point2:eA,scales:tA,threshold2:nA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!0});if(!oA.success)return{success:!1};let sA=1e-6,lA=sA**2,{nearestPoint1:gA,nearestPoint2:cA}=oA;if(!AA){let NA=[eA[0]-iA[0],eA[1]-iA[1]],yA=[cA[0]-gA[0],cA[1]-gA[1]],bA=Math.atan2(yA[1],yA[0])-Math.atan2(NA[1],NA[0]);if(bA=mod$1(bA+Math.PI,2*Math.PI)-Math.PI,Math.abs(bA)>sA)return{success:!1}}let IA=iA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0),CA=gA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0);if(Math.abs(IA-CA)<lA){let NA=gA.reduce((yA,bA,wA)=>yA+Math.pow(bA-iA[wA],2),0)+cA.reduce((yA,bA,wA)=>yA+Math.pow(bA-eA[wA],2),0);return NA<nA?{success:!0,distance2:NA,segment:[gA,cA]}:{success:!1}}if(CA>IA)return{success:!1};let uA=Math.sqrt(IA/CA),dA=Math.sqrt(iA.reduce((NA,yA,bA)=>NA+Math.pow(yA-gA[bA],2),0)),pA=Math.sqrt(eA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0)),mA=dA/(dA+pA),QA=1-mA,BA=(uA-1)*mA+1,hA=(uA-1)*QA+1,DA=cA.map((NA,yA)=>NA+(gA[yA]-NA)*BA),EA=gA.map((NA,yA)=>NA+(cA[yA]-NA)*hA);if(oA=findAttractedSegmentPointsSub({point1:DA,point2:EA,scales:tA,threshold2:lA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!1}),!oA.success)return{success:!1};let fA=DA.reduce((NA,yA,bA)=>NA+Math.pow(yA-iA[bA],2),0)+EA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0);return fA<nA?{success:!0,distance2:fA,segment:[DA,EA]}:{success:!1}}function attractSegment({segment:iA,allowRotation:eA,scales:AA,threshold2:tA,numericalNearestPointFunctions:nA,numericalNearestPointAsLineFunctions:rA}){let aA=iA[0],oA=iA[1];if(aA.length!=oA.length)return{};let sA,lA=1/0,gA=eA?tA*1e3:tA;for(let[cA,IA]of nA.entries()){let CA=rA[cA],uA=findAttractedSegmentPoints({point1:aA,point2:oA,allowRotation:eA,scales:AA,threshold2:gA,numericalNearestPointFunction:IA,numericalNearestPointAsLineFunction:CA});uA.success&&uA.distance2<lA&&(lA=uA.distance2,sA=uA.segment)}return lA<tA?{constrained:!0,segment:sA}:lA<gA?{constrained:!1,distance2:lA,segment:sA}:{}}function nearestPointForSegment({point:iA,segment:eA,scales:AA}){let tA=eA[0][0],nA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(nA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===nA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-nA)/lA,IA=gA*gA+cA*cA,CA=((iA[0]-tA)/sA*gA+(iA[1]-nA)/lA*cA)/IA;return CA<=0?[tA,nA]:CA>=1?[rA,aA]:[tA+CA*gA*sA,nA+CA*cA*lA]}function nearestPointForSegmentAsLine({point:iA,segment:eA,scales:AA}){let tA=eA[0][0],nA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(nA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===nA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-nA)/lA,IA=gA*gA+cA*cA,CA=((iA[0]-tA)/sA*gA+(iA[1]-nA)/lA*cA)/IA;return[tA+CA*gA*sA,nA+CA*cA*lA]}const{mod:mod$6}=context.math;class StickyGroup extends GraphicalComponent{static componentType="stickyGroup";constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentDocs={summary:"Constrains group members to attract to each other when nearby"};static rendererType="containerInline";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.relativeToGraphScales={description:"Whether the snapping threshold is interpreted relative to graph scales.",createComponentOfType:"boolean",createStateVariable:"relativeToGraphScales",defaultValue:!1,public:!0},eA.threshold={createComponentOfType:"number",description:"Distance threshold within which group members snap together."},eA.angleThreshold={description:"Angular distance within which group members snap together.",createComponentOfType:"number",createStateVariable:"angleThreshold",defaultValue:Math.PI*.03,public:!0},eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"graphical",componentTypes:["_graphical"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnConstraintGraphInfoDefinitions();return Object.assign(eA,AA),eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.pointsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","numericalXs","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let nA=[];for(let rA of tA.graphicalChildren)rA.stateValues.numericalVertices?nA.push(rA.stateValues.numericalVertices):rA.stateValues.numericalXs?nA.push([rA.stateValues.numericalXs]):rA.stateValues.numericalEndpoints?nA.push(rA.stateValues.numericalEndpoints):nA.push([]);return{setValue:{pointsByObject:nA}}}},eA.getPointsForObject={returnDependencies:()=>({pointsByObject:{dependencyType:"stateVariable",variableName:"pointsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getPointsForObject:function(rA){return tA.pointsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.segmentsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","closed","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let nA=[];for(let rA of tA.graphicalChildren)if(rA.stateValues.numericalVertices){let aA=rA.stateValues.numericalVertices,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);rA.stateValues.closed&&sA.push([aA[oA-1],aA[0]]),nA.push(sA)}else if(rA.stateValues.numericalEndpoints){let aA=rA.stateValues.numericalEndpoints,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);nA.push(sA)}else nA.push([]);return{setValue:{segmentsByObject:nA}}}},eA.getSegmentsForObject={returnDependencies:()=>({segmentsByObject:{dependencyType:"stateVariable",variableName:"segmentsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getSegmentsForObject:function(rA){return tA.segmentsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.threshold={description:"Distance within which group members attract each other.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,returnDependencies:()=>({thresholdAttr:{dependencyType:"attributeComponent",attributeName:"threshold",variableNames:["value"]},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"}}),definition({dependencyValues:tA}){return tA.thresholdAttr?{setValue:{threshold:tA.thresholdAttr.stateValues.value}}:{useEssentialOrDefaultValue:{threshold:{get defaultValue(){return tA.relativeToGraphScales&&tA.graphXmin!==null?.02:.5}}}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:nA}){return nA.thresholdAttr?{success:!0,instructions:[{setDependency:"thresholdAttr",desiredValue:tA.threshold}]}:{success:!0,instructions:[{setEssentialValue:"threshold",value:tA.threshold}]}}},eA.verticesConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},angleThreshold:{dependencyType:"stateVariable",variableName:"angleThreshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let nA;tA.relativeToGraphScales?nA=tA.scales||[1,1,1]:nA=[1,1,1];let rA=tA.angleThreshold,aA=function({numericalUnconstrainedEdges:cA,allowRotation:IA,enforceRigid:CA,shrinkThreshold:uA,rotationPoint:dA},{objectInd:pA}){let mA=tA.getSegmentsForObject(pA),QA=[],BA=[],hA=!1,DA={distance2:1/0},EA=tA.threshold;uA&&(EA*=.2);let fA=EA*EA;for(let[NA,yA]of cA.entries()){let bA=[],wA=[];for(let vA of mA)bA.push((OA,FA)=>nearestPointForSegment({point:OA,segment:vA,scales:FA})),wA.push((OA,FA)=>nearestPointForSegmentAsLine({point:OA,segment:vA,scales:FA}));let MA=attractSegment({segment:yA,allowRotation:IA,scales:nA,threshold2:fA,numericalNearestPointFunctions:bA,numericalNearestPointAsLineFunctions:wA});MA.constrained?(QA.push(MA.segment),BA.push(!0),hA=!0):(QA.push(yA),BA.push(!1),!hA&&MA.distance2<DA.distance2&&(DA=MA,DA.edgeInd=NA))}if(IA&&CA&&!hA&&DA.distance2<1/0){let NA=DA.edgeInd,yA=rotateIfClose({attractedEdgeInd:NA,attractingSegment:DA.segment,angleThreshold:rA,rotationPoint:dA,numericalUnconstrainedEdges:cA});yA&&(QA[NA]=yA,BA[NA]=!0,hA=!0)}if(IA&&CA&&!hA){let NA=[0,Math.PI/2],yA=rotateToAttractAngles({numericalUnconstrainedEdges:cA,anglesToAttract:NA,angleThreshold:rA,rotationPoint:dA});if(yA){let bA=yA.rotatedEdgeInd;QA[bA]=yA.rotatedEdge,BA[bA]=!0,hA=!0}}return{numericalConstrainedEdges:QA,constraintUsedForEdge:BA}},oA=function({numericalUnconstrainedVertices:cA,closed:IA,shrinkThreshold:CA,onlyMoveVertexInd:uA=null},{objectInd:dA}){let pA=tA.getPointsForObject(dA),mA=tA.getSegmentsForObject(dA),QA=[],BA=[],hA=tA.threshold;CA&&(hA*=.2);let DA=hA*hA;for(let[yA,bA]of cA.entries()){if(uA!==null&&yA!==uA){QA.push(bA),BA.push(!1);continue}let wA=1/0,MA={};for(let FA of pA){if(bA.length!==FA.length)continue;let kA=bA.reduce((SA,RA,xA)=>SA+Math.pow((RA-FA[xA])/nA[xA],2),0);kA<wA&&(MA=FA,wA=kA)}let vA=!1,OA;if(wA<DA)vA=!0,OA=MA;else{wA=1/0,MA={};for(let FA of mA){let kA=nearestPointForSegment({point:bA,segment:FA,scales:nA});if(kA){let SA=bA.reduce((RA,xA,ZA)=>RA+Math.pow((xA-kA[ZA])/nA[ZA],2),0);SA<wA&&(MA=kA,wA=SA)}}wA<DA?(vA=!0,OA=MA):OA=bA}QA.push(OA),BA.push(vA)}let EA=cA.length,fA=IA?EA:EA-1,NA=[];for(let yA=0;yA<fA;yA++){let bA=(yA+1)%EA;if(!(uA!==null&&!(uA===yA||uA===bA))&&!(BA[yA]||BA[bA])){let wA=cA[yA],MA=cA[bA],vA,OA=1/0;for(let FA of pA){let kA=nearestPointForSegment({point:FA,segment:[wA,MA],scales:nA});if(kA){let SA=kA.reduce((RA,xA,ZA)=>RA+Math.pow(xA-FA[ZA],2),0);if(SA<OA)if(uA===null){let RA=wA.map((ZA,XA)=>ZA+FA[XA]-kA[XA]),xA=MA.map((ZA,XA)=>ZA+FA[XA]-kA[XA]);vA=[RA,xA],OA=SA}else{let RA;uA===yA?RA=MA:RA=wA;let xA=[FA[0]-RA[0],FA[1]-RA[1]],ZA=Math.sqrt(Math.pow(xA[0],2)+Math.pow(xA[1],2)),jA=Math.sqrt(Math.pow(wA[0]-MA[0],2)+Math.pow(wA[1]-MA[1],2))/ZA;if(jA<1)continue;let TA=RA.map((VA,$A)=>VA+xA[$A]*jA),UA;uA===yA?(UA=[TA,MA],SA=Math.pow(wA[0]-TA[0],2)+Math.pow(wA[1]-TA[1],2)):(UA=[wA,TA],SA=Math.pow(MA[0]-TA[0],2)+Math.pow(MA[1]-TA[1],2)),SA<OA&&(OA=SA,vA=UA)}}}OA<DA&&NA.push({vertexInd1:yA,vertexInd2:bA,distance2:OA,movedSegment:vA})}}NA.sort((yA,bA)=>yA.distance2-bA.distance2);for(let{vertexInd1:yA,vertexInd2:bA,movedSegment:wA}of NA)BA[yA]||BA[bA]||(BA[yA]=!0,BA[bA]=!0,QA[yA]=wA[0],QA[bA]=wA[1]);return{numericalConstrainedVertices:QA,constraintUsedForVertex:BA}},sA=returnVertexConstraintFunctionFromEdges(aA),lA=returnVertexConstraintFunction(oA);return{setValue:{verticesConstraintFunction:function({unconstrainedVertices:cA,closed:IA,enforceRigid:CA,allowRotation:uA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}){let BA=sA({unconstrainedVertices:cA,closed:IA,enforceRigid:CA,allowRotation:uA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA});return BA=lA({unconstrainedVertices:BA,closed:IA,enforceRigid:CA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}),BA}}}}},eA.pointConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let nA;return tA.relativeToGraphScales?nA=tA.scales||[1,1,1]:nA=[1,1,1],{setValue:{pointConstraintFunction:function(aA,oA){let sA=aA.map(CA=>findFiniteNumericalValue(CA)),lA=tA.getPointsForObject(oA),gA=tA.getSegmentsForObject(oA),cA=1/0,IA={};for(let CA of lA){if(sA.length!==CA.length)continue;let uA=sA.reduce((dA,pA,mA)=>dA+Math.pow((pA-CA[mA])/nA[mA],2),0);uA<cA&&(IA=CA,cA=uA)}if(cA<tA.threshold*tA.threshold)return IA.map(CA=>context.fromAst(CA));cA=1/0,IA={};for(let CA of gA){let uA=nearestPointForSegment({point:sA,segment:CA,scales:nA});if(uA){let dA=sA.reduce((pA,mA,QA)=>pA+Math.pow((mA-uA[QA])/nA[QA],2),0);dA<cA&&(IA=uA,cA=dA)}}return cA<tA.threshold*tA.threshold?IA.map(CA=>context.fromAst(CA)):aA}}}}},eA}async addChildren(eA){return await addChildrenToDynamicChild(this,eA)}async deleteChildren(eA){return await deleteChildrenFromDynamicChild(this,eA)}}function rotateToAttractAngles({numericalUnconstrainedEdges:iA,anglesToAttract:eA,angleThreshold:AA,rotationPoint:tA}){let nA=1/0,rA;for(let[cA,IA]of iA.entries()){let CA=Math.atan((IA[1][1]-IA[0][1])/(IA[1][0]-IA[0][0]));for(let uA of eA){let dA=mod$6(uA-CA+Math.PI/2,Math.PI)-Math.PI/2;Math.abs(dA)<Math.abs(nA)&&(nA=dA,rA=cA)}}if(!(Math.abs(nA)<AA))return null;let[aA,oA]=tA,sA=Math.cos(nA),lA=Math.sin(nA),gA=iA[rA].map(cA=>{let IA=cA[0]-aA,CA=cA[1]-oA;return[IA*sA-CA*lA+aA,IA*lA+CA*sA+oA]});return{rotatedEdgeInd:rA,rotatedEdge:gA}}function rotateIfClose({attractedEdgeInd:iA,attractingSegment:eA,angleThreshold:AA,rotationPoint:tA,numericalUnconstrainedEdges:nA}){let rA=Math.atan((eA[1][1]-eA[0][1])/(eA[1][0]-eA[0][0])),aA=nA[iA],oA=Math.atan((aA[1][1]-aA[0][1])/(aA[1][0]-aA[0][0])),sA=mod$6(rA-oA+Math.PI/2,Math.PI)-Math.PI/2;if(!(Math.abs(sA)<AA))return null;let[lA,gA]=tA,cA=Math.cos(sA),IA=Math.sin(sA);return nA[iA].map(uA=>{let dA=uA[0]-lA,pA=uA[1]-gA;return[dA*cA-pA*IA+lA,dA*IA+pA*cA+gA]})}class BlockScoredComponent extends BlockComponent{static componentType="_blockScoredComponent";static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnStandardAnswerAttributes()),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"disabled",newName:"disabledOriginal"}),Object.assign(eA,returnStandardAnswerStateVariableDefinition()),eA}}function parseIntegerResponse(iA){const eA=iA.trim();if(eA==="")return null;const AA=Number(eA);return Number.isInteger(AA)?AA:null}function isDistractorResponse(iA){return iA.trim().toLowerCase()==="x"}function calculateResponseOffset({numericResponse:iA,effectiveProblemNum:eA,numEffectiveProblems:AA}){return(iA-eA+AA)%AA}function calculatePretzelCredit({problemOrder:iA,currentResponses:eA,distractors:AA,mode:tA}){const nA=new Set(AA),rA=iA.length,aA=rA-nA.size;if(aA===0)return eA.every(isDistractorResponse)?1:0;const oA=Array(rA).fill(null);let sA=0;for(let CA=0;CA<rA;CA++)nA.has(CA)||(oA[CA]=sA,sA++);const lA=[],gA=tA==="circuit"?aA===1?0:1:null;for(let CA=0;CA<rA;CA++){const uA=iA[CA],dA=eA[CA]??"";if(nA.has(uA)){if(!isDistractorResponse(dA))return 0;continue}const pA=parseIntegerResponse(dA);if(pA===null)return 0;const mA=oA[uA],QA=calculateResponseOffset({numericResponse:pA,effectiveProblemNum:mA,numEffectiveProblems:aA});if(tA==="circuit"){if(QA!==gA)return 0;continue}lA.push(QA)}if(tA==="circuit")return 1;const cA=lA[0];return lA.every(CA=>CA===cA)?1:0}class Pretzel extends BlockScoredComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this),submitAnswer:this.submitAnswer.bind(this)})}static componentType="pretzel";static componentDocs={summary:"A response-matching component where students enter a sequence to match statements and answers"};static renderChildren=!0;static additionalSchemaChildren=["problem"];static additionalSchemaChildrenDoNotInherit=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.maxNumColumns={description:"Maximum number of columns when arranging child problems.",createComponentOfType:"integer",createStateVariable:"maxNumColumns",defaultValue:2,public:!0,forRenderer:!0,clamp:[1,4]},eA.mode={description:"Arrangement mode for the child problems.",createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static returnChildGroups(){return[{group:"problems",componentTypes:["statement"],excludeFromSchema:!0},{group:"textInputs",componentTypes:["textInput"],excludeFromSchema:!0},{group:"givenAnswers",componentTypes:["span"],excludeFromSchema:!0}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.textInputs={returnDependencies:()=>({textInputs:{dependencyType:"child",childGroups:["textInputs"]}}),definition:function({dependencyValues:AA}){return{setValue:{textInputs:AA.textInputs}}}},eA.problemOrder={stateVariablesDeterminingDependencies:["textInputs"],additionalStateVariablesDefined:["distractors"],returnDependencies({stateValues:AA}){return AA.textInputs.length>0?{problemOrder:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"problemOrder"},distractors:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"distractors"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{problemOrder:AA.problemOrder??[],distractors:AA.distractors??[]}}}},eA.numProblems={description:"The number of child problems.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({problemChildren:{dependencyType:"child",childGroups:["problems"]}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.problemChildren.length}}}},eA.currentResponses={description:"The current responses across all child problems.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,entryPrefixes:["currentResponse"],returnArraySizeDependencies:()=>({numProblems:{dependencyType:"stateVariable",variableName:"numProblems"}}),returnArraySize({dependencyValues:AA}){return[AA.numProblems]},returnArrayDependenciesByKey({arrayKeys:AA}){const tA={};for(const nA of AA)tA[nA]={textInput:{dependencyType:"child",childGroups:["textInputs"],childIndices:[nA],variableNames:["value"]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA}){const tA={};for(const nA in AA)tA[nA]=AA[nA].textInput[0].stateValues.value;return{setValue:{currentResponses:tA}}}},eA.creditAchievedIfSubmit={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},currentResponses:{dependencyType:"stateVariable",variableName:"currentResponses"},distractors:{dependencyType:"stateVariable",variableName:"distractors"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=AA.problemOrder.map(nA=>nA-1);return{setValue:{creditAchievedIfSubmit:calculatePretzelCredit({problemOrder:tA,currentResponses:AA.currentResponses,distractors:AA.distractors,mode:AA.mode})}}}},eA.numSubmittedResponses={description:"The number of responses submitted.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,defaultValue:0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{numSubmittedResponses:!0}}),inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"numSubmittedResponses",value:AA.numSubmittedResponses}]}}},eA.submittedResponses={description:"The most recently submitted responses.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,allowExtraArrayKeysInInverse:!0,entryPrefixes:["submittedResponse"],defaultValueByArrayKey:()=>"_",hasEssential:!0,inverseShadowToSetEntireArray:!0,doNotCombineInverseArrayInstructions:!0,returnArraySizeDependencies:()=>({numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}),returnArraySize({dependencyValues:AA}){return[AA.numSubmittedResponses]},returnArrayDependenciesByKey(){return{globalDependencies:{numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA=[];AA.submittedResponsesComponentType&&tA.push(...AA.submittedResponsesComponentType.slice(0,AA.numSubmittedResponses));let nA={};for(let rA=0;rA<AA.numSubmittedResponses;rA++)nA[rA]=!0;return{useEssentialOrDefaultValue:{submittedResponses:nA}}},inverseArrayDefinitionByKey:function({desiredStateVariableValues:AA,initialChange:tA}){return tA?{success:!0,instructions:[{setDependency:"numSubmittedResponses",desiredValue:AA.submittedResponses.length},{setEssentialValue:"submittedResponses",value:[...AA.submittedResponses]}]}:{success:!1}}},eA.showCheckWork={forRenderer:!0,returnDependencies:()=>({suppressCheckWork:{dependencyType:"stateVariable",variableName:"suppressCheckWork"}}),definition({dependencyValues:AA}){return{setValue:{showCheckWork:!AA.suppressCheckWork}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}async submitAnswer({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(await this.stateValues.numAttemptsLeft<1||await this.stateValues.disabled)return;const aA=await this.stateValues.handGraded?0:await this.stateValues.creditAchievedIfSubmit;let oA=[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchieved",value:aA},{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"responseHasBeenSubmitted",value:!0}],sA=await this.stateValues.currentResponses;oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"submittedResponses",value:sA}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"justSubmitted",value:!0}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchievedDependenciesAtSubmit",value:await this.stateValues.creditAchievedDependencies}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numSubmissions",value:await this.stateValues.numSubmissions+1}),aA<1&&oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numIncorrectSubmissions",value:await this.stateValues.numIncorrectSubmissions+1});const lA=[];for(const gA of sA)if(gA.toString)try{lA.push(gA.toString())}catch{lA.push("_")}else lA.push(gA);return oA.push({updateType:"recordItemSubmission",componentNumber:await this.stateValues.inComponentNumber,submittedComponent:this.componentIdx,response:sA,responseText:lA,creditAchieved:aA}),await this.coreFunctions.performUpdate({updateInstructions:oA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"submitted",object:{componentIdx:this.componentIdx,componentType:this.componentType,answerNumber:this.answerNumber,rootName:this.rootName},result:{response:sA,responseText:lA,componentTypes:Array(sA.length).fill("text"),creditAchieved:aA}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}function getCorrespondingAnswerIdx({problemIdx:iA,numProblems:eA,distractorSet:AA}){if(AA.has(iA))return iA;let tA=(iA-1+eA)%eA,nA=0;for(;AA.has(tA)&&nA<eA;)tA=(tA-1+eA)%eA,nA++;return tA}function normalizePretzelMode(iA){return iA?.toLowerCase()==="circuit"?"circuit":"pretzel"}function getProblemIndicesToPermute({numProblems:iA,mode:eA}){const AA=eA==="circuit"?2:1;return[...Array(Math.max(iA-AA+1,0)).keys()].map(tA=>tA+AA)}function buildProblemOrderFromPermutedIndices({permutedIndices:iA,numProblems:eA,mode:AA}){return AA==="circuit"?eA===0?[]:[1,...iA]:iA}function determineNumberOfPermutations({numProblems:iA,mode:eA}){const AA=getProblemIndicesToPermute({numProblems:iA,mode:eA}).length;let tA=1;for(let nA=2;nA<=AA;nA++)tA*=nA;return tA}function shuffleProblemOrder({numProblems:iA,variantRng:eA,mode:AA}){const tA=getProblemIndicesToPermute({numProblems:iA,mode:AA});for(let nA=tA.length-1;nA>0;nA--){const rA=eA(),aA=Math.floor(rA*(nA+1));[tA[nA],tA[aA]]=[tA[aA],tA[nA]]}return buildProblemOrderFromPermutedIndices({permutedIndices:tA,numProblems:iA,mode:AA})}class PretzelArranger extends CompositeComponent{static componentType="_pretzelArranger";static componentDocs={summary:"Internal arranger that lays out subset visualizations within <pretzel>."};static createsVariants=!0;static serializeReplacementsForChildren=!0;static replacementsAlreadyInResolver=!0;static useSerializedChildrenComponentIndices=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.mode={createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.serializedProblemChildren={returnDependencies:()=>({serializedChildren:{dependencyType:"serializedChildren",doNotProxy:!0}}),definition:function({dependencyValues:AA}){return{setValue:{serializedProblemChildren:AA.serializedChildren.filter(tA=>tA.componentType==="problem")}}}},eA.numProblems={description:"The number of problems arranged.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.serializedProblemChildren.length}}}},eA.problemOrder={forRenderer:!0,shadowVariable:!0,returnDependencies:({sharedParameters:AA})=>({mode:{dependencyType:"stateVariable",variableName:"mode"},numProblems:{dependencyType:"stateVariable",variableName:"numProblems"},variantSeed:{dependencyType:"value",value:AA.variantSeed},rngClass:{dependencyType:"value",value:AA.rngClass,doNotProxy:!0},variants:{dependencyType:"variants"}}),definition:function({dependencyValues:AA}){let tA=AA.numProblems,nA=[],rA;const aA=AA.mode;let oA=AA.variants?.desiredVariant?.indices;if(oA!==void 0)if(oA.length!==tA)nA.push(codedDiagnostic({type:"info",code:"doenet-i0005"}));else{if(oA=oA.map(Number),!oA.every(Number.isInteger))throw Error("All indices specified for pretzel must be integers");if(!oA.every(lA=>lA>=1&&lA<=tA))nA.push(codedDiagnostic({type:"info",code:"doenet-i0007",args:{component:"pretzel"}}));else if(new Set(oA).size!==tA)nA.push(codedDiagnostic({type:"info",code:"doenet-i0008"}));else if(aA==="circuit"&&tA>0&&oA[0]!==1)nA.push(codedDiagnostic({type:"info",code:"doenet-i0009"}));else return{setValue:{problemOrder:oA}}}let sA=AA.rngClass(AA.variantSeed+"co");return rA=shuffleProblemOrder({numProblems:tA,variantRng:sA,mode:aA}),{setValue:{problemOrder:rA},sendDiagnostics:nA}}},eA.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({componentInfoObjects:AA,sharedParameters:tA})=>({variantSeed:{dependencyType:"value",value:tA.variantSeed},problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(AA.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],useReplacementsForComposites:!0,recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:AA,componentIdx:tA}){let nA={seed:AA.variantSeed,meta:{createdBy:tA},indices:AA.problemOrder},rA=nA.subvariants=[];for(let aA of AA.variantDescendants)aA.stateValues.isVariantComponent?rA.push(aA.stateValues.generatedVariantInfo):aA.stateValues.generatedVariantInfo&&rA.push(...aA.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:nA,isVariantComponent:!0}}}},eA.statements={additionalStateVariablesDefined:["givenAnswers","validProblems","distractors"],returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=[],nA=[],rA=[];let aA=!0;const oA=[];for(const[sA,lA]of AA.serializedProblemChildren.entries()){let gA=null,cA=null;for(const IA of lA.children)if(IA.componentType==="statement")gA=IA;else if(IA.componentType==="givenAnswer"){const CA=IA.children.find(uA=>uA.componentType==="_postponeRenderContainer");CA&&(cA={...CA,componentType:"span",attributes:{...CA.attributes},children:(CA.children??[]).filter(uA=>uA.componentType!=="label"&&uA.componentType!=="shortDescription")},cA.componentIdx=IA.componentIdx,IA.attributes.name&&(cA.attributes.name=IA.attributes.name))}(gA===null||cA===null)&&(aA=!1),tA.push(gA),nA.push(cA),lA.attributes.isDistractor?.primitive.value&&rA.push(sA)}return aA||oA.push(codedDiagnostic({type:"warning",code:"doenet-w0076"})),AA.mode==="circuit"&&rA.includes(0)&&oA.push(codedDiagnostic({type:"error",code:"doenet-e0001"})),{setValue:{statements:tA,givenAnswers:nA,validProblems:aA,distractors:rA},sendDiagnostics:oA}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},statements:{dependencyType:"stateVariable",variableName:"statements"},givenAnswers:{dependencyType:"stateVariable",variableName:"givenAnswers"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){tA.replacementsCreated===void 0&&(tA.replacementsCreated=0);const nA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated},rA=[];let aA=[];const oA=await eA.stateValues.numProblems,sA=await eA.stateValues.problemOrder,lA=await eA.stateValues.statements,gA=await eA.stateValues.givenAnswers,cA=await eA.stateValues.distractors,IA=await eA.stateValues.mode,CA=new Set(cA);for(let uA=0;uA<oA;uA++){const dA=sA[uA]-1,pA=lA[dA],mA=getCorrespondingAnswerIdx({problemIdx:dA,numProblems:oA,distractorSet:CA}),QA=gA[mA];QA===null?aA.push({type:"serialized",componentType:"span",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(QA),aA.push({type:"serialized",componentType:"textInput",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{width:{type:"component",name:"width",component:{type:"serialized",componentType:"componentSize",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,state:{componentSize:{size:15,isAbsolute:!0}},children:[],attributes:{},doenetAttributes:{}}}},doenetAttributes:{},state:IA==="circuit"&&uA===0?{value:"1",disabledPreliminary:!0}:{},children:[{type:"serialized",componentType:"shortDescription",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,state:{},children:[{type:"serialized",componentType:"text",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,state:{value:"Enter number in sequence for this answer or X if it is a distractor"},children:[],attributes:{},doenetAttributes:{}}],attributes:{},doenetAttributes:{}}]}),pA===null?aA.push({type:"serialized",componentType:"statement",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(pA)}return tA.replacementsCreated=nA.num,{replacements:aA,diagnostics:rA,nComponents:AA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}static determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA}){let nA=0;const rA=normalizePretzelMode(eA.attributes.mode?.primitive?.value);for(let lA of eA.children)if(lA.componentType==="problem")nA++;else if(AA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:"_composite"})&&lA.attributes.createComponentOfType?.primitive.value==="problem")if(lA.attributes.numProblems?.primitive!==void 0){let gA=Number(lA.attributes.numProblems?.primitive.value);if(Number.isInteger(gA)&&gA>=0)nA+=gA;else return{success:!1}}else nA++;else return{success:!1};let aA=determineNumberOfPermutations({numProblems:nA,mode:rA}),oA=super.determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA});if(!oA.success)return{success:!1};let sA=oA.numVariants*aA;return eA.variants.numVariants=sA,eA.variants.uniqueVariantData={numVariantsByDescendant:eA.variants.uniqueVariantData.numVariantsByDescendant,numberOfPermutations:aA,numProblems:nA,mode:rA},{success:!0,numVariants:sA}}static getUniqueVariant({serializedComponent:eA,variantIndex:AA,componentInfoObjects:tA}){let nA=eA.variants?.numVariants;if(nA===void 0)return{success:!1};if(!Number.isInteger(AA)||AA<1||AA>nA)return{success:!1};let rA=eA.variants.uniqueVariantData.numVariantsByDescendant,aA=eA.variants.descendantVariantComponents,oA=eA.variants.uniqueVariantData.numberOfPermutations,sA=eA.variants.uniqueVariantData.numProblems;const lA=normalizePretzelMode(eA.variants.uniqueVariantData.mode);let gA=[...rA];gA.push(oA);let cA=enumerateCombinations({numberOfOptionsByIndex:gA,maxNumber:AA})[AA-1].map(BA=>BA+1),IA=cA.pop(),CA=cA;const uA=getProblemIndicesToPermute({numProblems:sA,mode:lA}),dA=buildProblemOrderFromPermutedIndices({permutedIndices:enumeratePermutations({values:uA,maxNumber:IA})[IA-1],numProblems:sA,mode:lA});let pA=!1,mA=[];for(let BA=0;BA<rA.length;BA++)if(rA[BA]>1){let hA=aA[BA],EA=tA.allComponentClasses[hA.componentType].getUniqueVariant({serializedComponent:hA,variantIndex:CA[BA],componentInfoObjects:tA});if(!EA.success)return{success:!1};mA.push(EA.desiredVariant),pA=!0}else mA.push({});let QA={indices:dA};return pA&&(QA.subvariants=mA),{success:!0,desiredVariant:QA}}}class Cascade extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="cascade";static componentDocs={summary:"Reveals its children one step at a time, each once the steps before it are complete"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!1;static createAttributesObject(){let eA=super.createAttributesObject();return eA.hideFutureSections={createComponentOfType:"boolean",createStateVariable:"hideFutureSections",defaultValue:!1,public:!0,description:"Whether to hide later cascade sections until previous ones are completed."},eA.revealAll={createComponentOfType:"boolean",createStateVariable:"revealAllPreliminary",defaultValue:!1,description:"Whether all cascade entries should be revealed regardless of progress."},eA.boxAll={createComponentOfType:"boolean",createStateVariable:"boxAll",defaultValue:!1,description:"Whether to draw boxes around all cascade entries regardless of progress."},Object.assign(eA,returnSectionTitleStateColorAttributes()),eA}static returnChildGroups(){return[{group:"titles",componentTypes:["title"]},{group:"setups",componentTypes:["setup"]},{group:"cascadeMessages",componentTypes:["cascadeMessage"]},{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnCascadeStepStateVariableDefinitions()),Object.assign(eA,returnSectionTitleStateColorStateVariableDefinitions()),eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},titleChildren:{dependencyType:"child",childGroups:["titles"]},asList:{dependencyType:"stateVariable",variableName:"asList"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"}}),definition({dependencyValues:tA,componentInfoObjects:nA}){const rA=new Set(tA.titleChildren.map(sA=>sA.componentIdx)),aA=[];for(const[sA,lA]of tA.allChildren.entries()){if(typeof lA=="string"){!tA.hideChildren&&!tA.asList&&aA.push(sA);continue}rA.has(lA.componentIdx)||tA.asList&&!LIST_CONTAINER_TYPES.some(gA=>nA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:gA}))&&!["introduction","conclusion"].includes(lA.componentType)||aA.push(sA)}const oA=tA.titleChildren.map(sA=>codedDiagnostic({type:"warning",code:"doenet-w0167",position:sA.position||void 0}));return{setValue:{childIndicesToRender:aA},sendDiagnostics:oA}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this cascade's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:tA}){return{setValue:{asList:!!tA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA.childrenAggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{childrenAggregateScores:!0}})};const AA=returnScoredSectionStateVariableDefinition();return eA.aggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{aggregateScores:!0}})},eA.scoredDescendants=AA.scoredDescendants,eA.creditAchievedForProgress=AA.creditAchievedForProgress,eA.childCreditAchieved={returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["creditAchievedForProgress"],variablesOptional:!0}}),definition({dependencyValues:tA}){return{setValue:{childCreditAchieved:tA.children.map(rA=>rA.stateValues?.creditAchievedForProgress??null)}}}},eA.numCompleted={description:"The number of cascade sections currently completed.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({childCreditAchieved:{dependencyType:"stateVariable",variableName:"childCreditAchieved"}}),definition({dependencyValues:tA}){let nA=0;for(const rA of tA.childCreditAchieved)if(rA===1||rA===null)nA++;else break;return{setValue:{numCompleted:nA}}}},eA.revealAll={returnDependencies:()=>({cascadeAncestor:{dependencyType:"ancestor",componentType:"cascade",variableNames:["revealAll"]},revealAllPreliminary:{dependencyType:"stateVariable",variableName:"revealAllPreliminary"}}),definition({dependencyValues:tA,usedDefault:nA}){let rA=!1;return nA.revealAllPreliminary?tA.cascadeAncestor&&(rA=tA.cascadeAncestor.stateValues.revealAll):rA=tA.revealAllPreliminary,{setValue:{revealAll:rA}}}},eA.childrenToHide={additionalStateVariablesDefined:["childrenToHideChildren","sectionToShowCascadeMessage"],returnDependencies:()=>({hideFutureSections:{dependencyType:"stateVariable",variableName:"hideFutureSections"},numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"],variableNames:["hasCascadeMessageToShow"],variablesOptional:!0},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"},showCascadeMessage:{dependencyType:"stateVariable",variableName:"showCascadeMessage"}}),definition({dependencyValues:tA,componentInfoObjects:nA}){const rA=tA.childrenWithCascadeMessages.filter(cA=>cA.componentType==="cascadeMessage").map(cA=>cA.componentIdx);if(tA.revealAll)return{setValue:{childrenToHide:rA,childrenToHideChildren:[],sectionToShowCascadeMessage:null}};const aA=[],oA=[];for(const[cA,IA]of tA.children.entries())cA<=tA.numCompleted?tA.hideChildren&&aA.push(IA.componentIdx):!tA.hideChildren&&!tA.hideFutureSections&&["_sectioningComponent","cascade"].some(CA=>nA.isInheritedComponentType({inheritedComponentType:IA.componentType,baseComponentType:CA}))?oA.push(IA.componentIdx):aA.push(IA.componentIdx);const sA=tA.children[tA.numCompleted+1],lA=sA&&oA.includes(sA.componentIdx)&&sA.stateValues?.hasCascadeMessageToShow?sA.componentIdx:null,gA=lA===null&&(!tA.hideChildren||tA.showCascadeMessage)?nextOwnCascadeMessage(tA):null;return aA.push(...rA.filter(cA=>cA!==gA)),{setValue:{childrenToHide:aA,childrenToHideChildren:oA,sectionToShowCascadeMessage:lA}}}},eA.hasCascadeMessageToShow={returnDependencies:()=>({numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"]},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"}}),definition({dependencyValues:tA}){return{setValue:{hasCascadeMessageToShow:nextOwnCascadeMessage(tA)!==null}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}function nextOwnCascadeMessage(iA){if(iA.revealAll||iA.numCompleted>iA.children.length-2)return null;const eA=iA.children[iA.numCompleted].componentIdx,AA=iA.childrenWithCascadeMessages.findIndex(tA=>tA.componentIdx===eA);return iA.childrenWithCascadeMessages.slice(AA+1).find(tA=>tA.componentType==="cascadeMessage")?.componentIdx??null}class Page extends BlockComponent{static componentType="page";static componentDocs={summary:"The content of one printed page"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},asList:{dependencyType:"stateVariable",variableName:"asList"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){const nA=[];for(const[rA,aA]of AA.allChildren.entries())(!AA.asList||typeof aA!="string"&&(LIST_CONTAINER_TYPES.some(oA=>tA.isInheritedComponentType({inheritedComponentType:aA.componentType,baseComponentType:oA}))||["introduction","conclusion"].includes(aA.componentType)))&&nA.push(rA);return{setValue:{childIndicesToRender:nA}}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this page's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:AA}){return{setValue:{asList:!!AA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA}}class DynamicChildren extends CompositeComponent{constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentType="_dynamicChildren";static componentDocs={summary:"Internal container for dynamically-generated children."};static treatAsComponentForRecursiveReplacements=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.deferUntilParentRendered={createComponentOfType:"boolean",createStateVariable:"deferUntilParentRendered",defaultValue:!1,description:"Whether to wait until the parent is rendered before creating dynamic children."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.dynamicChildren={hasEssential:!0,defaultValue:[],returnDependencies:()=>({}),definition:function(){return{useEssentialOrDefaultValue:{dynamicChildren:!0}}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"dynamicChildren",value:AA.dynamicChildren}]}}},eA.createReplacements={stateVariablesDeterminingDependencies:["deferUntilParentRendered"],returnDependencies:({stateValues:AA})=>{const tA={deferUntilParentRendered:{dependencyType:"stateVariable",variableName:"deferUntilParentRendered"}};return AA.deferUntilParentRendered&&(tA.parentRendered={dependencyType:"parentStateVariable",variableName:"rendered"}),tA},definition({dependencyValues:AA}){return{setValue:{createReplacements:!AA.deferUntilParentRendered||AA.parentRendered!==!1}}},markStale(){return{updateReplacements:!0}}},eA.nGroups={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"}}),definition({dependencyValues:AA}){return{setValue:{nGroups:AA.dynamicChildren.length}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"},createReplacements:{dependencyType:"stateVariable",variableName:"createReplacements"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}},markStale(){return{updateReplacements:!0}}},eA}async addChildren({serializedComponents:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){if(eA&&eA.length>0){const rA=[...await this.stateValues.dynamicChildren];return rA.push({type:"serialized",componentType:"group",componentIdx:0,attributes:{},doenetAttributes:{},state:{},children:deepClone(eA)}),await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:rA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:nA})}else return}async deleteChildren({number:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){const rA=await this.stateValues.nGroups;let aA=Math.min(eA,rA);if(aA>0){const oA=(await this.stateValues.dynamicChildren).slice(0,rA-aA);return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:oA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:nA})}else return}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){let nA=[];tA.replacementsCreated===void 0&&(tA.replacementsCreated=0),tA.replacementsCreatedThroughGroup=[];let rA=[];if(!await eA.stateValues.createReplacements)return tA.nGroups=0,{replacements:rA,diagnostics:nA,nComponents:AA};const aA=await eA.stateValues.nGroups;for(let oA=0;oA<aA;oA++){let sA=await this.replacementForGroup({component:eA,groupNum:oA,nComponents:AA,workspace:tA}),lA=sA.replacements;AA=sA.nComponents,rA.push(...lA)}return tA.nGroups=aA,{replacements:rA,diagnostics:nA,nComponents:AA}}static async replacementForGroup({component:eA,groupNum:AA,nComponents:tA,workspace:nA}){let rA=[deepClone((await eA.stateValues.dynamicChildren)[AA])];const aA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated},oA=createNewComponentIndices(rA,tA,aA);return rA=oA.components,tA=oA.nComponents,nA.replacementsCreated=aA.num,nA.replacementsCreatedThroughGroup=[...nA.replacementsCreatedThroughGroup,nA.replacementsCreated],{replacements:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,nComponents:AA,workspace:tA}){const rA=await eA.stateValues.createReplacements?await eA.stateValues.nGroups:0;if(rA===tA.nGroups)return{replacementChanges:[],nComponents:AA};if(rA<tA.nGroups){const sA=[{changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:rA,numberReplacementsToDelete:tA.nGroups-rA}];return tA.nGroups=rA,tA.replacementsCreated=tA.replacementsCreatedThroughGroup[rA-1]||0,tA.replacementsCreatedThroughGroup=tA.replacementsCreatedThroughGroup.slice(0,rA),{replacementChanges:sA,nComponents:AA}}let aA=[];for(let sA=tA.nGroups;sA<rA;sA++){let lA=await this.replacementForGroup({component:eA,groupNum:sA,nComponents:AA,workspace:tA}),gA=lA.replacements;AA=lA.nComponents,aA.push(...gA)}let oA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA.nGroups,numberReplacementsToReplace:0,serializedReplacements:aA,replacementsToWithhold:0};return tA.nGroups=rA,{replacementChanges:[oA],nComponents:AA}}}class ShortDescription extends TextOrInline{static componentType="shortDescription";static componentDocs={summary:"A short accessibility description (e.g. for a `<graph>`) read by screen readers"};static rendererType=void 0;static inSchemaOnlyInheritAs=[];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.inlineChildren={returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:({dependencyValues:AA})=>({setValue:{inlineChildren:AA.inlineChildren}})},eA.value={description:"The short description text.",public:!0,shadowingInstructions:{createComponentOfType:this.componentType},stateVariablesDeterminingDependencies:["inlineChildren"],returnDependencies:({stateValues:AA})=>{const tA={inlineChildren:{dependencyType:"stateVariable",variableName:"inlineChildren"}};for(const[nA,rA]of AA.inlineChildren.entries())typeof rA=="object"&&(tA[`adapterSource${nA}`]={dependencyType:"adapterSource",componentIdx:rA.componentIdx});return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){const nA=textFromChildren(AA.inlineChildren);let rA;for(let oA=0;oA<AA.inlineChildren.length;oA++){const sA=AA.inlineChildren[oA];if(typeof sA!="object")continue;const lA=AA[`adapterSource${oA}`]?.componentType??sA.componentType;if(tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"math"})||tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"m"})){rA=lA;break}}const aA=[];return rA&&aA.push(codedDiagnostic({type:"accessibility",level:2,code:"doenet-a0005",args:{component:rA}})),{setValue:{value:nA},sendDiagnostics:aA}}},eA}}const unitConversions={"":1,px:1,pixel:1,pixels:1,"%":1,em:100,in:96,inch:96,inches:96,pt:1.333333333333,mm:3.7795296,millimeter:3.7795296,millimeters:3.7795296,cm:37.795296,centimeter:37.795296,centimeters:37.795296};class ComponentSize extends InlineComponent{static componentType="componentSize";static rendererType="text";static excludeFromSchema=!0;static primaryStateVariableForDefinition="componentSize";static stateVariableToBeShadowed="componentSize";static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){let aA=tA[tA.length-1];if(typeof aA=="string"){let oA=/([a-zA-z]+|%)$/,sA=aA.trim(),lA=sA.match(oA);if(lA){let gA=lA[1];if(gA in unitConversions){let cA=sA.slice(0,lA.index),IA=tA.slice(0,tA.length-1);return cA.length>0&&IA.push(cA),{success:!0,newChildren:[{type:"serialized",componentType:"number",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:IA,attributes:{},doenetAttributes:{},state:{}},gA],nComponents:nA}}}}return{success:!0,newChildren:[{componentType:"number",children:tA}]}};return eA.push({childrenRegex:/..+/,replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"strings",componentTypes:["string"]},{group:"numbers",componentTypes:["number"]},{group:"componentSizes",componentTypes:["componentSize"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA);let tA=returnTextStyleDescriptionDefinitions();return Object.assign(eA,tA),eA.componentSize={description:"The size value with its associated unit (absolute pixels or relative percent).",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},hasEssential:!0,returnDependencies:()=>({componentSizeChild:{dependencyType:"child",childGroups:["componentSizes"],variableNames:["componentSize"]},numberChild:{dependencyType:"child",childGroups:["numbers"],variableNames:["value"]},stringChild:{dependencyType:"child",childGroups:["strings"],variableNames:["value"]},parentDefaultAbsoluteSize:{dependencyType:"parentStateVariable",variableName:"defaultAbsoluteSize"}}),definition({dependencyValues:nA}){let rA=nA.parentDefaultAbsoluteSize===void 0?!1:nA.parentDefaultAbsoluteSize;if(nA.stringChild.length===0)return nA.numberChild.length===0?nA.componentSizeChild.length===0?{useEssentialOrDefaultValue:{componentSize:{defaultValue:{size:100,isAbsolute:rA}}}}:{setValue:{componentSize:nA.componentSizeChild[0].stateValues.componentSize}}:{setValue:{componentSize:{size:nA.numberChild[0].stateValues.value,isAbsolute:!0}}};{let aA,oA;if(nA.numberChild.length>0)aA=nA.numberChild[0].stateValues.value,oA=nA.stringChild[0].trim();else{let cA=nA.stringChild[0].trim().match(/^(-?[\d.]+)\s*(.*)$/);if(cA===null)return{setValue:{componentSize:null}};aA=cA[1],oA=cA[2].trim()}if(aA=Number(aA),!Number.isFinite(aA))return{setValue:{componentSize:null}};let sA=!(oA==="%"||oA==="em"),lA=unitConversions[oA];return lA===void 0&&(lA=1),{setValue:{componentSize:{size:lA*aA,isAbsolute:sA}}}}},inverseDefinition({desiredStateVariableValues:nA,dependencyValues:rA}){if(rA.stringChild.length===0)return rA.numberChild.length===0?rA.componentSizeChild.length===0?{success:!0,instructions:[{setEssentialValue:"componentSize",value:nA.componentSize}]}:{success:!0,instructions:[{setDependency:"componentSizeChild",desiredValue:nA.componentSize,childIndex:0,variableIndex:0}]}:nA.componentSize.isAbsolute?{success:!0,instructions:[{setDependency:"numberChild",desiredValue:nA.componentSize.size,childIndex:0,variableIndex:0}]}:{success:!1};if(rA.numberChild.length>0){let aA=rA.stringChild[0].trim(),oA=!(aA==="%"||aA==="em");if(nA.componentSize.isAbsolute!==oA)return{success:!1};let sA=unitConversions[aA];return sA===void 0&&(sA=1),{success:!0,instructions:[{setDependency:"numberChild",desiredValue:nA.componentSize.size/sA,childIndex:0,variableIndex:0}]}}else{let aA=nA.componentSize.size;return nA.componentSize.isAbsolute?aA+="px":aA+="%",{success:!0,instructions:[{setDependency:"stringChild",desiredValue:aA,childIndex:0,variableIndex:0}]}}}},eA.number={description:"The numeric portion of the size.",public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:nA}){let rA=null;return nA.componentSize&&(rA=nA.componentSize.size),{setValue:{number:rA}}},inverseDefinition({desiredStateVariableValues:nA,dependencyValues:rA}){return rA.componentSize?{success:!0,instructions:[{setDependency:"componentSize",desiredValue:{size:nA.number,isAbsolute:rA.componentSize.isAbsolute}}]}:{success:!1}}},eA.math=mathStateVariableFromNumberStateVariable({numberVariableName:"number",mathVariableName:"math",isPublic:!0}),eA.math.description="The size as a math expression.",eA.isAbsolute={description:"Whether the size uses absolute units (pixels) rather than relative units (percent).",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:nA}){let rA=null;return nA.componentSize&&(rA=nA.componentSize.isAbsolute),{setValue:{isAbsolute:rA}}}},eA.text={forRenderer:!0,returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:nA}){let rA="";return nA.componentSize&&(rA=nA.componentSize.size,nA.componentSize.isAbsolute?rA+="px":rA+="%"),{setValue:{text:rA}}}},eA}static adapters=["number","math"]}class ComponentSizeList extends BaseComponent{static componentType="_componentSizeList";static rendererType="asList";static renderChildren=!0;static stateVariableToBeShadowed="componentSizes";static additionalSchemaChildren=["string","number"];static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){let aA=[],oA=[],sA=function(){oA.length>0&&(aA.push({type:"serialized",componentType:"componentSize",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}}),oA=[])};for(let lA of tA)if(typeof lA=="string"){let gA=lA.split(/\s+/);gA[0].length===0&&(sA(),gA=gA.slice(1));for(let[cA,IA]of gA.entries())IA.length>0?(oA.push(IA),cA<gA.length-1&&sA()):sA()}else oA.push(lA);return sA(),{success:!0,newChildren:aA,nComponents:nA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"componentSizes",componentTypes:["componentSize"]},{group:"componentSizeLists",componentTypes:["_componentSizeList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.overrideChildHide={returnDependencies:()=>({}),definition:()=>({setValue:{overrideChildHide:!0}})},eA.numComponents={description:"The number of size values in the list.",public:!0,shadowingInstructions:{createComponentOfType:"number"},additionalStateVariablesDefined:["childIndexByArrayKey"],returnDependencies(){return{componentSizeListChildren:{dependencyType:"child",childGroups:["componentSizeLists"],variableNames:["numComponents"]},componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],skipComponentIndices:!0}}},definition:function({dependencyValues:AA,componentInfoObjects:tA}){let nA=0,rA=[],aA=0;for(let[oA,sA]of AA.componentSizeAndComponentSizeListChildren.entries())if(tA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.componentSizeListChildren[aA];aA++;for(let gA=0;gA<lA.stateValues.numComponents;gA++)rA[nA+gA]=[oA,gA];nA+=lA.stateValues.numComponents}else rA[nA]=[oA,0],nA+=1;return{setValue:{numComponents:nA,childIndexByArrayKey:rA},checkForActualChange:{numComponents:!0}}}},eA.componentSizes={description:"The list of component sizes.",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},isArray:!0,entryPrefixes:["componentSize"],stateVariablesDeterminingDependencies:["childIndexByArrayKey"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA,stateValues:tA}){let nA={},rA={childIndexByArrayKey:{dependencyType:"stateVariable",variableName:"childIndexByArrayKey"}};for(let aA of AA){let oA=[],sA="1";tA.childIndexByArrayKey[aA]&&(oA=[tA.childIndexByArrayKey[aA][0]],sA=tA.childIndexByArrayKey[aA][1]+1),nA[aA]={componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],variableNames:["componentSize","componentSize"+sA],variablesOptional:!0,childIndices:oA}}}return{globalDependencies:rA,dependenciesByKey:nA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:nA,componentInfoObjects:rA}){let aA={};for(let oA of nA){let sA=tA[oA].componentSizeAndComponentSizeListChildren[0];if(sA)if(rA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.childIndexByArrayKey[oA][1]+1;aA[oA]=sA.stateValues["componentSize"+lA]}else aA[oA]=sA.stateValues.componentSize}return{setValue:{componentSizes:aA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:nA,dependencyNamesByKey:rA,arraySize:aA,componentInfoObjects:oA}){let sA=[];for(let lA in AA.componentSizes){if(!nA[lA])continue;let gA=nA[lA].componentSizeAndComponentSizeListChildren[0];gA&&(oA.isInheritedComponentType({inheritedComponentType:gA.componentType,baseComponentType:"_componentSizeList"})?sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:1}):sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:0}))}return{success:!0,instructions:sA}}},eA.numValues={isAlias:!0,targetVariableName:"numComponents",description:"The number of component sizes in the list."},eA.values={isAlias:!0,targetVariableName:"componentSizes",description:"The list's component sizes."},eA}}const ComponentSize$1=Object.freeze(Object.defineProperty({__proto__:null,ComponentSize,ComponentSizeList},Symbol.toStringTag,{value:"Module"}));class Copy extends CompositeComponent{static componentType="_copy";static excludeFromSchema=!0;static acceptAnyAttribute=!0;static includeBlankStringChildren=!0;static stateVariableToEvaluateAfterReplacements="needsReplacementsUpdatedWhenStale";static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.disabled,delete eA.modifyIndirectly,delete eA.fixed,delete eA.styleNumber,delete eA.isResponse,delete eA.isPotentialResponse,delete eA.hide,eA.createComponentOfType={createPrimitiveOfType:"string"},eA.createComponentIdx={createPrimitiveOfType:"integer"},eA.createComponentName={createPrimitiveOfType:"string"},eA.numComponents={createPrimitiveOfType:"number"},eA.copyInChildren={createPrimitiveOfType:"boolean"},eA.uri={createPrimitiveOfType:"string",createStateVariable:"uri",defaultValue:null,public:!0},eA.link={createPrimitiveOfType:"boolean",createStateVariable:"link",defaultValue:!0},eA.removeEmptyArrayEntries={createPrimitiveOfType:"boolean",createStateVariable:"removeEmptyArrayEntries",defaultValue:!1},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asListPreliminary",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.refResolutionIndexDependencies={returnDependencies:()=>({refResolutionIndexDependencies:{dependencyType:"refResolutionIndexDependencies"}}),definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencies:AA.refResolutionIndexDependencies}})},eA.refResolutionIndexDependencyValues={stateVariablesDeterminingDependencies:["refResolutionIndexDependencies"],returnDependencies:({stateValues:AA})=>{const tA={};for(const nA of AA.refResolutionIndexDependencies)tA[nA]={dependencyType:"stateVariable",componentIdx:nA,variableName:"value"};return tA},definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencyValues:AA}})},eA.extendIdx={additionalStateVariablesDefined:["unresolvedPath","originalPath"],stateVariablesDeterminingDependencies:["refResolutionIndexDependencyValues"],returnDependencies:({stateValues:AA})=>({refResolution:{dependencyType:"refResolution",indexDependencyValues:AA.refResolutionIndexDependencyValues}}),definition:({dependencyValues:AA})=>({setValue:{extendIdx:AA.refResolution.extendIdx,unresolvedPath:AA.refResolution.unresolvedPath,originalPath:AA.refResolution.originalPath}})},eA.extendedComponent={shadowVariable:!0,stateVariablesDeterminingDependencies:["extendIdx"],returnDependencies({stateValues:AA}){return AA.extendIdx!==-1?{extendedComponent:{dependencyType:"componentIdentity",componentIdx:AA.extendIdx}}:{}},definition:function({dependencyValues:AA}){let tA=null;return AA.extendedComponent&&(tA=AA.extendedComponent),{setValue:{extendedComponent:tA}}}},eA.targetInactive={stateVariablesDeterminingDependencies:["extendedComponent"],returnDependencies({stateValues:AA}){return AA.extendedComponent?{targetIsInactiveCompositeReplacement:{dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"isInactiveCompositeReplacement"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{targetInactive:!!AA.targetIsInactiveCompositeReplacement}}}},eA.cid={additionalStateVariablesDefined:["doenetId"],returnDependencies:()=>({uri:{dependencyType:"stateVariable",variableName:"uri"}}),definition:function({dependencyValues:AA}){if(!AA.uri||AA.uri.substring(0,7).toLowerCase()!=="doenet:")return{setValue:{cid:null,doenetId:null}};let tA=null,nA=null,rA=AA.uri.match(/[:&]cid=([^&]+)/i);return rA&&(tA=rA[1]),rA=AA.uri.match(/[:&]doenetid=([^&]+)/i),rA&&(nA=rA[1]),{setValue:{cid:tA,doenetId:nA}}}},eA.createComponentOfType={returnDependencies:()=>({typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA}){let tA=null;return AA.typeAttr&&(tA=AA.typeAttr),{setValue:{createComponentOfType:tA}}}},eA.replacementSourceIdentities={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","createComponentOfType"],additionalStateVariablesDefined:["usedReplacements"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){let nA={numComponentsSpecified:{dependencyType:"stateVariable",variableName:"numComponentsSpecified"}},rA=!1;if(AA.extendedComponent!==null){if(AA.extendedComponent.componentType==="_copy"||tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!0})&&AA.extendedComponent.componentType!==AA.createComponentOfType){rA=!0;let aA=AA.unresolvedPath?.[0]?.name;aA===""&&(aA=null),nA.targets={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:AA.unresolvedPath!=null,stopAtListComposites:AA.unresolvedPath==null,includeWithheldReplacements:!0,stopIfHaveProp:aA}}rA||(nA.targets={dependencyType:"stateVariable",variableName:"extendedComponent"}),nA.usedReplacements={dependencyType:"value",value:rA}}return nA},definition({dependencyValues:AA}){let tA=null;if(AA.targets&&(tA=AA.targets,Array.isArray(tA)||(tA=[tA]),AA.numComponentsSpecified===1&&tA.length>1)){const nA=tA.findIndex(aA=>typeof aA!="string"||aA.trim()!==""),rA=tA.findLastIndex(aA=>typeof aA!="string"||aA.trim()!=="");nA!==-1&&rA!==-1&&(tA=tA.slice(nA,rA+1))}return{setValue:{replacementSourceIdentities:tA,usedReplacements:!!AA.usedReplacements}}}},eA.asList={stateVariablesDeterminingDependencies:["usedReplacements","extendedComponent"],returnDependencies({stateValues:AA}){const tA={asListPreliminary:{dependencyType:"stateVariable",variableName:"asListPreliminary"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.usedReplacements&&(tA.extendedComponentAsList={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"asList",variablesOptional:!0}),tA},definition({dependencyValues:AA,usedDefault:tA}){return tA.asListPreliminary&&AA.usedReplacements&&typeof AA.extendedComponentAsList=="boolean"?{setValue:{asList:AA.extendedComponentAsList}}:{setValue:{asList:AA.asListPreliminary}}}},eA.implicitProp={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath"],returnDependencies({stateValues:AA}){let tA={unresolvedPath:{dependencyType:"stateVariable",variableName:"unresolvedPath"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.unresolvedPath||(tA.replacementSourceIdentities={dependencyType:"stateVariable",variableName:"replacementSourceIdentities"},tA.typeAttr={dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}),tA},definition({dependencyValues:AA,componentInfoObjects:tA}){if(AA.unresolvedPath||AA.usedReplacements||!(AA.replacementSourceIdentities?.length>0))return{setValue:{implicitProp:null}};let nA=AA.replacementSourceIdentities[0],rA=tA.allComponentClasses[nA.componentType]?.variableForImplicitProp;if(!rA)return{setValue:{implicitProp:null}};if(AA.typeAttr){let aA=tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()];if(aA===nA.componentType)return{setValue:{implicitProp:null}};let oA=tA.publicStateVariableInfo[nA.componentType].stateVariableDescriptions[rA];if(oA.createComponentOfType!==void 0&&oA.createComponentOfType!==aA)return{setValue:{implicitProp:null}}}return{setValue:{implicitProp:rA}}}},eA.replacementSources={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath","implicitProp"],additionalStateVariablesDefined:["effectivePropNameBySource"],returnDependencies:function({stateValues:AA}){let tA={replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};if(AA.replacementSourceIdentities!==null)for(let[nA,rA]of AA.replacementSourceIdentities.entries()){let aA=AA.unresolvedPath;AA.implicitProp&&(aA=[{name:AA.implicitProp,index:[]}]);let oA;if(aA){if(aA=[...aA],tA["unresolvedPath"+nA]={dependencyType:"value",value:aA},typeof rA=="string")continue;oA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:rA.componentIdx,unresolvedPath:aA,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else{if(typeof rA=="string")continue;oA={dependencyType:"componentIdentity",componentIdx:rA.componentIdx}}tA["target"+nA]=oA}return tA},definition({dependencyValues:AA}){let tA=null,nA=null;if(AA.replacementSourceIdentities!==null){tA=[],nA=[];for(let rA in AA.replacementSourceIdentities){let aA=AA["target"+rA];if(aA){tA.push(aA);let oA;aA.stateValues&&(oA=Object.keys(aA.stateValues)[0]),!oA&&AA["unresolvedPath"+rA]&&(oA="__prop_name_not_found"),nA.push(oA)}else{const oA=AA.replacementSourceIdentities[rA];typeof oA=="string"?AA["unresolvedPath"+rA]?nA.push("__prop_name_not_found"):(tA.push(oA),nA.push(void 0)):(tA.push(void 0),nA.push("__no_target_found"))}}}return{setValue:{replacementSources:tA,effectivePropNameBySource:nA}}}},eA.numComponentsSpecified={returnDependencies:()=>({numComponentsAttr:{dependencyType:"attributePrimitive",attributeName:"numComponents"},typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){let nA;if(AA.typeAttr){if(!(tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()]in tA.allComponentClasses))return{setValue:{numComponentsSpecified:null},sendDiagnostics:[codedDiagnostic({type:"warning",code:"doenet-w0065",args:{type:AA.typeAttr}})]};AA.numComponentsAttr!==null?nA=AA.numComponentsAttr:nA=1}else{if(AA.numComponentsAttr!==null)throw Error("You must specify createComponentOfType when specifying numComponents for a copy.");nA=null}return{setValue:{numComponentsSpecified:nA}}}},eA.unlinkedDescendants={stateVariablesDeterminingDependencies:["extendIdx","link"],returnDependencies({stateValues:AA}){let tA={};return AA.link?tA.targetItself={dependencyType:"componentIdentity",componentIdx:AA.extendIdx}:tA.targetDescendants={dependencyType:"descendant",ancestorIdx:AA.extendIdx,componentTypes:["_composite"]},tA},definition(){return{setValue:{unlinkedDescendants:!0}}}},eA.unlinkedTargetsExpanded={stateVariablesDeterminingDependencies:["extendedComponent","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let nA={};return!AA.link&&AA.extendedComponent&&tA.isInheritedComponentType({inheritedComponentType:AA.extendedComponent.componentType,baseComponentType:"_composite"})&&(nA.targetReplacements={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:!0}),nA},definition(){return{setValue:{unlinkedTargetsExpanded:!0}}}},eA.readyToExpandWhenResolved={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let nA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},needsReplacementsUpdatedWhenStale:{dependencyType:"stateVariable",variableName:"needsReplacementsUpdatedWhenStale"},link:{dependencyType:"stateVariable",variableName:"link"},unlinkedTargetsExpanded:{dependencyType:"stateVariable",variableName:"unlinkedTargetsExpanded"},unlinkedDescendants:{dependencyType:"stateVariable",variableName:"unlinkedDescendants"}};return AA.extendedComponent&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(nA.targetReadyToExpandWhenResolved={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"readyToExpandWhenResolved"}),AA.extendedComponent&&AA.unresolvedPath===null&&(nA.extendedVariantInfo={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"generatedVariantInfo",variablesOptional:!0}),AA.link||(nA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),nA},definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.needsReplacementsUpdatedWhenStale={stateVariablesDeterminingDependencies:["extendedComponent","replacementSourceIdentities","effectivePropNameBySource","unresolvedPath","link","removeEmptyArrayEntries"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){if(!AA.link)return{};let nA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},targetInactive:{dependencyType:"stateVariable",variableName:"targetInactive"},replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};if(AA.effectivePropNameBySource!==null){for(let[rA,aA]of AA.effectivePropNameBySource.entries())if(aA){let oA=AA.replacementSourceIdentities[rA];nA["sourceArraySize"+rA]={dependencyType:"stateVariableArraySize",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0},nA["sourceComponentType"+rA]={dependencyType:"stateVariableComponentType",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0}}}return AA.extendedComponent!==null&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(nA.allReplacementIdentities={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,variableNames:["isInactiveCompositeReplacement"]}),AA.removeEmptyArrayEntries&&(nA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),nA},markStale(){return{updateReplacements:!0}},definition:()=>({setValue:{needsReplacementsUpdatedWhenStale:!0}})},eA}static async createSerializedReplacements({component:eA,components:AA,nComponents:tA,workspace:nA,allDoenetMLs:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){nA.replacementsCreated===void 0&&(nA.replacementsCreated=0);let lA=[];await eA.stateValues.numComponentsSpecified,nA.numReplacementsBySource=[],nA.numNonStringReplacementsBySource=[],nA.propVariablesCopiedBySource=[],nA.sourceIndices=[];let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let DA=[];const EA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated};if(eA.attributes.copyInChildren?.primitive.value){let NA=aA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],yA=aA.allComponentClasses[NA];const bA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:NA,componentInfoObjects:aA,compositeAttributesObj:gA,nComponents:tA,stateIdInfo:EA}),wA=bA.attributes;tA=bA.nComponents;let MA=deepClone(eA.serializedChildren);yA.includeBlankStringChildren||(MA=MA.filter(OA=>typeof OA!="string"||OA.trim()!==""));let vA=wA;DA=[{type:"serialized",componentType:NA,componentIdx:tA++,stateId:`${EA.prefix}${EA.num++}`,attributes:vA,doenetAttributes:{},state:{},children:MA}],nA.numReplacementsBySource.push(DA.length),nA.numNonStringReplacementsBySource.push(DA.filter(OA=>typeof OA!="string").length)}let fA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:DA,workspace:nA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:EA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...fA.diagnostics),tA=fA.nComponents,addAttributesToSingleReplacement(fA.replacements,eA),nA.replacementsCreated=EA.num,{replacements:fA.replacements,diagnostics:lA,nComponents:tA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let CA=await eA.stateValues.effectivePropNameBySource;for(let DA in cA)if(CA[DA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+DA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${DA} of replacementSources of ${eA.componentIdx}`);let uA=[];const dA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated};let pA=[],mA=[],QA=0,BA=0;for(let DA in cA){let EA;if(eA.attributes.createComponentOfType?.primitive){let yA=await eA.stateValues.numComponentsSpecified,bA=cA.length;EA=Math.floor(yA/bA);let wA=yA%bA;DA<wA&&EA++}let fA=await this.createReplacementForSource({component:eA,sourceNum:DA,components:AA,nComponents:tA,stateIdInfo:dA,allDoenetMLs:rA,numReplacementsSoFar:QA,numNonStringReplacementsSoFar:BA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:EA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(DA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...fA.diagnostics),tA=fA.nComponents,nA.propVariablesCopiedBySource[DA]=fA.propVariablesCopiedByReplacement;let NA=fA.serializedReplacements;pA[DA]=NA.length,mA[DA]=NA.filter(yA=>typeof yA!="string").length,QA+=pA[DA],BA+=mA[DA],uA.push(...NA)}nA.numReplacementsBySource=pA,nA.numNonStringReplacementsBySource=mA,nA.sourceIndices=cA.map(DA=>DA.componentIdx);let hA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:uA,workspace:nA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...hA.diagnostics),tA=hA.nComponents,uA=hA.replacements,addAttributesToSingleReplacement(uA,eA),nA.replacementsCreated=dA.num,{replacements:uA,diagnostics:lA,nComponents:tA}}static async createReplacementForSource({component:eA,sourceNum:AA,components:tA,nComponents:nA,stateIdInfo:rA,allDoenetMLs:aA,numReplacementsSoFar:oA,numNonStringReplacementsSoFar:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:CA}){let uA=[],dA=(await eA.stateValues.replacementSourceIdentities)[AA];if(typeof dA!="object")return eA.stateValues.effectivePropNameBySource[AA]?{serializedReplacements:[],diagnostics:uA,nComponents:nA}:{serializedReplacements:[dA],diagnostics:uA,nComponents:nA};const pA=tA[dA.componentIdx];if(await pA.stateValues.isInactiveCompositeReplacement)return{serializedReplacements:[],diagnostics:uA,nComponents:nA};let mA=(await eA.stateValues.effectivePropNameBySource)[AA],QA=await eA.stateValues.link;if(!QA||mA&&await eA.stateValues.removeEmptyArrayEntries){const hA=(await eA.stateValues.replacementSources)[AA];hA&&(dA=hA)}if(mA){let hA=await replacementFromProp({component:eA,components:tA,nComponents:nA,stateIdInfo:rA,replacementSource:dA,propName:mA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});uA.push(...hA.diagnostics),nA=hA.nComponents;let DA=hA.serializedReplacements,EA=hA.propVariablesCopiedByReplacement;if(CA&&eA.serializedChildren.length>0)if(DA.length===0){let fA=gA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],NA=gA.allComponentClasses[fA];const yA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:fA,componentInfoObjects:gA,compositeAttributesObj:lA,nComponents:nA,stateIdInfo:rA}),bA=yA.attributes;nA=yA.nComponents;let wA=deepClone(eA.serializedChildren);NA.includeBlankStringChildren||(wA=wA.filter(vA=>typeof vA!="string"||vA.trim()!==""));let MA=bA;DA=[{type:"serialized",componentType:fA,componentIdx:nA++,stateId:`${rA.prefix}${rA.num++}`,attributes:MA,doenetAttributes:{},state:{},children:wA}],EA=[[]]}else DA.length===1&&addChildrenFromComposite({replacements:DA,children:eA.serializedChildren,componentInfoObjects:gA});return{serializedReplacements:DA,propVariablesCopiedByReplacement:EA,diagnostics:uA,nComponents:nA}}let BA;try{BA=[await pA.serialize({copyAll:!QA,componentSourceAttributesToIgnore:["labelIsName"],copyVariants:!QA,copyPrimaryEssentialIfShadow:!QA,copyEssentialStateIfShadow:!QA,errorIfEncounterComponent:[eA.componentIdx]})];let hA=createNewComponentIndices(BA,nA,rA);BA=hA.components,nA=hA.nComponents}catch(hA){if(hA.message?.startsWith(SERIALIZE_ENCOUNTERED_COMPONENT_PREFIX)){const EA=getSelfReferentialFallbackPropName({componentAncestors:eA.ancestors,componentInfoObjects:gA,replacementSourceComponentType:pA.componentType});if(EA)try{let fA=await replacementFromProp({component:eA,components:tA,nComponents:nA,stateIdInfo:rA,replacementSource:pA,propName:EA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});return uA.push(...fA.diagnostics),nA=fA.nComponents,{serializedReplacements:fA.serializedReplacements,propVariablesCopiedByReplacement:fA.propVariablesCopiedByReplacement,diagnostics:uA,nComponents:nA}}catch{}}console.error("we're calling this circular",hA);const DA=codedDiagnostic({type:"error",code:"doenet-e0005",args:{componentType:eA.attributes.createComponentOfType?.primitive?.value??"none"}});return BA=[{type:"serialized",componentType:"_error",componentIdx:nA++,stateId:`${rA.prefix}${rA.num++}`,state:errorComponentState(DA.message,DA),attributes:{},doenetAttributes:{},children:[]}],uA.push(DA),{serializedReplacements:BA,diagnostics:uA,nComponents:nA}}!QA&&BA[0].state&&(delete BA[0].state.fixed,delete BA[0].state.fixedPreliminary,delete BA[0].attributes.fixed),BA=postProcessCopy({serializedComponents:BA,componentIdx:eA.componentIdx,addShadowDependencies:QA,unlinkExternalCopies:!1});for(let hA of BA){if(typeof hA!="object")continue;hA.attributes||(hA.attributes={});const DA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:hA.componentType,componentInfoObjects:gA,compositeAttributesObj:lA,dontSkipAttributes:["asList"],nComponents:nA,stateIdInfo:rA}),EA=DA.attributes;nA=DA.nComponents,(EA.displayDigits||EA.displayDecimals)&&(delete hA.attributes.displayDigits,delete hA.attributes.displayDecimals),Object.assign(hA.attributes,EA)}return CA&&BA.length===1&&eA.serializedChildren.length>0&&addChildrenFromComposite({replacements:BA,children:eA.serializedChildren,componentInfoObjects:gA}),{serializedReplacements:BA,diagnostics:uA,nComponents:nA}}static async calculateReplacementChanges({component:eA,nComponents:AA,componentChanges:tA,components:nA,workspace:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){let lA=[];if(await eA.stateValues.link===!1)return{replacementChanges:[],diagnostics:lA,nComponents:AA};let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacements.length>0){let vA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToDelete:eA.replacements.length};yA.push(vA)}let wA=rA.sourceIndices.length===0;rA.sourceIndices=[],rA.numReplacementsBySource=[],rA.numNonStringReplacementsBySource=[],rA.propVariablesCopiedBySource=[];let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:nA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...MA.diagnostics),AA=MA.nComponents,wA?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,MA.replacementChanges),rA.replacementsCreated=bA.num,{replacementChanges:MA.replacementChanges,diagnostics:lA,nComponents:AA})}if(await eA.stateValues.targetInactive){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};let wA=eA.replacements.length;if(wA>0){if(eA.replacementsToWithhold!==wA){let vA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:wA};yA.push(vA)}let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:nA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...MA.diagnostics),AA=MA.nComponents,yA=MA.replacementChanges}return addAttributesToSingleReplacementChange(eA,yA),rA.replacementsCreated=bA.num,{replacementChanges:yA,diagnostics:lA,nComponents:AA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let CA=await eA.stateValues.effectivePropNameBySource;for(let yA in cA)if(CA[yA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+yA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${yA} of replacementSources of ${eA.componentIdx}`);let uA=[];const dA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacementsToWithhold>0){let yA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:0};uA.push(yA)}let pA=0,mA=0,QA=[],BA=[],hA=[],DA=Math.max(cA.length,rA.numReplacementsBySource.length),EA=!1;for(let yA=0;yA<DA;yA++){let bA;if(eA.attributes.createComponentOfType?.primitive){let jA=await eA.stateValues.numComponentsSpecified,TA=cA.length;bA=Math.floor(jA/TA);let UA=jA%TA;yA<UA&&bA++}let wA=cA[yA];if(!EA&&await nA[wA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){let jA=!0;for(let TA=yA+1;TA<DA;TA++){const UA=cA[TA];if(!await nA[UA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){jA=!1;break}}if(jA){let TA=rA.numReplacementsBySource.slice(yA).reduce((UA,VA)=>UA+VA,0);if(TA>0){let UA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:TA};uA.push(UA)}for(let UA=yA;UA<DA;UA++)QA[UA]=rA.numReplacementsBySource[UA],BA[UA]=rA.numNonStringReplacementsBySource[UA],hA[UA]=rA.propVariablesCopiedBySource[UA];break}else wA=void 0}if(wA===void 0){if(rA.numReplacementsBySource[yA]>0&&!EA){let jA=rA.numReplacementsBySource.slice(yA).reduce((TA,UA)=>TA+UA,0);if(jA>0){let TA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToDelete:jA};uA.push(TA)}EA=!0,rA.numReplacementsBySource.slice(yA).forEach((TA,UA)=>rA.numReplacementsBySource[UA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((TA,UA)=>rA.numNonStringReplacementsBySource[UA]=0)}QA[yA]=0,BA[yA]=0,hA.push([]);continue}let MA=rA.sourceIndices[yA],vA=MA===void 0||wA.componentIdx!==MA||EA;if(!vA)for(let jA=0;jA<rA.numReplacementsBySource[yA];jA++){let TA=eA.replacements[pA+jA];if(TA){if(!CA[yA]&&TA.shadows?.componentIdx!==cA[yA].componentIdx){vA=!0;break}}else{vA=!0;break}}if(vA){let jA=0;yA in rA.numReplacementsBySource&&(jA=rA.numReplacementsBySource[yA]);let TA=jA;EA&&(TA=0);let UA=await this.recreateReplacements({component:eA,sourceNum:yA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,numReplacementsToDelete:TA,components:nA,nComponents:AA,stateIdInfo:dA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...UA.diagnostics),AA=UA.nComponents,pA+=UA.numReplacements,mA+=UA.numNonStringReplacements,QA[yA]=UA.numReplacements,BA[yA]=UA.numNonStringReplacements,hA[yA]=UA.propVariablesCopiedByReplacement;let VA=UA.replacementInstruction;if(!EA&&UA.numReplacements!==jA){let $A=rA.numReplacementsBySource.slice(yA).reduce((Br,KA)=>Br+KA,0);VA.numberReplacementsToReplace=$A,EA=!0,rA.numReplacementsBySource.slice(yA).forEach((Br,KA)=>rA.numReplacementsBySource[KA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((Br,KA)=>rA.numNonStringReplacementsBySource[KA]=0)}VA&&uA.push(VA);continue}if(!CA[yA]&&rA.numReplacementsBySource[yA]>0){pA+=rA.numReplacementsBySource[yA],mA+=rA.numNonStringReplacementsBySource[yA],QA[yA]=rA.numReplacementsBySource[yA],BA[yA]=rA.numNonStringReplacementsBySource[yA];continue}const OA={prefix:`${eA.stateId}|`,num:dA.num};let FA=await this.createReplacementForSource({component:eA,sourceNum:yA,components:nA,nComponents:AA,stateIdInfo:OA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(yA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...FA.diagnostics);const kA=FA.nComponents;let SA=FA.propVariablesCopiedByReplacement,RA=FA.serializedReplacements,xA=RA.length,ZA=rA.numReplacementsBySource[yA];if(xA!==ZA){let jA=rA.numReplacementsBySource.slice(yA).reduce((UA,VA)=>UA+VA,0),TA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToReplace:jA,serializedReplacements:RA};uA.push(TA),EA=!0,AA=kA,dA.num=OA.num,rA.numReplacementsBySource.slice(yA).forEach((UA,VA)=>rA.numReplacementsBySource[VA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((UA,VA)=>rA.numNonStringReplacementsBySource[VA]=0)}else for(let jA=0;jA<xA;jA++){let TA=SA[jA].length!==rA.propVariablesCopiedBySource[yA][jA].length,UA=!TA;if(TA||(rA.propVariablesCopiedBySource[yA][jA].some((VA,$A)=>VA!==SA[jA][$A])?(UA=!1,TA=!0):eA.replacements[pA+jA].componentType!==RA[jA].componentType&&(TA=!0)),jA==0&&TA&&UA&&await eA.stateValues.numComponentsSpecified===1&&xA===1&&!(eA.replacementsToWithhold>0)&&rA.sourceIndices.length===1&&(TA=!1),TA){AA=kA,dA.num=OA.num;let VA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA+jA,numberReplacementsToReplace:1,serializedReplacements:[RA[jA]]};uA.push(VA)}RA[jA]}let XA=RA.filter(jA=>typeof jA!="string").length;pA+=xA,mA+=XA,QA[yA]=xA,BA[yA]=XA,hA[yA]=SA}let fA=rA.sourceIndices.length===0;rA.numReplacementsBySource=QA,rA.numNonStringReplacementsBySource=BA,rA.sourceIndices=cA.map(yA=>yA.componentIdx),rA.propVariablesCopiedBySource=hA;let NA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:uA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:nA,nComponents:AA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...NA.diagnostics),AA=NA.nComponents,uA=NA.replacementChanges,fA&&rA.sourceIndices.length===0?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,uA),rA.replacementsCreated=dA.num,{replacementChanges:uA,diagnostics:lA,nComponents:AA})}static async recreateReplacements({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:nA,numReplacementsToDelete:rA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA}){let CA=[],uA=await this.createReplacementForSource({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:nA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:Number(AA)===0&&eA.attributes.copyInChildren?.primitive.value});CA.push(...uA.diagnostics),oA=uA.nComponents;let dA=uA.propVariablesCopiedByReplacement,pA=uA.serializedReplacements;if(pA.length>0||rA>0){let mA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA,numberReplacementsToReplace:rA,serializedReplacements:pA};return{numReplacements:pA.length,numNonStringReplacements:pA.filter(QA=>typeof QA!="string").length,propVariablesCopiedByReplacement:dA,replacementInstruction:mA,diagnostics:CA,nComponents:oA}}else return{numReplacements:0,numNonStringReplacements:0,propVariablesCopiedByReplacement:dA,replacementInstruction:null,diagnostics:CA,nComponents:oA}}}async function replacementFromProp({component:iA,components:eA,nComponents:AA,stateIdInfo:tA,replacementSource:nA,propName:rA,allDoenetMLs:aA,compositeAttributesObj:oA,componentInfoObjects:sA,numComponentsForSource:lA,publicCaseInsensitiveAliasSubstitutions:gA}){let cA=[],IA=[],CA=[],uA=-1,dA,pA;if(nA&&(dA=eA[nA.componentIdx],pA=gA({stateVariables:[rA],componentClass:dA.constructor})[0]),pA===void 0||pA.slice(0,12)==="__not_public"){if(rA==="__no_target_found"){const hA=await iA.stateValues.unresolvedPath,DA=hA[0].position?.start.offset,EA=hA[hA.length-1].position?.end.offset;let fA="";if(DA!=null&&EA!=null){const NA=hA[0].sourceDoc??0;fA=aA?.[NA]?.substring(DA,EA)}cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:fA,component:nA.componentType}}))}else rA!=="__prop_name_not_found"&&cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:rA,component:nA.componentType}}));return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA}}let mA=dA.state[pA],QA=await mA.value,BA=await iA.stateValues.link;if(mA.isArray||mA.isArrayEntry){let hA,DA,EA,fA;if(mA.isArray?(hA=mA,EA=await mA.arraySize,DA=mA.getAllArrayKeys(EA,!1)):(hA=dA.state[mA.arrayStateVariable],DA=await mA.unflattenedArrayKeys,fA=await mA.arrayKeys),hA.shadowingInstructions?.hasVariableComponentType&&(await iA.stateValues.replacementSources,!hA.shadowingInstructions.createComponentOfType))return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};let NA=mA.wrappingComponents,yA=NA.length,bA=lA;if(mA.isArray)EA.some(wA=>wA===0)?bA=0:bA=EA.slice(0,EA.length-yA).reduce((wA,MA)=>wA*MA,1);else if(fA.length===0)bA=0;else if(yA===0)bA=fA.length;else if(yA>=mA.numDimensions)bA=1;else if(yA===mA.numDimensions-1)bA=DA.length;else{let wA=mA.numDimensions-yA-1;bA=flattenLevels(DA,wA).length}if(yA===0){let wA=flattenDeep(DA);for(let MA=0;MA<bA;MA++){let vA=wA[MA];if(await iA.stateValues.removeEmptyArrayEntries){if(!vA)continue;let kA=hA.keyToIndex(vA);Array.isArray(kA)||(kA=[kA]);let SA=await hA.value;for(let RA of kA)SA=SA[RA];if(SA==null)continue}uA++;let OA=CA[uA]=[],FA=hA.shadowingInstructions.createComponentOfType;if(Array.isArray(FA)&&(FA[hA.keyToIndex(vA)]?FA=FA[hA.keyToIndex(vA)]:FA=FA[0]),vA){let kA=hA.arrayVarNameFromArrayKey(vA);OA.push(kA);const SA=convertUnresolvedAttributesForComponentType({attributes:iA.attributes,componentType:FA,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),RA=SA.attributes;AA=SA.nComponents;let xA;if(hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){xA={};for(let XA in hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let jA=hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[XA].stateVariableToShadow,TA=dA.state[jA];TA.isArray&&(jA=TA.arrayVarNameFromArrayKey(vA)),xA[XA]={stateVariableToShadow:jA}}}let ZA;if(hA.shadowingInstructions.addStateVariablesShadowingStateVariables){ZA={};for(let XA in hA.shadowingInstructions.addStateVariablesShadowingStateVariables){let jA=hA.shadowingInstructions.addStateVariablesShadowingStateVariables[XA].stateVariableToShadow,TA=dA.state[jA];TA.isArray&&(jA=TA.arrayVarNameFromArrayKey(vA)),ZA[XA]={stateVariableToShadow:jA}}}if(BA){let XA={};if(xA){let TA=sA.allComponentClasses[FA].createAttributesObject();for(let UA in xA){let VA=xA[UA].stateVariableToShadow,$A=TA[UA]?.createComponentOfType;if($A){let Br={type:"serialized",componentType:$A,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:VA}]}};XA[UA]={component:Br}}}}Object.assign(XA,RA),IA.push({type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:XA,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[nA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:kA,additionalStateVariableShadowing:ZA}]}})}else{let XA={};if(xA){let KA=sA.allComponentClasses[FA].createAttributesObject(),JA={};for(let HA in xA)if(KA[HA]?.createComponentOfType){let ns=xA[HA].stateVariableToShadow,ts=dA.state[ns],ls=await ts.value;ts.isArray&&(ls=ls[ts.keyToIndex[vA]]),dA.state[ns].usedDefault||(JA[HA]=ls)}const LA=convertAttributeValuesForComponentType({attributeValues:JA,componentType:FA,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),Or=LA.attributes;if(AA=LA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let HA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[HA]?.component){const ns=await dA.attributes[HA].component.serialize({copyAll:!0,copyVariants:!0});let ts=createNewComponentIndices([ns],AA,tA);AA=ts.nComponents,Or[HA]={component:ts.components[0]}}else dA.attributes[HA]?.primitive!==void 0&&(Or[HA]={primitive:JSON.parse(JSON.stringify(dA.attributes[HA].primitive))});Object.assign(XA,Or)}Object.assign(XA,RA);let jA="value",TA=sA.allComponentClasses[FA];TA.primaryEssentialStateVariable?jA=TA.primaryEssentialStateVariable:TA.primaryStateVariableForDefinition&&(jA=TA.primaryStateVariableForDefinition);let UA=hA.keyToIndex(vA);Array.isArray(UA)||(UA=[UA]);let VA=await hA.value;for(let Br of UA)VA=VA[Br];let $A={type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:XA,doenetAttributes:{},state:{[jA]:VA},children:[]};IA.push($A)}}else IA.push({type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},children:[],state:{}})}}else{let wA=async function(OA,FA,kA=!1){let SA=[],RA=[];if(FA>1)for(let ZA of OA){let XA=await wA(ZA,FA-1);SA.push(...XA.pieces),RA.push(...XA.propVariablesCopiedByPiece)}else for(let ZA of OA){let XA=hA.arrayVarNameFromArrayKey(ZA),jA=[XA],TA=hA.shadowingInstructions.createComponentOfType;Array.isArray(TA)&&(TA=TA[hA.keyToIndex(ZA)]);let UA;if(hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){UA={};let $A=hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let Br in $A)if(!$A[Br].addToOuterIfWrappedArray){let KA=$A[Br].stateVariableToShadow,JA=dA.state[KA];JA.isArray&&(KA=JA.arrayVarNameFromArrayKey(ZA)),UA[Br]={stateVariableToShadow:KA}}}let VA;if(hA.shadowingInstructions.addStateVariablesShadowingStateVariables){VA={};for(let $A in hA.shadowingInstructions.addStateVariablesShadowingStateVariables){let Br=hA.shadowingInstructions.addStateVariablesShadowingStateVariables[$A].stateVariableToShadow,KA=dA.state[Br];KA.isArray&&(Br=KA.arrayVarNameFromArrayKey(ZA)),VA[$A]={stateVariableToShadow:Br}}}if(BA){let $A={};if(UA){let KA=sA.allComponentClasses[TA].createAttributesObject();for(let JA in UA){let LA=UA[JA].stateVariableToShadow,Or=KA[JA]?.createComponentOfType;if(Or){let HA={type:"serialized",componentType:Or,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:LA}]}};$A[JA]={component:HA}}}}SA.push({type:"serialized",componentType:TA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:$A,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[nA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:XA,additionalStateVariableShadowing:VA}]}})}else{let $A={};if(UA){let ns=sA.allComponentClasses[TA].createAttributesObject(),ts={};for(let cs in UA)if(ns[cs]?.createComponentOfType){let rs=UA[cs].stateVariableToShadow,ds=dA.state[rs],Cs=await ds.value;ds.isArray&&(Cs=Cs[ds.keyToIndex[ZA]]),dA.state[rs].usedDefault||(ts[cs]=Cs)}const ls=convertAttributeValuesForComponentType({attributeValues:ts,componentType:TA,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),ss=ls.attributes;if(AA=ls.nComponents,mA.shadowingInstructions.attributesToShadow)for(let cs of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[cs]?.component){let rs=await dA.attributes[cs].component.serialize({copyAll:!0,copyVariants:!0}),ds=createNewComponentIndices([rs],AA,tA);AA=ds.nComponents,ss[cs]={component:ds.components[0]}}else dA.attributes[cs]?.primitive!==void 0&&(ss[cs]={primitive:JSON.parse(JSON.stringify(dA.attributes[cs].primitive))});Object.assign($A,ss)}let Br="value",KA=sA.allComponentClasses[TA];KA.primaryEssentialStateVariable?Br=KA.primaryEssentialStateVariable:KA.primaryStateVariableForDefinition&&(Br=KA.primaryStateVariableForDefinition);let JA=hA.keyToIndex(ZA);Array.isArray(JA)||(JA=[JA]);let LA=await hA.value;for(let HA of JA)LA=LA[HA];let Or={type:"serialized",componentType:TA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:$A,doenetAttributes:{},children:[],state:{[Br]:LA}};SA.push(Or)}RA.push(jA)}let xA=NA[FA-1];if(SA.length>0&&xA&&xA.length>0){for(let ZA=xA.length-1;ZA>=0;ZA--){let XA=typeof xA[ZA]=="object"?xA[ZA].componentType:xA[ZA],jA=[],TA={};for(let UA of SA)if(UA.isAttributeNamed){let VA=UA.isAttributeNamed;delete UA.isAttributeNamed,TA[VA]={component:UA}}else jA.push(UA);SA=[{type:"serialized",componentType:XA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,children:jA,attributes:TA,doenetAttributes:{},state:{},skipSugar:!0}],typeof xA[ZA]=="object"&&xA[ZA].isAttributeNamed&&(SA[0].isAttributeNamed=xA[ZA].isAttributeNamed)}RA=[flattenDeep(RA)]}if(kA&&hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let ZA={},XA=hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let jA in XA)if(XA[jA].addToOuterIfWrappedArray){let TA=XA[jA].stateVariableToShadow;ZA[jA]={stateVariableToShadow:TA}}if(Object.keys(ZA).length>0)for(let jA of SA){let TA=jA.attributes;TA||(TA=jA.attributes={});let VA=sA.allComponentClasses[jA.componentType].createAttributesObject();if(BA)for(let $A in ZA){let Br=ZA[$A].stateVariableToShadow,KA=VA[$A]?.createComponentOfType;if(KA){let JA={type:"serialized",componentType:KA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:Br}]}};TA[$A]={component:JA}}}else{let $A={};for(let Br in ZA)if(VA[Br]?.createComponentOfType){let KA=ZA[Br].stateVariableToShadow,LA=await dA.state[KA].value;dA.state[KA].usedDefault||($A[Br]=LA)}if(Object.keys($A).length>0){const Br=convertAttributeValuesForComponentType({attributeValues:$A,componentType:jA.componentType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA});$A=Br.attributes,AA=Br.nComponents,Object.assign(TA,$A)}}}}return{pieces:SA,propVariablesCopiedByPiece:RA}},MA=await wA(DA,mA.numDimensions,!0),vA=MA.pieces;CA=MA.propVariablesCopiedByPiece;for(let OA of vA){if(typeof OA!="object")continue;OA.attributes||(OA.attributes={});const FA=convertUnresolvedAttributesForComponentType({attributes:iA.attributes,componentType:OA.componentType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),kA=FA.attributes;AA=FA.nComponents,Object.assign(OA.attributes,kA),BA&&(OA.downstreamDependencies={[nA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:pA,ignorePrimaryStateVariable:!0}]})}if(uA+=vA.length,IA.push(...vA),vA.length<bA)for(let OA=vA.length;OA<bA;OA++){uA++,CA[uA]=[];let FA,kA=NA[0],SA;kA&&kA.length>0?typeof kA[0]=="object"?(FA=kA[0].componentType,SA=Object.assign({},kA[0].doenetAttributes)):FA=kA[0]:(FA=hA.shadowingInstructions.createComponentOfType,Array.isArray(FA)&&(mA.isArrayEntry?FA=FA[hA.keyToIndex(fA[OA])]:FA=FA[OA]));let RA={type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]};SA&&(RA.doenetAttributes=SA),IA.push(RA)}else if(vA>bA)throw Error(`Something went wrong when creating replacements for ${iA.componentIdx} as we ended up with too many replacements`)}}else{if(mA.shadowingInstructions?.hasVariableComponentType&&await mA.value,!mA.shadowingInstructions?.createComponentOfType)return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};if(uA++,(CA[uA]=[]).push(pA),mA.shadowingInstructions.createComponentOfType==="string")IA.push(await mA.value);else{const DA=convertUnresolvedAttributesForComponentType({attributes:iA.attributes,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),EA=DA.attributes;if(AA=DA.nComponents,BA){let fA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let yA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject();for(let bA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let wA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[bA].stateVariableToShadow,MA=yA[bA]?.createComponentOfType;if(MA){let vA={type:"serialized",componentType:MA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:wA}]}};fA[bA]={component:vA}}}}Object.assign(fA,EA),IA.push({type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:fA,doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:pA,additionalStateVariableShadowing:mA.shadowingInstructions.addStateVariablesShadowingStateVariables}]}})}else{let fA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let MA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject(),vA={};for(let kA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables)if(MA[kA]?.createComponentOfType&&kA!=="fixed"){let SA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[kA].stateVariableToShadow,RA=await dA.state[SA].value;dA.state[SA].usedDefault||(vA[kA]={type:"unresolved",name:kA,children:[RA.toString()]})}const OA=convertUnresolvedAttributesForComponentType({attributes:vA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),FA=OA.attributes;if(AA=OA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let kA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[kA]?.component){let SA=await dA.attributes[kA].component.serialize({copyAll:!0,copyVariants:!0}),RA=createNewComponentIndices([SA],AA,tA);AA=RA.nComponents,FA[kA]={type:"component",name:kA,component:RA.components[0]}}else dA.attributes[kA]?.primitive!==void 0&&(FA[kA]={type:"primitive",name:kA,primitive:JSON.parse(JSON.stringify(dA.attributes[kA].primitive))});Object.assign(fA,FA)}Object.assign(fA,EA);let NA="value",yA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType];yA.primaryEssentialStateVariable?NA=yA.primaryEssentialStateVariable:yA.primaryStateVariableForDefinition&&(NA=yA.primaryStateVariableForDefinition);let bA={type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:fA,doenetAttributes:{},children:[],state:{[NA]:QA}};IA.push(bA)}}}if(await iA.stateValues.implicitProp)for(let hA of IA)hA.doenetAttributes||(hA.doenetAttributes={}),hA.doenetAttributes.fromImplicitProp=!0,hA.downstreamDependencies?.[dA.componentIdx]?.[0]&&(hA.downstreamDependencies[dA.componentIdx][0].fromImplicitProp=!0);return{serializedReplacements:IA,propVariablesCopiedByReplacement:CA,diagnostics:cA,nComponents:AA}}function addChildrenFromComposite({replacements:iA,children:eA,componentInfoObjects:AA}){let tA=iA[0];tA.children||(tA.children=[]);let nA=deepClone(eA);AA.allComponentClasses[tA.componentType].includeBlankStringChildren||(nA=nA.filter(aA=>typeof aA!="string"||aA.trim()!=="")),tA.children.push(...nA)}class SegmentConstraintComponent extends BaseComponent{static componentType="_segmentConstraint";static rendererType=void 0;static inSchemaOnlyInheritAs=["_segmentConstraint"]}class VariableNameList extends MathList{static componentType="_variableNameList";static stateVariableToBeShadowed="variables";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.variables={description:"The list of variable names.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},isArray:!0,entryPrefixes:["var"],additionalStateVariablesDefined:["validVariables"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let nA of AA)tA[nA]={math:{dependencyType:"stateVariable",variableName:"math"+(Number(nA)+1)}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let nA={},rA={},aA=[];for(let oA of tA){let sA=AA[oA].math,lA=isValidVariable(sA);lA||(aA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:sA.toString()}})),lA=!1),nA[oA]=sA,rA[oA]=lA}return{setValue:{variables:nA,validVariables:rA},sendDiagnostics:aA}}},eA}}class Variable extends MathComponent{static componentType="_variableName";static rendererType="math";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"value",newName:"valuePreValidate"}),eA.valuePreValidate.essentialVarName="value",eA.value={description:"The variable as a math expression.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},additionalStateVariablesDefined:["validVariable"],returnDependencies:()=>({valuePreValidate:{dependencyType:"stateVariable",variableName:"valuePreValidate"}}),definition({dependencyValues:AA}){let tA=[],nA=isValidVariable(AA.valuePreValidate);return nA||tA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:AA.valuePreValidate.toString()}})),{setValue:{value:AA.valuePreValidate,validVariable:nA},sendDiagnostics:tA}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setDependency:"valuePreValidate",desiredValue:AA.value}]}}},eA}}class ListOfNumberLists extends InlineComponent{static componentType="_listOfNumberLists";static includeBlankStringChildren=!0;static removeBlankStringChildrenPostSugar=!0;static additionalSchemaChildren=["math","string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){let aA=breakEmbeddedStringsIntoParensPieces({componentList:tA,removeParens:!0});return aA.success!==!0?{success:!1}:{success:!0,newChildren:aA.pieces.map(oA=>({type:"serialized",componentType:"numberList",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}})),nComponents:nA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"lists",componentTypes:["numberList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.value,eA.numLists={returnDependencies:()=>({listChildren:{dependencyType:"child",childGroups:["lists"]}}),definition({dependencyValues:AA}){return{setValue:{numLists:AA.listChildren.length}}}},eA.lists={isArray:!0,entryPrefixes:["list"],returnArraySizeDependencies:()=>({numLists:{dependencyType:"stateVariable",variableName:"numLists"}}),returnArraySize({dependencyValues:AA}){return[AA.numLists]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let nA of AA)tA[nA]={listChildren:{dependencyType:"child",childGroups:["lists"],variableNames:["values"],childIndices:[nA]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let nA={};for(let rA of tA)if(AA[rA].listChildren&&AA[rA].listChildren.length===1){let aA=AA[rA].listChildren[0];nA[rA]=aA.stateValues.values}return{setValue:{lists:nA}}}},eA}}class DirectionComponent extends BaseComponent{static componentType="_directionComponent";static rendererType=void 0;static primaryStateVariableForDefinition="directionShadow";static additionalSchemaChildren=["math","string"];static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){return tA.length===0?{success:!1}:tA.length>1||typeof tA[0]=="string"?{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:nA}:{success:!1}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"directions",componentTypes:["_directionComponent"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.directionShadow={defaultValue:context.fromAst(["vector",1,0]),hasEssential:!0,essentialVarName:"direction",set:convertValueToMathExpression,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{directionShadow:!0}}),inverseDefinition:function({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"directionShadow",value:convertValueToMathExpression(AA.directionShadow)}]}}},eA.unnormalizedDirection={returnDependencies:()=>({directionChild:{dependencyType:"child",childGroups:["directions"],variableNames:["unnormalizedDirection"]},directionShadow:{dependencyType:"stateVariable",variableName:"directionShadow"}}),definition({dependencyValues:AA}){let tA;return AA.directionChild.length>0?tA=AA.directionChild[0].stateValues.unnormalizedDirection:tA=AA.directionShadow,tA=tA.tuples_to_vectors().expand().simplify(),{setValue:{unnormalizedDirection:tA}}},inverseDefinition({desiredStateVariableValues:AA,dependencyValues:tA}){let nA;return tA.directionChild.length>0?nA=[{setDependency:"directionChild",desiredValue:AA.unnormalizedDirection,childIndex:0,variableIndex:0}]:nA=[{setDependency:"directionShadow",desiredValue:AA.unnormalizedDirection}],{success:!0,instructions:nA}}},eA.numDimensions={returnDependencies:()=>({unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}),definition({dependencyValues:AA}){let tA=AA.unnormalizedDirection.tree,nA;return Array.isArray(tA)&&vectorOperators.includes(tA[0])?nA=tA.length-1:nA=1,{setValue:{numDimensions:nA}}}},eA.direction={description:"The normalized direction as a unit vector.",public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="x"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},isArray:!0,entryPrefixes:["x"],hasEssential:!0,essentialVarName:"direction2",set:convertValueToMathExpression,returnArraySizeDependencies:()=>({numDimensions:{dependencyType:"stateVariable",variableName:"numDimensions"}}),returnArraySize({dependencyValues:AA}){return[AA.numDimensions]},returnArrayDependenciesByKey(){return{globalDependencies:{unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}}},arrayDefinitionByKey:function({globalDependencyValues:AA,arraySize:tA}){let nA={},rA=AA.unnormalizedDirection.tree;if(Array.isArray(rA)&&vectorOperators.includes(rA[0])){let aA=[],oA=tA[0],sA=0,lA=!0;for(let gA=0;gA<oA;gA++){let cA=AA.unnormalizedDirection.get_component(gA).evaluate_to_constant();if(Number.isFinite(cA))aA.push(cA),sA+=cA*cA;else{lA=!1;break}}if(lA){let gA=Math.sqrt(sA);for(let cA=0;cA<oA;cA++)nA[cA.toString()]=context.fromAst(aA[cA]/gA)}else for(let gA=0;gA<oA;gA++)nA[gA.toString()]=context.fromAst("_")}else nA[0]=context.fromAst(1);return{setValue:{direction:nA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,arraySize:nA}){let rA=[];if(nA[0]>1){let aA=0;for(let sA=0;sA<nA[0];sA++){let lA=evaluateToNumber(tA.unnormalizedDirection.get_component(sA));aA+=lA*lA}Number.isFinite(aA)?aA=Math.sqrt(aA):aA=1;let oA=["vector"];for(let sA in AA.direction)oA[Number(sA)+1]=AA.direction[sA].tree*aA;oA.length=nA[0]+1,rA.push({setDependency:"unnormalizedDirection",desiredValue:context.fromAst(markUnspecifiedComponents(oA))})}return{success:!0,instructions:rA}}},eA}}class ErrorComponent extends BlockComponent{static componentType="_error";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.message={createComponentOfType:"text",createStateVariable:"message",defaultValue:"",public:!0,forRenderer:!0,description:"The error message describing what went wrong."},eA}static returnChildGroups(){return[{group:"errors",componentTypes:["_error"]},{group:"any",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.hidden={returnDependencies:()=>({}),definition:()=>({setValue:{hidden:!1}})},eA.code={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{code:!0}})},eA.args={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{args:!0}})},eA.rangeMessage={description:"A message describing where in the source document the error was found.",forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"text"},additionalStateVariablesDefined:[{variableName:"rangeArgs",forRenderer:!0}],returnDependencies:()=>({position:{dependencyType:"position"}}),definition({dependencyValues:AA}){let tA=AA.position;return tA?.start.line===void 0?{setValue:{rangeMessage:"",rangeArgs:null}}:{setValue:{rangeMessage:"Found on "+printDoenetMLrange(tA)+".",rangeArgs:{span:tA.start.line===tA.end.line?"line":"lines",startLine:String(tA.start.line),endLine:String(tA.end.line)}}}}},eA.showMessage={forRenderer:!0,returnDependencies:()=>({childErrors:{dependencyType:"child",childGroups:["errors"],variableNames:["message"]},message:{dependencyType:"stateVariable",variableName:"message"}}),definition({dependencyValues:AA}){return{setValue:{showMessage:!AA.childErrors.some(nA=>nA.stateValues.message===AA.message)}}}},eA}}class Comment extends BaseComponent{static componentType="_comment";static rendererType=void 0;static returnChildGroups(){return[{group:"any",componentTypes:["_base"]}]}}const componentTypeArray=[...Object.values(Aliases),...Object.values(MMeMen),...Object.values(MdMdnMrow),...Object.values(BooleanOperators),...Object.values(BooleanOperatorsOfMath),...Object.values(MathOperators),...Object.values(MathListOperators),...Object.values(ListIndexOperators),...Object.values(CountOperators),Chart,Series,...Object.values(FunctionOperators),...Object.values(TextOperatorsOfMath),...Object.values(Extrema$1),...Object.values(ParagraphMarkup),...Object.values(SingleCharacterComponents),...Object.values(Sectioning),...Object.values(Lists),...Object.values(DynamicalSystems),...Object.values(Chemistry),...Object.values(FeedbackDefinitions$1),...Object.values(StyleDefinitions$1),...Object.values(StylePalette$1),...Object.values(SideBySide$1),...Object.values(ComponentWithSelectableType$1),...Object.values(Indexing),...Object.values(Divisions),...Object.values(Verbatim),...Object.values(Paginator$1),...Object.values(MatrixInput$1),...Object.values(FractionInput$1),...Object.values(Solution$1),Document,Text,TextList$1,TextList2,P$2,BooleanComponent,BooleanList,MathComponent,MathList,TupleList,NumberList,Copy,Collect,Ref,Point,Coords,Line,LineSegment,Ray,Polyline,Polygon,Triangle,Rectangle,RegularPolygon,Circle,Parabola,Curve,BezierControls,ControlVectors,Vector,Angle,Answer,Award,When,MathInput,Textinput,BooleanInput,Choiceinput,Choice,NumberComponent,Integer,Graph$1,Annotations,Annotation,Function$1,PiecewiseFunction,Interval,Option$1,Sequence,Slider,Spreadsheet,DiscreteSimulationResultList,DiscreteSimulationResultPolyline,Cell,Row,Column,Col,CellBlock,Tabular,Table,Figure,Markers,Panel,Repeat,RepeatForSequence,Pegboard,Constraints,ConstrainToGrid,ConstrainToGraph,AttractToGrid,ConstrainTo,AttractTo,ConstraintUnion,AttractToConstraint,ConstrainToInterior,Intersection,ConstrainToAngles,AttractToAngles,ConditionalContent,AsList,VariantControl,TextListFromString,SelectFromSequence,Select,Group,AnimateFromSequence,Evaluate,SelectRandomNumbers,SampleRandomNumbers,SampleMultivariateRandomNumber,SelectPrimeNumbers,SamplePrimeNumbers,Substitute,PeriodicSet,Image,Video,Embed,Hint,IntComma,Pluralize,Feedback,CollaborateGroups,CollaborateGroupSetup,ConsiderAsResponses,Case,Lorem,UpdateValue,CallAction,triggerSet,FunctionIterates,Module,ModuleAttributes,Setup,Footnote,Caption,Endpoint,Sort,SortIndices,Shuffle,SolveEquations,PostponeRenderContainer,SubsetOfRealsInput,SubsetOfReals,Split,BestFitLine,RegionBetweenCurveXAxis,RegionBetweenCurves,SlopeField,VectorField,RegionHalfPlane,CodeEditor,HasSameFactoring,DataFrame,SummaryStatistics,Legend,Label,MatchesPattern,Matrix,EigenDecomposition,Latex,BlockQuote,Description,StickyGroup,Pretzel,PretzelArranger,Cascade,Page,DynamicChildren,ShortDescription,BaseComponent,InlineComponent,BlockComponent,BlockScoredComponent,GraphicalComponent,ConstraintComponent,SegmentConstraintComponent,Input,CompositeComponent,PointList,IntervalList,LineListComponent,VectorListComponent,AngleListComponent,BooleanOperator,BooleanBaseOperatorOfMath,MathOperator,MathOperatorOneInput,FunctionOperator,...Object.values(ComponentSize$1),...Object.values(SectioningComponent$1),InlineRenderInlineChildren,TextOrInline,SingleCharacter,VariableNameList,Variable,ListOfNumberLists,DirectionComponent,ErrorComponent,Comment];function allComponentClasses(){const iA={},eA=new Set;for(let AA of componentTypeArray){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let nA=tA.toLowerCase();if(eA.has(nA))throw Error("component type "+tA+" defined in two classes");iA[tA]=AA,eA.add(nA)}return iA}function componentTypesCreatingVariants(){const iA={},eA=new Set;for(let AA of componentTypeArray)if(AA.createsVariants){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let nA=tA.toLowerCase();if(eA.has(nA))throw Error("component type "+tA+" defined in two classes");iA[tA]=AA,eA.add(nA)}return iA}function createComponentInfoObjects(){const iA=allComponentClasses(),eA=componentTypesCreatingVariants(),AA={};for(const lA in iA)AA[lA.toLowerCase()]=lA;const tA={};for(const lA in iA)Object.defineProperty(tA,lA,{get:(function(){const gA=iA[lA].returnStateVariableInfo();return delete tA[lA],tA[lA]=gA}).bind(this),configurable:!0});const nA={};for(const lA in iA)Object.defineProperty(nA,lA,{get:(function(){const gA=iA[lA].returnStateVariableInfo({onlyPublic:!0});return delete nA[lA],nA[lA]=gA}).bind(this),configurable:!0});function rA({inheritedComponentType:lA,baseComponentType:gA}){if(lA===gA)return!0;if(lA==="string")return gA==="_base"||gA==="_inline";if(gA==="string")return!1;let cA=iA[gA];return cA?cA.isPrototypeOf(iA[lA]):!1}function aA({componentType:lA,includeNonStandard:gA=!0}){const cA=iA[lA];return cA?rA({inheritedComponentType:lA,baseComponentType:"_composite"})&&(gA||!cA.treatAsComponentForRecursiveReplacements):!1}const oA=(lA,gA)=>rA({inheritedComponentType:lA,baseComponentType:gA});return{allComponentClasses:iA,componentTypesCreatingVariants:eA,componentTypeLowerCaseMapping:AA,isInheritedComponentType:rA,isCompositeComponent:aA,stateVariableInfo:tA,publicStateVariableInfo:nA,componentIsSpecifiedType:(lA,gA)=>oA(lA.componentType,gA)||lA.attributes?.createComponentOfType?.primitive!==void 0&&oA(lA.attributes?.createComponentOfType?.primitive.value,gA)}}async function returnAllPossibleVariants(iA,eA,AA){let nA=getNumVariants({serializedComponent:iA,componentInfoObjects:eA,infoDiagnostics:AA}).numVariants,rA;return iA.variants?.allPossibleVariants?rA=iA.variants.allPossibleVariants:rA=[...Array(nA).keys()].map(aA=>indexToLowercaseLetters(aA+1)),rA}function indexToLowercaseLetters(iA){return numberToLetters(iA,!0)}class PublicDoenetMLCore{constructor(){this.core=null,this.initialized=!1,this.doenetML="",this.flags={},this.localeData=DEFAULT_LOCALE_DATA}setSource(eA){this.doenetML=eA}setFlags(eA){this.flags=eA}setLocaleData(eA){this.localeData=eA}async initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA,normalizedRoot:rA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:lA,updateRootNames:gA}){this.addNodesToResolver=aA,this.replaceIndexResolutionsInResolver=oA,this.deleteNodesFromResolver=sA,this.resolvePath=lA,this.updateRootNames=gA;let cA=createComponentInfoObjects();const{document:IA,nComponents:CA,diagnostics:uA,sources:dA}=await normalizedDastToSerializedComponents(rA,cA,aA);this.coreBaseArgs={doenetML:this.doenetML,flags:this.flags,localeData:this.localeData,activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA,serializedDocument:IA,nComponentsInit:CA,allDoenetMLs:dA,preliminaryDiagnostics:uA,componentInfoObjects:cA},this.initialized=!0;let pA=await returnAllPossibleVariants(this.coreBaseArgs.serializedDocument,this.coreBaseArgs.componentInfoObjects,uA);const mA=this.coreBaseArgs.serializedDocument.children.reduce((QA,BA)=>(typeof BA=="object"&&(QA[BA.componentType]=(QA[BA.componentType]??0)+1),QA),{});return{allPossibleVariants:pA,baseComponentCounts:mA}}async createCoreGenerateDast(eA,AA,tA,nA,rA,aA,oA,sA){if(this.initialized&&!this.coreBaseArgs?.serializedDocument)return{success:!1,errMsg:"Cannot create the core a second time from the same worker; the serialized document was released after the first core was created."};let lA={...this.coreBaseArgs,...eA,addNodesToResolver:this.addNodesToResolver,replaceIndexResolutionsInResolver:this.replaceIndexResolutionsInResolver,deleteNodesFromResolver:this.deleteNodesFromResolver,resolvePath:this.resolvePath,updateRootNames:this.updateRootNames,updateRenderersCallback:AA,reportScoreAndStateCallback:tA,requestAnimationFrame:nA,cancelAnimationFrame:rA,copyToClipboard:aA,sendEvent:oA,requestSolutionView:sA};if(this.initialized){this.core=new Core(lA),this.coreBaseArgs.serializedDocument=void 0;try{return{success:!0,...await this.core.generateDast()}}catch(gA){return console.error(gA),{success:!1,errMsg:typeof gA=="object"&&gA&&"message"in gA&&typeof gA.message=="string"?gA.message:""}}}else return{success:!1,coreId:lA.coreId,errMsg:"Internal error. Cannot create document. Core not initialized."}}async requestAction(eA){if(!this.core)return{success:!1,errMsg:"Cannot request action before core is created"};try{return await this.core.requestAction(eA)}catch(AA){return console.error(AA),{success:!1,errMsg:typeof AA=="object"&&AA&&"message"in AA&&typeof AA.message=="string"?AA.message:"",actionId:eA.args?.actionId}}}async returnAllStateVariables(eA=!1,AA=!1){if(!this.core?.components)return{};const tA={},nA=this.core.components;eA&&console.log(nA);for(let rA in nA){const aA=Number(rA);let oA=nA[aA];if(!oA)continue;tA[aA]={componentIdx:aA,componentType:oA.componentType,stateValues:{},activeChildren:[],sharedParameters:null};let sA=tA[aA];for(let lA in oA.state){if(["replacements","recursiveReplacements","fullRecursiveReplacements"].includes(lA)&&this.core.componentInfoObjects.isCompositeComponent({componentType:oA.componentType})&&!oA.isExpanded)continue;const gA=await oA.state[lA].value;sA.stateValues[lA]=AA?gA:removeFunctionsMathExpressionClass(gA)}sA.activeChildren=oA.activeChildren.map(lA=>lA.componentIdx?{componentIdx:lA.componentIdx,componentType:lA.componentType}:lA),oA.replacements&&(sA.replacements=oA.replacements.map(lA=>lA.componentIdx?{componentIdx:lA.componentIdx,componentType:lA.componentType}:lA),oA.replacementsToWithhold!==void 0&&(sA.replacementsToWithhold=oA.replacementsToWithhold)),oA.replacementOf&&(sA.replacementOf=oA.replacementOf.componentIdx),sA.sharedParameters=AA?oA.sharedParameters:removeFunctionsMathExpressionClass(oA.sharedParameters)}return tA}async terminate(){this.core&&(await this.core.terminate(),this.core=null)}handleVisibilityChange(eA){this.core?.handleVisibilityChange(eA)}navigatingToComponent(eA,AA){this.core&&handleNavigatingToComponent({core:this.core,componentIdx:eA,hash:AA}).catch(reportTimerError(TimerLabels.navigateToComponent))}async submitAllAnswers(){await this.core?.requestAction({componentIdx:this.core.documentIdx,actionName:"submitAllAnswers",args:{}}),await this.core?.saveImmediately()}async saveImmediately(){await this.core?.saveImmediately()}async flushState(){return await this.core?.flushState()??!1}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(iA){return iA&&iA.__esModule&&Object.prototype.hasOwnProperty.call(iA,"default")?iA.default:iA}var colorName$1,hasRequiredColorName;function requireColorName(){return hasRequiredColorName||(hasRequiredColorName=1,colorName$1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),colorName$1}var colorNameExports=requireColorName();const colorName=getDefaultExportFromCjs(colorNameExports);var r$2={grad:.9,turn:360,rad:360/(2*Math.PI)},t$3=function(iA){return typeof iA=="string"?iA.length>0:typeof iA=="number"},n$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*iA)/AA+0},e$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),iA>AA?AA:iA>eA?iA:eA},u$2=function(iA){return(iA=isFinite(iA)?iA%360:0)>0?iA:iA+360},a$2=function(iA){return{r:e$2(iA.r,0,255),g:e$2(iA.g,0,255),b:e$2(iA.b,0,255),a:e$2(iA.a)}},o$3=function(iA){return{r:n$2(iA.r),g:n$2(iA.g),b:n$2(iA.b),a:n$2(iA.a,3)}},i$2=/^#([0-9a-f]{3,8})$/i,s$1=function(iA){var eA=iA.toString(16);return eA.length<2?"0"+eA:eA},h$2=function(iA){var eA=iA.r,AA=iA.g,tA=iA.b,nA=iA.a,rA=Math.max(eA,AA,tA),aA=rA-Math.min(eA,AA,tA),oA=aA?rA===eA?(AA-tA)/aA:rA===AA?2+(tA-eA)/aA:4+(eA-AA)/aA:0;return{h:60*(oA<0?oA+6:oA),s:rA?aA/rA*100:0,v:rA/255*100,a:nA}},b$2=function(iA){var eA=iA.h,AA=iA.s,tA=iA.v,nA=iA.a;eA=eA/360*6,AA/=100,tA/=100;var rA=Math.floor(eA),aA=tA*(1-AA),oA=tA*(1-(eA-rA)*AA),sA=tA*(1-(1-eA+rA)*AA),lA=rA%6;return{r:255*[tA,oA,aA,aA,sA,tA][lA],g:255*[sA,tA,tA,oA,aA,aA][lA],b:255*[aA,aA,sA,tA,tA,oA][lA],a:nA}},g=function(iA){return{h:u$2(iA.h),s:e$2(iA.s,0,100),l:e$2(iA.l,0,100),a:e$2(iA.a)}},d$1=function(iA){return{h:n$2(iA.h),s:n$2(iA.s),l:n$2(iA.l),a:n$2(iA.a,3)}},f$1=function(iA){return b$2((AA=(eA=iA).s,{h:eA.h,s:(AA*=((tA=eA.l)<50?tA:100-tA)/100)>0?2*AA/(tA+AA)*100:0,v:tA+AA,a:eA.a}));var eA,AA,tA},c$1=function(iA){return{h:(eA=h$2(iA)).h,s:(nA=(200-(AA=eA.s))*(tA=eA.v)/100)>0&&nA<200?AA*tA/100/(nA<=100?nA:200-nA)*100:0,l:nA/2,a:eA.a};var eA,AA,tA,nA},l$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v$1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y$1={string:[[function(iA){var eA=i$2.exec(iA);return eA?(iA=eA[1]).length<=4?{r:parseInt(iA[0]+iA[0],16),g:parseInt(iA[1]+iA[1],16),b:parseInt(iA[2]+iA[2],16),a:iA.length===4?n$2(parseInt(iA[3]+iA[3],16)/255,2):1}:iA.length===6||iA.length===8?{r:parseInt(iA.substr(0,2),16),g:parseInt(iA.substr(2,2),16),b:parseInt(iA.substr(4,2),16),a:iA.length===8?n$2(parseInt(iA.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(iA){var eA=v$1.exec(iA)||m.exec(iA);return eA?eA[2]!==eA[4]||eA[4]!==eA[6]?null:a$2({r:Number(eA[1])/(eA[2]?100/255:1),g:Number(eA[3])/(eA[4]?100/255:1),b:Number(eA[5])/(eA[6]?100/255:1),a:eA[7]===void 0?1:Number(eA[7])/(eA[8]?100:1)}):null},"rgb"],[function(iA){var eA=l$2.exec(iA)||p$2.exec(iA);if(!eA)return null;var AA,tA,nA=g({h:(AA=eA[1],tA=eA[2],tA===void 0&&(tA="deg"),Number(AA)*(r$2[tA]||1)),s:Number(eA[3]),l:Number(eA[4]),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return f$1(nA)},"hsl"]],object:[[function(iA){var eA=iA.r,AA=iA.g,tA=iA.b,nA=iA.a,rA=nA===void 0?1:nA;return t$3(eA)&&t$3(AA)&&t$3(tA)?a$2({r:Number(eA),g:Number(AA),b:Number(tA),a:Number(rA)}):null},"rgb"],[function(iA){var eA=iA.h,AA=iA.s,tA=iA.l,nA=iA.a,rA=nA===void 0?1:nA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=g({h:Number(eA),s:Number(AA),l:Number(tA),a:Number(rA)});return f$1(aA)},"hsl"],[function(iA){var eA=iA.h,AA=iA.s,tA=iA.v,nA=iA.a,rA=nA===void 0?1:nA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=(function(oA){return{h:u$2(oA.h),s:e$2(oA.s,0,100),v:e$2(oA.v,0,100),a:e$2(oA.a)}})({h:Number(eA),s:Number(AA),v:Number(tA),a:Number(rA)});return b$2(aA)},"hsv"]]},N=function(iA,eA){for(var AA=0;AA<eA.length;AA++){var tA=eA[AA][0](iA);if(tA)return[tA,eA[AA][1]]}return[null,void 0]},x$1=function(iA){return typeof iA=="string"?N(iA.trim(),y$1.string):typeof iA=="object"&&iA!==null?N(iA,y$1.object):[null,void 0]},M$2=function(iA,eA){var AA=c$1(iA);return{h:AA.h,s:e$2(AA.s+100*eA,0,100),l:AA.l,a:AA.a}},H=function(iA){return(299*iA.r+587*iA.g+114*iA.b)/1e3/255},$=function(iA,eA){var AA=c$1(iA);return{h:AA.h,s:AA.s,l:e$2(AA.l+100*eA,0,100),a:AA.a}},j=(function(){function iA(eA){this.parsed=x$1(eA)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return iA.prototype.isValid=function(){return this.parsed!==null},iA.prototype.brightness=function(){return n$2(H(this.rgba),2)},iA.prototype.isDark=function(){return H(this.rgba)<.5},iA.prototype.isLight=function(){return H(this.rgba)>=.5},iA.prototype.toHex=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,nA=eA.b,aA=(rA=eA.a)<1?s$1(n$2(255*rA)):"","#"+s$1(AA)+s$1(tA)+s$1(nA)+aA;var eA,AA,tA,nA,rA,aA},iA.prototype.toRgb=function(){return o$3(this.rgba)},iA.prototype.toRgbString=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,nA=eA.b,(rA=eA.a)<1?"rgba("+AA+", "+tA+", "+nA+", "+rA+")":"rgb("+AA+", "+tA+", "+nA+")";var eA,AA,tA,nA,rA},iA.prototype.toHsl=function(){return d$1(c$1(this.rgba))},iA.prototype.toHslString=function(){return eA=d$1(c$1(this.rgba)),AA=eA.h,tA=eA.s,nA=eA.l,(rA=eA.a)<1?"hsla("+AA+", "+tA+"%, "+nA+"%, "+rA+")":"hsl("+AA+", "+tA+"%, "+nA+"%)";var eA,AA,tA,nA,rA},iA.prototype.toHsv=function(){return eA=h$2(this.rgba),{h:n$2(eA.h),s:n$2(eA.s),v:n$2(eA.v),a:n$2(eA.a,3)};var eA},iA.prototype.invert=function(){return w$1({r:255-(eA=this.rgba).r,g:255-eA.g,b:255-eA.b,a:eA.a});var eA},iA.prototype.saturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,eA))},iA.prototype.desaturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,-eA))},iA.prototype.grayscale=function(){return w$1(M$2(this.rgba,-1))},iA.prototype.lighten=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,eA))},iA.prototype.darken=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,-eA))},iA.prototype.rotate=function(eA){return eA===void 0&&(eA=15),this.hue(this.hue()+eA)},iA.prototype.alpha=function(eA){return typeof eA=="number"?w$1({r:(AA=this.rgba).r,g:AA.g,b:AA.b,a:eA}):n$2(this.rgba.a,3);var AA},iA.prototype.hue=function(eA){var AA=c$1(this.rgba);return typeof eA=="number"?w$1({h:eA,s:AA.s,l:AA.l,a:AA.a}):n$2(AA.h)},iA.prototype.isEqual=function(eA){return this.toHex()===w$1(eA).toHex()},iA})(),w$1=function(iA){return iA instanceof j?iA:new j(iA)},S=[],k=function(iA){iA.forEach(function(eA){S.indexOf(eA)<0&&(eA(j,y$1),S.push(eA))})},a$1=function(iA){return typeof iA=="string"?iA.length>0:typeof iA=="number"},t$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*iA)/AA+0},o$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),iA>AA?AA:iA>eA?iA:eA},r$1=function(iA){var eA=iA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h$1=function(iA){return 255*(iA>.0031308?1.055*Math.pow(iA,1/2.4)-.055:12.92*iA)},n$1=96.422,p$1=100,M$1=82.521,u$1=function(iA){var eA,AA,tA={x:.9555766*(eA=iA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h$1(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h$1(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h$1(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:iA.a},{r:o$2(AA.r,0,255),g:o$2(AA.g,0,255),b:o$2(AA.b,0,255),a:o$2(AA.a)}},e$1=function(iA){var eA=r$1(iA.r),AA=r$1(iA.g),tA=r$1(iA.b);return(function(nA){return{x:o$2(nA.x,0,n$1),y:o$2(nA.y,0,p$1),z:o$2(nA.z,0,M$1),a:o$2(nA.a)}})((function(nA){return{x:1.0478112*nA.x+.0228866*nA.y+-.050127*nA.z,y:.0295424*nA.x+.9904844*nA.y+-.0170491*nA.z,z:-.0092345*nA.x+.0150436*nA.y+.7521316*nA.z,a:nA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:iA.a}))},w=216/24389,b$1=24389/27,i$1=function(iA){var eA=iA.l,AA=iA.a,tA=iA.b,nA=iA.alpha,rA=nA===void 0?1:nA;if(!a$1(eA)||!a$1(AA)||!a$1(tA))return null;var aA=(function(oA){return{l:o$2(oA.l,0,400),a:oA.a,b:oA.b,alpha:o$2(oA.alpha)}})({l:Number(eA),a:Number(AA),b:Number(tA),alpha:Number(rA)});return l$1(aA)},l$1=function(iA){var eA=(iA.l+16)/116,AA=iA.a/500+eA,tA=eA-iA.b/200;return u$1({x:(Math.pow(AA,3)>w?Math.pow(AA,3):(116*AA-16)/b$1)*n$1,y:(iA.l>8?Math.pow((iA.l+16)/116,3):iA.l/b$1)*p$1,z:(Math.pow(tA,3)>w?Math.pow(tA,3):(116*tA-16)/b$1)*M$1,a:iA.alpha})};function labPlugin(iA,eA){iA.prototype.toLab=function(){return tA=e$1(this.rgba),rA=tA.y/p$1,aA=tA.z/M$1,nA=(nA=tA.x/n$1)>w?Math.cbrt(nA):(b$1*nA+16)/116,AA={l:116*(rA=rA>w?Math.cbrt(rA):(b$1*rA+16)/116)-16,a:500*(nA-rA),b:200*(rA-(aA=aA>w?Math.cbrt(aA):(b$1*aA+16)/116)),alpha:tA.a},{l:t$2(AA.l,2),a:t$2(AA.a,2),b:t$2(AA.b,2),alpha:t$2(AA.alpha,3)};var AA,tA,nA,rA,aA},iA.prototype.delta=function(AA){AA===void 0&&(AA="#FFF");var tA=AA instanceof iA?AA:new iA(AA),nA=(function(rA,aA){var oA=rA.l,sA=rA.a,lA=rA.b,gA=aA.l,cA=aA.a,IA=aA.b,CA=180/Math.PI,uA=Math.PI/180,dA=Math.pow(Math.pow(sA,2)+Math.pow(lA,2),.5),pA=Math.pow(Math.pow(cA,2)+Math.pow(IA,2),.5),mA=(oA+gA)/2,QA=Math.pow((dA+pA)/2,7),BA=.5*(1-Math.pow(QA/(QA+Math.pow(25,7)),.5)),hA=sA*(1+BA),DA=cA*(1+BA),EA=Math.pow(Math.pow(hA,2)+Math.pow(lA,2),.5),fA=Math.pow(Math.pow(DA,2)+Math.pow(IA,2),.5),NA=(EA+fA)/2,yA=hA===0&&lA===0?0:Math.atan2(lA,hA)*CA,bA=DA===0&&IA===0?0:Math.atan2(IA,DA)*CA;yA<0&&(yA+=360),bA<0&&(bA+=360);var wA=bA-yA,MA=Math.abs(bA-yA);MA>180&&bA<=yA?wA+=360:MA>180&&bA>yA&&(wA-=360);var vA=yA+bA;MA<=180?vA/=2:vA=(yA+bA<360?vA+360:vA-360)/2;var OA=1-.17*Math.cos(uA*(vA-30))+.24*Math.cos(2*uA*vA)+.32*Math.cos(uA*(3*vA+6))-.2*Math.cos(uA*(4*vA-63)),FA=gA-oA,kA=fA-EA,SA=2*Math.sin(uA*wA/2)*Math.pow(EA*fA,.5),RA=1+.015*Math.pow(mA-50,2)/Math.pow(20+Math.pow(mA-50,2),.5),xA=1+.045*NA,ZA=1+.015*NA*OA,XA=30*Math.exp(-1*Math.pow((vA-275)/25,2)),jA=-2*Math.pow(QA/(QA+Math.pow(25,7)),.5)*Math.sin(2*uA*XA);return Math.pow(Math.pow(FA/1/RA,2)+Math.pow(kA/1/xA,2)+Math.pow(SA/1/ZA,2)+jA*kA*SA/(1*xA*1*ZA),.5)})(this.toLab(),tA.toLab())/100;return o$2(t$2(nA,3))},eA.object.push([i$1,"lab"])}var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t$1=function(iA){return typeof iA=="string"?iA.length>0:typeof iA=="number"},a=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*iA)/AA+0},n=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),iA>AA?AA:iA>eA?iA:eA},u=function(iA){var eA=iA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h=function(iA){return 255*(iA>.0031308?1.055*Math.pow(iA,1/2.4)-.055:12.92*iA)},o$1=96.422,e=100,c=82.521,i=function(iA){var eA,AA,tA={x:.9555766*(eA=iA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:iA.a},{r:n(AA.r,0,255),g:n(AA.g,0,255),b:n(AA.b,0,255),a:n(AA.a)}},l=function(iA){var eA=u(iA.r),AA=u(iA.g),tA=u(iA.b);return(function(nA){return{x:n(nA.x,0,o$1),y:n(nA.y,0,e),z:n(nA.z,0,c),a:n(nA.a)}})((function(nA){return{x:1.0478112*nA.x+.0228866*nA.y+-.050127*nA.z,y:.0295424*nA.x+.9904844*nA.y+-.0170491*nA.z,z:-.0092345*nA.x+.0150436*nA.y+.7521316*nA.z,a:nA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:iA.a}))},f=216/24389,b=24389/27,d=function(iA){return{l:n(iA.l,0,100),c:iA.c,h:(eA=iA.h,(eA=isFinite(eA)?eA%360:0)>0?eA:eA+360),a:iA.a};var eA},p=function(iA){return{l:a(iA.l,2),c:a(iA.c,2),h:a(iA.h,2),a:a(iA.a,3)}},v=function(iA){var eA=iA.l,AA=iA.c,tA=iA.h,nA=iA.a,rA=nA===void 0?1:nA;if(!t$1(eA)||!t$1(AA)||!t$1(tA))return null;var aA=d({l:Number(eA),c:Number(AA),h:Number(tA),a:Number(rA)});return M(aA)},y=function(iA){var eA=(function(rA){var aA=l(rA),oA=aA.x/o$1,sA=aA.y/e,lA=aA.z/c;return oA=oA>f?Math.cbrt(oA):(b*oA+16)/116,{l:116*(sA=sA>f?Math.cbrt(sA):(b*sA+16)/116)-16,a:500*(oA-sA),b:200*(sA-(lA=lA>f?Math.cbrt(lA):(b*lA+16)/116)),alpha:aA.a}})(iA),AA=a(eA.a,3),tA=a(eA.b,3),nA=Math.atan2(tA,AA)/Math.PI*180;return{l:eA.l,c:Math.sqrt(AA*AA+tA*tA),h:nA<0?nA+360:nA,a:eA.alpha}},M=function(iA){return eA={l:iA.l,a:iA.c*Math.cos(iA.h*Math.PI/180),b:iA.c*Math.sin(iA.h*Math.PI/180),alpha:iA.a},tA=eA.a/500+(AA=(eA.l+16)/116),nA=AA-eA.b/200,i({x:(Math.pow(tA,3)>f?Math.pow(tA,3):(116*tA-16)/b)*o$1,y:(eA.l>8?Math.pow((eA.l+16)/116,3):eA.l/b)*e,z:(Math.pow(nA,3)>f?Math.pow(nA,3):(116*nA-16)/b)*c,a:eA.alpha});var eA,AA,tA,nA},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(iA){var eA=x.exec(iA);if(!eA)return null;var AA,tA,nA=d({l:Number(eA[1]),c:Number(eA[2]),h:(AA=eA[3],tA=eA[4],tA===void 0&&(tA="deg"),Number(AA)*(r[tA]||1)),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return M(nA)};function lchPlugin(iA,eA){iA.prototype.toLch=function(){return p(y(this.rgba))},iA.prototype.toLchString=function(){return AA=p(y(this.rgba)),tA=AA.l,nA=AA.c,rA=AA.h,(aA=AA.a)<1?"lch("+tA+"% "+nA+" "+rA+" / "+aA+")":"lch("+tA+"% "+nA+" "+rA+")";var AA,tA,nA,rA,aA},eA.string.push([s,"lch"]),eA.object.push([v,"lch"])}k([labPlugin,lchPlugin]);const canonicalColorHexByKey={black:"#000000",white:"#ffffff",gray:"#808080",red:"#ff0000",orange:"#ffa500",yellow:"#ffff00",green:"#008000",cyan:"#00ffff",blue:"#0000ff",purple:"#800080",pink:"#ffc0cb",brown:"#a52a2a"},canonicalAnchorDefinitions=Object.fromEntries(Object.entries(canonicalColorHexByKey).map(([iA,eA])=>[iA,{hex:eA,canonical:iA}])),extraAnchorDefinitions={silver:{hex:"#c0c0c0",canonical:"gray"},grayDark:{hex:"#4d4d4d",canonical:"gray"},grayCustom:{hex:"#757575",canonical:"gray"},grayLight:{hex:"#c8c8c8",canonical:"gray"},grayLighter:{hex:"#dcdcdc",canonical:"gray"},maroon:{hex:"#800000",canonical:"red"},redLight:{hex:"#f08080",canonical:"red"},redCustom:{hex:"#D4042D",canonical:"red"},redDark:{hex:"#8b0000",canonical:"red"},crimson:{hex:"#dc143c",canonical:"red"},wine:{hex:"#993355",canonical:"red"},orangeLight:{hex:"#ffa07a",canonical:"orange"},orangeCustom:{hex:"#F19143",canonical:"orange"},orangePresetAccessible:{hex:"#a6510c",canonical:"orange"},orangeDark:{hex:"#ff8c00",canonical:"orange"},yellowLight:{hex:"#ffffe0",canonical:"yellow"},yellowDark:{hex:"#bdb76b",canonical:"yellow"},yellowgreen:{hex:"#9acd32",canonical:"green"},olive:{hex:"#808000",canonical:"green"},lime:{hex:"#00ff00",canonical:"green"},greenLight:{hex:"#90ee90",canonical:"green"},greenCustom:{hex:"#2ca02c",canonical:"green"},greenDark:{hex:"#006400",canonical:"green"},teal:{hex:"#008080",canonical:"green"},aqua:{hex:"#00ffff",canonical:"cyan"},cyanLight:{hex:"#e0ffff",canonical:"cyan"},cyanMid:{hex:"#25b0c0",canonical:"cyan"},cyanDark:{hex:"#008b8b",canonical:"cyan"},navy:{hex:"#000080",canonical:"blue"},blueMid:{hex:"#4477aa",canonical:"blue"},blueSky:{hex:"#56b4e9",canonical:"blue"},blueCustom:{hex:"#648FFF",canonical:"blue"},bluePresetAccessible:{hex:"#1f5dff",canonical:"blue"},blueLight:{hex:"#add8e6",canonical:"blue"},blueDark:{hex:"#00008b",canonical:"blue"},fuchsia:{hex:"#ff00ff",canonical:"purple"},purpleCustom:{hex:"#644CD6",canonical:"purple"},purpleMuted:{hex:"#9c5686",canonical:"purple"},purpleLight:{hex:"#dda0dd",canonical:"purple"},purpleDark:{hex:"#8b008b",canonical:"purple"},hotpink:{hex:"#ff69b4",canonical:"pink"},pinkDark:{hex:"#ff1493",canonical:"pink"},brownLight:{hex:"#deb887",canonical:"brown"},brownDark:{hex:"#8b4513",canonical:"brown"}},anchorDefinitions={...canonicalAnchorDefinitions,...extraAnchorDefinitions};Object.values(anchorDefinitions).map(iA=>({color:w$1(iA.hex),canonical:iA.canonical})),[...Object.keys(colorName)];const DEFAULT_STYLE_VALUES={lineOpacity:.7,lineWidth:4,lineWidthWord:"thick",lineStyle:"solid",lineStyleWord:"",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,markerFilled:!0,fillOpacity:.3,fillPatternOpacity:1,fillStyle:"solid",fillStyleWord:"",lineColor:"#1f5dff",lineColorDarkMode:"#648FFF",markerColor:"#1f5dff",markerColorDarkMode:"#648FFF",fillColor:"#1f5dff",fillColorDarkMode:"#648FFF",textColor:"black",textColorDarkMode:"white",highContrastColor:"#2963FF",highContrastColorDarkMode:"#92B4FF"},defaultPalette={name:"default",description:"The standard Doenet styles: blue, red, orange, purple, black, and gray.",styles:{1:{...DEFAULT_STYLE_VALUES},2:{lineColor:"#D4042D",lineColorDarkMode:"#F1466A",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#D4042D",markerColorDarkMode:"#F1466A",markerOpacity:.7,markerStyle:"square",markerStyleWord:"square",markerSize:5,fillColor:"#D4042D",fillColorDarkMode:"#F1466A",fillOpacity:.3,textColor:"#D4042D",textColorDarkMode:"#FF7A7A",highContrastColor:"#D4042D",highContrastColorDarkMode:"#FF7A7A"},3:{lineColor:"#a6510c",lineColorDarkMode:"#F19143",lineOpacity:.7,lineWidth:3,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#a6510c",markerColorDarkMode:"#F19143",markerOpacity:.7,markerStyle:"triangle",markerStyleWord:"triangle",markerSize:5,fillColor:"#a6510c",fillColorDarkMode:"#F19143",fillOpacity:.3,textColor:"#BE5A0E",textColorDarkMode:"#FFA94D",highContrastColor:"#BE5A0E",highContrastColorDarkMode:"#FFA94D"},4:{lineColor:"#644CD6",lineColorDarkMode:"#9F8FE8",lineColorWordDarkMode:"purple",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#644CD6",markerColorDarkMode:"#9F8FE8",markerColorWordDarkMode:"purple",markerOpacity:.7,markerStyle:"diamond",markerStyleWord:"diamond",markerSize:5,fillColor:"#644CD6",fillColorDarkMode:"#9F8FE8",fillColorWordDarkMode:"purple",fillOpacity:.3,textColor:"#644CD6",textColorDarkMode:"#B0A4EE",highContrastColor:"#644CD6",highContrastColorDarkMode:"#B0A4EE"},5:{lineColor:"black",lineColorDarkMode:"white",lineOpacity:1,lineWidth:1,lineWidthWord:"thin",lineStyle:"solid",lineStyleWord:"",markerColor:"black",markerColorDarkMode:"white",markerOpacity:1,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"black",fillColorDarkMode:"white",fillOpacity:.7,textColor:"black",textColorDarkMode:"white",highContrastColor:"black",highContrastColorDarkMode:"white"},6:{lineColor:"#636363",lineColorDarkMode:"#CCCCCC",lineOpacity:.7,lineWidth:1,lineWidthWord:"thin",lineStyle:"dotted",lineStyleWord:"dotted",markerColor:"#636363",markerColorDarkMode:"#CCCCCC",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"#636363",fillColorDarkMode:"#CCCCCC",fillOpacity:.3,textColor:"#757575",textColorDarkMode:"#B0B0B0",highContrastColor:"#757575",highContrastColorDarkMode:"#B0B0B0"}}},okabeItoPalette={name:"okabeIto",description:"Colorblind-friendly blues, oranges, greens, and purples adapted from the Okabe-Ito palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#0072b2",markerColor:"#0072b2",fillColor:"#0072b2",highContrastColor:"#0072b2",lineColorDarkMode:"#0072b2",markerColorDarkMode:"#0072b2",fillColorDarkMode:"#0072b2",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#c15400",markerColor:"#c15400",fillColor:"#c15400",textColor:"#c15400",highContrastColor:"#c15400",lineColorDarkMode:"#d55e00",markerColorDarkMode:"#d55e00",fillColorDarkMode:"#d55e00",textColorDarkMode:"#d55e00",lineWidth:2,markerStyle:"square"},3:{lineColor:"#009e73",markerColor:"#009e73",fillColor:"#009e73",textColor:"#008561",highContrastColor:"#008561",lineColorDarkMode:"#009e73",markerColorDarkMode:"#009e73",fillColorDarkMode:"#009e73",textColorDarkMode:"#009e73",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#cc79a7",markerColor:"#cc79a7",fillColor:"#cc79a7",textColor:"#a35f85",highContrastColor:"#a35f85",lineColorWord:"purple",markerColorWord:"purple",fillColorWord:"purple",lineColorDarkMode:"#cc79a7",markerColorDarkMode:"#cc79a7",fillColorDarkMode:"#cc79a7",textColorDarkMode:"#cc79a7",lineColorWordDarkMode:"purple",markerColorWordDarkMode:"purple",fillColorWordDarkMode:"purple",textColorWordDarkMode:"purple",highContrastColorWordDarkMode:"purple",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#5a5513",markerColor:"#5a5513",fillColor:"#5a5513",textColor:"#5a5513",highContrastColor:"#5a5513",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#f0e442",markerColorDarkMode:"#f0e442",fillColorDarkMode:"#f0e442",textColorDarkMode:"#f0e442",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#499bca",markerColor:"#499bca",fillColor:"#499bca",textColor:"#397ba1",highContrastColor:"#397ba1",lineColorWord:"skyblue",markerColorWord:"skyblue",fillColorWord:"skyblue",textColorWord:"skyblue",highContrastColorWord:"skyblue",lineColorDarkMode:"#56b4e9",markerColorDarkMode:"#56b4e9",fillColorDarkMode:"#56b4e9",textColorDarkMode:"#56b4e9",lineColorWordDarkMode:"skyblue",markerColorWordDarkMode:"skyblue",fillColorWordDarkMode:"skyblue",textColorWordDarkMode:"skyblue",highContrastColorWordDarkMode:"skyblue",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#c58700",markerColor:"#c58700",fillColor:"#c58700",textColor:"#9d6b00",highContrastColor:"#9d6b00",lineColorWord:"goldenrod",markerColorWord:"goldenrod",fillColorWord:"goldenrod",textColorWord:"goldenrod",highContrastColorWord:"goldenrod",lineColorDarkMode:"#e69f00",markerColorDarkMode:"#e69f00",fillColorDarkMode:"#e69f00",textColorDarkMode:"#e69f00",lineColorWordDarkMode:"goldenrod",markerColorWordDarkMode:"goldenrod",fillColorWordDarkMode:"goldenrod",textColorWordDarkMode:"goldenrod",highContrastColorWordDarkMode:"goldenrod",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"}}},tolBrightPalette={name:"tolBright",description:"Colorblind-friendly bright blues, reds, greens, and purples from Paul Tol's bright palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#4477aa",markerColor:"#4477aa",fillColor:"#4477aa",highContrastColor:"#4477aa",lineColorDarkMode:"#4477aa",markerColorDarkMode:"#4477aa",fillColorDarkMode:"#4477aa",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#ee6677",markerColor:"#ee6677",fillColor:"#ee6677",textColor:"#bf515e",highContrastColor:"#bf515e",lineColorDarkMode:"#ee6677",markerColorDarkMode:"#ee6677",fillColorDarkMode:"#ee6677",textColorDarkMode:"#ee6677",lineWidth:2,markerStyle:"square"},3:{lineColor:"#228833",markerColor:"#228833",fillColor:"#228833",textColor:"#228833",highContrastColor:"#228833",lineColorDarkMode:"#228833",markerColorDarkMode:"#228833",fillColorDarkMode:"#228833",textColorDarkMode:"#3d8e47",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#a29534",markerColor:"#a29534",fillColor:"#a29534",textColor:"#817628",highContrastColor:"#817628",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#ccbb44",markerColorDarkMode:"#ccbb44",fillColorDarkMode:"#ccbb44",textColorDarkMode:"#ccbb44",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#4d9db8",markerColor:"#4d9db8",fillColor:"#4d9db8",textColor:"#3c7d94",highContrastColor:"#3c7d94",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#66ccee",markerColorDarkMode:"#66ccee",fillColorDarkMode:"#66ccee",textColorDarkMode:"#66ccee",lineColorWordDarkMode:"cyan",markerColorWordDarkMode:"cyan",fillColorWordDarkMode:"cyan",textColorWordDarkMode:"cyan",highContrastColorWordDarkMode:"cyan",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#aa3377",markerColor:"#aa3377",fillColor:"#aa3377",textColor:"#aa3377",highContrastColor:"#aa3377",lineColorDarkMode:"#aa3377",markerColorDarkMode:"#aa3377",fillColorDarkMode:"#aa3377",textColorDarkMode:"#b5648c",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#bbbbbb",markerColorDarkMode:"#bbbbbb",fillColorDarkMode:"#bbbbbb",textColorDarkMode:"#bbbbbb",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"}}},tolMutedPalette={name:"tolMuted",description:"Nine colorblind-friendly muted styles from Paul Tol's muted palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#332288",markerColor:"#332288",fillColor:"#332288",highContrastColor:"#332288",lineColorWord:"indigo",markerColorWord:"indigo",fillColorWord:"indigo",highContrastColorWord:"indigo",lineColorDarkMode:"#8a86e8",markerColorDarkMode:"#8a86e8",fillColorDarkMode:"#8a86e8",lineColorWordDarkMode:"indigo",markerColorWordDarkMode:"indigo",fillColorWordDarkMode:"indigo",highContrastColorWordDarkMode:"indigo",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#669ab5",markerColor:"#669ab5",fillColor:"#669ab5",textColor:"#507a90",highContrastColor:"#507a90",lineColorDarkMode:"#88ccee",markerColorDarkMode:"#88ccee",fillColorDarkMode:"#88ccee",textColorDarkMode:"#88ccee",lineWidth:2,markerStyle:"square"},3:{lineColor:"#41a393",markerColor:"#41a393",fillColor:"#41a393",textColor:"#328175",highContrastColor:"#328175",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#44aa99",markerColorDarkMode:"#44aa99",fillColorDarkMode:"#44aa99",textColorDarkMode:"#44aa99",lineColorWordDarkMode:"teal",markerColorWordDarkMode:"teal",fillColorWordDarkMode:"teal",textColorWordDarkMode:"teal",highContrastColorWordDarkMode:"teal",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#117733",markerColor:"#117733",fillColor:"#117733",textColor:"#117733",highContrastColor:"#117733",lineColorDarkMode:"#117733",markerColorDarkMode:"#117733",fillColorDarkMode:"#117733",textColorDarkMode:"#548a5f",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#989833",markerColor:"#989833",fillColor:"#989833",textColor:"#787827",highContrastColor:"#787827",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#999933",markerColorDarkMode:"#999933",fillColorDarkMode:"#999933",textColorDarkMode:"#999933",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#867c46",markerColor:"#867c46",fillColor:"#867c46",textColor:"#7f7542",highContrastColor:"#7f7542",lineColorWord:"tan",markerColorWord:"tan",fillColorWord:"tan",textColorWord:"tan",highContrastColorWord:"tan",lineColorDarkMode:"#ddcc77",markerColorDarkMode:"#ddcc77",fillColorDarkMode:"#ddcc77",textColorDarkMode:"#ddcc77",lineColorWordDarkMode:"tan",markerColorWordDarkMode:"tan",fillColorWordDarkMode:"tan",textColorWordDarkMode:"tan",highContrastColorWordDarkMode:"tan",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#cc6677",markerColor:"#cc6677",fillColor:"#cc6677",textColor:"#b35968",highContrastColor:"#b35968",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#cc6677",markerColorDarkMode:"#cc6677",fillColorDarkMode:"#cc6677",textColorDarkMode:"#cc6677",lineColorWordDarkMode:"pink",markerColorWordDarkMode:"pink",fillColorWordDarkMode:"pink",textColorWordDarkMode:"pink",highContrastColorWordDarkMode:"pink",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#882255",markerColor:"#882255",fillColor:"#882255",textColor:"#882255",highContrastColor:"#882255",lineColorWord:"maroon",markerColorWord:"maroon",fillColorWord:"maroon",textColorWord:"maroon",highContrastColorWord:"maroon",lineColorDarkMode:"#924b69",markerColorDarkMode:"#924b69",fillColorDarkMode:"#924b69",textColorDarkMode:"#a17083",lineColorWordDarkMode:"maroon",markerColorWordDarkMode:"maroon",fillColorWordDarkMode:"maroon",textColorWordDarkMode:"maroon",highContrastColorWordDarkMode:"maroon",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#aa4499",markerColor:"#aa4499",fillColor:"#aa4499",textColor:"#aa4499",highContrastColor:"#aa4499",lineColorDarkMode:"#aa4499",markerColorDarkMode:"#aa4499",fillColorDarkMode:"#aa4499",textColorDarkMode:"#b262a3",lineWidth:2,lineStyle:"dashed",markerStyle:"square"}}},tolHighContrastPalette={name:"tolHighContrast",description:"Four maximum-distinction styles from Paul Tol's high-contrast palette, distinguishable even in grayscale.",styles:{1:{lineColor:"#004488",markerColor:"#004488",fillColor:"#004488",highContrastColor:"#004488",lineColorDarkMode:"#496194",markerColorDarkMode:"#496194",fillColorDarkMode:"#496194",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#b88d29",markerColor:"#b88d29",fillColor:"#b88d29",textColor:"#92701f",highContrastColor:"#92701f",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ddaa33",markerColorDarkMode:"#ddaa33",fillColorDarkMode:"#ddaa33",textColorDarkMode:"#ddaa33",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"square"},3:{lineColor:"#bb5566",markerColor:"#bb5566",fillColor:"#bb5566",textColor:"#bb5566",highContrastColor:"#bb5566",lineColorDarkMode:"#c06976",markerColorDarkMode:"#c06976",fillColorDarkMode:"#c06976",textColorDarkMode:"#c06976",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"diamond"}}},ibmPalette={name:"ibm",description:"Five colorblind-friendly styles from the IBM Design Library accessible palette, with varied marker shapes.",styles:{1:{lineColor:"#648fff",markerColor:"#648fff",fillColor:"#648fff",highContrastColor:"#4f71cb",lineColorDarkMode:"#648fff",markerColorDarkMode:"#648fff",fillColorDarkMode:"#648fff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#6a53d5",markerColor:"#6a53d5",fillColor:"#6a53d5",textColor:"#6a53d5",highContrastColor:"#6a53d5",lineColorDarkMode:"#785ef0",markerColorDarkMode:"#785ef0",fillColorDarkMode:"#785ef0",textColorDarkMode:"#7f69f0",lineWidth:2,markerStyle:"square"},3:{lineColor:"#dc267f",markerColor:"#dc267f",fillColor:"#dc267f",textColor:"#dc267f",highContrastColor:"#dc267f",lineColorWord:"magenta",markerColorWord:"magenta",fillColorWord:"magenta",textColorWord:"magenta",highContrastColorWord:"magenta",lineColorDarkMode:"#dc267f",markerColorDarkMode:"#dc267f",fillColorDarkMode:"#dc267f",textColorDarkMode:"#dd4186",lineColorWordDarkMode:"magenta",markerColorWordDarkMode:"magenta",fillColorWordDarkMode:"magenta",textColorWordDarkMode:"magenta",highContrastColorWordDarkMode:"magenta",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#fe6100",markerColor:"#fe6100",fillColor:"#fe6100",textColor:"#cb4b00",highContrastColor:"#cb4b00",lineColorDarkMode:"#fe6100",markerColorDarkMode:"#fe6100",fillColorDarkMode:"#fe6100",textColorDarkMode:"#fe6100",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#865a00",markerColor:"#865a00",fillColor:"#865a00",textColor:"#865a00",highContrastColor:"#865a00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffb000",markerColorDarkMode:"#ffb000",fillColorDarkMode:"#ffb000",textColorDarkMode:"#ffb000",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"triangleDown"}}},grayscalePalette={name:"grayscale",description:"Four grays with maximum luminance separation, for readers who distinguish styles by lightness alone.",styles:{1:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",highContrastColorDarkMode:"#ffffff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#323232",markerColor:"#323232",fillColor:"#323232",textColor:"#323232",highContrastColor:"#323232",lineColorWord:"dark gray",markerColorWord:"dark gray",fillColorWord:"dark gray",textColorWord:"dark gray",highContrastColorWord:"dark gray",lineColorDarkMode:"#c7c7c7",markerColorDarkMode:"#c7c7c7",fillColorDarkMode:"#c7c7c7",textColorDarkMode:"#c7c7c7",highContrastColorDarkMode:"#c7c7c7",lineColorWordDarkMode:"light gray",markerColorWordDarkMode:"light gray",fillColorWordDarkMode:"light gray",textColorWordDarkMode:"light gray",highContrastColorWordDarkMode:"light gray",lineWidth:2,markerStyle:"square"},3:{lineColor:"#616161",markerColor:"#616161",fillColor:"#616161",textColor:"#616161",highContrastColor:"#616161",lineColorDarkMode:"#929292",markerColorDarkMode:"#929292",fillColorDarkMode:"#929292",textColorDarkMode:"#929292",highContrastColorDarkMode:"#929292",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#767676",highContrastColor:"#767676",lineColorWord:"light gray",markerColorWord:"light gray",fillColorWord:"light gray",textColorWord:"light gray",highContrastColorWord:"light gray",lineColorDarkMode:"#626262",markerColorDarkMode:"#626262",fillColorDarkMode:"#626262",textColorDarkMode:"#7d7d7d",highContrastColorDarkMode:"#7d7d7d",lineColorWordDarkMode:"dark gray",markerColorWordDarkMode:"dark gray",fillColorWordDarkMode:"dark gray",textColorWordDarkMode:"dark gray",highContrastColorWordDarkMode:"dark gray",lineWidth:2,markerStyle:"diamond"}}},categoricalPalette={name:"categorical",description:"Ten maximally varied hues adapted from the Category10 sequence, for documents needing many obviously distinct styles.",styles:{1:{lineColor:"#1f77b4",markerColor:"#1f77b4",fillColor:"#1f77b4",highContrastColor:"#1f77b4",lineColorDarkMode:"#5ba3dd",markerColorDarkMode:"#5ba3dd",fillColorDarkMode:"#5ba3dd",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#e7730c",markerColor:"#e7730c",fillColor:"#e7730c",textColor:"#b95b07",highContrastColor:"#b95b07",lineColorDarkMode:"#ff9d3c",markerColorDarkMode:"#ff9d3c",fillColorDarkMode:"#ff9d3c",textColorDarkMode:"#ff9d3c",lineWidth:2,markerStyle:"square"},3:{lineColor:"#217a21",markerColor:"#217a21",fillColor:"#217a21",textColor:"#217a21",highContrastColor:"#217a21",lineColorDarkMode:"#2ca02c",markerColorDarkMode:"#2ca02c",fillColorDarkMode:"#2ca02c",textColorDarkMode:"#2ca02c",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#d62728",markerColor:"#d62728",fillColor:"#d62728",textColor:"#d62728",highContrastColor:"#d62728",lineColorDarkMode:"#e2494a",markerColorDarkMode:"#e2494a",fillColorDarkMode:"#e2494a",textColorDarkMode:"#e2494a",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#9467bd",markerColor:"#9467bd",fillColor:"#9467bd",textColor:"#8e62b5",highContrastColor:"#8e62b5",lineColorDarkMode:"#b48fd6",markerColorDarkMode:"#b48fd6",fillColorDarkMode:"#b48fd6",textColorDarkMode:"#b48fd6",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#7a4a41",markerColor:"#7a4a41",fillColor:"#7a4a41",textColor:"#7a4a41",highContrastColor:"#7a4a41",lineColorDarkMode:"#a9705f",markerColorDarkMode:"#a9705f",fillColorDarkMode:"#a9705f",textColorDarkMode:"#a9705f",lineColorWordDarkMode:"brown",markerColorWordDarkMode:"brown",fillColorWordDarkMode:"brown",textColorWordDarkMode:"brown",highContrastColorWordDarkMode:"brown",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#d670b7",markerColor:"#d670b7",fillColor:"#d670b7",textColor:"#ab5892",highContrastColor:"#ab5892",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#e377c2",markerColorDarkMode:"#e377c2",fillColorDarkMode:"#e377c2",textColorDarkMode:"#e377c2",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#7f7f7f",markerColor:"#7f7f7f",fillColor:"#7f7f7f",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#a8a8a8",markerColorDarkMode:"#a8a8a8",fillColorDarkMode:"#a8a8a8",textColorDarkMode:"#a8a8a8",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#6e6e12",markerColor:"#6e6e12",fillColor:"#6e6e12",textColor:"#6e6e12",highContrastColor:"#6e6e12",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#bcbd22",markerColorDarkMode:"#bcbd22",fillColorDarkMode:"#bcbd22",textColorDarkMode:"#bcbd22",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,lineStyle:"dashed",markerStyle:"square"},10:{lineColor:"#12a2b1",markerColor:"#12a2b1",fillColor:"#12a2b1",textColor:"#0c818e",highContrastColor:"#0c818e",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#17becf",markerColorDarkMode:"#17becf",fillColorDarkMode:"#17becf",textColorDarkMode:"#17becf",lineWidth:2,lineStyle:"dotted",markerStyle:"diamond"}}},grumpyNarwhalPalette={name:"grumpyNarwhal",description:"Six saturated hues — burnt orange, forest green, deep pink, arctic teal, gold, and purple — going neon in dark mode.",styles:{1:{lineColor:"#b34700",markerColor:"#b34700",fillColor:"#b34700",highContrastColor:"#b34700",lineColorDarkMode:"#ff5f00",markerColorDarkMode:"#ff5f00",fillColorDarkMode:"#ff5f00",lineColorWordDarkMode:"orange",markerColorWordDarkMode:"orange",fillColorWordDarkMode:"orange",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#1b7a1b",markerColor:"#1b7a1b",fillColor:"#1b7a1b",textColor:"#1b7a1b",highContrastColor:"#1b7a1b",lineColorDarkMode:"#39ff14",markerColorDarkMode:"#39ff14",fillColorDarkMode:"#39ff14",textColorDarkMode:"#39ff14",lineWidth:2,markerStyle:"square"},3:{lineColor:"#c20e67",markerColor:"#c20e67",fillColor:"#c20e67",textColor:"#c20e67",highContrastColor:"#c20e67",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#ff1493",markerColorDarkMode:"#ff1493",fillColorDarkMode:"#ff1493",textColorDarkMode:"#ff1493",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#007a8c",markerColor:"#007a8c",fillColor:"#007a8c",textColor:"#007a8c",highContrastColor:"#007a8c",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#00e5ff",markerColorDarkMode:"#00e5ff",fillColorDarkMode:"#00e5ff",textColorDarkMode:"#00e5ff",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#8a6d00",markerColor:"#8a6d00",fillColor:"#8a6d00",textColor:"#8a6d00",highContrastColor:"#8a6d00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffea00",markerColorDarkMode:"#ffea00",fillColorDarkMode:"#ffea00",textColorDarkMode:"#ffea00",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#b026ff",markerColor:"#b026ff",fillColor:"#b026ff",textColor:"#b026ff",highContrastColor:"#b026ff",lineColorDarkMode:"#b026ff",markerColorDarkMode:"#b026ff",fillColorDarkMode:"#b026ff",textColorDarkMode:"#b445ff",highContrastColorDarkMode:"#b445ff",lineWidth:2,markerStyle:"triangleLeft"}}};function deepFreezePalette(iA){for(const eA of Object.values(iA.styles)){for(const AA of Object.values(eA))typeof AA=="object"&&AA!==null&&Object.freeze(AA);Object.freeze(eA)}return Object.freeze(iA.styles),Object.freeze(iA)}function registerByKey(iA){return[iA.name.toLowerCase(),deepFreezePalette(iA)]}const STYLE_PALETTES=Object.assign(Object.create(null),Object.fromEntries([defaultPalette,okabeItoPalette,tolBrightPalette,tolMutedPalette,tolHighContrastPalette,ibmPalette,grayscalePalette,categoricalPalette,grumpyNarwhalPalette].map(registerByKey)));Object.freeze(STYLE_PALETTES),defaultPalette.name.toLowerCase(),Object.freeze(Object.keys(STYLE_PALETTES));var o=function(iA){var eA=iA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},t=function(iA){return .2126*o(iA.r)+.7152*o(iA.g)+.0722*o(iA.b)};function a11yPlugin(iA){iA.prototype.luminance=function(){return eA=t(this.rgba),(AA=2)===void 0&&(AA=0),tA===void 0&&(tA=Math.pow(10,AA)),Math.round(tA*eA)/tA+0;var eA,AA,tA},iA.prototype.contrast=function(eA){eA===void 0&&(eA="#FFF");var AA,tA,nA,rA,aA,oA,sA,lA=eA instanceof iA?eA:new iA(eA);return rA=this.rgba,aA=lA.toRgb(),oA=t(rA),sA=t(aA),AA=oA>sA?(oA+.05)/(sA+.05):(sA+.05)/(oA+.05),(tA=2)===void 0&&(tA=0),nA===void 0&&(nA=Math.pow(10,tA)),Math.floor(nA*AA)/nA+0},iA.prototype.isReadable=function(eA,AA){return eA===void 0&&(eA="#FFF"),AA===void 0&&(AA={}),this.contrast(eA)>=(oA=(aA=(tA=AA).size)===void 0?"normal":aA,(rA=(nA=tA.level)===void 0?"AA":nA)==="AAA"&&oA==="normal"?7:rA==="AA"&&oA==="large"?3:4.5);var tA,nA,rA,aA,oA}}function namesPlugin(iA,eA){var AA={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},tA={};for(var nA in AA)tA[AA[nA]]=nA;var rA={};iA.prototype.toName=function(aA){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var oA,sA,lA=tA[this.toHex()];if(lA)return lA;if(aA?.closest){var gA=this.toRgb(),cA=1/0,IA="black";if(!rA.length)for(var CA in AA)rA[CA]=new iA(AA[CA]).toRgb();for(var uA in AA){var dA=(oA=gA,sA=rA[uA],Math.pow(oA.r-sA.r,2)+Math.pow(oA.g-sA.g,2)+Math.pow(oA.b-sA.b,2));dA<cA&&(cA=dA,IA=uA)}return IA}},eA.string.push([function(aA){var oA=aA.toLowerCase(),sA=oA==="transparent"?"#0000":AA[oA];return sA?new iA(sA).toRgb():null},"name"])}k([a11yPlugin,namesPlugin]);let styleAttributes={lineColor:{componentType:"text",description:"Color used for line strokes (light mode)."},lineColorWord:{componentType:"text",description:"Human-readable name of the line color (light mode)."},lineColorDarkMode:{componentType:"text",description:"Color used for line strokes (dark mode)."},lineColorWordDarkMode:{componentType:"text",description:"Human-readable name of the line color (dark mode)."},lineOpacity:{componentType:"number",description:"Opacity of line strokes, 0 to 1."},lineWidth:{componentType:"number",description:"Stroke width for lines, in pixels."},lineWidthWord:{componentType:"text",description:"Human-readable name of the line width."},lineStyle:{componentType:"text",description:"Stroke style for lines.",toLowerCase:!0,validValues:[{value:"solid",description:"Continuous, unbroken stroke."},{value:"dashed",description:"Stroke composed of evenly-spaced dashes."},{value:"dotted",description:"Stroke composed of evenly-spaced dots."}]},lineStyleWord:{componentType:"text",description:"Human-readable name of the line style."},markerColor:{componentType:"text",description:"Color used for markers/points (light mode)."},markerColorWord:{componentType:"text",description:"Human-readable name of the marker color (light mode)."},markerColorDarkMode:{componentType:"text",description:"Color used for markers/points (dark mode)."},markerColorWordDarkMode:{componentType:"text",description:"Human-readable name of the marker color (dark mode)."},markerOpacity:{componentType:"number",description:"Opacity of markers/points, 0 to 1."},markerStyle:{componentType:"text",description:"Marker shape.",toLowerCase:!0,validValues:[{value:"circle",description:"Circular marker."},{value:"square",description:"Square marker."},{value:"triangle",description:'Triangular marker pointing up (alias for "triangleUp").'},{value:"triangleUp",description:"Triangular marker pointing up."},{value:"triangleDown",description:"Triangular marker pointing down."},{value:"triangleLeft",description:"Triangular marker pointing left."},{value:"triangleRight",description:"Triangular marker pointing right."},{value:"diamond",description:"Diamond-shaped marker."},{value:"cross",description:"Cross-shaped marker (×)."},{value:"plus",description:"Plus-shaped marker (+)."}]},markerStyleWord:{componentType:"text",description:"Human-readable name of the marker style."},markerSize:{componentType:"number",description:"Marker size in pixels."},markerFilled:{componentType:"boolean",description:"Whether the marker is rendered filled (true) or open (false). Has no effect when markerStyle is cross or plus, which have no interior."},fillColor:{componentType:"text",description:"Fill color used inside closed shapes (light mode)."},fillColorWord:{componentType:"text",description:"Human-readable name of the fill color (light mode)."},fillColorDarkMode:{componentType:"text",description:"Fill color used inside closed shapes (dark mode)."},fillColorWordDarkMode:{componentType:"text",description:"Human-readable name of the fill color (dark mode)."},fillOpacity:{componentType:"number",description:"Opacity of solid fills, 0 to 1."},fillPatternOpacity:{componentType:"number",description:"Opacity of pattern fills (non-solid fillStyle), 0 to 1."},fillStyle:{componentType:"text",description:"Fill pattern used inside closed shapes.",toLowerCase:!0,validValues:[{value:"solid",description:"Solid fill."},{value:"horizontal",description:"Horizontal line pattern."},{value:"vertical",description:"Vertical line pattern."},{value:"diagonal",description:"Diagonal line pattern (/)."},{value:"backDiagonal",description:"Back-diagonal line pattern (\\)."},{value:"dots",description:"Dots pattern."},{value:"diamonds",description:"Filled diamonds pattern."}]},fillStyleWord:{componentType:"text",description:"Human-readable name of the fill style."},textColor:{componentType:"text",description:"Text color (light mode)."},textColorWord:{componentType:"text",description:"Human-readable name of the text color (light mode)."},textColorDarkMode:{componentType:"text",description:"Text color (dark mode)."},textColorWordDarkMode:{componentType:"text",description:"Human-readable name of the text color (dark mode)."},highContrastColor:{componentType:"text",description:"High-contrast accent color (light mode)."},highContrastColorWord:{componentType:"text",description:"Human-readable name of the high-contrast accent color (light mode)."},highContrastColorDarkMode:{componentType:"text",description:"High-contrast accent color (dark mode)."},highContrastColorWordDarkMode:{componentType:"text",description:"Human-readable name of the high-contrast accent color (dark mode)."},backgroundColor:{componentType:"text",description:"Background color (light mode)."},backgroundColorWord:{componentType:"text",description:"Human-readable name of the background color (light mode)."},backgroundColorDarkMode:{componentType:"text",description:"Background color (dark mode)."},backgroundColorWordDarkMode:{componentType:"text",description:"Human-readable name of the background color (dark mode)."}};styleAttributes.markerStyle.validValues.filter(iA=>iA.value!=="cross"&&iA.value!=="plus");const MARKER_OVERRIDE_KEYS=["markerStyle","markerSize","markerFilled"],LINE_OVERRIDE_KEYS=["lineStyle","lineWidth"],FILL_OVERRIDE_KEYS=["fillOpacity","fillPatternOpacity","fillStyle"],markerOverrideAttributes=Object.fromEntries(MARKER_OVERRIDE_KEYS.map(iA=>[iA,styleAttributes[iA]])),lineOverrideAttributes=Object.fromEntries(LINE_OVERRIDE_KEYS.map(iA=>[iA,styleAttributes[iA]])),fillOverrideAttributes=Object.fromEntries(FILL_OVERRIDE_KEYS.map(iA=>[iA,styleAttributes[iA]]));({...markerOverrideAttributes,...lineOverrideAttributes,...fillOverrideAttributes});const STYLE_OVERRIDE_CATEGORIES={marker:markerOverrideAttributes,line:lineOverrideAttributes,fill:fillOverrideAttributes};for(const[iA,eA]of Object.entries(STYLE_OVERRIDE_CATEGORIES))for(const[AA,tA]of Object.entries(eA)){if(AA.toLowerCase().includes("color"))throw new Error(`Style override category "${iA}" contains color-related key "${AA}"; colors stay <styleDefinition>-only so per-styleNumber WCAG contrast diagnostics remain authoritative. If this is intentional, also reconcile the lowercase asymmetry in returnSelectedStyleStateVariableDefinition.`);if(AA.endsWith("Opacity")&&AA!=="fillOpacity"&&AA!=="fillPatternOpacity")throw new Error(`Style override category "${iA}" contains contrast-feeding opacity key "${AA}"; lineOpacity and markerOpacity feed the WCAG contrast diagnostic as an opacityMultiplier on the foreground alpha, so they stay <styleDefinition>-only alongside colors. Only fillOpacity and fillPatternOpacity are contrast-irrelevant and overridable.`);if(tA.componentType==="text"&&!tA.toLowerCase)throw new Error(`Style override key "${AA}" in category "${iA}" is text-typed but missing toLowerCase: true. Add toLowerCase: true to its styleAttributes entry, or move it out of the override surface.`)}Object.entries(styleAttributes).filter(([,iA])=>iA.toLowerCase).map(([iA])=>iA);var base32$1={exports:{}},hasRequiredBase32;function requireBase32(){return hasRequiredBase32||(hasRequiredBase32=1,(function(iA){(function(){var eA=typeof window=="object"?window:{},AA=!eA.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;AA&&(eA=commonjsGlobal);var tA=!eA.HI_BASE32_NO_COMMON_JS&&!0&&iA.exports,nA="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),rA={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},aA=[0,0,0,0,0,0,0,0],oA=function(pA,mA){mA.length>10&&(mA="..."+mA.substr(-10));var QA=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+pA+" bytes: "+mA+" <-");throw QA.position=pA,QA},sA=function(pA){for(var mA="",QA=pA.length,BA=0,hA=0,DA,EA;BA<QA;){if(DA=pA[BA++],DA<=127){mA+=String.fromCharCode(DA);continue}else DA>191&&DA<=223?(EA=DA&31,hA=1):DA<=239?(EA=DA&15,hA=2):DA<=247?(EA=DA&7,hA=3):oA(BA,mA);for(var fA=0;fA<hA;++fA)DA=pA[BA++],(DA<128||DA>191)&&oA(BA,mA),EA<<=6,EA+=DA&63;EA>=55296&&EA<=57343&&oA(BA,mA),EA>1114111&&oA(BA,mA),EA<=65535?mA+=String.fromCharCode(EA):(EA-=65536,mA+=String.fromCharCode((EA>>10)+55296),mA+=String.fromCharCode((EA&1023)+56320))}return mA},lA=function(pA){if(pA==="")return[];if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");pA=pA.replace(/=/g,"");for(var mA,QA,BA,hA,DA,EA,fA,NA,yA=[],bA=0,wA=pA.length,MA=0,vA=wA>>3<<3;MA<vA;)mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255,yA[bA++]=(fA<<5|NA)&255;var OA=wA-vA;return OA===2?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255):OA===4?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255):OA===5?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255):OA===7&&(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255),yA},gA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA++),DA=pA.charCodeAt(NA++),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[(hA<<3|DA>>>5)&31]+nA[DA&31];var bA=fA-yA;return bA===1?(mA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[mA<<2&31]+"======"):bA===2?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[QA<<4&31]+"===="):bA===3?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[BA<<1&31]+"==="):bA===4&&(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[hA<<3&31]+"="),EA},cA=function(pA){var mA,QA,BA,hA,DA,EA,fA=!1,NA="",yA=0,bA,wA=0,MA=pA.length;if(pA==="")return NA;do{for(aA[0]=aA[5],aA[1]=aA[6],aA[2]=aA[7],bA=wA;yA<MA&&bA<5;++yA)EA=pA.charCodeAt(yA),EA<128?aA[bA++]=EA:EA<2048?(aA[bA++]=192|EA>>6,aA[bA++]=128|EA&63):EA<55296||EA>=57344?(aA[bA++]=224|EA>>12,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63):(EA=65536+((EA&1023)<<10|pA.charCodeAt(++yA)&1023),aA[bA++]=240|EA>>18,aA[bA++]=128|EA>>12&63,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63);wA=bA-5,yA===MA&&++yA,yA>MA&&bA<6&&(fA=!0),mA=aA[0],bA>4?(QA=aA[1],BA=aA[2],hA=aA[3],DA=aA[4],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[(hA<<3|DA>>>5)&31]+nA[DA&31]):bA===1?NA+=nA[mA>>>3]+nA[mA<<2&31]+"======":bA===2?(QA=aA[1],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[QA<<4&31]+"===="):bA===3?(QA=aA[1],BA=aA[2],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[BA<<1&31]+"==="):(QA=aA[1],BA=aA[2],hA=aA[3],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[hA<<3&31]+"=")}while(!fA);return NA},IA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA++],DA=pA[NA++],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[(hA<<3|DA>>>5)&31]+nA[DA&31];var bA=fA-yA;return bA===1?(mA=pA[NA],EA+=nA[mA>>>3]+nA[mA<<2&31]+"======"):bA===2?(mA=pA[NA++],QA=pA[NA],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[QA<<4&31]+"===="):bA===3?(mA=pA[NA++],QA=pA[NA++],BA=pA[NA],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[BA<<1&31]+"==="):bA===4&&(mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[hA<<3&31]+"="),EA},CA=function(pA,mA){var QA=typeof pA!="string";return QA&&pA.constructor===ArrayBuffer&&(pA=new Uint8Array(pA)),QA?IA(pA):mA?gA(pA):cA(pA)},uA=function(pA,mA){if(!mA)return sA(lA(pA));if(pA==="")return"";if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");var QA,BA,hA,DA,EA,fA,NA,yA,bA="",wA=pA.indexOf("=");wA===-1&&(wA=pA.length);for(var MA=0,vA=wA>>3<<3;MA<vA;)QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)+String.fromCharCode((NA<<5|yA)&255);var OA=wA-vA;return OA===2?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)):OA===4?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)):OA===5?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)):OA===7&&(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)),bA},dA={encode:CA,decode:uA};uA.asBytes=lA,tA?iA.exports=dA:eA.base32=dA})()})(base32$1)),base32$1.exports}requireBase32();function groupCompositeRanges({children:iA,ranges:eA,isAbsent:AA=()=>!1,isBlank:tA=()=>!1,skipRange:nA=()=>!1,trimEnd:rA=lA=>lA,startInd:aA=0,endInd:oA=iA.length-1,removedInd:sA=null}){const lA=(eA??[]).flatMap(uA=>{const dA=shiftForRemovedChild(uA,sA);return dA&&dA.firstInd>=aA&&dA.lastInd<=oA?[{range:uA,...dA}]:[]}).sort((uA,dA)=>uA.firstInd-dA.firstInd||dA.lastInd-uA.lastInd),gA={range:null,firstInd:aA,lastInd:oA,nextInd:aA,eligibility:null,items:[],eligible:[]},cA=[gA];function IA(uA,dA){for(;uA.nextInd<dA;uA.nextInd++){const pA=iA[uA.nextInd];AA(pA)||(uA.items.push({kind:"child",value:pA,index:uA.nextInd}),uA.eligibility&&uA.eligible.push(uA.eligibility[uA.nextInd-uA.firstInd]??!1))}}function CA(){const uA=cA.pop();if(IA(uA,uA.lastInd+1),uA.items.length===0)return;const dA=cA[cA.length-1],pA=uA.items.filter(BA=>!isBlankGroup(BA,tA)),mA=uA.eligible.every((BA,hA)=>BA||isBlankGroup(uA.items[hA],tA)),QA=!!uA.range.asList&&mA&&pA.length>1;dA.items.push({kind:"composite",range:uA.range,asList:QA,items:QA?prepareListItems(uA.items,tA,rA):uA.items}),dA.eligibility&&dA.eligible.push(mA)}for(const{range:uA,firstInd:dA,lastInd:pA}of lA){for(;cA.length>1&&pA>cA[cA.length-1].lastInd;)CA();const mA=cA[cA.length-1];dA<mA.nextInd||(IA(mA,dA),mA.nextInd=pA+1,!nA(uA)&&cA.push({range:uA,firstInd:dA,lastInd:pA,nextInd:dA,eligibility:uA.potentialListComponents??null,items:[],eligible:[]}))}for(;cA.length>1;)CA();return IA(gA,oA+1),gA.items}function shiftForRemovedChild(iA,eA){let{firstInd:AA,lastInd:tA}=iA;if(eA===null)return{firstInd:AA,lastInd:tA};if(!(AA===eA||tA===eA))return AA>eA&&(AA-=1),tA>eA&&(tA-=1),{firstInd:AA,lastInd:tA}}function isBlankGroup(iA,eA){return iA.kind==="child"?eA(iA.value):iA.items.every(AA=>isBlankGroup(AA,eA))}function prepareListItems(iA,eA,AA){const tA=iA.findIndex(aA=>!isBlankGroup(aA,eA));let nA=iA.length-1;for(;nA>tA&&isBlankGroup(iA[nA],eA);)nA--;const rA=[];for(const[aA,oA]of iA.entries())aA<tA||aA>=nA?rA.push(oA):isBlankGroup(oA,eA)?oA.kind==="composite"&&rA.push(withoutBlankChildren(oA)):rA.push(trimItemEnd(oA,eA,AA));return rA}function withoutBlankChildren(iA){return{...iA,items:iA.items.flatMap(eA=>eA.kind==="composite"?[withoutBlankChildren(eA)]:[])}}function trimItemEnd(iA,eA,AA){if(iA.kind==="child"){const rA=AA(iA.value);return rA===iA.value?iA:{...iA,value:rA}}let tA=iA.items.length;for(;isBlankGroup(iA.items[tA-1],eA);)tA--;const nA=iA.items.slice(tA).flatMap(rA=>rA.kind==="composite"?[withoutBlankChildren(rA)]:[]);return{...iA,items:[...iA.items.slice(0,tA-1),trimItemEnd(iA.items[tA-1],eA,AA),...nA]}}const{gcd,lcm}=context.math,{mod}=context.math,defaultCreativeCommonsVersion="4.0";function creativeCommonsLicense(iA,eA,AA,tA){return{code:iA,name:`Creative Commons ${eA}`,description:tA,kind:"creative-commons",url:(nA=defaultCreativeCommonsVersion)=>`https://creativecommons.org/licenses/${AA}/${nA}/`}}function fixedUrlLicense(iA,eA,AA,tA,nA){return{code:iA,name:eA,description:tA,kind:nA,url:()=>AA}}const mediaLicenses=[creativeCommonsLicense("CC-BY","Attribution","by","Creative Commons Attribution: reuse with credit, including commercially."),creativeCommonsLicense("CC-BY-SA","Attribution-ShareAlike","by-sa","Creative Commons Attribution-ShareAlike: reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-ND","Attribution-NoDerivatives","by-nd","Creative Commons Attribution-NoDerivatives: reuse unchanged, with credit."),creativeCommonsLicense("CC-BY-NC","Attribution-NonCommercial","by-nc","Creative Commons Attribution-NonCommercial: reuse with credit for noncommercial purposes."),creativeCommonsLicense("CC-BY-NC-SA","Attribution-NonCommercial-ShareAlike","by-nc-sa","Creative Commons Attribution-NonCommercial-ShareAlike: noncommercial reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-NC-ND","Attribution-NonCommercial-NoDerivatives","by-nc-nd","Creative Commons Attribution-NonCommercial-NoDerivatives: reuse unchanged for noncommercial purposes, with credit."),fixedUrlLicense("CC0","CC0 1.0 Public Domain Dedication","https://creativecommons.org/publicdomain/zero/1.0/","Creative Commons Zero: the creator has dedicated the work to the public domain.","public-domain"),fixedUrlLicense("PDM","Public Domain Mark 1.0","https://creativecommons.org/publicdomain/mark/1.0/","Public Domain Mark: the work is free of known copyright restrictions.","public-domain"),fixedUrlLicense("GFDL","GNU Free Documentation License","https://www.gnu.org/licenses/fdl-1.3.html","GNU Free Documentation License: copyleft license common on Wikimedia.","license"),fixedUrlLicense("FAL","Free Art License 1.3","https://artlibre.org/licence/lal/en/","Free Art License: copyleft license for artistic works.","license"),fixedUrlLicense("OGL","Open Government Licence v3.0 (UK)","https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/","UK Open Government Licence: reuse government material with attribution.","license"),fixedUrlLicense("MIT","MIT License","https://opensource.org/license/mit","MIT License: permissive license common for icon and illustration sets.","license"),fixedUrlLicense("APACHE-2.0","Apache License 2.0","https://www.apache.org/licenses/LICENSE-2.0","Apache License 2.0: permissive license common for icon and illustration sets.","license")];Object.fromEntries(mediaLicenses.map(iA=>[iA.code.toLowerCase(),iA]));var cssesc_1,hasRequiredCssesc;function requireCssesc(){if(hasRequiredCssesc)return cssesc_1;hasRequiredCssesc=1;var iA={},eA=iA.hasOwnProperty,AA=function(sA,lA){if(!sA)return lA;var gA={};for(var cA in lA)gA[cA]=eA.call(sA,cA)?sA[cA]:lA[cA];return gA},tA=/[ -,\.\/:-@\[-\^`\{-~]/,nA=/[ -,\.\/:-@\[\]\^`\{-~]/,rA=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,aA=function oA(sA,lA){lA=AA(lA,oA.options),lA.quotes!="single"&&lA.quotes!="double"&&(lA.quotes="single");for(var gA=lA.quotes=="double"?'"':"'",cA=lA.isIdentifier,IA=sA.charAt(0),CA="",uA=0,dA=sA.length;uA<dA;){var pA=sA.charAt(uA++),mA=pA.charCodeAt(),QA=void 0;if(mA<32||mA>126){if(mA>=55296&&mA<=56319&&uA<dA){var BA=sA.charCodeAt(uA++);(BA&64512)==56320?mA=((mA&1023)<<10)+(BA&1023)+65536:uA--}QA="\\"+mA.toString(16).toUpperCase()+" "}else lA.escapeEverything?tA.test(pA)?QA="\\"+pA:QA="\\"+mA.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(pA)?QA="\\"+mA.toString(16).toUpperCase()+" ":pA=="\\"||!cA&&(pA=='"'&&gA==pA||pA=="'"&&gA==pA)||cA&&nA.test(pA)?QA="\\"+pA:QA=pA;CA+=QA}return cA&&(/^-[-\d]/.test(CA)?CA="\\-"+CA.slice(1):/\d/.test(IA)&&(CA="\\3"+IA+" "+CA.slice(1))),CA=CA.replace(rA,function(hA,DA,EA){return DA&&DA.length%2?hA:(DA||"")+EA}),!cA&&lA.wrap?gA+CA+gA:CA};return aA.options={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1},aA.version="3.0.0",cssesc_1=aA,cssesc_1}requireCssesc();function isBlankChild(iA){return typeof iA=="string"&&iA.trim()===""}function makeWrapperElement(iA,eA,AA){return{type:"element",name:eA,attributes:{},children:AA,data:{id:iA}}}function materializeGroups(iA,eA,AA){const tA=[];for(const nA of iA){if(nA.kind==="child"){nA.value!==null&&tA.push(nA.value);continue}if(nA.asList){const aA=nA.items.map(gA=>isBlankGroup(gA,isBlankChild)),oA=aA.indexOf(!1),sA=aA.lastIndexOf(!1),lA=nA.items.slice(oA,sA+1).filter((gA,cA)=>!aA[oA+cA]);eA||tA.push(...materializeGroups(nA.items.slice(0,oA),!1,AA)),AA.push(makeWrapperElement(nA.range.compositeIdx,"asList",materializeGroups(lA,!0,AA))),tA.push({id:nA.range.compositeIdx,annotation:"original"}),eA||tA.push(...materializeGroups(nA.items.slice(sA+1),!1,AA));continue}const rA=materializeGroups(nA.items,!1,AA);eA&&rA.length>1?(AA.push(makeWrapperElement(nA.range.compositeIdx,"_fragment",rA)),tA.push({id:nA.range.compositeIdx,annotation:"original"})):tA.push(...rA)}return tA}function applyCompositeListWrapping(iA,eA){const AA=groupCompositeRanges({children:iA,ranges:eA,isAbsent:rA=>rA===null,isBlank:isBlankChild,trimEnd:rA=>typeof rA=="string"?rA.trimEnd():rA}),tA=[];return{children:materializeGroups(AA,!1,tA),wrapperElements:tA}}function propRename(iA,eA){for(const[AA,tA]of Object.entries(eA))iA.hasOwnProperty(AA)&&(iA[tA]=iA[AA],delete iA[AA])}function elementRename(iA,eA){iA.name=eA}function booleanInputJsToRust(iA){iA.immediateValue=iA.value}function pointJsToRust(iA){const eA=iA.numericalXs;iA.x={math_object:eA[0].toString()},eA.length>=2&&(iA.y={math_object:eA[1].toString()}),eA.length>=3&&(iA.z={math_object:eA[2].toString()}),iA.coordsLatex=iA.latex}function refJsToRust(iA,eA){iA.referent=eA[iA.targetRendererId]}function sectionJsToRust(iA,eA){iA.divisionType=eA.name,iA.divisionDepth=iA.level;const AA=iA.titleChildName!=null?Number(iA.titleChildName):void 0,tA=AA!==void 0&&Number.isInteger(AA);if(iA.xrefLabel={label:(tA?iA.titlePrefix:iA.title)??"",global_ident:iA.sectionNumber??"",local_ident:iA.sectionNumber??"",preferred_form:"Global"},iA.codeNumber="",tA){iA.title=AA;const nA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);nA!==-1&&eA.children.splice(nA,1)}else iA.title=null}function tableJsToRust(iA,eA){iA.xrefLabel={label:iA.tableName??"",global_ident:iA.tableEnumeration??"",local_ident:iA.tableEnumeration??"",preferred_form:"Global"},iA.codeNumber=iA.tableEnumeration??"",iA.titlePrefix=iA.suppressTableNameInTitle?"":iA.tableNamePrefix??"",iA.divisionType="table",iA.divisionDepth=3;const AA=iA.titleChildName!=null?Number(iA.titleChildName):void 0;if(AA!==void 0&&Number.isInteger(AA)){iA.title=AA;const nA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);nA!==-1&&eA.children.splice(nA,1)}else iA.title=null;delete iA.tableEnumeration,delete iA.titleChildName,delete iA.tableName,delete iA.tableNamePrefix}function textJsToRust(iA){iA.value=iA.text}function childInstructionToContent(iA,eA){return typeof iA=="string"?iA:(eA[iA.id]=iA.componentIdx,{id:iA.componentIdx,annotation:"original"})}function applyElementJsToRustFixups(iA,eA){if(!(iA?.type!=="element"||!iA.data.props))switch(iA.name){case"angle":propRename(iA.data.props,{latexForRenderer:"latex"});break;case"cell":propRename(iA.data.props,{inHeader:"header"});break;case"booleanInput":booleanInputJsToRust(iA.data.props);break;case"text":textJsToRust(iA.data.props);break;case"aside":case"article":case"section":sectionJsToRust(iA.data.props,iA),iA.name==="section"&&elementRename(iA,"division");break;case"table":tableJsToRust(iA.data.props,iA);break;case"point":pointJsToRust(iA.data.props);break;case"ref":refJsToRust(iA.data.props,eA);break;case"coords":elementRename(iA,"math");break}}function flatDastFromJS(iA,eA){const AA=eA[0].rendererStatesToUpdate,tA=[],nA={[iA.id]:iA.componentIdx};tA[iA.componentIdx]={type:"element",name:iA.componentType,attributes:{},children:[],data:{id:iA.componentIdx,action_names:Object.keys(iA.actions)}};for(const aA of AA){let oA=tA[aA.componentIdx];if(oA||(oA=tA[aA.componentIdx]={type:"element",name:"",attributes:{},children:[],data:{id:aA.componentIdx}}),oA.type==="element"&&(oA.data.props=aA.stateValues,aA.childrenInstructions)){const sA=[];for(const cA of aA.childrenInstructions){if(cA==null){sA.push(null);continue}if(sA.push(childInstructionToContent(cA,nA)),typeof cA=="string")continue;const IA=tA[cA.componentIdx];IA?IA.type==="element"&&(IA.name=cA.componentType,IA.data.id=cA.componentIdx,IA.data.action_names=Object.keys(cA.actions)):tA[cA.componentIdx]={type:"element",name:cA.componentType,attributes:{},children:[],data:{id:cA.componentIdx,action_names:Object.keys(cA.actions)}}}const{children:lA,wrapperElements:gA}=applyCompositeListWrapping(sA,aA.stateValues?._compositeReplacementActiveRange);oA.children=lA;for(const cA of gA)tA[cA.data.id]=cA}}for(const aA of tA)applyElementJsToRustFixups(aA,nA);return{type:"root",children:[{id:iA.componentIdx,annotation:"original"}],elements:tA,warnings:[]}}function collectInstructionMaps(iA,eA={},AA={}){for(const tA of iA)for(const nA of tA.rendererStatesToUpdate)for(const rA of nA.childrenInstructions??[])rA!=null&&typeof rA!="string"&&(eA[rA.componentIdx]=rA.componentType,AA[rA.id]=rA.componentIdx);return{componentIdxToName:eA,doenetIdToComponentIdx:AA}}function seedInstructionMaps(iA,eA){const AA={[iA.componentIdx]:iA.componentType},tA={[iA.id]:iA.componentIdx};return collectInstructionMaps(eA,AA,tA),{componentIdxToName:AA,doenetIdToComponentIdx:tA}}function flatDastUpdateFromJS(iA,eA,AA={}){const tA={};function nA(rA,aA){const oA=tA[rA];oA?(oA.changedState={...oA.changedState,...aA.changedState},aA.newChildren&&(oA.newChildren=aA.newChildren),aA.newFlatDastElement&&(oA.newFlatDastElement=aA.newFlatDastElement)):tA[rA]=aA}for(const rA of iA)for(const aA of rA.rendererStatesToUpdate){const{componentIdx:oA,stateValues:sA,childrenInstructions:lA}=aA,gA=[];if(lA)for(const dA of lA){if(dA==null){gA.push(null);continue}gA.push(childInstructionToContent(dA,AA))}const{children:cA,wrapperElements:IA}=applyCompositeListWrapping(gA,sA?._compositeReplacementActiveRange),CA={type:"element",name:eA[oA]??"",children:cA,data:{id:oA,props:{...sA}}};applyElementJsToRustFixups(CA,AA);const uA={changedState:CA.data.props};lA&&(uA.newChildren=CA.children),nA(oA,uA);for(const dA of IA)nA(dA.data.id,{newFlatDastElement:dA})}return tA}async function resolvePathImmediatelyToNodeIdx(iA,eA,AA,tA=0){if(!AA.core)return-1;const nA=iA.match(/^([\w-]+)((\[\d+\])*)/);if(!nA)throw Error(`Invalid name to resolve: ${iA}`);const rA=[{type:"flatPathPart",name:nA[1],index:extractIndex(nA[2])}];let aA=iA.slice(nA[0].length);for(;aA.length>0;){const oA=aA.match(/^\.([\w-]+)((\[\d+\])*)/);if(!oA)throw Error(`Invalid name to resolve: ${iA}`);rA.push({type:"flatPathPart",name:oA[1],index:extractIndex(oA[2])}),aA=aA.slice(oA[0].length)}try{let oA=eA.resolve_path({path:rA},tA,!1);for(;oA.unresolvedPath!==null;){if(oA.unresolvedPath[0].name!=="")return-1;const sA=AA.core._components[oA.nodeIdx];if(!AA.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType,includeNonStandard:!0})||sA.isExpanded)return-1;const gA=oA.unresolvedPath[0].index;if(gA.length===0)throw Error("Something went wrong as we have a ref resolution without a name or an index");if(typeof gA[0].value[0]!="string")throw Error("Not implemented: we have not implemented `resolvePathImmediatelyToNodeIdx` for paths that contain references to nodes.");await sA.stateValues.readyToExpandWhenResolved,await expandCompositeComponent({core:AA.core,component:sA}),oA=eA.resolve_path({path:rA},tA,!1)}return oA.nodeIdx}catch(oA){return console.error(oA),-1}}function extractIndex(iA){const eA=[];for(const AA of iA.matchAll(/\[(\d+)\]/g))eA.push({value:[AA[1]]});return eA}const JS_CORE_ACTION_NAME_OVERRIDES={point:{move:"movePoint"},graph:{changeBoundingBox:"changeAxisLimits"}};function translateJsCoreActionName(iA,eA){return iA==null?eA:JS_CORE_ACTION_NAME_OVERRIDES[iA]?.[eA]??eA}const WASM_FILE_NAME="lib_doenetml_worker_bg.wasm";function injectedGlobal(iA){const eA=globalThis[iA];return typeof eA=="string"?eA:void 0}function decodeWasmDataUrl(iA){try{const eA=iA.split(",")[1],AA=atob(eA),tA=new Uint8Array(AA.length);for(let nA=0;nA<AA.length;nA++)tA[nA]=AA.charCodeAt(nA);return tA.buffer}catch(eA){return console.warn("Error while decoding the WASM data URL:",eA),null}}function wasmUrlCandidates(){const iA=[];function eA(nA){iA.includes(nA)||iA.push(nA)}const AA=injectedGlobal("__doenetWorkerWasmUrl");AA!==void 0&&eA(AA);const tA=[injectedGlobal("__doenetWorkerScriptUrl"),typeof location<"u"?location.href:void 0];for(const nA of tA)if(nA!==void 0)try{eA(new URL(WASM_FILE_NAME,nA).href)}catch{}return eA(`https://cdn.jsdelivr.net/npm/@doenet/standalone@0.7.27-dev.649/doenetml-worker/${WASM_FILE_NAME}`),iA}async function resolveWasmInput(){const iA=injectedGlobal("__doenetWorkerWasmUrl");if(iA!==void 0&&/^data:.*;base64,/.test(iA)){const AA=decodeWasmDataUrl(iA);if(AA)return AA}let eA;for(const AA of wasmUrlCandidates())if(!AA.startsWith("data:"))try{const tA=await fetch(AA);if(!tA.ok)throw Error(`HTTP ${tA.status} fetching ${AA}`);const nA=tA.headers.get("Content-Type")??"";if(/^text\/html\b/i.test(nA))throw Error(`Fetching ${AA} returned ${nA}, an HTML page rather than WebAssembly`);return tA}catch(tA){eA=tA}throw eA??Error("No URL to load the core WASM from")}if(typeof globalThis<"u"&&!globalThis.document){const iA=new URL(typeof location<"u"?location.href:"http://localhost"),eA=iA.protocol+"//"+iA.host+iA.pathname;globalThis.document={URL:eA,baseURI:eA}}let wasmInitPromise=null;function ensureWasmInitialized(){return wasmInitPromise||(wasmInitPromise=(async()=>{const iA=await resolveWasmInput();return await __wbg_init({module_or_path:iA})})().catch(iA=>{throw wasmInitPromise=null,iA})),wasmInitPromise}const RELEASED_INITIALIZATION_DATA_MESSAGE="Cannot initialize from the document DAST: it was released when the previous initialization completed. Call setSource again before re-initializing.",DOCUMENT_BUILD_ERROR_NAME="DoenetDocumentBuildError";function readPanicMessage(){try{return take_last_panic_message()??void 0}catch(iA){console.error(iA);return}}function discardStalePanicMessage(){readPanicMessage()}function throwAsDocumentBuildError(iA,eA){const AA=iA instanceof Error?iA:new Error(String(iA??"unknown error"));throw AA.name=DOCUMENT_BUILD_ERROR_NAME,eA&&(AA.message=eA),AA}class CoreWorker{constructor(){this.wasm_initialized=!1,this.javascript_initialized=!1,this.source_set=!1,this._initializationDataReleased=!1,this.flags_set=!1,this.core_type="rust",this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!1,this._componentIdxToName={},this._doenetIdToComponentIdx={},this._javascriptInitialRenderDone=!1,this.isProcessingPromise=Promise.resolve(),this._hostedCores=new Map,this._nextHostedCoreId=1,this._isHostedCore=!1}async createCore(eA){const AA=new CoreWorker;AA._isHostedCore=!0,expose(AA,eA);const tA=this._nextHostedCoreId++;return this._hostedCores.set(tA,{core:AA,port:eA}),tA}async destroyCore(eA){const AA=this._hostedCores.get(eA);if(AA){this._hostedCores.delete(eA);try{await AA.core.terminate()}catch(tA){console.error("Error terminating hosted core",tA)}finally{AA.port.close()}}}setCoreType(eA){this.core_type=eA}async setSource(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setSource(eA.source)),this.doenetCore.set_source(eA.dast,eA.source),this.source_set=!0,this._initializationDataReleased=!1}catch(rA){throw console.error("Error when setting source",rA),rA}finally{nA()}}async setFlags(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setFlags(eA.flags)),this.doenetCore.set_flags(JSON.stringify(eA.flags)),this.flags_set=!0}finally{nA()}}async setLocaleData(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setLocaleData(eA.localeData))}finally{nA()}}async initializeJavascriptCore({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA}){const rA=this.isProcessingPromise;let{promise:aA,resolve:oA}=promiseWithResolver();this.isProcessingPromise=aA,await rA;let sA=!1;try{let lA=function(mA){return dA.update_root_names(mA)},gA=function(mA,QA,BA){return dA.resolve_path(mA,QA,BA)},cA=function(mA,QA){dA.add_nodes_to_resolver(mA,QA)},IA=function(mA,QA){dA.replace_index_resolutions_in_resolver(mA,QA)},CA=function(mA){dA.delete_nodes_from_resolver(mA)};if(!this.source_set||!this.flags_set||!this.javascriptCore||!this.doenetCore)throw Error("Cannot initialize javascript core before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);sA=!0,discardStalePanicMessage();let uA=this.doenetCore.return_normalized_dast_root();const dA=this.doenetCore,pA=await this.javascriptCore.initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA,normalizedRoot:uA,addNodesToResolver:cA,replaceIndexResolutionsInResolver:IA,deleteNodesFromResolver:CA,resolvePath:gA,updateRootNames:lA});return this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0,pA}catch(lA){if(console.error(lA),!sA)throw lA;throwAsDocumentBuildError(lA,readPanicMessage())}finally{oA()}}async generateJavascriptDast(eA,AA,tA,nA,rA,aA,oA,sA){const lA=this.isProcessingPromise;let{promise:gA,resolve:cA}=promiseWithResolver();if(this.isProcessingPromise=gA,await lA,!this.javascript_initialized||!this.javascriptCore)throw Error("Cannot return javascript dast before initializing javascript core");try{discardStalePanicMessage();const IA=await this.javascriptCore?.createCoreGenerateDast(eA,AA,tA,nA,rA,aA,oA,sA);if(IA?.success===!1){const CA=readPanicMessage();CA!==void 0&&throwAsDocumentBuildError(new Error(IA.errMsg??""),CA)}return IA}catch(IA){console.error(IA),throwAsDocumentBuildError(IA,readPanicMessage())}finally{cA()}}async returnDast({variantIndex:eA=1}={}){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");try{return this.core_type==="javascript"?await this.returnFlatDastFromJS(eA):this.doenetCore.return_dast()}catch(rA){throw console.error(rA),rA}finally{nA()}}async returnNormalizedDastRoot(){if(!this.source_set||!this.doenetCore)throw Error("Cannot return normalized dast root before setting source");if(this.core_type==="javascript")return{nodes:[]};if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);return this.doenetCore.return_normalized_dast_root()}async returnFlatDastFromJS(eA){if(!this.javascriptCore||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);let AA=this.doenetCore.return_normalized_dast_root();const tA=this.doenetCore;function nA(fA){return tA.update_root_names(fA)}function rA(fA,NA,yA){return tA.resolve_path(fA,NA,yA)}function aA(fA,NA){tA.add_nodes_to_resolver(fA,NA)}function oA(fA,NA){tA.replace_index_resolutions_in_resolver(fA,NA)}function sA(fA){tA.delete_nodes_from_resolver(fA)}await this.javascriptCore.initializeWorker({activityId:"a",docId:"a",requestedVariantIndex:eA,attemptNumber:1,normalizedRoot:AA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:rA,updateRootNames:nA}),this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0;const lA={coreId:"a",cid:null,initializeCounters:{}};let gA=null;this._javascriptUpdateBuffer=[];const cA=fA=>{fA.init?gA=fA.updateInstructions:this._capturingJavascriptUpdates&&fA.updateInstructions&&this._javascriptUpdateBuffer.push(...fA.updateInstructions)},IA=fA=>{},CA=fA=>{},uA=fA=>{},dA=fA=>{},pA=fA=>{},mA=fA=>Promise.resolve({allowView:!0}),QA=await this.javascriptCore.createCoreGenerateDast(lA,cA,IA,CA,uA,dA,pA,mA);if(!QA.success)throw console.error(QA.errMsg),Error(QA.errMsg);if(gA===null)throw Error("Need to address case where do not get updateRenderersCallback before dast");const BA=QA.coreInfo.documentToRender,{componentIdxToName:hA,doenetIdToComponentIdx:DA}=seedInstructionMaps(BA,gA);return this._componentIdxToName=hA,this._doenetIdToComponentIdx=DA,this._javascriptInitialRenderDone=!0,flatDastFromJS(BA,gA)}async dispatchActionJavascript(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");try{return await this.javascriptCore.requestAction(eA)}catch(rA){throw console.error(rA),rA}finally{nA()}}async dispatchActionJavascriptFlat(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{if(!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");if(!this._javascriptInitialRenderDone)throw Error("Cannot dispatch a flat action before the initial render (returnDast) has run");this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!0;const rA=eA.componentIdx!=null?this._componentIdxToName[eA.componentIdx]:void 0,aA=translateJsCoreActionName(rA,eA.actionName),oA=await this.javascriptCore.requestAction({...eA,actionName:aA});if(oA&&typeof oA=="object"&&"success"in oA&&oA.success===!1){const lA=aA===eA.actionName?`"${eA.actionName}"`:`"${eA.actionName}" (translated to "${aA}")`;throw Error(`Action ${lA} failed: ${oA.errMsg??"unknown error"}`)}this._capturingJavascriptUpdates=!1;const sA=this._javascriptUpdateBuffer;return this._javascriptUpdateBuffer=[],collectInstructionMaps(sA,this._componentIdxToName,this._doenetIdToComponentIdx),flatDastUpdateFromJS(sA,this._componentIdxToName,this._doenetIdToComponentIdx)}catch(rA){throw console.error(rA),rA}finally{this._capturingJavascriptUpdates=!1,nA()}}async resolvePath(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot resolve a path before setting source and flags");try{return this.doenetCore.resolve_path(eA.path,eA.origin,eA.skipParentSearch)}finally{nA()}}async dispatchAction(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot handle action before setting source and flags");try{return this.doenetCore.dispatch_action(eA)}catch(rA){throw console.error(rA),rA}finally{nA()}}async resolvePathJavascript(eA,AA=0){const tA=this.isProcessingPromise;let{promise:nA,resolve:rA}=promiseWithResolver();if(this.isProcessingPromise=nA,await tA,!this.source_set||!this.flags_set||!this.doenetCore||!this.javascriptCore)throw Error("Cannot resolve path before setting source and flags");try{return await resolvePathImmediatelyToNodeIdx(eA,this.doenetCore,this.javascriptCore,AA)}catch(aA){throw console.error(aA),aA}finally{rA()}}async terminate(){const eA=this.isProcessingPromise;let{promise:AA,resolve:tA}=promiseWithResolver();if(this.isProcessingPromise=AA,await eA,this.doenetCore?.free(),this.doenetCore=void 0,this.source_set=!1,this.flags_set=!1,this.javascriptCore)try{await this.javascriptCore.terminate()}catch(nA){throw console.error(nA),nA}finally{tA()}else tA();this._isHostedCore||close()}async returnAllStateVariables(eA=!1){return this.javascriptCore?this.javascriptCore.returnAllStateVariables(eA):{}}handleVisibilityChange(eA){this.javascriptCore&&this.javascriptCore.handleVisibilityChange(eA)}async submitAllAnswers(){this.javascriptCore&&this.javascriptCore.submitAllAnswers()}async saveImmediately(){this.javascriptCore&&this.javascriptCore.saveImmediately()}async flushState(){return this.javascriptCore?await this.javascriptCore.flushState():!1}async _getTests(){return this.doenetCore?._get_tests()}async _runTest(eA){return this.doenetCore?._run_test(eA)}}function promiseWithResolver(){let iA,eA;return{promise:new Promise((tA,nA)=>{iA=tA,eA=nA}),resolve:iA,reject:eA}}expose(new CoreWorker);function _mergeNamespaces$1(iA,eA){for(var AA=0;AA<eA.length;AA++){const tA=eA[AA];if(typeof tA!="string"&&!Array.isArray(tA)){for(const nA in tA)if(nA!=="default"&&!(nA in iA)){const rA=Object.getOwnPropertyDescriptor(tA,nA);rA&&Object.defineProperty(iA,nA,rA.get?rA:{enumerable:!0,get:()=>tA[nA]})}}}return Object.freeze(Object.defineProperty(iA,Symbol.toStringTag,{value:"Module"}))}var sha256$3={exports:{}},convertHex$1={exports:{}},convertHex=convertHex$1.exports,hasRequiredConvertHex;function requireConvertHex(){return hasRequiredConvertHex||(hasRequiredConvertHex=1,(function(iA){(function(eA){var AA={bytesToHex:function(rA){return tA(rA)},hexToBytes:function(rA){if(rA.length%2===1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return rA.indexOf("0x")===0&&(rA=rA.slice(2)),rA.match(/../g).map(function(aA){return parseInt(aA,16)})}};function tA(rA){return rA.map(function(aA){return nA(aA.toString(16),2)}).join("")}function nA(rA,aA){return rA.length>aA?rA:Array(aA-rA.length+1).join("0")+rA}iA.exports?iA.exports=AA:eA.convertHex=AA})(convertHex)})(convertHex$1)),convertHex$1.exports}var convertString$1={exports:{}},convertString=convertString$1.exports,hasRequiredConvertString;function requireConvertString(){return hasRequiredConvertString||(hasRequiredConvertString=1,(function(iA){(function(eA){var AA={bytesToString:function(tA){return tA.map(function(nA){return String.fromCharCode(nA)}).join("")},stringToBytes:function(tA){return tA.split("").map(function(nA){return nA.charCodeAt(0)})}};AA.UTF8={bytesToString:function(tA){return decodeURIComponent(escape(AA.bytesToString(tA)))},stringToBytes:function(tA){return AA.stringToBytes(unescape(encodeURIComponent(tA)))}},iA.exports?iA.exports=AA:eA.convertString=AA})(convertString)})(convertString$1)),convertString$1.exports}var sha256$2=sha256$3.exports,hasRequiredSha256;function requireSha256(){return hasRequiredSha256||(hasRequiredSha256=1,(function(iA){(function(eA){var AA={};iA.exports?(AA.bytesToHex=requireConvertHex().bytesToHex,AA.convertString=requireConvertString(),iA.exports=sA):(AA.bytesToHex=eA.convertHex.bytesToHex,AA.convertString=eA.convertString,eA.sha256=sA);var tA=[];(function(){function lA(CA){for(var uA=Math.sqrt(CA),dA=2;dA<=uA;dA++)if(!(CA%dA))return!1;return!0}function gA(CA){return(CA-(CA|0))*4294967296|0}for(var cA=2,IA=0;IA<64;)lA(cA)&&(tA[IA]=gA(Math.pow(cA,.3333333333333333)),IA++),cA++})();var nA=function(lA){for(var gA=[],cA=0,IA=0;cA<lA.length;cA++,IA+=8)gA[IA>>>5]|=lA[cA]<<24-IA%32;return gA},rA=function(lA){for(var gA=[],cA=0;cA<lA.length*32;cA+=8)gA.push(lA[cA>>>5]>>>24-cA%32&255);return gA},aA=[],oA=function(lA,gA,cA){for(var IA=lA[0],CA=lA[1],uA=lA[2],dA=lA[3],pA=lA[4],mA=lA[5],QA=lA[6],BA=lA[7],hA=0;hA<64;hA++){if(hA<16)aA[hA]=gA[cA+hA]|0;else{var DA=aA[hA-15],EA=(DA<<25|DA>>>7)^(DA<<14|DA>>>18)^DA>>>3,fA=aA[hA-2],NA=(fA<<15|fA>>>17)^(fA<<13|fA>>>19)^fA>>>10;aA[hA]=EA+aA[hA-7]+NA+aA[hA-16]}var yA=pA&mA^~pA&QA,bA=IA&CA^IA&uA^CA&uA,wA=(IA<<30|IA>>>2)^(IA<<19|IA>>>13)^(IA<<10|IA>>>22),MA=(pA<<26|pA>>>6)^(pA<<21|pA>>>11)^(pA<<7|pA>>>25),vA=BA+MA+yA+tA[hA]+aA[hA],OA=wA+bA;BA=QA,QA=mA,mA=pA,pA=dA+vA|0,dA=uA,uA=CA,CA=IA,IA=vA+OA|0}lA[0]=lA[0]+IA|0,lA[1]=lA[1]+CA|0,lA[2]=lA[2]+uA|0,lA[3]=lA[3]+dA|0,lA[4]=lA[4]+pA|0,lA[5]=lA[5]+mA|0,lA[6]=lA[6]+QA|0,lA[7]=lA[7]+BA|0};function sA(lA,gA){lA.constructor===String&&(lA=AA.convertString.UTF8.stringToBytes(lA));var cA=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],IA=nA(lA),CA=lA.length*8;IA[CA>>5]|=128<<24-CA%32,IA[(CA+64>>9<<4)+15]=CA;for(var uA=0;uA<IA.length;uA+=16)oA(cA,IA,uA);var dA=rA(cA);return gA&&gA.asBytes?dA:gA&&gA.asString?AA.convertString.bytesToString(dA):AA.bytesToHex(dA)}sA.x2=function(lA,gA){return sA(sA(lA,{asBytes:!0}),gA)}})(sha256$2)})(sha256$3)),sha256$3.exports}var sha256Exports=requireSha256();const sha256=getDefaultExportFromCjs$1(sha256Exports),sha256$1=_mergeNamespaces$1({__proto__:null,default:sha256},[sha256Exports]),sha2568sXzDnE0D37pHzmU=Object.freeze(Object.defineProperty({__proto__:null,s:sha256$1},Symbol.toStringTag,{value:"Module"}));return exports.CoreWorker=CoreWorker,exports.DOCUMENT_BUILD_ERROR_NAME=DOCUMENT_BUILD_ERROR_NAME,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports})({});
2784
+ `).map(IA=>IA.trim().split(",").map(CA=>CA.trim())),oA=aA[0]?.length,sA=!1;for(let IA of aA.slice(1))if(IA.length!==oA){sA=!0;break}if(sA){let IA=codedDiagnostic({type:"warning",code:"doenet-w0066",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:rA},sendDiagnostics:[IA]}}let lA={},gA=[];if(AA.hasHeader?(lA.columnNames=aA[0].map(IA=>(['"',"'"].includes(IA[0])&&IA[IA.length-1]===IA[0]&&(IA=IA.substring(1,IA.length-1)),IA)),gA=aA.slice(1)):(lA.columnNames=[...Array(oA).keys()].map(IA=>`col${IA+1}`),gA=aA),[...new Set(lA.columnNames)].length<lA.columnNames){let IA=codedDiagnostic({type:"warning",code:"doenet-w0067",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:rA},sendDiagnostics:[IA]}}if(lA.columnNames.includes("")){let IA=codedDiagnostic({type:"warning",code:"doenet-w0068",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:rA},sendDiagnostics:[IA]}}let cA=gA.length;lA.shape=[cA,oA];for(let IA=0;IA<oA;IA++){let CA=AA.columnTypesPrelim[IA]?.toLowerCase();if(["number","string"].includes(CA)||(CA="auto"),CA==="auto"){let uA=!1;for(let dA=0;dA<cA;dA++){let pA=gA[dA][IA];if(pA!==""){let mA=Number(pA);if(!Number.isFinite(mA)){uA=!0;break}}}uA?CA="string":CA="number"}if(CA==="number")for(let uA=0;uA<cA;uA++)gA[uA][IA]===""?gA[uA][IA]=null:gA[uA][IA]=Number(gA[uA][IA]);else for(let uA=0;uA<cA;uA++){let dA=gA[uA][IA];['"',"'"].includes(dA[0])&&dA[dA.length-1]===dA[0]&&(dA=dA.substring(1,dA.length-1)),gA[uA][IA]=dA}nA.push(CA)}return lA.data=gA,lA.columnTypes=nA,{setValue:{dataFrame:lA,numRows:cA,numColumns:oA,columnTypes:nA,columnNames:lA.columnNames}}}},eA.means={description:"Mean of each numeric column in the data frame.",public:!0,shadowingInstructions:{createComponentOfType:"number"},isArray:!0,entryPrefixes:["mean"],returnArraySizeDependencies:()=>({numColumns:{dependencyType:"stateVariable",variableName:"numColumns"}}),returnArraySize({dependencyValues:AA}){return[AA.numColumns]},returnArrayDependenciesByKey(){return{globalDependencies:{dataFrame:{dependencyType:"stateVariable",variableName:"dataFrame"},numColumns:{dependencyType:"stateVariable",variableName:"numColumns"},numRows:{dependencyType:"stateVariable",variableName:"numRows"},columnTypes:{dependencyType:"stateVariable",variableName:"columnTypes"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arrayKeys:tA}){let nA={};for(let rA of tA){let aA=0,oA=0;if(AA.columnTypes[rA]==="number"){for(let sA=0;sA<AA.numRows;sA++){let lA=AA.dataFrame.data[sA][rA];lA!==null&&(aA+=lA,oA++)}aA/=oA}else aA=NaN;nA[rA]=aA}return{setValue:{means:nA}}}},eA}}const{mean,std,variance}=context.math,STATISTICS=[{value:"mean",description:"The arithmetic mean of the values.",compute:mean},{value:"stdev",description:"The sample standard deviation.",compute:std},{value:"variance",description:"The sample variance.",compute:variance},{value:"stderr",description:"The standard error of the mean."},{value:"count",description:"The number of non-missing values."},{value:"minimum",description:"The smallest value.",compute:smallest},{value:"quartile1",description:"The first quartile (25th percentile).",compute:quartile1},{value:"median",description:"The median value.",compute:median},{value:"quartile3",description:"The third quartile (75th percentile).",compute:quartile3},{value:"maximum",description:"The largest value.",compute:largest},{value:"range",description:"The maximum minus the minimum."},{value:"sum",description:"The sum of the values.",compute:iA=>iA.reduce((eA,AA)=>eA+AA)}],FIVE_NUMBER_SUMMARY=["minimum","quartile1","median","quartile3","maximum"],DEFAULT_STATISTICS=["mean","stdev","count","minimum","quartile1","median","quartile3","maximum"];function returnColumnStatisticDefinition({value:iA,description:eA,compute:AA}){return{description:eA,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){const nA=tA.dataColumn;return{setValue:{[iA]:nA.length?AA(nA):null}}}}}function displayedStatistic(iA,eA,AA){return eA===null?null:iA==="count"?eA:roundForDisplay({value:numberToMathExpression(eA),dependencyValues:AA}).toString(buildNumberDisplayParameters(AA))}class SummaryStatistics extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="summaryStatistics";static componentDocs={summary:"Summary statistics (mean, median, etc.) for a list of numbers."};static createAttributesObject(){let eA=super.createAttributesObject();return eA.statisticsToDisplay={createComponentOfType:"textList",createStateVariable:"statisticsToDisplayPrelim",defaultValue:["default"],toLowerCase:!0,highlighted:!0,validValues:[{value:"default",description:`The default selection: ${DEFAULT_STATISTICS.join(", ")}.`},{value:"all",description:"Every statistic listed here."},{value:"fiveNumberSummary",description:`The five-number summary: ${FIVE_NUMBER_SUMMARY.join(", ")}.`},...STATISTICS.map(({value:AA,description:tA})=>({value:AA,description:tA}))],description:'Which summary statistics to display (or "default" / "all" / "fiveNumberSummary").'},Object.assign(eA,returnNumberDisplayAttributes()),eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoMathsBySpacesSugarInstruction()),eA}static returnChildGroups(){return[{group:"numbers",componentTypes:["number"]},{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.statisticsToDisplay={description:"Which summary statistics to display.",public:!0,shadowingInstructions:{createComponentOfType:"textList"},returnDependencies:()=>({statisticsToDisplayPrelim:{dependencyType:"stateVariable",variableName:"statisticsToDisplayPrelim"}}),definition:function({dependencyValues:tA}){const nA=STATISTICS.map(sA=>sA.value),rA=tA.statisticsToDisplayPrelim,aA=new Set;for(const sA of rA)if(sA==="default")for(const lA of DEFAULT_STATISTICS)aA.add(lA);else if(sA==="all")for(const lA of nA)aA.add(lA);else if(sA==="fivenumbersummary")for(const lA of FIVE_NUMBER_SUMMARY)aA.add(lA);else aA.add(sA);return{setValue:{statisticsToDisplay:nA.filter(sA=>aA.has(sA))}}}},eA.dataColumn={description:"The numeric values being summarized.",returnDependencies:()=>({valueChildren:{dependencyType:"child",childGroups:["numbers","maths"],variableNames:["value"]}}),definition({dependencyValues:tA}){const nA=[];for(let rA of tA.valueChildren){const aA=rA.stateValues.value,oA=typeof aA?.evaluate_to_constant=="function"?aA.evaluate_to_constant():aA;Number.isFinite(oA)&&nA.push(oA)}return{setValue:{dataColumn:nA}}}};const AA={};AA.count={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){return{setValue:{count:tA.dataColumn.length}}}},AA.stderr={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({stdev:{dependencyType:"stateVariable",variableName:"stdev"},count:{dependencyType:"stateVariable",variableName:"count"}}),definition({dependencyValues:tA}){let nA=null;return tA.stdev!==null&&(nA=tA.stdev/Math.sqrt(tA.count)),{setValue:{stderr:nA}}}},AA.range={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({minimum:{dependencyType:"stateVariable",variableName:"minimum"},maximum:{dependencyType:"stateVariable",variableName:"maximum"}}),definition({dependencyValues:tA}){let nA=null;return tA.minimum!==null&&(nA=tA.maximum-tA.minimum),{setValue:{range:nA}}}};for(let tA of STATISTICS)eA[tA.value]={...tA.compute?returnColumnStatisticDefinition(tA):{description:tA.description,...AA[tA.value]},highlighted:!0};return eA.summaryStatistics={description:"The statistics being displayed, as the table should show them, keyed by statistic.",forRenderer:!0,stateVariablesDeterminingDependencies:["statisticsToDisplay"],returnDependencies({stateValues:tA}){let nA={};for(let rA of["displayDigits","displayDecimals","displaySmallAsZero","padZeros","avoidScientificNotation"])nA[rA]={dependencyType:"stateVariable",variableName:rA};for(let rA of tA.statisticsToDisplay)nA[rA]={dependencyType:"stateVariable",variableName:rA};return nA},definition({dependencyValues:tA}){let nA={};for(let{value:rA}of STATISTICS){const aA=tA[rA];aA!==void 0&&(nA[rA]=displayedStatistic(rA,aA,tA))}return{setValue:{summaryStatistics:nA}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Legend extends GraphicalComponent{static componentType="legend";static componentDocs={summary:"A legend describing the contents of a graph"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.layer.defaultValue=1,eA.position={description:"Position of the legend on the graph.",createComponentOfType:"text",createStateVariable:"position",defaultValue:"upperRight",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"upperRight",description:"Place the legend in the upper-right corner."},{value:"upperLeft",description:"Place the legend in the upper-left corner."},{value:"lowerRight",description:"Place the legend in the lower-right corner."},{value:"lowerLeft",description:"Place the legend in the lower-left corner."}]},eA.boxed={description:"Whether to draw an opaque box behind the legend so that graph contents passing behind it stay hidden.",createComponentOfType:"boolean",createStateVariable:"boxed",defaultValue:!1,public:!0,forRenderer:!0},eA.displayClosedSwatches={description:"Whether to render closed/filled swatches in the legend.",createComponentOfType:"boolean",createStateVariable:"displayClosedSwatches",defaultValue:!1,public:!0},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.graphicalElementNames={returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["graphicalDescendants"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphicalElementNames:AA.graphAncestor.stateValues.graphicalDescendants.map(tA=>tA.componentIdx)}}:{setValue:{graphicalElementNames:null}}}},eA.legendElements={forRenderer:!0,stateVariablesDeterminingDependencies:["graphicalElementNames"],returnDependencies:({stateValues:AA})=>{let tA={labelChildren:{dependencyType:"child",childGroups:["labels"],variableNames:["value","hasLatex","forObjectComponentIdx"]},displayClosedSwatches:{dependencyType:"stateVariable",variableName:"displayClosedSwatches"}};if(AA.graphicalElementNames){tA.numGraphicalElements={dependencyType:"value",value:AA.graphicalElementNames.length};for(let[nA,rA]of AA.graphicalElementNames.entries())tA[`graphicalElement${nA}`]={dependencyType:"multipleStateVariables",componentIdx:rA,variableNames:["selectedStyle","styleNumber","filled"],variablesOptional:!0},tA[`graphicalElement${nA}AdapterSource`]={dependencyType:"adapterSource",componentIdx:rA},tA[`graphicalElement${nA}ShadowSource`]={dependencyType:"shadowSource",componentIdx:rA}}return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){let nA=[];if(AA.numGraphicalElements>0){let rA=[],aA=[],oA=[],sA=[];for(let IA=0;IA<AA.numGraphicalElements;IA++){let CA=AA[`graphicalElement${IA}`],uA=AA[`graphicalElement${IA}AdapterSource`];uA&&(CA={...CA},CA.componentIdx=uA.componentIdx);let dA=AA[`graphicalElement${IA}ShadowSource`];if(dA){const pA=JSON.parse(JSON.stringify(CA));pA.componentIdx=dA.componentIdx,sA.push(pA)}sA.push(CA)}let lA=sA.map(IA=>IA.componentIdx),gA=[],cA={};for(let IA of AA.labelChildren){let CA={value:IA.stateValues.value,hasLatex:IA.stateValues.hasLatex};if(IA.stateValues.forObjectComponentIdx){cA[IA.stateValues.forObjectComponentIdx]=CA;let uA=lA.indexOf(IA.stateValues.forObjectComponentIdx);if(uA!==-1){let dA=sA[uA];tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})?rA.push(dA.stateValues.styleNumber):AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath?aA.push(dA.stateValues.styleNumber):dA.componentType!=="legend"&&oA.push(dA.stateValues.styleNumber)}}gA.push({labelInfo:CA,forObject:IA.stateValues.forObjectComponentIdx})}for(let IA of gA){let CA;if(IA.forObject){let uA=lA.indexOf(IA.forObject);uA!==-1&&(CA=sA[uA],sA.splice(uA,1),lA.splice(uA,1))}else for(let uA=0;uA<sA.length;uA++){let dA=sA[uA];if(!(dA.componentIdx in cA)){if(tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})){if(!rA.includes(dA.stateValues.styleNumber)){CA=dA;break}}else if(AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath){if(!aA.includes(dA.stateValues.styleNumber)){CA=dA;break}}else if(dA.componentType!=="legend"&&!oA.includes(dA.stateValues.styleNumber)){CA=dA;break}}}if(CA){let uA=CA.stateValues.selectedStyle,dA=CA.stateValues.styleNumber;tA.isInheritedComponentType({inheritedComponentType:CA.componentType,baseComponentType:"point"})?(rA.push(dA),nA.push({swatchType:"marker",markerStyle:uA.markerStyle,markerColor:uA.markerColor,markerColorDarkMode:uA.markerColorDarkMode,markerSize:uA.markerSize,lineOpacity:uA.lineOpacity,label:IA.labelInfo})):AA.displayClosedSwatches&&tA.allComponentClasses[CA.componentType].representsClosedPath?(aA.push(dA),nA.push({swatchType:"rectangle",lineStyle:uA.lineStyle,lineColor:uA.lineColor,lineColorDarkMode:uA.lineColorDarkMode,lineWidth:uA.lineWidth,lineOpacity:uA.lineOpacity,fillColor:uA.fillColor,fillColorDarkMode:uA.fillColorDarkMode,filled:CA.stateValues.filled,fillOpacity:uA.fillOpacity,label:IA.labelInfo})):(oA.push(dA),nA.push({swatchType:"line",lineStyle:uA.lineStyle,lineColor:uA.lineColor,lineColorDarkMode:uA.lineColorDarkMode,lineWidth:uA.lineWidth,lineOpacity:uA.lineOpacity,label:IA.labelInfo}))}}}return{setValue:{legendElements:nA}}}},eA.graphLimits={forRenderer:!0,returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["xMin","xMax","yMin","yMax"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphLimits:AA.graphAncestor.stateValues}}:{setValue:{graphLimits:null}}}},eA}}function parameterKey(iA){if(isValidVariable({tree:iA}))return typeof iA=="string"?"s"+iA:"t"+JSON.stringify(iA)}function replacePlaceholders(iA,eA){let AA=eA(iA);return AA!==void 0?AA:Array.isArray(iA)?[iA[0],...iA.slice(1).map(tA=>replacePlaceholders(tA,eA))]:iA}class MatchesPattern extends BooleanComponent{static componentType="matchesPattern";static componentDocs={summary:"Boolean condition that tests whether input matches a math pattern"};static rendererType="boolean";static createAttributesObject(){let eA=super.createAttributesObject();return eA.pattern={createComponentOfType:"math",description:"Math expression pattern to match against.",highlighted:!0},eA.parameters={createComponentOfType:"_variableNameList",description:"Variables in the pattern that act as placeholders. Repeating one in the pattern requires the same subexpression at each occurrence. When specified, blanks in the pattern are matched literally.",highlighted:!0},eA.allowImplicitIdentities={description:"Whether to allow implicit identity transformations when matching.",createComponentOfType:"boolean",createStateVariable:"allowImplicitIdentities",defaultValue:!1,public:!0,highlighted:!0},eA.allowPermutations={description:"Whether to allow permutations of operands when matching.",createComponentOfType:"boolean",createStateVariable:"allowPermutations",defaultValue:!0,public:!0,highlighted:!0},eA.requireNumericMatches={description:"Whether numeric placeholders must match numbers.",createComponentOfType:"boolean",createStateVariable:"requireNumericMatches",defaultValue:!1,public:!0,highlighted:!0},eA.requireVariableMatches={description:"Whether variable placeholders must match variables.",createComponentOfType:"boolean",createStateVariable:"requireVariableMatches",defaultValue:!1,public:!0,highlighted:!0},eA.excludeMatches={description:"Patterns whose matches are excluded.",createComponentOfType:"mathList",createStateVariable:"excludeMatches",defaultValue:[],public:!0,highlighted:!0},eA.matchExpressionWithBlanks={description:"Whether to allow expressions with blanks to match.",createComponentOfType:"boolean",createStateVariable:"matchExpressionWithBlanks",defaultValue:!1,public:!0,highlighted:!0},eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,componentInfoObjects:nA,nComponents:rA,stateIdInfo:aA}){return tA.length===0||tA.length===1&&nA.componentIsSpecifiedType(tA[0],"math")?{success:!1}:{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.parsedExpression,delete eA.mathChildrenByCode,eA.pattern={additionalStateVariablesDefined:["patternVariables"],returnDependencies:()=>({patternAttr:{dependencyType:"attributeComponent",attributeName:"pattern",variableNames:["value"]},parametersAttr:{dependencyType:"attributeComponent",attributeName:"parameters",variableNames:["variables"]}}),definition({dependencyValues:AA}){let tA=[];if(!AA.patternAttr)return{setValue:{pattern:BLANK,patternVariables:tA}};let nA=AA.patternAttr.stateValues.value,rA=nA.variables(),aA=703;function oA(){let dA=numberToLetters(aA);for(aA++;rA.includes(dA);)dA=numberToLetters(aA),aA++;return dA}if(!AA.parametersAttr)return{setValue:{pattern:replacePlaceholders(nA.tree,pA=>{if(pA!==BLANK)return;let mA=oA();return tA.push(mA),mA}),patternVariables:tA}};let sA=AA.parametersAttr.position||void 0,lA=[],gA=new Map,cA=new Map;for(let dA of AA.parametersAttr.stateValues.variables){let pA=parameterKey(dA.tree);if(pA===void 0||gA.has(pA))continue;let mA=oA();gA.set(pA,mA),cA.set(mA,dA.toString()),tA.push(mA)}let IA=new Set,CA=replacePlaceholders(nA.tree,dA=>{let pA=gA.get(parameterKey(dA));return pA!==void 0&&IA.add(pA),pA}),uA=[...cA].filter(([dA])=>!IA.has(dA)).map(([dA,pA])=>pA);return uA.length>0&&lA.push(codedDiagnostic({type:"warning",code:"doenet-w0117",args:{parameters:uA},position:sA})),{setValue:{pattern:CA,patternVariables:tA},sendDiagnostics:lA}}},eA.value={description:"Whether the input matches the pattern.",additionalStateVariablesDefined:[{variableName:"allPatternMatches"}],public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({pattern:{dependencyType:"stateVariable",variableName:"pattern"},patternVariables:{dependencyType:"stateVariable",variableName:"patternVariables"},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},allowImplicitIdentities:{dependencyType:"stateVariable",variableName:"allowImplicitIdentities"},allowPermutations:{dependencyType:"stateVariable",variableName:"allowPermutations"},requireNumericMatches:{dependencyType:"stateVariable",variableName:"requireNumericMatches"},requireVariableMatches:{dependencyType:"stateVariable",variableName:"requireVariableMatches"},excludeMatches:{dependencyType:"stateVariable",variableName:"excludeMatches"},matchExpressionWithBlanks:{dependencyType:"stateVariable",variableName:"matchExpressionWithBlanks"}}),definition:function({dependencyValues:AA}){if(AA.mathChildren.length===0)return{setValue:{value:!1,allPatternMatches:[]}};let tA=AA.mathChildren[0].stateValues.value;if(treeContainsBlank(tA.tree)&&!AA.matchExpressionWithBlanks)return{setValue:{value:!1,allPatternMatches:[]}};let nA="any";AA.requireNumericMatches?nA="number":AA.requireVariableMatches&&(nA="variable");let rA={};AA.patternVariables.forEach(gA=>rA[gA]=nA);let aA={variables:rA,allow_permutations:AA.allowPermutations};AA.allowImplicitIdentities&&(aA.allow_implicit_identities=AA.patternVariables);let oA=tA.match(AA.pattern,aA),sA=!1,lA=[];return oA&&(Object.values(oA).map(gA=>context.fromAst(gA)).some(gA=>AA.excludeMatches.some(cA=>gA.variables().some(IA=>cA.equalsViaSyntax(context.fromAst(IA)))))||(sA=!0,lA=AA.patternVariables.map(gA=>context.fromAst(oA[gA]??BLANK)))),{setValue:{value:sA,allPatternMatches:lA}}}},eA.numMatches={description:"The number of matches found.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}),definition({dependencyValues:AA}){return{setValue:{numMatches:AA.allPatternMatches.length},checkForActualChange:{numMatches:!0}}}},eA.patternMatches={description:"The list of matched sub-expressions.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,numDimensions:1,entryPrefixes:["patternMatch"],returnArraySizeDependencies:()=>({numMatches:{dependencyType:"stateVariable",variableName:"numMatches"}}),returnArraySize({dependencyValues:AA}){return[AA.numMatches]},returnArrayDependenciesByKey(){return{globalDependencies:{allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA={};for(let nA=0;nA<AA.__array_size[0];nA++)tA[nA]=AA.allPatternMatches[nA];return{setValue:{patternMatches:tA}}}},eA}}class Matrix extends MathComponent{static componentType="matrix";static componentDocs={summary:"A matrix of math values",childAliases:{row:"matrixRow",column:"matrixColumn"}};static rendererType="math";static additionalSchemaChildren=["row","column"];static returnChildGroups(){return[{group:"rows",componentTypes:["matrixRow"]},{group:"columns",componentTypes:["matrixColumn"]},{group:"maths",componentTypes:["math"],excludeFromSchema:!0}]}static createAttributesObject(){let eA=super.createAttributesObject();return eA.defaultEntry={createComponentOfType:"math",createStateVariable:"defaultEntry",defaultValue:context.fromAst(0),description:"Value used for entries that aren't explicitly specified."},eA.numRows={createComponentOfType:"integer",description:"Number of rows in the matrix."},eA.numColumns={createComponentOfType:"integer",description:"Number of columns in the matrix."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,componentInfoObjects:nA,nComponents:rA,stateIdInfo:aA}){if(tA.length===0)return{success:!1};let oA=[],sA=!1;for(let lA of tA)typeof lA!="string"&&(lA.doenetAttributes||(lA.doenetAttributes={}),lA.componentType==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.componentType="matrixColumn",sA=!0):lA.componentType==="row"?(lA.doenetAttributes.createNameFromComponentType="row",lA.componentType="matrixRow",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.attributes.createComponentOfType.primitive.value="matrixColumn",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="row"&&(lA.doenetAttributes.createNameFromComponentType="row",lA.attributes.createComponentOfType.primitive.value="matrixRow",sA=!0),oA.push(lA));return sA||(tA.length>1||!nA.componentIsSpecifiedType(tA[0],"math"))&&(oA=[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}]),{success:!0,newChildren:oA,nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.codePre,delete eA.mathChildrenFunctionSymbols,delete eA.expressionWithCodes,delete eA.mathChildrenWithCanBeModified,delete eA.codesAdjacentToStrings,delete eA.canBeModified,delete eA.mathChildrenByVectorComponent,Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.unordered={description:"Whether matrix entries should be treated as unordered.",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({}),definition(){return{setValue:{unordered:!1}}}},eA.matrixSizePre={returnDependencies:()=>({rowChildren:{dependencyType:"child",childGroups:["rows"],variableNames:["numComponents"]},colChildren:{dependencyType:"child",childGroups:["columns"],variableNames:["numComponents"]},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["matrixSize"]},numRowsAttr:{dependencyType:"attributeComponent",attributeName:"numRows",variableNames:["value"]},numColumnsAttr:{dependencyType:"attributeComponent",attributeName:"numColumns",variableNames:["value"]}}),definition({dependencyValues:AA}){let tA=null,nA=null;return AA.numRowsAttr&&(tA=AA.numRowsAttr.stateValues.value,Number.isFinite(tA)&&tA>0||(tA=null)),AA.numColumnsAttr&&(nA=AA.numColumnsAttr.stateValues.value,Number.isFinite(nA)&&nA>0||(nA=null)),AA.rowChildren.length>0?(tA===null&&(tA=AA.rowChildren.length),nA===null&&(nA=Math.max(1,...AA.rowChildren.map(rA=>rA.stateValues.numComponents)))):AA.colChildren.length>0?(nA===null&&(nA=AA.colChildren.length),tA===null&&(tA=Math.max(1,...AA.colChildren.map(rA=>rA.stateValues.numComponents)))):AA.mathChildren.length===1?(tA===null&&(tA=AA.mathChildren[0].stateValues.matrixSize[0]),nA===null&&(nA=AA.mathChildren[0].stateValues.matrixSize[1])):tA===null?nA===null?(tA=0,nA=0):tA=1:nA===null&&(nA=1),{setValue:{matrixSizePre:[tA,nA]}}}},eA.matrixPre={isArray:!0,numDimensions:2,hasEssential:!0,returnArraySizeDependencies:()=>({matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),returnArraySize({dependencyValues:AA}){return AA.matrixSizePre},returnArrayDependenciesByKey:({arrayKeys:AA})=>{let tA={defaultEntry:{dependencyType:"stateVariable",variableName:"defaultEntry"},rowChildIdentities:{dependencyType:"child",childGroups:["rows"]},colChildIdentities:{dependencyType:"child",childGroups:["columns"]}},nA={};for(let rA of AA){let[aA,oA]=rA.split(",");nA[rA]={rowChild:{dependencyType:"child",childGroups:["rows"],childIndices:[aA],variableNames:["math"+(Number(oA)+1)]},colChild:{dependencyType:"child",childGroups:["columns"],childIndices:[oA],variableNames:["math"+(Number(aA)+1)]},mathChild:{dependencyType:"child",childGroups:["maths"],childIndices:[0],variableNames:["matrixEntry"+(Number(aA)+1)+"_"+(Number(oA)+1)]}}}return{globalDependencies:tA,dependenciesByKey:nA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:nA,arraySize:rA}){let aA={},oA={},sA=AA.rowChildIdentities.length>0,lA=AA.colChildIdentities.length>0;for(let gA of nA){let[cA,IA]=gA.split(","),CA;sA?CA=tA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]:lA?CA=tA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]:CA=tA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)],CA===void 0?oA[gA]={defaultValue:AA.defaultEntry}:aA[gA]=CA}return{setValue:{matrixPre:aA},useEssentialOrDefaultValue:{matrixPre:oA}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:nA,dependencyNamesByKey:rA}){let aA=[],oA={},sA=tA.rowChildIdentities.length>0,lA=tA.colChildIdentities.length>0;for(let gA in AA.matrixPre){let[cA,IA]=gA.split(",");sA?nA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].rowChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):lA?nA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].colChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):nA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].mathChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0})}return Object.keys(oA).length>0&&aA.push({setEssentialValue:"matrixPre",value:oA}),{success:!0,instructions:aA}}},eA.unnormalizedValue={returnDependencies:()=>({matrixPre:{dependencyType:"stateVariable",variableName:"matrixPre"},matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),hasEssential:!0,defaultValue:context.fromAst(["matrix",["tuple",0,0],["tuple"]]),definition({dependencyValues:AA}){let tA=["tuple"];for(let rA=0;rA<AA.matrixSizePre[0];rA++)tA.push(["tuple",...AA.matrixPre[rA].map(aA=>aA.tree)]);return{setValue:{unnormalizedValue:context.fromAst(["matrix",["tuple",...AA.matrixSizePre],tA])}}},inverseDefinition({dependencyValues:AA,desiredStateVariableValues:tA}){let nA=tA.unnormalizedValue.tree;if(!(Array.isArray(nA)&&nA[0]==="matrix"&&nA[1]?.[1]===AA.matrixSizePre[0]&&nA[1]?.[2]===AA.matrixSizePre[1]))return{success:!1};let rA={};for(let aA=0;aA<AA.matrixSizePre[0];aA++)for(let oA=0;oA<AA.matrixSizePre[1];oA++)rA[`${aA},${oA}`]=context.fromAst(nA[2][aA+1][oA+1]);return{success:!0,instructions:[{setDependency:"matrixPre",desiredValue:rA}]}}},eA.canBeModified={returnDependencies:()=>({modifyIndirectly:{dependencyType:"stateVariable",variableName:"modifyIndirectly"},fixed:{dependencyType:"stateVariable",variableName:"fixed"}}),definition({dependencyValues:AA}){return{setValue:{canBeModified:AA.modifyIndirectly&&!AA.fixed}}}},eA}}const{eigs,square,abs,divide}=context.math;class EigenDecomposition extends BaseComponent{static componentType="eigenDecomposition";static rendererType=void 0;static componentDocs={summary:"Computes the eigenvalues and eigenvectors of a square matrix"};static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.decomposition={description:"The eigendecomposition of the matrix as a list of eigenvalue/eigenvector pairs.",additionalStateVariablesDefined:[{variableName:"numEigenvectors",description:"The number of eigenvectors found in the decomposition.",public:!0,shadowingInstructions:{createComponentOfType:"integer"}}],returnDependencies:()=>({mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]}}),definition({dependencyValues:AA}){if(AA.mathChild.length===0)return{setValue:{decomposition:null,numEigenvectors:0}};let tA=AA.mathChild[0].stateValues.value.tree;if(!Array.isArray(tA)||tA[0]!=="matrix")return{setValue:{decomposition:null,numEigenvectors:0}};let nA=tA[1][1],rA=tA[1][2];if(!(Number.isInteger(nA)&&rA===nA))return{setValue:{decomposition:null,numEigenvectors:0}};let aA=[];for(let sA=0;sA<nA;sA++){let lA=[],gA=tA[2][sA+1]||[];for(let cA=0;cA<rA;cA++){let IA=gA[cA+1];if(IA==null)return{setValue:{decomposition:null,numEigenvectors:0}};if(typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number")lA.push(IA);else try{IA=context.fromAst(IA).evaluate_to_constant(),typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number"?lA.push(IA):lA.push(NaN)}catch{lA.push(NaN)}}aA.push(lA)}let oA;try{oA=eigs(aA)}catch(sA){console.error("Could nt calculate eigenvalues of matrix",sA);let lA=codedDiagnostic({type:"warning",code:"doenet-w0059"});return{setValue:{decomposition:null,numEigenvectors:0},sendDiagnostics:[lA]}}return{setValue:{decomposition:oA,numEigenvectors:oA.eigenvectors.length}}}},eA.eigenvalues={description:"The eigenvalues of the matrix.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},entryPrefixes:["eigenvalue"],returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA;return AA.decomposition?tA=AA.decomposition.values.length:tA=0,[tA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let nA=[];for(let rA=0;rA<tA[0];rA++)nA.push(AA.decomposition.values[rA]);return{setValue:{eigenvalues:nA}}}},eA.eigenvectors={description:"The eigenvectors of the matrix, as a 2D array (one column per eigenvalue).",isArray:!0,public:!0,numDimensions:2,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="eigenvectorX"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},getArrayKeysFromVarName({arrayEntryPrefix:AA,varEnding:tA,arraySize:nA}){if(AA==="eigenvectorX"){let rA=tA.split("_").map(aA=>Number(aA)-1);return rA.length===2&&rA.every((aA,oA)=>Number.isInteger(aA)&&aA>=0)?nA?rA.every((aA,oA)=>aA<nA[oA])?[String(rA)]:[]:[String(rA)]:[]}else{let rA=Number(tA)-1;return Number.isInteger(rA)&&rA>=0?nA?rA<nA[0]?Array.from(Array(nA[1]),(aA,oA)=>rA+","+oA):[]:[rA+",0"]:[]}},arrayVarNameFromPropIndex(AA,tA){if(tA==="eigenvectors")return AA.length===1?"eigenvector"+AA[0]:`eigenvectorX${AA[0]}_${AA[1]}`;if(tA.slice(0,11)==="eigenvector"){let nA=Number(tA.slice(11));if(Number.isInteger(nA)&&nA>0)return`eigenvectorX${nA}_${AA[0]}`}return null},indexAliases:[[],["x","y","z"]],entryPrefixes:["eigenvectorX","eigenvector"],returnEntryDimensions:AA=>AA==="eigenvector"?1:0,returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA,nA;return AA.decomposition?(tA=AA.decomposition.eigenvectors.length,nA=AA.decomposition.eigenvectors[0].vector.length):(tA=0,nA=0),[tA,nA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let nA={};for(let rA=0;rA<tA[0];rA++){let aA=[],oA=0;for(let sA=0;sA<tA[1];sA++){let lA=AA.decomposition.eigenvectors[rA].vector[sA];aA.push(lA),oA+=square(abs(lA))}oA=Math.sqrt(oA),aA=aA.map(sA=>divide(sA,oA));for(let sA=0;sA<tA[1];sA++)nA[`${rA},${sA}`]=aA[sA]}return{setValue:{eigenvectors:nA}}}},eA}}class Latex extends Text{static componentType="latex";static componentDocs={summary:"A snippet of LaTeX that can be rendered as math"};static rendererType="text";static createAttributesObject(){let eA=super.createAttributesObject();return eA.isLatex.defaultValue=!0,eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA[0].componentTypes.push("math","m","md"),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.value.returnDependencies=()=>({mathTextLikeChildren:{dependencyType:"child",childGroups:["textLike"],variableNames:["text","latex"],variablesOptional:!0}}),eA.value.definition=function({dependencyValues:AA}){if(AA.mathTextLikeChildren.length===0)return{useEssentialOrDefaultValue:{value:!0}};let tA=[];for(let rA of AA.mathTextLikeChildren)if(typeof rA=="string"){let aA=rA.trim();aA&&tA.push(aA)}else if(rA.stateValues.latex!==void 0){let aA=rA.stateValues.latex.trim();aA&&tA.push(aA)}else{let aA=rA.stateValues.text.trim();aA&&tA.push(aA)}return{setValue:{value:tA.join(" ")}}},eA.value.inverseDefinition=function({desiredStateVariableValues:AA,dependencyValues:tA}){let nA=tA.mathTextLikeChildren.length;return nA>1?{success:!1}:nA===1?{success:!0,instructions:[{setDependency:"textLikeChildren",desiredValue:AA.value,childIndex:0,variableIndex:tA.textLikeChildren[0].stateValues?.latex===void 0?0:1}]}:{success:!0,instructions:[{setEssentialValue:"value",value:AA.value===null?"":String(AA.value)}]}},eA.latex={isAlias:!0,targetVariableName:"value",description:"The LaTeX content as a string."},eA}}class BlockQuote extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="blockQuote";static rendererType="blockQuote";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static componentDocs={summary:"A block-level quotation"};static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Description extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="description";static componentDocs={summary:"Extra information about an enclosing component, shown to all users in a popup or disclosure"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static inSchemaOnlyInheritAs=[];static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}const{mod:mod$1}=context.math;function findAttractedSegmentPointsSub({point1:iA,point2:eA,scales:AA,threshold2:tA,numericalNearestPointFunction:nA,numericalNearestPointAsLineFunction:rA,verifyNotOneSided:aA=!0}){let oA=1e-6,sA=oA**2,lA=rA(iA,AA);if(!lA)return{success:!1};let gA=lA.reduce((IA,CA,uA)=>IA+Math.pow(CA-iA[uA],2),0);if(gA>=tA)return{success:!1};let cA=rA(eA,AA);if(!cA)return{success:!1};if(gA=cA.reduce((IA,CA,uA)=>IA+Math.pow(CA-eA[uA],2),0),gA>=tA)return{success:!1};if(aA){let IA=nA(iA,AA),CA=IA&&IA.every((pA,mA)=>Math.abs(pA-lA[mA])<oA),uA=nA(eA,AA),dA=uA&&uA.every((pA,mA)=>Math.abs(pA-cA[mA])<oA);if(!(CA||dA)&&(gA=IA.reduce((pA,mA,QA)=>pA+Math.pow(mA-uA[QA],2),0),gA<sA))return{success:!1}}return{success:!0,nearestPoint1:lA,nearestPoint2:cA}}function findAttractedSegmentPoints({point1:iA,point2:eA,allowRotation:AA,scales:tA,threshold2:nA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA}){let oA=findAttractedSegmentPointsSub({point1:iA,point2:eA,scales:tA,threshold2:nA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!0});if(!oA.success)return{success:!1};let sA=1e-6,lA=sA**2,{nearestPoint1:gA,nearestPoint2:cA}=oA;if(!AA){let NA=[eA[0]-iA[0],eA[1]-iA[1]],yA=[cA[0]-gA[0],cA[1]-gA[1]],bA=Math.atan2(yA[1],yA[0])-Math.atan2(NA[1],NA[0]);if(bA=mod$1(bA+Math.PI,2*Math.PI)-Math.PI,Math.abs(bA)>sA)return{success:!1}}let IA=iA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0),CA=gA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0);if(Math.abs(IA-CA)<lA){let NA=gA.reduce((yA,bA,wA)=>yA+Math.pow(bA-iA[wA],2),0)+cA.reduce((yA,bA,wA)=>yA+Math.pow(bA-eA[wA],2),0);return NA<nA?{success:!0,distance2:NA,segment:[gA,cA]}:{success:!1}}if(CA>IA)return{success:!1};let uA=Math.sqrt(IA/CA),dA=Math.sqrt(iA.reduce((NA,yA,bA)=>NA+Math.pow(yA-gA[bA],2),0)),pA=Math.sqrt(eA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0)),mA=dA/(dA+pA),QA=1-mA,BA=(uA-1)*mA+1,hA=(uA-1)*QA+1,DA=cA.map((NA,yA)=>NA+(gA[yA]-NA)*BA),EA=gA.map((NA,yA)=>NA+(cA[yA]-NA)*hA);if(oA=findAttractedSegmentPointsSub({point1:DA,point2:EA,scales:tA,threshold2:lA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!1}),!oA.success)return{success:!1};let fA=DA.reduce((NA,yA,bA)=>NA+Math.pow(yA-iA[bA],2),0)+EA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0);return fA<nA?{success:!0,distance2:fA,segment:[DA,EA]}:{success:!1}}function attractSegment({segment:iA,allowRotation:eA,scales:AA,threshold2:tA,numericalNearestPointFunctions:nA,numericalNearestPointAsLineFunctions:rA}){let aA=iA[0],oA=iA[1];if(aA.length!=oA.length)return{};let sA,lA=1/0,gA=eA?tA*1e3:tA;for(let[cA,IA]of nA.entries()){let CA=rA[cA],uA=findAttractedSegmentPoints({point1:aA,point2:oA,allowRotation:eA,scales:AA,threshold2:gA,numericalNearestPointFunction:IA,numericalNearestPointAsLineFunction:CA});uA.success&&uA.distance2<lA&&(lA=uA.distance2,sA=uA.segment)}return lA<tA?{constrained:!0,segment:sA}:lA<gA?{constrained:!1,distance2:lA,segment:sA}:{}}function nearestPointForSegment({point:iA,segment:eA,scales:AA}){let tA=eA[0][0],nA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(nA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===nA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-nA)/lA,IA=gA*gA+cA*cA,CA=((iA[0]-tA)/sA*gA+(iA[1]-nA)/lA*cA)/IA;return CA<=0?[tA,nA]:CA>=1?[rA,aA]:[tA+CA*gA*sA,nA+CA*cA*lA]}function nearestPointForSegmentAsLine({point:iA,segment:eA,scales:AA}){let tA=eA[0][0],nA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(nA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===nA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-nA)/lA,IA=gA*gA+cA*cA,CA=((iA[0]-tA)/sA*gA+(iA[1]-nA)/lA*cA)/IA;return[tA+CA*gA*sA,nA+CA*cA*lA]}const{mod:mod$6}=context.math;class StickyGroup extends GraphicalComponent{static componentType="stickyGroup";constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentDocs={summary:"Constrains group members to attract to each other when nearby"};static rendererType="containerInline";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.relativeToGraphScales={description:"Whether the snapping threshold is interpreted relative to graph scales.",createComponentOfType:"boolean",createStateVariable:"relativeToGraphScales",defaultValue:!1,public:!0},eA.threshold={createComponentOfType:"number",description:"Distance threshold within which group members snap together."},eA.angleThreshold={description:"Angular distance within which group members snap together.",createComponentOfType:"number",createStateVariable:"angleThreshold",defaultValue:Math.PI*.03,public:!0},eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"graphical",componentTypes:["_graphical"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnConstraintGraphInfoDefinitions();return Object.assign(eA,AA),eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.pointsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","numericalXs","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let nA=[];for(let rA of tA.graphicalChildren)rA.stateValues.numericalVertices?nA.push(rA.stateValues.numericalVertices):rA.stateValues.numericalXs?nA.push([rA.stateValues.numericalXs]):rA.stateValues.numericalEndpoints?nA.push(rA.stateValues.numericalEndpoints):nA.push([]);return{setValue:{pointsByObject:nA}}}},eA.getPointsForObject={returnDependencies:()=>({pointsByObject:{dependencyType:"stateVariable",variableName:"pointsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getPointsForObject:function(rA){return tA.pointsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.segmentsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","closed","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let nA=[];for(let rA of tA.graphicalChildren)if(rA.stateValues.numericalVertices){let aA=rA.stateValues.numericalVertices,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);rA.stateValues.closed&&sA.push([aA[oA-1],aA[0]]),nA.push(sA)}else if(rA.stateValues.numericalEndpoints){let aA=rA.stateValues.numericalEndpoints,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);nA.push(sA)}else nA.push([]);return{setValue:{segmentsByObject:nA}}}},eA.getSegmentsForObject={returnDependencies:()=>({segmentsByObject:{dependencyType:"stateVariable",variableName:"segmentsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getSegmentsForObject:function(rA){return tA.segmentsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.threshold={description:"Distance within which group members attract each other.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,returnDependencies:()=>({thresholdAttr:{dependencyType:"attributeComponent",attributeName:"threshold",variableNames:["value"]},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"}}),definition({dependencyValues:tA}){return tA.thresholdAttr?{setValue:{threshold:tA.thresholdAttr.stateValues.value}}:{useEssentialOrDefaultValue:{threshold:{get defaultValue(){return tA.relativeToGraphScales&&tA.graphXmin!==null?.02:.5}}}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:nA}){return nA.thresholdAttr?{success:!0,instructions:[{setDependency:"thresholdAttr",desiredValue:tA.threshold}]}:{success:!0,instructions:[{setEssentialValue:"threshold",value:tA.threshold}]}}},eA.verticesConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},angleThreshold:{dependencyType:"stateVariable",variableName:"angleThreshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let nA;tA.relativeToGraphScales?nA=tA.scales||[1,1,1]:nA=[1,1,1];let rA=tA.angleThreshold,aA=function({numericalUnconstrainedEdges:cA,allowRotation:IA,enforceRigid:CA,shrinkThreshold:uA,rotationPoint:dA},{objectInd:pA}){let mA=tA.getSegmentsForObject(pA),QA=[],BA=[],hA=!1,DA={distance2:1/0},EA=tA.threshold;uA&&(EA*=.2);let fA=EA*EA;for(let[NA,yA]of cA.entries()){let bA=[],wA=[];for(let vA of mA)bA.push((OA,FA)=>nearestPointForSegment({point:OA,segment:vA,scales:FA})),wA.push((OA,FA)=>nearestPointForSegmentAsLine({point:OA,segment:vA,scales:FA}));let MA=attractSegment({segment:yA,allowRotation:IA,scales:nA,threshold2:fA,numericalNearestPointFunctions:bA,numericalNearestPointAsLineFunctions:wA});MA.constrained?(QA.push(MA.segment),BA.push(!0),hA=!0):(QA.push(yA),BA.push(!1),!hA&&MA.distance2<DA.distance2&&(DA=MA,DA.edgeInd=NA))}if(IA&&CA&&!hA&&DA.distance2<1/0){let NA=DA.edgeInd,yA=rotateIfClose({attractedEdgeInd:NA,attractingSegment:DA.segment,angleThreshold:rA,rotationPoint:dA,numericalUnconstrainedEdges:cA});yA&&(QA[NA]=yA,BA[NA]=!0,hA=!0)}if(IA&&CA&&!hA){let NA=[0,Math.PI/2],yA=rotateToAttractAngles({numericalUnconstrainedEdges:cA,anglesToAttract:NA,angleThreshold:rA,rotationPoint:dA});if(yA){let bA=yA.rotatedEdgeInd;QA[bA]=yA.rotatedEdge,BA[bA]=!0,hA=!0}}return{numericalConstrainedEdges:QA,constraintUsedForEdge:BA}},oA=function({numericalUnconstrainedVertices:cA,closed:IA,shrinkThreshold:CA,onlyMoveVertexInd:uA=null},{objectInd:dA}){let pA=tA.getPointsForObject(dA),mA=tA.getSegmentsForObject(dA),QA=[],BA=[],hA=tA.threshold;CA&&(hA*=.2);let DA=hA*hA;for(let[yA,bA]of cA.entries()){if(uA!==null&&yA!==uA){QA.push(bA),BA.push(!1);continue}let wA=1/0,MA={};for(let FA of pA){if(bA.length!==FA.length)continue;let kA=bA.reduce((SA,RA,xA)=>SA+Math.pow((RA-FA[xA])/nA[xA],2),0);kA<wA&&(MA=FA,wA=kA)}let vA=!1,OA;if(wA<DA)vA=!0,OA=MA;else{wA=1/0,MA={};for(let FA of mA){let kA=nearestPointForSegment({point:bA,segment:FA,scales:nA});if(kA){let SA=bA.reduce((RA,xA,ZA)=>RA+Math.pow((xA-kA[ZA])/nA[ZA],2),0);SA<wA&&(MA=kA,wA=SA)}}wA<DA?(vA=!0,OA=MA):OA=bA}QA.push(OA),BA.push(vA)}let EA=cA.length,fA=IA?EA:EA-1,NA=[];for(let yA=0;yA<fA;yA++){let bA=(yA+1)%EA;if(!(uA!==null&&!(uA===yA||uA===bA))&&!(BA[yA]||BA[bA])){let wA=cA[yA],MA=cA[bA],vA,OA=1/0;for(let FA of pA){let kA=nearestPointForSegment({point:FA,segment:[wA,MA],scales:nA});if(kA){let SA=kA.reduce((RA,xA,ZA)=>RA+Math.pow(xA-FA[ZA],2),0);if(SA<OA)if(uA===null){let RA=wA.map((ZA,XA)=>ZA+FA[XA]-kA[XA]),xA=MA.map((ZA,XA)=>ZA+FA[XA]-kA[XA]);vA=[RA,xA],OA=SA}else{let RA;uA===yA?RA=MA:RA=wA;let xA=[FA[0]-RA[0],FA[1]-RA[1]],ZA=Math.sqrt(Math.pow(xA[0],2)+Math.pow(xA[1],2)),jA=Math.sqrt(Math.pow(wA[0]-MA[0],2)+Math.pow(wA[1]-MA[1],2))/ZA;if(jA<1)continue;let TA=RA.map((VA,$A)=>VA+xA[$A]*jA),UA;uA===yA?(UA=[TA,MA],SA=Math.pow(wA[0]-TA[0],2)+Math.pow(wA[1]-TA[1],2)):(UA=[wA,TA],SA=Math.pow(MA[0]-TA[0],2)+Math.pow(MA[1]-TA[1],2)),SA<OA&&(OA=SA,vA=UA)}}}OA<DA&&NA.push({vertexInd1:yA,vertexInd2:bA,distance2:OA,movedSegment:vA})}}NA.sort((yA,bA)=>yA.distance2-bA.distance2);for(let{vertexInd1:yA,vertexInd2:bA,movedSegment:wA}of NA)BA[yA]||BA[bA]||(BA[yA]=!0,BA[bA]=!0,QA[yA]=wA[0],QA[bA]=wA[1]);return{numericalConstrainedVertices:QA,constraintUsedForVertex:BA}},sA=returnVertexConstraintFunctionFromEdges(aA),lA=returnVertexConstraintFunction(oA);return{setValue:{verticesConstraintFunction:function({unconstrainedVertices:cA,closed:IA,enforceRigid:CA,allowRotation:uA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}){let BA=sA({unconstrainedVertices:cA,closed:IA,enforceRigid:CA,allowRotation:uA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA});return BA=lA({unconstrainedVertices:BA,closed:IA,enforceRigid:CA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}),BA}}}}},eA.pointConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let nA;return tA.relativeToGraphScales?nA=tA.scales||[1,1,1]:nA=[1,1,1],{setValue:{pointConstraintFunction:function(aA,oA){let sA=aA.map(CA=>findFiniteNumericalValue(CA)),lA=tA.getPointsForObject(oA),gA=tA.getSegmentsForObject(oA),cA=1/0,IA={};for(let CA of lA){if(sA.length!==CA.length)continue;let uA=sA.reduce((dA,pA,mA)=>dA+Math.pow((pA-CA[mA])/nA[mA],2),0);uA<cA&&(IA=CA,cA=uA)}if(cA<tA.threshold*tA.threshold)return IA.map(CA=>context.fromAst(CA));cA=1/0,IA={};for(let CA of gA){let uA=nearestPointForSegment({point:sA,segment:CA,scales:nA});if(uA){let dA=sA.reduce((pA,mA,QA)=>pA+Math.pow((mA-uA[QA])/nA[QA],2),0);dA<cA&&(IA=uA,cA=dA)}}return cA<tA.threshold*tA.threshold?IA.map(CA=>context.fromAst(CA)):aA}}}}},eA}async addChildren(eA){return await addChildrenToDynamicChild(this,eA)}async deleteChildren(eA){return await deleteChildrenFromDynamicChild(this,eA)}}function rotateToAttractAngles({numericalUnconstrainedEdges:iA,anglesToAttract:eA,angleThreshold:AA,rotationPoint:tA}){let nA=1/0,rA;for(let[cA,IA]of iA.entries()){let CA=Math.atan((IA[1][1]-IA[0][1])/(IA[1][0]-IA[0][0]));for(let uA of eA){let dA=mod$6(uA-CA+Math.PI/2,Math.PI)-Math.PI/2;Math.abs(dA)<Math.abs(nA)&&(nA=dA,rA=cA)}}if(!(Math.abs(nA)<AA))return null;let[aA,oA]=tA,sA=Math.cos(nA),lA=Math.sin(nA),gA=iA[rA].map(cA=>{let IA=cA[0]-aA,CA=cA[1]-oA;return[IA*sA-CA*lA+aA,IA*lA+CA*sA+oA]});return{rotatedEdgeInd:rA,rotatedEdge:gA}}function rotateIfClose({attractedEdgeInd:iA,attractingSegment:eA,angleThreshold:AA,rotationPoint:tA,numericalUnconstrainedEdges:nA}){let rA=Math.atan((eA[1][1]-eA[0][1])/(eA[1][0]-eA[0][0])),aA=nA[iA],oA=Math.atan((aA[1][1]-aA[0][1])/(aA[1][0]-aA[0][0])),sA=mod$6(rA-oA+Math.PI/2,Math.PI)-Math.PI/2;if(!(Math.abs(sA)<AA))return null;let[lA,gA]=tA,cA=Math.cos(sA),IA=Math.sin(sA);return nA[iA].map(uA=>{let dA=uA[0]-lA,pA=uA[1]-gA;return[dA*cA-pA*IA+lA,dA*IA+pA*cA+gA]})}class BlockScoredComponent extends BlockComponent{static componentType="_blockScoredComponent";static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnStandardAnswerAttributes()),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"disabled",newName:"disabledOriginal"}),Object.assign(eA,returnStandardAnswerStateVariableDefinition()),eA}}function parseIntegerResponse(iA){const eA=iA.trim();if(eA==="")return null;const AA=Number(eA);return Number.isInteger(AA)?AA:null}function isDistractorResponse(iA){return iA.trim().toLowerCase()==="x"}function calculateResponseOffset({numericResponse:iA,effectiveProblemNum:eA,numEffectiveProblems:AA}){return(iA-eA+AA)%AA}function calculatePretzelCredit({problemOrder:iA,currentResponses:eA,distractors:AA,mode:tA}){const nA=new Set(AA),rA=iA.length,aA=rA-nA.size;if(aA===0)return eA.every(isDistractorResponse)?1:0;const oA=Array(rA).fill(null);let sA=0;for(let CA=0;CA<rA;CA++)nA.has(CA)||(oA[CA]=sA,sA++);const lA=[],gA=tA==="circuit"?aA===1?0:1:null;for(let CA=0;CA<rA;CA++){const uA=iA[CA],dA=eA[CA]??"";if(nA.has(uA)){if(!isDistractorResponse(dA))return 0;continue}const pA=parseIntegerResponse(dA);if(pA===null)return 0;const mA=oA[uA],QA=calculateResponseOffset({numericResponse:pA,effectiveProblemNum:mA,numEffectiveProblems:aA});if(tA==="circuit"){if(QA!==gA)return 0;continue}lA.push(QA)}if(tA==="circuit")return 1;const cA=lA[0];return lA.every(CA=>CA===cA)?1:0}class Pretzel extends BlockScoredComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this),submitAnswer:this.submitAnswer.bind(this)})}static componentType="pretzel";static componentDocs={summary:"A response-matching component where students enter a sequence to match statements and answers"};static renderChildren=!0;static additionalSchemaChildren=["problem"];static additionalSchemaChildrenDoNotInherit=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.maxNumColumns={description:"Maximum number of columns when arranging child problems.",createComponentOfType:"integer",createStateVariable:"maxNumColumns",defaultValue:2,public:!0,forRenderer:!0,clamp:[1,4]},eA.mode={description:"Arrangement mode for the child problems.",createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static returnChildGroups(){return[{group:"problems",componentTypes:["statement"],excludeFromSchema:!0},{group:"textInputs",componentTypes:["textInput"],excludeFromSchema:!0},{group:"givenAnswers",componentTypes:["span"],excludeFromSchema:!0}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.textInputs={returnDependencies:()=>({textInputs:{dependencyType:"child",childGroups:["textInputs"]}}),definition:function({dependencyValues:AA}){return{setValue:{textInputs:AA.textInputs}}}},eA.problemOrder={stateVariablesDeterminingDependencies:["textInputs"],additionalStateVariablesDefined:["distractors"],returnDependencies({stateValues:AA}){return AA.textInputs.length>0?{problemOrder:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"problemOrder"},distractors:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"distractors"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{problemOrder:AA.problemOrder??[],distractors:AA.distractors??[]}}}},eA.numProblems={description:"The number of child problems.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({problemChildren:{dependencyType:"child",childGroups:["problems"]}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.problemChildren.length}}}},eA.currentResponses={description:"The current responses across all child problems.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,entryPrefixes:["currentResponse"],returnArraySizeDependencies:()=>({numProblems:{dependencyType:"stateVariable",variableName:"numProblems"}}),returnArraySize({dependencyValues:AA}){return[AA.numProblems]},returnArrayDependenciesByKey({arrayKeys:AA}){const tA={};for(const nA of AA)tA[nA]={textInput:{dependencyType:"child",childGroups:["textInputs"],childIndices:[nA],variableNames:["value"]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA}){const tA={};for(const nA in AA)tA[nA]=AA[nA].textInput[0].stateValues.value;return{setValue:{currentResponses:tA}}}},eA.creditAchievedIfSubmit={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},currentResponses:{dependencyType:"stateVariable",variableName:"currentResponses"},distractors:{dependencyType:"stateVariable",variableName:"distractors"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=AA.problemOrder.map(nA=>nA-1);return{setValue:{creditAchievedIfSubmit:calculatePretzelCredit({problemOrder:tA,currentResponses:AA.currentResponses,distractors:AA.distractors,mode:AA.mode})}}}},eA.numSubmittedResponses={description:"The number of responses submitted.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,defaultValue:0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{numSubmittedResponses:!0}}),inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"numSubmittedResponses",value:AA.numSubmittedResponses}]}}},eA.submittedResponses={description:"The most recently submitted responses.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,allowExtraArrayKeysInInverse:!0,entryPrefixes:["submittedResponse"],defaultValueByArrayKey:()=>"_",hasEssential:!0,inverseShadowToSetEntireArray:!0,doNotCombineInverseArrayInstructions:!0,returnArraySizeDependencies:()=>({numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}),returnArraySize({dependencyValues:AA}){return[AA.numSubmittedResponses]},returnArrayDependenciesByKey(){return{globalDependencies:{numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA=[];AA.submittedResponsesComponentType&&tA.push(...AA.submittedResponsesComponentType.slice(0,AA.numSubmittedResponses));let nA={};for(let rA=0;rA<AA.numSubmittedResponses;rA++)nA[rA]=!0;return{useEssentialOrDefaultValue:{submittedResponses:nA}}},inverseArrayDefinitionByKey:function({desiredStateVariableValues:AA,initialChange:tA}){return tA?{success:!0,instructions:[{setDependency:"numSubmittedResponses",desiredValue:AA.submittedResponses.length},{setEssentialValue:"submittedResponses",value:[...AA.submittedResponses]}]}:{success:!1}}},eA.showCheckWork={forRenderer:!0,returnDependencies:()=>({suppressCheckWork:{dependencyType:"stateVariable",variableName:"suppressCheckWork"}}),definition({dependencyValues:AA}){return{setValue:{showCheckWork:!AA.suppressCheckWork}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}async submitAnswer({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(await this.stateValues.numAttemptsLeft<1||await this.stateValues.disabled)return;const aA=await this.stateValues.handGraded?0:await this.stateValues.creditAchievedIfSubmit;let oA=[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchieved",value:aA},{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"responseHasBeenSubmitted",value:!0}],sA=await this.stateValues.currentResponses;oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"submittedResponses",value:sA}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"justSubmitted",value:!0}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchievedDependenciesAtSubmit",value:await this.stateValues.creditAchievedDependencies}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numSubmissions",value:await this.stateValues.numSubmissions+1}),aA<1&&oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numIncorrectSubmissions",value:await this.stateValues.numIncorrectSubmissions+1});const lA=[];for(const gA of sA)if(gA.toString)try{lA.push(gA.toString())}catch{lA.push("_")}else lA.push(gA);return oA.push({updateType:"recordItemSubmission",componentNumber:await this.stateValues.inComponentNumber,submittedComponent:this.componentIdx,response:sA,responseText:lA,creditAchieved:aA}),await this.coreFunctions.performUpdate({updateInstructions:oA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"submitted",object:{componentIdx:this.componentIdx,componentType:this.componentType,answerNumber:this.answerNumber,rootName:this.rootName},result:{response:sA,responseText:lA,componentTypes:Array(sA.length).fill("text"),creditAchieved:aA}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}function getCorrespondingAnswerIdx({problemIdx:iA,numProblems:eA,distractorSet:AA}){if(AA.has(iA))return iA;let tA=(iA-1+eA)%eA,nA=0;for(;AA.has(tA)&&nA<eA;)tA=(tA-1+eA)%eA,nA++;return tA}function normalizePretzelMode(iA){return iA?.toLowerCase()==="circuit"?"circuit":"pretzel"}function getProblemIndicesToPermute({numProblems:iA,mode:eA}){const AA=eA==="circuit"?2:1;return[...Array(Math.max(iA-AA+1,0)).keys()].map(tA=>tA+AA)}function buildProblemOrderFromPermutedIndices({permutedIndices:iA,numProblems:eA,mode:AA}){return AA==="circuit"?eA===0?[]:[1,...iA]:iA}function determineNumberOfPermutations({numProblems:iA,mode:eA}){const AA=getProblemIndicesToPermute({numProblems:iA,mode:eA}).length;let tA=1;for(let nA=2;nA<=AA;nA++)tA*=nA;return tA}function shuffleProblemOrder({numProblems:iA,variantRng:eA,mode:AA}){const tA=getProblemIndicesToPermute({numProblems:iA,mode:AA});for(let nA=tA.length-1;nA>0;nA--){const rA=eA(),aA=Math.floor(rA*(nA+1));[tA[nA],tA[aA]]=[tA[aA],tA[nA]]}return buildProblemOrderFromPermutedIndices({permutedIndices:tA,numProblems:iA,mode:AA})}class PretzelArranger extends CompositeComponent{static componentType="_pretzelArranger";static componentDocs={summary:"Internal arranger that lays out subset visualizations within <pretzel>."};static createsVariants=!0;static serializeReplacementsForChildren=!0;static replacementsAlreadyInResolver=!0;static useSerializedChildrenComponentIndices=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.mode={createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.serializedProblemChildren={returnDependencies:()=>({serializedChildren:{dependencyType:"serializedChildren",doNotProxy:!0}}),definition:function({dependencyValues:AA}){return{setValue:{serializedProblemChildren:AA.serializedChildren.filter(tA=>tA.componentType==="problem")}}}},eA.numProblems={description:"The number of problems arranged.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.serializedProblemChildren.length}}}},eA.problemOrder={forRenderer:!0,shadowVariable:!0,returnDependencies:({sharedParameters:AA})=>({mode:{dependencyType:"stateVariable",variableName:"mode"},numProblems:{dependencyType:"stateVariable",variableName:"numProblems"},variantSeed:{dependencyType:"value",value:AA.variantSeed},rngClass:{dependencyType:"value",value:AA.rngClass,doNotProxy:!0},variants:{dependencyType:"variants"}}),definition:function({dependencyValues:AA}){let tA=AA.numProblems,nA=[],rA;const aA=AA.mode;let oA=AA.variants?.desiredVariant?.indices;if(oA!==void 0)if(oA.length!==tA)nA.push(codedDiagnostic({type:"info",code:"doenet-i0005"}));else{if(oA=oA.map(Number),!oA.every(Number.isInteger))throw Error("All indices specified for pretzel must be integers");if(!oA.every(lA=>lA>=1&&lA<=tA))nA.push(codedDiagnostic({type:"info",code:"doenet-i0007",args:{component:"pretzel"}}));else if(new Set(oA).size!==tA)nA.push(codedDiagnostic({type:"info",code:"doenet-i0008"}));else if(aA==="circuit"&&tA>0&&oA[0]!==1)nA.push(codedDiagnostic({type:"info",code:"doenet-i0009"}));else return{setValue:{problemOrder:oA}}}let sA=AA.rngClass(AA.variantSeed+"co");return rA=shuffleProblemOrder({numProblems:tA,variantRng:sA,mode:aA}),{setValue:{problemOrder:rA},sendDiagnostics:nA}}},eA.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({componentInfoObjects:AA,sharedParameters:tA})=>({variantSeed:{dependencyType:"value",value:tA.variantSeed},problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(AA.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],useReplacementsForComposites:!0,recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:AA,componentIdx:tA}){let nA={seed:AA.variantSeed,meta:{createdBy:tA},indices:AA.problemOrder},rA=nA.subvariants=[];for(let aA of AA.variantDescendants)aA.stateValues.isVariantComponent?rA.push(aA.stateValues.generatedVariantInfo):aA.stateValues.generatedVariantInfo&&rA.push(...aA.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:nA,isVariantComponent:!0}}}},eA.statements={additionalStateVariablesDefined:["givenAnswers","validProblems","distractors"],returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=[],nA=[],rA=[];let aA=!0;const oA=[];for(const[sA,lA]of AA.serializedProblemChildren.entries()){let gA=null,cA=null;for(const IA of lA.children)if(IA.componentType==="statement")gA=IA;else if(IA.componentType==="givenAnswer"){const CA=IA.children.find(uA=>uA.componentType==="_postponeRenderContainer");CA&&(cA={...CA,componentType:"span",attributes:{...CA.attributes},children:(CA.children??[]).filter(uA=>uA.componentType!=="label"&&uA.componentType!=="shortDescription")},cA.componentIdx=IA.componentIdx,IA.attributes.name&&(cA.attributes.name=IA.attributes.name))}(gA===null||cA===null)&&(aA=!1),tA.push(gA),nA.push(cA),lA.attributes.isDistractor?.primitive.value&&rA.push(sA)}return aA||oA.push(codedDiagnostic({type:"warning",code:"doenet-w0076"})),AA.mode==="circuit"&&rA.includes(0)&&oA.push(codedDiagnostic({type:"error",code:"doenet-e0001"})),{setValue:{statements:tA,givenAnswers:nA,validProblems:aA,distractors:rA},sendDiagnostics:oA}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},statements:{dependencyType:"stateVariable",variableName:"statements"},givenAnswers:{dependencyType:"stateVariable",variableName:"givenAnswers"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){tA.replacementsCreated===void 0&&(tA.replacementsCreated=0);const nA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated},rA=[];let aA=[];const oA=await eA.stateValues.numProblems,sA=await eA.stateValues.problemOrder,lA=await eA.stateValues.statements,gA=await eA.stateValues.givenAnswers,cA=await eA.stateValues.distractors,IA=await eA.stateValues.mode,CA=new Set(cA);for(let uA=0;uA<oA;uA++){const dA=sA[uA]-1,pA=lA[dA],mA=getCorrespondingAnswerIdx({problemIdx:dA,numProblems:oA,distractorSet:CA}),QA=gA[mA];QA===null?aA.push({type:"serialized",componentType:"span",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(QA),aA.push({type:"serialized",componentType:"textInput",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{width:{type:"component",name:"width",component:{type:"serialized",componentType:"componentSize",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,state:{componentSize:{size:15,isAbsolute:!0}},children:[],attributes:{},doenetAttributes:{}}}},doenetAttributes:{},state:IA==="circuit"&&uA===0?{value:"1",disabledPreliminary:!0}:{},children:[{type:"serialized",componentType:"shortDescription",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,state:{},children:[{type:"serialized",componentType:"text",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,state:{value:"Enter number in sequence for this answer or X if it is a distractor"},children:[],attributes:{},doenetAttributes:{}}],attributes:{},doenetAttributes:{}}]}),pA===null?aA.push({type:"serialized",componentType:"statement",componentIdx:AA++,stateId:`${nA.prefix}${nA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(pA)}return tA.replacementsCreated=nA.num,{replacements:aA,diagnostics:rA,nComponents:AA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}static determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA}){let nA=0;const rA=normalizePretzelMode(eA.attributes.mode?.primitive?.value);for(let lA of eA.children)if(lA.componentType==="problem")nA++;else if(AA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:"_composite"})&&lA.attributes.createComponentOfType?.primitive.value==="problem")if(lA.attributes.numProblems?.primitive!==void 0){let gA=Number(lA.attributes.numProblems?.primitive.value);if(Number.isInteger(gA)&&gA>=0)nA+=gA;else return{success:!1}}else nA++;else return{success:!1};let aA=determineNumberOfPermutations({numProblems:nA,mode:rA}),oA=super.determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA});if(!oA.success)return{success:!1};let sA=oA.numVariants*aA;return eA.variants.numVariants=sA,eA.variants.uniqueVariantData={numVariantsByDescendant:eA.variants.uniqueVariantData.numVariantsByDescendant,numberOfPermutations:aA,numProblems:nA,mode:rA},{success:!0,numVariants:sA}}static getUniqueVariant({serializedComponent:eA,variantIndex:AA,componentInfoObjects:tA}){let nA=eA.variants?.numVariants;if(nA===void 0)return{success:!1};if(!Number.isInteger(AA)||AA<1||AA>nA)return{success:!1};let rA=eA.variants.uniqueVariantData.numVariantsByDescendant,aA=eA.variants.descendantVariantComponents,oA=eA.variants.uniqueVariantData.numberOfPermutations,sA=eA.variants.uniqueVariantData.numProblems;const lA=normalizePretzelMode(eA.variants.uniqueVariantData.mode);let gA=[...rA];gA.push(oA);let cA=enumerateCombinations({numberOfOptionsByIndex:gA,maxNumber:AA})[AA-1].map(BA=>BA+1),IA=cA.pop(),CA=cA;const uA=getProblemIndicesToPermute({numProblems:sA,mode:lA}),dA=buildProblemOrderFromPermutedIndices({permutedIndices:enumeratePermutations({values:uA,maxNumber:IA})[IA-1],numProblems:sA,mode:lA});let pA=!1,mA=[];for(let BA=0;BA<rA.length;BA++)if(rA[BA]>1){let hA=aA[BA],EA=tA.allComponentClasses[hA.componentType].getUniqueVariant({serializedComponent:hA,variantIndex:CA[BA],componentInfoObjects:tA});if(!EA.success)return{success:!1};mA.push(EA.desiredVariant),pA=!0}else mA.push({});let QA={indices:dA};return pA&&(QA.subvariants=mA),{success:!0,desiredVariant:QA}}}class Cascade extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="cascade";static componentDocs={summary:"Reveals its children one step at a time, each once the steps before it are complete"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!1;static createAttributesObject(){let eA=super.createAttributesObject();return eA.hideFutureSections={createComponentOfType:"boolean",createStateVariable:"hideFutureSections",defaultValue:!1,public:!0,description:"Whether to hide later cascade sections until previous ones are completed."},eA.revealAll={createComponentOfType:"boolean",createStateVariable:"revealAllPreliminary",defaultValue:!1,description:"Whether all cascade entries should be revealed regardless of progress."},eA.boxAll={createComponentOfType:"boolean",createStateVariable:"boxAll",defaultValue:!1,description:"Whether to draw boxes around all cascade entries regardless of progress."},Object.assign(eA,returnSectionTitleStateColorAttributes()),eA}static returnChildGroups(){return[{group:"titles",componentTypes:["title"]},{group:"setups",componentTypes:["setup"]},{group:"cascadeMessages",componentTypes:["cascadeMessage"]},{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnCascadeStepStateVariableDefinitions()),Object.assign(eA,returnSectionTitleStateColorStateVariableDefinitions()),eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},titleChildren:{dependencyType:"child",childGroups:["titles"]},asList:{dependencyType:"stateVariable",variableName:"asList"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"}}),definition({dependencyValues:tA,componentInfoObjects:nA}){const rA=new Set(tA.titleChildren.map(sA=>sA.componentIdx)),aA=[];for(const[sA,lA]of tA.allChildren.entries()){if(typeof lA=="string"){!tA.hideChildren&&!tA.asList&&aA.push(sA);continue}rA.has(lA.componentIdx)||tA.asList&&!LIST_CONTAINER_TYPES.some(gA=>nA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:gA}))&&!["introduction","conclusion"].includes(lA.componentType)||aA.push(sA)}const oA=tA.titleChildren.map(sA=>codedDiagnostic({type:"warning",code:"doenet-w0167",position:sA.position||void 0}));return{setValue:{childIndicesToRender:aA},sendDiagnostics:oA}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this cascade's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:tA}){return{setValue:{asList:!!tA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA.childrenAggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{childrenAggregateScores:!0}})};const AA=returnScoredSectionStateVariableDefinition();return eA.aggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{aggregateScores:!0}})},eA.scoredDescendants=AA.scoredDescendants,eA.creditAchievedForProgress=AA.creditAchievedForProgress,eA.childCreditAchieved={returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["creditAchievedForProgress"],variablesOptional:!0}}),definition({dependencyValues:tA}){return{setValue:{childCreditAchieved:tA.children.map(rA=>rA.stateValues?.creditAchievedForProgress??null)}}}},eA.numCompleted={description:"The number of cascade sections currently completed.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({childCreditAchieved:{dependencyType:"stateVariable",variableName:"childCreditAchieved"}}),definition({dependencyValues:tA}){let nA=0;for(const rA of tA.childCreditAchieved)if(rA===1||rA===null)nA++;else break;return{setValue:{numCompleted:nA}}}},eA.revealAll={returnDependencies:()=>({cascadeAncestor:{dependencyType:"ancestor",componentType:"cascade",variableNames:["revealAll"]},revealAllPreliminary:{dependencyType:"stateVariable",variableName:"revealAllPreliminary"}}),definition({dependencyValues:tA,usedDefault:nA}){let rA=!1;return nA.revealAllPreliminary?tA.cascadeAncestor&&(rA=tA.cascadeAncestor.stateValues.revealAll):rA=tA.revealAllPreliminary,{setValue:{revealAll:rA}}}},eA.childrenToHide={additionalStateVariablesDefined:["childrenToHideChildren","sectionToShowCascadeMessage"],returnDependencies:()=>({hideFutureSections:{dependencyType:"stateVariable",variableName:"hideFutureSections"},numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"],variableNames:["hasCascadeMessageToShow"],variablesOptional:!0},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"},showCascadeMessage:{dependencyType:"stateVariable",variableName:"showCascadeMessage"}}),definition({dependencyValues:tA,componentInfoObjects:nA}){const rA=tA.childrenWithCascadeMessages.filter(cA=>cA.componentType==="cascadeMessage").map(cA=>cA.componentIdx);if(tA.revealAll)return{setValue:{childrenToHide:rA,childrenToHideChildren:[],sectionToShowCascadeMessage:null}};const aA=[],oA=[];for(const[cA,IA]of tA.children.entries())cA<=tA.numCompleted?tA.hideChildren&&aA.push(IA.componentIdx):!tA.hideChildren&&!tA.hideFutureSections&&["_sectioningComponent","cascade"].some(CA=>nA.isInheritedComponentType({inheritedComponentType:IA.componentType,baseComponentType:CA}))?oA.push(IA.componentIdx):aA.push(IA.componentIdx);const sA=tA.children[tA.numCompleted+1],lA=sA&&oA.includes(sA.componentIdx)&&sA.stateValues?.hasCascadeMessageToShow?sA.componentIdx:null,gA=lA===null&&(!tA.hideChildren||tA.showCascadeMessage)?nextOwnCascadeMessage(tA):null;return aA.push(...rA.filter(cA=>cA!==gA)),{setValue:{childrenToHide:aA,childrenToHideChildren:oA,sectionToShowCascadeMessage:lA}}}},eA.hasCascadeMessageToShow={returnDependencies:()=>({numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"]},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"}}),definition({dependencyValues:tA}){return{setValue:{hasCascadeMessageToShow:nextOwnCascadeMessage(tA)!==null}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}function nextOwnCascadeMessage(iA){if(iA.revealAll||iA.numCompleted>iA.children.length-2)return null;const eA=iA.children[iA.numCompleted].componentIdx,AA=iA.childrenWithCascadeMessages.findIndex(tA=>tA.componentIdx===eA);return iA.childrenWithCascadeMessages.slice(AA+1).find(tA=>tA.componentType==="cascadeMessage")?.componentIdx??null}class Page extends BlockComponent{static componentType="page";static componentDocs={summary:"The content of one printed page"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},asList:{dependencyType:"stateVariable",variableName:"asList"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){const nA=[];for(const[rA,aA]of AA.allChildren.entries())(!AA.asList||typeof aA!="string"&&(LIST_CONTAINER_TYPES.some(oA=>tA.isInheritedComponentType({inheritedComponentType:aA.componentType,baseComponentType:oA}))||["introduction","conclusion"].includes(aA.componentType)))&&nA.push(rA);return{setValue:{childIndicesToRender:nA}}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this page's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:AA}){return{setValue:{asList:!!AA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA}}class DynamicChildren extends CompositeComponent{constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentType="_dynamicChildren";static componentDocs={summary:"Internal container for dynamically-generated children."};static treatAsComponentForRecursiveReplacements=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.deferUntilParentRendered={createComponentOfType:"boolean",createStateVariable:"deferUntilParentRendered",defaultValue:!1,description:"Whether to wait until the parent is rendered before creating dynamic children."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.dynamicChildren={hasEssential:!0,defaultValue:[],returnDependencies:()=>({}),definition:function(){return{useEssentialOrDefaultValue:{dynamicChildren:!0}}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"dynamicChildren",value:AA.dynamicChildren}]}}},eA.createReplacements={stateVariablesDeterminingDependencies:["deferUntilParentRendered"],returnDependencies:({stateValues:AA})=>{const tA={deferUntilParentRendered:{dependencyType:"stateVariable",variableName:"deferUntilParentRendered"}};return AA.deferUntilParentRendered&&(tA.parentRendered={dependencyType:"parentStateVariable",variableName:"rendered"}),tA},definition({dependencyValues:AA}){return{setValue:{createReplacements:!AA.deferUntilParentRendered||AA.parentRendered!==!1}}},markStale(){return{updateReplacements:!0}}},eA.nGroups={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"}}),definition({dependencyValues:AA}){return{setValue:{nGroups:AA.dynamicChildren.length}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"},createReplacements:{dependencyType:"stateVariable",variableName:"createReplacements"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}},markStale(){return{updateReplacements:!0}}},eA}async addChildren({serializedComponents:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){if(eA&&eA.length>0){const rA=[...await this.stateValues.dynamicChildren];return rA.push({type:"serialized",componentType:"group",componentIdx:0,attributes:{},doenetAttributes:{},state:{},children:deepClone(eA)}),await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:rA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:nA})}else return}async deleteChildren({number:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:nA=!1}){const rA=await this.stateValues.nGroups;let aA=Math.min(eA,rA);if(aA>0){const oA=(await this.stateValues.dynamicChildren).slice(0,rA-aA);return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:oA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:nA})}else return}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){let nA=[];tA.replacementsCreated===void 0&&(tA.replacementsCreated=0),tA.replacementsCreatedThroughGroup=[];let rA=[];if(!await eA.stateValues.createReplacements)return tA.nGroups=0,{replacements:rA,diagnostics:nA,nComponents:AA};const aA=await eA.stateValues.nGroups;for(let oA=0;oA<aA;oA++){let sA=await this.replacementForGroup({component:eA,groupNum:oA,nComponents:AA,workspace:tA}),lA=sA.replacements;AA=sA.nComponents,rA.push(...lA)}return tA.nGroups=aA,{replacements:rA,diagnostics:nA,nComponents:AA}}static async replacementForGroup({component:eA,groupNum:AA,nComponents:tA,workspace:nA}){let rA=[deepClone((await eA.stateValues.dynamicChildren)[AA])];const aA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated},oA=createNewComponentIndices(rA,tA,aA);return rA=oA.components,tA=oA.nComponents,nA.replacementsCreated=aA.num,nA.replacementsCreatedThroughGroup=[...nA.replacementsCreatedThroughGroup,nA.replacementsCreated],{replacements:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,nComponents:AA,workspace:tA}){const rA=await eA.stateValues.createReplacements?await eA.stateValues.nGroups:0;if(rA===tA.nGroups)return{replacementChanges:[],nComponents:AA};if(rA<tA.nGroups){const sA=[{changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:rA,numberReplacementsToDelete:tA.nGroups-rA}];return tA.nGroups=rA,tA.replacementsCreated=tA.replacementsCreatedThroughGroup[rA-1]||0,tA.replacementsCreatedThroughGroup=tA.replacementsCreatedThroughGroup.slice(0,rA),{replacementChanges:sA,nComponents:AA}}let aA=[];for(let sA=tA.nGroups;sA<rA;sA++){let lA=await this.replacementForGroup({component:eA,groupNum:sA,nComponents:AA,workspace:tA}),gA=lA.replacements;AA=lA.nComponents,aA.push(...gA)}let oA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA.nGroups,numberReplacementsToReplace:0,serializedReplacements:aA,replacementsToWithhold:0};return tA.nGroups=rA,{replacementChanges:[oA],nComponents:AA}}}class ShortDescription extends TextOrInline{static componentType="shortDescription";static componentDocs={summary:"A short accessibility description (e.g. for a `<graph>`) read by screen readers"};static rendererType=void 0;static inSchemaOnlyInheritAs=[];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.inlineChildren={returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:({dependencyValues:AA})=>({setValue:{inlineChildren:AA.inlineChildren}})},eA.value={description:"The short description text.",public:!0,shadowingInstructions:{createComponentOfType:this.componentType},stateVariablesDeterminingDependencies:["inlineChildren"],returnDependencies:({stateValues:AA})=>{const tA={inlineChildren:{dependencyType:"stateVariable",variableName:"inlineChildren"}};for(const[nA,rA]of AA.inlineChildren.entries())typeof rA=="object"&&(tA[`adapterSource${nA}`]={dependencyType:"adapterSource",componentIdx:rA.componentIdx});return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){const nA=textFromChildren(AA.inlineChildren);let rA;for(let oA=0;oA<AA.inlineChildren.length;oA++){const sA=AA.inlineChildren[oA];if(typeof sA!="object")continue;const lA=AA[`adapterSource${oA}`]?.componentType??sA.componentType;if(tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"math"})||tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"m"})){rA=lA;break}}const aA=[];return rA&&aA.push(codedDiagnostic({type:"accessibility",level:2,code:"doenet-a0005",args:{component:rA}})),{setValue:{value:nA},sendDiagnostics:aA}}},eA}}const unitConversions={"":1,px:1,pixel:1,pixels:1,"%":1,em:100,in:96,inch:96,inches:96,pt:1.333333333333,mm:3.7795296,millimeter:3.7795296,millimeters:3.7795296,cm:37.795296,centimeter:37.795296,centimeters:37.795296};class ComponentSize extends InlineComponent{static componentType="componentSize";static rendererType="text";static excludeFromSchema=!0;static primaryStateVariableForDefinition="componentSize";static stateVariableToBeShadowed="componentSize";static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){let aA=tA[tA.length-1];if(typeof aA=="string"){let oA=/([a-zA-z]+|%)$/,sA=aA.trim(),lA=sA.match(oA);if(lA){let gA=lA[1];if(gA in unitConversions){let cA=sA.slice(0,lA.index),IA=tA.slice(0,tA.length-1);return cA.length>0&&IA.push(cA),{success:!0,newChildren:[{type:"serialized",componentType:"number",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:IA,attributes:{},doenetAttributes:{},state:{}},gA],nComponents:nA}}}}return{success:!0,newChildren:[{componentType:"number",children:tA}]}};return eA.push({childrenRegex:/..+/,replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"strings",componentTypes:["string"]},{group:"numbers",componentTypes:["number"]},{group:"componentSizes",componentTypes:["componentSize"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA);let tA=returnTextStyleDescriptionDefinitions();return Object.assign(eA,tA),eA.componentSize={description:"The size value with its associated unit (absolute pixels or relative percent).",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},hasEssential:!0,returnDependencies:()=>({componentSizeChild:{dependencyType:"child",childGroups:["componentSizes"],variableNames:["componentSize"]},numberChild:{dependencyType:"child",childGroups:["numbers"],variableNames:["value"]},stringChild:{dependencyType:"child",childGroups:["strings"],variableNames:["value"]},parentDefaultAbsoluteSize:{dependencyType:"parentStateVariable",variableName:"defaultAbsoluteSize"}}),definition({dependencyValues:nA}){let rA=nA.parentDefaultAbsoluteSize===void 0?!1:nA.parentDefaultAbsoluteSize;if(nA.stringChild.length===0)return nA.numberChild.length===0?nA.componentSizeChild.length===0?{useEssentialOrDefaultValue:{componentSize:{defaultValue:{size:100,isAbsolute:rA}}}}:{setValue:{componentSize:nA.componentSizeChild[0].stateValues.componentSize}}:{setValue:{componentSize:{size:nA.numberChild[0].stateValues.value,isAbsolute:!0}}};{let aA,oA;if(nA.numberChild.length>0)aA=nA.numberChild[0].stateValues.value,oA=nA.stringChild[0].trim();else{let cA=nA.stringChild[0].trim().match(/^(-?[\d.]+)\s*(.*)$/);if(cA===null)return{setValue:{componentSize:null}};aA=cA[1],oA=cA[2].trim()}if(aA=Number(aA),!Number.isFinite(aA))return{setValue:{componentSize:null}};let sA=!(oA==="%"||oA==="em"),lA=unitConversions[oA];return lA===void 0&&(lA=1),{setValue:{componentSize:{size:lA*aA,isAbsolute:sA}}}}},inverseDefinition({desiredStateVariableValues:nA,dependencyValues:rA}){if(rA.stringChild.length===0)return rA.numberChild.length===0?rA.componentSizeChild.length===0?{success:!0,instructions:[{setEssentialValue:"componentSize",value:nA.componentSize}]}:{success:!0,instructions:[{setDependency:"componentSizeChild",desiredValue:nA.componentSize,childIndex:0,variableIndex:0}]}:nA.componentSize.isAbsolute?{success:!0,instructions:[{setDependency:"numberChild",desiredValue:nA.componentSize.size,childIndex:0,variableIndex:0}]}:{success:!1};if(rA.numberChild.length>0){let aA=rA.stringChild[0].trim(),oA=!(aA==="%"||aA==="em");if(nA.componentSize.isAbsolute!==oA)return{success:!1};let sA=unitConversions[aA];return sA===void 0&&(sA=1),{success:!0,instructions:[{setDependency:"numberChild",desiredValue:nA.componentSize.size/sA,childIndex:0,variableIndex:0}]}}else{let aA=nA.componentSize.size;return nA.componentSize.isAbsolute?aA+="px":aA+="%",{success:!0,instructions:[{setDependency:"stringChild",desiredValue:aA,childIndex:0,variableIndex:0}]}}}},eA.number={description:"The numeric portion of the size.",public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:nA}){let rA=null;return nA.componentSize&&(rA=nA.componentSize.size),{setValue:{number:rA}}},inverseDefinition({desiredStateVariableValues:nA,dependencyValues:rA}){return rA.componentSize?{success:!0,instructions:[{setDependency:"componentSize",desiredValue:{size:nA.number,isAbsolute:rA.componentSize.isAbsolute}}]}:{success:!1}}},eA.math=mathStateVariableFromNumberStateVariable({numberVariableName:"number",mathVariableName:"math",isPublic:!0}),eA.math.description="The size as a math expression.",eA.isAbsolute={description:"Whether the size uses absolute units (pixels) rather than relative units (percent).",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:nA}){let rA=null;return nA.componentSize&&(rA=nA.componentSize.isAbsolute),{setValue:{isAbsolute:rA}}}},eA.text={forRenderer:!0,returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:nA}){let rA="";return nA.componentSize&&(rA=nA.componentSize.size,nA.componentSize.isAbsolute?rA+="px":rA+="%"),{setValue:{text:rA}}}},eA}static adapters=["number","math"]}class ComponentSizeList extends BaseComponent{static componentType="_componentSizeList";static rendererType="asList";static renderChildren=!0;static stateVariableToBeShadowed="componentSizes";static additionalSchemaChildren=["string","number"];static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){let aA=[],oA=[],sA=function(){oA.length>0&&(aA.push({type:"serialized",componentType:"componentSize",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}}),oA=[])};for(let lA of tA)if(typeof lA=="string"){let gA=lA.split(/\s+/);gA[0].length===0&&(sA(),gA=gA.slice(1));for(let[cA,IA]of gA.entries())IA.length>0?(oA.push(IA),cA<gA.length-1&&sA()):sA()}else oA.push(lA);return sA(),{success:!0,newChildren:aA,nComponents:nA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"componentSizes",componentTypes:["componentSize"]},{group:"componentSizeLists",componentTypes:["_componentSizeList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.overrideChildHide={returnDependencies:()=>({}),definition:()=>({setValue:{overrideChildHide:!0}})},eA.numComponents={description:"The number of size values in the list.",public:!0,shadowingInstructions:{createComponentOfType:"number"},additionalStateVariablesDefined:["childIndexByArrayKey"],returnDependencies(){return{componentSizeListChildren:{dependencyType:"child",childGroups:["componentSizeLists"],variableNames:["numComponents"]},componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],skipComponentIndices:!0}}},definition:function({dependencyValues:AA,componentInfoObjects:tA}){let nA=0,rA=[],aA=0;for(let[oA,sA]of AA.componentSizeAndComponentSizeListChildren.entries())if(tA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.componentSizeListChildren[aA];aA++;for(let gA=0;gA<lA.stateValues.numComponents;gA++)rA[nA+gA]=[oA,gA];nA+=lA.stateValues.numComponents}else rA[nA]=[oA,0],nA+=1;return{setValue:{numComponents:nA,childIndexByArrayKey:rA},checkForActualChange:{numComponents:!0}}}},eA.componentSizes={description:"The list of component sizes.",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},isArray:!0,entryPrefixes:["componentSize"],stateVariablesDeterminingDependencies:["childIndexByArrayKey"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA,stateValues:tA}){let nA={},rA={childIndexByArrayKey:{dependencyType:"stateVariable",variableName:"childIndexByArrayKey"}};for(let aA of AA){let oA=[],sA="1";tA.childIndexByArrayKey[aA]&&(oA=[tA.childIndexByArrayKey[aA][0]],sA=tA.childIndexByArrayKey[aA][1]+1),nA[aA]={componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],variableNames:["componentSize","componentSize"+sA],variablesOptional:!0,childIndices:oA}}}return{globalDependencies:rA,dependenciesByKey:nA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:nA,componentInfoObjects:rA}){let aA={};for(let oA of nA){let sA=tA[oA].componentSizeAndComponentSizeListChildren[0];if(sA)if(rA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.childIndexByArrayKey[oA][1]+1;aA[oA]=sA.stateValues["componentSize"+lA]}else aA[oA]=sA.stateValues.componentSize}return{setValue:{componentSizes:aA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:nA,dependencyNamesByKey:rA,arraySize:aA,componentInfoObjects:oA}){let sA=[];for(let lA in AA.componentSizes){if(!nA[lA])continue;let gA=nA[lA].componentSizeAndComponentSizeListChildren[0];gA&&(oA.isInheritedComponentType({inheritedComponentType:gA.componentType,baseComponentType:"_componentSizeList"})?sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:1}):sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:0}))}return{success:!0,instructions:sA}}},eA.numValues={isAlias:!0,targetVariableName:"numComponents",description:"The number of component sizes in the list."},eA.values={isAlias:!0,targetVariableName:"componentSizes",description:"The list's component sizes."},eA}}const ComponentSize$1=Object.freeze(Object.defineProperty({__proto__:null,ComponentSize,ComponentSizeList},Symbol.toStringTag,{value:"Module"}));class Copy extends CompositeComponent{static componentType="_copy";static excludeFromSchema=!0;static acceptAnyAttribute=!0;static includeBlankStringChildren=!0;static stateVariableToEvaluateAfterReplacements="needsReplacementsUpdatedWhenStale";static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.disabled,delete eA.modifyIndirectly,delete eA.fixed,delete eA.styleNumber,delete eA.isResponse,delete eA.isPotentialResponse,delete eA.hide,eA.createComponentOfType={createPrimitiveOfType:"string"},eA.createComponentIdx={createPrimitiveOfType:"integer"},eA.createComponentName={createPrimitiveOfType:"string"},eA.numComponents={createPrimitiveOfType:"number"},eA.copyInChildren={createPrimitiveOfType:"boolean"},eA.uri={createPrimitiveOfType:"string",createStateVariable:"uri",defaultValue:null,public:!0},eA.link={createPrimitiveOfType:"boolean",createStateVariable:"link",defaultValue:!0},eA.removeEmptyArrayEntries={createPrimitiveOfType:"boolean",createStateVariable:"removeEmptyArrayEntries",defaultValue:!1},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asListPreliminary",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.refResolutionIndexDependencies={returnDependencies:()=>({refResolutionIndexDependencies:{dependencyType:"refResolutionIndexDependencies"}}),definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencies:AA.refResolutionIndexDependencies}})},eA.refResolutionIndexDependencyValues={stateVariablesDeterminingDependencies:["refResolutionIndexDependencies"],returnDependencies:({stateValues:AA})=>{const tA={};for(const nA of AA.refResolutionIndexDependencies)tA[nA]={dependencyType:"stateVariable",componentIdx:nA,variableName:"value"};return tA},definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencyValues:AA}})},eA.extendIdx={additionalStateVariablesDefined:["unresolvedPath","originalPath"],stateVariablesDeterminingDependencies:["refResolutionIndexDependencyValues"],returnDependencies:({stateValues:AA})=>({refResolution:{dependencyType:"refResolution",indexDependencyValues:AA.refResolutionIndexDependencyValues}}),definition:({dependencyValues:AA})=>({setValue:{extendIdx:AA.refResolution.extendIdx,unresolvedPath:AA.refResolution.unresolvedPath,originalPath:AA.refResolution.originalPath}})},eA.extendedComponent={shadowVariable:!0,stateVariablesDeterminingDependencies:["extendIdx"],returnDependencies({stateValues:AA}){return AA.extendIdx!==-1?{extendedComponent:{dependencyType:"componentIdentity",componentIdx:AA.extendIdx}}:{}},definition:function({dependencyValues:AA}){let tA=null;return AA.extendedComponent&&(tA=AA.extendedComponent),{setValue:{extendedComponent:tA}}}},eA.targetInactive={stateVariablesDeterminingDependencies:["extendedComponent"],returnDependencies({stateValues:AA}){return AA.extendedComponent?{targetIsInactiveCompositeReplacement:{dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"isInactiveCompositeReplacement"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{targetInactive:!!AA.targetIsInactiveCompositeReplacement}}}},eA.cid={additionalStateVariablesDefined:["doenetId"],returnDependencies:()=>({uri:{dependencyType:"stateVariable",variableName:"uri"}}),definition:function({dependencyValues:AA}){if(!AA.uri||AA.uri.substring(0,7).toLowerCase()!=="doenet:")return{setValue:{cid:null,doenetId:null}};let tA=null,nA=null,rA=AA.uri.match(/[:&]cid=([^&]+)/i);return rA&&(tA=rA[1]),rA=AA.uri.match(/[:&]doenetid=([^&]+)/i),rA&&(nA=rA[1]),{setValue:{cid:tA,doenetId:nA}}}},eA.createComponentOfType={returnDependencies:()=>({typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA}){let tA=null;return AA.typeAttr&&(tA=AA.typeAttr),{setValue:{createComponentOfType:tA}}}},eA.replacementSourceIdentities={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","createComponentOfType"],additionalStateVariablesDefined:["usedReplacements"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){let nA={numComponentsSpecified:{dependencyType:"stateVariable",variableName:"numComponentsSpecified"}},rA=!1;if(AA.extendedComponent!==null){if(AA.extendedComponent.componentType==="_copy"||tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!0})&&AA.extendedComponent.componentType!==AA.createComponentOfType){rA=!0;let aA=AA.unresolvedPath?.[0]?.name;aA===""&&(aA=null),nA.targets={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:AA.unresolvedPath!=null,stopAtListComposites:AA.unresolvedPath==null,includeWithheldReplacements:!0,stopIfHaveProp:aA}}rA||(nA.targets={dependencyType:"stateVariable",variableName:"extendedComponent"}),nA.usedReplacements={dependencyType:"value",value:rA}}return nA},definition({dependencyValues:AA}){let tA=null;if(AA.targets&&(tA=AA.targets,Array.isArray(tA)||(tA=[tA]),AA.numComponentsSpecified===1&&tA.length>1)){const nA=tA.findIndex(aA=>typeof aA!="string"||aA.trim()!==""),rA=tA.findLastIndex(aA=>typeof aA!="string"||aA.trim()!=="");nA!==-1&&rA!==-1&&(tA=tA.slice(nA,rA+1))}return{setValue:{replacementSourceIdentities:tA,usedReplacements:!!AA.usedReplacements}}}},eA.asList={stateVariablesDeterminingDependencies:["usedReplacements","extendedComponent"],returnDependencies({stateValues:AA}){const tA={asListPreliminary:{dependencyType:"stateVariable",variableName:"asListPreliminary"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.usedReplacements&&(tA.extendedComponentAsList={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"asList",variablesOptional:!0}),tA},definition({dependencyValues:AA,usedDefault:tA}){return tA.asListPreliminary&&AA.usedReplacements&&typeof AA.extendedComponentAsList=="boolean"?{setValue:{asList:AA.extendedComponentAsList}}:{setValue:{asList:AA.asListPreliminary}}}},eA.implicitProp={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath"],returnDependencies({stateValues:AA}){let tA={unresolvedPath:{dependencyType:"stateVariable",variableName:"unresolvedPath"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.unresolvedPath||(tA.replacementSourceIdentities={dependencyType:"stateVariable",variableName:"replacementSourceIdentities"},tA.typeAttr={dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}),tA},definition({dependencyValues:AA,componentInfoObjects:tA}){if(AA.unresolvedPath||AA.usedReplacements||!(AA.replacementSourceIdentities?.length>0))return{setValue:{implicitProp:null}};let nA=AA.replacementSourceIdentities[0],rA=tA.allComponentClasses[nA.componentType]?.variableForImplicitProp;if(!rA)return{setValue:{implicitProp:null}};if(AA.typeAttr){let aA=tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()];if(aA===nA.componentType)return{setValue:{implicitProp:null}};let oA=tA.publicStateVariableInfo[nA.componentType].stateVariableDescriptions[rA];if(oA.createComponentOfType!==void 0&&oA.createComponentOfType!==aA)return{setValue:{implicitProp:null}}}return{setValue:{implicitProp:rA}}}},eA.replacementSources={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath","implicitProp"],additionalStateVariablesDefined:["effectivePropNameBySource"],returnDependencies:function({stateValues:AA}){let tA={replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};if(AA.replacementSourceIdentities!==null)for(let[nA,rA]of AA.replacementSourceIdentities.entries()){let aA=AA.unresolvedPath;AA.implicitProp&&(aA=[{name:AA.implicitProp,index:[]}]);let oA;if(aA){if(aA=[...aA],tA["unresolvedPath"+nA]={dependencyType:"value",value:aA},typeof rA=="string")continue;oA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:rA.componentIdx,unresolvedPath:aA,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else{if(typeof rA=="string")continue;oA={dependencyType:"componentIdentity",componentIdx:rA.componentIdx}}tA["target"+nA]=oA}return tA},definition({dependencyValues:AA}){let tA=null,nA=null;if(AA.replacementSourceIdentities!==null){tA=[],nA=[];for(let rA in AA.replacementSourceIdentities){let aA=AA["target"+rA];if(aA){tA.push(aA);let oA;aA.stateValues&&(oA=Object.keys(aA.stateValues)[0]),!oA&&AA["unresolvedPath"+rA]&&(oA="__prop_name_not_found"),nA.push(oA)}else{const oA=AA.replacementSourceIdentities[rA];typeof oA=="string"?AA["unresolvedPath"+rA]?nA.push("__prop_name_not_found"):(tA.push(oA),nA.push(void 0)):(tA.push(void 0),nA.push("__no_target_found"))}}}return{setValue:{replacementSources:tA,effectivePropNameBySource:nA}}}},eA.numComponentsSpecified={returnDependencies:()=>({numComponentsAttr:{dependencyType:"attributePrimitive",attributeName:"numComponents"},typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){let nA;if(AA.typeAttr){if(!(tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()]in tA.allComponentClasses))return{setValue:{numComponentsSpecified:null},sendDiagnostics:[codedDiagnostic({type:"warning",code:"doenet-w0065",args:{type:AA.typeAttr}})]};AA.numComponentsAttr!==null?nA=AA.numComponentsAttr:nA=1}else{if(AA.numComponentsAttr!==null)throw Error("You must specify createComponentOfType when specifying numComponents for a copy.");nA=null}return{setValue:{numComponentsSpecified:nA}}}},eA.unlinkedDescendants={stateVariablesDeterminingDependencies:["extendIdx","link"],returnDependencies({stateValues:AA}){let tA={};return AA.link?tA.targetItself={dependencyType:"componentIdentity",componentIdx:AA.extendIdx}:tA.targetDescendants={dependencyType:"descendant",ancestorIdx:AA.extendIdx,componentTypes:["_composite"]},tA},definition(){return{setValue:{unlinkedDescendants:!0}}}},eA.unlinkedTargetsExpanded={stateVariablesDeterminingDependencies:["extendedComponent","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let nA={};return!AA.link&&AA.extendedComponent&&tA.isInheritedComponentType({inheritedComponentType:AA.extendedComponent.componentType,baseComponentType:"_composite"})&&(nA.targetReplacements={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:!0}),nA},definition(){return{setValue:{unlinkedTargetsExpanded:!0}}}},eA.readyToExpandWhenResolved={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let nA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},needsReplacementsUpdatedWhenStale:{dependencyType:"stateVariable",variableName:"needsReplacementsUpdatedWhenStale"},link:{dependencyType:"stateVariable",variableName:"link"},unlinkedTargetsExpanded:{dependencyType:"stateVariable",variableName:"unlinkedTargetsExpanded"},unlinkedDescendants:{dependencyType:"stateVariable",variableName:"unlinkedDescendants"}};return AA.extendedComponent&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(nA.targetReadyToExpandWhenResolved={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"readyToExpandWhenResolved"}),AA.extendedComponent&&AA.unresolvedPath===null&&(nA.extendedVariantInfo={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"generatedVariantInfo",variablesOptional:!0}),AA.link||(nA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),nA},definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.needsReplacementsUpdatedWhenStale={stateVariablesDeterminingDependencies:["extendedComponent","replacementSourceIdentities","effectivePropNameBySource","unresolvedPath","link","removeEmptyArrayEntries"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){if(!AA.link)return{};let nA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},targetInactive:{dependencyType:"stateVariable",variableName:"targetInactive"},replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};if(AA.effectivePropNameBySource!==null){for(let[rA,aA]of AA.effectivePropNameBySource.entries())if(aA){let oA=AA.replacementSourceIdentities[rA];nA["sourceArraySize"+rA]={dependencyType:"stateVariableArraySize",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0},nA["sourceComponentType"+rA]={dependencyType:"stateVariableComponentType",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0}}}return AA.extendedComponent!==null&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(nA.allReplacementIdentities={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,variableNames:["isInactiveCompositeReplacement"]}),AA.removeEmptyArrayEntries&&(nA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),nA},markStale(){return{updateReplacements:!0}},definition:()=>({setValue:{needsReplacementsUpdatedWhenStale:!0}})},eA}static async createSerializedReplacements({component:eA,components:AA,nComponents:tA,workspace:nA,allDoenetMLs:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){nA.replacementsCreated===void 0&&(nA.replacementsCreated=0);let lA=[];await eA.stateValues.numComponentsSpecified,nA.numReplacementsBySource=[],nA.numNonStringReplacementsBySource=[],nA.propVariablesCopiedBySource=[],nA.sourceIndices=[];let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let DA=[];const EA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated};if(eA.attributes.copyInChildren?.primitive.value){let NA=aA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],yA=aA.allComponentClasses[NA];const bA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:NA,componentInfoObjects:aA,compositeAttributesObj:gA,nComponents:tA,stateIdInfo:EA}),wA=bA.attributes;tA=bA.nComponents;let MA=deepClone(eA.serializedChildren);yA.includeBlankStringChildren||(MA=MA.filter(OA=>typeof OA!="string"||OA.trim()!==""));let vA=wA;DA=[{type:"serialized",componentType:NA,componentIdx:tA++,stateId:`${EA.prefix}${EA.num++}`,attributes:vA,doenetAttributes:{},state:{},children:MA}],nA.numReplacementsBySource.push(DA.length),nA.numNonStringReplacementsBySource.push(DA.filter(OA=>typeof OA!="string").length)}let fA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:DA,workspace:nA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:EA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...fA.diagnostics),tA=fA.nComponents,addAttributesToSingleReplacement(fA.replacements,eA),nA.replacementsCreated=EA.num,{replacements:fA.replacements,diagnostics:lA,nComponents:tA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let CA=await eA.stateValues.effectivePropNameBySource;for(let DA in cA)if(CA[DA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+DA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${DA} of replacementSources of ${eA.componentIdx}`);let uA=[];const dA={prefix:`${eA.stateId}|`,num:nA.replacementsCreated};let pA=[],mA=[],QA=0,BA=0;for(let DA in cA){let EA;if(eA.attributes.createComponentOfType?.primitive){let yA=await eA.stateValues.numComponentsSpecified,bA=cA.length;EA=Math.floor(yA/bA);let wA=yA%bA;DA<wA&&EA++}let fA=await this.createReplacementForSource({component:eA,sourceNum:DA,components:AA,nComponents:tA,stateIdInfo:dA,allDoenetMLs:rA,numReplacementsSoFar:QA,numNonStringReplacementsSoFar:BA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:EA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(DA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...fA.diagnostics),tA=fA.nComponents,nA.propVariablesCopiedBySource[DA]=fA.propVariablesCopiedByReplacement;let NA=fA.serializedReplacements;pA[DA]=NA.length,mA[DA]=NA.filter(yA=>typeof yA!="string").length,QA+=pA[DA],BA+=mA[DA],uA.push(...NA)}nA.numReplacementsBySource=pA,nA.numNonStringReplacementsBySource=mA,nA.sourceIndices=cA.map(DA=>DA.componentIdx);let hA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:uA,workspace:nA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...hA.diagnostics),tA=hA.nComponents,uA=hA.replacements,addAttributesToSingleReplacement(uA,eA),nA.replacementsCreated=dA.num,{replacements:uA,diagnostics:lA,nComponents:tA}}static async createReplacementForSource({component:eA,sourceNum:AA,components:tA,nComponents:nA,stateIdInfo:rA,allDoenetMLs:aA,numReplacementsSoFar:oA,numNonStringReplacementsSoFar:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:CA}){let uA=[],dA=(await eA.stateValues.replacementSourceIdentities)[AA];if(typeof dA!="object")return eA.stateValues.effectivePropNameBySource[AA]?{serializedReplacements:[],diagnostics:uA,nComponents:nA}:{serializedReplacements:[dA],diagnostics:uA,nComponents:nA};const pA=tA[dA.componentIdx];if(await pA.stateValues.isInactiveCompositeReplacement)return{serializedReplacements:[],diagnostics:uA,nComponents:nA};let mA=(await eA.stateValues.effectivePropNameBySource)[AA],QA=await eA.stateValues.link;if(!QA||mA&&await eA.stateValues.removeEmptyArrayEntries){const hA=(await eA.stateValues.replacementSources)[AA];hA&&(dA=hA)}if(mA){let hA=await replacementFromProp({component:eA,components:tA,nComponents:nA,stateIdInfo:rA,replacementSource:dA,propName:mA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});uA.push(...hA.diagnostics),nA=hA.nComponents;let DA=hA.serializedReplacements,EA=hA.propVariablesCopiedByReplacement;if(CA&&eA.serializedChildren.length>0)if(DA.length===0){let fA=gA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],NA=gA.allComponentClasses[fA];const yA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:fA,componentInfoObjects:gA,compositeAttributesObj:lA,nComponents:nA,stateIdInfo:rA}),bA=yA.attributes;nA=yA.nComponents;let wA=deepClone(eA.serializedChildren);NA.includeBlankStringChildren||(wA=wA.filter(vA=>typeof vA!="string"||vA.trim()!==""));let MA=bA;DA=[{type:"serialized",componentType:fA,componentIdx:nA++,stateId:`${rA.prefix}${rA.num++}`,attributes:MA,doenetAttributes:{},state:{},children:wA}],EA=[[]]}else DA.length===1&&addChildrenFromComposite({replacements:DA,children:eA.serializedChildren,componentInfoObjects:gA});return{serializedReplacements:DA,propVariablesCopiedByReplacement:EA,diagnostics:uA,nComponents:nA}}let BA;try{BA=[await pA.serialize({copyAll:!QA,componentSourceAttributesToIgnore:["labelIsName"],copyVariants:!QA,copyPrimaryEssentialIfShadow:!QA,copyEssentialStateIfShadow:!QA,errorIfEncounterComponent:[eA.componentIdx]})];let hA=createNewComponentIndices(BA,nA,rA);BA=hA.components,nA=hA.nComponents}catch(hA){if(hA.message?.startsWith(SERIALIZE_ENCOUNTERED_COMPONENT_PREFIX)){const EA=getSelfReferentialFallbackPropName({componentAncestors:eA.ancestors,componentInfoObjects:gA,replacementSourceComponentType:pA.componentType});if(EA)try{let fA=await replacementFromProp({component:eA,components:tA,nComponents:nA,stateIdInfo:rA,replacementSource:pA,propName:EA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});return uA.push(...fA.diagnostics),nA=fA.nComponents,{serializedReplacements:fA.serializedReplacements,propVariablesCopiedByReplacement:fA.propVariablesCopiedByReplacement,diagnostics:uA,nComponents:nA}}catch{}}console.error("we're calling this circular",hA);const DA=codedDiagnostic({type:"error",code:"doenet-e0005",args:{componentType:eA.attributes.createComponentOfType?.primitive?.value??"none"}});return BA=[{type:"serialized",componentType:"_error",componentIdx:nA++,stateId:`${rA.prefix}${rA.num++}`,state:errorComponentState(DA.message,DA),attributes:{},doenetAttributes:{},children:[]}],uA.push(DA),{serializedReplacements:BA,diagnostics:uA,nComponents:nA}}!QA&&BA[0].state&&(delete BA[0].state.fixed,delete BA[0].state.fixedPreliminary,delete BA[0].attributes.fixed),BA=postProcessCopy({serializedComponents:BA,componentIdx:eA.componentIdx,addShadowDependencies:QA,unlinkExternalCopies:!1});for(let hA of BA){if(typeof hA!="object")continue;hA.attributes||(hA.attributes={});const DA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:hA.componentType,componentInfoObjects:gA,compositeAttributesObj:lA,dontSkipAttributes:["asList"],nComponents:nA,stateIdInfo:rA}),EA=DA.attributes;nA=DA.nComponents,(EA.displayDigits||EA.displayDecimals)&&(delete hA.attributes.displayDigits,delete hA.attributes.displayDecimals),Object.assign(hA.attributes,EA)}return CA&&BA.length===1&&eA.serializedChildren.length>0&&addChildrenFromComposite({replacements:BA,children:eA.serializedChildren,componentInfoObjects:gA}),{serializedReplacements:BA,diagnostics:uA,nComponents:nA}}static async calculateReplacementChanges({component:eA,nComponents:AA,componentChanges:tA,components:nA,workspace:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){let lA=[];if(await eA.stateValues.link===!1)return{replacementChanges:[],diagnostics:lA,nComponents:AA};let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacements.length>0){let vA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToDelete:eA.replacements.length};yA.push(vA)}let wA=rA.sourceIndices.length===0;rA.sourceIndices=[],rA.numReplacementsBySource=[],rA.numNonStringReplacementsBySource=[],rA.propVariablesCopiedBySource=[];let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:nA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...MA.diagnostics),AA=MA.nComponents,wA?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,MA.replacementChanges),rA.replacementsCreated=bA.num,{replacementChanges:MA.replacementChanges,diagnostics:lA,nComponents:AA})}if(await eA.stateValues.targetInactive){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};let wA=eA.replacements.length;if(wA>0){if(eA.replacementsToWithhold!==wA){let vA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:wA};yA.push(vA)}let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:nA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...MA.diagnostics),AA=MA.nComponents,yA=MA.replacementChanges}return addAttributesToSingleReplacementChange(eA,yA),rA.replacementsCreated=bA.num,{replacementChanges:yA,diagnostics:lA,nComponents:AA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let CA=await eA.stateValues.effectivePropNameBySource;for(let yA in cA)if(CA[yA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+yA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${yA} of replacementSources of ${eA.componentIdx}`);let uA=[];const dA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacementsToWithhold>0){let yA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:0};uA.push(yA)}let pA=0,mA=0,QA=[],BA=[],hA=[],DA=Math.max(cA.length,rA.numReplacementsBySource.length),EA=!1;for(let yA=0;yA<DA;yA++){let bA;if(eA.attributes.createComponentOfType?.primitive){let jA=await eA.stateValues.numComponentsSpecified,TA=cA.length;bA=Math.floor(jA/TA);let UA=jA%TA;yA<UA&&bA++}let wA=cA[yA];if(!EA&&await nA[wA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){let jA=!0;for(let TA=yA+1;TA<DA;TA++){const UA=cA[TA];if(!await nA[UA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){jA=!1;break}}if(jA){let TA=rA.numReplacementsBySource.slice(yA).reduce((UA,VA)=>UA+VA,0);if(TA>0){let UA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:TA};uA.push(UA)}for(let UA=yA;UA<DA;UA++)QA[UA]=rA.numReplacementsBySource[UA],BA[UA]=rA.numNonStringReplacementsBySource[UA],hA[UA]=rA.propVariablesCopiedBySource[UA];break}else wA=void 0}if(wA===void 0){if(rA.numReplacementsBySource[yA]>0&&!EA){let jA=rA.numReplacementsBySource.slice(yA).reduce((TA,UA)=>TA+UA,0);if(jA>0){let TA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToDelete:jA};uA.push(TA)}EA=!0,rA.numReplacementsBySource.slice(yA).forEach((TA,UA)=>rA.numReplacementsBySource[UA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((TA,UA)=>rA.numNonStringReplacementsBySource[UA]=0)}QA[yA]=0,BA[yA]=0,hA.push([]);continue}let MA=rA.sourceIndices[yA],vA=MA===void 0||wA.componentIdx!==MA||EA;if(!vA)for(let jA=0;jA<rA.numReplacementsBySource[yA];jA++){let TA=eA.replacements[pA+jA];if(TA){if(!CA[yA]&&TA.shadows?.componentIdx!==cA[yA].componentIdx){vA=!0;break}}else{vA=!0;break}}if(vA){let jA=0;yA in rA.numReplacementsBySource&&(jA=rA.numReplacementsBySource[yA]);let TA=jA;EA&&(TA=0);let UA=await this.recreateReplacements({component:eA,sourceNum:yA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,numReplacementsToDelete:TA,components:nA,nComponents:AA,stateIdInfo:dA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...UA.diagnostics),AA=UA.nComponents,pA+=UA.numReplacements,mA+=UA.numNonStringReplacements,QA[yA]=UA.numReplacements,BA[yA]=UA.numNonStringReplacements,hA[yA]=UA.propVariablesCopiedByReplacement;let VA=UA.replacementInstruction;if(!EA&&UA.numReplacements!==jA){let $A=rA.numReplacementsBySource.slice(yA).reduce((Br,KA)=>Br+KA,0);VA.numberReplacementsToReplace=$A,EA=!0,rA.numReplacementsBySource.slice(yA).forEach((Br,KA)=>rA.numReplacementsBySource[KA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((Br,KA)=>rA.numNonStringReplacementsBySource[KA]=0)}VA&&uA.push(VA);continue}if(!CA[yA]&&rA.numReplacementsBySource[yA]>0){pA+=rA.numReplacementsBySource[yA],mA+=rA.numNonStringReplacementsBySource[yA],QA[yA]=rA.numReplacementsBySource[yA],BA[yA]=rA.numNonStringReplacementsBySource[yA];continue}const OA={prefix:`${eA.stateId}|`,num:dA.num};let FA=await this.createReplacementForSource({component:eA,sourceNum:yA,components:nA,nComponents:AA,stateIdInfo:OA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(yA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...FA.diagnostics);const kA=FA.nComponents;let SA=FA.propVariablesCopiedByReplacement,RA=FA.serializedReplacements,xA=RA.length,ZA=rA.numReplacementsBySource[yA];if(xA!==ZA){let jA=rA.numReplacementsBySource.slice(yA).reduce((UA,VA)=>UA+VA,0),TA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToReplace:jA,serializedReplacements:RA};uA.push(TA),EA=!0,AA=kA,dA.num=OA.num,rA.numReplacementsBySource.slice(yA).forEach((UA,VA)=>rA.numReplacementsBySource[VA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((UA,VA)=>rA.numNonStringReplacementsBySource[VA]=0)}else for(let jA=0;jA<xA;jA++){let TA=SA[jA].length!==rA.propVariablesCopiedBySource[yA][jA].length,UA=!TA;if(TA||(rA.propVariablesCopiedBySource[yA][jA].some((VA,$A)=>VA!==SA[jA][$A])?(UA=!1,TA=!0):eA.replacements[pA+jA].componentType!==RA[jA].componentType&&(TA=!0)),jA==0&&TA&&UA&&await eA.stateValues.numComponentsSpecified===1&&xA===1&&!(eA.replacementsToWithhold>0)&&rA.sourceIndices.length===1&&(TA=!1),TA){AA=kA,dA.num=OA.num;let VA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA+jA,numberReplacementsToReplace:1,serializedReplacements:[RA[jA]]};uA.push(VA)}RA[jA]}let XA=RA.filter(jA=>typeof jA!="string").length;pA+=xA,mA+=XA,QA[yA]=xA,BA[yA]=XA,hA[yA]=SA}let fA=rA.sourceIndices.length===0;rA.numReplacementsBySource=QA,rA.numNonStringReplacementsBySource=BA,rA.sourceIndices=cA.map(yA=>yA.componentIdx),rA.propVariablesCopiedBySource=hA;let NA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:uA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:nA,nComponents:AA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...NA.diagnostics),AA=NA.nComponents,uA=NA.replacementChanges,fA&&rA.sourceIndices.length===0?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,uA),rA.replacementsCreated=dA.num,{replacementChanges:uA,diagnostics:lA,nComponents:AA})}static async recreateReplacements({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:nA,numReplacementsToDelete:rA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA}){let CA=[],uA=await this.createReplacementForSource({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:nA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:Number(AA)===0&&eA.attributes.copyInChildren?.primitive.value});CA.push(...uA.diagnostics),oA=uA.nComponents;let dA=uA.propVariablesCopiedByReplacement,pA=uA.serializedReplacements;if(pA.length>0||rA>0){let mA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA,numberReplacementsToReplace:rA,serializedReplacements:pA};return{numReplacements:pA.length,numNonStringReplacements:pA.filter(QA=>typeof QA!="string").length,propVariablesCopiedByReplacement:dA,replacementInstruction:mA,diagnostics:CA,nComponents:oA}}else return{numReplacements:0,numNonStringReplacements:0,propVariablesCopiedByReplacement:dA,replacementInstruction:null,diagnostics:CA,nComponents:oA}}}async function replacementFromProp({component:iA,components:eA,nComponents:AA,stateIdInfo:tA,replacementSource:nA,propName:rA,allDoenetMLs:aA,compositeAttributesObj:oA,componentInfoObjects:sA,numComponentsForSource:lA,publicCaseInsensitiveAliasSubstitutions:gA}){let cA=[],IA=[],CA=[],uA=-1,dA,pA;if(nA&&(dA=eA[nA.componentIdx],pA=gA({stateVariables:[rA],componentClass:dA.constructor})[0]),pA===void 0||pA.slice(0,12)==="__not_public"){if(rA==="__no_target_found"){const hA=await iA.stateValues.unresolvedPath,DA=hA[0].position?.start.offset,EA=hA[hA.length-1].position?.end.offset;let fA="";if(DA!=null&&EA!=null){const NA=hA[0].sourceDoc??0;fA=aA?.[NA]?.substring(DA,EA)}cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:fA,component:nA.componentType}}))}else rA!=="__prop_name_not_found"&&cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:rA,component:nA.componentType}}));return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA}}let mA=dA.state[pA],QA=await mA.value,BA=await iA.stateValues.link;if(mA.isArray||mA.isArrayEntry){let hA,DA,EA,fA;if(mA.isArray?(hA=mA,EA=await mA.arraySize,DA=mA.getAllArrayKeys(EA,!1)):(hA=dA.state[mA.arrayStateVariable],DA=await mA.unflattenedArrayKeys,fA=await mA.arrayKeys),hA.shadowingInstructions?.hasVariableComponentType&&(await iA.stateValues.replacementSources,!hA.shadowingInstructions.createComponentOfType))return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};let NA=mA.wrappingComponents,yA=NA.length,bA=lA;if(mA.isArray)EA.some(wA=>wA===0)?bA=0:bA=EA.slice(0,EA.length-yA).reduce((wA,MA)=>wA*MA,1);else if(fA.length===0)bA=0;else if(yA===0)bA=fA.length;else if(yA>=mA.numDimensions)bA=1;else if(yA===mA.numDimensions-1)bA=DA.length;else{let wA=mA.numDimensions-yA-1;bA=flattenLevels(DA,wA).length}if(yA===0){let wA=flattenDeep(DA);for(let MA=0;MA<bA;MA++){let vA=wA[MA];if(await iA.stateValues.removeEmptyArrayEntries){if(!vA)continue;let kA=hA.keyToIndex(vA);Array.isArray(kA)||(kA=[kA]);let SA=await hA.value;for(let RA of kA)SA=SA[RA];if(SA==null)continue}uA++;let OA=CA[uA]=[],FA=hA.shadowingInstructions.createComponentOfType;if(Array.isArray(FA)&&(FA[hA.keyToIndex(vA)]?FA=FA[hA.keyToIndex(vA)]:FA=FA[0]),vA){let kA=hA.arrayVarNameFromArrayKey(vA);OA.push(kA);const SA=convertUnresolvedAttributesForComponentType({attributes:iA.attributes,componentType:FA,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),RA=SA.attributes;AA=SA.nComponents;let xA;if(hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){xA={};for(let XA in hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let jA=hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[XA].stateVariableToShadow,TA=dA.state[jA];TA.isArray&&(jA=TA.arrayVarNameFromArrayKey(vA)),xA[XA]={stateVariableToShadow:jA}}}let ZA;if(hA.shadowingInstructions.addStateVariablesShadowingStateVariables){ZA={};for(let XA in hA.shadowingInstructions.addStateVariablesShadowingStateVariables){let jA=hA.shadowingInstructions.addStateVariablesShadowingStateVariables[XA].stateVariableToShadow,TA=dA.state[jA];TA.isArray&&(jA=TA.arrayVarNameFromArrayKey(vA)),ZA[XA]={stateVariableToShadow:jA}}}if(BA){let XA={};if(xA){let TA=sA.allComponentClasses[FA].createAttributesObject();for(let UA in xA){let VA=xA[UA].stateVariableToShadow,$A=TA[UA]?.createComponentOfType;if($A){let Br={type:"serialized",componentType:$A,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:VA}]}};XA[UA]={component:Br}}}}Object.assign(XA,RA),IA.push({type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:XA,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[nA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:kA,additionalStateVariableShadowing:ZA}]}})}else{let XA={};if(xA){let KA=sA.allComponentClasses[FA].createAttributesObject(),JA={};for(let HA in xA)if(KA[HA]?.createComponentOfType){let ns=xA[HA].stateVariableToShadow,ts=dA.state[ns],ls=await ts.value;ts.isArray&&(ls=ls[ts.keyToIndex[vA]]),dA.state[ns].usedDefault||(JA[HA]=ls)}const LA=convertAttributeValuesForComponentType({attributeValues:JA,componentType:FA,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),Or=LA.attributes;if(AA=LA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let HA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[HA]?.component){const ns=await dA.attributes[HA].component.serialize({copyAll:!0,copyVariants:!0});let ts=createNewComponentIndices([ns],AA,tA);AA=ts.nComponents,Or[HA]={component:ts.components[0]}}else dA.attributes[HA]?.primitive!==void 0&&(Or[HA]={primitive:JSON.parse(JSON.stringify(dA.attributes[HA].primitive))});Object.assign(XA,Or)}Object.assign(XA,RA);let jA="value",TA=sA.allComponentClasses[FA];TA.primaryEssentialStateVariable?jA=TA.primaryEssentialStateVariable:TA.primaryStateVariableForDefinition&&(jA=TA.primaryStateVariableForDefinition);let UA=hA.keyToIndex(vA);Array.isArray(UA)||(UA=[UA]);let VA=await hA.value;for(let Br of UA)VA=VA[Br];let $A={type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:XA,doenetAttributes:{},state:{[jA]:VA},children:[]};IA.push($A)}}else IA.push({type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},children:[],state:{}})}}else{let wA=async function(OA,FA,kA=!1){let SA=[],RA=[];if(FA>1)for(let ZA of OA){let XA=await wA(ZA,FA-1);SA.push(...XA.pieces),RA.push(...XA.propVariablesCopiedByPiece)}else for(let ZA of OA){let XA=hA.arrayVarNameFromArrayKey(ZA),jA=[XA],TA=hA.shadowingInstructions.createComponentOfType;Array.isArray(TA)&&(TA=TA[hA.keyToIndex(ZA)]);let UA;if(hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){UA={};let $A=hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let Br in $A)if(!$A[Br].addToOuterIfWrappedArray){let KA=$A[Br].stateVariableToShadow,JA=dA.state[KA];JA.isArray&&(KA=JA.arrayVarNameFromArrayKey(ZA)),UA[Br]={stateVariableToShadow:KA}}}let VA;if(hA.shadowingInstructions.addStateVariablesShadowingStateVariables){VA={};for(let $A in hA.shadowingInstructions.addStateVariablesShadowingStateVariables){let Br=hA.shadowingInstructions.addStateVariablesShadowingStateVariables[$A].stateVariableToShadow,KA=dA.state[Br];KA.isArray&&(Br=KA.arrayVarNameFromArrayKey(ZA)),VA[$A]={stateVariableToShadow:Br}}}if(BA){let $A={};if(UA){let KA=sA.allComponentClasses[TA].createAttributesObject();for(let JA in UA){let LA=UA[JA].stateVariableToShadow,Or=KA[JA]?.createComponentOfType;if(Or){let HA={type:"serialized",componentType:Or,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:LA}]}};$A[JA]={component:HA}}}}SA.push({type:"serialized",componentType:TA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:$A,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[nA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:XA,additionalStateVariableShadowing:VA}]}})}else{let $A={};if(UA){let ns=sA.allComponentClasses[TA].createAttributesObject(),ts={};for(let cs in UA)if(ns[cs]?.createComponentOfType){let rs=UA[cs].stateVariableToShadow,ds=dA.state[rs],Cs=await ds.value;ds.isArray&&(Cs=Cs[ds.keyToIndex[ZA]]),dA.state[rs].usedDefault||(ts[cs]=Cs)}const ls=convertAttributeValuesForComponentType({attributeValues:ts,componentType:TA,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),ss=ls.attributes;if(AA=ls.nComponents,mA.shadowingInstructions.attributesToShadow)for(let cs of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[cs]?.component){let rs=await dA.attributes[cs].component.serialize({copyAll:!0,copyVariants:!0}),ds=createNewComponentIndices([rs],AA,tA);AA=ds.nComponents,ss[cs]={component:ds.components[0]}}else dA.attributes[cs]?.primitive!==void 0&&(ss[cs]={primitive:JSON.parse(JSON.stringify(dA.attributes[cs].primitive))});Object.assign($A,ss)}let Br="value",KA=sA.allComponentClasses[TA];KA.primaryEssentialStateVariable?Br=KA.primaryEssentialStateVariable:KA.primaryStateVariableForDefinition&&(Br=KA.primaryStateVariableForDefinition);let JA=hA.keyToIndex(ZA);Array.isArray(JA)||(JA=[JA]);let LA=await hA.value;for(let HA of JA)LA=LA[HA];let Or={type:"serialized",componentType:TA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:$A,doenetAttributes:{},children:[],state:{[Br]:LA}};SA.push(Or)}RA.push(jA)}let xA=NA[FA-1];if(SA.length>0&&xA&&xA.length>0){for(let ZA=xA.length-1;ZA>=0;ZA--){let XA=typeof xA[ZA]=="object"?xA[ZA].componentType:xA[ZA],jA=[],TA={};for(let UA of SA)if(UA.isAttributeNamed){let VA=UA.isAttributeNamed;delete UA.isAttributeNamed,TA[VA]={component:UA}}else jA.push(UA);SA=[{type:"serialized",componentType:XA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,children:jA,attributes:TA,doenetAttributes:{},state:{},skipSugar:!0}],typeof xA[ZA]=="object"&&xA[ZA].isAttributeNamed&&(SA[0].isAttributeNamed=xA[ZA].isAttributeNamed)}RA=[flattenDeep(RA)]}if(kA&&hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let ZA={},XA=hA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let jA in XA)if(XA[jA].addToOuterIfWrappedArray){let TA=XA[jA].stateVariableToShadow;ZA[jA]={stateVariableToShadow:TA}}if(Object.keys(ZA).length>0)for(let jA of SA){let TA=jA.attributes;TA||(TA=jA.attributes={});let VA=sA.allComponentClasses[jA.componentType].createAttributesObject();if(BA)for(let $A in ZA){let Br=ZA[$A].stateVariableToShadow,KA=VA[$A]?.createComponentOfType;if(KA){let JA={type:"serialized",componentType:KA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:Br}]}};TA[$A]={component:JA}}}else{let $A={};for(let Br in ZA)if(VA[Br]?.createComponentOfType){let KA=ZA[Br].stateVariableToShadow,LA=await dA.state[KA].value;dA.state[KA].usedDefault||($A[Br]=LA)}if(Object.keys($A).length>0){const Br=convertAttributeValuesForComponentType({attributeValues:$A,componentType:jA.componentType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA});$A=Br.attributes,AA=Br.nComponents,Object.assign(TA,$A)}}}}return{pieces:SA,propVariablesCopiedByPiece:RA}},MA=await wA(DA,mA.numDimensions,!0),vA=MA.pieces;CA=MA.propVariablesCopiedByPiece;for(let OA of vA){if(typeof OA!="object")continue;OA.attributes||(OA.attributes={});const FA=convertUnresolvedAttributesForComponentType({attributes:iA.attributes,componentType:OA.componentType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),kA=FA.attributes;AA=FA.nComponents,Object.assign(OA.attributes,kA),BA&&(OA.downstreamDependencies={[nA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:pA,ignorePrimaryStateVariable:!0}]})}if(uA+=vA.length,IA.push(...vA),vA.length<bA)for(let OA=vA.length;OA<bA;OA++){uA++,CA[uA]=[];let FA,kA=NA[0],SA;kA&&kA.length>0?typeof kA[0]=="object"?(FA=kA[0].componentType,SA=Object.assign({},kA[0].doenetAttributes)):FA=kA[0]:(FA=hA.shadowingInstructions.createComponentOfType,Array.isArray(FA)&&(mA.isArrayEntry?FA=FA[hA.keyToIndex(fA[OA])]:FA=FA[OA]));let RA={type:"serialized",componentType:FA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]};SA&&(RA.doenetAttributes=SA),IA.push(RA)}else if(vA>bA)throw Error(`Something went wrong when creating replacements for ${iA.componentIdx} as we ended up with too many replacements`)}}else{if(mA.shadowingInstructions?.hasVariableComponentType&&await mA.value,!mA.shadowingInstructions?.createComponentOfType)return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};if(uA++,(CA[uA]=[]).push(pA),mA.shadowingInstructions.createComponentOfType==="string")IA.push(await mA.value);else{const DA=convertUnresolvedAttributesForComponentType({attributes:iA.attributes,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),EA=DA.attributes;if(AA=DA.nComponents,BA){let fA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let yA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject();for(let bA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let wA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[bA].stateVariableToShadow,MA=yA[bA]?.createComponentOfType;if(MA){let vA={type:"serialized",componentType:MA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:iA.componentIdx,dependencyType:"referenceShadow",propVariable:wA}]}};fA[bA]={component:vA}}}}Object.assign(fA,EA),IA.push({type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:fA,doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:iA.componentIdx,propVariable:pA,additionalStateVariableShadowing:mA.shadowingInstructions.addStateVariablesShadowingStateVariables}]}})}else{let fA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let MA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject(),vA={};for(let kA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables)if(MA[kA]?.createComponentOfType&&kA!=="fixed"){let SA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[kA].stateVariableToShadow,RA=await dA.state[SA].value;dA.state[SA].usedDefault||(vA[kA]={type:"unresolved",name:kA,children:[RA.toString()]})}const OA=convertUnresolvedAttributesForComponentType({attributes:vA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),FA=OA.attributes;if(AA=OA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let kA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[kA]?.component){let SA=await dA.attributes[kA].component.serialize({copyAll:!0,copyVariants:!0}),RA=createNewComponentIndices([SA],AA,tA);AA=RA.nComponents,FA[kA]={type:"component",name:kA,component:RA.components[0]}}else dA.attributes[kA]?.primitive!==void 0&&(FA[kA]={type:"primitive",name:kA,primitive:JSON.parse(JSON.stringify(dA.attributes[kA].primitive))});Object.assign(fA,FA)}Object.assign(fA,EA);let NA="value",yA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType];yA.primaryEssentialStateVariable?NA=yA.primaryEssentialStateVariable:yA.primaryStateVariableForDefinition&&(NA=yA.primaryStateVariableForDefinition);let bA={type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:fA,doenetAttributes:{},children:[],state:{[NA]:QA}};IA.push(bA)}}}if(await iA.stateValues.implicitProp)for(let hA of IA)hA.doenetAttributes||(hA.doenetAttributes={}),hA.doenetAttributes.fromImplicitProp=!0,hA.downstreamDependencies?.[dA.componentIdx]?.[0]&&(hA.downstreamDependencies[dA.componentIdx][0].fromImplicitProp=!0);return{serializedReplacements:IA,propVariablesCopiedByReplacement:CA,diagnostics:cA,nComponents:AA}}function addChildrenFromComposite({replacements:iA,children:eA,componentInfoObjects:AA}){let tA=iA[0];tA.children||(tA.children=[]);let nA=deepClone(eA);AA.allComponentClasses[tA.componentType].includeBlankStringChildren||(nA=nA.filter(aA=>typeof aA!="string"||aA.trim()!=="")),tA.children.push(...nA)}class SegmentConstraintComponent extends BaseComponent{static componentType="_segmentConstraint";static rendererType=void 0;static inSchemaOnlyInheritAs=["_segmentConstraint"]}class VariableNameList extends MathList{static componentType="_variableNameList";static stateVariableToBeShadowed="variables";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.variables={description:"The list of variable names.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},isArray:!0,entryPrefixes:["var"],additionalStateVariablesDefined:["validVariables"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let nA of AA)tA[nA]={math:{dependencyType:"stateVariable",variableName:"math"+(Number(nA)+1)}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let nA={},rA={},aA=[];for(let oA of tA){let sA=AA[oA].math,lA=isValidVariable(sA);lA||(aA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:sA.toString()}})),lA=!1),nA[oA]=sA,rA[oA]=lA}return{setValue:{variables:nA,validVariables:rA},sendDiagnostics:aA}}},eA}}class Variable extends MathComponent{static componentType="_variableName";static rendererType="math";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"value",newName:"valuePreValidate"}),eA.valuePreValidate.essentialVarName="value",eA.value={description:"The variable as a math expression.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},additionalStateVariablesDefined:["validVariable"],returnDependencies:()=>({valuePreValidate:{dependencyType:"stateVariable",variableName:"valuePreValidate"}}),definition({dependencyValues:AA}){let tA=[],nA=isValidVariable(AA.valuePreValidate);return nA||tA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:AA.valuePreValidate.toString()}})),{setValue:{value:AA.valuePreValidate,validVariable:nA},sendDiagnostics:tA}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setDependency:"valuePreValidate",desiredValue:AA.value}]}}},eA}}class ListOfNumberLists extends InlineComponent{static componentType="_listOfNumberLists";static includeBlankStringChildren=!0;static removeBlankStringChildrenPostSugar=!0;static additionalSchemaChildren=["math","string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){let aA=breakEmbeddedStringsIntoParensPieces({componentList:tA,removeParens:!0});return aA.success!==!0?{success:!1}:{success:!0,newChildren:aA.pieces.map(oA=>({type:"serialized",componentType:"numberList",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}})),nComponents:nA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"lists",componentTypes:["numberList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.value,eA.numLists={returnDependencies:()=>({listChildren:{dependencyType:"child",childGroups:["lists"]}}),definition({dependencyValues:AA}){return{setValue:{numLists:AA.listChildren.length}}}},eA.lists={isArray:!0,entryPrefixes:["list"],returnArraySizeDependencies:()=>({numLists:{dependencyType:"stateVariable",variableName:"numLists"}}),returnArraySize({dependencyValues:AA}){return[AA.numLists]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let nA of AA)tA[nA]={listChildren:{dependencyType:"child",childGroups:["lists"],variableNames:["values"],childIndices:[nA]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let nA={};for(let rA of tA)if(AA[rA].listChildren&&AA[rA].listChildren.length===1){let aA=AA[rA].listChildren[0];nA[rA]=aA.stateValues.values}return{setValue:{lists:nA}}}},eA}}class DirectionComponent extends BaseComponent{static componentType="_directionComponent";static rendererType=void 0;static primaryStateVariableForDefinition="directionShadow";static additionalSchemaChildren=["math","string"];static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:nA,stateIdInfo:rA}){return tA.length===0?{success:!1}:tA.length>1||typeof tA[0]=="string"?{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:nA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:nA}:{success:!1}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"directions",componentTypes:["_directionComponent"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.directionShadow={defaultValue:context.fromAst(["vector",1,0]),hasEssential:!0,essentialVarName:"direction",set:convertValueToMathExpression,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{directionShadow:!0}}),inverseDefinition:function({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"directionShadow",value:convertValueToMathExpression(AA.directionShadow)}]}}},eA.unnormalizedDirection={returnDependencies:()=>({directionChild:{dependencyType:"child",childGroups:["directions"],variableNames:["unnormalizedDirection"]},directionShadow:{dependencyType:"stateVariable",variableName:"directionShadow"}}),definition({dependencyValues:AA}){let tA;return AA.directionChild.length>0?tA=AA.directionChild[0].stateValues.unnormalizedDirection:tA=AA.directionShadow,tA=tA.tuples_to_vectors().expand().simplify(),{setValue:{unnormalizedDirection:tA}}},inverseDefinition({desiredStateVariableValues:AA,dependencyValues:tA}){let nA;return tA.directionChild.length>0?nA=[{setDependency:"directionChild",desiredValue:AA.unnormalizedDirection,childIndex:0,variableIndex:0}]:nA=[{setDependency:"directionShadow",desiredValue:AA.unnormalizedDirection}],{success:!0,instructions:nA}}},eA.numDimensions={returnDependencies:()=>({unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}),definition({dependencyValues:AA}){let tA=AA.unnormalizedDirection.tree,nA;return Array.isArray(tA)&&vectorOperators.includes(tA[0])?nA=tA.length-1:nA=1,{setValue:{numDimensions:nA}}}},eA.direction={description:"The normalized direction as a unit vector.",public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="x"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},isArray:!0,entryPrefixes:["x"],hasEssential:!0,essentialVarName:"direction2",set:convertValueToMathExpression,returnArraySizeDependencies:()=>({numDimensions:{dependencyType:"stateVariable",variableName:"numDimensions"}}),returnArraySize({dependencyValues:AA}){return[AA.numDimensions]},returnArrayDependenciesByKey(){return{globalDependencies:{unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}}},arrayDefinitionByKey:function({globalDependencyValues:AA,arraySize:tA}){let nA={},rA=AA.unnormalizedDirection.tree;if(Array.isArray(rA)&&vectorOperators.includes(rA[0])){let aA=[],oA=tA[0],sA=0,lA=!0;for(let gA=0;gA<oA;gA++){let cA=AA.unnormalizedDirection.get_component(gA).evaluate_to_constant();if(Number.isFinite(cA))aA.push(cA),sA+=cA*cA;else{lA=!1;break}}if(lA){let gA=Math.sqrt(sA);for(let cA=0;cA<oA;cA++)nA[cA.toString()]=context.fromAst(aA[cA]/gA)}else for(let gA=0;gA<oA;gA++)nA[gA.toString()]=context.fromAst("_")}else nA[0]=context.fromAst(1);return{setValue:{direction:nA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,arraySize:nA}){let rA=[];if(nA[0]>1){let aA=0;for(let sA=0;sA<nA[0];sA++){let lA=evaluateToNumber(tA.unnormalizedDirection.get_component(sA));aA+=lA*lA}Number.isFinite(aA)?aA=Math.sqrt(aA):aA=1;let oA=["vector"];for(let sA in AA.direction)oA[Number(sA)+1]=AA.direction[sA].tree*aA;oA.length=nA[0]+1,rA.push({setDependency:"unnormalizedDirection",desiredValue:context.fromAst(markUnspecifiedComponents(oA))})}return{success:!0,instructions:rA}}},eA}}class ErrorComponent extends BlockComponent{static componentType="_error";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.message={createComponentOfType:"text",createStateVariable:"message",defaultValue:"",public:!0,forRenderer:!0,description:"The error message describing what went wrong."},eA}static returnChildGroups(){return[{group:"errors",componentTypes:["_error"]},{group:"any",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.hidden={returnDependencies:()=>({}),definition:()=>({setValue:{hidden:!1}})},eA.code={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{code:!0}})},eA.args={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{args:!0}})},eA.rangeMessage={description:"A message describing where in the source document the error was found.",forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"text"},additionalStateVariablesDefined:[{variableName:"rangeArgs",forRenderer:!0}],returnDependencies:()=>({position:{dependencyType:"position"}}),definition({dependencyValues:AA}){let tA=AA.position;return tA?.start.line===void 0?{setValue:{rangeMessage:"",rangeArgs:null}}:{setValue:{rangeMessage:"Found on "+printDoenetMLrange(tA)+".",rangeArgs:{span:tA.start.line===tA.end.line?"line":"lines",startLine:String(tA.start.line),endLine:String(tA.end.line)}}}}},eA.showMessage={forRenderer:!0,returnDependencies:()=>({childErrors:{dependencyType:"child",childGroups:["errors"],variableNames:["message"]},message:{dependencyType:"stateVariable",variableName:"message"}}),definition({dependencyValues:AA}){return{setValue:{showMessage:!AA.childErrors.some(nA=>nA.stateValues.message===AA.message)}}}},eA}}class Comment extends BaseComponent{static componentType="_comment";static rendererType=void 0;static returnChildGroups(){return[{group:"any",componentTypes:["_base"]}]}}const componentTypeArray=[...Object.values(Aliases),...Object.values(MMeMen),...Object.values(MdMdnMrow),...Object.values(BooleanOperators),...Object.values(BooleanOperatorsOfMath),...Object.values(MathOperators),...Object.values(MathListOperators),...Object.values(ListIndexOperators),...Object.values(CountOperators),Chart,Series,...Object.values(FunctionOperators),...Object.values(TextOperatorsOfMath),...Object.values(Extrema$1),...Object.values(ParagraphMarkup),...Object.values(SingleCharacterComponents),...Object.values(Sectioning),...Object.values(Lists),...Object.values(DynamicalSystems),...Object.values(Chemistry),...Object.values(FeedbackDefinitions$1),...Object.values(StyleDefinitions$1),...Object.values(StylePalette$1),...Object.values(SideBySide$1),...Object.values(ComponentWithSelectableType$1),...Object.values(Indexing),...Object.values(Divisions),...Object.values(Verbatim),...Object.values(Paginator$1),...Object.values(MatrixInput$1),...Object.values(FractionInput$1),...Object.values(Solution$1),Document,Text,TextList$1,TextList2,P$2,BooleanComponent,BooleanList,MathComponent,MathList,TupleList,NumberList,Copy,Collect,Ref,Point,Coords,Line,LineSegment,Ray,Polyline,Polygon,Triangle,Rectangle,RegularPolygon,Circle,Parabola,Curve,BezierControls,ControlVectors,Vector,Angle,Answer,Award,When,MathInput,Textinput,BooleanInput,Choiceinput,Choice,NumberComponent,Integer,Graph$1,Annotations,Annotation,Function$1,PiecewiseFunction,Interval,Option$1,Sequence,Slider,Spreadsheet,DiscreteSimulationResultList,DiscreteSimulationResultPolyline,Cell,Row,Column,Col,CellBlock,Tabular,Table,Figure,Markers,Panel,Repeat,RepeatForSequence,Pegboard,Constraints,ConstrainToGrid,ConstrainToGraph,AttractToGrid,ConstrainTo,AttractTo,ConstraintUnion,AttractToConstraint,ConstrainToInterior,Intersection,ConstrainToAngles,AttractToAngles,ConditionalContent,AsList,VariantControl,TextListFromString,SelectFromSequence,Select,Group,AnimateFromSequence,Evaluate,SelectRandomNumbers,SampleRandomNumbers,SampleMultivariateRandomNumber,SelectPrimeNumbers,SamplePrimeNumbers,Substitute,PeriodicSet,Image,Video,Embed,Hint,IntComma,Pluralize,Feedback,CollaborateGroups,CollaborateGroupSetup,ConsiderAsResponses,Case,Lorem,UpdateValue,CallAction,triggerSet,FunctionIterates,Module,ModuleAttributes,Setup,Footnote,Caption,Endpoint,Sort,SortIndices,Shuffle,SolveEquations,PostponeRenderContainer,SubsetOfRealsInput,SubsetOfReals,Split,BestFitLine,RegionBetweenCurveXAxis,RegionBetweenCurves,SlopeField,VectorField,RegionHalfPlane,CodeEditor,HasSameFactoring,DataFrame,SummaryStatistics,Legend,Label,MatchesPattern,Matrix,EigenDecomposition,Latex,BlockQuote,Description,StickyGroup,Pretzel,PretzelArranger,Cascade,Page,DynamicChildren,ShortDescription,BaseComponent,InlineComponent,BlockComponent,BlockScoredComponent,GraphicalComponent,ConstraintComponent,SegmentConstraintComponent,Input,CompositeComponent,PointList,IntervalList,LineListComponent,VectorListComponent,AngleListComponent,BooleanOperator,BooleanBaseOperatorOfMath,MathOperator,MathOperatorOneInput,FunctionOperator,...Object.values(ComponentSize$1),...Object.values(SectioningComponent$1),InlineRenderInlineChildren,TextOrInline,SingleCharacter,VariableNameList,Variable,ListOfNumberLists,DirectionComponent,ErrorComponent,Comment];function allComponentClasses(){const iA={},eA=new Set;for(let AA of componentTypeArray){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let nA=tA.toLowerCase();if(eA.has(nA))throw Error("component type "+tA+" defined in two classes");iA[tA]=AA,eA.add(nA)}return iA}function componentTypesCreatingVariants(){const iA={},eA=new Set;for(let AA of componentTypeArray)if(AA.createsVariants){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let nA=tA.toLowerCase();if(eA.has(nA))throw Error("component type "+tA+" defined in two classes");iA[tA]=AA,eA.add(nA)}return iA}function createComponentInfoObjects(){const iA=allComponentClasses(),eA=componentTypesCreatingVariants(),AA={};for(const lA in iA)AA[lA.toLowerCase()]=lA;const tA={};for(const lA in iA)Object.defineProperty(tA,lA,{get:(function(){const gA=iA[lA].returnStateVariableInfo();return delete tA[lA],tA[lA]=gA}).bind(this),configurable:!0});const nA={};for(const lA in iA)Object.defineProperty(nA,lA,{get:(function(){const gA=iA[lA].returnStateVariableInfo({onlyPublic:!0});return delete nA[lA],nA[lA]=gA}).bind(this),configurable:!0});function rA({inheritedComponentType:lA,baseComponentType:gA}){if(lA===gA)return!0;if(lA==="string")return gA==="_base"||gA==="_inline";if(gA==="string")return!1;let cA=iA[gA];return cA?cA.isPrototypeOf(iA[lA]):!1}function aA({componentType:lA,includeNonStandard:gA=!0}){const cA=iA[lA];return cA?rA({inheritedComponentType:lA,baseComponentType:"_composite"})&&(gA||!cA.treatAsComponentForRecursiveReplacements):!1}const oA=(lA,gA)=>rA({inheritedComponentType:lA,baseComponentType:gA});return{allComponentClasses:iA,componentTypesCreatingVariants:eA,componentTypeLowerCaseMapping:AA,isInheritedComponentType:rA,isCompositeComponent:aA,stateVariableInfo:tA,publicStateVariableInfo:nA,componentIsSpecifiedType:(lA,gA)=>oA(lA.componentType,gA)||lA.attributes?.createComponentOfType?.primitive!==void 0&&oA(lA.attributes?.createComponentOfType?.primitive.value,gA)}}async function returnAllPossibleVariants(iA,eA,AA){let nA=getNumVariants({serializedComponent:iA,componentInfoObjects:eA,infoDiagnostics:AA}).numVariants,rA;return iA.variants?.allPossibleVariants?rA=iA.variants.allPossibleVariants:rA=[...Array(nA).keys()].map(aA=>indexToLowercaseLetters(aA+1)),rA}function indexToLowercaseLetters(iA){return numberToLetters(iA,!0)}class PublicDoenetMLCore{constructor(){this.core=null,this.initialized=!1,this.doenetML="",this.flags={},this.localeData=DEFAULT_LOCALE_DATA}setSource(eA){this.doenetML=eA}setFlags(eA){this.flags=eA}setLocaleData(eA){this.localeData=eA}async initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA,normalizedRoot:rA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:lA,updateRootNames:gA}){this.addNodesToResolver=aA,this.replaceIndexResolutionsInResolver=oA,this.deleteNodesFromResolver=sA,this.resolvePath=lA,this.updateRootNames=gA;let cA=createComponentInfoObjects();const{document:IA,nComponents:CA,diagnostics:uA,sources:dA}=await normalizedDastToSerializedComponents(rA,cA,aA);this.coreBaseArgs={doenetML:this.doenetML,flags:this.flags,localeData:this.localeData,activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA,serializedDocument:IA,nComponentsInit:CA,allDoenetMLs:dA,preliminaryDiagnostics:uA,componentInfoObjects:cA},this.initialized=!0;let pA=await returnAllPossibleVariants(this.coreBaseArgs.serializedDocument,this.coreBaseArgs.componentInfoObjects,uA);const mA=this.coreBaseArgs.serializedDocument.children.reduce((QA,BA)=>(typeof BA=="object"&&(QA[BA.componentType]=(QA[BA.componentType]??0)+1),QA),{});return{allPossibleVariants:pA,baseComponentCounts:mA}}async createCoreGenerateDast(eA,AA,tA,nA,rA,aA,oA,sA){if(this.initialized&&!this.coreBaseArgs?.serializedDocument)return{success:!1,errMsg:"Cannot create the core a second time from the same worker; the serialized document was released after the first core was created."};let lA={...this.coreBaseArgs,...eA,addNodesToResolver:this.addNodesToResolver,replaceIndexResolutionsInResolver:this.replaceIndexResolutionsInResolver,deleteNodesFromResolver:this.deleteNodesFromResolver,resolvePath:this.resolvePath,updateRootNames:this.updateRootNames,updateRenderersCallback:AA,reportScoreAndStateCallback:tA,requestAnimationFrame:nA,cancelAnimationFrame:rA,copyToClipboard:aA,sendEvent:oA,requestSolutionView:sA};if(this.initialized){this.core=new Core(lA),this.coreBaseArgs.serializedDocument=void 0;try{return{success:!0,...await this.core.generateDast()}}catch(gA){return console.error(gA),{success:!1,errMsg:typeof gA=="object"&&gA&&"message"in gA&&typeof gA.message=="string"?gA.message:""}}}else return{success:!1,coreId:lA.coreId,errMsg:"Internal error. Cannot create document. Core not initialized."}}async requestAction(eA){if(!this.core)return{success:!1,errMsg:"Cannot request action before core is created"};try{return await this.core.requestAction(eA)}catch(AA){return console.error(AA),{success:!1,errMsg:typeof AA=="object"&&AA&&"message"in AA&&typeof AA.message=="string"?AA.message:"",actionId:eA.args?.actionId}}}async returnAllStateVariables(eA=!1,AA=!1){if(!this.core?.components)return{};const tA={},nA=this.core.components;eA&&console.log(nA);for(let rA in nA){const aA=Number(rA);let oA=nA[aA];if(!oA)continue;tA[aA]={componentIdx:aA,componentType:oA.componentType,stateValues:{},activeChildren:[],sharedParameters:null};let sA=tA[aA];for(let lA in oA.state){if(["replacements","recursiveReplacements","fullRecursiveReplacements"].includes(lA)&&this.core.componentInfoObjects.isCompositeComponent({componentType:oA.componentType})&&!oA.isExpanded)continue;const gA=await oA.state[lA].value;sA.stateValues[lA]=AA?gA:removeFunctionsMathExpressionClass(gA)}sA.activeChildren=oA.activeChildren.map(lA=>lA.componentIdx?{componentIdx:lA.componentIdx,componentType:lA.componentType}:lA),oA.replacements&&(sA.replacements=oA.replacements.map(lA=>lA.componentIdx?{componentIdx:lA.componentIdx,componentType:lA.componentType}:lA),oA.replacementsToWithhold!==void 0&&(sA.replacementsToWithhold=oA.replacementsToWithhold)),oA.replacementOf&&(sA.replacementOf=oA.replacementOf.componentIdx),sA.sharedParameters=AA?oA.sharedParameters:removeFunctionsMathExpressionClass(oA.sharedParameters)}return tA}async terminate(){this.core&&(await this.core.terminate(),this.core=null)}handleVisibilityChange(eA){this.core?.handleVisibilityChange(eA)}navigatingToComponent(eA,AA){this.core&&handleNavigatingToComponent({core:this.core,componentIdx:eA,hash:AA}).catch(reportTimerError(TimerLabels.navigateToComponent))}async submitAllAnswers(){await this.core?.requestAction({componentIdx:this.core.documentIdx,actionName:"submitAllAnswers",args:{}}),await this.core?.saveImmediately()}async saveImmediately(){await this.core?.saveImmediately()}async flushState(){return await this.core?.flushState()??!1}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(iA){return iA&&iA.__esModule&&Object.prototype.hasOwnProperty.call(iA,"default")?iA.default:iA}var colorName$1,hasRequiredColorName;function requireColorName(){return hasRequiredColorName||(hasRequiredColorName=1,colorName$1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),colorName$1}var colorNameExports=requireColorName();const colorName=getDefaultExportFromCjs(colorNameExports);var r$2={grad:.9,turn:360,rad:360/(2*Math.PI)},t$3=function(iA){return typeof iA=="string"?iA.length>0:typeof iA=="number"},n$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*iA)/AA+0},e$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),iA>AA?AA:iA>eA?iA:eA},u$2=function(iA){return(iA=isFinite(iA)?iA%360:0)>0?iA:iA+360},a$2=function(iA){return{r:e$2(iA.r,0,255),g:e$2(iA.g,0,255),b:e$2(iA.b,0,255),a:e$2(iA.a)}},o$3=function(iA){return{r:n$2(iA.r),g:n$2(iA.g),b:n$2(iA.b),a:n$2(iA.a,3)}},i$2=/^#([0-9a-f]{3,8})$/i,s$1=function(iA){var eA=iA.toString(16);return eA.length<2?"0"+eA:eA},h$2=function(iA){var eA=iA.r,AA=iA.g,tA=iA.b,nA=iA.a,rA=Math.max(eA,AA,tA),aA=rA-Math.min(eA,AA,tA),oA=aA?rA===eA?(AA-tA)/aA:rA===AA?2+(tA-eA)/aA:4+(eA-AA)/aA:0;return{h:60*(oA<0?oA+6:oA),s:rA?aA/rA*100:0,v:rA/255*100,a:nA}},b$2=function(iA){var eA=iA.h,AA=iA.s,tA=iA.v,nA=iA.a;eA=eA/360*6,AA/=100,tA/=100;var rA=Math.floor(eA),aA=tA*(1-AA),oA=tA*(1-(eA-rA)*AA),sA=tA*(1-(1-eA+rA)*AA),lA=rA%6;return{r:255*[tA,oA,aA,aA,sA,tA][lA],g:255*[sA,tA,tA,oA,aA,aA][lA],b:255*[aA,aA,sA,tA,tA,oA][lA],a:nA}},g=function(iA){return{h:u$2(iA.h),s:e$2(iA.s,0,100),l:e$2(iA.l,0,100),a:e$2(iA.a)}},d$1=function(iA){return{h:n$2(iA.h),s:n$2(iA.s),l:n$2(iA.l),a:n$2(iA.a,3)}},f$1=function(iA){return b$2((AA=(eA=iA).s,{h:eA.h,s:(AA*=((tA=eA.l)<50?tA:100-tA)/100)>0?2*AA/(tA+AA)*100:0,v:tA+AA,a:eA.a}));var eA,AA,tA},c$1=function(iA){return{h:(eA=h$2(iA)).h,s:(nA=(200-(AA=eA.s))*(tA=eA.v)/100)>0&&nA<200?AA*tA/100/(nA<=100?nA:200-nA)*100:0,l:nA/2,a:eA.a};var eA,AA,tA,nA},l$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v$1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y$1={string:[[function(iA){var eA=i$2.exec(iA);return eA?(iA=eA[1]).length<=4?{r:parseInt(iA[0]+iA[0],16),g:parseInt(iA[1]+iA[1],16),b:parseInt(iA[2]+iA[2],16),a:iA.length===4?n$2(parseInt(iA[3]+iA[3],16)/255,2):1}:iA.length===6||iA.length===8?{r:parseInt(iA.substr(0,2),16),g:parseInt(iA.substr(2,2),16),b:parseInt(iA.substr(4,2),16),a:iA.length===8?n$2(parseInt(iA.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(iA){var eA=v$1.exec(iA)||m.exec(iA);return eA?eA[2]!==eA[4]||eA[4]!==eA[6]?null:a$2({r:Number(eA[1])/(eA[2]?100/255:1),g:Number(eA[3])/(eA[4]?100/255:1),b:Number(eA[5])/(eA[6]?100/255:1),a:eA[7]===void 0?1:Number(eA[7])/(eA[8]?100:1)}):null},"rgb"],[function(iA){var eA=l$2.exec(iA)||p$2.exec(iA);if(!eA)return null;var AA,tA,nA=g({h:(AA=eA[1],tA=eA[2],tA===void 0&&(tA="deg"),Number(AA)*(r$2[tA]||1)),s:Number(eA[3]),l:Number(eA[4]),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return f$1(nA)},"hsl"]],object:[[function(iA){var eA=iA.r,AA=iA.g,tA=iA.b,nA=iA.a,rA=nA===void 0?1:nA;return t$3(eA)&&t$3(AA)&&t$3(tA)?a$2({r:Number(eA),g:Number(AA),b:Number(tA),a:Number(rA)}):null},"rgb"],[function(iA){var eA=iA.h,AA=iA.s,tA=iA.l,nA=iA.a,rA=nA===void 0?1:nA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=g({h:Number(eA),s:Number(AA),l:Number(tA),a:Number(rA)});return f$1(aA)},"hsl"],[function(iA){var eA=iA.h,AA=iA.s,tA=iA.v,nA=iA.a,rA=nA===void 0?1:nA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=(function(oA){return{h:u$2(oA.h),s:e$2(oA.s,0,100),v:e$2(oA.v,0,100),a:e$2(oA.a)}})({h:Number(eA),s:Number(AA),v:Number(tA),a:Number(rA)});return b$2(aA)},"hsv"]]},N=function(iA,eA){for(var AA=0;AA<eA.length;AA++){var tA=eA[AA][0](iA);if(tA)return[tA,eA[AA][1]]}return[null,void 0]},x$1=function(iA){return typeof iA=="string"?N(iA.trim(),y$1.string):typeof iA=="object"&&iA!==null?N(iA,y$1.object):[null,void 0]},M$2=function(iA,eA){var AA=c$1(iA);return{h:AA.h,s:e$2(AA.s+100*eA,0,100),l:AA.l,a:AA.a}},H=function(iA){return(299*iA.r+587*iA.g+114*iA.b)/1e3/255},$=function(iA,eA){var AA=c$1(iA);return{h:AA.h,s:AA.s,l:e$2(AA.l+100*eA,0,100),a:AA.a}},j=(function(){function iA(eA){this.parsed=x$1(eA)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return iA.prototype.isValid=function(){return this.parsed!==null},iA.prototype.brightness=function(){return n$2(H(this.rgba),2)},iA.prototype.isDark=function(){return H(this.rgba)<.5},iA.prototype.isLight=function(){return H(this.rgba)>=.5},iA.prototype.toHex=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,nA=eA.b,aA=(rA=eA.a)<1?s$1(n$2(255*rA)):"","#"+s$1(AA)+s$1(tA)+s$1(nA)+aA;var eA,AA,tA,nA,rA,aA},iA.prototype.toRgb=function(){return o$3(this.rgba)},iA.prototype.toRgbString=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,nA=eA.b,(rA=eA.a)<1?"rgba("+AA+", "+tA+", "+nA+", "+rA+")":"rgb("+AA+", "+tA+", "+nA+")";var eA,AA,tA,nA,rA},iA.prototype.toHsl=function(){return d$1(c$1(this.rgba))},iA.prototype.toHslString=function(){return eA=d$1(c$1(this.rgba)),AA=eA.h,tA=eA.s,nA=eA.l,(rA=eA.a)<1?"hsla("+AA+", "+tA+"%, "+nA+"%, "+rA+")":"hsl("+AA+", "+tA+"%, "+nA+"%)";var eA,AA,tA,nA,rA},iA.prototype.toHsv=function(){return eA=h$2(this.rgba),{h:n$2(eA.h),s:n$2(eA.s),v:n$2(eA.v),a:n$2(eA.a,3)};var eA},iA.prototype.invert=function(){return w$1({r:255-(eA=this.rgba).r,g:255-eA.g,b:255-eA.b,a:eA.a});var eA},iA.prototype.saturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,eA))},iA.prototype.desaturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,-eA))},iA.prototype.grayscale=function(){return w$1(M$2(this.rgba,-1))},iA.prototype.lighten=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,eA))},iA.prototype.darken=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,-eA))},iA.prototype.rotate=function(eA){return eA===void 0&&(eA=15),this.hue(this.hue()+eA)},iA.prototype.alpha=function(eA){return typeof eA=="number"?w$1({r:(AA=this.rgba).r,g:AA.g,b:AA.b,a:eA}):n$2(this.rgba.a,3);var AA},iA.prototype.hue=function(eA){var AA=c$1(this.rgba);return typeof eA=="number"?w$1({h:eA,s:AA.s,l:AA.l,a:AA.a}):n$2(AA.h)},iA.prototype.isEqual=function(eA){return this.toHex()===w$1(eA).toHex()},iA})(),w$1=function(iA){return iA instanceof j?iA:new j(iA)},S=[],k=function(iA){iA.forEach(function(eA){S.indexOf(eA)<0&&(eA(j,y$1),S.push(eA))})},a$1=function(iA){return typeof iA=="string"?iA.length>0:typeof iA=="number"},t$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*iA)/AA+0},o$2=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),iA>AA?AA:iA>eA?iA:eA},r$1=function(iA){var eA=iA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h$1=function(iA){return 255*(iA>.0031308?1.055*Math.pow(iA,1/2.4)-.055:12.92*iA)},n$1=96.422,p$1=100,M$1=82.521,u$1=function(iA){var eA,AA,tA={x:.9555766*(eA=iA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h$1(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h$1(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h$1(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:iA.a},{r:o$2(AA.r,0,255),g:o$2(AA.g,0,255),b:o$2(AA.b,0,255),a:o$2(AA.a)}},e$1=function(iA){var eA=r$1(iA.r),AA=r$1(iA.g),tA=r$1(iA.b);return(function(nA){return{x:o$2(nA.x,0,n$1),y:o$2(nA.y,0,p$1),z:o$2(nA.z,0,M$1),a:o$2(nA.a)}})((function(nA){return{x:1.0478112*nA.x+.0228866*nA.y+-.050127*nA.z,y:.0295424*nA.x+.9904844*nA.y+-.0170491*nA.z,z:-.0092345*nA.x+.0150436*nA.y+.7521316*nA.z,a:nA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:iA.a}))},w=216/24389,b$1=24389/27,i$1=function(iA){var eA=iA.l,AA=iA.a,tA=iA.b,nA=iA.alpha,rA=nA===void 0?1:nA;if(!a$1(eA)||!a$1(AA)||!a$1(tA))return null;var aA=(function(oA){return{l:o$2(oA.l,0,400),a:oA.a,b:oA.b,alpha:o$2(oA.alpha)}})({l:Number(eA),a:Number(AA),b:Number(tA),alpha:Number(rA)});return l$1(aA)},l$1=function(iA){var eA=(iA.l+16)/116,AA=iA.a/500+eA,tA=eA-iA.b/200;return u$1({x:(Math.pow(AA,3)>w?Math.pow(AA,3):(116*AA-16)/b$1)*n$1,y:(iA.l>8?Math.pow((iA.l+16)/116,3):iA.l/b$1)*p$1,z:(Math.pow(tA,3)>w?Math.pow(tA,3):(116*tA-16)/b$1)*M$1,a:iA.alpha})};function labPlugin(iA,eA){iA.prototype.toLab=function(){return tA=e$1(this.rgba),rA=tA.y/p$1,aA=tA.z/M$1,nA=(nA=tA.x/n$1)>w?Math.cbrt(nA):(b$1*nA+16)/116,AA={l:116*(rA=rA>w?Math.cbrt(rA):(b$1*rA+16)/116)-16,a:500*(nA-rA),b:200*(rA-(aA=aA>w?Math.cbrt(aA):(b$1*aA+16)/116)),alpha:tA.a},{l:t$2(AA.l,2),a:t$2(AA.a,2),b:t$2(AA.b,2),alpha:t$2(AA.alpha,3)};var AA,tA,nA,rA,aA},iA.prototype.delta=function(AA){AA===void 0&&(AA="#FFF");var tA=AA instanceof iA?AA:new iA(AA),nA=(function(rA,aA){var oA=rA.l,sA=rA.a,lA=rA.b,gA=aA.l,cA=aA.a,IA=aA.b,CA=180/Math.PI,uA=Math.PI/180,dA=Math.pow(Math.pow(sA,2)+Math.pow(lA,2),.5),pA=Math.pow(Math.pow(cA,2)+Math.pow(IA,2),.5),mA=(oA+gA)/2,QA=Math.pow((dA+pA)/2,7),BA=.5*(1-Math.pow(QA/(QA+Math.pow(25,7)),.5)),hA=sA*(1+BA),DA=cA*(1+BA),EA=Math.pow(Math.pow(hA,2)+Math.pow(lA,2),.5),fA=Math.pow(Math.pow(DA,2)+Math.pow(IA,2),.5),NA=(EA+fA)/2,yA=hA===0&&lA===0?0:Math.atan2(lA,hA)*CA,bA=DA===0&&IA===0?0:Math.atan2(IA,DA)*CA;yA<0&&(yA+=360),bA<0&&(bA+=360);var wA=bA-yA,MA=Math.abs(bA-yA);MA>180&&bA<=yA?wA+=360:MA>180&&bA>yA&&(wA-=360);var vA=yA+bA;MA<=180?vA/=2:vA=(yA+bA<360?vA+360:vA-360)/2;var OA=1-.17*Math.cos(uA*(vA-30))+.24*Math.cos(2*uA*vA)+.32*Math.cos(uA*(3*vA+6))-.2*Math.cos(uA*(4*vA-63)),FA=gA-oA,kA=fA-EA,SA=2*Math.sin(uA*wA/2)*Math.pow(EA*fA,.5),RA=1+.015*Math.pow(mA-50,2)/Math.pow(20+Math.pow(mA-50,2),.5),xA=1+.045*NA,ZA=1+.015*NA*OA,XA=30*Math.exp(-1*Math.pow((vA-275)/25,2)),jA=-2*Math.pow(QA/(QA+Math.pow(25,7)),.5)*Math.sin(2*uA*XA);return Math.pow(Math.pow(FA/1/RA,2)+Math.pow(kA/1/xA,2)+Math.pow(SA/1/ZA,2)+jA*kA*SA/(1*xA*1*ZA),.5)})(this.toLab(),tA.toLab())/100;return o$2(t$2(nA,3))},eA.object.push([i$1,"lab"])}var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t$1=function(iA){return typeof iA=="string"?iA.length>0:typeof iA=="number"},a=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*iA)/AA+0},n=function(iA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),iA>AA?AA:iA>eA?iA:eA},u=function(iA){var eA=iA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h=function(iA){return 255*(iA>.0031308?1.055*Math.pow(iA,1/2.4)-.055:12.92*iA)},o$1=96.422,e=100,c=82.521,i=function(iA){var eA,AA,tA={x:.9555766*(eA=iA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:iA.a},{r:n(AA.r,0,255),g:n(AA.g,0,255),b:n(AA.b,0,255),a:n(AA.a)}},l=function(iA){var eA=u(iA.r),AA=u(iA.g),tA=u(iA.b);return(function(nA){return{x:n(nA.x,0,o$1),y:n(nA.y,0,e),z:n(nA.z,0,c),a:n(nA.a)}})((function(nA){return{x:1.0478112*nA.x+.0228866*nA.y+-.050127*nA.z,y:.0295424*nA.x+.9904844*nA.y+-.0170491*nA.z,z:-.0092345*nA.x+.0150436*nA.y+.7521316*nA.z,a:nA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:iA.a}))},f=216/24389,b=24389/27,d=function(iA){return{l:n(iA.l,0,100),c:iA.c,h:(eA=iA.h,(eA=isFinite(eA)?eA%360:0)>0?eA:eA+360),a:iA.a};var eA},p=function(iA){return{l:a(iA.l,2),c:a(iA.c,2),h:a(iA.h,2),a:a(iA.a,3)}},v=function(iA){var eA=iA.l,AA=iA.c,tA=iA.h,nA=iA.a,rA=nA===void 0?1:nA;if(!t$1(eA)||!t$1(AA)||!t$1(tA))return null;var aA=d({l:Number(eA),c:Number(AA),h:Number(tA),a:Number(rA)});return M(aA)},y=function(iA){var eA=(function(rA){var aA=l(rA),oA=aA.x/o$1,sA=aA.y/e,lA=aA.z/c;return oA=oA>f?Math.cbrt(oA):(b*oA+16)/116,{l:116*(sA=sA>f?Math.cbrt(sA):(b*sA+16)/116)-16,a:500*(oA-sA),b:200*(sA-(lA=lA>f?Math.cbrt(lA):(b*lA+16)/116)),alpha:aA.a}})(iA),AA=a(eA.a,3),tA=a(eA.b,3),nA=Math.atan2(tA,AA)/Math.PI*180;return{l:eA.l,c:Math.sqrt(AA*AA+tA*tA),h:nA<0?nA+360:nA,a:eA.alpha}},M=function(iA){return eA={l:iA.l,a:iA.c*Math.cos(iA.h*Math.PI/180),b:iA.c*Math.sin(iA.h*Math.PI/180),alpha:iA.a},tA=eA.a/500+(AA=(eA.l+16)/116),nA=AA-eA.b/200,i({x:(Math.pow(tA,3)>f?Math.pow(tA,3):(116*tA-16)/b)*o$1,y:(eA.l>8?Math.pow((eA.l+16)/116,3):eA.l/b)*e,z:(Math.pow(nA,3)>f?Math.pow(nA,3):(116*nA-16)/b)*c,a:eA.alpha});var eA,AA,tA,nA},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(iA){var eA=x.exec(iA);if(!eA)return null;var AA,tA,nA=d({l:Number(eA[1]),c:Number(eA[2]),h:(AA=eA[3],tA=eA[4],tA===void 0&&(tA="deg"),Number(AA)*(r[tA]||1)),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return M(nA)};function lchPlugin(iA,eA){iA.prototype.toLch=function(){return p(y(this.rgba))},iA.prototype.toLchString=function(){return AA=p(y(this.rgba)),tA=AA.l,nA=AA.c,rA=AA.h,(aA=AA.a)<1?"lch("+tA+"% "+nA+" "+rA+" / "+aA+")":"lch("+tA+"% "+nA+" "+rA+")";var AA,tA,nA,rA,aA},eA.string.push([s,"lch"]),eA.object.push([v,"lch"])}k([labPlugin,lchPlugin]);const canonicalColorHexByKey={black:"#000000",white:"#ffffff",gray:"#808080",red:"#ff0000",orange:"#ffa500",yellow:"#ffff00",green:"#008000",cyan:"#00ffff",blue:"#0000ff",purple:"#800080",pink:"#ffc0cb",brown:"#a52a2a"},canonicalAnchorDefinitions=Object.fromEntries(Object.entries(canonicalColorHexByKey).map(([iA,eA])=>[iA,{hex:eA,canonical:iA}])),extraAnchorDefinitions={silver:{hex:"#c0c0c0",canonical:"gray"},grayDark:{hex:"#4d4d4d",canonical:"gray"},grayCustom:{hex:"#757575",canonical:"gray"},grayLight:{hex:"#c8c8c8",canonical:"gray"},grayLighter:{hex:"#dcdcdc",canonical:"gray"},maroon:{hex:"#800000",canonical:"red"},redLight:{hex:"#f08080",canonical:"red"},redCustom:{hex:"#D4042D",canonical:"red"},redDark:{hex:"#8b0000",canonical:"red"},crimson:{hex:"#dc143c",canonical:"red"},wine:{hex:"#993355",canonical:"red"},orangeLight:{hex:"#ffa07a",canonical:"orange"},orangeCustom:{hex:"#F19143",canonical:"orange"},orangePresetAccessible:{hex:"#a6510c",canonical:"orange"},orangeDark:{hex:"#ff8c00",canonical:"orange"},yellowLight:{hex:"#ffffe0",canonical:"yellow"},yellowDark:{hex:"#bdb76b",canonical:"yellow"},yellowgreen:{hex:"#9acd32",canonical:"green"},olive:{hex:"#808000",canonical:"green"},lime:{hex:"#00ff00",canonical:"green"},greenLight:{hex:"#90ee90",canonical:"green"},greenCustom:{hex:"#2ca02c",canonical:"green"},greenDark:{hex:"#006400",canonical:"green"},teal:{hex:"#008080",canonical:"green"},aqua:{hex:"#00ffff",canonical:"cyan"},cyanLight:{hex:"#e0ffff",canonical:"cyan"},cyanMid:{hex:"#25b0c0",canonical:"cyan"},cyanDark:{hex:"#008b8b",canonical:"cyan"},navy:{hex:"#000080",canonical:"blue"},blueMid:{hex:"#4477aa",canonical:"blue"},blueSky:{hex:"#56b4e9",canonical:"blue"},blueCustom:{hex:"#648FFF",canonical:"blue"},bluePresetAccessible:{hex:"#1f5dff",canonical:"blue"},blueLight:{hex:"#add8e6",canonical:"blue"},blueDark:{hex:"#00008b",canonical:"blue"},fuchsia:{hex:"#ff00ff",canonical:"purple"},purpleCustom:{hex:"#644CD6",canonical:"purple"},purpleMuted:{hex:"#9c5686",canonical:"purple"},purpleLight:{hex:"#dda0dd",canonical:"purple"},purpleDark:{hex:"#8b008b",canonical:"purple"},hotpink:{hex:"#ff69b4",canonical:"pink"},pinkDark:{hex:"#ff1493",canonical:"pink"},brownLight:{hex:"#deb887",canonical:"brown"},brownDark:{hex:"#8b4513",canonical:"brown"}},anchorDefinitions={...canonicalAnchorDefinitions,...extraAnchorDefinitions};Object.values(anchorDefinitions).map(iA=>({color:w$1(iA.hex),canonical:iA.canonical})),[...Object.keys(colorName)];const DEFAULT_STYLE_VALUES={lineOpacity:.7,lineWidth:4,lineWidthWord:"thick",lineStyle:"solid",lineStyleWord:"",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,markerFilled:!0,fillOpacity:.3,fillPatternOpacity:1,fillStyle:"solid",fillStyleWord:"",lineColor:"#1f5dff",lineColorDarkMode:"#648FFF",markerColor:"#1f5dff",markerColorDarkMode:"#648FFF",fillColor:"#1f5dff",fillColorDarkMode:"#648FFF",textColor:"black",textColorDarkMode:"white",highContrastColor:"#2963FF",highContrastColorDarkMode:"#92B4FF"},defaultPalette={name:"default",description:"The standard Doenet styles: blue, red, orange, purple, black, and gray.",styles:{1:{...DEFAULT_STYLE_VALUES},2:{lineColor:"#D4042D",lineColorDarkMode:"#F1466A",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#D4042D",markerColorDarkMode:"#F1466A",markerOpacity:.7,markerStyle:"square",markerStyleWord:"square",markerSize:5,fillColor:"#D4042D",fillColorDarkMode:"#F1466A",fillOpacity:.3,textColor:"#D4042D",textColorDarkMode:"#FF7A7A",highContrastColor:"#D4042D",highContrastColorDarkMode:"#FF7A7A"},3:{lineColor:"#a6510c",lineColorDarkMode:"#F19143",lineOpacity:.7,lineWidth:3,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#a6510c",markerColorDarkMode:"#F19143",markerOpacity:.7,markerStyle:"triangle",markerStyleWord:"triangle",markerSize:5,fillColor:"#a6510c",fillColorDarkMode:"#F19143",fillOpacity:.3,textColor:"#BE5A0E",textColorDarkMode:"#FFA94D",highContrastColor:"#BE5A0E",highContrastColorDarkMode:"#FFA94D"},4:{lineColor:"#644CD6",lineColorDarkMode:"#9F8FE8",lineColorWordDarkMode:"purple",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#644CD6",markerColorDarkMode:"#9F8FE8",markerColorWordDarkMode:"purple",markerOpacity:.7,markerStyle:"diamond",markerStyleWord:"diamond",markerSize:5,fillColor:"#644CD6",fillColorDarkMode:"#9F8FE8",fillColorWordDarkMode:"purple",fillOpacity:.3,textColor:"#644CD6",textColorDarkMode:"#B0A4EE",highContrastColor:"#644CD6",highContrastColorDarkMode:"#B0A4EE"},5:{lineColor:"black",lineColorDarkMode:"white",lineOpacity:1,lineWidth:1,lineWidthWord:"thin",lineStyle:"solid",lineStyleWord:"",markerColor:"black",markerColorDarkMode:"white",markerOpacity:1,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"black",fillColorDarkMode:"white",fillOpacity:.7,textColor:"black",textColorDarkMode:"white",highContrastColor:"black",highContrastColorDarkMode:"white"},6:{lineColor:"#636363",lineColorDarkMode:"#CCCCCC",lineOpacity:.7,lineWidth:1,lineWidthWord:"thin",lineStyle:"dotted",lineStyleWord:"dotted",markerColor:"#636363",markerColorDarkMode:"#CCCCCC",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"#636363",fillColorDarkMode:"#CCCCCC",fillOpacity:.3,textColor:"#757575",textColorDarkMode:"#B0B0B0",highContrastColor:"#757575",highContrastColorDarkMode:"#B0B0B0"}}},okabeItoPalette={name:"okabeIto",description:"Colorblind-friendly blues, oranges, greens, and purples adapted from the Okabe-Ito palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#0072b2",markerColor:"#0072b2",fillColor:"#0072b2",highContrastColor:"#0072b2",lineColorDarkMode:"#0072b2",markerColorDarkMode:"#0072b2",fillColorDarkMode:"#0072b2",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#c15400",markerColor:"#c15400",fillColor:"#c15400",textColor:"#c15400",highContrastColor:"#c15400",lineColorDarkMode:"#d55e00",markerColorDarkMode:"#d55e00",fillColorDarkMode:"#d55e00",textColorDarkMode:"#d55e00",lineWidth:2,markerStyle:"square"},3:{lineColor:"#009e73",markerColor:"#009e73",fillColor:"#009e73",textColor:"#008561",highContrastColor:"#008561",lineColorDarkMode:"#009e73",markerColorDarkMode:"#009e73",fillColorDarkMode:"#009e73",textColorDarkMode:"#009e73",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#cc79a7",markerColor:"#cc79a7",fillColor:"#cc79a7",textColor:"#a35f85",highContrastColor:"#a35f85",lineColorWord:"purple",markerColorWord:"purple",fillColorWord:"purple",lineColorDarkMode:"#cc79a7",markerColorDarkMode:"#cc79a7",fillColorDarkMode:"#cc79a7",textColorDarkMode:"#cc79a7",lineColorWordDarkMode:"purple",markerColorWordDarkMode:"purple",fillColorWordDarkMode:"purple",textColorWordDarkMode:"purple",highContrastColorWordDarkMode:"purple",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#5a5513",markerColor:"#5a5513",fillColor:"#5a5513",textColor:"#5a5513",highContrastColor:"#5a5513",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#f0e442",markerColorDarkMode:"#f0e442",fillColorDarkMode:"#f0e442",textColorDarkMode:"#f0e442",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#499bca",markerColor:"#499bca",fillColor:"#499bca",textColor:"#397ba1",highContrastColor:"#397ba1",lineColorWord:"skyblue",markerColorWord:"skyblue",fillColorWord:"skyblue",textColorWord:"skyblue",highContrastColorWord:"skyblue",lineColorDarkMode:"#56b4e9",markerColorDarkMode:"#56b4e9",fillColorDarkMode:"#56b4e9",textColorDarkMode:"#56b4e9",lineColorWordDarkMode:"skyblue",markerColorWordDarkMode:"skyblue",fillColorWordDarkMode:"skyblue",textColorWordDarkMode:"skyblue",highContrastColorWordDarkMode:"skyblue",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#c58700",markerColor:"#c58700",fillColor:"#c58700",textColor:"#9d6b00",highContrastColor:"#9d6b00",lineColorWord:"goldenrod",markerColorWord:"goldenrod",fillColorWord:"goldenrod",textColorWord:"goldenrod",highContrastColorWord:"goldenrod",lineColorDarkMode:"#e69f00",markerColorDarkMode:"#e69f00",fillColorDarkMode:"#e69f00",textColorDarkMode:"#e69f00",lineColorWordDarkMode:"goldenrod",markerColorWordDarkMode:"goldenrod",fillColorWordDarkMode:"goldenrod",textColorWordDarkMode:"goldenrod",highContrastColorWordDarkMode:"goldenrod",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"}}},tolBrightPalette={name:"tolBright",description:"Colorblind-friendly bright blues, reds, greens, and purples from Paul Tol's bright palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#4477aa",markerColor:"#4477aa",fillColor:"#4477aa",highContrastColor:"#4477aa",lineColorDarkMode:"#4477aa",markerColorDarkMode:"#4477aa",fillColorDarkMode:"#4477aa",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#ee6677",markerColor:"#ee6677",fillColor:"#ee6677",textColor:"#bf515e",highContrastColor:"#bf515e",lineColorDarkMode:"#ee6677",markerColorDarkMode:"#ee6677",fillColorDarkMode:"#ee6677",textColorDarkMode:"#ee6677",lineWidth:2,markerStyle:"square"},3:{lineColor:"#228833",markerColor:"#228833",fillColor:"#228833",textColor:"#228833",highContrastColor:"#228833",lineColorDarkMode:"#228833",markerColorDarkMode:"#228833",fillColorDarkMode:"#228833",textColorDarkMode:"#3d8e47",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#a29534",markerColor:"#a29534",fillColor:"#a29534",textColor:"#817628",highContrastColor:"#817628",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#ccbb44",markerColorDarkMode:"#ccbb44",fillColorDarkMode:"#ccbb44",textColorDarkMode:"#ccbb44",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#4d9db8",markerColor:"#4d9db8",fillColor:"#4d9db8",textColor:"#3c7d94",highContrastColor:"#3c7d94",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#66ccee",markerColorDarkMode:"#66ccee",fillColorDarkMode:"#66ccee",textColorDarkMode:"#66ccee",lineColorWordDarkMode:"cyan",markerColorWordDarkMode:"cyan",fillColorWordDarkMode:"cyan",textColorWordDarkMode:"cyan",highContrastColorWordDarkMode:"cyan",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#aa3377",markerColor:"#aa3377",fillColor:"#aa3377",textColor:"#aa3377",highContrastColor:"#aa3377",lineColorDarkMode:"#aa3377",markerColorDarkMode:"#aa3377",fillColorDarkMode:"#aa3377",textColorDarkMode:"#b5648c",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#bbbbbb",markerColorDarkMode:"#bbbbbb",fillColorDarkMode:"#bbbbbb",textColorDarkMode:"#bbbbbb",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"}}},tolMutedPalette={name:"tolMuted",description:"Nine colorblind-friendly muted styles from Paul Tol's muted palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#332288",markerColor:"#332288",fillColor:"#332288",highContrastColor:"#332288",lineColorWord:"indigo",markerColorWord:"indigo",fillColorWord:"indigo",highContrastColorWord:"indigo",lineColorDarkMode:"#8a86e8",markerColorDarkMode:"#8a86e8",fillColorDarkMode:"#8a86e8",lineColorWordDarkMode:"indigo",markerColorWordDarkMode:"indigo",fillColorWordDarkMode:"indigo",highContrastColorWordDarkMode:"indigo",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#669ab5",markerColor:"#669ab5",fillColor:"#669ab5",textColor:"#507a90",highContrastColor:"#507a90",lineColorDarkMode:"#88ccee",markerColorDarkMode:"#88ccee",fillColorDarkMode:"#88ccee",textColorDarkMode:"#88ccee",lineWidth:2,markerStyle:"square"},3:{lineColor:"#41a393",markerColor:"#41a393",fillColor:"#41a393",textColor:"#328175",highContrastColor:"#328175",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#44aa99",markerColorDarkMode:"#44aa99",fillColorDarkMode:"#44aa99",textColorDarkMode:"#44aa99",lineColorWordDarkMode:"teal",markerColorWordDarkMode:"teal",fillColorWordDarkMode:"teal",textColorWordDarkMode:"teal",highContrastColorWordDarkMode:"teal",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#117733",markerColor:"#117733",fillColor:"#117733",textColor:"#117733",highContrastColor:"#117733",lineColorDarkMode:"#117733",markerColorDarkMode:"#117733",fillColorDarkMode:"#117733",textColorDarkMode:"#548a5f",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#989833",markerColor:"#989833",fillColor:"#989833",textColor:"#787827",highContrastColor:"#787827",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#999933",markerColorDarkMode:"#999933",fillColorDarkMode:"#999933",textColorDarkMode:"#999933",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#867c46",markerColor:"#867c46",fillColor:"#867c46",textColor:"#7f7542",highContrastColor:"#7f7542",lineColorWord:"tan",markerColorWord:"tan",fillColorWord:"tan",textColorWord:"tan",highContrastColorWord:"tan",lineColorDarkMode:"#ddcc77",markerColorDarkMode:"#ddcc77",fillColorDarkMode:"#ddcc77",textColorDarkMode:"#ddcc77",lineColorWordDarkMode:"tan",markerColorWordDarkMode:"tan",fillColorWordDarkMode:"tan",textColorWordDarkMode:"tan",highContrastColorWordDarkMode:"tan",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#cc6677",markerColor:"#cc6677",fillColor:"#cc6677",textColor:"#b35968",highContrastColor:"#b35968",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#cc6677",markerColorDarkMode:"#cc6677",fillColorDarkMode:"#cc6677",textColorDarkMode:"#cc6677",lineColorWordDarkMode:"pink",markerColorWordDarkMode:"pink",fillColorWordDarkMode:"pink",textColorWordDarkMode:"pink",highContrastColorWordDarkMode:"pink",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#882255",markerColor:"#882255",fillColor:"#882255",textColor:"#882255",highContrastColor:"#882255",lineColorWord:"maroon",markerColorWord:"maroon",fillColorWord:"maroon",textColorWord:"maroon",highContrastColorWord:"maroon",lineColorDarkMode:"#924b69",markerColorDarkMode:"#924b69",fillColorDarkMode:"#924b69",textColorDarkMode:"#a17083",lineColorWordDarkMode:"maroon",markerColorWordDarkMode:"maroon",fillColorWordDarkMode:"maroon",textColorWordDarkMode:"maroon",highContrastColorWordDarkMode:"maroon",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#aa4499",markerColor:"#aa4499",fillColor:"#aa4499",textColor:"#aa4499",highContrastColor:"#aa4499",lineColorDarkMode:"#aa4499",markerColorDarkMode:"#aa4499",fillColorDarkMode:"#aa4499",textColorDarkMode:"#b262a3",lineWidth:2,lineStyle:"dashed",markerStyle:"square"}}},tolHighContrastPalette={name:"tolHighContrast",description:"Four maximum-distinction styles from Paul Tol's high-contrast palette, distinguishable even in grayscale.",styles:{1:{lineColor:"#004488",markerColor:"#004488",fillColor:"#004488",highContrastColor:"#004488",lineColorDarkMode:"#496194",markerColorDarkMode:"#496194",fillColorDarkMode:"#496194",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#b88d29",markerColor:"#b88d29",fillColor:"#b88d29",textColor:"#92701f",highContrastColor:"#92701f",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ddaa33",markerColorDarkMode:"#ddaa33",fillColorDarkMode:"#ddaa33",textColorDarkMode:"#ddaa33",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"square"},3:{lineColor:"#bb5566",markerColor:"#bb5566",fillColor:"#bb5566",textColor:"#bb5566",highContrastColor:"#bb5566",lineColorDarkMode:"#c06976",markerColorDarkMode:"#c06976",fillColorDarkMode:"#c06976",textColorDarkMode:"#c06976",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"diamond"}}},ibmPalette={name:"ibm",description:"Five colorblind-friendly styles from the IBM Design Library accessible palette, with varied marker shapes.",styles:{1:{lineColor:"#648fff",markerColor:"#648fff",fillColor:"#648fff",highContrastColor:"#4f71cb",lineColorDarkMode:"#648fff",markerColorDarkMode:"#648fff",fillColorDarkMode:"#648fff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#6a53d5",markerColor:"#6a53d5",fillColor:"#6a53d5",textColor:"#6a53d5",highContrastColor:"#6a53d5",lineColorDarkMode:"#785ef0",markerColorDarkMode:"#785ef0",fillColorDarkMode:"#785ef0",textColorDarkMode:"#7f69f0",lineWidth:2,markerStyle:"square"},3:{lineColor:"#dc267f",markerColor:"#dc267f",fillColor:"#dc267f",textColor:"#dc267f",highContrastColor:"#dc267f",lineColorWord:"magenta",markerColorWord:"magenta",fillColorWord:"magenta",textColorWord:"magenta",highContrastColorWord:"magenta",lineColorDarkMode:"#dc267f",markerColorDarkMode:"#dc267f",fillColorDarkMode:"#dc267f",textColorDarkMode:"#dd4186",lineColorWordDarkMode:"magenta",markerColorWordDarkMode:"magenta",fillColorWordDarkMode:"magenta",textColorWordDarkMode:"magenta",highContrastColorWordDarkMode:"magenta",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#fe6100",markerColor:"#fe6100",fillColor:"#fe6100",textColor:"#cb4b00",highContrastColor:"#cb4b00",lineColorDarkMode:"#fe6100",markerColorDarkMode:"#fe6100",fillColorDarkMode:"#fe6100",textColorDarkMode:"#fe6100",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#865a00",markerColor:"#865a00",fillColor:"#865a00",textColor:"#865a00",highContrastColor:"#865a00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffb000",markerColorDarkMode:"#ffb000",fillColorDarkMode:"#ffb000",textColorDarkMode:"#ffb000",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"triangleDown"}}},grayscalePalette={name:"grayscale",description:"Four grays with maximum luminance separation, for readers who distinguish styles by lightness alone.",styles:{1:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",highContrastColorDarkMode:"#ffffff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#323232",markerColor:"#323232",fillColor:"#323232",textColor:"#323232",highContrastColor:"#323232",lineColorWord:"dark gray",markerColorWord:"dark gray",fillColorWord:"dark gray",textColorWord:"dark gray",highContrastColorWord:"dark gray",lineColorDarkMode:"#c7c7c7",markerColorDarkMode:"#c7c7c7",fillColorDarkMode:"#c7c7c7",textColorDarkMode:"#c7c7c7",highContrastColorDarkMode:"#c7c7c7",lineColorWordDarkMode:"light gray",markerColorWordDarkMode:"light gray",fillColorWordDarkMode:"light gray",textColorWordDarkMode:"light gray",highContrastColorWordDarkMode:"light gray",lineWidth:2,markerStyle:"square"},3:{lineColor:"#616161",markerColor:"#616161",fillColor:"#616161",textColor:"#616161",highContrastColor:"#616161",lineColorDarkMode:"#929292",markerColorDarkMode:"#929292",fillColorDarkMode:"#929292",textColorDarkMode:"#929292",highContrastColorDarkMode:"#929292",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#767676",highContrastColor:"#767676",lineColorWord:"light gray",markerColorWord:"light gray",fillColorWord:"light gray",textColorWord:"light gray",highContrastColorWord:"light gray",lineColorDarkMode:"#626262",markerColorDarkMode:"#626262",fillColorDarkMode:"#626262",textColorDarkMode:"#7d7d7d",highContrastColorDarkMode:"#7d7d7d",lineColorWordDarkMode:"dark gray",markerColorWordDarkMode:"dark gray",fillColorWordDarkMode:"dark gray",textColorWordDarkMode:"dark gray",highContrastColorWordDarkMode:"dark gray",lineWidth:2,markerStyle:"diamond"}}},categoricalPalette={name:"categorical",description:"Ten maximally varied hues adapted from the Category10 sequence, for documents needing many obviously distinct styles.",styles:{1:{lineColor:"#1f77b4",markerColor:"#1f77b4",fillColor:"#1f77b4",highContrastColor:"#1f77b4",lineColorDarkMode:"#5ba3dd",markerColorDarkMode:"#5ba3dd",fillColorDarkMode:"#5ba3dd",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#e7730c",markerColor:"#e7730c",fillColor:"#e7730c",textColor:"#b95b07",highContrastColor:"#b95b07",lineColorDarkMode:"#ff9d3c",markerColorDarkMode:"#ff9d3c",fillColorDarkMode:"#ff9d3c",textColorDarkMode:"#ff9d3c",lineWidth:2,markerStyle:"square"},3:{lineColor:"#217a21",markerColor:"#217a21",fillColor:"#217a21",textColor:"#217a21",highContrastColor:"#217a21",lineColorDarkMode:"#2ca02c",markerColorDarkMode:"#2ca02c",fillColorDarkMode:"#2ca02c",textColorDarkMode:"#2ca02c",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#d62728",markerColor:"#d62728",fillColor:"#d62728",textColor:"#d62728",highContrastColor:"#d62728",lineColorDarkMode:"#e2494a",markerColorDarkMode:"#e2494a",fillColorDarkMode:"#e2494a",textColorDarkMode:"#e2494a",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#9467bd",markerColor:"#9467bd",fillColor:"#9467bd",textColor:"#8e62b5",highContrastColor:"#8e62b5",lineColorDarkMode:"#b48fd6",markerColorDarkMode:"#b48fd6",fillColorDarkMode:"#b48fd6",textColorDarkMode:"#b48fd6",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#7a4a41",markerColor:"#7a4a41",fillColor:"#7a4a41",textColor:"#7a4a41",highContrastColor:"#7a4a41",lineColorDarkMode:"#a9705f",markerColorDarkMode:"#a9705f",fillColorDarkMode:"#a9705f",textColorDarkMode:"#a9705f",lineColorWordDarkMode:"brown",markerColorWordDarkMode:"brown",fillColorWordDarkMode:"brown",textColorWordDarkMode:"brown",highContrastColorWordDarkMode:"brown",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#d670b7",markerColor:"#d670b7",fillColor:"#d670b7",textColor:"#ab5892",highContrastColor:"#ab5892",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#e377c2",markerColorDarkMode:"#e377c2",fillColorDarkMode:"#e377c2",textColorDarkMode:"#e377c2",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#7f7f7f",markerColor:"#7f7f7f",fillColor:"#7f7f7f",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#a8a8a8",markerColorDarkMode:"#a8a8a8",fillColorDarkMode:"#a8a8a8",textColorDarkMode:"#a8a8a8",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#6e6e12",markerColor:"#6e6e12",fillColor:"#6e6e12",textColor:"#6e6e12",highContrastColor:"#6e6e12",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#bcbd22",markerColorDarkMode:"#bcbd22",fillColorDarkMode:"#bcbd22",textColorDarkMode:"#bcbd22",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,lineStyle:"dashed",markerStyle:"square"},10:{lineColor:"#12a2b1",markerColor:"#12a2b1",fillColor:"#12a2b1",textColor:"#0c818e",highContrastColor:"#0c818e",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#17becf",markerColorDarkMode:"#17becf",fillColorDarkMode:"#17becf",textColorDarkMode:"#17becf",lineWidth:2,lineStyle:"dotted",markerStyle:"diamond"}}},grumpyNarwhalPalette={name:"grumpyNarwhal",description:"Six saturated hues — burnt orange, forest green, deep pink, arctic teal, gold, and purple — going neon in dark mode.",styles:{1:{lineColor:"#b34700",markerColor:"#b34700",fillColor:"#b34700",highContrastColor:"#b34700",lineColorDarkMode:"#ff5f00",markerColorDarkMode:"#ff5f00",fillColorDarkMode:"#ff5f00",lineColorWordDarkMode:"orange",markerColorWordDarkMode:"orange",fillColorWordDarkMode:"orange",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#1b7a1b",markerColor:"#1b7a1b",fillColor:"#1b7a1b",textColor:"#1b7a1b",highContrastColor:"#1b7a1b",lineColorDarkMode:"#39ff14",markerColorDarkMode:"#39ff14",fillColorDarkMode:"#39ff14",textColorDarkMode:"#39ff14",lineWidth:2,markerStyle:"square"},3:{lineColor:"#c20e67",markerColor:"#c20e67",fillColor:"#c20e67",textColor:"#c20e67",highContrastColor:"#c20e67",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#ff1493",markerColorDarkMode:"#ff1493",fillColorDarkMode:"#ff1493",textColorDarkMode:"#ff1493",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#007a8c",markerColor:"#007a8c",fillColor:"#007a8c",textColor:"#007a8c",highContrastColor:"#007a8c",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#00e5ff",markerColorDarkMode:"#00e5ff",fillColorDarkMode:"#00e5ff",textColorDarkMode:"#00e5ff",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#8a6d00",markerColor:"#8a6d00",fillColor:"#8a6d00",textColor:"#8a6d00",highContrastColor:"#8a6d00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffea00",markerColorDarkMode:"#ffea00",fillColorDarkMode:"#ffea00",textColorDarkMode:"#ffea00",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#b026ff",markerColor:"#b026ff",fillColor:"#b026ff",textColor:"#b026ff",highContrastColor:"#b026ff",lineColorDarkMode:"#b026ff",markerColorDarkMode:"#b026ff",fillColorDarkMode:"#b026ff",textColorDarkMode:"#b445ff",highContrastColorDarkMode:"#b445ff",lineWidth:2,markerStyle:"triangleLeft"}}};function deepFreezePalette(iA){for(const eA of Object.values(iA.styles)){for(const AA of Object.values(eA))typeof AA=="object"&&AA!==null&&Object.freeze(AA);Object.freeze(eA)}return Object.freeze(iA.styles),Object.freeze(iA)}function registerByKey(iA){return[iA.name.toLowerCase(),deepFreezePalette(iA)]}const STYLE_PALETTES=Object.assign(Object.create(null),Object.fromEntries([defaultPalette,okabeItoPalette,tolBrightPalette,tolMutedPalette,tolHighContrastPalette,ibmPalette,grayscalePalette,categoricalPalette,grumpyNarwhalPalette].map(registerByKey)));Object.freeze(STYLE_PALETTES),defaultPalette.name.toLowerCase(),Object.freeze(Object.keys(STYLE_PALETTES));var o=function(iA){var eA=iA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},t=function(iA){return .2126*o(iA.r)+.7152*o(iA.g)+.0722*o(iA.b)};function a11yPlugin(iA){iA.prototype.luminance=function(){return eA=t(this.rgba),(AA=2)===void 0&&(AA=0),tA===void 0&&(tA=Math.pow(10,AA)),Math.round(tA*eA)/tA+0;var eA,AA,tA},iA.prototype.contrast=function(eA){eA===void 0&&(eA="#FFF");var AA,tA,nA,rA,aA,oA,sA,lA=eA instanceof iA?eA:new iA(eA);return rA=this.rgba,aA=lA.toRgb(),oA=t(rA),sA=t(aA),AA=oA>sA?(oA+.05)/(sA+.05):(sA+.05)/(oA+.05),(tA=2)===void 0&&(tA=0),nA===void 0&&(nA=Math.pow(10,tA)),Math.floor(nA*AA)/nA+0},iA.prototype.isReadable=function(eA,AA){return eA===void 0&&(eA="#FFF"),AA===void 0&&(AA={}),this.contrast(eA)>=(oA=(aA=(tA=AA).size)===void 0?"normal":aA,(rA=(nA=tA.level)===void 0?"AA":nA)==="AAA"&&oA==="normal"?7:rA==="AA"&&oA==="large"?3:4.5);var tA,nA,rA,aA,oA}}function namesPlugin(iA,eA){var AA={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},tA={};for(var nA in AA)tA[AA[nA]]=nA;var rA={};iA.prototype.toName=function(aA){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var oA,sA,lA=tA[this.toHex()];if(lA)return lA;if(aA?.closest){var gA=this.toRgb(),cA=1/0,IA="black";if(!rA.length)for(var CA in AA)rA[CA]=new iA(AA[CA]).toRgb();for(var uA in AA){var dA=(oA=gA,sA=rA[uA],Math.pow(oA.r-sA.r,2)+Math.pow(oA.g-sA.g,2)+Math.pow(oA.b-sA.b,2));dA<cA&&(cA=dA,IA=uA)}return IA}},eA.string.push([function(aA){var oA=aA.toLowerCase(),sA=oA==="transparent"?"#0000":AA[oA];return sA?new iA(sA).toRgb():null},"name"])}k([a11yPlugin,namesPlugin]);let styleAttributes={lineColor:{componentType:"text",description:"Color used for line strokes (light mode)."},lineColorWord:{componentType:"text",description:"Human-readable name of the line color (light mode)."},lineColorDarkMode:{componentType:"text",description:"Color used for line strokes (dark mode)."},lineColorWordDarkMode:{componentType:"text",description:"Human-readable name of the line color (dark mode)."},lineOpacity:{componentType:"number",description:"Opacity of line strokes, 0 to 1."},lineWidth:{componentType:"number",description:"Stroke width for lines, in pixels."},lineWidthWord:{componentType:"text",description:"Human-readable name of the line width."},lineStyle:{componentType:"text",description:"Stroke style for lines.",toLowerCase:!0,validValues:[{value:"solid",description:"Continuous, unbroken stroke."},{value:"dashed",description:"Stroke composed of evenly-spaced dashes."},{value:"dotted",description:"Stroke composed of evenly-spaced dots."}]},lineStyleWord:{componentType:"text",description:"Human-readable name of the line style."},markerColor:{componentType:"text",description:"Color used for markers/points (light mode)."},markerColorWord:{componentType:"text",description:"Human-readable name of the marker color (light mode)."},markerColorDarkMode:{componentType:"text",description:"Color used for markers/points (dark mode)."},markerColorWordDarkMode:{componentType:"text",description:"Human-readable name of the marker color (dark mode)."},markerOpacity:{componentType:"number",description:"Opacity of markers/points, 0 to 1."},markerStyle:{componentType:"text",description:"Marker shape.",toLowerCase:!0,validValues:[{value:"circle",description:"Circular marker."},{value:"square",description:"Square marker."},{value:"triangle",description:'Triangular marker pointing up (alias for "triangleUp").'},{value:"triangleUp",description:"Triangular marker pointing up."},{value:"triangleDown",description:"Triangular marker pointing down."},{value:"triangleLeft",description:"Triangular marker pointing left."},{value:"triangleRight",description:"Triangular marker pointing right."},{value:"diamond",description:"Diamond-shaped marker."},{value:"cross",description:"Cross-shaped marker (×)."},{value:"plus",description:"Plus-shaped marker (+)."}]},markerStyleWord:{componentType:"text",description:"Human-readable name of the marker style."},markerSize:{componentType:"number",description:"Marker size in pixels."},markerFilled:{componentType:"boolean",description:"Whether the marker is rendered filled (true) or open (false). Has no effect when markerStyle is cross or plus, which have no interior."},fillColor:{componentType:"text",description:"Fill color used inside closed shapes (light mode)."},fillColorWord:{componentType:"text",description:"Human-readable name of the fill color (light mode)."},fillColorDarkMode:{componentType:"text",description:"Fill color used inside closed shapes (dark mode)."},fillColorWordDarkMode:{componentType:"text",description:"Human-readable name of the fill color (dark mode)."},fillOpacity:{componentType:"number",description:"Opacity of solid fills, 0 to 1."},fillPatternOpacity:{componentType:"number",description:"Opacity of pattern fills (non-solid fillStyle), 0 to 1."},fillStyle:{componentType:"text",description:"Fill pattern used inside closed shapes.",toLowerCase:!0,validValues:[{value:"solid",description:"Solid fill."},{value:"horizontal",description:"Horizontal line pattern."},{value:"vertical",description:"Vertical line pattern."},{value:"diagonal",description:"Diagonal line pattern (/)."},{value:"backDiagonal",description:"Back-diagonal line pattern (\\)."},{value:"dots",description:"Dots pattern."},{value:"diamonds",description:"Filled diamonds pattern."}]},fillStyleWord:{componentType:"text",description:"Human-readable name of the fill style."},textColor:{componentType:"text",description:"Text color (light mode)."},textColorWord:{componentType:"text",description:"Human-readable name of the text color (light mode)."},textColorDarkMode:{componentType:"text",description:"Text color (dark mode)."},textColorWordDarkMode:{componentType:"text",description:"Human-readable name of the text color (dark mode)."},highContrastColor:{componentType:"text",description:"High-contrast accent color (light mode)."},highContrastColorWord:{componentType:"text",description:"Human-readable name of the high-contrast accent color (light mode)."},highContrastColorDarkMode:{componentType:"text",description:"High-contrast accent color (dark mode)."},highContrastColorWordDarkMode:{componentType:"text",description:"Human-readable name of the high-contrast accent color (dark mode)."},backgroundColor:{componentType:"text",description:"Background color (light mode)."},backgroundColorWord:{componentType:"text",description:"Human-readable name of the background color (light mode)."},backgroundColorDarkMode:{componentType:"text",description:"Background color (dark mode)."},backgroundColorWordDarkMode:{componentType:"text",description:"Human-readable name of the background color (dark mode)."}};styleAttributes.markerStyle.validValues.filter(iA=>iA.value!=="cross"&&iA.value!=="plus");const MARKER_OVERRIDE_KEYS=["markerStyle","markerSize","markerFilled"],LINE_OVERRIDE_KEYS=["lineStyle","lineWidth"],FILL_OVERRIDE_KEYS=["fillOpacity","fillPatternOpacity","fillStyle"],markerOverrideAttributes=Object.fromEntries(MARKER_OVERRIDE_KEYS.map(iA=>[iA,styleAttributes[iA]])),lineOverrideAttributes=Object.fromEntries(LINE_OVERRIDE_KEYS.map(iA=>[iA,styleAttributes[iA]])),fillOverrideAttributes=Object.fromEntries(FILL_OVERRIDE_KEYS.map(iA=>[iA,styleAttributes[iA]]));({...markerOverrideAttributes,...lineOverrideAttributes,...fillOverrideAttributes});const STYLE_OVERRIDE_CATEGORIES={marker:markerOverrideAttributes,line:lineOverrideAttributes,fill:fillOverrideAttributes};for(const[iA,eA]of Object.entries(STYLE_OVERRIDE_CATEGORIES))for(const[AA,tA]of Object.entries(eA)){if(AA.toLowerCase().includes("color"))throw new Error(`Style override category "${iA}" contains color-related key "${AA}"; colors stay <styleDefinition>-only so per-styleNumber WCAG contrast diagnostics remain authoritative. If this is intentional, also reconcile the lowercase asymmetry in returnSelectedStyleStateVariableDefinition.`);if(AA.endsWith("Opacity")&&AA!=="fillOpacity"&&AA!=="fillPatternOpacity")throw new Error(`Style override category "${iA}" contains contrast-feeding opacity key "${AA}"; lineOpacity and markerOpacity feed the WCAG contrast diagnostic as an opacityMultiplier on the foreground alpha, so they stay <styleDefinition>-only alongside colors. Only fillOpacity and fillPatternOpacity are contrast-irrelevant and overridable.`);if(tA.componentType==="text"&&!tA.toLowerCase)throw new Error(`Style override key "${AA}" in category "${iA}" is text-typed but missing toLowerCase: true. Add toLowerCase: true to its styleAttributes entry, or move it out of the override surface.`)}Object.entries(styleAttributes).filter(([,iA])=>iA.toLowerCase).map(([iA])=>iA);var base32$1={exports:{}},hasRequiredBase32;function requireBase32(){return hasRequiredBase32||(hasRequiredBase32=1,(function(iA){(function(){var eA=typeof window=="object"?window:{},AA=!eA.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;AA&&(eA=commonjsGlobal);var tA=!eA.HI_BASE32_NO_COMMON_JS&&!0&&iA.exports,nA="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),rA={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},aA=[0,0,0,0,0,0,0,0],oA=function(pA,mA){mA.length>10&&(mA="..."+mA.substr(-10));var QA=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+pA+" bytes: "+mA+" <-");throw QA.position=pA,QA},sA=function(pA){for(var mA="",QA=pA.length,BA=0,hA=0,DA,EA;BA<QA;){if(DA=pA[BA++],DA<=127){mA+=String.fromCharCode(DA);continue}else DA>191&&DA<=223?(EA=DA&31,hA=1):DA<=239?(EA=DA&15,hA=2):DA<=247?(EA=DA&7,hA=3):oA(BA,mA);for(var fA=0;fA<hA;++fA)DA=pA[BA++],(DA<128||DA>191)&&oA(BA,mA),EA<<=6,EA+=DA&63;EA>=55296&&EA<=57343&&oA(BA,mA),EA>1114111&&oA(BA,mA),EA<=65535?mA+=String.fromCharCode(EA):(EA-=65536,mA+=String.fromCharCode((EA>>10)+55296),mA+=String.fromCharCode((EA&1023)+56320))}return mA},lA=function(pA){if(pA==="")return[];if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");pA=pA.replace(/=/g,"");for(var mA,QA,BA,hA,DA,EA,fA,NA,yA=[],bA=0,wA=pA.length,MA=0,vA=wA>>3<<3;MA<vA;)mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255,yA[bA++]=(fA<<5|NA)&255;var OA=wA-vA;return OA===2?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255):OA===4?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255):OA===5?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255):OA===7&&(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255),yA},gA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA++),DA=pA.charCodeAt(NA++),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[(hA<<3|DA>>>5)&31]+nA[DA&31];var bA=fA-yA;return bA===1?(mA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[mA<<2&31]+"======"):bA===2?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[QA<<4&31]+"===="):bA===3?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[BA<<1&31]+"==="):bA===4&&(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA),EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[hA<<3&31]+"="),EA},cA=function(pA){var mA,QA,BA,hA,DA,EA,fA=!1,NA="",yA=0,bA,wA=0,MA=pA.length;if(pA==="")return NA;do{for(aA[0]=aA[5],aA[1]=aA[6],aA[2]=aA[7],bA=wA;yA<MA&&bA<5;++yA)EA=pA.charCodeAt(yA),EA<128?aA[bA++]=EA:EA<2048?(aA[bA++]=192|EA>>6,aA[bA++]=128|EA&63):EA<55296||EA>=57344?(aA[bA++]=224|EA>>12,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63):(EA=65536+((EA&1023)<<10|pA.charCodeAt(++yA)&1023),aA[bA++]=240|EA>>18,aA[bA++]=128|EA>>12&63,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63);wA=bA-5,yA===MA&&++yA,yA>MA&&bA<6&&(fA=!0),mA=aA[0],bA>4?(QA=aA[1],BA=aA[2],hA=aA[3],DA=aA[4],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[(hA<<3|DA>>>5)&31]+nA[DA&31]):bA===1?NA+=nA[mA>>>3]+nA[mA<<2&31]+"======":bA===2?(QA=aA[1],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[QA<<4&31]+"===="):bA===3?(QA=aA[1],BA=aA[2],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[BA<<1&31]+"==="):(QA=aA[1],BA=aA[2],hA=aA[3],NA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[hA<<3&31]+"=")}while(!fA);return NA},IA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA++],DA=pA[NA++],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[(hA<<3|DA>>>5)&31]+nA[DA&31];var bA=fA-yA;return bA===1?(mA=pA[NA],EA+=nA[mA>>>3]+nA[mA<<2&31]+"======"):bA===2?(mA=pA[NA++],QA=pA[NA],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[QA<<4&31]+"===="):bA===3?(mA=pA[NA++],QA=pA[NA++],BA=pA[NA],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[BA<<1&31]+"==="):bA===4&&(mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA],EA+=nA[mA>>>3]+nA[(mA<<2|QA>>>6)&31]+nA[QA>>>1&31]+nA[(QA<<4|BA>>>4)&31]+nA[(BA<<1|hA>>>7)&31]+nA[hA>>>2&31]+nA[hA<<3&31]+"="),EA},CA=function(pA,mA){var QA=typeof pA!="string";return QA&&pA.constructor===ArrayBuffer&&(pA=new Uint8Array(pA)),QA?IA(pA):mA?gA(pA):cA(pA)},uA=function(pA,mA){if(!mA)return sA(lA(pA));if(pA==="")return"";if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");var QA,BA,hA,DA,EA,fA,NA,yA,bA="",wA=pA.indexOf("=");wA===-1&&(wA=pA.length);for(var MA=0,vA=wA>>3<<3;MA<vA;)QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)+String.fromCharCode((NA<<5|yA)&255);var OA=wA-vA;return OA===2?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)):OA===4?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)):OA===5?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)):OA===7&&(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)),bA},dA={encode:CA,decode:uA};uA.asBytes=lA,tA?iA.exports=dA:eA.base32=dA})()})(base32$1)),base32$1.exports}requireBase32();function groupCompositeRanges({children:iA,ranges:eA,isAbsent:AA=()=>!1,isBlank:tA=()=>!1,skipRange:nA=()=>!1,trimEnd:rA=lA=>lA,startInd:aA=0,endInd:oA=iA.length-1,removedInd:sA=null}){const lA=(eA??[]).flatMap(uA=>{const dA=shiftForRemovedChild(uA,sA);return dA&&dA.firstInd>=aA&&dA.lastInd<=oA?[{range:uA,...dA}]:[]}).sort((uA,dA)=>uA.firstInd-dA.firstInd||dA.lastInd-uA.lastInd),gA={range:null,firstInd:aA,lastInd:oA,nextInd:aA,eligibility:null,items:[],eligible:[]},cA=[gA];function IA(uA,dA){for(;uA.nextInd<dA;uA.nextInd++){const pA=iA[uA.nextInd];AA(pA)||(uA.items.push({kind:"child",value:pA,index:uA.nextInd}),uA.eligibility&&uA.eligible.push(uA.eligibility[uA.nextInd-uA.firstInd]??!1))}}function CA(){const uA=cA.pop();if(IA(uA,uA.lastInd+1),uA.items.length===0)return;const dA=cA[cA.length-1],pA=uA.items.filter(BA=>!isBlankGroup(BA,tA)),mA=uA.eligible.every((BA,hA)=>BA||isBlankGroup(uA.items[hA],tA)),QA=!!uA.range.asList&&mA&&pA.length>1;dA.items.push({kind:"composite",range:uA.range,asList:QA,items:QA?prepareListItems(uA.items,tA,rA):uA.items}),dA.eligibility&&dA.eligible.push(mA)}for(const{range:uA,firstInd:dA,lastInd:pA}of lA){for(;cA.length>1&&pA>cA[cA.length-1].lastInd;)CA();const mA=cA[cA.length-1];dA<mA.nextInd||(IA(mA,dA),mA.nextInd=pA+1,!nA(uA)&&cA.push({range:uA,firstInd:dA,lastInd:pA,nextInd:dA,eligibility:uA.potentialListComponents??null,items:[],eligible:[]}))}for(;cA.length>1;)CA();return IA(gA,oA+1),gA.items}function shiftForRemovedChild(iA,eA){let{firstInd:AA,lastInd:tA}=iA;if(eA===null)return{firstInd:AA,lastInd:tA};if(!(AA===eA||tA===eA))return AA>eA&&(AA-=1),tA>eA&&(tA-=1),{firstInd:AA,lastInd:tA}}function isBlankGroup(iA,eA){return iA.kind==="child"?eA(iA.value):iA.items.every(AA=>isBlankGroup(AA,eA))}function prepareListItems(iA,eA,AA){const tA=iA.findIndex(aA=>!isBlankGroup(aA,eA));let nA=iA.length-1;for(;nA>tA&&isBlankGroup(iA[nA],eA);)nA--;const rA=[];for(const[aA,oA]of iA.entries())aA<tA||aA>=nA?rA.push(oA):isBlankGroup(oA,eA)?oA.kind==="composite"&&rA.push(withoutBlankChildren(oA)):rA.push(trimItemEnd(oA,eA,AA));return rA}function withoutBlankChildren(iA){return{...iA,items:iA.items.flatMap(eA=>eA.kind==="composite"?[withoutBlankChildren(eA)]:[])}}function trimItemEnd(iA,eA,AA){if(iA.kind==="child"){const rA=AA(iA.value);return rA===iA.value?iA:{...iA,value:rA}}let tA=iA.items.length;for(;isBlankGroup(iA.items[tA-1],eA);)tA--;const nA=iA.items.slice(tA).flatMap(rA=>rA.kind==="composite"?[withoutBlankChildren(rA)]:[]);return{...iA,items:[...iA.items.slice(0,tA-1),trimItemEnd(iA.items[tA-1],eA,AA),...nA]}}const{gcd,lcm}=context.math,{mod}=context.math,defaultCreativeCommonsVersion="4.0";function creativeCommonsLicense(iA,eA,AA,tA){return{code:iA,name:`Creative Commons ${eA}`,description:tA,kind:"creative-commons",url:(nA=defaultCreativeCommonsVersion)=>`https://creativecommons.org/licenses/${AA}/${nA}/`}}function fixedUrlLicense(iA,eA,AA,tA,nA){return{code:iA,name:eA,description:tA,kind:nA,url:()=>AA}}const mediaLicenses=[creativeCommonsLicense("CC-BY","Attribution","by","Creative Commons Attribution: reuse with credit, including commercially."),creativeCommonsLicense("CC-BY-SA","Attribution-ShareAlike","by-sa","Creative Commons Attribution-ShareAlike: reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-ND","Attribution-NoDerivatives","by-nd","Creative Commons Attribution-NoDerivatives: reuse unchanged, with credit."),creativeCommonsLicense("CC-BY-NC","Attribution-NonCommercial","by-nc","Creative Commons Attribution-NonCommercial: reuse with credit for noncommercial purposes."),creativeCommonsLicense("CC-BY-NC-SA","Attribution-NonCommercial-ShareAlike","by-nc-sa","Creative Commons Attribution-NonCommercial-ShareAlike: noncommercial reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-NC-ND","Attribution-NonCommercial-NoDerivatives","by-nc-nd","Creative Commons Attribution-NonCommercial-NoDerivatives: reuse unchanged for noncommercial purposes, with credit."),fixedUrlLicense("CC0","CC0 1.0 Public Domain Dedication","https://creativecommons.org/publicdomain/zero/1.0/","Creative Commons Zero: the creator has dedicated the work to the public domain.","public-domain"),fixedUrlLicense("PDM","Public Domain Mark 1.0","https://creativecommons.org/publicdomain/mark/1.0/","Public Domain Mark: the work is free of known copyright restrictions.","public-domain"),fixedUrlLicense("GFDL","GNU Free Documentation License","https://www.gnu.org/licenses/fdl-1.3.html","GNU Free Documentation License: copyleft license common on Wikimedia.","license"),fixedUrlLicense("FAL","Free Art License 1.3","https://artlibre.org/licence/lal/en/","Free Art License: copyleft license for artistic works.","license"),fixedUrlLicense("OGL","Open Government Licence v3.0 (UK)","https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/","UK Open Government Licence: reuse government material with attribution.","license"),fixedUrlLicense("MIT","MIT License","https://opensource.org/license/mit","MIT License: permissive license common for icon and illustration sets.","license"),fixedUrlLicense("APACHE-2.0","Apache License 2.0","https://www.apache.org/licenses/LICENSE-2.0","Apache License 2.0: permissive license common for icon and illustration sets.","license")];Object.fromEntries(mediaLicenses.map(iA=>[iA.code.toLowerCase(),iA]));var cssesc_1,hasRequiredCssesc;function requireCssesc(){if(hasRequiredCssesc)return cssesc_1;hasRequiredCssesc=1;var iA={},eA=iA.hasOwnProperty,AA=function(sA,lA){if(!sA)return lA;var gA={};for(var cA in lA)gA[cA]=eA.call(sA,cA)?sA[cA]:lA[cA];return gA},tA=/[ -,\.\/:-@\[-\^`\{-~]/,nA=/[ -,\.\/:-@\[\]\^`\{-~]/,rA=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,aA=function oA(sA,lA){lA=AA(lA,oA.options),lA.quotes!="single"&&lA.quotes!="double"&&(lA.quotes="single");for(var gA=lA.quotes=="double"?'"':"'",cA=lA.isIdentifier,IA=sA.charAt(0),CA="",uA=0,dA=sA.length;uA<dA;){var pA=sA.charAt(uA++),mA=pA.charCodeAt(),QA=void 0;if(mA<32||mA>126){if(mA>=55296&&mA<=56319&&uA<dA){var BA=sA.charCodeAt(uA++);(BA&64512)==56320?mA=((mA&1023)<<10)+(BA&1023)+65536:uA--}QA="\\"+mA.toString(16).toUpperCase()+" "}else lA.escapeEverything?tA.test(pA)?QA="\\"+pA:QA="\\"+mA.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(pA)?QA="\\"+mA.toString(16).toUpperCase()+" ":pA=="\\"||!cA&&(pA=='"'&&gA==pA||pA=="'"&&gA==pA)||cA&&nA.test(pA)?QA="\\"+pA:QA=pA;CA+=QA}return cA&&(/^-[-\d]/.test(CA)?CA="\\-"+CA.slice(1):/\d/.test(IA)&&(CA="\\3"+IA+" "+CA.slice(1))),CA=CA.replace(rA,function(hA,DA,EA){return DA&&DA.length%2?hA:(DA||"")+EA}),!cA&&lA.wrap?gA+CA+gA:CA};return aA.options={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1},aA.version="3.0.0",cssesc_1=aA,cssesc_1}requireCssesc();function isBlankChild(iA){return typeof iA=="string"&&iA.trim()===""}function makeWrapperElement(iA,eA,AA){return{type:"element",name:eA,attributes:{},children:AA,data:{id:iA}}}function materializeGroups(iA,eA,AA){const tA=[];for(const nA of iA){if(nA.kind==="child"){nA.value!==null&&tA.push(nA.value);continue}if(nA.asList){const aA=nA.items.map(gA=>isBlankGroup(gA,isBlankChild)),oA=aA.indexOf(!1),sA=aA.lastIndexOf(!1),lA=nA.items.slice(oA,sA+1).filter((gA,cA)=>!aA[oA+cA]);eA||tA.push(...materializeGroups(nA.items.slice(0,oA),!1,AA)),AA.push(makeWrapperElement(nA.range.compositeIdx,"asList",materializeGroups(lA,!0,AA))),tA.push({id:nA.range.compositeIdx,annotation:"original"}),eA||tA.push(...materializeGroups(nA.items.slice(sA+1),!1,AA));continue}const rA=materializeGroups(nA.items,!1,AA);eA&&rA.length>1?(AA.push(makeWrapperElement(nA.range.compositeIdx,"_fragment",rA)),tA.push({id:nA.range.compositeIdx,annotation:"original"})):tA.push(...rA)}return tA}function applyCompositeListWrapping(iA,eA){const AA=groupCompositeRanges({children:iA,ranges:eA,isAbsent:rA=>rA===null,isBlank:isBlankChild,trimEnd:rA=>typeof rA=="string"?rA.trimEnd():rA}),tA=[];return{children:materializeGroups(AA,!1,tA),wrapperElements:tA}}function propRename(iA,eA){for(const[AA,tA]of Object.entries(eA))iA.hasOwnProperty(AA)&&(iA[tA]=iA[AA],delete iA[AA])}function elementRename(iA,eA){iA.name=eA}function booleanInputJsToRust(iA){iA.immediateValue=iA.value}function pointJsToRust(iA){const eA=iA.numericalXs;iA.x={math_object:eA[0].toString()},eA.length>=2&&(iA.y={math_object:eA[1].toString()}),eA.length>=3&&(iA.z={math_object:eA[2].toString()}),iA.coordsLatex=iA.latex}function refJsToRust(iA,eA){iA.referent=eA[iA.targetRendererId]}function sectionJsToRust(iA,eA){iA.divisionType=eA.name,iA.divisionDepth=iA.level;const AA=iA.titleChildName!=null?Number(iA.titleChildName):void 0,tA=AA!==void 0&&Number.isInteger(AA);if(iA.xrefLabel={label:(tA?iA.titlePrefix:iA.title)??"",global_ident:iA.sectionNumber??"",local_ident:iA.sectionNumber??"",preferred_form:"Global"},iA.codeNumber="",tA){iA.title=AA;const nA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);nA!==-1&&eA.children.splice(nA,1)}else iA.title=null}function tableJsToRust(iA,eA){iA.xrefLabel={label:iA.tableName??"",global_ident:iA.tableEnumeration??"",local_ident:iA.tableEnumeration??"",preferred_form:"Global"},iA.codeNumber=iA.tableEnumeration??"",iA.titlePrefix=iA.suppressTableNameInTitle?"":iA.tableNamePrefix??"",iA.divisionType="table",iA.divisionDepth=3;const AA=iA.titleChildName!=null?Number(iA.titleChildName):void 0;if(AA!==void 0&&Number.isInteger(AA)){iA.title=AA;const nA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);nA!==-1&&eA.children.splice(nA,1)}else iA.title=null;delete iA.tableEnumeration,delete iA.titleChildName,delete iA.tableName,delete iA.tableNamePrefix}function textJsToRust(iA){iA.value=iA.text}function childInstructionToContent(iA,eA){return typeof iA=="string"?iA:(eA[iA.id]=iA.componentIdx,{id:iA.componentIdx,annotation:"original"})}function applyElementJsToRustFixups(iA,eA){if(!(iA?.type!=="element"||!iA.data.props))switch(iA.name){case"angle":propRename(iA.data.props,{latexForRenderer:"latex"});break;case"cell":propRename(iA.data.props,{inHeader:"header"});break;case"booleanInput":booleanInputJsToRust(iA.data.props);break;case"text":textJsToRust(iA.data.props);break;case"aside":case"article":case"section":sectionJsToRust(iA.data.props,iA),iA.name==="section"&&elementRename(iA,"division");break;case"table":tableJsToRust(iA.data.props,iA);break;case"point":pointJsToRust(iA.data.props);break;case"ref":refJsToRust(iA.data.props,eA);break;case"coords":elementRename(iA,"math");break}}function flatDastFromJS(iA,eA){const AA=eA[0].rendererStatesToUpdate,tA=[],nA={[iA.id]:iA.componentIdx};tA[iA.componentIdx]={type:"element",name:iA.componentType,attributes:{},children:[],data:{id:iA.componentIdx,action_names:Object.keys(iA.actions)}};for(const aA of AA){let oA=tA[aA.componentIdx];if(oA||(oA=tA[aA.componentIdx]={type:"element",name:"",attributes:{},children:[],data:{id:aA.componentIdx}}),oA.type==="element"&&(oA.data.props=aA.stateValues,aA.childrenInstructions)){const sA=[];for(const cA of aA.childrenInstructions){if(cA==null){sA.push(null);continue}if(sA.push(childInstructionToContent(cA,nA)),typeof cA=="string")continue;const IA=tA[cA.componentIdx];IA?IA.type==="element"&&(IA.name=cA.componentType,IA.data.id=cA.componentIdx,IA.data.action_names=Object.keys(cA.actions)):tA[cA.componentIdx]={type:"element",name:cA.componentType,attributes:{},children:[],data:{id:cA.componentIdx,action_names:Object.keys(cA.actions)}}}const{children:lA,wrapperElements:gA}=applyCompositeListWrapping(sA,aA.stateValues?._compositeReplacementActiveRange);oA.children=lA;for(const cA of gA)tA[cA.data.id]=cA}}for(const aA of tA)applyElementJsToRustFixups(aA,nA);return{type:"root",children:[{id:iA.componentIdx,annotation:"original"}],elements:tA,warnings:[]}}function collectInstructionMaps(iA,eA={},AA={}){for(const tA of iA)for(const nA of tA.rendererStatesToUpdate)for(const rA of nA.childrenInstructions??[])rA!=null&&typeof rA!="string"&&(eA[rA.componentIdx]=rA.componentType,AA[rA.id]=rA.componentIdx);return{componentIdxToName:eA,doenetIdToComponentIdx:AA}}function seedInstructionMaps(iA,eA){const AA={[iA.componentIdx]:iA.componentType},tA={[iA.id]:iA.componentIdx};return collectInstructionMaps(eA,AA,tA),{componentIdxToName:AA,doenetIdToComponentIdx:tA}}function flatDastUpdateFromJS(iA,eA,AA={}){const tA={};function nA(rA,aA){const oA=tA[rA];oA?(oA.changedState={...oA.changedState,...aA.changedState},aA.newChildren&&(oA.newChildren=aA.newChildren),aA.newFlatDastElement&&(oA.newFlatDastElement=aA.newFlatDastElement)):tA[rA]=aA}for(const rA of iA)for(const aA of rA.rendererStatesToUpdate){const{componentIdx:oA,stateValues:sA,childrenInstructions:lA}=aA,gA=[];if(lA)for(const dA of lA){if(dA==null){gA.push(null);continue}gA.push(childInstructionToContent(dA,AA))}const{children:cA,wrapperElements:IA}=applyCompositeListWrapping(gA,sA?._compositeReplacementActiveRange),CA={type:"element",name:eA[oA]??"",children:cA,data:{id:oA,props:{...sA}}};applyElementJsToRustFixups(CA,AA);const uA={changedState:CA.data.props};lA&&(uA.newChildren=CA.children),nA(oA,uA);for(const dA of IA)nA(dA.data.id,{newFlatDastElement:dA})}return tA}async function resolvePathImmediatelyToNodeIdx(iA,eA,AA,tA=0){if(!AA.core)return-1;const nA=iA.match(/^([\w-]+)((\[\d+\])*)/);if(!nA)throw Error(`Invalid name to resolve: ${iA}`);const rA=[{type:"flatPathPart",name:nA[1],index:extractIndex(nA[2])}];let aA=iA.slice(nA[0].length);for(;aA.length>0;){const oA=aA.match(/^\.([\w-]+)((\[\d+\])*)/);if(!oA)throw Error(`Invalid name to resolve: ${iA}`);rA.push({type:"flatPathPart",name:oA[1],index:extractIndex(oA[2])}),aA=aA.slice(oA[0].length)}try{let oA=eA.resolve_path({path:rA},tA,!1);for(;oA.unresolvedPath!==null;){if(oA.unresolvedPath[0].name!=="")return-1;const sA=AA.core._components[oA.nodeIdx];if(!AA.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType,includeNonStandard:!0})||sA.isExpanded)return-1;const gA=oA.unresolvedPath[0].index;if(gA.length===0)throw Error("Something went wrong as we have a ref resolution without a name or an index");if(typeof gA[0].value[0]!="string")throw Error("Not implemented: we have not implemented `resolvePathImmediatelyToNodeIdx` for paths that contain references to nodes.");await sA.stateValues.readyToExpandWhenResolved,await expandCompositeComponent({core:AA.core,component:sA}),oA=eA.resolve_path({path:rA},tA,!1)}return oA.nodeIdx}catch(oA){return console.error(oA),-1}}function extractIndex(iA){const eA=[];for(const AA of iA.matchAll(/\[(\d+)\]/g))eA.push({value:[AA[1]]});return eA}const JS_CORE_ACTION_NAME_OVERRIDES={point:{move:"movePoint"},graph:{changeBoundingBox:"changeAxisLimits"}};function translateJsCoreActionName(iA,eA){return iA==null?eA:JS_CORE_ACTION_NAME_OVERRIDES[iA]?.[eA]??eA}const WASM_FILE_NAME="lib_doenetml_worker_bg.wasm";function injectedGlobal(iA){const eA=globalThis[iA];return typeof eA=="string"?eA:void 0}function decodeWasmDataUrl(iA){try{const eA=iA.split(",")[1],AA=atob(eA),tA=new Uint8Array(AA.length);for(let nA=0;nA<AA.length;nA++)tA[nA]=AA.charCodeAt(nA);return tA.buffer}catch(eA){return console.warn("Error while decoding the WASM data URL:",eA),null}}function wasmUrlCandidates(){const iA=[];function eA(nA){iA.includes(nA)||iA.push(nA)}const AA=injectedGlobal("__doenetWorkerWasmUrl");AA!==void 0&&eA(AA);const tA=[injectedGlobal("__doenetWorkerScriptUrl"),typeof location<"u"?location.href:void 0];for(const nA of tA)if(nA!==void 0)try{eA(new URL(WASM_FILE_NAME,nA).href)}catch{}return eA(`https://cdn.jsdelivr.net/npm/@doenet/standalone@0.7.27-dev.651/doenetml-worker/${WASM_FILE_NAME}`),iA}async function resolveWasmInput(){const iA=injectedGlobal("__doenetWorkerWasmUrl");if(iA!==void 0&&/^data:.*;base64,/.test(iA)){const AA=decodeWasmDataUrl(iA);if(AA)return AA}let eA;for(const AA of wasmUrlCandidates())if(!AA.startsWith("data:"))try{const tA=await fetch(AA);if(!tA.ok)throw Error(`HTTP ${tA.status} fetching ${AA}`);const nA=tA.headers.get("Content-Type")??"";if(/^text\/html\b/i.test(nA))throw Error(`Fetching ${AA} returned ${nA}, an HTML page rather than WebAssembly`);return tA}catch(tA){eA=tA}throw eA??Error("No URL to load the core WASM from")}if(typeof globalThis<"u"&&!globalThis.document){const iA=new URL(typeof location<"u"?location.href:"http://localhost"),eA=iA.protocol+"//"+iA.host+iA.pathname;globalThis.document={URL:eA,baseURI:eA}}let wasmInitPromise=null;function ensureWasmInitialized(){return wasmInitPromise||(wasmInitPromise=(async()=>{const iA=await resolveWasmInput();return await __wbg_init({module_or_path:iA})})().catch(iA=>{throw wasmInitPromise=null,iA})),wasmInitPromise}const RELEASED_INITIALIZATION_DATA_MESSAGE="Cannot initialize from the document DAST: it was released when the previous initialization completed. Call setSource again before re-initializing.",DOCUMENT_BUILD_ERROR_NAME="DoenetDocumentBuildError";function readPanicMessage(){try{return take_last_panic_message()??void 0}catch(iA){console.error(iA);return}}function discardStalePanicMessage(){readPanicMessage()}function throwAsDocumentBuildError(iA,eA){const AA=iA instanceof Error?iA:new Error(String(iA??"unknown error"));throw AA.name=DOCUMENT_BUILD_ERROR_NAME,eA&&(AA.message=eA),AA}class CoreWorker{constructor(){this.wasm_initialized=!1,this.javascript_initialized=!1,this.source_set=!1,this._initializationDataReleased=!1,this.flags_set=!1,this.core_type="rust",this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!1,this._componentIdxToName={},this._doenetIdToComponentIdx={},this._javascriptInitialRenderDone=!1,this.isProcessingPromise=Promise.resolve(),this._hostedCores=new Map,this._nextHostedCoreId=1,this._isHostedCore=!1}async createCore(eA){const AA=new CoreWorker;AA._isHostedCore=!0,expose(AA,eA);const tA=this._nextHostedCoreId++;return this._hostedCores.set(tA,{core:AA,port:eA}),tA}async destroyCore(eA){const AA=this._hostedCores.get(eA);if(AA){this._hostedCores.delete(eA);try{await AA.core.terminate()}catch(tA){console.error("Error terminating hosted core",tA)}finally{AA.port.close()}}}setCoreType(eA){this.core_type=eA}async setSource(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setSource(eA.source)),this.doenetCore.set_source(eA.dast,eA.source),this.source_set=!0,this._initializationDataReleased=!1}catch(rA){throw console.error("Error when setting source",rA),rA}finally{nA()}}async setFlags(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setFlags(eA.flags)),this.doenetCore.set_flags(JSON.stringify(eA.flags)),this.flags_set=!0}finally{nA()}}async setLocaleData(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setLocaleData(eA.localeData))}finally{nA()}}async initializeJavascriptCore({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA}){const rA=this.isProcessingPromise;let{promise:aA,resolve:oA}=promiseWithResolver();this.isProcessingPromise=aA,await rA;let sA=!1;try{let lA=function(mA){return dA.update_root_names(mA)},gA=function(mA,QA,BA){return dA.resolve_path(mA,QA,BA)},cA=function(mA,QA){dA.add_nodes_to_resolver(mA,QA)},IA=function(mA,QA){dA.replace_index_resolutions_in_resolver(mA,QA)},CA=function(mA){dA.delete_nodes_from_resolver(mA)};if(!this.source_set||!this.flags_set||!this.javascriptCore||!this.doenetCore)throw Error("Cannot initialize javascript core before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);sA=!0,discardStalePanicMessage();let uA=this.doenetCore.return_normalized_dast_root();const dA=this.doenetCore,pA=await this.javascriptCore.initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:nA,normalizedRoot:uA,addNodesToResolver:cA,replaceIndexResolutionsInResolver:IA,deleteNodesFromResolver:CA,resolvePath:gA,updateRootNames:lA});return this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0,pA}catch(lA){if(console.error(lA),!sA)throw lA;throwAsDocumentBuildError(lA,readPanicMessage())}finally{oA()}}async generateJavascriptDast(eA,AA,tA,nA,rA,aA,oA,sA){const lA=this.isProcessingPromise;let{promise:gA,resolve:cA}=promiseWithResolver();if(this.isProcessingPromise=gA,await lA,!this.javascript_initialized||!this.javascriptCore)throw Error("Cannot return javascript dast before initializing javascript core");try{discardStalePanicMessage();const IA=await this.javascriptCore?.createCoreGenerateDast(eA,AA,tA,nA,rA,aA,oA,sA);if(IA?.success===!1){const CA=readPanicMessage();CA!==void 0&&throwAsDocumentBuildError(new Error(IA.errMsg??""),CA)}return IA}catch(IA){console.error(IA),throwAsDocumentBuildError(IA,readPanicMessage())}finally{cA()}}async returnDast({variantIndex:eA=1}={}){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");try{return this.core_type==="javascript"?await this.returnFlatDastFromJS(eA):this.doenetCore.return_dast()}catch(rA){throw console.error(rA),rA}finally{nA()}}async returnNormalizedDastRoot(){if(!this.source_set||!this.doenetCore)throw Error("Cannot return normalized dast root before setting source");if(this.core_type==="javascript")return{nodes:[]};if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);return this.doenetCore.return_normalized_dast_root()}async returnFlatDastFromJS(eA){if(!this.javascriptCore||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);let AA=this.doenetCore.return_normalized_dast_root();const tA=this.doenetCore;function nA(fA){return tA.update_root_names(fA)}function rA(fA,NA,yA){return tA.resolve_path(fA,NA,yA)}function aA(fA,NA){tA.add_nodes_to_resolver(fA,NA)}function oA(fA,NA){tA.replace_index_resolutions_in_resolver(fA,NA)}function sA(fA){tA.delete_nodes_from_resolver(fA)}await this.javascriptCore.initializeWorker({activityId:"a",docId:"a",requestedVariantIndex:eA,attemptNumber:1,normalizedRoot:AA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:rA,updateRootNames:nA}),this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0;const lA={coreId:"a",cid:null,initializeCounters:{}};let gA=null;this._javascriptUpdateBuffer=[];const cA=fA=>{fA.init?gA=fA.updateInstructions:this._capturingJavascriptUpdates&&fA.updateInstructions&&this._javascriptUpdateBuffer.push(...fA.updateInstructions)},IA=fA=>{},CA=fA=>{},uA=fA=>{},dA=fA=>{},pA=fA=>{},mA=fA=>Promise.resolve({allowView:!0}),QA=await this.javascriptCore.createCoreGenerateDast(lA,cA,IA,CA,uA,dA,pA,mA);if(!QA.success)throw console.error(QA.errMsg),Error(QA.errMsg);if(gA===null)throw Error("Need to address case where do not get updateRenderersCallback before dast");const BA=QA.coreInfo.documentToRender,{componentIdxToName:hA,doenetIdToComponentIdx:DA}=seedInstructionMaps(BA,gA);return this._componentIdxToName=hA,this._doenetIdToComponentIdx=DA,this._javascriptInitialRenderDone=!0,flatDastFromJS(BA,gA)}async dispatchActionJavascript(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");try{return await this.javascriptCore.requestAction(eA)}catch(rA){throw console.error(rA),rA}finally{nA()}}async dispatchActionJavascriptFlat(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{if(!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");if(!this._javascriptInitialRenderDone)throw Error("Cannot dispatch a flat action before the initial render (returnDast) has run");this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!0;const rA=eA.componentIdx!=null?this._componentIdxToName[eA.componentIdx]:void 0,aA=translateJsCoreActionName(rA,eA.actionName),oA=await this.javascriptCore.requestAction({...eA,actionName:aA});if(oA&&typeof oA=="object"&&"success"in oA&&oA.success===!1){const lA=aA===eA.actionName?`"${eA.actionName}"`:`"${eA.actionName}" (translated to "${aA}")`;throw Error(`Action ${lA} failed: ${oA.errMsg??"unknown error"}`)}this._capturingJavascriptUpdates=!1;const sA=this._javascriptUpdateBuffer;return this._javascriptUpdateBuffer=[],collectInstructionMaps(sA,this._componentIdxToName,this._doenetIdToComponentIdx),flatDastUpdateFromJS(sA,this._componentIdxToName,this._doenetIdToComponentIdx)}catch(rA){throw console.error(rA),rA}finally{this._capturingJavascriptUpdates=!1,nA()}}async resolvePath(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot resolve a path before setting source and flags");try{return this.doenetCore.resolve_path(eA.path,eA.origin,eA.skipParentSearch)}finally{nA()}}async dispatchAction(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:nA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot handle action before setting source and flags");try{return this.doenetCore.dispatch_action(eA)}catch(rA){throw console.error(rA),rA}finally{nA()}}async resolvePathJavascript(eA,AA=0){const tA=this.isProcessingPromise;let{promise:nA,resolve:rA}=promiseWithResolver();if(this.isProcessingPromise=nA,await tA,!this.source_set||!this.flags_set||!this.doenetCore||!this.javascriptCore)throw Error("Cannot resolve path before setting source and flags");try{return await resolvePathImmediatelyToNodeIdx(eA,this.doenetCore,this.javascriptCore,AA)}catch(aA){throw console.error(aA),aA}finally{rA()}}async terminate(){const eA=this.isProcessingPromise;let{promise:AA,resolve:tA}=promiseWithResolver();if(this.isProcessingPromise=AA,await eA,this.doenetCore?.free(),this.doenetCore=void 0,this.source_set=!1,this.flags_set=!1,this.javascriptCore)try{await this.javascriptCore.terminate()}catch(nA){throw console.error(nA),nA}finally{tA()}else tA();this._isHostedCore||close()}async returnAllStateVariables(eA=!1){return this.javascriptCore?this.javascriptCore.returnAllStateVariables(eA):{}}handleVisibilityChange(eA){this.javascriptCore&&this.javascriptCore.handleVisibilityChange(eA)}async submitAllAnswers(){this.javascriptCore&&this.javascriptCore.submitAllAnswers()}async saveImmediately(){this.javascriptCore&&this.javascriptCore.saveImmediately()}async flushState(){return this.javascriptCore?await this.javascriptCore.flushState():!1}async _getTests(){return this.doenetCore?._get_tests()}async _runTest(eA){return this.doenetCore?._run_test(eA)}}function promiseWithResolver(){let iA,eA;return{promise:new Promise((tA,nA)=>{iA=tA,eA=nA}),resolve:iA,reject:eA}}expose(new CoreWorker);function _mergeNamespaces$1(iA,eA){for(var AA=0;AA<eA.length;AA++){const tA=eA[AA];if(typeof tA!="string"&&!Array.isArray(tA)){for(const nA in tA)if(nA!=="default"&&!(nA in iA)){const rA=Object.getOwnPropertyDescriptor(tA,nA);rA&&Object.defineProperty(iA,nA,rA.get?rA:{enumerable:!0,get:()=>tA[nA]})}}}return Object.freeze(Object.defineProperty(iA,Symbol.toStringTag,{value:"Module"}))}var sha256$3={exports:{}},convertHex$1={exports:{}},convertHex=convertHex$1.exports,hasRequiredConvertHex;function requireConvertHex(){return hasRequiredConvertHex||(hasRequiredConvertHex=1,(function(iA){(function(eA){var AA={bytesToHex:function(rA){return tA(rA)},hexToBytes:function(rA){if(rA.length%2===1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return rA.indexOf("0x")===0&&(rA=rA.slice(2)),rA.match(/../g).map(function(aA){return parseInt(aA,16)})}};function tA(rA){return rA.map(function(aA){return nA(aA.toString(16),2)}).join("")}function nA(rA,aA){return rA.length>aA?rA:Array(aA-rA.length+1).join("0")+rA}iA.exports?iA.exports=AA:eA.convertHex=AA})(convertHex)})(convertHex$1)),convertHex$1.exports}var convertString$1={exports:{}},convertString=convertString$1.exports,hasRequiredConvertString;function requireConvertString(){return hasRequiredConvertString||(hasRequiredConvertString=1,(function(iA){(function(eA){var AA={bytesToString:function(tA){return tA.map(function(nA){return String.fromCharCode(nA)}).join("")},stringToBytes:function(tA){return tA.split("").map(function(nA){return nA.charCodeAt(0)})}};AA.UTF8={bytesToString:function(tA){return decodeURIComponent(escape(AA.bytesToString(tA)))},stringToBytes:function(tA){return AA.stringToBytes(unescape(encodeURIComponent(tA)))}},iA.exports?iA.exports=AA:eA.convertString=AA})(convertString)})(convertString$1)),convertString$1.exports}var sha256$2=sha256$3.exports,hasRequiredSha256;function requireSha256(){return hasRequiredSha256||(hasRequiredSha256=1,(function(iA){(function(eA){var AA={};iA.exports?(AA.bytesToHex=requireConvertHex().bytesToHex,AA.convertString=requireConvertString(),iA.exports=sA):(AA.bytesToHex=eA.convertHex.bytesToHex,AA.convertString=eA.convertString,eA.sha256=sA);var tA=[];(function(){function lA(CA){for(var uA=Math.sqrt(CA),dA=2;dA<=uA;dA++)if(!(CA%dA))return!1;return!0}function gA(CA){return(CA-(CA|0))*4294967296|0}for(var cA=2,IA=0;IA<64;)lA(cA)&&(tA[IA]=gA(Math.pow(cA,.3333333333333333)),IA++),cA++})();var nA=function(lA){for(var gA=[],cA=0,IA=0;cA<lA.length;cA++,IA+=8)gA[IA>>>5]|=lA[cA]<<24-IA%32;return gA},rA=function(lA){for(var gA=[],cA=0;cA<lA.length*32;cA+=8)gA.push(lA[cA>>>5]>>>24-cA%32&255);return gA},aA=[],oA=function(lA,gA,cA){for(var IA=lA[0],CA=lA[1],uA=lA[2],dA=lA[3],pA=lA[4],mA=lA[5],QA=lA[6],BA=lA[7],hA=0;hA<64;hA++){if(hA<16)aA[hA]=gA[cA+hA]|0;else{var DA=aA[hA-15],EA=(DA<<25|DA>>>7)^(DA<<14|DA>>>18)^DA>>>3,fA=aA[hA-2],NA=(fA<<15|fA>>>17)^(fA<<13|fA>>>19)^fA>>>10;aA[hA]=EA+aA[hA-7]+NA+aA[hA-16]}var yA=pA&mA^~pA&QA,bA=IA&CA^IA&uA^CA&uA,wA=(IA<<30|IA>>>2)^(IA<<19|IA>>>13)^(IA<<10|IA>>>22),MA=(pA<<26|pA>>>6)^(pA<<21|pA>>>11)^(pA<<7|pA>>>25),vA=BA+MA+yA+tA[hA]+aA[hA],OA=wA+bA;BA=QA,QA=mA,mA=pA,pA=dA+vA|0,dA=uA,uA=CA,CA=IA,IA=vA+OA|0}lA[0]=lA[0]+IA|0,lA[1]=lA[1]+CA|0,lA[2]=lA[2]+uA|0,lA[3]=lA[3]+dA|0,lA[4]=lA[4]+pA|0,lA[5]=lA[5]+mA|0,lA[6]=lA[6]+QA|0,lA[7]=lA[7]+BA|0};function sA(lA,gA){lA.constructor===String&&(lA=AA.convertString.UTF8.stringToBytes(lA));var cA=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],IA=nA(lA),CA=lA.length*8;IA[CA>>5]|=128<<24-CA%32,IA[(CA+64>>9<<4)+15]=CA;for(var uA=0;uA<IA.length;uA+=16)oA(cA,IA,uA);var dA=rA(cA);return gA&&gA.asBytes?dA:gA&&gA.asString?AA.convertString.bytesToString(dA):AA.bytesToHex(dA)}sA.x2=function(lA,gA){return sA(sA(lA,{asBytes:!0}),gA)}})(sha256$2)})(sha256$3)),sha256$3.exports}var sha256Exports=requireSha256();const sha256=getDefaultExportFromCjs$1(sha256Exports),sha256$1=_mergeNamespaces$1({__proto__:null,default:sha256},[sha256Exports]),sha2568sXzDnE0D37pHzmU=Object.freeze(Object.defineProperty({__proto__:null,s:sha256$1},Symbol.toStringTag,{value:"Module"}));return exports.CoreWorker=CoreWorker,exports.DOCUMENT_BUILD_ERROR_NAME=DOCUMENT_BUILD_ERROR_NAME,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports})({});
2785
2785
  //# sourceMappingURL=index.js.map