@khanacademy/perseus 12.4.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -81,6 +81,7 @@ const customKeyTranslator = _extends({}, keyTranslator, {
81
81
  class MathInput extends React.Component {
82
82
  constructor(...args) {
83
83
  super(...args);
84
+ // @ts-expect-error - TS2564 - Property 'mouseDown' has no initializer and is not definitely assigned in the constructor.
84
85
  this.mouseDown = void 0;
85
86
  this.__mathFieldWrapperRef = null;
86
87
  this.__mathField = null;
@@ -94,7 +95,7 @@ class MathInput extends React.Component {
94
95
  const inputModifier = customKeyTranslator[value];
95
96
  if (inputModifier) {
96
97
  inputModifier(input, value);
97
- input == null ? void 0 : input.focus();
98
+ input == null || input.focus();
98
99
  return;
99
100
  }
100
101
 
@@ -105,11 +106,11 @@ class MathInput extends React.Component {
105
106
  if (_(value).isFunction()) {
106
107
  value(input);
107
108
  } else if (value[0] === "\\") {
108
- input == null ? void 0 : input.cmd(value).focus();
109
+ input == null || input.cmd(value).focus();
109
110
  } else {
110
- input == null ? void 0 : input.write(value).focus();
111
+ input == null || input.write(value).focus();
111
112
  }
112
- input == null ? void 0 : input.focus();
113
+ input == null || input.focus();
113
114
  };
114
115
  this.mathField = () => {
115
116
  if (!this.__mathField && this.__mathFieldWrapperRef) {
@@ -179,11 +180,13 @@ class MathInput extends React.Component {
179
180
  };
180
181
  this.focus = () => {
181
182
  var _this$mathField;
182
- (_this$mathField = this.mathField()) == null ? void 0 : _this$mathField.focus();
183
+ (_this$mathField = this.mathField()) == null || _this$mathField.focus();
183
184
  this.setState({
184
185
  focused: true
185
186
  });
186
187
  };
188
+ // removing mathfield focus here makes the cursor vanished when the
189
+ // input is still focused
187
190
  this.blur = () => this.setState({
188
191
  focused: false
189
192
  });
@@ -213,7 +216,7 @@ class MathInput extends React.Component {
213
216
  var _this$mathField2;
214
217
  // Ideally, we would be able to pass an initial value directly into
215
218
  // the constructor
216
- (_this$mathField2 = this.mathField()) == null ? void 0 : _this$mathField2.latex(this.props.value);
219
+ (_this$mathField2 = this.mathField()) == null || _this$mathField2.latex(this.props.value);
217
220
  }
218
221
  openKeypad() {
219
222
  if (this.props.buttonsVisible === "never") {
@@ -433,7 +436,6 @@ var dependencies = /*#__PURE__*/Object.freeze({
433
436
  // TODO(LP-11481): Change the primary API we use for logging in Perseus to use
434
437
  // getDependencies() internally... simplify usage to just using a "singleton"
435
438
  // which get's the injected logger.
436
-
437
439
  /**
438
440
  * @typedef {Object} Errors utility for referencing the Perseus error taxonomy.
439
441
  */
@@ -476,6 +478,10 @@ const Errors = Object.freeze({
476
478
  * @type {ErrorKind} The kind of error being reported
477
479
  */
478
480
 
481
+ /**
482
+ * Provides logging infrastructure for Perseus
483
+ */
484
+
479
485
  const Log = {
480
486
  // Logs a message
481
487
  log: (message, extra) => {
@@ -1203,6 +1209,10 @@ const KhanMath = {
1203
1209
 
1204
1210
  /* eslint-disable no-useless-escape */
1205
1211
  const MAXERROR_EPSILON = Math.pow(2, -42);
1212
+
1213
+ // TOOD(kevinb): Figure out how this relates to KEScore in
1214
+ // perseus-all-package/types.js and see if there's a way to
1215
+ // unify these types.
1206
1216
  const errors = {
1207
1217
  APPROXIMATED_PI_ERROR: i18n._("Your answer is close, but you may " + "have approximated pi. Enter your " + "answer as a multiple of pi, like " + "<code>12\\ \\text{pi}</code> or " + "<code>2/3\\ \\text{pi}</code>"),
1208
1218
  EXTRA_SYMBOLS_ERROR: i18n._("We could not understand your " + "answer. Please check your answer for extra " + "text or symbols."),
@@ -1934,6 +1944,10 @@ class Expression extends React.Component {
1934
1944
  // this.isMounted() but is still considered an anti-pattern.
1935
1945
  this._isMounted = true;
1936
1946
  };
1947
+ // Whenever the input value changes, attempt to parse it.
1948
+ //
1949
+ // Clear any errors if this parse succeeds, show an error within a second
1950
+ // if it fails.
1937
1951
  this.componentDidUpdate = prevProps => {
1938
1952
  if (!_.isEqual(this.props.value, prevProps.value) || !_.isEqual(this.props.functions, prevProps.functions)) {
1939
1953
  this.setState({
@@ -1974,7 +1988,7 @@ class Expression extends React.Component {
1974
1988
  // otherwise, we may just be checking validity after changes.
1975
1989
  if (scoring && score.type !== "invalid") {
1976
1990
  var _this$props$analytics;
1977
- (_this$props$analytics = this.props.analytics) == null ? void 0 : _this$props$analytics.onAnalyticsEvent({
1991
+ (_this$props$analytics = this.props.analytics) == null || _this$props$analytics.onAnalyticsEvent({
1978
1992
  type: "perseus:expression-evaluated",
1979
1993
  payload: {
1980
1994
  result: score.earned === score.total ? "correct" : "incorrect",
@@ -2005,7 +2019,7 @@ class Expression extends React.Component {
2005
2019
  };
2006
2020
  this._handleFocus = () => {
2007
2021
  var _this$props$analytics2;
2008
- (_this$props$analytics2 = this.props.analytics) == null ? void 0 : _this$props$analytics2.onAnalyticsEvent({
2022
+ (_this$props$analytics2 = this.props.analytics) == null || _this$props$analytics2.onAnalyticsEvent({
2009
2023
  type: "perseus:expression-focused",
2010
2024
  payload: null
2011
2025
  });
@@ -2041,6 +2055,7 @@ class Expression extends React.Component {
2041
2055
  /* c8 ignore next */
2042
2056
  return [[]];
2043
2057
  };
2058
+ // TODO(Nicole): I believe this is going away and won't be needed anymore
2044
2059
  this.getGrammarTypeForPath = inputPath => {
2045
2060
  /* c8 ignore next */
2046
2061
  return "expression";
@@ -2228,7 +2243,7 @@ class Expression extends React.Component {
2228
2243
  // this.props.keypadElement should always be set
2229
2244
  // when apiOptions.customKeypad is set, but how
2230
2245
  // to convince TypeScript of this?
2231
- (_this$props$keypadEle = this.props.keypadElement) == null ? void 0 : _this$props$keypadEle.configure(this.props.keypadConfiguration, () => {
2246
+ (_this$props$keypadEle = this.props.keypadElement) == null || _this$props$keypadEle.configure(this.props.keypadConfiguration, () => {
2232
2247
  if (this._isMounted) {
2233
2248
  this._handleFocus();
2234
2249
  }
@@ -2472,6 +2487,9 @@ async function getImageSizeModern(url) {
2472
2487
  }
2473
2488
 
2474
2489
  /* eslint-disable @babel/no-invalid-this, getter-return, one-var */
2490
+
2491
+ // TODO: dedupe this with Coord in interactive2/types.js
2492
+
2475
2493
  let supportsPassive = false;
2476
2494
  const nestedMap$2 = function nestedMap(children, func, context) {
2477
2495
  if (Array.isArray(children)) {
@@ -3152,12 +3170,12 @@ function getImageSize(url, callback) {
3152
3170
  // width in a full-screen article.
3153
3171
  if (img.width === 0 && img.height === 0) {
3154
3172
  var _document$body;
3155
- (_document$body = document.body) == null ? void 0 : _document$body.appendChild(img);
3173
+ (_document$body = document.body) == null || _document$body.appendChild(img);
3156
3174
  // TODO(scottgrant): Remove this use of _.defer.
3157
3175
  _.defer(function () {
3158
3176
  var _document$body2;
3159
3177
  callback(img.clientWidth, img.clientHeight);
3160
- (_document$body2 = document.body) == null ? void 0 : _document$body2.removeChild(img);
3178
+ (_document$body2 = document.body) == null || _document$body2.removeChild(img);
3161
3179
  });
3162
3180
  } else {
3163
3181
  callback(img.width, img.height);
@@ -3561,11 +3579,11 @@ Zoom.prototype._zoomOriginal = function () {
3561
3579
  $(this._targetImage).css("visibility", "hidden");
3562
3580
  this._backdrop = document.createElement("div");
3563
3581
  this._backdrop.className = "zoom-backdrop";
3564
- (_document$body = document.body) == null ? void 0 : _document$body.appendChild(this._backdrop);
3582
+ (_document$body = document.body) == null || _document$body.appendChild(this._backdrop);
3565
3583
  this._overlay = document.createElement("div");
3566
3584
  this._overlay.className = "zoom-overlay";
3567
- (_document$body2 = document.body) == null ? void 0 : _document$body2.appendChild(this._overlay);
3568
- (_this$_overlay = this._overlay) == null ? void 0 : _this$_overlay.appendChild(this.$zoomedImage[0]);
3585
+ (_document$body2 = document.body) == null || _document$body2.appendChild(this._overlay);
3586
+ (_this$_overlay = this._overlay) == null || _this$_overlay.appendChild(this.$zoomedImage[0]);
3569
3587
  this._calculateZoom();
3570
3588
  this._triggerAnimation();
3571
3589
  };
@@ -10593,7 +10611,7 @@ _.extend(GraphUtils.Graphie.prototype, {
10593
10611
  }
10594
10612
  }
10595
10613
  if (!options.allowScratchpad) {
10596
- options.setDrawingAreaAvailable == null ? void 0 : options.setDrawingAreaAvailable(false);
10614
+ options.setDrawingAreaAvailable == null || options.setDrawingAreaAvailable(false);
10597
10615
  }
10598
10616
 
10599
10617
  // Add mouse and visible wrapper layers for DOM-node-wrapped movables
@@ -16061,10 +16079,19 @@ class Graphie extends React.Component {
16061
16079
  constructor(...args) {
16062
16080
  super(...args);
16063
16081
  this.graphieDivRef = /*#__PURE__*/React.createRef();
16082
+ /**
16083
+ * Allow parents of the <Graphie> component to grab a reference to the
16084
+ * underlying graphie object using
16085
+ * `this.refs.graphieComponent.getGraphie()`
16086
+ *
16087
+ * This shouldn't be necessary for 90% of cases, but the power is there.
16088
+ * Use it for good and not evil.
16089
+ */
16064
16090
  this.getGraphie = () => {
16065
16091
  // @ts-expect-error - TS2339 - Property '_graphie' does not exist on type 'Graphie'.
16066
16092
  return this._graphie;
16067
16093
  };
16094
+ // bounds-checked range
16068
16095
  this._range = () => {
16069
16096
  const boundsCheckRange = range => {
16070
16097
  if (range[0] >= range[1]) {
@@ -16139,6 +16166,7 @@ class Graphie extends React.Component {
16139
16166
  // @ts-expect-error - TS2339 - Property '_movables' does not exist on type 'Graphie'.
16140
16167
  this._movables = {};
16141
16168
  };
16169
+ // @ts-expect-error - TS2322 - Type '(children: readonly any[], options: any) => ReactElement<any, string | JSXElementConstructor<any>> | readonly ReactElement<any, string | JSXElementConstructor<any>>[]' is not assignable to type '(children: readonly any[], arg2: any) => ReactElement<any, string | JSXElementConstructor<any>>'.
16142
16170
  this._renderMovables = (children, options) => {
16143
16171
  // Each leaf of `children` is a movable descriptor created by a call to
16144
16172
  // some `GraphieMovable`, such as `MovablePoint`.
@@ -16237,6 +16265,7 @@ class Graphie extends React.Component {
16237
16265
  return newMovables[key];
16238
16266
  });
16239
16267
  };
16268
+ // Sort of like react diffing, but for movables
16240
16269
  this._updateMovables = () => {
16241
16270
  // @ts-expect-error - TS2339 - Property '_graphie' does not exist on type 'Graphie'.
16242
16271
  const graphie = this._graphie;
@@ -16291,16 +16320,6 @@ class Graphie extends React.Component {
16291
16320
  }
16292
16321
  this._updateMovables();
16293
16322
  }
16294
-
16295
- /**
16296
- * Allow parents of the <Graphie> component to grab a reference to the
16297
- * underlying graphie object using
16298
- * `this.refs.graphieComponent.getGraphie()`
16299
- *
16300
- * This shouldn't be necessary for 90% of cases, but the power is there.
16301
- * Use it for good and not evil.
16302
- */
16303
-
16304
16323
  render() {
16305
16324
  return /*#__PURE__*/React.createElement("div", {
16306
16325
  className: "graphie-container"
@@ -17043,10 +17062,14 @@ Tex.defaultProps = {
17043
17062
  class Zoomable extends React.Component {
17044
17063
  constructor(...args) {
17045
17064
  super(...args);
17065
+ // @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
17046
17066
  this._isMounted = void 0;
17067
+ // @ts-expect-error - TS2564 - Property '_observer' has no initializer and is not definitely assigned in the constructor.
17047
17068
  this._observer = void 0;
17069
+ // @ts-expect-error - TS2564 - Property '_measuringInitialized' has no initializer and is not definitely assigned in the constructor.
17048
17070
  this._measuringInitialized = void 0;
17049
17071
  this._originalWidth = void 0;
17072
+ // @ts-expect-error - TS2564 - Property '_node' has no initializer and is not definitely assigned in the constructor.
17050
17073
  this._node = void 0;
17051
17074
  this.state = {
17052
17075
  visible: false,
@@ -17312,9 +17335,11 @@ const DefinitionContext = /*#__PURE__*/React.createContext(defaultContext$1);
17312
17335
  class DefinitionProvider extends React.Component {
17313
17336
  constructor(...args) {
17314
17337
  super(...args);
17338
+ // Context state
17315
17339
  this.state = {
17316
17340
  activeDefinitionId: null
17317
17341
  };
17342
+ // Method to update state
17318
17343
  this.setActiveDefinitionId = activeDefinitionId => {
17319
17344
  this.setState(prevState => ({
17320
17345
  activeDefinitionId
@@ -17353,7 +17378,7 @@ class ErrorBoundary extends React.Component {
17353
17378
  this.setState({
17354
17379
  error: error.toString()
17355
17380
  });
17356
- (_this$props$onError = (_this$props = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props, error, info);
17381
+ (_this$props$onError = (_this$props = this.props).onError) == null || _this$props$onError.call(_this$props, error, info);
17357
17382
  Log.error("Perseus error boundary caught error", Errors.Internal, {
17358
17383
  cause: error,
17359
17384
  loggedMetadata: _extends({
@@ -17391,21 +17416,25 @@ function _noop() {}
17391
17416
  * Wrapper for the trackInteraction apiOption.
17392
17417
  */
17393
17418
  class InteractionTracker {
17394
- // @ts-expect-error - TS2564 - Property '_tracked' has no initializer and is not definitely assigned in the constructor.
17395
-
17396
- // @ts-expect-error - TS2564 - Property 'setting' has no initializer and is not definitely assigned in the constructor.
17397
-
17398
- // @ts-expect-error - TS2564 - Property 'widgetID' has no initializer and is not definitely assigned in the constructor.
17399
-
17400
- // @ts-expect-error - TS2564 - Property 'widgetType' has no initializer and is not definitely assigned in the constructor.
17401
-
17402
17419
  constructor(trackApi, widgetType, widgetID, setting) {
17420
+ // @ts-expect-error - TS2564 - Property '_tracked' has no initializer and is not definitely assigned in the constructor.
17403
17421
  this._tracked = void 0;
17422
+ // @ts-expect-error - TS2564 - Property 'setting' has no initializer and is not definitely assigned in the constructor.
17404
17423
  this.setting = void 0;
17405
17424
  this.track = void 0;
17406
17425
  this.trackApi = void 0;
17426
+ // @ts-expect-error - TS2564 - Property 'widgetID' has no initializer and is not definitely assigned in the constructor.
17407
17427
  this.widgetID = void 0;
17428
+ // @ts-expect-error - TS2564 - Property 'widgetType' has no initializer and is not definitely assigned in the constructor.
17408
17429
  this.widgetType = void 0;
17430
+ /**
17431
+ * Function that actually calls the API to mark the interaction. This is
17432
+ * private. The public version is just `.track` and is bound to this object
17433
+ * for easy use in other context.
17434
+ *
17435
+ * @param extraData Any extra data to track about the event.
17436
+ * @private
17437
+ */
17409
17438
  this._track = extraData => {
17410
17439
  if (this._tracked && !this.setting) {
17411
17440
  return;
@@ -17427,15 +17456,6 @@ class InteractionTracker {
17427
17456
  this.track = this._track;
17428
17457
  }
17429
17458
  }
17430
-
17431
- /**
17432
- * Function that actually calls the API to mark the interaction. This is
17433
- * private. The public version is just `.track` and is bound to this object
17434
- * for easy use in other context.
17435
- *
17436
- * @param extraData Any extra data to track about the event.
17437
- * @private
17438
- */
17439
17459
  }
17440
17460
 
17441
17461
  /**
@@ -17521,6 +17541,10 @@ class Lint extends React.Component {
17521
17541
  this.state = {
17522
17542
  tooltipAbove: true
17523
17543
  };
17544
+ // We can't call setState in componentDidMount without risking a render
17545
+ // thrash, and we can't call getBoundingClientRect in render, so we
17546
+ // borrow a timeout approach from learnstorm-dashboard.jsx and set our
17547
+ // state once the component has mounted and we can get what we need.
17524
17548
  this.getPosition = () => {
17525
17549
  // @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'getBoundingClientRect' does not exist on type 'Element | Text'.
17526
17550
  const rect = ReactDOM__default.findDOMNode(this).getBoundingClientRect();
@@ -17531,6 +17555,8 @@ class Lint extends React.Component {
17531
17555
  tooltipAbove: rect.top > 100
17532
17556
  });
17533
17557
  };
17558
+ // Render the <a> element that holds the indicator icon and the tooltip
17559
+ // We pass different styles for the inline and block cases
17534
17560
  this.renderLink = style => {
17535
17561
  const tooltipAbove = this.state.tooltipAbove;
17536
17562
  let severityStyle;
@@ -17577,12 +17603,6 @@ class Lint extends React.Component {
17577
17603
  // eslint-disable-next-line no-restricted-syntax
17578
17604
  window.clearTimeout(this._positionTimeout);
17579
17605
  }
17580
-
17581
- // We can't call setState in componentDidMount without risking a render
17582
- // thrash, and we can't call getBoundingClientRect in render, so we
17583
- // borrow a timeout approach from learnstorm-dashboard.jsx and set our
17584
- // state once the component has mounted and we can get what we need.
17585
-
17586
17606
  // The main render method surrounds linty content with a block or
17587
17607
  // inline container and the link element that displays the indicator
17588
17608
  // and holds the tooltip.
@@ -18198,12 +18218,26 @@ class QuestionParagraph extends React.Component {
18198
18218
  * anything in non-KA environments.
18199
18219
  */
18200
18220
 
18221
+ // A LintCB is called once the linter has been run.
18222
+
18201
18223
  // msec to wait before we actually call the linter after receiving the
18202
18224
  // last call. The timer is reset if the lint is called during the wait.
18203
18225
  const DEBOUNCE_TIMEOUT = 1000;
18204
18226
  class TranslationLinter {
18205
18227
  constructor() {
18228
+ // To avoid linting when nothing has changed.
18206
18229
  this.previousContent = null;
18230
+ /**
18231
+ * Runs the poentry linter on the given perseus string asynchronously.
18232
+ *
18233
+ * It doesn't do anything unless we're in a KA environment.
18234
+ *
18235
+ * onLintErrorsGenerated is called even if there are no errors. It is not
18236
+ * called if perseusStr is unchanged from the last call.
18237
+ *
18238
+ * Linting is relatively expensive -- so we debounce linting each instance
18239
+ * for some amount of time.
18240
+ */
18207
18241
  this.runLinter = debounce((perseusStr, onLintErrorsGenerated) => {
18208
18242
  // TODO(FEI-5003): Do we still need to check for 'KA'?
18209
18243
  if (typeof KA === "undefined") {
@@ -18867,35 +18901,33 @@ const isIdPathPrefix = function isIdPathPrefix(prefixArray, wholeArray) {
18867
18901
  }
18868
18902
  });
18869
18903
  };
18870
- class Renderer extends React.Component {
18871
- // @ts-expect-error - TS2564 - Property '_foundTextNodes' has no initializer and is not definitely assigned in the constructor.
18872
-
18873
- // @ts-expect-error - TS2564 - Property '_interactionTrackers' has no initializer and is not definitely assigned in the constructor.
18874
-
18875
- // @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
18876
-
18877
- // @ts-expect-error - TS2564 - Property '_isTwoColumn' has no initializer and is not definitely assigned in the constructor.
18878
-
18879
- // The i18n linter.
18880
-
18881
- // @ts-expect-error - TS2564 - Property 'reuseMarkdown' has no initializer and is not definitely assigned in the constructor.
18882
-
18883
- // @ts-expect-error - TS2564 - Property 'translationIndex' has no initializer and is not definitely assigned in the constructor.
18884
-
18885
- // @ts-expect-error - TS2564 - Property 'widgetIds' has no initializer and is not definitely assigned in the constructor.
18886
18904
 
18905
+ // The return type for getUserInput. Widgets have full control of what is
18906
+ // returned so it's not easily typed (some widgets return a scalar (string),
18907
+ // some return a custom-built object, some delegate to
18908
+ // `WidgetJsonifyDeprecated` which returns an object containing widget props
18909
+ // (filtered by deprecated keys)).
18910
+ class Renderer extends React.Component {
18887
18911
  constructor(_props) {
18888
18912
  super(_props);
18889
18913
  this._currentFocus = void 0;
18914
+ // @ts-expect-error - TS2564 - Property '_foundTextNodes' has no initializer and is not definitely assigned in the constructor.
18890
18915
  this._foundTextNodes = void 0;
18916
+ // @ts-expect-error - TS2564 - Property '_interactionTrackers' has no initializer and is not definitely assigned in the constructor.
18891
18917
  this._interactionTrackers = void 0;
18918
+ // @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
18892
18919
  this._isMounted = void 0;
18920
+ // @ts-expect-error - TS2564 - Property '_isTwoColumn' has no initializer and is not definitely assigned in the constructor.
18893
18921
  this._isTwoColumn = void 0;
18922
+ // The i18n linter.
18894
18923
  this._translationLinter = void 0;
18895
18924
  this._widgetContainers = new Map();
18896
18925
  this.lastRenderedMarkdown = void 0;
18926
+ // @ts-expect-error - TS2564 - Property 'reuseMarkdown' has no initializer and is not definitely assigned in the constructor.
18897
18927
  this.reuseMarkdown = void 0;
18928
+ // @ts-expect-error - TS2564 - Property 'translationIndex' has no initializer and is not definitely assigned in the constructor.
18898
18929
  this.translationIndex = void 0;
18930
+ // @ts-expect-error - TS2564 - Property 'widgetIds' has no initializer and is not definitely assigned in the constructor.
18899
18931
  this.widgetIds = void 0;
18900
18932
  this.getApiOptions = () => {
18901
18933
  return _extends({}, ApiOptions.defaults, this.props.apiOptions);
@@ -18907,6 +18939,7 @@ class Renderer extends React.Component {
18907
18939
  widgetProps: this._getAllWidgetsStartProps(allWidgetInfo, props)
18908
18940
  };
18909
18941
  };
18942
+ // @ts-expect-error - TS2322 - Type '(props: Props) => Partial<Record<string, CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ... 35 more ... | VideoWidget>>' is not assignable to type '(props: Props) => { [key: string]: PerseusWidget; }'.
18910
18943
  this._getAllWidgetsInfo = props => {
18911
18944
  // @ts-expect-error - TS2345 - Argument of type '{ [key: string]: PerseusWidget; }' is not assignable to parameter of type 'Partial<Record<string, CategorizerWidget>>'.
18912
18945
  return mapObject$2(props.widgets, (widgetInfo, widgetId) => {
@@ -18929,6 +18962,11 @@ class Renderer extends React.Component {
18929
18962
  return getRendererPropsForWidgetInfo(widgetInfo, props.problemNum);
18930
18963
  });
18931
18964
  };
18965
+ // This is only used in _getWidgetInfo as a fallback if widgetId
18966
+ // doesn't exist in this.state.widgetInfo. It doesn't get run as
18967
+ // part of the happy path.
18968
+ // TODO(LP-10713): Refactor how we handle widgetIds that don't exist
18969
+ // in this.state.widgetInfo.
18932
18970
  this._getDefaultWidgetInfo = widgetId => {
18933
18971
  const widgetIdParts = Util.rTypeFromWidgetId.exec(widgetId);
18934
18972
  if (widgetIdParts == null) {
@@ -19025,6 +19063,15 @@ class Renderer extends React.Component {
19025
19063
  isLastUsedWidget: id === this.state.lastUsedWidgetId
19026
19064
  });
19027
19065
  };
19066
+ /**
19067
+ * Serializes the questions state so it can be recovered.
19068
+ *
19069
+ * The return value of this function can be sent to the
19070
+ * `restoreSerializedState` method to restore this state.
19071
+ *
19072
+ * If an instance of widgetProps is passed in, it generates the serialized
19073
+ * state from that instead of the current widget props.
19074
+ */
19028
19075
  this.getSerializedState = widgetProps => {
19029
19076
  return mapObject$2(widgetProps || this.state.widgetProps, (props, widgetId) => {
19030
19077
  const widget = this.getWidgetInstance(widgetId);
@@ -19089,6 +19136,12 @@ class Renderer extends React.Component {
19089
19136
  setTimeout(fireCallback, 0);
19090
19137
  });
19091
19138
  };
19139
+ /**
19140
+ * Tell each of the radio widgets to show rationales for each of the
19141
+ * currently selected choices inside of them. If the widget is correct, it
19142
+ * shows rationales for all of the choices. This also disables interaction
19143
+ * with the choices that we show rationales for.
19144
+ */
19092
19145
  this.showRationalesForCurrentlySelectedChoices = () => {
19093
19146
  Object.keys(this.props.widgets).forEach(widgetId => {
19094
19147
  const widget = this.getWidgetInstance(widgetId);
@@ -19097,6 +19150,10 @@ class Renderer extends React.Component {
19097
19150
  }
19098
19151
  });
19099
19152
  };
19153
+ /**
19154
+ * Tells each of the radio widgets to deselect any of the incorrect choices
19155
+ * that are currently selected (leaving correct choices still selected).
19156
+ */
19100
19157
  this.deselectIncorrectSelectedChoices = () => {
19101
19158
  // TODO(emily): this has the exact same structure as
19102
19159
  // showRationalesForCurrentlySelectedChoices above. Maybe DRY this up.
@@ -19107,6 +19164,37 @@ class Renderer extends React.Component {
19107
19164
  }
19108
19165
  });
19109
19166
  };
19167
+ /**
19168
+ * Allows inter-widget communication.
19169
+ *
19170
+ * This function yields this Renderer's own internal widgets, and it's used
19171
+ * in two places.
19172
+ *
19173
+ * First, we expose our own internal widgets to each other by giving them
19174
+ * a `findWidgets` function that, in turn, calls this function.
19175
+ *
19176
+ * Second, we expose our own internal widgets to this Renderer's parent,
19177
+ * by allowing it to call this function directly. That way, it can hook us
19178
+ * up to other Renderers on the page, by writing a `findExternalWidgets`
19179
+ * prop that calls each other Renderer's `findInternalWidgets` function.
19180
+ *
19181
+ * Takes a `filterCriterion` on which widgets to return.
19182
+ * `filterCriterion` can be one of:
19183
+ * * A string widget id
19184
+ * * A string widget type
19185
+ * * a function from (id, widgetInfo, widgetComponent) to true or false
19186
+ *
19187
+ * Returns an array of the matching widget components.
19188
+ *
19189
+ * If you need to do logic with more than the components, it is possible
19190
+ * to do such logic inside the filter, rather than on the result array.
19191
+ *
19192
+ * See the passage-ref widget for an example.
19193
+ *
19194
+ * "Remember: abilities are not inherently good or evil, it's how you use
19195
+ * them." ~ Kyle Katarn
19196
+ * Please use this one with caution.
19197
+ */
19110
19198
  this.findInternalWidgets = filterCriterion => {
19111
19199
  let filterFunc;
19112
19200
  // Convenience filters:
@@ -19132,6 +19220,14 @@ class Renderer extends React.Component {
19132
19220
  }).map(this.getWidgetInstance);
19133
19221
  return results;
19134
19222
  };
19223
+ /**
19224
+ * Allows inter-widget communication.
19225
+ *
19226
+ * Includes both widgets internal to this Renderer, and external widgets
19227
+ * exposed by the `findExternalWidgets` prop.
19228
+ *
19229
+ * See `findInteralWidgets` for more information.
19230
+ */
19135
19231
  this.findWidgets = filterCriterion => {
19136
19232
  return [...this.findInternalWidgets(filterCriterion), ...this.props.findExternalWidgets(filterCriterion)];
19137
19233
  };
@@ -19217,6 +19313,9 @@ class Renderer extends React.Component {
19217
19313
  });
19218
19314
  }
19219
19315
  };
19316
+ // wrap top-level elements in a QuestionParagraph, mostly
19317
+ // for appropriate spacing and other css
19318
+ // @ts-expect-error - TS2322 - Type '(ast: any, state: WidgetState) => never[] | JSX.Element' is not assignable to type '(ast: any, state: WidgetState) => ReactElement<any, string | JSXElementConstructor<any>>'.
19220
19319
  this.outputMarkdown = (ast, state) => {
19221
19320
  if (_.isArray(ast)) {
19222
19321
  // This is duplicated from simple-markdown
@@ -19288,6 +19387,7 @@ class Renderer extends React.Component {
19288
19387
  paragraphIndex: state.paragraphIndex
19289
19388
  }, /*#__PURE__*/React.createElement(ErrorBoundary, null, output));
19290
19389
  };
19390
+ // output non-top-level nodes or arrays
19291
19391
  this.outputNested = (ast, state) => {
19292
19392
  if (_.isArray(ast)) {
19293
19393
  // This is duplicated from simple-markdown
@@ -19318,6 +19418,7 @@ class Renderer extends React.Component {
19318
19418
  }
19319
19419
  return this.outputNode(ast, this.outputNested, state);
19320
19420
  };
19421
+ // output individual AST nodes [not arrays]
19321
19422
  this.outputNode = (node, nestedOutput, state) => {
19322
19423
  const apiOptions = this.getApiOptions();
19323
19424
  const imagePlaceholder = apiOptions.imagePlaceholder;
@@ -19551,6 +19652,9 @@ class Renderer extends React.Component {
19551
19652
  // ...as well as right now (non-image, non-TeX or image from cache)
19552
19653
  onRender();
19553
19654
  };
19655
+ // Sets the current focus path
19656
+ // If the new focus path is not a prefix of the old focus path,
19657
+ // we send an onChangeFocus event back to our parent.
19554
19658
  this._setCurrentFocus = path => {
19555
19659
  const apiOptions = this.getApiOptions();
19556
19660
 
@@ -19703,6 +19807,7 @@ class Renderer extends React.Component {
19703
19807
  this.blurPath(this._currentFocus);
19704
19808
  }
19705
19809
  };
19810
+ // Serializes widget state. Seems to be used only by editors though.
19706
19811
  this.serialize = () => {
19707
19812
  const state = {};
19708
19813
  _.each(this.state.widgetInfo, function (info, id) {
@@ -19788,8 +19893,11 @@ class Renderer extends React.Component {
19788
19893
  const widget = this.getWidgetInstance(widgetId);
19789
19894
 
19790
19895
  // Widget handles parsing of the interWidgetPath.
19791
- widget == null ? void 0 : widget.setInputValue == null ? void 0 : widget.setInputValue(interWidgetPath, newValue, focus);
19896
+ widget == null || widget.setInputValue == null || widget.setInputValue(interWidgetPath, newValue, focus);
19792
19897
  };
19898
+ /**
19899
+ * Returns an array of the widget `.getUserInput()` results
19900
+ */
19793
19901
  this.getUserInput = () => {
19794
19902
  return this.widgetIds.map(id => {
19795
19903
  const widget = this.getWidgetInstance(id);
@@ -19800,9 +19908,22 @@ class Renderer extends React.Component {
19800
19908
  }
19801
19909
  });
19802
19910
  };
19911
+ /**
19912
+ * Returns an array of all widget IDs in the order they occur in
19913
+ * the content.
19914
+ */
19803
19915
  this.getWidgetIds = () => {
19804
19916
  return this.widgetIds;
19805
19917
  };
19918
+ /**
19919
+ * Returns the result of `.getUserInput()` for each widget, in
19920
+ * a map from widgetId to userInput.
19921
+ * NOTE(jeremy): This function is hauntingly similar to `getUserInput` with
19922
+ * the major difference being that this function returns a map of
19923
+ * `widgetID` => UserInput and `getUserInput` simply returns an array. It
19924
+ * would be trivial to map between the results of each of these functions,
19925
+ * so we should aim to remove one of these functions.
19926
+ */
19806
19927
  this.getUserInputForWidgets = () => {
19807
19928
  return mapObjectFromArray(this.widgetIds, id => {
19808
19929
  const widget = this.getWidgetInstance(id);
@@ -19811,6 +19932,11 @@ class Renderer extends React.Component {
19811
19932
  }
19812
19933
  });
19813
19934
  };
19935
+ /**
19936
+ * Returns an object mapping from widget ID to perseus-style score.
19937
+ * The keys of this object are the values of the array returned
19938
+ * from `getWidgetIds`.
19939
+ */
19814
19940
  this.scoreWidgets = () => {
19815
19941
  const widgetProps = this.state.widgetInfo;
19816
19942
  const onInputError = this.getApiOptions().onInputError;
@@ -19834,6 +19960,9 @@ class Renderer extends React.Component {
19834
19960
  });
19835
19961
  return widgetScores;
19836
19962
  };
19963
+ /**
19964
+ * Grades the content.
19965
+ */
19837
19966
  this.score = () => {
19838
19967
  return _.reduce(this.scoreWidgets(), Util.combineScores, Util.noScore);
19839
19968
  };
@@ -19864,6 +19993,7 @@ class Renderer extends React.Component {
19864
19993
  }
19865
19994
  return examples[0];
19866
19995
  };
19996
+ // TranslationLinter callback
19867
19997
  this.handletranslationLintErrors = lintErrors => {
19868
19998
  if (!this._isMounted) {
19869
19999
  return;
@@ -21084,6 +21214,8 @@ class InputNumber extends React.Component {
21084
21214
  /* c8 ignore next */
21085
21215
  return [[]];
21086
21216
  };
21217
+ // Note: We believe that this isn't used anywhere but are leaving it during
21218
+ // the initial refactor
21087
21219
  this.getGrammarTypeForPath = path => {
21088
21220
  /* c8 ignore next */
21089
21221
  return "number";
@@ -21317,6 +21449,7 @@ class NumericInput extends React.Component {
21317
21449
  // between 0 and finite solutions
21318
21450
  previousValues: [""]
21319
21451
  };
21452
+ // TODO(Nicole, Jeremy): This is maybe never used and should be removed
21320
21453
  this.examples = () => {
21321
21454
  var _this$props$answerFor;
21322
21455
  // if the set of specified forms are empty, allow all forms
@@ -21350,16 +21483,16 @@ class NumericInput extends React.Component {
21350
21483
  };
21351
21484
  this.focus = () => {
21352
21485
  var _this$inputRef;
21353
- (_this$inputRef = this.inputRef) == null ? void 0 : _this$inputRef.focus();
21486
+ (_this$inputRef = this.inputRef) == null || _this$inputRef.focus();
21354
21487
  return true;
21355
21488
  };
21356
21489
  this.focusInputPath = () => {
21357
21490
  var _this$inputRef2;
21358
- (_this$inputRef2 = this.inputRef) == null ? void 0 : _this$inputRef2.focus();
21491
+ (_this$inputRef2 = this.inputRef) == null || _this$inputRef2.focus();
21359
21492
  };
21360
21493
  this.blurInputPath = () => {
21361
21494
  var _this$inputRef3;
21362
- (_this$inputRef3 = this.inputRef) == null ? void 0 : _this$inputRef3.blur();
21495
+ (_this$inputRef3 = this.inputRef) == null || _this$inputRef3.blur();
21363
21496
  };
21364
21497
  this.getInputPaths = () => {
21365
21498
  // The widget itself is an input, so we return a single empty list to
@@ -21692,12 +21825,16 @@ class PassageRef extends React.Component {
21692
21825
  constructor(..._args) {
21693
21826
  super(..._args);
21694
21827
  this.displayName = "PassageRef";
21828
+ // @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
21695
21829
  this._isMounted = void 0;
21830
+ // @ts-expect-error - TS2564 - Property '_throttledUpdateRange' has no initializer and is not definitely assigned in the constructor.
21696
21831
  this._throttledUpdateRange = void 0;
21697
21832
  this.state = {
21698
21833
  lineRange: null,
21699
21834
  content: null
21700
21835
  };
21836
+ // TODO(tamarab): getUserInput needs to be updated to only return
21837
+ // props input by the user. Currently returns all the widget's props.
21701
21838
  this.getUserInput = () => {
21702
21839
  return removeDenylistProps(this.props);
21703
21840
  };
@@ -21737,10 +21874,6 @@ class PassageRef extends React.Component {
21737
21874
  shouldComponentUpdate(nextProps, nextState) {
21738
21875
  return !_.isEqual(this.props, nextProps) || !_.isEqual(this.state, nextState);
21739
21876
  }
21740
-
21741
- // TODO(tamarab): getUserInput needs to be updated to only return
21742
- // props input by the user. Currently returns all the widget's props.
21743
-
21744
21877
  render() {
21745
21878
  const lineRange = this.state.lineRange;
21746
21879
  let lineRangeOutput;
@@ -22094,7 +22227,6 @@ const BASE_ICON_SIZE = 10;
22094
22227
  // If you pass in an object you need to specify an SVG path to
22095
22228
  // render along with the width and height of the path (to ensure
22096
22229
  // that it gets scaled correctly).
22097
-
22098
22230
  class Icon extends React.Component {
22099
22231
  render() {
22100
22232
  const {
@@ -22928,7 +23060,7 @@ const BaseRadio = function BaseRadio(props) {
22928
23060
 
22929
23061
  // register a callback with the parent that allows
22930
23062
  // the parent to focus an individual choice
22931
- registerFocusFunction == null ? void 0 : registerFocusFunction(choiceIndex => {
23063
+ registerFocusFunction == null || registerFocusFunction(choiceIndex => {
22932
23064
  const ref = choiceRefs.current[choiceIndex || 0];
22933
23065
  // note(matthew): we know this is only getting passed
22934
23066
  // to a WB Clickable button, so we force it to be of
@@ -23171,9 +23303,12 @@ const styles$q = StyleSheet.create({
23171
23303
  }
23172
23304
  });
23173
23305
 
23306
+ // RenderProps is the return type for radio.jsx#transform
23307
+
23174
23308
  class Radio$1 extends React.Component {
23175
23309
  constructor(...args) {
23176
23310
  super(...args);
23311
+ // @ts-expect-error - TS2564 - Property 'focusFunction' has no initializer and is not definitely assigned in the constructor.
23177
23312
  this.focusFunction = void 0;
23178
23313
  this._renderRenderer = (content = "") => {
23179
23314
  let nextPassageRefId = 1;
@@ -23216,6 +23351,19 @@ class Radio$1 extends React.Component {
23216
23351
  })
23217
23352
  });
23218
23353
  };
23354
+ // When `BaseRadio`'s `onChange` handler is called, indicating a change in
23355
+ // our choices' state, we need to call our `onChange` handler in order to
23356
+ // persist those changes in the item's Perseus state.
23357
+ //
23358
+ // So, given the new values for each choice, construct the new
23359
+ // `choiceStates` objects, and pass them to `this.props.onChange`.
23360
+ //
23361
+ // `newValueLists` is an object with two keys: `checked` and `crossedOut`.
23362
+ // Each contains an array of boolean values, specifying the new checked and
23363
+ // crossed-out value of each choice.
23364
+ //
23365
+ // NOTE(mdr): This method expects to be auto-bound. If this component is
23366
+ // converted to an ES6 class, take care to auto-bind this method!
23219
23367
  this.updateChoices = newValueLists => {
23220
23368
  const {
23221
23369
  choiceStates,
@@ -23254,6 +23402,11 @@ class Radio$1 extends React.Component {
23254
23402
  this.simpleValidate = rubric => {
23255
23403
  return Radio$1.validate(this.getUserInput(), rubric);
23256
23404
  };
23405
+ /**
23406
+ * Turn on rationale display for the currently selected choices. Note that
23407
+ * this leaves rationales on for choices that are already showing
23408
+ * rationales.
23409
+ */
23257
23410
  this.showRationalesForCurrentlySelectedChoices = rubric => {
23258
23411
  const {
23259
23412
  choiceStates
@@ -23287,6 +23440,9 @@ class Radio$1 extends React.Component {
23287
23440
  );
23288
23441
  }
23289
23442
  };
23443
+ /**
23444
+ * Deselects any currently-selected choices that are not correct choices.
23445
+ */
23290
23446
  this.deselectIncorrectSelectedChoices = () => {
23291
23447
  if (this.props.choiceStates) {
23292
23448
  const newStates = this.props.choiceStates.map((state, i) => _extends({}, state, {
@@ -23428,21 +23584,6 @@ class Radio$1 extends React.Component {
23428
23584
  registerFocusFunction(fun) {
23429
23585
  this.focusFunction = fun;
23430
23586
  }
23431
-
23432
- // When `BaseRadio`'s `onChange` handler is called, indicating a change in
23433
- // our choices' state, we need to call our `onChange` handler in order to
23434
- // persist those changes in the item's Perseus state.
23435
- //
23436
- // So, given the new values for each choice, construct the new
23437
- // `choiceStates` objects, and pass them to `this.props.onChange`.
23438
- //
23439
- // `newValueLists` is an object with two keys: `checked` and `crossedOut`.
23440
- // Each contains an array of boolean values, specifying the new checked and
23441
- // crossed-out value of each choice.
23442
- //
23443
- // NOTE(mdr): This method expects to be auto-bound. If this component is
23444
- // converted to an ES6 class, take care to auto-bind this method!
23445
-
23446
23587
  render() {
23447
23588
  const {
23448
23589
  choices
@@ -24112,6 +24253,8 @@ var CSProgram$1 = {
24112
24253
  hidden: true
24113
24254
  };
24114
24255
 
24256
+ // TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
24257
+
24115
24258
  class Definition extends React.Component {
24116
24259
  constructor(...args) {
24117
24260
  super(...args);
@@ -24280,6 +24423,11 @@ var Dropdown$1 = {
24280
24423
  };
24281
24424
 
24282
24425
  /* eslint-disable react/sort-comp */
24426
+
24427
+ // TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
24428
+
24429
+ // transform = _.identity
24430
+
24283
24431
  class Explanation extends React.Component {
24284
24432
  constructor(..._args) {
24285
24433
  super(..._args);
@@ -24611,6 +24759,9 @@ const getNextState = (currentState, answerable) => {
24611
24759
  // Prepended to all invalid messages to make the widget messages a bit clearer
24612
24760
  const INVALID_MESSAGE_PREFIX = i18n._("We couldn't grade your answer.");
24613
24761
  const DEFAULT_INVALID_MESSAGE = i18n._("It looks like you left something blank or ") + i18n._("entered in an invalid answer.");
24762
+
24763
+ // exports has no 'transform'
24764
+
24614
24765
  // A Graded Group is more or less a Group widget that displays a check
24615
24766
  // answer button below the rendered content. When clicked, the widget grades
24616
24767
  // the stuff inside and displays feedback about whether the inputted answer was
@@ -24628,6 +24779,11 @@ class GradedGroup extends React.Component {
24628
24779
  // @ts-expect-error - TS2345 - Argument of type 'readonly unknown[]' is not assignable to parameter of type 'any[]'.
24629
24780
  return change.apply(this, args);
24630
24781
  };
24782
+ // This is a little strange because the id of the widget that actually
24783
+ // changed is going to be lost in favor of the group widget's id. The
24784
+ // widgets prop also wasn't actually changed, and this only serves to
24785
+ // alert our renderer (our parent) of the fact that some interaction
24786
+ // has occurred.
24631
24787
  this._onInteractWithWidget = id => {
24632
24788
  // Reset grading display when user changes answer
24633
24789
  this.setState({
@@ -24667,6 +24823,7 @@ class GradedGroup extends React.Component {
24667
24823
  status: status
24668
24824
  });
24669
24825
  };
24826
+ // Mobile API
24670
24827
  this.getInputPaths = () => {
24671
24828
  // eslint-disable-next-line react/no-string-refs
24672
24829
  // @ts-expect-error - TS2339 - Property 'getInputPaths' does not exist on type 'ReactInstance'.
@@ -24937,11 +25094,15 @@ class Indicators extends React.Component {
24937
25094
  }, i18n._("Current"))))))));
24938
25095
  }
24939
25096
  }
25097
+
25098
+ // no transform
25099
+
24940
25100
  // TODO(jared): find a better name for this :) and for GradedGroup; the names
24941
25101
  // are currently a little confusing.
24942
25102
  class GradedGroupSet extends React.Component {
24943
25103
  constructor(..._args) {
24944
25104
  super(..._args);
25105
+ // @ts-expect-error - TS2564 - Property '_childGroup' has no initializer and is not definitely assigned in the constructor.
24945
25106
  this._childGroup = void 0;
24946
25107
  this.state = {
24947
25108
  currentGroup: 0
@@ -24950,6 +25111,7 @@ class GradedGroupSet extends React.Component {
24950
25111
  // @ts-expect-error - TS2345 - Argument of type 'readonly unknown[]' is not assignable to parameter of type 'any[]'.
24951
25112
  return change.apply(this, args);
24952
25113
  };
25114
+ // Mobile API
24953
25115
  this.getInputPaths = () => {
24954
25116
  return this._childGroup.getInputPaths();
24955
25117
  };
@@ -25984,7 +26146,7 @@ FunctionGrapher.defaultProps = {
25984
26146
  coords: null,
25985
26147
  asymptote: null,
25986
26148
  isMobile: false
25987
- };
26149
+ }; // Really this is props.plot, I think
25988
26150
  /* Widget and editor. */
25989
26151
  class Grapher extends React.Component {
25990
26152
  constructor(...args) {
@@ -26190,6 +26352,8 @@ var Grapher$1 = {
26190
26352
  staticTransform: staticTransform$3
26191
26353
  };
26192
26354
 
26355
+ // exports has no 'transform'
26356
+
26193
26357
  class Group extends React.Component {
26194
26358
  constructor(..._args) {
26195
26359
  super(..._args);
@@ -26207,7 +26371,7 @@ class Group extends React.Component {
26207
26371
  };
26208
26372
  this.restoreSerializedState = (state, callback) => {
26209
26373
  var _this$rendererRef3;
26210
- (_this$rendererRef3 = this.rendererRef) == null ? void 0 : _this$rendererRef3.restoreSerializedState(state, callback);
26374
+ (_this$rendererRef3 = this.rendererRef) == null || _this$rendererRef3.restoreSerializedState(state, callback);
26211
26375
  // Tell our renderer that we have no props to change
26212
26376
  // (all our changes were in state):
26213
26377
  return null;
@@ -26216,6 +26380,7 @@ class Group extends React.Component {
26216
26380
  var _this$rendererRef4;
26217
26381
  return (_this$rendererRef4 = this.rendererRef) == null ? void 0 : _this$rendererRef4.score();
26218
26382
  };
26383
+ // Mobile API:
26219
26384
  this.getInputPaths = () => {
26220
26385
  var _this$rendererRef5;
26221
26386
  return (_this$rendererRef5 = this.rendererRef) == null ? void 0 : _this$rendererRef5.getInputPaths();
@@ -26230,15 +26395,15 @@ class Group extends React.Component {
26230
26395
  };
26231
26396
  this.focusInputPath = path => {
26232
26397
  var _this$rendererRef8;
26233
- (_this$rendererRef8 = this.rendererRef) == null ? void 0 : _this$rendererRef8.focusPath(path);
26398
+ (_this$rendererRef8 = this.rendererRef) == null || _this$rendererRef8.focusPath(path);
26234
26399
  };
26235
26400
  this.blurInputPath = path => {
26236
26401
  var _this$rendererRef9;
26237
- (_this$rendererRef9 = this.rendererRef) == null ? void 0 : _this$rendererRef9.blurPath(path);
26402
+ (_this$rendererRef9 = this.rendererRef) == null || _this$rendererRef9.blurPath(path);
26238
26403
  };
26239
26404
  this.showRationalesForCurrentlySelectedChoices = () => {
26240
26405
  var _this$rendererRef10;
26241
- (_this$rendererRef10 = this.rendererRef) == null ? void 0 : _this$rendererRef10.showRationalesForCurrentlySelectedChoices();
26406
+ (_this$rendererRef10 = this.rendererRef) == null || _this$rendererRef10.showRationalesForCurrentlySelectedChoices();
26242
26407
  };
26243
26408
  }
26244
26409
  componentDidMount() {
@@ -26504,6 +26669,9 @@ const defaultBackgroundImage$3 = {
26504
26669
  };
26505
26670
  const editorAlignments = ["block", "full-width"];
26506
26671
  const DEFAULT_ALIGNMENT = "block";
26672
+
26673
+ // there is no transform as part of exports
26674
+
26507
26675
  class ImageWidget extends React.Component {
26508
26676
  constructor(..._args) {
26509
26677
  super(..._args);
@@ -26768,6 +26936,9 @@ const KAScompile = (expr, options) => {
26768
26936
  _compileCache[hash] = cached;
26769
26937
  return cached;
26770
26938
  };
26939
+
26940
+ // There's no transform function in exports
26941
+
26771
26942
  class Interaction extends React.Component {
26772
26943
  constructor(..._args) {
26773
26944
  super(..._args);
@@ -26833,6 +27004,7 @@ class Interaction extends React.Component {
26833
27004
  // Default to 0 if the expression couldn't be parsed
26834
27005
  return func(compiledVars) || 0;
26835
27006
  };
27007
+ // Return an array of all the variables in an expression
26836
27008
  this._extractVars = expr => {
26837
27009
  if (expr == null) {
26838
27010
  return [];
@@ -27341,8 +27513,15 @@ class Graph extends React.Component {
27341
27513
  this.protractor = void 0;
27342
27514
  this.ruler = void 0;
27343
27515
  this._graphie = void 0;
27516
+ // @ts-expect-error - TS2564 - Property '_hasSetupGraphieThisUpdate' has no initializer and is not definitely assigned in the constructor.
27344
27517
  this._hasSetupGraphieThisUpdate = void 0;
27518
+ // @ts-expect-error - TS2564 - Property '_shouldSetupGraphie' has no initializer and is not definitely assigned in the constructor.
27345
27519
  this._shouldSetupGraphie = void 0;
27520
+ /* Reset the graphie canvas to its initial state
27521
+ *
27522
+ * Use when re-rendering the parent component and you need a blank
27523
+ * graphie.
27524
+ */
27346
27525
  this.reset = () => {
27347
27526
  this._setupGraphie(false);
27348
27527
  };
@@ -27549,13 +27728,6 @@ class Graph extends React.Component {
27549
27728
  this._shouldSetupGraphie = false;
27550
27729
  }
27551
27730
  }
27552
-
27553
- /* Reset the graphie canvas to its initial state
27554
- *
27555
- * Use when re-rendering the parent component and you need a blank
27556
- * graphie.
27557
- */
27558
-
27559
27731
  render() {
27560
27732
  let image;
27561
27733
  const imageData = this.props.backgroundImage;
@@ -27869,6 +28041,9 @@ const makeInvalidTypeError = (functionName, graphType) => {
27869
28041
  }
27870
28042
  });
27871
28043
  };
28044
+
28045
+ // There's no transform function in exports
28046
+
27872
28047
  class InteractiveGraph extends React.Component {
27873
28048
  constructor(...args) {
27874
28049
  super(...args);
@@ -27882,8 +28057,10 @@ class InteractiveGraph extends React.Component {
27882
28057
  this.pointA = void 0;
27883
28058
  this.pointB = void 0;
27884
28059
  this.pointC = void 0;
28060
+ // @ts-expect-error - TS2564 - Property 'points' has no initializer and is not definitely assigned in the constructor.
27885
28061
  this.points = void 0;
27886
28062
  this.polygon = void 0;
28063
+ // @ts-expect-error - TS2564 - Property 'shouldResetGraphie' has no initializer and is not definitely assigned in the constructor.
27887
28064
  this.shouldResetGraphie = void 0;
27888
28065
  this.sinusoid = void 0;
27889
28066
  this.trashCan = void 0;
@@ -27965,7 +28142,7 @@ class InteractiveGraph extends React.Component {
27965
28142
  this.horizHairline.attr({
27966
28143
  stroke: KhanColors.INTERACTIVE
27967
28144
  });
27968
- (_this$horizHairline = this.horizHairline) == null ? void 0 : _this$horizHairline.hide();
28145
+ (_this$horizHairline = this.horizHairline) == null || _this$horizHairline.hide();
27969
28146
  this.vertHairline = new WrappedLine(this.graphie, [0, 0], [0, 0], {
27970
28147
  normalStyle: {
27971
28148
  strokeWidth: 1
@@ -27974,7 +28151,7 @@ class InteractiveGraph extends React.Component {
27974
28151
  this.vertHairline.attr({
27975
28152
  stroke: KhanColors.INTERACTIVE
27976
28153
  });
27977
- (_this$vertHairline = this.vertHairline) == null ? void 0 : _this$vertHairline.hide();
28154
+ (_this$vertHairline = this.vertHairline) == null || _this$vertHairline.hide();
27978
28155
  }
27979
28156
  const type = this.props.graph.type;
27980
28157
  this["add" + capitalize(type) + "Controls"]();
@@ -27985,17 +28162,17 @@ class InteractiveGraph extends React.Component {
27985
28162
  // Hairlines are already initialized when the graph is loaded, so
27986
28163
  // here we just move them to the updated location and make them
27987
28164
  // visible.
27988
- (_this$horizHairline2 = this.horizHairline) == null ? void 0 : _this$horizHairline2.moveTo([this.props.range[0][0], point[1]], [this.props.range[0][1], point[1]]);
27989
- (_this$horizHairline3 = this.horizHairline) == null ? void 0 : _this$horizHairline3.show();
27990
- (_this$vertHairline2 = this.vertHairline) == null ? void 0 : _this$vertHairline2.moveTo([point[0], this.props.range[1][0]], [point[0], this.props.range[1][1]]);
27991
- (_this$vertHairline3 = this.vertHairline) == null ? void 0 : _this$vertHairline3.show();
28165
+ (_this$horizHairline2 = this.horizHairline) == null || _this$horizHairline2.moveTo([this.props.range[0][0], point[1]], [this.props.range[0][1], point[1]]);
28166
+ (_this$horizHairline3 = this.horizHairline) == null || _this$horizHairline3.show();
28167
+ (_this$vertHairline2 = this.vertHairline) == null || _this$vertHairline2.moveTo([point[0], this.props.range[1][0]], [point[0], this.props.range[1][1]]);
28168
+ (_this$vertHairline3 = this.vertHairline) == null || _this$vertHairline3.show();
27992
28169
  }
27993
28170
  };
27994
28171
  this.hideHairlines = () => {
27995
28172
  if (this.props.apiOptions.isMobile) {
27996
28173
  var _this$horizHairline4, _this$vertHairline4;
27997
- (_this$horizHairline4 = this.horizHairline) == null ? void 0 : _this$horizHairline4.hide();
27998
- (_this$vertHairline4 = this.vertHairline) == null ? void 0 : _this$vertHairline4.hide();
28174
+ (_this$horizHairline4 = this.horizHairline) == null || _this$horizHairline4.hide();
28175
+ (_this$vertHairline4 = this.vertHairline) == null || _this$vertHairline4.hide();
27999
28176
  }
28000
28177
  };
28001
28178
  this.setTrashCanVisibility = opacity => {
@@ -28011,9 +28188,9 @@ class InteractiveGraph extends React.Component {
28011
28188
  // trash can area.
28012
28189
  if (!this.trashCan) {
28013
28190
  var _graphie$raphael;
28014
- this.trashCan = graphie == null ? void 0 : (_graphie$raphael = graphie.raphael) == null ? void 0 : _graphie$raphael.image(TRASH_ICON_URI, graphie.xpixels - 40, graphie.ypixels - 40, 40, 40);
28191
+ this.trashCan = graphie == null || (_graphie$raphael = graphie.raphael) == null ? void 0 : _graphie$raphael.image(TRASH_ICON_URI, graphie.xpixels - 40, graphie.ypixels - 40, 40, 40);
28015
28192
  }
28016
- (_this$trashCan = this.trashCan) == null ? void 0 : _this$trashCan.attr({
28193
+ (_this$trashCan = this.trashCan) == null || _this$trashCan.attr({
28017
28194
  opacity: opacity
28018
28195
  });
28019
28196
  }
@@ -28078,7 +28255,7 @@ class InteractiveGraph extends React.Component {
28078
28255
  this.removeLine = () => {
28079
28256
  var _this$line;
28080
28257
  _.invoke(this.points, "remove");
28081
- (_this$line = this.line) == null ? void 0 : _this$line.remove();
28258
+ (_this$line = this.line) == null || _this$line.remove();
28082
28259
  };
28083
28260
  this.addLinearControls = () => {
28084
28261
  this.addLine("line");
@@ -28181,23 +28358,23 @@ class InteractiveGraph extends React.Component {
28181
28358
  if (this.parabola) {
28182
28359
  var _this$graphie, _this$parabola;
28183
28360
  const path = (_this$graphie = this.graphie) == null ? void 0 : _this$graphie.svgParabolaPath(a, b, c);
28184
- (_this$parabola = this.parabola) == null ? void 0 : _this$parabola.attr({
28361
+ (_this$parabola = this.parabola) == null || _this$parabola.attr({
28185
28362
  path: path
28186
28363
  });
28187
28364
  } else {
28188
28365
  var _this$graphie2, _this$parabola2, _this$parabola3;
28189
28366
  this.parabola = (_this$graphie2 = this.graphie) == null ? void 0 : _this$graphie2.parabola(a, b, c);
28190
- (_this$parabola2 = this.parabola) == null ? void 0 : _this$parabola2.attr(_extends({
28367
+ (_this$parabola2 = this.parabola) == null || _this$parabola2.attr(_extends({
28191
28368
  stroke: this.props.apiOptions.isMobile ? KhanColors.BLUE_C : KhanColors.DYNAMIC
28192
28369
  }, this._lineStroke()));
28193
- (_this$parabola3 = this.parabola) == null ? void 0 : _this$parabola3.toBack();
28370
+ (_this$parabola3 = this.parabola) == null || _this$parabola3.toBack();
28194
28371
  }
28195
28372
  };
28196
28373
  this.removeQuadraticControls = () => {
28197
28374
  var _this$pointA, _this$pointB, _this$pointC;
28198
- (_this$pointA = this.pointA) == null ? void 0 : _this$pointA.remove();
28199
- (_this$pointB = this.pointB) == null ? void 0 : _this$pointB.remove();
28200
- (_this$pointC = this.pointC) == null ? void 0 : _this$pointC.remove();
28375
+ (_this$pointA = this.pointA) == null || _this$pointA.remove();
28376
+ (_this$pointB = this.pointB) == null || _this$pointB.remove();
28377
+ (_this$pointC = this.pointC) == null || _this$pointC.remove();
28201
28378
  if (this.parabola) {
28202
28379
  this.parabola.remove();
28203
28380
  this.parabola = null;
@@ -28265,22 +28442,22 @@ class InteractiveGraph extends React.Component {
28265
28442
  if (this.sinusoid) {
28266
28443
  var _this$graphie3, _this$sinusoid;
28267
28444
  const path = (_this$graphie3 = this.graphie) == null ? void 0 : _this$graphie3.svgSinusoidPath(a, b, c, d);
28268
- (_this$sinusoid = this.sinusoid) == null ? void 0 : _this$sinusoid.attr({
28445
+ (_this$sinusoid = this.sinusoid) == null || _this$sinusoid.attr({
28269
28446
  path: path
28270
28447
  });
28271
28448
  } else {
28272
28449
  var _this$graphie4, _this$sinusoid2, _this$sinusoid3;
28273
28450
  this.sinusoid = (_this$graphie4 = this.graphie) == null ? void 0 : _this$graphie4.sinusoid(a, b, c, d);
28274
- (_this$sinusoid2 = this.sinusoid) == null ? void 0 : _this$sinusoid2.attr(_extends({
28451
+ (_this$sinusoid2 = this.sinusoid) == null || _this$sinusoid2.attr(_extends({
28275
28452
  stroke: this.props.apiOptions.isMobile ? KhanColors.BLUE_C : KhanColors.DYNAMIC
28276
28453
  }, this._lineStroke()));
28277
- (_this$sinusoid3 = this.sinusoid) == null ? void 0 : _this$sinusoid3.toBack();
28454
+ (_this$sinusoid3 = this.sinusoid) == null || _this$sinusoid3.toBack();
28278
28455
  }
28279
28456
  };
28280
28457
  this.removeSinusoidControls = () => {
28281
28458
  var _this$pointA2, _this$pointB2;
28282
- (_this$pointA2 = this.pointA) == null ? void 0 : _this$pointA2.remove();
28283
- (_this$pointB2 = this.pointB) == null ? void 0 : _this$pointB2.remove();
28459
+ (_this$pointA2 = this.pointA) == null || _this$pointA2.remove();
28460
+ (_this$pointB2 = this.pointB) == null || _this$pointB2.remove();
28284
28461
  if (this.sinusoid) {
28285
28462
  this.sinusoid.remove();
28286
28463
  this.sinusoid = null;
@@ -28311,7 +28488,7 @@ class InteractiveGraph extends React.Component {
28311
28488
  };
28312
28489
  this.removeCircleControls = () => {
28313
28490
  var _this$circle;
28314
- (_this$circle = this.circle) == null ? void 0 : _this$circle.remove();
28491
+ (_this$circle = this.circle) == null || _this$circle.remove();
28315
28492
  };
28316
28493
  this.addLinearSystemControls = () => {
28317
28494
  const graphie = this.graphie;
@@ -28476,7 +28653,7 @@ class InteractiveGraph extends React.Component {
28476
28653
  // We should be checking if this.points is defined before rotating them.
28477
28654
  // @ts-expect-error - TS4104 - The type 'readonly any[]' is 'readonly' and cannot be assigned to the mutable type 'any[]'. | TS2345 - Argument of type 'number | null | undefined' is not assignable to parameter of type 'number | undefined'.
28478
28655
  this.points = rotate(this.points, index);
28479
- (_this$polygon3 = this.polygon) == null ? void 0 : _this$polygon3.update({
28656
+ (_this$polygon3 = this.polygon) == null || _this$polygon3.update({
28480
28657
  closed: false
28481
28658
  });
28482
28659
  }
@@ -28507,13 +28684,13 @@ class InteractiveGraph extends React.Component {
28507
28684
  const pointToRemove = this.points.pop();
28508
28685
  if (this.points.length > 2) {
28509
28686
  var _this$polygon4;
28510
- (_this$polygon4 = this.polygon) == null ? void 0 : _this$polygon4.update({
28687
+ (_this$polygon4 = this.polygon) == null || _this$polygon4.update({
28511
28688
  closed: true
28512
28689
  });
28513
28690
  this.updateCoordsFromPoints();
28514
28691
  } else {
28515
28692
  var _this$polygon5;
28516
- (_this$polygon5 = this.polygon) == null ? void 0 : _this$polygon5.update({
28693
+ (_this$polygon5 = this.polygon) == null || _this$polygon5.update({
28517
28694
  closed: false
28518
28695
  });
28519
28696
  this.clearCoords();
@@ -28537,7 +28714,7 @@ class InteractiveGraph extends React.Component {
28537
28714
  this.removePoint(point$1);
28538
28715
  if (this.points.length < 3) {
28539
28716
  var _this$polygon6;
28540
- (_this$polygon6 = this.polygon) == null ? void 0 : _this$polygon6.update({
28717
+ (_this$polygon6 = this.polygon) == null || _this$polygon6.update({
28541
28718
  closed: false
28542
28719
  });
28543
28720
  this.clearCoords();
@@ -28575,7 +28752,7 @@ class InteractiveGraph extends React.Component {
28575
28752
  const canCloseUnclosedPolygon = isFirstOrLastPoint && pointNotMoved && notANewPoint && polygonNotClosed && allPointsPlotted;
28576
28753
  if (canCloseUnclosedPolygon) {
28577
28754
  var _this$polygon9;
28578
- (_this$polygon9 = this.polygon) == null ? void 0 : _this$polygon9.update({
28755
+ (_this$polygon9 = this.polygon) == null || _this$polygon9.update({
28579
28756
  closed: true
28580
28757
  });
28581
28758
  this.updatePolygon();
@@ -28948,7 +29125,7 @@ class InteractiveGraph extends React.Component {
28948
29125
  this.removePolygonControls = () => {
28949
29126
  var _this$polygon11;
28950
29127
  _.invoke(this.points, "remove");
28951
- (_this$polygon11 = this.polygon) == null ? void 0 : _this$polygon11.remove();
29128
+ (_this$polygon11 = this.polygon) == null || _this$polygon11.remove();
28952
29129
  };
28953
29130
  this.addAngleControls = () => {
28954
29131
  if (this.props.graph.type !== "angle") {
@@ -28993,7 +29170,7 @@ class InteractiveGraph extends React.Component {
28993
29170
  this.removeAngleControls = () => {
28994
29171
  var _this$angle2;
28995
29172
  _.invoke(this.points, "remove");
28996
- (_this$angle2 = this.angle) == null ? void 0 : _this$angle2.remove();
29173
+ (_this$angle2 = this.angle) == null || _this$angle2.remove();
28997
29174
  };
28998
29175
  this.toggleShowSides = () => {
28999
29176
  if (this.props.graph.type !== "polygon") {
@@ -29530,7 +29707,7 @@ class InteractiveGraph extends React.Component {
29530
29707
  // eq() comparison but _.isEqual(0, -0) is false, so we'll use
29531
29708
  // eq() anyway. The sort should be fine because it'll stringify
29532
29709
  // it and -0 converted to a string is "0"
29533
- guess == null ? void 0 : guess.sort();
29710
+ guess == null || guess.sort();
29534
29711
  // @ts-expect-error - TS2339 - Property 'sort' does not exist on type 'readonly Coord[]'.
29535
29712
  correct.sort();
29536
29713
  if (deepEq$2(guess, correct)) {
@@ -30647,6 +30824,7 @@ var globalStyles = /*#__PURE__*/Object.freeze({
30647
30824
  class AnswerChoice extends React.Component {
30648
30825
  constructor(...args) {
30649
30826
  super(...args);
30827
+ // The radio button or checkbox input control.
30650
30828
  this._input = void 0;
30651
30829
  this.state = {
30652
30830
  isInputFocused: false
@@ -30753,10 +30931,9 @@ class AnswerChoice extends React.Component {
30753
30931
  }
30754
30932
  }
30755
30933
  class AnswerChoices extends React.Component {
30756
- // The rendered answers elements.
30757
-
30758
30934
  constructor(props) {
30759
30935
  super(props);
30936
+ // The rendered answers elements.
30760
30937
  this._choices = void 0;
30761
30938
  this._choices = [];
30762
30939
  this.state = {
@@ -30850,6 +31027,7 @@ const styles$h = StyleSheet.create({
30850
31027
  class Marker extends React.Component {
30851
31028
  constructor(...args) {
30852
31029
  super(...args);
31030
+ // The marker icon element.
30853
31031
  this._icon = void 0;
30854
31032
  this.state = {
30855
31033
  isFocused: false
@@ -31105,13 +31283,12 @@ const styles$g = StyleSheet.create({
31105
31283
  }
31106
31284
  });
31107
31285
 
31108
- class LabelImage extends React.Component {
31109
- // The rendered markers on the question image for labeling.
31110
-
31111
- // The popup component containing the answer choices.
31112
-
31113
- // The rendered list of answer choices for the currently selected marker.
31286
+ /**
31287
+ * Represents a direction vector.
31288
+ * No diagonals allowed.
31289
+ */
31114
31290
 
31291
+ class LabelImage extends React.Component {
31115
31292
  static gradeMarker(marker) {
31116
31293
  const score = {
31117
31294
  hasAnswers: false,
@@ -31329,8 +31506,11 @@ class LabelImage extends React.Component {
31329
31506
  }
31330
31507
  constructor(props) {
31331
31508
  super(props);
31509
+ // The rendered markers on the question image for labeling.
31332
31510
  this._markers = void 0;
31511
+ // The popup component containing the answer choices.
31333
31512
  this._selectedMarkerPopup = void 0;
31513
+ // The rendered list of answer choices for the currently selected marker.
31334
31514
  this._answerChoices = void 0;
31335
31515
  this.handleDocumentClick = e => {
31336
31516
  // Dismiss open popup with answer choices if user clicks outside it.
@@ -31858,6 +32038,7 @@ class LightsPuzzle extends React.Component {
31858
32038
  super(..._args);
31859
32039
  this._currPattern = void 0;
31860
32040
  this._nextPattern = void 0;
32041
+ // @ts-expect-error - TS2564 - Property '_patternIndex' has no initializer and is not definitely assigned in the constructor.
31861
32042
  this._patternIndex = void 0;
31862
32043
  this.getUserInput = () => {
31863
32044
  return WidgetJsonifyDeprecated.getUserInput.call(this);
@@ -32059,8 +32240,11 @@ class Placeholder extends React.Component {
32059
32240
  class Draggable extends React.Component {
32060
32241
  constructor(...args) {
32061
32242
  super(...args);
32243
+ // Handler returned by requestAnimationFrame.
32062
32244
  this.animationFrameRequest = null;
32245
+ // @ts-expect-error - TS2564 - Property 'isMouseMoveUpBound' has no initializer and is not definitely assigned in the constructor.
32063
32246
  this.isMouseMoveUpBound = void 0;
32247
+ // @ts-expect-error - TS2564 - Property '_mounted' has no initializer and is not definitely assigned in the constructor.
32064
32248
  this._mounted = void 0;
32065
32249
  this.state = {
32066
32250
  startPosition: {
@@ -32761,11 +32945,15 @@ class Matcher extends React.Component {
32761
32945
  right: this.refs.right.getOptions()
32762
32946
  };
32763
32947
  };
32948
+ // Programatic API for moving options
32949
+ // This is used by testing
32764
32950
  this.moveLeftOptionToIndex = (option, index) => {
32765
32951
  // eslint-disable-next-line react/no-string-refs
32766
32952
  // @ts-expect-error - TS2339 - Property 'moveOptionToIndex' does not exist on type 'ReactInstance'.
32767
32953
  this.refs.left.moveOptionToIndex(option, index);
32768
32954
  };
32955
+ // Programatic API for moving options
32956
+ // This is used by testing
32769
32957
  this.moveRightOptionToIndex = (option, index) => {
32770
32958
  // eslint-disable-next-line react/no-string-refs
32771
32959
  // @ts-expect-error - TS2339 - Property 'moveOptionToIndex' does not exist on type 'ReactInstance'.
@@ -32965,12 +33153,16 @@ class NumberInput extends React.Component {
32965
33153
  this.state = {
32966
33154
  format: this.props.format
32967
33155
  };
33156
+ /* Return the current "value" of this input
33157
+ * If empty, it returns the placeholder (if it is a number) or null
33158
+ */
32968
33159
  this.getValue = () => {
32969
33160
  return this.parseInputValue(
32970
33161
  // @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
32971
33162
  ReactDOM__default.findDOMNode(this.refs.input).value // eslint-disable-line react/no-string-refs
32972
33163
  );
32973
33164
  };
33165
+ /* Return the current string value of this input */
32974
33166
  this.getStringValue = () => {
32975
33167
  // @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
32976
33168
  return ReactDOM__default.findDOMNode(this.refs.input).value.toString(); // eslint-disable-line react/no-string-refs
@@ -32983,6 +33175,7 @@ class NumberInput extends React.Component {
32983
33175
  const result = firstNumericalParse(value);
32984
33176
  return _.isFinite(result) ? result : this.props.value;
32985
33177
  };
33178
+ /* Set text input focus to this input */
32986
33179
  this.focus = () => {
32987
33180
  // @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
32988
33181
  ReactDOM__default.findDOMNode(this.refs.input).focus(); // eslint-disable-line react/no-string-refs
@@ -33104,10 +33297,6 @@ class NumberInput extends React.Component {
33104
33297
  this._setValue(this.props.value, this.state.format);
33105
33298
  }
33106
33299
  }
33107
-
33108
- /* Return the current "value" of this input
33109
- * If empty, it returns the placeholder (if it is a number) or null
33110
- */
33111
33300
  }
33112
33301
  NumberInput.propTypes = {
33113
33302
  value: PropTypes.number,
@@ -33204,6 +33393,7 @@ const getMatrixSize = function getMatrixSize(matrix) {
33204
33393
  class Matrix extends React.Component {
33205
33394
  constructor(...args) {
33206
33395
  super(...args);
33396
+ // @ts-expect-error - TS2564 - Property 'cursorPosition' has no initializer and is not definitely assigned in the constructor.
33207
33397
  this.cursorPosition = void 0;
33208
33398
  this.state = {
33209
33399
  enterTheMatrix: 0
@@ -34933,6 +35123,9 @@ class NumberLine extends React.Component {
34933
35123
  assert$3(_.isFinite(x));
34934
35124
  return x;
34935
35125
  };
35126
+ // This function is intended to be used by the client code
35127
+ // and by test code to directly set the target number line
35128
+ // position
34936
35129
  this.movePosition = targetPosition => {
34937
35130
  this.change({
34938
35131
  numLinePosition: targetPosition
@@ -35002,6 +35195,7 @@ class NumberLine extends React.Component {
35002
35195
  rel: newRel
35003
35196
  });
35004
35197
  };
35198
+ // @ts-expect-error - TS2322 - Type '(props: any) => any[]' is not assignable to type '(arg1: any) => [number, number]'.
35005
35199
  this._getInequalityEndpoint = props => {
35006
35200
  const isGreater = _(["ge", "gt"]).contains(props.rel);
35007
35201
  const widthInPixels = 400;
@@ -35013,6 +35207,7 @@ class NumberLine extends React.Component {
35013
35207
  const end = isGreater ? [right, 0] : [left, 0];
35014
35208
  return end;
35015
35209
  };
35210
+ // @ts-expect-error - TS2322 - Type '(props: any) => Element | null' is not assignable to type '(arg1: any) => ReactElement<any, string | JSXElementConstructor<any>>'.
35016
35211
  this._renderInequality = props => {
35017
35212
  if (props.isInequality) {
35018
35213
  const end = this._getInequalityEndpoint(props);
@@ -35269,6 +35464,7 @@ const PropTypePosition = PropTypes.shape({
35269
35464
  class Card extends React.Component {
35270
35465
  constructor(...args) {
35271
35466
  super(...args);
35467
+ // @ts-expect-error - TS2564 - Property 'mouseMoveUpBound' has no initializer and is not definitely assigned in the constructor.
35272
35468
  this.mouseMoveUpBound = void 0;
35273
35469
  this.state = {
35274
35470
  dragging: false
@@ -35649,6 +35845,9 @@ class Orderer extends React.Component {
35649
35845
  }
35650
35846
  return draggableOffset.left + draggableWidth / 2 < bankOffset.left + bankWidth;
35651
35847
  };
35848
+ // This component makes use of a lot of DOM manipulation
35849
+ // For testing and direct manipulation of values there's a function
35850
+ // to directly set the list value
35652
35851
  this.setListValues = values => {
35653
35852
  const list = values.map(value => {
35654
35853
  return {
@@ -36605,6 +36804,7 @@ class HighlightSetRenderer extends React.PureComponent {
36605
36804
  hoveredHighlightKey: null,
36606
36805
  hoveringTooltipFor: null
36607
36806
  };
36807
+ // eslint-disable-next-line react/sort-comp
36608
36808
  this._highlightRenderers = {};
36609
36809
  this._handleMouseMove = e => {
36610
36810
  const mouseClientPosition = {
@@ -37052,11 +37252,15 @@ class WordIndexer extends React.PureComponent {
37052
37252
  class HighlightableContent extends React.PureComponent {
37053
37253
  constructor(...args) {
37054
37254
  super(...args);
37255
+ // References to the mounted container and content divs.
37055
37256
  this._container = void 0;
37056
37257
  this._content = void 0;
37057
37258
  this.state = {
37058
37259
  wordRanges: []
37059
37260
  };
37261
+ /**
37262
+ * Add the given DOMHighlight to the current set.
37263
+ */
37060
37264
  this._handleAddHighlight = highlight => {
37061
37265
  const newDomHighlights = addHighlight(this._getDOMHighlights(), highlight);
37062
37266
  const newSerializedHighlights = {};
@@ -37065,6 +37269,10 @@ class HighlightableContent extends React.PureComponent {
37065
37269
  }
37066
37270
  this.props.onSerializedHighlightsUpdate(newSerializedHighlights);
37067
37271
  };
37272
+ /**
37273
+ * Remove the given highlight from the list, and call our callback with the
37274
+ * new set of highlights.
37275
+ */
37068
37276
  this._handleRemoveHighlight = keyToRemove => {
37069
37277
  const {
37070
37278
  serializedHighlights
@@ -37074,6 +37282,10 @@ class HighlightableContent extends React.PureComponent {
37074
37282
  delete newSerializedHighlights[keyToRemove];
37075
37283
  this.props.onSerializedHighlightsUpdate(newSerializedHighlights);
37076
37284
  };
37285
+ /**
37286
+ * When our WordIndexer sends us a new cache of word ranges, store it in
37287
+ * our component state.
37288
+ */
37077
37289
  this._handleWordsUpdate = wordRanges => {
37078
37290
  this.setState({
37079
37291
  wordRanges
@@ -37104,11 +37316,6 @@ class HighlightableContent extends React.PureComponent {
37104
37316
  }
37105
37317
  return domHighlights;
37106
37318
  }
37107
-
37108
- /**
37109
- * Add the given DOMHighlight to the current set.
37110
- */
37111
-
37112
37319
  render() {
37113
37320
  const highlights = this._getDOMHighlights();
37114
37321
 
@@ -37202,6 +37409,7 @@ function getInitialParseState() {
37202
37409
  class RefStart extends React.Component {
37203
37410
  constructor(...args) {
37204
37411
  super(...args);
37412
+ // @ts-expect-error - TS2322 - Type '() => React.ReactNode' is not assignable to type '() => ReactElement<any, string | JSXElementConstructor<any>>'.
37205
37413
  this.getRefContent = () => {
37206
37414
  return this.props.refContent;
37207
37415
  };
@@ -37211,10 +37419,7 @@ class RefStart extends React.Component {
37211
37419
  style: REF_STYLE
37212
37420
  }, i18n.doNotTranslate("_"));
37213
37421
  }
37214
-
37215
- // @ts-expect-error - TS2322 - Type '() => React.ReactNode' is not assignable to type '() => ReactElement<any, string | JSXElementConstructor<any>>'.
37216
37422
  }
37217
-
37218
37423
  class RefEnd extends React.Component {
37219
37424
  render() {
37220
37425
  return /*#__PURE__*/React.createElement("span", {
@@ -37575,12 +37780,19 @@ const styles$8 = StyleSheet.create({
37575
37780
  zIndex: -1
37576
37781
  }
37577
37782
  });
37783
+
37784
+ // The result of the `transform` function (end of this file)
37785
+
37786
+ // Information about a passage reference, used in inter-widgets.
37787
+
37578
37788
  class Passage extends React.Component {
37579
37789
  constructor(...args) {
37580
37790
  super(...args);
37581
37791
  this._contentRef = void 0;
37582
37792
  this._lineHeightMeasurerRef = void 0;
37793
+ // @ts-expect-error - TS2564 - Property '_onResize' has no initializer and is not definitely assigned in the constructor.
37583
37794
  this._onResize = void 0;
37795
+ // @ts-expect-error - TS2564 - Property '_stylesAppiedTimer' has no initializer and is not definitely assigned in the constructor.
37584
37796
  this._stylesAppiedTimer = void 0;
37585
37797
  this.state = {
37586
37798
  nLines: null,
@@ -37609,7 +37821,7 @@ class Passage extends React.Component {
37609
37821
  // height changes we expect are subpixel changes when the user
37610
37822
  // zooms in/out, and the only way to listen for zoom events is to
37611
37823
  // listen for resize events.
37612
- (_this$_lineHeightMeas = this._lineHeightMeasurerRef) == null ? void 0 : _this$_lineHeightMeas.measureLineHeight();
37824
+ (_this$_lineHeightMeas = this._lineHeightMeasurerRef) == null || _this$_lineHeightMeas.measureLineHeight();
37613
37825
  this._updateState();
37614
37826
  }, 500);
37615
37827
  window.addEventListener("resize", this._onResize);
@@ -38028,14 +38240,10 @@ var PassageRefTarget$1 = {
38028
38240
  const {
38029
38241
  deepEq: deepEq$1
38030
38242
  } = Util;
38031
- const BAR = "bar";
38032
- const LINE = "line";
38033
- const PIC = "pic";
38034
- const HISTOGRAM = "histogram";
38035
- const DOTPLOT = "dotplot";
38036
38243
  class Plotter extends React.Component {
38037
38244
  constructor(..._args) {
38038
38245
  super(..._args);
38246
+ // @ts-expect-error - TS2564 - Property 'shouldSetupGraphie' has no initializer and is not definitely assigned in the constructor.
38039
38247
  this.shouldSetupGraphie = void 0;
38040
38248
  this._isMounted = false;
38041
38249
  this.horizHairline = void 0;
@@ -38071,11 +38279,11 @@ class Plotter extends React.Component {
38071
38279
  self.graphie = graphie;
38072
38280
  self.graphie.pics = [];
38073
38281
  self.graphie.dotTicks = [];
38074
- const isBar = self.props.type === BAR;
38075
- const isLine = self.props.type === LINE;
38076
- const isPic = self.props.type === PIC;
38077
- const isHistogram = self.props.type === HISTOGRAM;
38078
- const isDotplot = self.props.type === DOTPLOT;
38282
+ const isBar = self.props.type === "bar";
38283
+ const isLine = self.props.type === "line";
38284
+ const isPic = self.props.type === "pic";
38285
+ const isHistogram = self.props.type === "histogram";
38286
+ const isDotplot = self.props.type === "dotplot";
38079
38287
  const isTiledPlot = isPic || isDotplot;
38080
38288
  const config = {};
38081
38289
  const c = config; // c for short
@@ -38253,7 +38461,7 @@ class Plotter extends React.Component {
38253
38461
  }
38254
38462
  };
38255
38463
  this.showHairlines = point => {
38256
- if (this.props.apiOptions.isMobile && this.props.markings !== "none") {
38464
+ if (this.props.apiOptions.isMobile) {
38257
38465
  // Hairlines are already initialized when the graph is loaded, so
38258
38466
  // here we just move them to the updated location and make them
38259
38467
  // visible.
@@ -38308,7 +38516,7 @@ class Plotter extends React.Component {
38308
38516
 
38309
38517
  // The deferred measurements returned from `labelCategory`.
38310
38518
  const categoryHeightPromises = [];
38311
- if (self.props.type === HISTOGRAM) {
38519
+ if (self.props.type === "histogram") {
38312
38520
  // Histograms with n labels/categories have n - 1 buckets
38313
38521
  _.times(self.props.categories.length - 1, function (i) {
38314
38522
  self.setupBar({
@@ -38338,26 +38546,26 @@ class Plotter extends React.Component {
38338
38546
  _.each(self.props.categories, function (category, i) {
38339
38547
  const startHeight = self.state.values[i];
38340
38548
  let x;
38341
- if (self.props.type === BAR) {
38549
+ if (self.props.type === "bar") {
38342
38550
  x = self.setupBar({
38343
38551
  index: i,
38344
38552
  startHeight: startHeight,
38345
38553
  config: config,
38346
38554
  isHistogram: false
38347
38555
  });
38348
- } else if (self.props.type === LINE) {
38556
+ } else if (self.props.type === "line") {
38349
38557
  x = self.setupLine(i, startHeight, config);
38350
- } else if (self.props.type === PIC) {
38558
+ } else if (self.props.type === "pic") {
38351
38559
  x = self.setupPic(i, config);
38352
- } else if (self.props.type === DOTPLOT) {
38560
+ } else if (self.props.type === "dotplot") {
38353
38561
  x = self.setupDotplot(i, config);
38354
38562
  }
38355
38563
  let tickStart = 0;
38356
38564
  let tickEnd = -6 / c.scale[1];
38357
- if (self.props.type === DOTPLOT && !isMobile) {
38565
+ if (self.props.type === "dotplot" && !isMobile) {
38358
38566
  tickStart = -tickEnd;
38359
38567
  }
38360
- if (self.props.type === DOTPLOT) {
38568
+ if (self.props.type === "dotplot") {
38361
38569
  // Dotplot lets you specify to only show labels every 'n'
38362
38570
  // ticks. It also looks nicer if it makes the labelled
38363
38571
  // ticks a bit bigger.
@@ -38483,7 +38691,7 @@ class Plotter extends React.Component {
38483
38691
  },
38484
38692
  onMove: function () {
38485
38693
  const y = config.graph.lines[i].coord()[1];
38486
- const values = _.clone(self.state.values);
38694
+ const values = [...self.state.values];
38487
38695
  values[i] = y;
38488
38696
  self.setState({
38489
38697
  values: values
@@ -38528,7 +38736,7 @@ class Plotter extends React.Component {
38528
38736
  // Snap the line back into range.
38529
38737
  this.transform();
38530
38738
  }
38531
- const values = _.clone(self.state.values);
38739
+ const values = [...self.state.values];
38532
38740
  values[i] = y;
38533
38741
  self.setState({
38534
38742
  values: values
@@ -38542,6 +38750,12 @@ class Plotter extends React.Component {
38542
38750
  scaleBar(i, startHeight);
38543
38751
  return x;
38544
38752
  };
38753
+ /**
38754
+ * Renders a segment of an interactive line to the plotter graph
38755
+ * @param i the index of the point to render
38756
+ * @param startHeight the initial height of the given point
38757
+ * @param config the graph setup, such as scale and dimensions
38758
+ */
38545
38759
  this.setupLine = (i, startHeight, config) => {
38546
38760
  const isMobile = this.props.apiOptions.isMobile;
38547
38761
  const self = this;
@@ -38557,7 +38771,7 @@ class Plotter extends React.Component {
38557
38771
  }],
38558
38772
  onMove: function () {
38559
38773
  const y = c.graph.points[i].coord()[1];
38560
- const values = _.clone(self.state.values);
38774
+ const values = [...self.state.values];
38561
38775
  values[i] = y;
38562
38776
  self.setState({
38563
38777
  values: values
@@ -38598,7 +38812,7 @@ class Plotter extends React.Component {
38598
38812
  });
38599
38813
  c.graph.points[i].onMove = function (x, y) {
38600
38814
  y = Math.min(Math.max(y, 0), c.dimY);
38601
- const values = _.clone(self.state.values);
38815
+ const values = [...self.state.values];
38602
38816
  values[i] = y;
38603
38817
  self.setState({
38604
38818
  values: values
@@ -38711,7 +38925,7 @@ class Plotter extends React.Component {
38711
38925
  return x;
38712
38926
  };
38713
38927
  this.setPicHeight = (i, y) => {
38714
- const values = _.clone(this.state.values);
38928
+ const values = [...this.state.values];
38715
38929
  values[i] = y;
38716
38930
  this.drawPicHeights(values, this.state.values);
38717
38931
  this.setState({
@@ -38738,7 +38952,7 @@ class Plotter extends React.Component {
38738
38952
  _.each(ps, function (pic, j) {
38739
38953
  const y = (j + 1) * self.props.scaleY;
38740
38954
  const show = y <= values[i];
38741
- if (self.props.type === DOTPLOT) {
38955
+ if (self.props.type === "dotplot") {
38742
38956
  const wasShown = y <= prevValues[i];
38743
38957
  const wasJustShown = show && !wasShown;
38744
38958
  if (wasJustShown) {
@@ -38805,7 +39019,7 @@ class Plotter extends React.Component {
38805
39019
  }
38806
39020
  }
38807
39021
  Plotter.defaultProps = {
38808
- type: BAR,
39022
+ type: "bar",
38809
39023
  labels: ["", ""],
38810
39024
  categories: [""],
38811
39025
  scaleY: 1,
@@ -39212,6 +39426,7 @@ const maxSampleSize = 1000;
39212
39426
  class Histogram extends React.Component {
39213
39427
  constructor(...args) {
39214
39428
  super(...args);
39429
+ /* Renders the vertical line that users can drag across the histogram. */
39215
39430
  this._renderThresholdLine = () => {
39216
39431
  // Recall the the y-range goes from [-1, yMax] to allow for ticks on
39217
39432
  // the x-axis.
@@ -39235,6 +39450,7 @@ class Histogram extends React.Component {
39235
39450
  onMove: this.handleMouseInteraction
39236
39451
  }, _.map(coords, invisiblePointForCoord));
39237
39452
  };
39453
+ /* Renders the shaded circle in the top right. */
39238
39454
  this._renderCircle = () => {
39239
39455
  const data = this.props.data;
39240
39456
 
@@ -39310,6 +39526,7 @@ class Histogram extends React.Component {
39310
39526
  };
39311
39527
  return [proportionBelow > 0 && plotBelowCircle(), proportionBelow < 1 && plotAboveCircle(), plotLabel()];
39312
39528
  };
39529
+ /* Renders the actual bars of the histogram. */
39313
39530
  this._renderData = () => {
39314
39531
  const data = this.props.data;
39315
39532
  // @ts-expect-error - TS2554 - Expected 1 arguments, but got 0.
@@ -39399,6 +39616,7 @@ class Histogram extends React.Component {
39399
39616
  threshold: point[0]
39400
39617
  });
39401
39618
  };
39619
+ /* Convenience functions that help calculate props based on other props. */
39402
39620
  this._range = props => {
39403
39621
  const defaultRange = [[0, 100], [-1, 10]];
39404
39622
  props = props || this.props;
@@ -39441,9 +39659,6 @@ class Histogram extends React.Component {
39441
39659
  });
39442
39660
  }
39443
39661
  }
39444
-
39445
- /* Renders the vertical line that users can drag across the histogram. */
39446
-
39447
39662
  render() {
39448
39663
  const data = this.props.data;
39449
39664
  // @ts-expect-error - TS2554 - Expected 1 arguments, but got 0.
@@ -39493,6 +39708,7 @@ Histogram.defaultProps = {
39493
39708
  class Simulator extends React.Component {
39494
39709
  constructor(..._args) {
39495
39710
  super(..._args);
39711
+ // @ts-expect-error - TS2564 - Property 'generateNumber' has no initializer and is not definitely assigned in the constructor.
39496
39712
  this.generateNumber = void 0;
39497
39713
  this.state = {
39498
39714
  invalidInput: false
@@ -39532,6 +39748,7 @@ class Simulator extends React.Component {
39532
39748
  userProportion: userProportion
39533
39749
  }, cb);
39534
39750
  };
39751
+ // @ts-expect-error - TS2322 - Type '(sampleSize: any, cb: any) => void' is not assignable to type '(number: any) => void'.
39535
39752
  this.handleSampleSizeChange = (sampleSize, cb) => {
39536
39753
  if (sampleSize != null) {
39537
39754
  sampleSize = Math.min(maxSampleSize, Math.max(0, Math.floor(sampleSize)));
@@ -39574,6 +39791,7 @@ class Simulator extends React.Component {
39574
39791
  };
39575
39792
  return getSampleDistribution(props.sampleSize, props.numTrials, props.userProportion);
39576
39793
  };
39794
+ /* InputPath API */
39577
39795
  this.getInputPaths = () => {
39578
39796
  return [["userProportion"], ["sampleSize"]];
39579
39797
  };
@@ -39783,6 +40001,7 @@ const VERTICAL = "vertical";
39783
40001
  class Sorter extends React.Component {
39784
40002
  constructor(...args) {
39785
40003
  super(...args);
40004
+ // @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
39786
40005
  this._isMounted = void 0;
39787
40006
  this.state = {
39788
40007
  changed: false
@@ -40604,6 +40823,7 @@ const Transformations = {
40604
40823
  vector: [x, y]
40605
40824
  };
40606
40825
  };
40826
+ /* InputPath API */
40607
40827
  this.setInputValue = (path, value, cb) => {
40608
40828
  const id = _.first(path);
40609
40829
  const vector = _.clone(this.state.vector);
@@ -40741,6 +40961,7 @@ const Transformations = {
40741
40961
  center: [centerX, centerY]
40742
40962
  };
40743
40963
  };
40964
+ /* InputPath API */
40744
40965
  this.setInputValue = (path, value, cb) => {
40745
40966
  const id = _.first(path);
40746
40967
  let angleDeg = _.clone(this.state.angleDeg);
@@ -40919,6 +41140,7 @@ const Transformations = {
40919
41140
  line: [[x1, y1], [x2, y2]]
40920
41141
  };
40921
41142
  };
41143
+ /* InputPath API */
40922
41144
  this.setInputValue = (path, value, cb) => {
40923
41145
  const id = _.first(path);
40924
41146
  let j;
@@ -41081,6 +41303,7 @@ const Transformations = {
41081
41303
  center: [x, y]
41082
41304
  };
41083
41305
  };
41306
+ /* InputPath API */
41084
41307
  this.setInputValue = (path, value, cb) => {
41085
41308
  const id = _.first(path);
41086
41309
  let scale = this.state.scale;
@@ -41727,13 +41950,19 @@ class AddTransformBar extends React.Component {
41727
41950
  }));
41728
41951
  }
41729
41952
  }
41953
+
41954
+ // there's no transform in the exports
41955
+
41730
41956
  class Transformer extends React.Component {
41731
41957
  constructor(..._args) {
41732
41958
  super(..._args);
41959
+ // @ts-expect-error - TS2564 - Property 'tools' has no initializer and is not definitely assigned in the constructor.
41733
41960
  this.tools = void 0;
41734
41961
  this.currentTool = void 0;
41962
+ // @ts-expect-error - TS2564 - Property 'transformations' has no initializer and is not definitely assigned in the constructor.
41735
41963
  this.transformations = void 0;
41736
41964
  this.shape = void 0;
41965
+ // This is not the same as TransformerShape
41737
41966
  this.dilationCircle = void 0;
41738
41967
  this.rotatePoint = void 0;
41739
41968
  this.rotateHandle = void 0;
@@ -41798,11 +42027,18 @@ class Transformer extends React.Component {
41798
42027
  dilation: _.clone(this.props.tools.dilation)
41799
42028
  };
41800
42029
  };
42030
+ /* Applies all transformations in `transformations`
42031
+ * to the starting shape, and updates this.transformations
42032
+ * to reflect this
42033
+ *
42034
+ * Usually called with this.props.transformations
42035
+ */
41801
42036
  this.setTransformations = transformations => {
41802
42037
  this.resetCoords();
41803
42038
  this.transformations = _.clone(transformations);
41804
42039
  _.each(this.transformations, this.applyTransform);
41805
42040
  };
42041
+ // the polygon that we transform
41806
42042
  this.addTransformerShape = (shape, translatable) => {
41807
42043
  const self = this;
41808
42044
  const graphie = this.graphie();
@@ -41909,22 +42145,27 @@ class Transformer extends React.Component {
41909
42145
  this.addTranslationTool = () => {
41910
42146
  var _this$shape, _this$shape2;
41911
42147
  const self = this;
41912
- (_this$shape = this.shape) == null ? void 0 : _this$shape.remove();
42148
+ (_this$shape = this.shape) == null || _this$shape.remove();
41913
42149
  this.addTransformerShape((_this$shape2 = this.shape) == null ? void 0 : _this$shape2.toJSON(), /* translatable */true);
41914
42150
  return {
41915
42151
  remove: function () {
41916
42152
  var _self$shape, _self$shape2;
41917
- (_self$shape = self.shape) == null ? void 0 : _self$shape.remove();
42153
+ (_self$shape = self.shape) == null || _self$shape.remove();
41918
42154
  self.addTransformerShape((_self$shape2 = self.shape) == null ? void 0 : _self$shape2.toJSON(), /* translatable */false);
41919
42155
  }
41920
42156
  };
41921
42157
  };
42158
+ // Snaps a coord to this.graphie()'s snap
42159
+ // @ts-expect-error - TS2322 - Type '(coord: Coord) => number[]' is not assignable to type '(arg1: Coord) => Coord'.
41922
42160
  this.snapCoord = coord => {
41923
42161
  const graphie = this.graphie();
41924
42162
  return _.map(coord, function (val, dim) {
41925
42163
  return KhanMath.roundToNearest(graphie.snap[dim], val);
41926
42164
  });
41927
42165
  };
42166
+ // Normalize the coords into something that fits the new 45 degree
42167
+ // reflection line.
42168
+ // @ts-expect-error - TS2322 - Type '(messyCoords: [Coord, Coord]) => any[]' is not assignable to type '(arg1: [Coord, Coord]) => [Coord, Coord]'.
41928
42169
  this.normalizeReflectionCoords = messyCoords => {
41929
42170
  // @ts-expect-error - TS2345 - Argument of type 'Point' is not assignable to parameter of type 'Coord'.
41930
42171
  const midpoint = this.snapCoord(line.midpoint(messyCoords));
@@ -42083,6 +42324,12 @@ class Transformer extends React.Component {
42083
42324
  }
42084
42325
  };
42085
42326
  };
42327
+ /* Scales a distance from the default range of
42328
+ * [-10, 10] to the current this.props.graph.range
42329
+ *
42330
+ * Used for sizing various transformation tools
42331
+ * (rotation handle, dilation circle)
42332
+ */
42086
42333
  this.scaleToCurrentRange = dist => {
42087
42334
  // eslint-disable-next-line react/no-string-refs
42088
42335
  // @ts-expect-error - TS2339 - Property 'props' does not exist on type 'ReactInstance'.
@@ -42146,8 +42393,8 @@ class Transformer extends React.Component {
42146
42393
  return {
42147
42394
  remove: function () {
42148
42395
  var _self$rotateHandle, _self$rotatePoint;
42149
- (_self$rotateHandle = self.rotateHandle) == null ? void 0 : _self$rotateHandle.remove();
42150
- (_self$rotatePoint = self.rotatePoint) == null ? void 0 : _self$rotatePoint.remove();
42396
+ (_self$rotateHandle = self.rotateHandle) == null || _self$rotateHandle.remove();
42397
+ (_self$rotatePoint = self.rotatePoint) == null || _self$rotatePoint.remove();
42151
42398
  }
42152
42399
  };
42153
42400
  };
@@ -42217,10 +42464,13 @@ class Transformer extends React.Component {
42217
42464
  return {
42218
42465
  remove: function () {
42219
42466
  var _self$dilationCircle;
42220
- (_self$dilationCircle = self.dilationCircle) == null ? void 0 : _self$dilationCircle.remove();
42467
+ (_self$dilationCircle = self.dilationCircle) == null || _self$dilationCircle.remove();
42221
42468
  }
42222
42469
  };
42223
42470
  };
42471
+ // returns a transformation object representing a rotation
42472
+ // rounds the angle to the nearest 15 degrees
42473
+ // @ts-expect-error - TS2322 - Type '(center: Coord, angleChanged: number) => { type: "rotation"; center: Coord; angleDeg: number; }' is not assignable to type '(arg1: Coord, arg2: number) => PerseusTransformerTransformation'.
42224
42474
  this.getRotationTransformFromAngle = (center, angleChanged) => {
42225
42475
  angleChanged = (angleChanged + 360) % 360;
42226
42476
  if (angleChanged > 180) {
@@ -42235,10 +42485,13 @@ class Transformer extends React.Component {
42235
42485
  angleDeg: roundedAngle
42236
42486
  };
42237
42487
  };
42488
+ // apply and save a transform
42238
42489
  this.doTransform = (transform, callback) => {
42239
42490
  this.applyTransform(transform);
42240
42491
  this.addTransform(transform, callback);
42241
42492
  };
42493
+ // apply a transform to our polygon (without modifying our transformation
42494
+ // list)
42242
42495
  this.applyTransform = transform => {
42243
42496
  if (this.props.graphMode !== "static") {
42244
42497
  const transformFunc = TransformOps.apply(transform);
@@ -42246,6 +42499,7 @@ class Transformer extends React.Component {
42246
42499
  this.applyCoordTransformation(transformFunc);
42247
42500
  }
42248
42501
  };
42502
+ // transform our polygon by transforming each point using a given function
42249
42503
  this.applyCoordTransformation = pointTransform => {
42250
42504
  var _this$shape3;
42251
42505
  _.each(this.shape.points, function (point) {
@@ -42253,7 +42507,7 @@ class Transformer extends React.Component {
42253
42507
  const newCoord = pointTransform(point.coord);
42254
42508
  point.setCoord(newCoord);
42255
42509
  });
42256
- (_this$shape3 = this.shape) == null ? void 0 : _this$shape3.update();
42510
+ (_this$shape3 = this.shape) == null || _this$shape3.update();
42257
42511
  };
42258
42512
  this.resetCoords = () => {
42259
42513
  var _this$shape4;
@@ -42261,8 +42515,9 @@ class Transformer extends React.Component {
42261
42515
  _.each(this.shape.points, function (point, i) {
42262
42516
  point.setCoord(startCoords[i]);
42263
42517
  });
42264
- (_this$shape4 = this.shape) == null ? void 0 : _this$shape4.update();
42518
+ (_this$shape4 = this.shape) == null || _this$shape4.update();
42265
42519
  };
42520
+ // Remove the last transformation
42266
42521
  this.handleUndoClick = () => {
42267
42522
  // eslint-disable-next-line react/no-string-refs
42268
42523
  // @ts-expect-error - TS2339 - Property 'changeSelected' does not exist on type 'ReactInstance'.
@@ -42280,6 +42535,7 @@ class Transformer extends React.Component {
42280
42535
  // @ts-expect-error - TS2345 - Argument of type '(arg1: any) => unknown' is not assignable to parameter of type '() => unknown'.
42281
42536
  callback);
42282
42537
  };
42538
+ // add a transformation to our props list of transformation
42283
42539
  this.addTransform = (transform, callback) => {
42284
42540
  this.transformations = TransformOps.append(this.transformations, transform);
42285
42541
  this.props.onChange({
@@ -42301,6 +42557,12 @@ class Transformer extends React.Component {
42301
42557
  this.simpleValidate = rubric => {
42302
42558
  return Transformer.validate(this.getUserInput(), rubric);
42303
42559
  };
42560
+ /**
42561
+ * Calculate where the coordinates would be if they were
42562
+ * moved, even if we're in formal mode with no movement
42563
+ * (and thus the actual movablepoints may not have moved
42564
+ */
42565
+ // @ts-expect-error - TS2322 - Type '() => [Coord, Coord] | readonly Coord[] | [Coord, Coord, Coord]' is not assignable to type '() => Coord'.
42304
42566
  this.getCoords = () => {
42305
42567
  const startCoords = this.props.starting.shape.coords;
42306
42568
  const transforms = this.props.transformations;
@@ -42336,6 +42598,7 @@ class Transformer extends React.Component {
42336
42598
  }
42337
42599
  };
42338
42600
  };
42601
+ /* InputPath API */
42339
42602
  this._handleFocus = (...path) => {
42340
42603
  this.props.onFocus(path);
42341
42604
  };
@@ -43426,6 +43689,7 @@ class OldUnitInput extends React.Component {
43426
43689
  this.getUserInput = () => {
43427
43690
  return this.props.value;
43428
43691
  };
43692
+ // begin mobile stuff
43429
43693
  this.getInputPaths = () => {
43430
43694
  // The widget itself is an input, so we return a single empty list to
43431
43695
  // indicate this.
@@ -43567,7 +43831,6 @@ class OldUnitInput extends React.Component {
43567
43831
  clearTimeout(this._errorTimeout);
43568
43832
  }
43569
43833
  // end mobile stuff
43570
-
43571
43834
  // TODO(joel) think about showing the error buddy
43572
43835
  render() {
43573
43836
  return /*#__PURE__*/React.createElement("div", {
@@ -43684,6 +43947,9 @@ const DEFAULT_HEIGHT = 720;
43684
43947
  const KA_EMBED = "{host}/embed_video?slug={slug}" + "&internal_video_only=1";
43685
43948
  const IS_URL = /^https?:\/\//;
43686
43949
  const IS_KA_SITE = /(khanacademy\.org|localhost)/;
43950
+
43951
+ // exports has no 'transform'
43952
+
43687
43953
  /**
43688
43954
  * Video renderer.
43689
43955
  */
@@ -43805,7 +44071,7 @@ const init = function init(options) {
43805
44071
 
43806
44072
  // This file is processed by a Rollup plugin (replace) to inject the production
43807
44073
  const libName = "@khanacademy/perseus";
43808
- const libVersion = "12.4.0";
44074
+ const libVersion = "13.0.0";
43809
44075
  addLibraryVersionToPerseusDebug(libName, libVersion);
43810
44076
 
43811
44077
  const apiVersion = {
@@ -44064,6 +44330,12 @@ const styles$5 = StyleSheet.create({
44064
44330
  class HintsRenderer extends React.Component {
44065
44331
  constructor(...args) {
44066
44332
  super(...args);
44333
+ // The isFinalHelpPage property determines if the user has requested help
44334
+ // after answering an exercise question incorrectly, which differs from
44335
+ // the case when the user is requesting successive hints. In the case
44336
+ // where isFinalHelpPage property is true, we want to display all hints.
44337
+ // We know the user is on the final help page when the hintsVisible
44338
+ // property jumps from 0 to the total number of hints.
44067
44339
  this.state = {
44068
44340
  isFinalHelpPage: false
44069
44341
  };
@@ -44307,6 +44579,9 @@ const styles$4 = StyleSheet.create({
44307
44579
  });
44308
44580
 
44309
44581
  /* eslint-disable @khanacademy/ts-no-error-suppressions */
44582
+
44583
+ // This represents the shape of any component that uses this ProvideKeypad
44584
+ // mixin.
44310
44585
  // NOTE: This is not a real component. It's a collection of methods used to
44311
44586
  // create and manage a Keypad instances.
44312
44587
  // TODO(LP-10789): replace this with a React Context object to pass information
@@ -44333,7 +44608,7 @@ const ProvideKeypad = {
44333
44608
  // React tree. We may also want to add this keypad asynchronously
44334
44609
  // or on-demand in the future.
44335
44610
  _this._keypadContainer = document.createElement("div");
44336
- (_document$body = document.body) == null ? void 0 : _document$body.appendChild(_this._keypadContainer);
44611
+ (_document$body = document.body) == null || _document$body.appendChild(_this._keypadContainer);
44337
44612
  render( /*#__PURE__*/React.createElement(MobileKeypad, {
44338
44613
  onElementMounted: element => {
44339
44614
  // NOTE(kevinb): The reason why this setState works is
@@ -44385,10 +44660,9 @@ const {
44385
44660
  * @depreciated use ServerItemRenderer
44386
44661
  */
44387
44662
  class ItemRenderer extends React.Component {
44388
- // @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
44389
-
44390
44663
  constructor(props) {
44391
44664
  super(props);
44665
+ // @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
44392
44666
  this.questionRenderer = void 0;
44393
44667
  this.hintsRenderer = void 0;
44394
44668
  this._currentFocus = void 0;
@@ -44399,6 +44673,7 @@ class ItemRenderer extends React.Component {
44399
44673
  this._onRendererBlur(oldFocus);
44400
44674
  }
44401
44675
  };
44676
+ // NOTE: this must remain as an arrow function because we pass it Renderer
44402
44677
  this.handleInteractWithWidget = widgetId => {
44403
44678
  const withRemoved = _.difference(this.state.questionHighlightedWidgets, [widgetId]);
44404
44679
  this.setState({
@@ -44533,7 +44808,9 @@ class ItemRenderer extends React.Component {
44533
44808
  this.props.onShowCalculator && this.props.onShowCalculator();
44534
44809
  }
44535
44810
  if (answerArea.periodicTable) {
44536
- this.props.onShowPeriodicTable && this.props.onShowPeriodicTable();
44811
+ this.props.onShowPeriodicTable && this.props.onShowPeriodicTable({
44812
+ showKey: answerArea.periodicTableWithKey
44813
+ });
44537
44814
  }
44538
44815
  if (answerArea.zTable) {
44539
44816
  this.props.onShowZTable && this.props.onShowZTable();
@@ -44629,9 +44906,6 @@ class ItemRenderer extends React.Component {
44629
44906
  const questionAreaInputPaths = this.questionRenderer.getInputPaths();
44630
44907
  return questionAreaInputPaths;
44631
44908
  }
44632
-
44633
- // NOTE: this must remain as an arrow function because we pass it Renderer
44634
-
44635
44909
  focus() {
44636
44910
  return this.questionRenderer.focus();
44637
44911
  }
@@ -44726,7 +45000,7 @@ class ItemRenderer extends React.Component {
44726
45000
  }
44727
45001
  };
44728
45002
  this.questionRenderer.restoreSerializedState(state.question, fireCallback);
44729
- (_this$hintsRenderer2 = this.hintsRenderer) == null ? void 0 : _this$hintsRenderer2.restoreSerializedState(state.hints, fireCallback);
45003
+ (_this$hintsRenderer2 = this.hintsRenderer) == null || _this$hintsRenderer2.restoreSerializedState(state.hints, fireCallback);
44730
45004
  }
44731
45005
  showRationalesForCurrentlySelectedChoices() {
44732
45006
  this.questionRenderer.showRationalesForCurrentlySelectedChoices();
@@ -44769,10 +45043,9 @@ const {
44769
45043
  } = objective_;
44770
45044
  /* eslint-disable-next-line react/no-unsafe */
44771
45045
  class ServerItemRenderer extends React.Component {
44772
- // @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
44773
-
44774
45046
  constructor(props) {
44775
45047
  super(props);
45048
+ // @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
44776
45049
  this.questionRenderer = void 0;
44777
45050
  this.hintsRenderer = void 0;
44778
45051
  this._currentFocus = void 0;
@@ -44795,6 +45068,8 @@ class ServerItemRenderer extends React.Component {
44795
45068
  this.props.apiOptions.interactionCallback();
44796
45069
  }
44797
45070
  };
45071
+ // This must be pre-bound otherwise SvgImage's shouldComponentUpdate
45072
+ // won't behave correctly and we'll get an infinite loop.
44798
45073
  this.setAssetStatus = (assetKey, status) => {
44799
45074
  // setState doesn't properly merge objects so we have to do it ourselves
44800
45075
  const assetStatuses = _extends({}, this.state.assetStatuses, {
@@ -45018,10 +45293,6 @@ class ServerItemRenderer extends React.Component {
45018
45293
  deselectIncorrectSelectedChoices() {
45019
45294
  this.questionRenderer.deselectIncorrectSelectedChoices();
45020
45295
  }
45021
-
45022
- // This must be pre-bound otherwise SvgImage's shouldComponentUpdate
45023
- // won't behave correctly and we'll get an infinite loop.
45024
-
45025
45296
  render() {
45026
45297
  const apiOptions = _extends({}, ApiOptions.defaults, this.props.apiOptions, {
45027
45298
  onFocusChange: this._handleFocusChange
@@ -45367,7 +45638,7 @@ class MultiButtonGroup extends React.Component {
45367
45638
  focus() {
45368
45639
  var _ReactDOM$findDOMNode;
45369
45640
  // @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'Element | Text'.
45370
- (_ReactDOM$findDOMNode = ReactDOM.findDOMNode(this)) == null ? void 0 : _ReactDOM$findDOMNode.focus();
45641
+ (_ReactDOM$findDOMNode = ReactDOM.findDOMNode(this)) == null || _ReactDOM$findDOMNode.focus();
45371
45642
  return true;
45372
45643
  }
45373
45644
  render() {
@@ -45540,7 +45811,6 @@ const symbStyle = {
45540
45811
  // on the page rather than reusing an instance (which will cause an error).
45541
45812
  // Also, it's useful for things which might look different depending on the
45542
45813
  // props.
45543
-
45544
45814
  const basic = [() => [/*#__PURE__*/React.createElement("span", {
45545
45815
  key: "plus",
45546
45816
  style: slightlyBig
@@ -45889,6 +46159,9 @@ var constants = /*#__PURE__*/Object.freeze({
45889
46159
  // A background image applied to various widgets.
45890
46160
 
45891
46161
  const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
46162
+ const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
46163
+
46164
+ // TODO(FEI-3983): Create proper types for these.
45892
46165
 
45893
46166
  /**
45894
46167
  * Traverses a {content, widgets, images} renderer props object,
@@ -46073,6 +46346,49 @@ var shapes = {
46073
46346
  * provided shape. If not, behavior is undefined and may not respect the type
46074
46347
  * signatures specified here.
46075
46348
  */
46349
+
46350
+ /**
46351
+ * The sequence of edges that lead to a particular node in a Tree.
46352
+ * Elements can be `string` to correspond to an ObjectNode key, or `number` to
46353
+ * correspond to an ArrayNode index.
46354
+ */
46355
+
46356
+ /**
46357
+ * These are function interfaces for mapping over various types of tree nodes.
46358
+ *
46359
+ * ArrayMapper is a bit more complicated than the leaf node mappers. It's
46360
+ * executed in the context of a `mapTree` call, after we've finished mapping
46361
+ * its child nodes, so the function has access to both the resulting array
46362
+ * (with mapped elements) and the original array (with the original untouched
46363
+ * elements).
46364
+ *
46365
+ * The ArrayMapper then has the opportunity to apply a final transformation to
46366
+ * the resulting array, like filtering certain elements or (in the hacky
46367
+ * MultiRenderer case) attaching a `renderHints` method to arrays of hint
46368
+ * renderers :)
46369
+ *
46370
+ * This is why `TreeMapper#setArrayMapper` must be called last: ArrayMapper's
46371
+ * types depend on the ContentMapper and HintMapper's types. And, since you can
46372
+ * only specify one mapper at a time in this builder interface (which is
46373
+ * necessary to provide default mappers in a type-safe way), you need your
46374
+ * dependencies to already be in place by the time you call `setArrayMapper`.
46375
+ * Otherwise, we'd have to set the ArrayMapper and *hope* that you *eventually*
46376
+ * provide a compatible ContentMapper and HintMapper, which is difficult to
46377
+ * prove at compile time.
46378
+ *
46379
+ * There's no ObjectMapper here, but not for any particular reason. We just
46380
+ * don't have a use case for it yet, so we haven't built it yet.
46381
+ */
46382
+
46383
+ /**
46384
+ * A TreeMapper is a collection of node mappers, which, together, compose the
46385
+ * behavior for mapping over an entire tree.
46386
+ *
46387
+ * This serves as the interface for the two TreeMapper classes, including both
46388
+ * the internal mapper properties that we care about, and the `mapTree`
46389
+ * function that the call site will use.
46390
+ */
46391
+
46076
46392
  /**
46077
46393
  * This is a TreeMapper that only has mappers specified for its leaf nodes; its
46078
46394
  * array mapper is the identity function.
@@ -46368,6 +46684,23 @@ function treeToItem(node) {
46368
46684
  }
46369
46685
 
46370
46686
  const _excluded = ["item", "children", "shape", "serializedState", "onSerializedStateUpdated"];
46687
+
46688
+ // TODO(mdr)
46689
+ // TODO(mdr)
46690
+ // TODO(mdr)
46691
+
46692
+ // @ts-expect-error - TS2315 - Type 'Tree' is not generic.
46693
+
46694
+ /**
46695
+ * TODO(somewhatabstract, JIRA-XXXX):
46696
+ * Some usage of this type somewhere is causing TypeScript to believe that these
46697
+ * elements should be components. Don't know where that is, to fix it up
46698
+ * properly. In reality, these types are just too hard to use and aren't
46699
+ * really helping us out as I now have to suppress this rather than
46700
+ * get value from the type. :(
46701
+ */ // @ts-expect-error - TS2315 - Type 'Tree' is not generic.
46702
+ // @ts-expect-error - TS2315 - Type 'Tree' is not generic.
46703
+ // @ts-expect-error - TS2315 - Type 'Tree' is not generic.
46371
46704
  class MultiRenderer extends React.Component {
46372
46705
  constructor(props) {
46373
46706
  super(props);
@@ -46651,7 +46984,7 @@ class MultiRenderer extends React.Component {
46651
46984
  return;
46652
46985
  }
46653
46986
  numCallbacks++;
46654
- (_data$ref2 = data.ref) == null ? void 0 : _data$ref2.restoreSerializedState(state, countCallback);
46987
+ (_data$ref2 = data.ref) == null || _data$ref2.restoreSerializedState(state, countCallback);
46655
46988
  });
46656
46989
  }
46657
46990
 
@@ -46963,5 +47296,5 @@ const EditorJsonify = {
46963
47296
  }
46964
47297
  };
46965
47298
 
46966
- export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
47299
+ export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
46967
47300
  //# sourceMappingURL=index.js.map