@khanacademy/perseus 19.1.7 → 19.1.9

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/index.js CHANGED
@@ -4237,22 +4237,13 @@ const InteractiveUtil = {
4237
4237
  }
4238
4238
  };
4239
4239
 
4240
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4241
-
4242
- function getDefaultExportFromCjs (x) {
4243
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
4244
- }
4245
-
4246
- var raphael = {exports: {}};
4247
-
4248
4240
  /*!
4249
4241
  * Raphael 1.5.2 - JavaScript Vector Library
4250
4242
  *
4251
4243
  * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
4252
4244
  * Licensed under the MIT (http://raphaeljs.com/license.html) license.
4253
4245
  */
4254
-
4255
- (function () {
4246
+ var Raphael$1 = (function () {
4256
4247
  var setAttr;
4257
4248
  if ("".trim) {
4258
4249
  setAttr = function (node, att, value) {
@@ -8429,7 +8420,7 @@ var raphael = {exports: {}};
8429
8420
  };
8430
8421
  R.el = elproto;
8431
8422
  R.st = Set[proto];
8432
- raphael.exports = R;
8423
+ return R;
8433
8424
  })();
8434
8425
 
8435
8426
  /**
@@ -8701,6 +8692,11 @@ function polar(r, th) {
8701
8692
  class Graphie$1 {
8702
8693
  #bounds;
8703
8694
  #drawingTransform;
8695
+
8696
+ // The primary drawing layer
8697
+
8698
+ // The layer that all visuals with mouse handlers are drawn into
8699
+
8704
8700
  isMobile = false;
8705
8701
  // Set up some reasonable defaults
8706
8702
  currentStyle = {
@@ -8717,7 +8713,7 @@ class Graphie$1 {
8717
8713
  constructor(el) {
8718
8714
  this.el = el;
8719
8715
  $__default["default"](el).css("position", "relative");
8720
- this.raphael = raphael.exports(el);
8716
+ this.raphael = Raphael$1(el);
8721
8717
 
8722
8718
  // For a sometimes-reproducible IE8 bug; doesn't affect SVG browsers at all
8723
8719
  $__default["default"](el).children("div").css("position", "absolute");
@@ -9076,7 +9072,7 @@ class Graphie$1 {
9076
9072
  // wrapper.setAttribute("data-graphie-type", "ellipse");
9077
9073
 
9078
9074
  // Create Raphael canvas
9079
- const localRaphael = raphael.exports(wrapper, width, height);
9075
+ const localRaphael = Raphael$1(wrapper, width, height);
9080
9076
  const visibleShape = localRaphael.ellipse(width / 2, height / 2, scaledRadii[0], scaledRadii[1]);
9081
9077
  return {
9082
9078
  wrapper: wrapper,
@@ -9143,7 +9139,7 @@ class Graphie$1 {
9143
9139
  });
9144
9140
 
9145
9141
  // Create Raphael canvas
9146
- const localRaphael = raphael.exports(wrapper, width, height);
9142
+ const localRaphael = Raphael$1(wrapper, width, height);
9147
9143
 
9148
9144
  // Calculate path
9149
9145
  const visibleShape = localRaphael.path(createPath(points));
@@ -9206,7 +9202,7 @@ class Graphie$1 {
9206
9202
  });
9207
9203
 
9208
9204
  // Create Raphael canvas
9209
- const localRaphael = raphael.exports(wrapper, width, height);
9205
+ const localRaphael = Raphael$1(wrapper, width, height);
9210
9206
 
9211
9207
  // Calculate path
9212
9208
  const path = "M" + start[0] + " " + start[1] + " " + "L" + end[0] + " " + end[1];
@@ -9430,7 +9426,7 @@ class Graphie$1 {
9430
9426
  postprocessDrawingResult(result) {
9431
9427
  // Bad heuristic for recognizing Raphael elements and sets
9432
9428
  const type = result.constructor.prototype;
9433
- if (type === raphael.exports.el || type === raphael.exports.st) {
9429
+ if (type === Raphael$1.el || type === Raphael$1.st) {
9434
9430
  result.attr(this.currentStyle);
9435
9431
  if (this.currentStyle.arrows) {
9436
9432
  result = this.addArrowheads(result);
@@ -9448,7 +9444,7 @@ class Graphie$1 {
9448
9444
  }
9449
9445
  addArrowheads(path) {
9450
9446
  const type = path.constructor.prototype;
9451
- if (type === raphael.exports.el) {
9447
+ if (type === Raphael$1.el) {
9452
9448
  if (path.type === "path" && typeof path.arrowheadsDrawn === "undefined") {
9453
9449
  const w = path.attr("stroke-width");
9454
9450
  const s = 0.6 + 0.4 * w;
@@ -9476,7 +9472,7 @@ class Graphie$1 {
9476
9472
  set.push(head);
9477
9473
  return set;
9478
9474
  }
9479
- } else if (type === raphael.exports.st) {
9475
+ } else if (type === Raphael$1.st) {
9480
9476
  for (let i = 0, l = path.items.length; i < l; i++) {
9481
9477
  this.addArrowheads(path.items[i]);
9482
9478
  }
@@ -9546,13 +9542,125 @@ class Graphie$1 {
9546
9542
  return processed;
9547
9543
  }
9548
9544
 
9549
- // This is a stub that's overridden in interactive.ts
9550
- getMouseCoord(event) {
9551
- throw new Error("getMouseCoord is a stub, and is not implemented");
9545
+ // Graphie puts text spans on top of the SVG, which looks good, but gets
9546
+ // in the way of mouse events. This adds another SVG element on top
9547
+ // of everything else where we can add invisible shapes with mouse
9548
+ // handlers wherever we want.
9549
+ addMouseLayer(options) {
9550
+ const localOptions = {
9551
+ allowScratchpad: false,
9552
+ setDrawingAreaAvailable: function () {},
9553
+ ...options
9554
+ };
9555
+ const mouselayerZIndex = 2;
9556
+ this.mouselayer = Raphael$1(this.el, this.xpixels, this.ypixels);
9557
+ $__default["default"](this.mouselayer.canvas).css("z-index", mouselayerZIndex);
9558
+ if (localOptions.onClick || localOptions.onMouseDown || localOptions.onMouseMove || localOptions.onMouseOver || localOptions.onMouseOut) {
9559
+ const canvasClickTarget = this.mouselayer.rect(0, 0, this.xpixels, this.ypixels).attr({
9560
+ fill: "#000",
9561
+ opacity: 0
9562
+ });
9563
+ let isClickingCanvas = false;
9564
+ $__default["default"](this.mouselayer.canvas).on("vmousedown", e => {
9565
+ if (e.target === canvasClickTarget[0]) {
9566
+ if (localOptions.onMouseDown) {
9567
+ localOptions.onMouseDown(this.getMouseCoord(e));
9568
+ }
9569
+ isClickingCanvas = true;
9570
+ if (localOptions.onMouseMove) {
9571
+ const handler = localOptions.onMouseMove;
9572
+ $__default["default"](document).bind("vmousemove.mouseLayer", e => {
9573
+ if (isClickingCanvas) {
9574
+ e.preventDefault();
9575
+ handler(this.getMouseCoord(e));
9576
+ }
9577
+ });
9578
+ }
9579
+ $__default["default"](document).bind("vmouseup.mouseLayer", e => {
9580
+ $__default["default"](document).unbind(".mouseLayer");
9581
+
9582
+ // Only register clicks that started on the canvas,
9583
+ // and not on another mouseLayer target
9584
+ if (isClickingCanvas && localOptions.onClick) {
9585
+ localOptions.onClick(this.getMouseCoord(e));
9586
+ }
9587
+ isClickingCanvas = false;
9588
+ });
9589
+ }
9590
+ });
9591
+ if (localOptions.onMouseOver) {
9592
+ const handler = localOptions.onMouseOver;
9593
+ $__default["default"](this.mouselayer.canvas).on("vmouseover", e => {
9594
+ handler(this.getMouseCoord(e));
9595
+ });
9596
+ }
9597
+ if (localOptions.onMouseOut) {
9598
+ const handler = localOptions.onMouseOut;
9599
+ $__default["default"](this.mouselayer.canvas).on("vmouseout", e => {
9600
+ handler(this.getMouseCoord(e));
9601
+ });
9602
+ }
9603
+ }
9604
+ if (!localOptions.allowScratchpad) {
9605
+ localOptions.setDrawingAreaAvailable?.(false);
9606
+ }
9607
+
9608
+ // Add mouse and visible wrapper layers for DOM-node-wrapped movables
9609
+ this._mouselayerWrapper = document.createElement("div");
9610
+ $__default["default"](this._mouselayerWrapper).css({
9611
+ position: "absolute",
9612
+ left: 0,
9613
+ top: 0,
9614
+ zIndex: mouselayerZIndex
9615
+ });
9616
+ this._visiblelayerWrapper = document.createElement("div");
9617
+ $__default["default"](this._visiblelayerWrapper).css({
9618
+ position: "absolute",
9619
+ left: 0,
9620
+ top: 0
9621
+ });
9622
+ const el = this.el;
9623
+ el.appendChild(this._visiblelayerWrapper);
9624
+ el.appendChild(this._mouselayerWrapper);
9625
+
9626
+ // Add functions for adding to wrappers
9627
+ this.addToMouseLayerWrapper = el => {
9628
+ this._mouselayerWrapper?.appendChild(el);
9629
+ };
9630
+ this.addToVisibleLayerWrapper = el => {
9631
+ this._visiblelayerWrapper?.appendChild(el);
9632
+ };
9633
+ }
9634
+ addToMouseLayerWrapper(el) {
9635
+ throw new Error("addToMouseLayerWrapper is not ready. Call addMouseLayer() first.");
9636
+ }
9637
+ addToVisibleLayerWrapper(el) {
9638
+ throw new Error("addToVisibleLayerWrapper is not ready. Call addMouseLayer() first.");
9639
+ }
9640
+ /**
9641
+ * Get mouse coordinates in pixels
9642
+ */
9643
+ getMousePx(event) {
9644
+ const offset = $__default["default"](this.el).offset();
9645
+ const mouseX =
9646
+ // @ts-expect-error - TS18048 - 'event.pageX' is possibly 'undefined'.
9647
+ event.pageX -
9648
+ // @ts-expect-error - TS2532 - Object is possibly 'undefined'.
9649
+ offset.left;
9650
+ const mouseY =
9651
+ // @ts-expect-error - TS18048 - 'event.pageY' is possibly 'undefined'.
9652
+ event.pageY -
9653
+ // @ts-expect-error - TS2532 - Object is possibly 'undefined'.
9654
+ offset.top;
9655
+ return [mouseX, mouseY];
9552
9656
  }
9553
9657
 
9554
- // This is a stub that's overridden in interactive.ts
9555
- addMouseLayer(options) {}
9658
+ /**
9659
+ * Get mouse coordinates in graph coordinates
9660
+ */
9661
+ getMouseCoord(event) {
9662
+ return this.unscalePoint(this.getMousePx(event));
9663
+ }
9556
9664
  }
9557
9665
  const labelDirections = {
9558
9666
  center: [-0.5, -0.5],
@@ -10653,114 +10761,6 @@ const InteractiveUtils = {
10653
10761
  }
10654
10762
  };
10655
10763
  ___default["default"].extend(GraphUtils.Graphie.prototype, {
10656
- // graphie puts text spans on top of the SVG, which looks good, but gets
10657
- // in the way of mouse events. This adds another SVG element on top
10658
- // of everything else where we can add invisible shapes with mouse
10659
- // handlers wherever we want.
10660
- addMouseLayer: function (options) {
10661
- const graph = this;
10662
- options = ___default["default"].extend({
10663
- allowScratchpad: false,
10664
- setDrawingAreaAvailable: function () {}
10665
- }, options);
10666
- const mouselayerZIndex = 2;
10667
- graph.mouselayer = raphael.exports(graph.raphael.canvas.parentNode, graph.xpixels, graph.ypixels);
10668
- $__default["default"](graph.mouselayer.canvas).css("z-index", mouselayerZIndex);
10669
- if (options.onClick || options.onMouseDown || options.onMouseMove || options.onMouseOver || options.onMouseOut) {
10670
- const canvasClickTarget = graph.mouselayer.rect(0, 0, graph.xpixels, graph.ypixels).attr({
10671
- fill: "#000",
10672
- opacity: 0
10673
- });
10674
- let isClickingCanvas = false;
10675
- $__default["default"](graph.mouselayer.canvas).on("vmousedown", function (e) {
10676
- if (e.target === canvasClickTarget[0]) {
10677
- if (options.onMouseDown) {
10678
- options.onMouseDown(graph.getMouseCoord(e));
10679
- }
10680
- isClickingCanvas = true;
10681
- if (options.onMouseMove) {
10682
- const handler = options.onMouseMove;
10683
- $__default["default"](document).bind("vmousemove.mouseLayer", function (e) {
10684
- if (isClickingCanvas) {
10685
- e.preventDefault();
10686
- handler(graph.getMouseCoord(e));
10687
- }
10688
- });
10689
- }
10690
- $__default["default"](document).bind("vmouseup.mouseLayer", function (e) {
10691
- $__default["default"](document).unbind(".mouseLayer");
10692
-
10693
- // Only register clicks that started on the canvas,
10694
- // and not on another mouseLayer target
10695
- if (isClickingCanvas && options.onClick) {
10696
- options.onClick(graph.getMouseCoord(e));
10697
- }
10698
- isClickingCanvas = false;
10699
- });
10700
- }
10701
- });
10702
- if (options.onMouseOver) {
10703
- const handler = options.onMouseOver;
10704
- $__default["default"](graph.mouselayer.canvas).on("vmouseover", function (e) {
10705
- handler(graph.getMouseCoord(e));
10706
- });
10707
- }
10708
- if (options.onMouseOut) {
10709
- const handler = options.onMouseOut;
10710
- $__default["default"](graph.mouselayer.canvas).on("vmouseout", function (e) {
10711
- handler(graph.getMouseCoord(e));
10712
- });
10713
- }
10714
- }
10715
- if (!options.allowScratchpad) {
10716
- options.setDrawingAreaAvailable?.(false);
10717
- }
10718
-
10719
- // Add mouse and visible wrapper layers for DOM-node-wrapped movables
10720
- graph._mouselayerWrapper = document.createElement("div");
10721
- $__default["default"](graph._mouselayerWrapper).css({
10722
- position: "absolute",
10723
- left: 0,
10724
- top: 0,
10725
- zIndex: mouselayerZIndex
10726
- });
10727
- graph._visiblelayerWrapper = document.createElement("div");
10728
- $__default["default"](graph._visiblelayerWrapper).css({
10729
- position: "absolute",
10730
- left: 0,
10731
- top: 0
10732
- });
10733
- const el = graph.raphael.canvas.parentNode;
10734
- el.appendChild(graph._visiblelayerWrapper);
10735
- el.appendChild(graph._mouselayerWrapper);
10736
-
10737
- // Add functions for adding to wrappers
10738
- graph.addToMouseLayerWrapper = function (el) {
10739
- this._mouselayerWrapper.appendChild(el);
10740
- };
10741
- graph.addToVisibleLayerWrapper = function (el) {
10742
- this._visiblelayerWrapper.appendChild(el);
10743
- };
10744
- },
10745
- /**
10746
- * Get mouse coordinates in pixels
10747
- */
10748
- getMousePx: function (event) {
10749
- const graphie = this;
10750
- const mouseX =
10751
- // @ts-expect-error - TS2532 - Object is possibly 'undefined'.
10752
- event.pageX - $__default["default"](graphie.raphael.canvas.parentNode).offset().left;
10753
- const mouseY =
10754
- // @ts-expect-error - TS2532 - Object is possibly 'undefined'.
10755
- event.pageY - $__default["default"](graphie.raphael.canvas.parentNode).offset().top;
10756
- return [mouseX, mouseY];
10757
- },
10758
- /**
10759
- * Get mouse coordinates in graph coordinates
10760
- */
10761
- getMouseCoord: function (event) {
10762
- return this.unscalePoint(this.getMousePx(event));
10763
- },
10764
10764
  /**
10765
10765
  * Unlike all other Graphie-related code, the following three functions use
10766
10766
  * a lot of scaled coordinates (so that labels appear the same size
@@ -23352,14 +23352,16 @@ const Choice = function (props) {
23352
23352
  close
23353
23353
  } = _ref2;
23354
23354
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksPopover.PopoverContent, {
23355
- title: "Cross out",
23356
- content: "Cross out option",
23355
+ title: i18n__namespace._("Cross out"),
23356
+ content: i18n__namespace._("Cross out option"),
23357
23357
  closeButtonVisible: true,
23358
23358
  actions: /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
23359
23359
  size: Spacing__default["default"].medium_16
23360
23360
  }), /*#__PURE__*/React__namespace.createElement(Button__default["default"], {
23361
23361
  kind: "primary",
23362
- "aria-label": `Cross out Choice ${getChoiceLetter(pos)}`,
23362
+ "aria-label": i18n__namespace._("Cross out Choice %(letter)s", {
23363
+ letter: getChoiceLetter(pos)
23364
+ }),
23363
23365
  disabled: apiOptions.readOnly || reviewMode,
23364
23366
  onClick: () => {
23365
23367
  if (!crossedOut) {
@@ -23378,7 +23380,7 @@ const Choice = function (props) {
23378
23380
  }
23379
23381
  close();
23380
23382
  }
23381
- }, crossedOut ? "Bring back" : "Cross out"))
23383
+ }, crossedOut ? i18n__namespace._("Bring back") : i18n__namespace._("Cross out")))
23382
23384
  });
23383
23385
  }
23384
23386
  }, _ref3 => {
@@ -23387,7 +23389,9 @@ const Choice = function (props) {
23387
23389
  } = _ref3;
23388
23390
  return /*#__PURE__*/React__namespace.createElement(Clickable__default["default"], {
23389
23391
  onClick: open,
23390
- "aria-label": `Open menu for Choice ${getChoiceLetter(pos)}`,
23392
+ "aria-label": i18n__namespace._(`Open menu for Choice %(letter)s`, {
23393
+ letter: getChoiceLetter(pos)
23394
+ }),
23391
23395
  style: {
23392
23396
  alignSelf: "center",
23393
23397
  padding: "5px",
@@ -40597,366 +40601,222 @@ var Table$1 = {
40597
40601
  isLintable: true
40598
40602
  };
40599
40603
 
40600
- var hubble = {exports: {}};
40601
-
40602
- (function (module, exports) {
40603
- (function webpackUniversalModuleDefinition(root, factory) {
40604
- module.exports = factory();
40605
- })(commonjsGlobal, function () {
40606
- return (/******/function (modules) {
40607
- // webpackBootstrap
40608
- /******/ // The module cache
40609
- /******/
40610
- var installedModules = {};
40611
- /******/
40612
- /******/ // The require function
40613
- /******/
40614
- function __webpack_require__(moduleId) {
40615
- /******/
40616
- /******/ // Check if module is in cache
40617
- /******/if (installedModules[moduleId]) {
40618
- /******/return installedModules[moduleId].exports;
40619
- /******/
40620
- }
40621
- /******/ // Create a new module (and put it into the cache)
40622
- /******/
40623
- var module = installedModules[moduleId] = {
40624
- /******/i: moduleId,
40625
- /******/l: false,
40626
- /******/exports: {}
40627
- /******/
40628
- };
40629
- /******/
40630
- /******/ // Execute the module function
40631
- /******/
40632
- modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
40633
- /******/
40634
- /******/ // Flag the module as loaded
40635
- /******/
40636
- module.l = true;
40637
- /******/
40638
- /******/ // Return the exports of the module
40639
- /******/
40640
- return module.exports;
40641
- /******/
40642
- }
40643
- /******/
40644
- /******/
40645
- /******/ // expose the modules object (__webpack_modules__)
40646
- /******/
40647
- __webpack_require__.m = modules;
40648
- /******/
40649
- /******/ // expose the module cache
40650
- /******/
40651
- __webpack_require__.c = installedModules;
40652
- /******/
40653
- /******/ // define getter function for harmony exports
40654
- /******/
40655
- __webpack_require__.d = function (exports, name, getter) {
40656
- /******/if (!__webpack_require__.o(exports, name)) {
40657
- /******/Object.defineProperty(exports, name, {
40658
- /******/configurable: false,
40659
- /******/enumerable: true,
40660
- /******/get: getter
40661
- /******/
40662
- });
40663
- /******/
40664
- }
40665
- /******/
40666
- };
40667
- /******/
40668
- /******/ // getDefaultExport function for compatibility with non-harmony modules
40669
- /******/
40670
- __webpack_require__.n = function (module) {
40671
- /******/var getter = module && module.__esModule ? /******/function getDefault() {
40672
- return module['default'];
40673
- } : /******/function getModuleExports() {
40674
- return module;
40675
- };
40676
- /******/
40677
- __webpack_require__.d(getter, 'a', getter);
40678
- /******/
40679
- return getter;
40680
- /******/
40681
- };
40682
- /******/
40683
- /******/ // Object.prototype.hasOwnProperty.call
40684
- /******/
40685
- __webpack_require__.o = function (object, property) {
40686
- return Object.prototype.hasOwnProperty.call(object, property);
40687
- };
40688
- /******/
40689
- /******/ // __webpack_public_path__
40690
- /******/
40691
- __webpack_require__.p = "";
40692
- /******/
40693
- /******/ // Load entry module and return exports
40694
- /******/
40695
- return __webpack_require__(__webpack_require__.s = 1);
40696
- /******/
40697
- }
40698
- /************************************************************************/
40699
- /******/([/* 0 */
40700
- /***/function (module, exports) {
40701
- var isObject = function (obj) {
40702
- return obj === Object(obj);
40703
- };
40704
- var merge = function () {
40705
- var obj = {};
40706
- for (var i = 0; i < arguments.length; i++) {
40707
- var source = arguments[i];
40708
- if (source) {
40709
- for (var prop in source) {
40710
- obj[prop] = source[prop];
40711
- }
40712
- }
40713
- }
40714
- return obj;
40715
- };
40716
- var clone = function (obj) {
40717
- if (!isObject(obj)) {
40718
- return obj;
40719
- }
40720
- return Array.isArray(obj) ? obj.slice() : merge(obj);
40721
- };
40722
- module.exports = {
40723
- isObject: isObject,
40724
- merge: merge,
40725
- clone: clone
40726
- };
40727
-
40728
- /***/
40729
- }, /* 1 */
40730
- /***/function (module, exports, __webpack_require__) {
40731
- /* TODO batch *all* mutations
40732
- * idea: freeze / thaw implementations for all types
40733
- * lens constructor thaws, freeze delegates to type's freeze
40734
- */
40735
-
40736
- var util = __webpack_require__(0);
40737
- var clone = util.clone;
40738
- var isObject = util.isObject;
40739
- var merge = util.merge;
40740
- var arr = __webpack_require__(2);
40741
- var obj = __webpack_require__(3);
40742
- var str = __webpack_require__(4);
40743
-
40744
- // equivalents, without requiring it
40745
- // find the implementation to use for a given object
40746
- var dispatch = function (x) {
40747
- if (Array.isArray(x)) {
40748
- return arr;
40749
- } else if (isObject(x)) {
40750
- return obj;
40751
- } else if (typeof x === "string") {
40752
- return str;
40753
- }
40754
- };
40755
-
40756
- // This is underscore with a different name
40757
- var lens = function (obj) {
40758
- if (obj instanceof lens) {
40759
- return obj;
40760
- }
40761
- if (!(this instanceof lens)) {
40762
- return new lens(obj);
40763
- }
40764
- var ops = dispatch(obj);
40765
- this._wrapped = ops.thaw ? ops.thaw(obj) : obj;
40766
- };
40767
- lens.prototype.freeze = function () {
40768
- var obj = this._wrapped;
40769
- var ops = dispatch(obj);
40770
- return ops.freeze ? ops.freeze(obj) : obj;
40771
- };
40772
- lens.prototype.zoom = function (lensArr) {
40773
- if (this._zoomStack === undefined) {
40774
- this._zoomStack = [];
40775
- }
40776
- this._zoomStack.push({
40777
- zoom: lensArr,
40778
- wrapped: this._wrapped
40779
- });
40780
- this._wrapped = lens(this._wrapped).get(lensArr);
40781
- return this;
40782
- };
40783
- lens.prototype.deZoom = function () {
40784
- var frame = this._zoomStack.pop();
40785
- this._wrapped = lens(frame.wrapped).set(frame.zoom, this._wrapped).freeze();
40786
- return this;
40787
- };
40788
- lens.prototype.get = function (lensArr) {
40789
- var obj = this._wrapped;
40790
- for (var i = 0; i < lensArr.length; i++) {
40791
- obj = dispatch(obj).get(obj, lensArr[i]);
40792
- }
40793
- return obj;
40794
- };
40795
- lens.prototype.mod = function (lensArr, f) {
40796
- var obj = this._wrapped;
40797
- var newObj = clone(obj);
40798
- var ops = dispatch(obj);
40799
- if (lensArr.length === 0) {
40800
- this._wrapped = f(this._wrapped);
40801
- } else if (lensArr.length === 1) {
40802
- this._wrapped = ops.mod(newObj, lensArr[0], f);
40803
- } else {
40804
- var monocle = lensArr[0];
40805
- var shortLens = lensArr.slice(1);
40806
-
40807
- // newObj = ops.mod(obj[monocle], shortLens, f);
40808
-
40809
- newObj[monocle] = lens(obj[monocle]).mod(shortLens, f).freeze();
40810
- this._wrapped = newObj;
40811
- }
40812
- return this;
40813
- };
40814
-
40815
- // TODO - move to individual files
40816
- lens.prototype.merge = function (lensArr, props) {
40817
- this._wrapped = lens(this._wrapped).mod(lensArr, function (oldProps) {
40818
- return merge(oldProps, props);
40819
- }).freeze();
40820
- return this;
40821
- };
40822
-
40823
- // Lens must have length >= 1 or there would be nothing to return
40824
- lens.prototype.del = function (lensArr) {
40825
- var obj = this._wrapped;
40826
- var ops = dispatch(obj);
40827
- if (lensArr.length === 1) {
40828
- this._wrapped = ops.del(obj, lensArr[0]);
40829
- } else {
40830
- var monocle = lensArr[0];
40831
- var shortLens = lensArr.slice(1);
40832
- var newObj = clone(obj);
40833
- newObj[monocle] = lens(obj[monocle]).del(shortLens).freeze();
40834
- this._wrapped = newObj;
40835
- }
40836
- return this;
40837
- };
40838
- lens.prototype.set = function (lensArr, set) {
40839
- return this.mod(lensArr, function () {
40840
- return set;
40841
- });
40842
- };
40843
- module.exports = lens;
40844
-
40845
- /***/
40846
- }, /* 2 */
40847
- /***/function (module, exports) {
40848
- var get = function (arr, monocle) {
40849
- return arr[monocle];
40850
- };
40851
- var set = function (arr, monocle, val) {
40852
- var newArr = arr.splice();
40853
- newArr[monocle] = val;
40854
- return newArr;
40855
- };
40856
- var mod = function (arr, monocle, f) {
40857
- var newArr = arr.slice();
40858
- newArr[monocle] = f(arr[monocle]);
40859
- return newArr;
40860
- };
40861
- var del = function (arr, monocle) {
40862
- var newArr = arr.slice();
40863
- newArr.splice(monocle, 1);
40864
- return newArr;
40865
- };
40866
-
40867
- /*
40868
- // Lens must point to a member of an array. We'll insert into that array.
40869
- lens.prototype.insertAt = function(lensArr, toInsert) {
40870
- var obj = this._wrapped;
40871
-
40872
- var arrLens = lensArr.slice(0, -1);
40873
- var arr = lens(obj).get(arrLens).slice(); // slice to copy
40874
-
40875
- var arrIdx = lensArr[lensArr.length-1];
40876
- arr.splice(arrIdx, 0, toInsert);
40877
- return lens(obj).set(arrLens, arr);
40878
- };
40879
-
40880
- lens.prototype.insertBefore = lens.prototype.insertAt;
40881
- lens.prototype.insertAfter = function(lensArr, toInsert) {
40882
- var newLens = lensArr.slice();
40883
- newLens[newLens.length-1] += 1;
40884
- return lens(this._wrapped).insertAt(newLens, toInsert);
40885
- };
40886
- */
40887
-
40888
- module.exports = {
40889
- get: get,
40890
- set: set,
40891
- mod: mod,
40892
- del: del
40893
- };
40894
-
40895
- /***/
40896
- }, /* 3 */
40897
- /***/function (module, exports, __webpack_require__) {
40898
- var clone = __webpack_require__(0).clone;
40899
- var get = function (obj, monocle) {
40900
- return obj[monocle];
40901
- };
40902
- var set = function (obj, monocle, val) {
40903
- var newObj = clone(obj);
40904
- newObj[monocle] = val;
40905
- return newObj;
40906
- };
40907
- var mod = function (obj, monocle, f) {
40908
- var newObj = clone(obj);
40909
- newObj[monocle] = f(obj[monocle]);
40910
- return newObj;
40911
- };
40912
- var del = function (obj, monocle) {
40913
- var newObj = clone(obj);
40914
- delete newObj[monocle];
40915
- return newObj;
40916
- };
40917
- module.exports = {
40918
- get: get,
40919
- set: set,
40920
- mod: mod,
40921
- del: del
40922
- };
40923
-
40924
- /***/
40925
- }, /* 4 */
40926
- /***/function (module, exports) {
40927
- var get = function (arr, monocle) {
40928
- return arr[monocle];
40929
- };
40930
- var set = function (arr, monocle, val) {
40931
- var newArr = arr.splice();
40932
- newArr[monocle] = val;
40933
- return newArr;
40934
- };
40935
- var mod = function (arr, monocle, f) {
40936
- var newArr = arr.splice();
40937
- newArr[monocle] = f(arr[monocle]);
40938
- return newArr;
40939
- };
40940
- var del = function (arr, monocle) {
40941
- var newArr = arr.slice();
40942
- newArr.splice(monocle);
40943
- return newArr;
40944
- };
40945
- module.exports = {
40946
- get: get,
40947
- set: set,
40948
- mod: mod,
40949
- del: del
40950
- };
40951
-
40952
- /***/
40953
- }
40954
- /******/])
40955
- );
40956
- });
40957
- } (hubble));
40958
-
40959
- var lens = /*@__PURE__*/getDefaultExportFromCjs(hubble.exports);
40604
+ var isObject = function (obj) {
40605
+ return obj === Object(obj);
40606
+ };
40607
+ var merge = function () {
40608
+ var obj = {};
40609
+ for (var i = 0; i < arguments.length; i++) {
40610
+ var source = arguments[i];
40611
+ if (source) {
40612
+ for (var prop in source) {
40613
+ obj[prop] = source[prop];
40614
+ }
40615
+ }
40616
+ }
40617
+ return obj;
40618
+ };
40619
+ var clone = function (obj) {
40620
+ if (!isObject(obj)) {
40621
+ return obj;
40622
+ }
40623
+ return Array.isArray(obj) ? obj.slice() : merge(obj);
40624
+ };
40625
+
40626
+ /* TODO batch *all* mutations
40627
+ * idea: freeze / thaw implementations for all types
40628
+ * lens constructor thaws, freeze delegates to type's freeze
40629
+ */
40630
+
40631
+ // equivalents, without requiring it
40632
+ // find the implementation to use for a given object
40633
+ var dispatch = function (x) {
40634
+ if (Array.isArray(x)) {
40635
+ return arr;
40636
+ } else if (isObject(x)) {
40637
+ return obj;
40638
+ } else if (typeof x === "string") {
40639
+ return str;
40640
+ }
40641
+ };
40642
+
40643
+ // This is underscore with a different name
40644
+ var lens = function (obj) {
40645
+ if (obj instanceof lens) {
40646
+ return obj;
40647
+ }
40648
+ if (!(this instanceof lens)) {
40649
+ return new lens(obj);
40650
+ }
40651
+ var ops = dispatch(obj);
40652
+ this._wrapped = ops.thaw ? ops.thaw(obj) : obj;
40653
+ };
40654
+ lens.prototype.freeze = function () {
40655
+ var obj = this._wrapped;
40656
+ var ops = dispatch(obj);
40657
+ return ops.freeze ? ops.freeze(obj) : obj;
40658
+ };
40659
+ lens.prototype.zoom = function (lensArr) {
40660
+ if (this._zoomStack === undefined) {
40661
+ this._zoomStack = [];
40662
+ }
40663
+ this._zoomStack.push({
40664
+ zoom: lensArr,
40665
+ wrapped: this._wrapped
40666
+ });
40667
+ this._wrapped = lens(this._wrapped).get(lensArr);
40668
+ return this;
40669
+ };
40670
+ lens.prototype.deZoom = function () {
40671
+ var frame = this._zoomStack.pop();
40672
+ this._wrapped = lens(frame.wrapped).set(frame.zoom, this._wrapped).freeze();
40673
+ return this;
40674
+ };
40675
+ lens.prototype.get = function (lensArr) {
40676
+ var obj = this._wrapped;
40677
+ for (var i = 0; i < lensArr.length; i++) {
40678
+ obj = dispatch(obj).get(obj, lensArr[i]);
40679
+ }
40680
+ return obj;
40681
+ };
40682
+ lens.prototype.mod = function (lensArr, f) {
40683
+ var obj = this._wrapped;
40684
+ var newObj = clone(obj);
40685
+ var ops = dispatch(obj);
40686
+ if (lensArr.length === 0) {
40687
+ this._wrapped = f(this._wrapped);
40688
+ } else if (lensArr.length === 1) {
40689
+ this._wrapped = ops.mod(newObj, lensArr[0], f);
40690
+ } else {
40691
+ var monocle = lensArr[0];
40692
+ var shortLens = lensArr.slice(1);
40693
+
40694
+ // newObj = ops.mod(obj[monocle], shortLens, f);
40695
+
40696
+ newObj[monocle] = lens(obj[monocle]).mod(shortLens, f).freeze();
40697
+ this._wrapped = newObj;
40698
+ }
40699
+ return this;
40700
+ };
40701
+
40702
+ // TODO - move to individual files
40703
+ lens.prototype.merge = function (lensArr, props) {
40704
+ this._wrapped = lens(this._wrapped).mod(lensArr, function (oldProps) {
40705
+ return merge(oldProps, props);
40706
+ }).freeze();
40707
+ return this;
40708
+ };
40709
+
40710
+ // Lens must have length >= 1 or there would be nothing to return
40711
+ lens.prototype.del = function (lensArr) {
40712
+ var obj = this._wrapped;
40713
+ var ops = dispatch(obj);
40714
+ if (lensArr.length === 1) {
40715
+ this._wrapped = ops.del(obj, lensArr[0]);
40716
+ } else {
40717
+ var monocle = lensArr[0];
40718
+ var shortLens = lensArr.slice(1);
40719
+ var newObj = clone(obj);
40720
+ newObj[monocle] = lens(obj[monocle]).del(shortLens).freeze();
40721
+ this._wrapped = newObj;
40722
+ }
40723
+ return this;
40724
+ };
40725
+ lens.prototype.set = function (lensArr, set) {
40726
+ return this.mod(lensArr, function () {
40727
+ return set;
40728
+ });
40729
+ };
40730
+
40731
+ // ARRAY FUNCTIONS
40732
+
40733
+ const arr = {
40734
+ get: function (arr, monocle) {
40735
+ return arr[monocle];
40736
+ },
40737
+ set: function (arr, monocle, val) {
40738
+ var newArr = arr.splice();
40739
+ newArr[monocle] = val;
40740
+ return newArr;
40741
+ },
40742
+ mod: function (arr, monocle, f) {
40743
+ var newArr = arr.slice();
40744
+ newArr[monocle] = f(arr[monocle]);
40745
+ return newArr;
40746
+ },
40747
+ del: function (arr, monocle) {
40748
+ var newArr = arr.slice();
40749
+ newArr.splice(monocle, 1);
40750
+ return newArr;
40751
+ }
40752
+ };
40753
+
40754
+ /*
40755
+ // Lens must point to a member of an array. We'll insert into that array.
40756
+ lens.prototype.insertAt = function(lensArr, toInsert) {
40757
+ var obj = this._wrapped;
40758
+
40759
+ var arrLens = lensArr.slice(0, -1);
40760
+ var arr = lens(obj).get(arrLens).slice(); // slice to copy
40761
+
40762
+ var arrIdx = lensArr[lensArr.length-1];
40763
+ arr.splice(arrIdx, 0, toInsert);
40764
+ return lens(obj).set(arrLens, arr);
40765
+ };
40766
+
40767
+ lens.prototype.insertBefore = lens.prototype.insertAt;
40768
+ lens.prototype.insertAfter = function(lensArr, toInsert) {
40769
+ var newLens = lensArr.slice();
40770
+ newLens[newLens.length-1] += 1;
40771
+ return lens(this._wrapped).insertAt(newLens, toInsert);
40772
+ };
40773
+ */
40774
+
40775
+ // OBJECT FUNCTIONS
40776
+
40777
+ const obj = {
40778
+ get: function (obj, monocle) {
40779
+ return obj[monocle];
40780
+ },
40781
+ set: function (obj, monocle, val) {
40782
+ var newObj = clone(obj);
40783
+ newObj[monocle] = val;
40784
+ return newObj;
40785
+ },
40786
+ mod: function (obj, monocle, f) {
40787
+ var newObj = clone(obj);
40788
+ newObj[monocle] = f(obj[monocle]);
40789
+ return newObj;
40790
+ },
40791
+ del: function (obj, monocle) {
40792
+ var newObj = clone(obj);
40793
+ delete newObj[monocle];
40794
+ return newObj;
40795
+ }
40796
+ };
40797
+
40798
+ // STRING FUNCTIONS
40799
+
40800
+ const str = {
40801
+ get: function (arr, monocle) {
40802
+ return arr[monocle];
40803
+ },
40804
+ set: function (arr, monocle, val) {
40805
+ var newArr = arr.splice();
40806
+ newArr[monocle] = val;
40807
+ return newArr;
40808
+ },
40809
+ mod: function (arr, monocle, f) {
40810
+ var newArr = arr.splice();
40811
+ newArr[monocle] = f(arr[monocle]);
40812
+ return newArr;
40813
+ },
40814
+ del: function (arr, monocle) {
40815
+ var newArr = arr.slice();
40816
+ newArr.splice(monocle);
40817
+ return newArr;
40818
+ }
40819
+ };
40960
40820
 
40961
40821
  /* eslint-disable eqeqeq, @typescript-eslint/no-unused-vars */
40962
40822
  /*
@@ -41862,7 +41722,7 @@ const init = function (options) {
41862
41722
 
41863
41723
  // This file is processed by a Rollup plugin (replace) to inject the production
41864
41724
  const libName = "@khanacademy/perseus";
41865
- const libVersion = "19.1.7";
41725
+ const libVersion = "19.1.9";
41866
41726
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
41867
41727
 
41868
41728
  const apiVersion = {