@khanacademy/perseus 0.0.1 → 0.1.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/.babelrc.js +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/es/index.js +15 -1
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +11934 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/strings.js +148 -1
- package/package.json +40 -4
- package/src/README.md +7 -0
- package/src/__stories__/item-renderer.stories.jsx +27 -0
- package/src/__stories__/server-item-renderer.stories.jsx +27 -0
- package/src/__testdata__/item-renderer_testdata.js +161 -0
- package/src/__testdata__/renderer_testdata.js +123 -0
- package/src/__tests__/__snapshots__/item-renderer_test.jsx.snap +233 -0
- package/src/__tests__/__snapshots__/perseus-markdown_test.jsx.snap +516 -0
- package/src/__tests__/__snapshots__/pure-markdown_test.js.snap +113 -0
- package/src/__tests__/__snapshots__/renderer_test.jsx.snap +576 -0
- package/src/__tests__/__snapshots__/server-item-renderer_test.jsx.snap +306 -0
- package/src/__tests__/a11y_test.jsx +304 -0
- package/src/__tests__/item-renderer_test.jsx +892 -0
- package/src/__tests__/mock-asset-loading-widget.jsx +57 -0
- package/src/__tests__/mock-widget.jsx +35 -0
- package/src/__tests__/perseus-markdown_test.jsx +747 -0
- package/src/__tests__/pure-markdown_test.js +552 -0
- package/src/__tests__/renderability_test.jsx +481 -0
- package/src/__tests__/renderer-api_test.jsx +333 -0
- package/src/__tests__/renderer_test.jsx +1792 -0
- package/src/__tests__/server-item-renderer_test.jsx +516 -0
- package/src/__tests__/test-items/image-item.js +25 -0
- package/src/__tests__/test-items/input-number-1-item.js +27 -0
- package/src/__tests__/test-items/input-number-2-item.js +39 -0
- package/src/__tests__/test-items/table-item.js +30 -0
- package/src/__tests__/tex-wrangler_test.js +83 -0
- package/src/__tests__/util_test.js +41 -0
- package/src/a11y.js +46 -0
- package/src/all-widgets.js +9 -0
- package/src/article-renderer.jsx +215 -0
- package/src/asset-context.js +30 -0
- package/src/basic-widgets.js +13 -0
- package/src/components/__stories__/button-group.stories.jsx +61 -0
- package/src/components/__stories__/fixed-to-responsive.stories.jsx +132 -0
- package/src/components/__stories__/graph.stories.jsx +27 -0
- package/src/components/__stories__/graphie.stories.jsx +28 -0
- package/src/components/__stories__/hud.stories.jsx +36 -0
- package/src/components/__stories__/icon.stories.jsx +56 -0
- package/src/components/__stories__/image-loader.stories.jsx +60 -0
- package/src/components/__stories__/info-tip.stories.jsx +33 -0
- package/src/components/__stories__/inline-icon.stories.jsx +39 -0
- package/src/components/__stories__/input-with-examples.stories.jsx +51 -0
- package/src/components/__stories__/lint.stories.jsx +40 -0
- package/src/components/__stories__/math-input.stories.jsx +29 -0
- package/src/components/__stories__/math-output.stories.jsx +24 -0
- package/src/components/__stories__/multi-button-group.stories.jsx +69 -0
- package/src/components/__stories__/number-input.stories.jsx +42 -0
- package/src/components/__stories__/possible-answers.stories.jsx +22 -0
- package/src/components/__stories__/prop-check-box.stories.jsx +62 -0
- package/src/components/__stories__/range-input.stories.jsx +28 -0
- package/src/components/__stories__/simple-keypad-input.stories.jsx +28 -0
- package/src/components/__stories__/sortable.stories.jsx +73 -0
- package/src/components/__stories__/stub-tag-editor.stories.jsx +44 -0
- package/src/components/__stories__/svg-image.stories.jsx +60 -0
- package/src/components/__stories__/tex.stories.jsx +18 -0
- package/src/components/__stories__/text-buttons.stories.jsx +51 -0
- package/src/components/__stories__/text-input.stories.jsx +34 -0
- package/src/components/__stories__/text-list-editor.stories.jsx +33 -0
- package/src/components/__stories__/zoomable-tex.stories.jsx +39 -0
- package/src/components/__stories__/zoomable.stories.jsx +40 -0
- package/src/components/__testdata__/sorter_testdata.js +20 -0
- package/src/components/__tests__/__snapshots__/sortable_test.jsx.snap +79 -0
- package/src/components/__tests__/__snapshots__/sorter_test.jsx.snap +297 -0
- package/src/components/__tests__/number-input_test.jsx +112 -0
- package/src/components/__tests__/sortable_test.jsx +234 -0
- package/src/components/__tests__/sorter_test.jsx +111 -0
- package/src/components/__tests__/zoomable_test.jsx +388 -0
- package/src/components/button-group.jsx +131 -0
- package/src/components/constants.js +15 -0
- package/src/components/fixed-to-responsive.jsx +163 -0
- package/src/components/graph.jsx +414 -0
- package/src/components/graphie-classes.jsx +148 -0
- package/src/components/graphie-movables.jsx +342 -0
- package/src/components/graphie.jsx +353 -0
- package/src/components/highlighting/highlightable-content.jsx +245 -0
- package/src/components/highlighting/highlights.js +208 -0
- package/src/components/highlighting/ranges.js +299 -0
- package/src/components/highlighting/types.js +73 -0
- package/src/components/highlighting/ui/highlight-renderer.jsx +179 -0
- package/src/components/highlighting/ui/highlight-set-renderer.jsx +190 -0
- package/src/components/highlighting/ui/highlight-tooltip.jsx +153 -0
- package/src/components/highlighting/ui/highlighting-ui.jsx +163 -0
- package/src/components/highlighting/ui/selection-tracker.jsx +195 -0
- package/src/components/highlighting/ui/types.js +21 -0
- package/src/components/highlighting/ui/util.js +166 -0
- package/src/components/highlighting/word-indexer.jsx +155 -0
- package/src/components/hud.jsx +179 -0
- package/src/components/icon.jsx +149 -0
- package/src/components/image-loader.jsx +175 -0
- package/src/components/info-tip/info-tip.jsx +149 -0
- package/src/components/info-tip.jsx +38 -0
- package/src/components/inline-icon.jsx +81 -0
- package/src/components/input-with-examples.jsx +231 -0
- package/src/components/lint.jsx +456 -0
- package/src/components/math-input.jsx +282 -0
- package/src/components/math-output.jsx +128 -0
- package/src/components/multi-button-group.jsx +137 -0
- package/src/components/new-tooltip/README.md +110 -0
- package/src/components/new-tooltip/__stories__/flexible-position.stories.jsx +437 -0
- package/src/components/new-tooltip/__stories__/new-tooltip.stories.jsx +665 -0
- package/src/components/new-tooltip/__stories__/tooltip-arrow.stories.jsx +70 -0
- package/src/components/new-tooltip/__stories__/tooltip-bubble.stories.jsx +98 -0
- package/src/components/new-tooltip/__tests__/style-constants_test.js +8 -0
- package/src/components/new-tooltip/__tests__/util_test.js +47 -0
- package/src/components/new-tooltip/flexible-position.jsx +182 -0
- package/src/components/new-tooltip/new-tooltip.jsx +399 -0
- package/src/components/new-tooltip/style-constants.js +13 -0
- package/src/components/new-tooltip/tooltip-arrow.jsx +184 -0
- package/src/components/new-tooltip/tooltip-bubble.jsx +223 -0
- package/src/components/new-tooltip/tooltip-portal.jsx +101 -0
- package/src/components/new-tooltip/tooltip-positioner.jsx +529 -0
- package/src/components/new-tooltip/types.js +183 -0
- package/src/components/new-tooltip/util.js +27 -0
- package/src/components/number-input.jsx +253 -0
- package/src/components/possible-answers.jsx +36 -0
- package/src/components/prop-check-box.jsx +78 -0
- package/src/components/range-input.jsx +61 -0
- package/src/components/simple-keypad-input.jsx +91 -0
- package/src/components/sortable.jsx +872 -0
- package/src/components/stub-tag-editor.jsx +53 -0
- package/src/components/svg-image.jsx +762 -0
- package/src/components/tex-buttons.jsx +322 -0
- package/src/components/tex.jsx +70 -0
- package/src/components/text-input.jsx +82 -0
- package/src/components/text-list-editor.jsx +157 -0
- package/src/components/tooltip.jsx +395 -0
- package/src/components/visibility-observer/__stories__/visibility-observer.stories.jsx +140 -0
- package/src/components/visibility-observer/get-scroll-parent.js +45 -0
- package/src/components/visibility-observer/visibility-observer.js +109 -0
- package/src/components/visibility-observer/visibility-observer.jsx +123 -0
- package/src/components/zoomable-tex.jsx +70 -0
- package/src/components/zoomable.jsx +304 -0
- package/src/components.js +17 -0
- package/src/dependencies.js +22 -0
- package/src/error-boundary.jsx +48 -0
- package/src/extra-widgets.js +75 -0
- package/src/gorgon/README +40 -0
- package/src/gorgon/__tests__/matcher_test.js +497 -0
- package/src/gorgon/__tests__/rule_test.js +101 -0
- package/src/gorgon/__tests__/rules_test.js +487 -0
- package/src/gorgon/__tests__/selector-parser_test.js +52 -0
- package/src/gorgon/__tests__/tree-transformer_test.js +446 -0
- package/src/gorgon/gorgon.js +290 -0
- package/src/gorgon/proptypes.js +29 -0
- package/src/gorgon/rule.js +413 -0
- package/src/gorgon/rules/absolute-url.js +24 -0
- package/src/gorgon/rules/all-rules.js +72 -0
- package/src/gorgon/rules/blockquoted-math.js +10 -0
- package/src/gorgon/rules/blockquoted-widget.js +10 -0
- package/src/gorgon/rules/double-spacing-after-terminal.js +12 -0
- package/src/gorgon/rules/extra-content-spacing.js +12 -0
- package/src/gorgon/rules/heading-level-1.js +14 -0
- package/src/gorgon/rules/heading-level-skip.js +20 -0
- package/src/gorgon/rules/heading-sentence-case.js +11 -0
- package/src/gorgon/rules/heading-title-case.js +63 -0
- package/src/gorgon/rules/image-alt-text.js +21 -0
- package/src/gorgon/rules/image-in-table.js +10 -0
- package/src/gorgon/rules/image-spaces-around-urls.js +35 -0
- package/src/gorgon/rules/image-widget.js +50 -0
- package/src/gorgon/rules/link-click-here.js +11 -0
- package/src/gorgon/rules/lint-utils.js +48 -0
- package/src/gorgon/rules/long-paragraph.js +14 -0
- package/src/gorgon/rules/math-adjacent.js +10 -0
- package/src/gorgon/rules/math-align-extra-break.js +11 -0
- package/src/gorgon/rules/math-align-linebreaks.js +43 -0
- package/src/gorgon/rules/math-empty.js +10 -0
- package/src/gorgon/rules/math-font-size.js +12 -0
- package/src/gorgon/rules/math-frac.js +10 -0
- package/src/gorgon/rules/math-nested.js +11 -0
- package/src/gorgon/rules/math-starts-with-space.js +12 -0
- package/src/gorgon/rules/math-text-empty.js +10 -0
- package/src/gorgon/rules/math-without-dollars.js +14 -0
- package/src/gorgon/rules/nested-lists.js +11 -0
- package/src/gorgon/rules/profanity.js +10 -0
- package/src/gorgon/rules/table-missing-cells.js +20 -0
- package/src/gorgon/rules/unbalanced-code-delimiters.js +14 -0
- package/src/gorgon/rules/unescaped-dollar.js +10 -0
- package/src/gorgon/rules/widget-in-table.js +10 -0
- package/src/gorgon/selector.js +506 -0
- package/src/gorgon/tree-transformer.js +588 -0
- package/src/hint-renderer.jsx +159 -0
- package/src/hints-renderer.jsx +359 -0
- package/src/icon-paths.js +120 -0
- package/src/index.js +149 -2
- package/src/init.js +49 -0
- package/src/interaction-tracker.js +60 -0
- package/src/interactive2/__tests__/movable-mock.js +48 -0
- package/src/interactive2/__tests__/movable-point_test.js +146 -0
- package/src/interactive2/interactive-util.js +152 -0
- package/src/interactive2/movable-helper-methods.js +160 -0
- package/src/interactive2/movable-line-options.js +392 -0
- package/src/interactive2/movable-line.js +322 -0
- package/src/interactive2/movable-point-options.js +190 -0
- package/src/interactive2/movable-point.jsx +604 -0
- package/src/interactive2/movable-polygon-options.js +351 -0
- package/src/interactive2/movable-polygon.js +367 -0
- package/src/interactive2/movable.js +273 -0
- package/src/interactive2/objective_.js +79 -0
- package/src/interactive2/types.js +3 -0
- package/src/interactive2/wrapped-defaults.js +86 -0
- package/src/interactive2/wrapped-ellipse.js +87 -0
- package/src/interactive2/wrapped-line.js +109 -0
- package/src/interactive2/wrapped-path.js +47 -0
- package/src/interactive2.js +91 -0
- package/src/item-renderer.jsx +518 -0
- package/src/item-version.js +12 -0
- package/src/jipt-paragraphs.js +44 -0
- package/src/jquery.mobile.vmouse.js +545 -0
- package/src/keypad-context.js +33 -0
- package/src/loading-context.js +20 -0
- package/src/logging/log.js +107 -0
- package/src/logging/log_test.js +41 -0
- package/src/mixins/changeable.jsx +115 -0
- package/src/mixins/editor-jsonify.jsx +13 -0
- package/src/mixins/provide-keypad.jsx +131 -0
- package/src/mixins/widget-jsonify-deprecated.jsx +23 -0
- package/src/mixins/widget-prop-blacklist.js +36 -0
- package/src/multi-items/__stories__/multi-renderer.stories.js +88 -0
- package/src/multi-items/__testdata__/multi-renderer_testdata.js +174 -0
- package/src/multi-items/__tests__/__snapshots__/multi-renderer_test.js.snap +994 -0
- package/src/multi-items/__tests__/items_test.js +245 -0
- package/src/multi-items/__tests__/multi-renderer_test.js +903 -0
- package/src/multi-items/__tests__/prop-type-builders_test.js +134 -0
- package/src/multi-items/__tests__/shapes_test.js +44 -0
- package/src/multi-items/__tests__/trees_test.js +316 -0
- package/src/multi-items/item-types.js +55 -0
- package/src/multi-items/items.js +176 -0
- package/src/multi-items/multi-renderer.jsx +542 -0
- package/src/multi-items/prop-type-builders.js +105 -0
- package/src/multi-items/shape-types.js +47 -0
- package/src/multi-items/shapes.js +53 -0
- package/src/multi-items/tree-types.js +42 -0
- package/src/multi-items/trees.js +345 -0
- package/src/multi-items.js +76 -0
- package/src/not-gorgon.js +129 -0
- package/src/perseus-api.jsx +270 -0
- package/src/perseus-env.js +26 -0
- package/src/perseus-error.js +19 -0
- package/src/perseus-markdown.jsx +434 -0
- package/src/perseus-types.js +1597 -0
- package/src/pure-markdown.js +346 -0
- package/src/question-paragraph.jsx +30 -0
- package/src/renderability.jsx +108 -0
- package/src/renderer.jsx +1931 -0
- package/src/server-item-renderer.jsx +467 -0
- package/src/sigfigs.jsx +492 -0
- package/src/styles/articles.less +748 -0
- package/src/styles/constants.js +119 -0
- package/src/styles/global-constants.js +350 -0
- package/src/styles/global-styles.js +307 -0
- package/src/styles/khan-exercise.css +1304 -0
- package/src/styles/media-queries.js +48 -0
- package/src/styles/perseus-renderer.less +1008 -0
- package/src/styles/shared.js +132 -0
- package/src/styles/util.less +47 -0
- package/src/styles/variables.boostrap.less +301 -0
- package/src/styles/variables.less +68 -0
- package/src/styles/variables.shared.less +356 -0
- package/src/styles/widgets/categorizer.less +39 -0
- package/src/styles/widgets/definition.less +86 -0
- package/src/styles/widgets/dropdown.less +3 -0
- package/src/styles/widgets/expression.less +147 -0
- package/src/styles/widgets/graded-group.less +36 -0
- package/src/styles/widgets/grapher.less +11 -0
- package/src/styles/widgets/group.less +19 -0
- package/src/styles/widgets/image.less +29 -0
- package/src/styles/widgets/interactive-graph.less +61 -0
- package/src/styles/widgets/label-image.less +41 -0
- package/src/styles/widgets/matcher.less +8 -0
- package/src/styles/widgets/matrix.less +120 -0
- package/src/styles/widgets/measurer.less +20 -0
- package/src/styles/widgets/orderer.less +97 -0
- package/src/styles/widgets/passage.less +151 -0
- package/src/styles/widgets/plotter.less +33 -0
- package/src/styles/widgets/radio.less +52 -0
- package/src/styles/widgets/reaction-diagram.less +35 -0
- package/src/styles/widgets/sequence.less +5 -0
- package/src/styles/widgets/sortable.less +127 -0
- package/src/styles/widgets/table.less +56 -0
- package/src/styles/widgets/transformer.less +28 -0
- package/src/styles/widgets/unit.less +14 -0
- package/src/tex-wrangler.js +176 -0
- package/src/traversal.jsx +141 -0
- package/src/types.js +538 -0
- package/src/util/a11y.js +24 -0
- package/src/util/answer-types.js +862 -0
- package/src/util/answer-types_test.js +115 -0
- package/src/util/colors.js +94 -0
- package/src/util/fix-passage-refs.jsx +122 -0
- package/src/util/graph-utils.js +16 -0
- package/src/util/graphie.js +1585 -0
- package/src/util/interactive.js +4071 -0
- package/src/util/katex-preprocess.js +16 -0
- package/src/util/math.js +296 -0
- package/src/util/mobile-native-utils.js +14 -0
- package/src/util/mobile-native-utils_test.js +24 -0
- package/src/util/register-all-widgets-for-testing.js +12 -0
- package/src/util/scroll-utils.js +162 -0
- package/src/util/sizing-utils.js +46 -0
- package/src/util/tex.js +203 -0
- package/src/util/url-utils.js +36 -0
- package/src/util.js +990 -0
- package/src/version.js +11 -0
- package/src/widget-container.jsx +174 -0
- package/src/widgets/__stories__/categorizer.stories.jsx +15 -0
- package/src/widgets/__stories__/cs-program.stories.jsx +15 -0
- package/src/widgets/__stories__/definition.stories.jsx +38 -0
- package/src/widgets/__stories__/dropdown.stories.jsx +15 -0
- package/src/widgets/__stories__/explanation.stories.jsx +19 -0
- package/src/widgets/__stories__/expression.stories.jsx +26 -0
- package/src/widgets/__stories__/graded-group-set.stories.jsx +32 -0
- package/src/widgets/__stories__/graded-group.stories.jsx +32 -0
- package/src/widgets/__stories__/grapher.stories.jsx +47 -0
- package/src/widgets/__stories__/group.stories.jsx +15 -0
- package/src/widgets/__stories__/iframe.stories.jsx +15 -0
- package/src/widgets/__stories__/image.stories.jsx +62 -0
- package/src/widgets/__stories__/input-number.stories.jsx +90 -0
- package/src/widgets/__stories__/interaction.stories.jsx +15 -0
- package/src/widgets/__stories__/interactive-graph.stories.jsx +61 -0
- package/src/widgets/__stories__/matcher.stories.jsx +15 -0
- package/src/widgets/__stories__/matrix.stories.jsx +15 -0
- package/src/widgets/__stories__/number-line.stories.jsx +15 -0
- package/src/widgets/__stories__/numeric-input.stories.jsx +19 -0
- package/src/widgets/__stories__/orderer.stories.jsx +15 -0
- package/src/widgets/__stories__/passage-ref.stories.jsx +19 -0
- package/src/widgets/__stories__/passage.stories.jsx +19 -0
- package/src/widgets/__stories__/radio.stories.jsx +82 -0
- package/src/widgets/__stories__/sorter.stories.jsx +15 -0
- package/src/widgets/__stories__/transformer.stories.jsx +15 -0
- package/src/widgets/__stories__/video.stories.jsx +15 -0
- package/src/widgets/__testdata__/categorizer_testdata.js +50 -0
- package/src/widgets/__testdata__/cs-program_testdata.js +28 -0
- package/src/widgets/__testdata__/dropdown_testdata.js +34 -0
- package/src/widgets/__testdata__/explanation_testdata.js +56 -0
- package/src/widgets/__testdata__/expression_testdata.js +95 -0
- package/src/widgets/__testdata__/graded-group-set_testdata.js +358 -0
- package/src/widgets/__testdata__/graded-group_testdata.js +79 -0
- package/src/widgets/__testdata__/grapher_testdata.js +376 -0
- package/src/widgets/__testdata__/group_testdata.js +156 -0
- package/src/widgets/__testdata__/iframe_testdata.js +36 -0
- package/src/widgets/__testdata__/image_testdata.js +38 -0
- package/src/widgets/__testdata__/input-number_testdata.js +73 -0
- package/src/widgets/__testdata__/interaction_testdata.js +264 -0
- package/src/widgets/__testdata__/interactive-graph_testdata.js +646 -0
- package/src/widgets/__testdata__/matcher_testdata.js +34 -0
- package/src/widgets/__testdata__/matrix_testdata.js +29 -0
- package/src/widgets/__testdata__/number-line_testdata.js +31 -0
- package/src/widgets/__testdata__/numeric-input_testdata.js +266 -0
- package/src/widgets/__testdata__/orderer_testdata.js +58 -0
- package/src/widgets/__testdata__/passage-ref_testdata.js +41 -0
- package/src/widgets/__testdata__/passage_testdata.js +71 -0
- package/src/widgets/__testdata__/radio_testdata.js +210 -0
- package/src/widgets/__testdata__/sorter_testdata.js +20 -0
- package/src/widgets/__testdata__/transformer_testdata.js +109 -0
- package/src/widgets/__testdata__/video_testdata.js +22 -0
- package/src/widgets/__tests__/__snapshots__/categorizer_test.jsx.snap +928 -0
- package/src/widgets/__tests__/__snapshots__/cs-program_test.jsx.snap +75 -0
- package/src/widgets/__tests__/__snapshots__/definition_test.js.snap +99 -0
- package/src/widgets/__tests__/__snapshots__/dropdown_test.jsx.snap +143 -0
- package/src/widgets/__tests__/__snapshots__/explanation_test.js.snap +473 -0
- package/src/widgets/__tests__/__snapshots__/expression_test.jsx.snap +38 -0
- package/src/widgets/__tests__/__snapshots__/graded-group-set-jipt_test.jsx.snap +754 -0
- package/src/widgets/__tests__/__snapshots__/graded-group-set_test.jsx.snap +310 -0
- package/src/widgets/__tests__/__snapshots__/graded-group_test.jsx.snap +863 -0
- package/src/widgets/__tests__/__snapshots__/grapher_test.jsx.snap +2880 -0
- package/src/widgets/__tests__/__snapshots__/group_test.jsx.snap +1154 -0
- package/src/widgets/__tests__/__snapshots__/iframe_test.jsx.snap +69 -0
- package/src/widgets/__tests__/__snapshots__/image_test.jsx.snap +388 -0
- package/src/widgets/__tests__/__snapshots__/input-number_test.jsx.snap +978 -0
- package/src/widgets/__tests__/__snapshots__/interaction_test.jsx.snap +311 -0
- package/src/widgets/__tests__/__snapshots__/interactive-graph_test.jsx.snap +2915 -0
- package/src/widgets/__tests__/__snapshots__/matcher_test.jsx.snap +1039 -0
- package/src/widgets/__tests__/__snapshots__/matrix_test.jsx.snap +450 -0
- package/src/widgets/__tests__/__snapshots__/number-line_test.jsx.snap +888 -0
- package/src/widgets/__tests__/__snapshots__/numeric-input_test.jsx.snap +930 -0
- package/src/widgets/__tests__/__snapshots__/orderer_test.jsx.snap +275 -0
- package/src/widgets/__tests__/__snapshots__/passage-ref_test.jsx.snap +446 -0
- package/src/widgets/__tests__/__snapshots__/passage_test.jsx.snap +1988 -0
- package/src/widgets/__tests__/__snapshots__/radio_test.jsx.snap +7107 -0
- package/src/widgets/__tests__/__snapshots__/video_test.jsx.snap +163 -0
- package/src/widgets/__tests__/categorizer_test.jsx +205 -0
- package/src/widgets/__tests__/cs-program_test.jsx +45 -0
- package/src/widgets/__tests__/definition_test.js +152 -0
- package/src/widgets/__tests__/dropdown_test.jsx +106 -0
- package/src/widgets/__tests__/explanation_test.js +199 -0
- package/src/widgets/__tests__/expression_test.jsx +439 -0
- package/src/widgets/__tests__/graded-group-set-jipt_test.jsx +33 -0
- package/src/widgets/__tests__/graded-group-set_test.jsx +270 -0
- package/src/widgets/__tests__/graded-group_test.jsx +233 -0
- package/src/widgets/__tests__/grapher.cypress.jsx +486 -0
- package/src/widgets/__tests__/grapher_test.jsx +35 -0
- package/src/widgets/__tests__/group_test.jsx +512 -0
- package/src/widgets/__tests__/iframe_test.jsx +47 -0
- package/src/widgets/__tests__/image_test.jsx +65 -0
- package/src/widgets/__tests__/input-number_test.jsx +360 -0
- package/src/widgets/__tests__/interaction_test.jsx +33 -0
- package/src/widgets/__tests__/interactive-graph.cypress.jsx +697 -0
- package/src/widgets/__tests__/interactive-graph_test.jsx +105 -0
- package/src/widgets/__tests__/matcher_test.jsx +157 -0
- package/src/widgets/__tests__/matrix_test.jsx +84 -0
- package/src/widgets/__tests__/number-line_test.jsx +81 -0
- package/src/widgets/__tests__/numeric-input_test.jsx +574 -0
- package/src/widgets/__tests__/orderer_test.jsx +75 -0
- package/src/widgets/__tests__/passage-ref_test.jsx +166 -0
- package/src/widgets/__tests__/passage_test.jsx +133 -0
- package/src/widgets/__tests__/radio/base-radio_test.jsx +82 -0
- package/src/widgets/__tests__/radio_test.jsx +651 -0
- package/src/widgets/__tests__/renderQuestion.jsx +65 -0
- package/src/widgets/__tests__/unit_test.jsx +144 -0
- package/src/widgets/__tests__/video_test.jsx +55 -0
- package/src/widgets/categorizer.jsx +338 -0
- package/src/widgets/cs-program.jsx +228 -0
- package/src/widgets/definition.jsx +141 -0
- package/src/widgets/dropdown.jsx +143 -0
- package/src/widgets/explanation.jsx +315 -0
- package/src/widgets/expression.jsx +654 -0
- package/src/widgets/graded-group-answer-bar.jsx +152 -0
- package/src/widgets/graded-group-set.jsx +285 -0
- package/src/widgets/graded-group.jsx +448 -0
- package/src/widgets/grapher/util.jsx +819 -0
- package/src/widgets/grapher.jsx +658 -0
- package/src/widgets/group.jsx +213 -0
- package/src/widgets/iframe.jsx +199 -0
- package/src/widgets/image.jsx +309 -0
- package/src/widgets/input-number.jsx +410 -0
- package/src/widgets/interaction/arrow-picker.jsx +39 -0
- package/src/widgets/interaction/color-picker.jsx +69 -0
- package/src/widgets/interaction/dash-picker.jsx +46 -0
- package/src/widgets/interaction/element-container.jsx +97 -0
- package/src/widgets/interaction.jsx +742 -0
- package/src/widgets/interactive-graph.jsx +2821 -0
- package/src/widgets/label-image/__stories__/answer-choices.stories.jsx +93 -0
- package/src/widgets/label-image/__stories__/marker.stories.jsx +172 -0
- package/src/widgets/label-image/answer-choices.jsx +311 -0
- package/src/widgets/label-image/marker.jsx +365 -0
- package/src/widgets/label-image/types.js +33 -0
- package/src/widgets/label-image.jsx +841 -0
- package/src/widgets/label-image_test.js +840 -0
- package/src/widgets/lights-puzzle.jsx +356 -0
- package/src/widgets/matcher.jsx +271 -0
- package/src/widgets/matrix.jsx +615 -0
- package/src/widgets/measurer.jsx +215 -0
- package/src/widgets/molecule/__tests__/layout_test.jsx +159 -0
- package/src/widgets/molecule/__tests__/parser_test.jsx +142 -0
- package/src/widgets/molecule/molecule-drawing.jsx +175 -0
- package/src/widgets/molecule/molecule-layout.jsx +367 -0
- package/src/widgets/molecule/smiles-parser.jsx +300 -0
- package/src/widgets/molecule.jsx +172 -0
- package/src/widgets/number-line.jsx +858 -0
- package/src/widgets/numeric-input.jsx +622 -0
- package/src/widgets/orderer.jsx +753 -0
- package/src/widgets/passage/__tests__/passage-markdown_test.jsx +382 -0
- package/src/widgets/passage/get-line-height-for-node.js +10 -0
- package/src/widgets/passage/passage-markdown.jsx +416 -0
- package/src/widgets/passage-ref-target.jsx +70 -0
- package/src/widgets/passage-ref.jsx +198 -0
- package/src/widgets/passage.jsx +601 -0
- package/src/widgets/plotter.jsx +1198 -0
- package/src/widgets/radio/__stories__/base-radio.stories.jsx +40 -0
- package/src/widgets/radio/__stories__/choice-icon.stories.jsx +157 -0
- package/src/widgets/radio/__stories__/choice-none-above.stories.jsx +26 -0
- package/src/widgets/radio/__stories__/cross-out-button.stories.jsx +64 -0
- package/src/widgets/radio/__stories__/cross-out-menu.stories.jsx +59 -0
- package/src/widgets/radio/__stories__/cross-out-tooltip.stories.jsx +59 -0
- package/src/widgets/radio/__stories__/focus-ring.stories.jsx +38 -0
- package/src/widgets/radio/__stories__/option-status.stories.jsx +118 -0
- package/src/widgets/radio/__stories__/toggleable-radio-button.stories.jsx +28 -0
- package/src/widgets/radio/base-radio.jsx +642 -0
- package/src/widgets/radio/choice-icon.jsx +468 -0
- package/src/widgets/radio/choice-none-above.jsx +54 -0
- package/src/widgets/radio/choice.jsx +692 -0
- package/src/widgets/radio/choice.jsx.fixture.js +64 -0
- package/src/widgets/radio/cross-out-button.jsx +136 -0
- package/src/widgets/radio/cross-out-menu-wrapper.jsx +492 -0
- package/src/widgets/radio/cross-out-tooltip.jsx +129 -0
- package/src/widgets/radio/focus-ring.jsx +51 -0
- package/src/widgets/radio/option-status.jsx +89 -0
- package/src/widgets/radio/toggleable-radio-button.jsx +133 -0
- package/src/widgets/radio/util.js +32 -0
- package/src/widgets/radio/util_test.js +19 -0
- package/src/widgets/radio/widget.jsx +470 -0
- package/src/widgets/radio.jsx +156 -0
- package/src/widgets/reaction-diagram.jsx +136 -0
- package/src/widgets/sequence.jsx +140 -0
- package/src/widgets/simulator.jsx +808 -0
- package/src/widgets/sorter.jsx +146 -0
- package/src/widgets/table.jsx +395 -0
- package/src/widgets/transformer.jsx +2870 -0
- package/src/widgets/unit.jsx +371 -0
- package/src/widgets/video-transcript-link.jsx +84 -0
- package/src/widgets/video-transcript-link_test.js +211 -0
- package/src/widgets/video.jsx +131 -0
- package/src/widgets.js +431 -0
- package/src/zoom.js +539 -0
- package/src/__tests__/index.test.js +0 -14
package/dist/index.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
"use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("@khanacademy/wonder-blocks-i18n"));exports.foo=()=>r._("foo");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@khanacademy/math-input"),t=require("@khanacademy/wonder-blocks-i18n"),n=require("classnames"),o=require("kas"),s=require("react"),i=require("underscore"),r=require("prop-types"),a=require("jquery"),l=require("react-dom"),c=require("simple-markdown"),d=require("aphrodite"),p=require("kmath"),u=require("create-react-class"),h=require("mathquill"),f=require("@khanacademy/wonder-blocks-color"),m=require("@khanacademy/wonder-blocks-core");require("intersection-observer");var g=require("@khanacademy/wonder-blocks-spacing"),v=require("@khanacademy/wonder-blocks-tooltip"),y=require("@khanacademy/wonder-blocks-dropdown"),b=require("@khanacademy/wonder-blocks-popover"),x=require("@khanacademy/wonder-blocks-link");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function C(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var k=C(t),S=w(n),E=w(o),_=C(s),T=w(s),M=w(i),I=w(r),P=w(a),N=w(l),A=C(l),R=w(c),F=w(p),O=w(u),D=w(h),L=w(f),B=w(g),z=w(v),q=w(x),H={major:11,minor:0},W={major:0,minor:1};function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(){return G=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},G.apply(this,arguments)}const V=e=>{let{path:t,width:n,height:o,style:s={},title:i}=e;return _.createElement("svg",{role:"img","aria-hidden":!i,style:{verticalAlign:"middle",...s},width:"".concat(n/o,"em"),height:"1em",viewBox:"0 0 ".concat(n," ").concat(o)},!!i&&_.createElement("title",null,i),_.createElement("path",{d:t,fill:"currentColor"}))};V.propTypes={path:I.default.string.isRequired,height:I.default.number.isRequired,width:I.default.number.isRequired,style:I.default.object,title:I.default.string};let j=null;const Y=()=>{if(j)return j;throw new Error(["Perseus has not been provided required dependencies.","setDependencies(dependencies) must be called first.","Make sure Perseus is being imported from javascript/perseus/perseus.js."].join("\n"))};var $=Object.freeze({__proto__:null,setDependencies:e=>{j=e},getDependencies:Y});const X={};function K(e){if(!X[e]){const t=P.default("<span>").text(e).appendTo("body");X[e]=t.width()+5,t.remove()}return X[e]}class Z extends _.Component{constructor(){super(...arguments),U(this,"state",{items:this.props.options.concat("")}),U(this,"onChange",((e,t)=>{let n=M.default.clone(this.state.items);n[e]=t.target.value,e===n.length-1&&(n=n.concat("")),this.setState({items:n}),this.props.onChange(M.default.compact(n))})),U(this,"onKeyDown",((e,t)=>{const n=t.nativeEvent.keyCode;if(8===n&&""===this.state.items[e]){t.preventDefault();const n=M.default.clone(this.state.items),o=0===e?0:e-1;e!==n.length-1||0!==e&&""===n[o]?(n.splice(e,1),this.setState({items:n},(function(){N.default.findDOMNode(this.refs["input_"+o]).focus()}))):N.default.findDOMNode(this.refs["input_"+o]).focus()}else if(8===n&&1===this.state.items[e].length&&e===this.state.items.length-2){t.preventDefault();const n=M.default.clone(this.state.items);n.splice(e,1),this.setState({items:n}),this.props.onChange(M.default.compact(n))}else if(13===n){t.preventDefault();const n=M.default.clone(this.state.items),o=e+1;e===n.length-2?N.default.findDOMNode(this.refs["input_"+o]).focus():(n.splice(o,0,""),this.setState({items:n},(function(){N.default.findDOMNode(this.refs["input_"+o]).focus()})))}}))}UNSAFE_componentWillReceiveProps(e){this.setState({items:e.options.concat("")})}render(){const e=["perseus-text-list-editor","perseus-clearfix","layout-"+this.props.layout].join(" "),t=M.default.map(this.state.items,(function(e,t){return _.createElement("li",{key:t},_.createElement("input",{ref:"input_"+t,type:"text",value:e,onChange:this.onChange.bind(this,t),onKeyDown:this.onKeyDown.bind(this,t),style:{width:K(e)}}))}),this);return _.createElement("ul",{className:e},t)}}U(Z,"propTypes",{options:I.default.array,layout:I.default.string,onChange:I.default.func.isRequired}),U(Z,"defaultProps",{options:[],layout:"horizontal"});const J=[];class Q extends _.Component{render(){return _.createElement("div",null,this.props.showTitle&&_.createElement("div",{style:{fontSize:14}},"Tags:"),_.createElement(Z,{options:this.props.value||J,layout:"vertical",onChange:this.props.onChange}))}}U(Q,"propTypes",{value:I.default.arrayOf(I.default.string),onChange:I.default.func.isRequired,showTitle:I.default.bool.isRequired}),U(Q,"defaultProps",{value:J,showTitle:!0});const ee={propTypes:I.default.shape({isArticle:I.default.bool.isRequired,satStyling:I.default.bool.isRequired,onInputError:I.default.func.isRequired,onFocusChange:I.default.func.isRequired,staticRender:I.default.bool.isRequired,GroupMetadataEditor:I.default.func.isRequired,showAlignmentOptions:I.default.bool.isRequired,readOnly:I.default.bool.isRequired,answerableCallback:I.default.func,getAnotherHint:I.default.func,interactionCallback:I.default.func,groupAnnotator:I.default.func.isRequired,imagePlaceholder:I.default.node,widgetPlaceholder:I.default.node,baseElements:I.default.shape({Link:I.default.func}),imagePreloader:I.default.func,trackInteraction:I.default.func,customKeypad:I.default.bool,nativeKeypadProxy:I.default.func,isMobile:I.default.bool,setDrawingAreaAvailable:I.default.func,useDraftEditor:I.default.bool,styling:I.default.shape({radioStyleVersion:I.default.oneOf(["intermediate","final"])}),hintProgressColor:I.default.string,canScrollPage:I.default.bool,inModal:I.default.bool,crossOutEnabled:I.default.bool,editorChangeDelay:I.default.number}).isRequired,defaults:{isArticle:!1,isMobile:!1,satStyling:!1,onInputError:function(){},onFocusChange:function(){},staticRender:!1,GroupMetadataEditor:Q,showAlignmentOptions:!1,readOnly:!1,groupAnnotator:function(){return null},baseElements:{Link:e=>_.createElement("a",e)},setDrawingAreaAvailable:function(){},useDraftEditor:!1,styling:{radioStyleVersion:"final"},canScrollPage:!1,inModal:!1,crossOutEnabled:!1,editorChangeDelay:0}},te={RENDERER:"perseus-renderer",TWO_COLUMN_RENDERER:"perseus-renderer-two-columns",RESPONSIVE_RENDERER:"perseus-renderer-responsive",INPUT:"perseus-input",FOCUSED:"perseus-focused",RADIO:{OPTION:"perseus-radio-option",SELECTED:"perseus-radio-selected",OPTION_CONTENT:"perseus-radio-option-content"},INTERACTIVE:"perseus-interactive",CORRECT:"perseus-correct",INCORRECT:"perseus-incorrect",UNANSWERED:"perseus-unanswered",MOBILE:"perseus-mobile"};function ne(e,t,n){const o=e.indexOf("{",t)+1,s=function(e,t){let n=0;for(let o=t,s=e.length;o<s;o++){const t=e[o];if("{"===t?n++:"}"===t&&n--,n<0)return o}return e.length}(e,o);return{endpoint:s,expression:se(e.substring(o,s),n)}}function oe(e,t){const n=e.indexOf("\\frac",t),o=e.indexOf("\\dfrac",t);return n>-1&&o>-1?Math.min(n,o):n>-1?n:o>-1?o:-1}function se(e,t){if(!e)return"";let n="",o=0,s=oe(e,o);for(;s>-1;){n+=e.substring(o,s),o=s;const i=ne(e,o,t);o=i.endpoint+1;const r=ne(e,o,t);o=r.endpoint+1,n.length&&(n+=" "),n+=t(i.expression,r.expression),s=oe(e,o)}return n+=e.slice(o),n}var ie=function(e){return se(e,(function(e,t){return e+"/"+t})).replace("\\%","%")},re=function(e){function t(e){return e.indexOf("\\frac")>-1||e.indexOf("\\dfrac")>-1}return se(e,(function(e,n){let o;return o=t(e)||t(n)?"\\dfrac":"\\frac",o+" {"+e+"}{"+n+"}"}))};const ae=re;class le extends _.Component{constructor(){super(...arguments),U(this,"state",{focused:!1,selectorNamespace:M.default.uniqueId("math-output")}),U(this,"_getInputClassName",(()=>{let e="math-output "+te.INPUT+" "+te.INTERACTIVE;return this.state.focused&&(e+=" "+te.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),U(this,"_getDisplayValue",(e=>{let t;return t=null!=e?""+e:"",ae(t)})),U(this,"getValue",(()=>this.props.value)),U(this,"focus",(()=>{this.state.focused||(this.props.onFocus(),this._bindBlurHandler(),this.setState({focused:!0}))})),U(this,"blur",(()=>{this.state.focused&&(this.props.onBlur(),this._unbindBlurHandler(),this.setState({focused:!1}))})),U(this,"_bindBlurHandler",(()=>{P.default(document).bind("vclick."+this.state.selectorNamespace,(e=>{P.default(e.target).closest(N.default.findDOMNode(this)).length||this.blur()}))})),U(this,"_unbindBlurHandler",(()=>{P.default(document).unbind("."+this.state.selectorNamespace)}))}render(){const{TeX:e}=Y();return _.createElement("span",{ref:"input",className:this._getInputClassName(),"aria-label":this.props.labelText,onMouseDown:this.focus,onTouchStart:this.focus},_.createElement("div",{style:{textAlign:"center"}},_.createElement(e,null,this._getDisplayValue(this.props.value))))}componentWillUnmount(){this._unbindBlurHandler()}}U(le,"propTypes",{value:I.default.oneOfType([I.default.string,I.default.number]),className:I.default.string,labelText:I.default.string,onFocus:I.default.func,onBlur:I.default.func}),U(le,"defaultProps",{value:"",onFocus:function(){},onBlur:function(){}});const ce="'Proxima Nova Semibold',sans-serif",de="#FFFFFF",pe="#BABEC2",ue="#888D93",he="#21242c",fe={defaultBoxSize:400,defaultBoxSizeSmall:288};var me=Object.freeze({__proto__:null,baseFontFamily:"'Proxima Nova',sans-serif",boldFontFamily:ce,green:"#76A005",kaGreen:"#71B307",blue:"#1C758A",gray:"#AAAAAA",red:"#FFBABA",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",learnstormBlue:"#4898FC",white:de,gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:pe,gray68:ue,gray41:"#626569",gray25:"#3B3e40",gray17:he,black:"#000000",warning1:"#F86700",warning3:"#C75300",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1280px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1279px",tableBackgroundAccent:"#F9F9F9",gtpBlue:"#4c00ff",gtpIncorrectColor:"#babec2",gtpCorrectColor:"#ffbe26",satBlue:"#0084CE",satSelectedBackgroundColor:"#E4F3F9",satActiveBackgroundColor:"#D0EDF4",satCorrectColor:"#009900",satCorrectBorderColor:"#00CC00",satCorrectBackgroundColor:"#E4F7E4",satIncorrectColor:"#990000",satIncorrectBorderColor:"#CC5252",satIncorrectBackgroundColor:"#F2EBEB",zIndexScratchPad:1,zIndexAboveScratchpad:2,zIndexInteractiveComponent:3,zIndexCurrentlyDragging:4,zIndexCalculator:5,phoneMargin:16,negativePhoneMargin:-16,hintBorderWidth:4,baseUnitPx:16,interactiveSizes:fe,circleSize:24,radioMarginWidth:2,warningColor:"#f86700",warningColorHover:"#df5c00",warningColorActive:"#c75300",publishBlockingErrorColor:"#be2612",radioBorderColor:"#BABEC2",checkedColor:"#71B307",articleMaxWidthInPx:688,articleMaxWidthTableInPx:512});const ge={path:"M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",height:12,width:12};class ve extends _.Component{constructor(){super(...arguments),U(this,"_positionTimeout",void 0),U(this,"state",{tooltipAbove:!0}),U(this,"getPosition",(()=>{const e=N.default.findDOMNode(this).getBoundingClientRect();this.setState({tooltipAbove:e.top>100})})),U(this,"renderLink",(e=>{const t=this.state.tooltipAbove;let n,o,s;return 1===this.props.severity?(n=ye.indicatorError,o="Error",s=ye.publishBlockingError):2===this.props.severity?(n=ye.indicatorWarning,o="Warning",s=ye.warning):(n=ye.indicatorGuideline,o="Recommendation",s=ye.warning),_.createElement("a",{href:"https://khanacademy.org/r/linter-rules#".concat(this.props.ruleName),target:"lint-help-window",className:d.css(e)},_.createElement("span",{className:d.css(ye.indicator,n)},1===this.props.severity&&_.createElement(V,ge)),_.createElement("div",{className:d.css(ye.tooltip,t&&ye.tooltipAbove)},this.props.message.split("\n\n").map(((e,t)=>_.createElement("p",{key:t,className:d.css(ye.tooltipParagraph)},_.createElement("span",{className:d.css(s)},o,":"," "),e))),_.createElement("div",{className:d.css(ye.tail,t&&ye.tailAbove)})))}))}componentDidMount(){this._positionTimeout=window.setTimeout(this.getPosition)}componentWillUnmount(){window.clearTimeout(this._positionTimeout)}render(){const{children:e,inline:t,blockHighlight:n,insideTable:o}=this.props;return o?t?_.createElement("span",{"data-lint-inside-table":"true"},e):_.createElement("div",{"data-lint-inside-table":"true"},e):n?_.createElement("span",{className:d.css(ye.lintContainer,ye.lintContainerBlock)},this.renderLink(ye.radioWidgetHoverTarget),_.createElement("span",null,e)):t?_.createElement("span",{className:d.css(ye.lintContainer)},this.renderLink(ye.inlineHoverTarget),_.createElement("span",null,e)):_.createElement("div",{className:d.css(ye.lintContainer)},this.renderLink(ye.hoverTarget),_.createElement("div",null,e))}}U(ve,"propTypes",{children:I.default.node,inline:I.default.bool,message:I.default.string.isRequired,ruleName:I.default.string.isRequired,insideTable:I.default.bool.isRequired,blockHighlight:I.default.bool,severity:I.default.number});const ye=d.StyleSheet.create({lintContainer:{position:"relative"},lintContainerBlock:{display:"block"},hoverTarget:{position:"absolute",top:0,right:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ div":{outline:"1px solid #f86700"},":hover ~ div div[data-lint-inside-table]":{outline:"1px solid #f86700"},":hover ~ div span[data-lint-inside-table]":{backgroundColor:"#f86700",color:de}},inlineHoverTarget:{float:"right",position:"relative",marginRight:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ span":{backgroundColor:"#f86700",color:de}},radioWidgetHoverTarget:{position:"absolute",left:-40,display:"block",width:24,height:24,minWidth:264,":hover > span":{backgroundColor:"#df5c00"},":hover > div":{display:"block",padding:8,width:280},":hover > div > div":{left:8},":hover ~ span":{backgroundColor:"#f86700",color:de}},indicator:{alignItems:"center",borderRadius:4,color:"white",display:"flex",fontSize:12,height:8,justifyContent:"center",margin:8,width:8},indicatorError:{backgroundColor:"#be2612",borderRadius:8,height:16,width:16},indicatorWarning:{backgroundColor:"#f86700"},indicatorGuideline:{backgroundColor:"#ffbe26"},tooltip:{position:"absolute",right:-12,display:"none",zIndex:1e3,color:de,backgroundColor:he,opacity:.9,fontFamily:"'Proxima Nova',sans-serif",fontSize:"12px",lineHeight:"15px",width:"320px",borderRadius:"4px"},tooltipAbove:{bottom:32},tail:{position:"absolute",top:-12,right:16,width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:"12px solid #21242c"},tailAbove:{bottom:-12,borderBottom:"none",borderTop:"12px solid #21242c",top:"auto"},tooltipParagraph:{margin:12},warning:{color:"#f86700",fontFamily:ce},publishBlockingError:{color:"#be2612"}}),be=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"}),xe={log:(e,t)=>{Y().Log.log(e,t)},error:(e,t,n)=>{Y().Log.error(e,t,n)}};class we extends Error{constructor(e,t,n){super(e),U(this,"kind",void 0),U(this,"metadata",void 0),this.kind=t,this.metadata=null==n?void 0:n.metadata}}const Ce={cleanMath:function(e){return"string"==typeof e?e.replace(/\+\s*-/g,"- ").replace(/-\s*-/g,"+ ").replace(/\^1/g,""):e},bound:function(e){return 0===e?e:e<0?-Ce.bound(-e):Math.max(1e-6,Math.min(e,1e20))},factorial:function(e){return e<=1?e:e*Ce.factorial(e-1)},getGCD:function(e,t){if(arguments.length>2){const t=[].slice.call(arguments,1);return Ce.getGCD(e,Ce.getGCD(...t))}let n;for(e=Math.abs(e),t=Math.abs(t);t;)n=e%t,e=t,t=n;return e},getLCM:function(e,t){if(arguments.length>2){const t=[].slice.call(arguments,1);return Ce.getLCM(e,Ce.getLCM(...t))}return Math.abs(e*t)/Ce.getGCD(e,t)},primes:[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97],isPrime:function(e){if(e<=1)return!1;if(e<101)return!!P.default.grep(Ce.primes,(function(t,n){return Math.abs(t-e)<=.5})).length;if(e<=1||e>2&&e%2==0)return!1;for(let t=3,n=Math.sqrt(e);t<=n;t+=2)if(e%t==0)return!1;return!0},getPrimeFactorization:function(e){if(1===e)return[];if(Ce.isPrime(e))return[e];const t=Math.sqrt(e);for(let n=2;n<=t;n++)if(e%n==0)return P.default.merge(Ce.getPrimeFactorization(n),Ce.getPrimeFactorization(e/n))},roundToNearest:function(e,t){return Math.round(t/e)*e},roundTo:function(e,t){const n=Math.pow(10,e).toFixed(5);return Math.round((t*n).toFixed(5))/n},toFixedApprox:function(e,t){const n=e.toFixed(t);return p.number.equal(+n,e)?n:"\\approx "+n},roundToApprox:function(e,t){const n=Ce.roundTo(t,e);return p.number.equal(n,e)?String(n):Ce.toFixedApprox(e,t)},toFraction:function(e,t){if(null==t&&(t=Math.pow(2,-46)),e<0||e>1){let n=e%1;n+=n<0?1:0;const o=Ce.toFraction(n,t);return o[0]+=Math.round(e-n)*o[1],o}if(Math.abs(Math.round(Number(e))-e)<=t)return[Math.round(e),1];let n=0,o=1,s=1,i=1,r=1,a=2;for(;;){if(Math.abs(Number(r/a)-e)<=t)return[r,a];r/a<e?(n=r,o=a):(s=r,i=a),r=n+s,a=o+i}},getNumericFormat:function(e){if((e=(e=P.default.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1")).match(/^[+-]?\d+$/))return"integer";if(e.match(/^[+-]?\d+\s+\d+\s*\/\s*\d+$/))return"mixed";const t=e.match(/^[+-]?(\d+)\s*\/\s*(\d+)$/);return t?parseFloat(t[1])>parseFloat(t[2])?"improper":"proper":e.replace(/[,. ]/g,"").match(/^\d+$/)?"decimal":e.match(/(pi?|\u03c0|t(?:au)?|\u03c4|pau)/)?"pi":null},toNumericString:function(e,t){if(null==e)return"";if(0===e)return"0";if("percent"===t)return 100*e+"%";if("pi"===t){const t=p.number.toFraction(e/Math.PI),n=Math.abs(t[0]),o=t[1];if(p.number.isInteger(n)){return(e<0?"-":"")+(1===n?"":n)+"π"+(1===o?"":"/"+o)}}if(M.default(["proper","improper","mixed","fraction"]).contains(t)){const n=p.number.toFraction(e),o=Math.abs(n[0]),s=n[1],i=e<0?"-":"";if(1===s)return i+o;if("mixed"===t){const e=o%s,t=(o-e)/s;return i+(t?t+" ":"")+e+"/"+s}return i+o+"/"+s}return String(e)}},ke=Math.pow(2,-42),Se={APPROXIMATED_PI_ERROR:k._("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>"),EXTRA_SYMBOLS_ERROR:k._("We could not understand your answer. Please check your answer for extra text or symbols."),NEEDS_TO_BE_SIMPLFIED_ERROR:k._("Your answer is almost correct, but it needs to be simplified."),MISSING_PERCENT_ERROR:k._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end."),MULTIPLICATION_SIGN_ERROR:k._("I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign."),WRONG_CASE_ERROR:k._("Your answer includes use of a variable with the wrong case."),WRONG_LETTER_ERROR:k._("Your answer includes a wrong variable letter.")},Ee={predicate:{defaultForms:"integer, proper, improper, mixed, decimal",createValidatorFunctional:function(e,t){let n;t=M.default.extend({simplify:"required",ratio:!1,forms:Ee.predicate.defaultForms},t),n=M.default.isArray(t.forms)?t.forms:t.forms.split(/\s*,\s*/),void 0===t.inexact&&(t.maxError=0),t.maxError=+t.maxError+ke,M.default.contains(n,"percent")&&(n=M.default.without(n,"percent"),n.push("percent"));const o=function(e){const n=(e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").replace(/(^\s*)|(\s*$)/gi,"")).match(/^([+-]?\d+)\s*\/\s*([+-]?\d+)$/),o=e.match(/^([+-]?)\\frac\{([+-]?\d+)\}\{([+-]?\d+)\}$/),s=parseInt(e,10);if(n||o){let e,s,i=!0;return n?(e=parseFloat(n[1]),s=parseFloat(n[2])):(e=parseFloat(o[2]),"-"===o[1]&&(e<0&&(i=!1),e=-e),s=parseFloat(o[3])),i=i&&s>0&&(t.ratio||1!==s)&&1===Ce.getGCD(e,s),[{value:e/s,exact:i}]}return isNaN(s)||""+s!==e?[]:[{value:s,exact:!0}]},s={integer:function(e){const t=s.decimal(e),n=s.decimal(e,1);return null!=t[0].value&&t[0].value===n[0].value||null!=t[1].value&&t[1].value===n[1].value?t:[]},proper:function(e){return P.default.map(o(e),(function(e){return Math.abs(e.value)<1?[e]:[]}))},improper:function(e){return P.default.map(o(e),(function(e){return Math.abs(e.value)>=1?[e]:[]}))},pi:function(e){let t,n=[];if(t=(e=e.replace(/\u2212/,"-")).match(/^([+-]?)\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=[{value:parseFloat(t[1]+"1"),exact:!0}];else if(t=e.match(/^([+-]?\s*\d+\s*(?:\/\s*[+-]?\s*\d+)?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=o(t[1]);else if(t=e.match(/^([+-]?)\s*(\d+)\s*([+-]?\d+)\s*\/\s*([+-]?\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i)){const e=parseFloat(t[1]+"1"),o=parseFloat(t[2]),s=parseFloat(t[3]),i=parseFloat(t[4]);n=[{value:e*(o+s/i),exact:s<i&&1===Ce.getGCD(s,i)}]}else if(t=e.match(/^([+-]?\s*\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\s*\d+))?$/i))n=o(t[1]+"/"+t[3]);else if(t=e.match(/^([+-]?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\d+))?$/i))n=o(t[1]+"1/"+t[3]);else if("0"===e)n=[{value:0,exact:!0}];else{if(!(t=e.match(/^(.+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))){n=M.default.reduce(Ee.predicate.defaultForms.split(/\s*,\s*/),(function(t,n){return t.concat(s[n](e))}),[]);let t=!1;const o=parseFloat(e);if(isNaN(o)||o===parseInt(e))e.match(/\/\s*7/)&&(t=!0);else{const e=Math.PI/12,n=e*Math.round(o/e);Math.abs(o-n)<.01&&(t=!0)}return t&&M.default.each(n,(function(e){e.piApprox=!0})),n}n=s.decimal(t[1])}let i=Math.PI;return e.match(/\\?tau|t|\u03c4/)&&(i=2*Math.PI),e.match(/pau/)&&(i=1.5*Math.PI),P.default.each(n,(function(e,t){t.value*=i})),n},coefficient:function(e){let t=[];return""===(e=e.replace(/\u2212/,"-"))?t=[{value:1,exact:!0}]:"-"===e&&(t=[{value:-1,exact:!0}]),t},log:function(e){let t,n=[];return(t=(e=(e=e.replace(/\u2212/,"-")).replace(/[ \(\)]/g,"")).match(/^log\s*(\S+)\s*$/i))?n=s.decimal(t[1]):"0"===e&&(n=[{value:0,exact:!0}]),n},percent:function(e){e=P.default.trim(e);let t=!1;e.indexOf("%")===e.length-1&&(e=P.default.trim(e.substring(0,e.length-1)),t=!0);const n=s.decimal(e);return P.default.each(n,(function(e,n){n.exact=t,n.value=n.value/100})),n},mixed:function(e){const t=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?)(\d+)\s+(\d+)\s*\/\s*(\d+)$/);if(t){const e=parseFloat(t[1]+"1"),n=parseFloat(t[2]),o=parseFloat(t[3]),s=parseFloat(t[4]);return[{value:e*(n+o/s),exact:o<s&&1===Ce.getGCD(o,s)}]}return[]},decimal:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10;const o=function(e){const o=(e=P.default.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?(?:\d{1,3}(?:[, ]?\d{3})*\.?|\d{0,3}(?:[, ]?\d{3})*\.(?:\d{3}[, ]?)*\d{1,3}))$/),s=e.match(/^0[0,]*,/);if(o&&!s){let e=parseFloat(o[1].replace(/[, ]/g,""));return void 0===t.inexact&&(e=Math.round(e*n)/n),e}},s=function(e){return e=e.replace(/([\.,])/g,(function(e,t){return"."===t?",":"."})),o(e)};return[{value:o(e),exact:!0},{value:s(e),exact:!0}]}};return function(o){const i=null!=t.fallback?""+t.fallback:"",r={empty:""===(o=P.default.trim(o)||i),correct:!1,message:null,guess:o};if(P.default.each(n,(function(n,i){const a=s[i](o);for(let n=0,o=a.length;n<o;n++){const o=a[n].value,s=a[n].exact,l=a[n].piApprox;if(e(o,t.maxError))return s||"optional"===t.simplify?(r.correct=!0,r.message=t.message||null,r.empty=!1):"percent"===i?(r.empty=!0,r.message=Se.MISSING_PERCENT_ERROR):("enforced"!==t.simplify&&(r.empty=!0),r.message=Se.NEEDS_TO_BE_SIMPLFIED_ERROR),!1;l&&e(o,Math.abs(.001*o))&&(r.empty=!0,r.message=Se.APPROXIMATED_PI_ERROR)}})),!1===r.correct){let e=!1;if(M.default.each(s,(function(t){M.default.any(t(o),(function(e){return null!=e.value&&!M.default.isNaN(e.value)}))&&(e=!0)})),!e)return r.empty=!0,r.message=Se.EXTRA_SYMBOLS_ERROR,r}return r}}},number:{convertToPredicate:function(e,t){const n=parseFloat(P.default.trim(e));return[function(e,t){return Math.abs(e-n)<t},P.default.extend({},t,{type:"predicate"})]},createValidatorFunctional:function(e,t){return Ee.predicate.createValidatorFunctional(...Ee.number.convertToPredicate(e,t))}},expression:{parseSolution:function(e,t){let n=E.default.parse(e,t);if(!n.parsed)throw new we("The provided solution ("+e+") didn't parse.",be.InvalidInput);if(t.simplified&&!n.expr.isSimplified())throw new we("The provided solution ("+e+") isn't fully expanded and simplified.",be.InvalidInput);return n=n.expr,n},createValidatorFunctional:function(e,t){return function(n){const o={empty:!1,correct:!1,message:null,guess:n,ungraded:!1};if(!n)return o.empty=!0,o;const s=E.default.parse(n,t);if(!s.parsed)return o.empty=!0,o;"string"==typeof e&&(e=Ee.expression.parseSolution(e,t));const i=E.default.compare(s.expr,e,t);if(i.equal)o.correct=!0;else if(i.wrongVariableNames||i.wrongVariableCase)o.ungraded=!0,o.message=i.wrongVariableCase?Se.WRONG_CASE_ERROR:Se.WRONG_LETTER_ERROR,o.suppressAlmostThere=!0;else if(i.message)o.message=i.message;else{const s=E.default.parse(n.replace(/[xX]/g,"*"),t);if(s.parsed){const n=E.default.compare(s.expr,e,t);n.equal?(o.ungraded=!0,o.message=Se.MULTIPLICATION_SIGN_ERROR):n.message&&(o.message=n.message+" Also, I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign.")}}return o}}}};let _e=!1;const Te=/^web\+graphie:/,Me=/^file\+graphie:/,Ie=function(e,t,n){return Array.isArray(e)?M.default.map(e,(function(e){return Ie(e,t)})):t.call(n,e)};const Pe=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/,Ne=new RegExp(Pe.source+"$"),Ae=function(e){let t=e;return function(){let e=t;return e=e+2127912214+(e<<12)&4294967295,e=4294967295&(3345072700^e^e>>>19),e=e+374761393+(e<<5)&4294967295,e=4294967295&(e+3550635116^e<<9),e=e+4251993797+(e<<3)&4294967295,e=4294967295&(3042594569^e^e>>>16),(t=268435455&e)/268435456}};const Re="x".split(/(.)/g).length?function(e,t){return e.split(t)}:function(e,t){const n=[];let o,s=t.lastIndex=0;for(;o=t.exec(e);){const t=o;n.push(e.slice(s,t.index)),n.push(...t.slice(1)),s=t.index+t[0].length}return n.push(e.slice(s)),n};function Fe(e,t){const n=e*t,o=e,s=Math.pow(10,Math.floor(Math.log(o)/Math.LN10)),i=Math.floor(o/s);return n<25?e:n<50?5===i?e:e/2:1===i?e/2:2===i?e/4:5===i?e/5:void 0}function Oe(e,t){return t/(e[1]-e[0])}function De(e,t){let n=Math.pow(10,Math.floor(Math.log(e/t)/Math.LN10));const o=t/e*n;return o<=.15?n*=10:o<=.35?n*=5:o<=.75&&(n*=2),n}const Le=(e,t)=>{const n=t[1]-t[0],o=n/e;return o<=10?e:o<=20?2*e:De(n,10)};const Be={UNSAFE_componentWillMount:function(){const e={};M.default.each(this.deprecatedProps,(function(t,n){M.default.has(this.props,n)&&M.default.extend(e,t(this.props))}),this),M.default.isEmpty(e)||(M.default.extend(this.props,e),setTimeout(this.props.onChange,0,e))}};function ze(e,t){return"number"==typeof e&&"number"==typeof t?Math.abs(e-t)<1e-9:e===t}const qe={pointerDown:!1,currentTouchIdentifier:null};function He(e){return We(e)?Ge(e):e}function We(e){return Te.test(e)||Me.test(e)}function Ue(e){return e.replace(Te,"https:").replace(Me,"file:")}function Ge(e){return Ue(e)+".svg"}const Ve={getWordBeforeCursor:function(e){const t=e.value,n=e.selectionStart-1,o=Math.max(t.lastIndexOf("\n",n),t.lastIndexOf(" ",n))+1;return{string:t.substring(o,n+1),pos:{start:o,end:n}}},moveCursor:function(e,t){e.selectionStart=t,e.selectionEnd=t}},je=Ae(4294967295&(new Date).getTime()),Ye={inputPathsEqual:function(e,t){return null==e||null==t?null==e==(null==t):e.length===t.length&&e.every(((e,n)=>t[n]===e))},nestedMap:Ie,rWidgetRule:Pe,rTypeFromWidgetId:/^([a-z-]+) ([0-9]+)$/,rWidgetParts:Ne,snowman:"☃",noScore:{type:"points",earned:0,total:0,message:null},seededRNG:Ae,shuffle:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=M.default.clone(e);if(!o.length||M.default.all(o,(function(e){return M.default.isEqual(e,o[0])})))return o;let s;s="function"==typeof t?t:Ae(t);do{for(let e=o.length;e>0;e--){const t=Math.floor(s()*e),n=o[t];o[t]=o[e-1],o[e-1]=n}}while(n&&M.default.isEqual(e,o));return o},split:Re,combineScores:function(e,t){let n;if("points"===e.type&&"points"===t.type)return n=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"points",earned:e.earned+t.earned,total:e.total+t.total,message:n};if("points"===e.type&&"invalid"===t.type)return t;if("invalid"===e.type&&"points"===t.type)return e;if("invalid"===e.type&&"invalid"===t.type)return n=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"invalid",message:n};throw new we("PerseusScore with unknown type encountered",be.InvalidInput,{metadata:{scoreA:JSON.stringify(e),scoreB:JSON.stringify(t)}})},keScoreFromPerseusScore:function(e,t,n){if("points"===e.type)return{empty:!1,correct:e.earned>=e.total,message:e.message,guess:t,state:n};if("invalid"===e.type)return{empty:!0,correct:!1,message:e.message,suppressAlmostThere:e.suppressAlmostThere,guess:t,state:n};throw new we("Invalid score type: "+e.type,be.InvalidInput,{metadata:{score:JSON.stringify(e),guess:JSON.stringify(t),state:JSON.stringify(n)}})},firstNumericalParse:function(e){let t;return Ee.predicate.createValidatorFunctional((function(e){return t=e,!0}),{simplify:"optional",inexact:!0,forms:"integer, proper, improper, pi, log, mixed, decimal"})(e),t},stringArrayOfSize:function(e){return M.default(e).times((function(){return""}))},gridDimensionConfig:function(e,t,n,o){const s=Oe(t,n);return{scale:s,tickStep:e/o,unityLabel:e*s>30}},getGridStep:function(e,t,n){return M.default(2).times((function(o){const s=Oe(e[o],n);return Fe(t[o],s)}))},snapStepFromGridStep:function(e){return[e[0]/2,e[1]/2]},scaleFromExtent:Oe,tickStepFromExtent:function(e,t){const n=e[1]-e[0];let o;return o=15<n&&n<=20?23:n>100||n<5?10:16,De(n,o*(t/500))},gridStepFromTickStep:Fe,tickStepFromNumTicks:De,constrainedTickStepsFromTickSteps:function(e,t){return[Le(e[0],t[0]),Le(e[1],t[1])]},DeprecationMixin:Be,eq:ze,deepEq:function e(t,n){if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return!1;for(let o=0;o<t.length;o++)if(!e(t[o],n[o]))return!1;return!0}return!Array.isArray(t)&&!Array.isArray(n)&&("function"==typeof t&&"function"==typeof n?ze(t,n):"function"!=typeof t&&"function"!=typeof n&&("object"==typeof t&&"object"==typeof n&&t&&n?t===n||M.default.all(t,(function(t,o){return e(n[o],t)}))&&M.default.all(n,(function(n,o){return e(t[o],n)})):!("object"==typeof t&&t||"object"==typeof n&&n)&&ze(t,n)))},parseQueryString:function(e){e=e||window.location.search.substring(1);const t={},n=/\+/g,o=/([^&=]+)=?([^&]*)/g,s=function(e){return decodeURIComponent(e.replace(n," "))};let i;for(;i=o.exec(e);){const e=i;t[s(e[1])]=s(e[2])}return t},updateQueryString:function(e,t,n){n=encodeURIComponent(n);const o=new RegExp("([?&])"+t+"=.*?(&|$)","i"),s=-1!==e.indexOf("?")?"&":"?";return e.match(o)?e.replace(o,"$1"+t+"="+n+"$2"):e+s+t+"="+n},strongEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/['()!]/g,window.escape).replace(/\*/g,"%2A")},widgetShouldHighlight:function(e){if(!e)return!1;switch(e.type){case"measurer":case"protractor":return!0;default:return!1}},scoreIsEmpty:function(e){return"invalid"===e.type&&(!e.message||0===e.message.length)},touchHandlers:qe,resetTouchHandlers:function(){Object.assign(qe,{pointerDown:!1,currentTouchIdentifier:null})},extractPointerLocation:function(e){let t;if(qe.pointerDown){if(null!=qe.currentTouchIdentifier){const n=e.changedTouches?e.changedTouches.length:0;for(let o=0;o<n;o++)e.changedTouches[o].identifier===qe.currentTouchIdentifier&&(t=e.changedTouches[o])}else t=e;const n="touchend"===e.type||"touchcancel"===e.type;t&&n&&(qe.pointerDown=!1,qe.currentTouchIdentifier=null)}else qe.pointerDown=!0,e.changedTouches?(t=e.changedTouches[0],qe.currentTouchIdentifier=t.identifier):t=e;if(t)return{left:t.pageX,top:t.pageY}},supportsPassiveEvents:()=>{try{const e=Object.defineProperty({},"passive",{get:function(){_e=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(e){}return _e},captureScratchpadTouchStart:function(e){e.stopPropagation()},getImageSize:function(e,t){const n=new Image;n.onload=function(){var e;0===n.width&&0===n.height?(null===(e=document.body)||void 0===e||e.appendChild(n),M.default.defer((function(){var e;t(n.clientWidth,n.clientHeight),null===(e=document.body)||void 0===e||e.removeChild(n)}))):t(n.width,n.height)},n.src=He(e)},getRealImageUrl:He,isLabeledSVG:We,getBaseUrl:Ue,getSvgUrl:Ge,getDataUrl:function(e){return Ue(e)+"-data.json"},textarea:Ve,unescapeMathMode:e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e,random:je},$e=(e,t,n)=>{const o=e.length;let s=0;if(n){if(t.inline)return null;for(;s<o&&" "===e[s];)s++}if(!(s<o&&"$"===e[s]))return null;s++;const i=s;let r=0;for(;s<o;){const t=e[s];if("\\"===t)s++;else{if(r<=0&&"$"===t){let t=s+1;if(n){const n=/^(?: *\n){2,}/.exec(e.slice(t));t=n?t+n[0].length:null}return t?[e.substring(0,t),e.substring(i,s)]:null}if("{"===t)r++;else if("}"===t)r--;else if("\n"===t&&"\n"===e[s-1])return null}s++}return null},Xe=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n("+R.default.defaultRules.nptable.match.regex.source.substring(1)+")"),Ke=R.default.blockRegex(/^(crwdns.*)\n\s*\n/),Ze={...R.default.defaultRules,columns:{order:-2,match:R.default.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(e,t,n)=>({col1:t(e[1],n),col2:t(e[2],n)})},crowdinId:{order:-1,match:(e,t,n)=>t.isJipt?Ke(e,t,n):null,parse:(e,t,n)=>({id:e[1]})},titledTable:{order:R.default.defaultRules.nptable.order-.5,match:R.default.blockRegex(Xe),parse:(e,t,n)=>{const o=R.default.parseInline(t,e[1],n),s=e.slice(2);return{title:o,table:R.default.defaultRules.nptable.parse(s,t,n)}}},widget:{order:R.default.defaultRules.link.order-.75,match:R.default.inlineRegex(Ye.rWidgetRule),parse:(e,t,n)=>({id:e[1],widgetType:e[2]})},blockMath:{order:R.default.defaultRules.codeBlock.order+.5,match:(e,t)=>$e(e,t,!0),parse:(e,t,n)=>({content:e[1]})},math:{order:R.default.defaultRules.link.order-.25,match:(e,t)=>$e(e,t,!1),parse:(e,t,n)=>({content:e[1]})},unescapedDollar:{order:R.default.defaultRules.link.order-.24,match:R.default.inlineRegex(/^(?!\\)\$/),parse:(e,t,n)=>({})},fence:{...R.default.defaultRules.fence,parse:(e,t,n)=>{const o=R.default.defaultRules.fence.parse(e,t,n);return"alt"===o.lang?{type:"codeBlock",lang:"alt",content:t(o.content+"\n\n",n)}:o}},blockQuote:{...R.default.defaultRules.blockQuote,match:R.default.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)},list:{...R.default.defaultRules.list,match:(e,t,n)=>t.isJipt?null:R.default.defaultRules.list.match(e,t,n)},lint:{order:1e3,match:e=>null,parse:(e,t,n)=>({})}};R.default.parserFor(Ze);const Je={...Ze,columns:{...Ze.columns,react:(e,t,n)=>_.createElement("div",{className:"perseus-two-columns",key:n.key},_.createElement("div",{className:"perseus-column"},_.createElement("div",{className:"perseus-column-content"},t(e.col1,n))),_.createElement("div",{className:"perseus-column"},_.createElement("div",{className:"sat-header-grafting-area"}),_.createElement("div",{className:"perseus-column-content"},_.createElement("div",{className:"sat-skill-subscore-grafting-area"}),t(e.col2,n),_.createElement("div",{className:"sat-grafting-area"}))))},crowdinId:{...Ze.crowdinId,react:(e,t,n)=>e.id},table:{...Ze.table,react:function(e,t,n){const o=R.default.defaultRules.table.react(e,t,n);return n.isMobile?_.cloneElement(o,{tabIndex:0}):o}},titledTable:{...Ze.titledTable,react:(e,t,n)=>{let o;if(e.table)if("lint"===e.table.type){var s;o="table"===(null===(s=e.table.content)||void 0===s?void 0:s.type)?Je.lint.react({...e.table,content:{...e,table:e.table.content}},t,{...n,unwrapTitledTableContents:!0}):Je.lint.react(e.table,t,n)}else{const s=R.default.defaultRules.table.react(e.table,t,n),i=_.createElement("caption",{key:"caption",className:"perseus-table-title"},t(e.title,n));o=_.cloneElement(s,null,[i,...s.props.children])}else o="//invalid table//";return n.unwrapTitledTableContents?o:_.createElement("div",{className:"perseus-titled-table",key:n.key},o)}},widget:{...Ze.widget,react:(e,t,n)=>_.createElement("em",{key:n.key},k.doNotTranslate("[Widget: ",e.id,"]"))},blockMath:{...Ze.blockMath,react:(e,t,n)=>{const{TeX:o}=Y();return _.createElement(o,{key:n.key},e.content)}},math:{...Ze.math,react:(e,t,n)=>{const{TeX:o}=Y();return _.createElement(o,{key:n.key},e.content)}},unescapedDollar:{...Ze.unescapedDollar,react:(e,t,n)=>"$"},link:{...Ze.link,react:function(e,t,n){const o=R.default.defaultRules.link.react(e,t,n),s=o.props.href;let i=null;!!s&&s.match(/https?:\/\/[^\/]*khanacademy.org|^\//)||(i="noopener noreferrer");const r={...o.props,target:"_blank",href:s,rel:i};return n.baseElements&&n.baseElements.Link?n.baseElements.Link(r):_.cloneElement(o,r)}},codeBlock:{...Ze.codeBlock,react:(e,t,n)=>"alt"===e.lang?_.createElement("div",{key:n.key,className:"perseus-markdown-alt perseus-sr-only"},t(e.content,n)):R.default.defaultRules.codeBlock.react(e,t,n)},lint:{...Ze.lint,react:(e,t,n)=>_.createElement(ve,{message:e.message,ruleName:e.ruleName,inline:Qe(e.content),blockHighlight:e.blockHighlight,insideTable:e.insideTable,severity:e.severity},t(e.content,n))}};function Qe(e){return!!(e&&e.type&&et.hasOwnProperty(e.type))}const et={text:!0,math:!0,unescapedDollar:!0,link:!0,img:!0,strong:!0,u:!0,em:!0,del:!0,code:!0},tt=R.default.parserFor(Je),nt=(e,t)=>tt(e+"\n\n",{...t,inline:!1}),ot=(e,t)=>{M.default.isArray(e)?M.default.each(e,(e=>ot(e,t))):M.default.isObject(e)&&(t(e),"table"===e.type?(ot(e.header,t),ot(e.cells,t)):"list"===e.type?ot(e.items,t):"titledTable"===e.type?ot(e.table,t):"columns"===e.type?(ot(e.col1,t),ot(e.col2,t)):M.default.isArray(e.content)&&ot(e.content,t))},st=e=>{if(M.default.isArray(e))return M.default.flatten(M.default.map(e,st));if(e.content&&M.default.isString(e.content))return-1!==e.type.toLowerCase().indexOf("code")?["",e.content,""]:[e.content.replace(/\s+/g," ")];const t=M.default.chain(e).values().flatten().filter((e=>null!=e&&M.default.has(e,"type"))).value();if(!t.length)return[];const n=st(t);if("paragraph"===e.type&&n.length){n[0]=n[0].replace(/^\s+/,"");const e=n.length-1;n[e]=n[e].replace(/\s+$/,"")}return n};var it={characterCount:e=>{const t=nt(e);return st(t).join("").length},traverseContent:ot,parse:nt,parseInline:(e,t)=>tt(e,{...t,inline:!0}),reactFor:R.default.reactFor,ruleOutput:R.default.ruleOutput(Je,"react"),basicOutput:R.default.reactFor(R.default.ruleOutput(Je,"react")),sanitizeUrl:R.default.sanitizeUrl};class rt{static parse(e){return new at(e).parse()}match(e){throw new we("Selector subclasses must implement match()",be.NotAllowed)}toString(){return"Unknown selector class"}}class at{constructor(e){U(this,"tokens",void 0),U(this,"tokenIndex",void 0),e=e.trim().replace(/\s+/g," "),this.tokens=e.match(at.TOKENS)||[],this.tokenIndex=0}nextToken(){return this.tokens[this.tokenIndex]||""}consume(){this.tokenIndex++}isIdentifier(){const e=this.tokens[this.tokenIndex][0];return e>="a"&&e<="z"||e>="A"&&e<="Z"}skipSpace(){for(;" "===this.nextToken();)this.consume()}parse(){const e=this.parseTreeSelector();let t=this.nextToken();if(!t)return e;const n=[e];for(;t;){if(","!==t)throw new lt("Expected comma");this.consume(),n.push(this.parseTreeSelector()),t=this.nextToken()}return new ct(n)}parseTreeSelector(){this.skipSpace();let e=this.parseNodeSelector();for(;;){const t=this.nextToken();if(!t||","===t)break;if(" "===t)this.consume(),e=new ht(e,this.parseNodeSelector());else if(">"===t)this.consume(),e=new ft(e,this.parseNodeSelector());else if("+"===t)this.consume(),e=new mt(e,this.parseNodeSelector());else{if("~"!==t)throw new lt("Unexpected token: "+t);this.consume(),e=new gt(e,this.parseNodeSelector())}}return e}parseNodeSelector(){this.skipSpace();const e=this.nextToken();if("*"===e)return this.consume(),new dt;if(this.isIdentifier())return this.consume(),new pt(e);throw new lt("Expected node type")}}U(at,"TOKENS",void 0),at.TOKENS=/([a-zA-Z][\w-]*)|(\d+)|[^\s]|(\s(?=[a-zA-Z\*]))/g;class lt extends Error{constructor(e){super(e)}}class ct extends rt{constructor(e){super(),U(this,"selectors",void 0),this.selectors=e}match(e){for(let t=0;t<this.selectors.length;t++){const n=this.selectors[t].match(e);if(n)return n}return null}toString(){let e="";for(let t=0;t<this.selectors.length;t++)e+=t>0?", ":"",e+=this.selectors[t].toString();return e}}class dt extends rt{match(e){return[e.currentNode()]}toString(){return"*"}}class pt extends rt{constructor(e){super(),U(this,"type",void 0),this.type=e}match(e){const t=e.currentNode();return t.type===this.type?[t]:null}toString(){return this.type}}class ut extends rt{constructor(e,t){super(),U(this,"left",void 0),U(this,"right",void 0),this.left=e,this.right=t}}class ht extends ut{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t)for(e=e.clone();e.hasParent();){e.goToParent();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" "+this.right.toString()}}class ft extends ut{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t&&e.hasParent()){(e=e.clone()).goToParent();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" > "+this.right.toString()}}class mt extends ut{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t&&e.hasPreviousSibling()){(e=e.clone()).goToPreviousSibling();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" + "+this.right.toString()}}class gt extends ut{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t)for(e=e.clone();e.hasPreviousSibling();){e.goToPreviousSibling();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" ~ "+this.right.toString()}}class vt{constructor(e,t,n,o,s,i){var r=this;if(U(this,"name",void 0),U(this,"severity",void 0),U(this,"selector",void 0),U(this,"pattern",void 0),U(this,"lint",void 0),U(this,"applies",void 0),U(this,"message",void 0),!n&&!o)throw new we("Lint rules must have a selector or pattern",be.InvalidInput,{metadata:{name:e}});this.name=e||"unnamed rule",this.severity=t||vt.Severity.BULK_WARNING,this.selector=n||vt.DEFAULT_SELECTOR,this.pattern=o||null,"function"==typeof s?(this.lint=s,this.message=null):(this.lint=function(){return r._defaultLintFunction(...arguments)},this.message=s),this.applies=i||function(){return!0}}static makeRule(e){return new vt(e.name,e.severity,e.selector?rt.parse(e.selector):null,vt.makePattern(e.pattern),e.lint||e.message,e.applies)}check(e,t,n,o){const s=this.selector.match(t);if(!s)return null;let i;if(i=this.pattern?n.match(this.pattern):vt.FakePatternMatch(n,n,0),!i)return null;try{const e=this.lint(t,n,s,i,o);return e?"string"==typeof e?{rule:this.name,severity:this.severity,message:e,start:0,end:n.length}:{rule:this.name,severity:this.severity,message:e.message,start:e.start,end:e.end}:null}catch(e){return{rule:"lint-rule-failure",message:"Exception in rule ".concat(this.name,": ").concat(e.message,"\nStack trace:\n").concat(e.stack),start:0,end:n.length}}}_defaultLintFunction(e,t,n,o,s){return{message:this.message||"",start:o.index,end:o.index+o[0].length}}static makePattern(e){if(!e)return null;if(e instanceof RegExp)return e;if("/"===e[0]){const t=e.lastIndexOf("/"),n=e.substring(1,t),o=e.substring(t+1);return new RegExp(n,o)}return new RegExp(e)}static FakePatternMatch(e,t,n){const o=[t];return o.index=n,o.input=e,o}}U(vt,"DEFAULT_SELECTOR",void 0),U(vt,"Severity",{ERROR:1,WARNING:2,GUIDELINE:3,BULK_WARNING:4}),vt.DEFAULT_SELECTOR=rt.parse("text");const yt=/\/\/([^\/]+)/;var bt=vt.makeRule({name:"absolute-url",severity:vt.Severity.GUIDELINE,selector:"link, image",lint:function(e,t,n,o){const s=function(e){if(!e)return"";const t=e.match(yt);return t?t[1]:""}(n[0].target);if("khanacademy.org"===s||s.endsWith(".khanacademy.org"))return"Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead."}}),xt=vt.makeRule({name:"blockquoted-math",severity:vt.Severity.WARNING,selector:"blockQuote math, blockQuote blockMath",message:"Blockquoted math:\nmath should not be indented."}),wt=vt.makeRule({name:"blockquoted-widget",severity:vt.Severity.WARNING,selector:"blockQuote widget",message:"Blockquoted widget:\nwidgets should not be indented."}),Ct=vt.makeRule({name:"double-spacing-after-terminal",severity:vt.Severity.BULK_WARNING,selector:"paragraph",pattern:/[.!\?] {2}/i,message:"Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation."}),kt=vt.makeRule({name:"extra-content-spacing",selector:"paragraph",pattern:/\s+$/,applies:function(e){return"article"===e.contentType},message:"No extra whitespace at the end of content blocks."}),St=vt.makeRule({name:"heading-level-1",severity:vt.Severity.WARNING,selector:"heading",lint:function(e,t,n,o){if(1===n[0].level)return"Don't use level-1 headings:\nBegin headings with two or more # characters."}}),Et=vt.makeRule({name:"heading-level-skip",severity:vt.Severity.WARNING,selector:"heading ~ heading",lint:function(e,t,n,o){const s=n[1],i=n[0];if(s.level>i.level+1)return"Skipped heading level:\nthis heading is level ".concat(s.level," but\nthe previous heading was level ").concat(i.level)}}),_t=vt.makeRule({name:"heading-sentence-case",severity:vt.Severity.GUIDELINE,selector:"heading",pattern:/^\W*[a-z]/,message:"First letter is lowercase:\nthe first letter of a heading should be capitalized."});const Tt={and:!0,nor:!0,but:!0,the:!0,for:!0};var Mt=vt.makeRule({name:"heading-title-case",severity:vt.Severity.GUIDELINE,selector:"heading",pattern:/[^\s:]\s+[A-Z]+[a-z]/,locale:"en",lint:function(e,t,n,o){let s=t.trim().split(/\s+/);if(s.shift(),s=s.filter((e=>e.length>2&&!Tt.hasOwnProperty(e))),s.length>=3&&s.every((e=>function(e){const t=e[0];return t===t.toUpperCase()}(e))))return"Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns."}}),It=vt.makeRule({name:"image-alt-text",severity:vt.Severity.WARNING,selector:"image",lint:function(e,t,n,o){const s=n[0];return s.alt&&s.alt.trim()?s.alt.length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(s.alt.length," characters long."):void 0:"Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !."}}),Pt=vt.makeRule({name:"image-in-table",severity:vt.Severity.BULK_WARNING,selector:"table image",message:"Image in table:\ndo not put images inside of tables."}),Nt=vt.makeRule({name:"image-spaces-around-urls",severity:vt.Severity.ERROR,selector:"image",lint:function(e,t,n,o,s){const i=n[0].target;if(s&&s.content){const e=s.content.indexOf(i);if(-1===e)return;if("("!==s.content[e-1]||")"!==s.content[e+i.length])return"Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties."}}}),At=vt.makeRule({name:"image-widget",severity:vt.Severity.WARNING,selector:"widget",lint:function(e,t,n,o,s){if("image"!==e.currentNode().widgetType)return;const i=s&&s.widgets&&s.widgets[e.currentNode().id];if(!i)return;const r=i.options.alt;return r?r.trim().length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(r.trim().length," characters long."):i.options.caption&&i.options.caption.match(/[^\\]\$/)?"No math in image captions:\nDon't include math expressions in image captions.":void 0:'Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the "Alt Text" box of the image widget.'}}),Rt=vt.makeRule({name:"link-click-here",severity:vt.Severity.WARNING,selector:"link",pattern:/click here/i,message:'Inappropriate link text:\nDo not use the words "click here" in links.'}),Ft=vt.makeRule({name:"long-paragraph",severity:vt.Severity.GUIDELINE,selector:"paragraph",pattern:/^.{501,}/,lint:function(e,t,n,o){return"Paragraph too long:\nThis paragraph is ".concat(t.length," characters long.\nShorten it to 500 characters or fewer.")}}),Ot=vt.makeRule({name:"math-adjacent",severity:vt.Severity.WARNING,selector:"blockMath+blockMath",message:"Adjacent math blocks:\ncombine the blocks between \\begin{align} and \\end{align}"}),Dt=vt.makeRule({name:"math-align-extra-break",severity:vt.Severity.WARNING,selector:"blockMath",pattern:/(\\{2,})\s*\\end{align}/,message:"Extra space at end of block:\nDon't end an align block with backslashes"}),Lt=vt.makeRule({name:"math-align-linebreaks",severity:vt.Severity.WARNING,selector:"blockMath",pattern:/\\begin{align}[\s\S]*\\\\[\s\S]+\\end{align}/,lint:function(e,t,n,o){let s=o[0];for(;s.length;){const e=s.indexOf("\\\\");if(-1===e)return null;s=s.substring(e+2);const t=s.match(/^\s*\\\\\s*(?!\\\\)/);if(!t)return"Use four backslashes between lines of an align block";s=s.substring(t[0].length)}}}),Bt=vt.makeRule({name:"math-empty",severity:vt.Severity.WARNING,selector:"math, blockMath",pattern:/^$/,message:"Empty math: don't use $$ in your markdown."}),zt=vt.makeRule({name:"math-font-size",severity:vt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\s*{/,message:"Math font size:\nDon't change the default font size with \\Large{} or similar commands"}),qt=vt.makeRule({name:"math-frac",severity:vt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\frac[ {]/,message:"Use \\dfrac instead of \\frac in your math expressions."}),Ht=vt.makeRule({name:"math-nested",severity:vt.Severity.ERROR,selector:"math, blockMath",pattern:/\\text{[^$}]*\$[^$}]*\$[^}]*}/,message:"Nested math:\nDon't nest math expressions inside \\text{} blocks"}),Wt=vt.makeRule({name:"math-starts-with-space",severity:vt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/^\s*(~|\\qquad|\\quad|\\,|\\;|\\:|\\ |\\!|\\enspace|\\phantom)/,message:"Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\;, \\quad, or \\phantom"}),Ut=vt.makeRule({name:"math-text-empty",severity:vt.Severity.WARNING,selector:"math, blockMath",pattern:/\\text{\s*}/,message:"Empty \\text{} block in math expression"}),Gt=vt.makeRule({name:"math-without-dollars",severity:vt.Severity.GUIDELINE,pattern:/\\\w+{[^}]*}|{|}/,message:"This looks like LaTeX:\ndid you mean to put it inside dollar signs?"}),Vt=vt.makeRule({name:"nested-lists",severity:vt.Severity.WARNING,selector:"list list",message:"Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation."}),jt=vt.makeRule({name:"profanity",pattern:/\b(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)\b/i,message:"Avoid profanity"}),Yt=vt.makeRule({name:"table-missing-cells",severity:vt.Severity.WARNING,selector:"table",lint:function(e,t,n,o){const s=n[0],i=s.header.length,r=s.cells.map((e=>e.length));for(let e=0;e<r.length;e++)if(r[e]!==i)return"Table rows don't match header:\nThe table header has ".concat(i," cells, but\nRow ").concat(e+1," has ").concat(r[e]," cells.")}}),$t=vt.makeRule({name:"unbalanced-code-delimiters",severity:vt.Severity.ERROR,pattern:/[`~]+/,message:"Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters"}),Xt=[bt,xt,wt,Ct,kt,St,Et,_t,Mt,It,Pt,Rt,Ft,Ot,Dt,Lt,Bt,zt,qt,Ht,Wt,Ut,Vt,Yt,vt.makeRule({name:"unescaped-dollar",severity:vt.Severity.ERROR,selector:"unescapedDollar",message:"Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\$"}),vt.makeRule({name:"widget-in-table",severity:vt.Severity.BULK_WARNING,selector:"table widget",message:"Widget in table:\ndo not put widgets inside of tables."}),jt,Gt,$t,Nt,At];class Kt{constructor(e){U(this,"root",void 0),this.root=e}static isNode(e){return e&&"object"==typeof e&&"string"==typeof e.type}static isTextNode(e){return Kt.isNode(e)&&"text"===e.type&&"string"==typeof e.content}traverse(e){this._traverse(this.root,new Zt(this.root),e)}_traverse(e,t,n){let o="";if(Kt.isNode(e)){const s=e;t._containers.push(s),t._ancestors.push(s),"string"==typeof s.content&&(o=s.content);Object.keys(s).forEach((e=>{if("type"===e)return;const i=s[e];i&&"object"==typeof i&&(t._indexes.push(e),o+=this._traverse(i,t,n),t._indexes.pop())})),t._currentNode=t._ancestors.pop(),t._containers.pop(),n(s,t,o)}else if(Array.isArray(e)){const s=e;t._containers.push(s);let i=0;for(;i<s.length;)t._indexes.push(i),o+=this._traverse(s[i],t,n),i=t._indexes.pop()+1;t._containers.pop()}return o}}class Zt{constructor(e){U(this,"root",void 0),U(this,"_currentNode",void 0),U(this,"_containers",void 0),U(this,"_indexes",void 0),U(this,"_ancestors",void 0),this.root=e,this._currentNode=null,this._containers=new Jt,this._indexes=new Jt,this._ancestors=new Jt}currentNode(){return this._currentNode||this.root}parent(){return this._ancestors.top()}ancestors(){return this._ancestors.values()}nextSibling(){const e=this._containers.top();if(!e||!Array.isArray(e))return null;const t=this._indexes.top();return e.length>t+1?e[t+1]:null}previousSibling(){const e=this._containers.top();if(!e||!Array.isArray(e))return null;const t=this._indexes.top();return t>0?e[t-1]:null}removeNextSibling(){const e=this._containers.top();if(e&&Array.isArray(e)){const t=this._indexes.top();if(e.length>t+1)return e.splice(t+1,1)[0]}return null}replace(){const e=this._containers.top();if(!e)throw new we("Can't replace the root of the tree",be.Internal);for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];if(Array.isArray(e)){const t=this._indexes.top();e.splice(t,1,...n),this._indexes.pop(),this._indexes.push(t+n.length-1)}else{const t=this._indexes.top();0===n.length?delete e[t]:1===n.length?e[t]=n[0]:e[t]=n}}hasPreviousSibling(){return Array.isArray(this._containers.top())&&this._indexes.top()>0}goToPreviousSibling(){if(!this.hasPreviousSibling())throw new we("goToPreviousSibling(): node has no previous sibling",be.Internal);this._currentNode=this.previousSibling();const e=this._indexes.pop();this._indexes.push(e-1)}hasParent(){return 0!==this._ancestors.size()}goToParent(){if(!this.hasParent())throw new we("goToParent(): node has no ancestor",be.NotAllowed);for(this._currentNode=this._ancestors.pop();this._containers.size()&&this._containers.top()[this._indexes.top()]!==this._currentNode;)this._containers.pop(),this._indexes.pop()}clone(){const e=new Zt(this.root);return e._currentNode=this._currentNode,e._containers=this._containers.clone(),e._indexes=this._indexes.clone(),e._ancestors=this._ancestors.clone(),e}equals(e){return this.root===e.root&&this._currentNode===e._currentNode&&this._containers.equals(e._containers)&&this._indexes.equals(e._indexes)&&this._ancestors.equals(e._ancestors)}}class Jt{constructor(e){U(this,"stack",void 0),this.stack=e?e.slice(0):[]}push(e){this.stack.push(e)}pop(){return this.stack.pop()}top(){return this.stack[this.stack.length-1]}values(){return this.stack.slice(0)}size(){return this.stack.length}toString(){return this.stack.toString()}clone(){return new Jt(this.stack)}equals(e){if(!e||!e.stack||e.stack.length!==this.stack.length)return!1;for(let t=0;t<this.stack.length;t++)if(this.stack[t]!==e.stack[t])return!1;return!0}}const Qt=Xt.filter((e=>e.severity<vt.Severity.BULK_WARNING));var en={runLinter:function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Qt;const s=[],i=new Kt(e);i.traverse(((e,t,n)=>{if(Kt.isTextNode(e)){let n=t.nextSibling();for(;Kt.isTextNode(n);)e.content+=n.content,t.removeNextSibling(),n=t.nextSibling()}}));let r=[],a=!1;return i.traverse(((e,i,l)=>{const c=[],d=o.filter((e=>e.applies(t))),p=[...t.stack];p.push(e.type);const u={...t,stack:p.join(".")};if(d.forEach((t=>{const o=t.check(e,i,l,u);o&&((o.start||o.end)&&(o.target=l.substring(o.start,o.end)),s.push(o),n&&c.push(o))})),n&&("table"===e.type?(r.length&&c.push(...r),a=!1,r=[]):a||(a=i.ancestors().some((e=>"table"===e.type))),a&&c.length&&r.push(...c),c.length))if(c.sort(((e,t)=>e.severity-t.severity)),"text"!==e.type||c.length>1)i.replace({type:"lint",content:e,message:c.map((e=>e.message)).join("\n\n"),ruleName:c[0].rule,blockHighlight:u.blockHighlight,insideTable:a,severity:c[0].severity});else{const t=e.content,n=c[0],o=n.start||0,s=n.end||t.length,r=t.substring(0,o),l=t.substring(o,s),d=t.substring(s),p=[];r&&p.push({type:"text",content:r}),p.push({type:"lint",content:{type:"text",content:l},message:n.message,ruleName:n.rule,insideTable:a,severity:n.severity}),d&&p.push({type:"text",content:d}),i.replace(...p)}})),s},parse:it.parse,pushContextStack:function(e,t){const n=e.stack||[];return{...e,stack:n.concat(t)}},rules:Qt};const tn=I.default.shape({contentType:I.default.string,highlightLint:I.default.bool,paths:I.default.arrayOf(I.default.string),stack:I.default.arrayOf(I.default.string)}),nn={contentType:"",highlightLint:!1,paths:[],stack:[]},on={assetStatuses:{},setAssetStatus:(e,t)=>{}},sn=_.createContext(on);function rn(e,t){const n=window.scrollX,o=window.scrollY,s=document.querySelector("meta[name=viewport]");s?s.setAttribute("content",e):P.default("head").append('<meta name="viewport" content="'.concat(e,'">')),document.body.style.opacity=.9999,setTimeout((()=>{document.body.style.opacity=1,window.scrollTo(n,o),t&&setTimeout(t,0)}),0)}function an(){}function ln(e,t){this._fullHeight=this._fullWidth=this._overlay=null,this._targetImage=e,this._enableMobilePinch=t,this._$body=P.default(document.body)}P.default.fn.emulateTransitionEnd=function(e){let t=!1;const n=this;P.default(this).one("bsTransitionEnd",(function(){t=!0}));return setTimeout((function(){t||P.default(n).trigger(P.default.support.transition.end)}),e),this},P.default((function(){P.default.support.transition=function(){const e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(const n in t)if(void 0!==e.style[n])return{end:t[n]};return!1}(),P.default.support.transition&&(P.default.event.special.bsTransitionEnd={bindType:P.default.support.transition.end,delegateType:P.default.support.transition.end,handle:function(e){if(P.default(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})),an.prototype._initialize=function(e){this._$document||(this._activeZoom=this._initialScrollPosition=this._initialTouchPosition=this._touchMoveListener=null,this._$document=P.default(document),this._$window=P.default(window),this._$body=P.default(document.body),this._boundClick=P.default.proxy(this._clickHandler,this),this._enableMobilePinch=e)},an.prototype.handleZoomClick=function(e,t){this._initialize(t);const n=e.target;if(n&&"IMG"===n.tagName&&!this._$body.hasClass("zoom-overlay-open"))return e.metaKey||e.ctrlKey?window.open(e.target.src,"_blank"):void(!t&&n.width>=window.innerWidth-ln.getOffset()||(this._activeZoomClose(!0),t?rn("width=device-width, initial-scale=1, minimum-scale=1",(()=>this._zoom(n))):this._zoom(n),t||(this._$window.on("scroll.zoom",P.default.proxy(this._scrollHandler,this)),this._$document.on("keyup.zoom",P.default.proxy(this._keyHandler,this)),this._$document.on("touchstart.zoom",P.default.proxy(this._touchStart,this))),document.addEventListener("click",this._boundClick,!0),e.stopPropagation()))},an.prototype._zoom=function(e){this._activeZoom=new ln(e,this._enableMobilePinch),this._activeZoom.zoomImage()},an.prototype._activeZoomClose=function(e){this._activeZoom&&(e?(this._activeZoom.dispose(),this._disposeActiveZoom()):rn("width=device-width, initial-scale=1, minimum-scale=1,\n maximum-scale=1",(()=>{this._activeZoom&&(this._activeZoom.close(),this._disposeActiveZoom())})))},an.prototype._disposeActiveZoom=function(){this._$window.off(".zoom"),this._$document.off(".zoom"),document.removeEventListener("click",this._boundClick,!0),this._activeZoom=null},an.prototype._scrollHandler=function(e){null===this._initialScrollPosition&&(this._initialScrollPosition=window.scrollY);const t=this._initialScrollPosition-window.scrollY;Math.abs(t)>=40&&this._activeZoomClose()},an.prototype._keyHandler=function(e){27===e.keyCode&&this._activeZoomClose()},an.prototype._clickHandler=function(e){e.stopPropagation(),e.preventDefault(),this._activeZoomClose()},an.prototype._touchStart=function(e){this._initialTouchPosition=e.originalEvent.touches[0].pageY,P.default(e.target).on("touchmove.zoom",P.default.proxy(this._touchMove,this))},an.prototype._touchMove=function(e){Math.abs(e.originalEvent.touches[0].pageY-this._initialTouchPosition)>10&&(this._activeZoomClose(),P.default(e.target).off("touchmove.zoom"))},ln._OFFSET=80,ln._MAX_WIDTH=2560,ln._MAX_HEIGHT=4096,ln.getOffset=function(e){return e?0:ln._OFFSET},ln.prototype.getOffset=function(){return ln.getOffset(this._enableMobilePinch)},ln.prototype.zoomImage=function(){const e=document.createElement("img"),t=P.default(e);e.onload=function(){this._fullHeight=Number(e.height),this._fullWidth=Number(e.width);const n=this._imageOffset=P.default(this._targetImage).offset(),o=this._left=n.left-P.default(window).scrollLeft(),s=this._top=n.top-P.default(window).scrollTop();t.css({left:o,top:s,width:this._targetImage.width,height:this._targetImage.height}),this._zoomOriginal()}.bind(this),e.src=this._targetImage.src,this.$zoomedImage=t},ln.prototype._zoomOriginal=function(){var e,t,n;this.$zoomedImage.addClass("zoom-img").attr("data-action","zoom-out"),P.default(this._targetImage).css("visibility","hidden"),this._backdrop=document.createElement("div"),this._backdrop.className="zoom-backdrop",null===(e=document.body)||void 0===e||e.appendChild(this._backdrop),this._overlay=document.createElement("div"),this._overlay.className="zoom-overlay",null===(t=document.body)||void 0===t||t.appendChild(this._overlay),null===(n=this._overlay)||void 0===n||n.appendChild(this.$zoomedImage[0]),this._calculateZoom(),this._triggerAnimation()},ln.prototype._calculateZoom=function(){const e=this._fullWidth,t=this._fullHeight,n=window.innerHeight-this.getOffset(),o=window.innerWidth-this.getOffset(),s=e/this._targetImage.width,i=e/t,r=o/n;this._imgScaleFactor=e<o&&t<n?s:i<r?n/t*s:o/(null!=e?e:0)*s},ln.prototype._triggerAnimation=function(){const e=P.default(window).scrollTop()+window.innerHeight/2,t=P.default(window).scrollLeft()+window.innerWidth/2,n=this._imgScaleFactor,o=this._imageOffset.top+this._targetImage.height/2,s=this._imageOffset.left+this._targetImage.width/2;this._translateY=(e-o)/n,this._translateX=(t-s)/n,this._zoomedInTransformString="\n scale(".concat(n,")\n translate3d(").concat(this._translateX,"px, ").concat(this._translateY,"px, 0)\n "),this.$zoomedImage.css({transform:this._zoomedInTransformString}).addClass("zoom-transition").one(P.default.support.transition.end,P.default.proxy(this._onZoomInFinish,this)).emulateTransitionEnd(300),this._$body.addClass("zoom-overlay-open")},ln.prototype._onZoomInFinish=function(){const e=this._targetImage.height*this._imgScaleFactor,t=this._targetImage.width*this._imgScaleFactor;let n=0,o=0,s=0,i=0,r=0,a=0;t<window.innerWidth?(n="50%",s=-t/2):r=(t-window.innerWidth)/2,e<window.innerHeight?(o="50%",i=-e/2):a=(e-window.innerHeight)/2,this.$zoomedImage.css({height:e,left:n,marginLeft:s,marginTop:i,top:o,transform:"",width:t}).removeClass("zoom-transition"),P.default(this._overlay).scrollLeft(r).scrollTop(a)},ln.prototype.close=function(){this._$body.removeClass("zoom-overlay-open").addClass("zoom-overlay-transitioning"),this.$zoomedImage.css({height:this._targetImage.height,left:this._left,marginLeft:0,marginTop:0,top:this._top,transform:this._zoomedInTransformString,width:this._targetImage.width}).removeClass("zoom-transition"),P.default(this._overlay).scrollLeft(0).scrollTop(0),setTimeout((()=>{this.$zoomedImage.css({transform:"scale(1)"}).addClass("zoom-transition").one(P.default.support.transition.end,P.default.proxy(this.dispose,this)).emulateTransitionEnd(300)}),10)},ln.prototype.dispose=function(){this.$zoomedImage&&this.$zoomedImage[0].parentNode&&(this.$zoomedImage.remove(),this.$zoomedImage=null,this._overlay.parentNode.removeChild(this._overlay),this._backdrop.parentNode.removeChild(this._backdrop),this._$body.removeClass("zoom-overlay-transitioning")),P.default(this._targetImage).css("visibility","visible"),this._targetImage.focus()};const cn=new an,dn=O.default({displayName:"FixedToResponsive",propTypes:{width:I.default.number.isRequired,height:I.default.number.isRequired,className:I.default.string,constrainHeight:I.default.bool,allowFullBleed:I.default.bool},getDefaultProps:function(){return{className:"",constrainHeight:!1,allowFullBleed:!1}},getInitialState:function(){return{viewportHeight:null,viewportWidth:null}},componentDidMount:function(){this._isMounted=!0,window.innerHeight<480?setTimeout(this._cacheViewportSize,800):this._cacheViewportSize()},componentWillUnmount:function(){this._isMounted=!1},_cacheViewportSize:function(){this._isMounted&&this.setState({viewportHeight:Math.max(480,window.innerHeight),viewportWidth:window.innerWidth})},render:function(){const e=this.props.width/this.props.height,t=_.createElement("div",{style:{paddingBottom:100*(1/e).toFixed(4)+"%"}});let{width:n,height:o}=this.props;if(this.props.constrainHeight&&this.state.viewportHeight){const t=2/3*this.state.viewportHeight;this.props.height>=t&&(o=t,n=t*e)}const s={maxWidth:n,maxHeight:o},i=S.default("fixed-to-responsive",this.props.className),r=_.createElement("div",{className:i,style:s},t,this.props.children);return this.props.allowFullBleed&&this.state.viewportWidth&&n>=this.state.viewportWidth?_.createElement("div",{style:{marginLeft:-16,marginRight:-16}},r):r}});function pn(e,t){return e+":"+t}const un={_fireEvent:function(e,t,n){M.default.invoke(e,"call",this,t,n)},_applyConstraints:function(e,t,n){let o=!1;return M.default.reduce(this.state.constraints,((e,s)=>{if(!1===e)return!1;if(o)return e;const i=s.call(this,e,t,{onSkipRemaining:()=>{o=!0},...n});if(!1===i)return!1;if(p.point.is(i,2))return i;if(!0===i||null==i)return e;throw new we("Constraint returned invalid result: "+i,be.Internal)}),e,this)},draw:function(){const e=this.cloneState();un._fireEvent.call(this,this.state.draw,e,this.prevState),this.prevState=e},listen:function(e,t,n){this._listenerMap=this._listenerMap||{};const o=pn(e,t),s=this._listenerMap[o]=this._listenerMap[o]||this.state[e].length;this.state[e][s]=n},unlisten:function(e,t){this._listenerMap=this._listenerMap||{};const n=pn(e,t),o=this._listenerMap[n];if(void 0!==o){this.state[e].splice(o,1),delete this._listenerMap[n];const t=M.default.keys(this._listenerMap);M.default.each(t,(function(t){(function(e){return e.split(":")[0]})(t)===e&&this._listenerMap[t]>o&&this._listenerMap[t]--}),this)}}};let hn=null;let fn=null;const mn={assert:function(e,t){if(!e)throw new we("Assertion Error"+(t?": "+t:""),be.Internal)},createGettersFor:function(e,t){M.default.each(M.default.keys(t),(function(t){void 0===e.prototype[t]&&(e.prototype[t]=function(){return this.state[t]})}))},addMovableHelperMethodsTo:function(e){M.default.each(un,(function(t,n){void 0===e.prototype[n]&&(e.prototype[n]=t)}))},arrayify:function(e){return null==e?[]:M.default.isArray(e)?M.default.filter(M.default.flatten(e),M.default.identity):[e]},normalizeOptions:function(e,t){const n=M.default.clone(t);return M.default.each(e,(function(e){const o=t[e];if(void 0!==o){const t=mn.arrayify(o);n[e]=t}})),n},getPrefixedTransform:function(){return hn=hn||function(){const e=document.createElement("div");let t=null;return M.default.each(["transform","msTransform","MozTransform","WebkitTransform","OTransform"],(function(n){void 0!==e.style[n]&&(t=n)})),t}(),hn},getCanUse3dTransform:function(){return null==fn&&(fn=function(){const e=document.createElement("div"),t=mn.getPrefixedTransform();return e.style[t]="translateZ(0px)",!!e.style[t]}()),fn}};var gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function vn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yn={exports:{}};
|
|
2
|
+
/*!
|
|
3
|
+
* Raphael 1.5.2 - JavaScript Vector Library
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
|
|
6
|
+
* Licensed under the MIT (http://raphaeljs.com/license.html) license.
|
|
7
|
+
*/!function(){var e;function t(){if(t.is(arguments[0],I)){for(var e=arguments[0],n=qe[u](t,e.splice(0,3+t.is(e[0],T))),o=n.set(),i=0,r=e[b];i<r;i++){var l=e[i]||{};s[a](l.type)&&o[A](n[l.type]().attr(l))}return o}return qe[u](t,arguments)}e="".trim?function(e,t,n){e.setAttribute(t,String(n).trim())}:function(e,t,n){e.setAttribute(t,String(n))},t.version="1.5.2";var n,o=/[, ]+/,s={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},i=/\{(\d+)\}/g,r="prototype",a="hasOwnProperty",l=document,c=window,d={was:Object[r][a].call(c,"Raphael"),is:c.Raphael},p=function(){this.customAttributes={}},u="apply",h="createTouch"in l,f="",m=" ",g=String,v="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend".split(m),y={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},b="length",x=g[r].toLowerCase,w=Math,C=w.max,k=w.min,S=w.abs,E=w.pow,_=w.PI,T="number",M="string",I="array",P="fill",N=Object[r].toString,A="push",R=/^url\(['"]?([^\)]+?)['"]?\)$/i,F=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,O={NaN:1,Infinity:1,"-Infinity":1},D=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,L=w.round,B=parseFloat,z=parseInt,q=" progid:DXImageTransform.Microsoft",H=g[r].toUpperCase,W={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},U={along:"along",blur:T,"clip-rect":"csv",cx:T,cy:T,fill:"colour","fill-opacity":T,"font-size":T,height:T,opacity:T,path:"path",r:T,rotation:"csv",rx:T,ry:T,scale:"csv",stroke:"colour","stroke-opacity":T,"stroke-width":T,translation:"csv",width:T,x:T,y:T},G="replace",V=/^(from|to|\d+%?)$/,j=/\s*,\s*/,Y={hs:1,rg:1},$=/,?([achlmqrstvxz]),?/gi,X=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/gi,K=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/gi,Z=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,J=function(e,t){return e.key-t.key};if(t.type=c.SVGAngle||l.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML","VML"==t.type){var Q,ee=l.createElement("div");if(ee.innerHTML='<v:shape adj="1"/>',(Q=ee.firstChild).style.behavior="url(#default#VML)",!Q||"object"!=typeof Q.adj)return t.type=null;ee=null}function te(){for(var e=[],t=0;t<32;t++)e[t]=(~~(16*w.random())).toString(16);return e[12]=4,e[16]=(3&e[16]|8).toString(16),"r-"+e.join("")}t.svg=!(t.vml="VML"==t.type),p[r]=t[r],n=p[r],t._id=0,t._oid=0,t.fn={},t.is=function(e,t){return"finite"==(t=x.call(t))?!O[a](+e):"null"==t&&null===e||t==typeof e||"object"==t&&e===Object(e)||"array"==t&&Array.isArray&&Array.isArray(e)||N.call(e).slice(8,-1).toLowerCase()==t},t.angle=function(e,n,o,s,i,r){if(null==i){var a=e-o,l=n-s;return a||l?(180*(a<0)+180*w.atan(-l/-a)/_+360)%360:0}return t.angle(e,n,i,r)-t.angle(o,s,i,r)},t.rad=function(e){return e%360*_/180},t.deg=function(e){return 180*e/_%360},t.snapTo=function(e,n,o){if(o=t.is(o,"finite")?o:10,t.is(e,I)){for(var s=e.length;s--;)if(S(e[s]-n)<=o)return e[s]}else{var i=n%(e=+e);if(i<o)return n-i;if(i>e-o)return n-i+e}return n},t.setWindow=function(e){l=(c=e).document};var ne=function(e){if(t.vml){var n,o=/^\s+|\s+$/g;try{var s=new ActiveXObject("htmlfile");s.write("<body>"),s.close(),n=s.body}catch(e){n=createPopup().document.body}var i=n.createTextRange();ne=re((function(e){try{n.style.color=g(e)[G](o,f);var t=i.queryCommandValue("ForeColor");return"#"+("000000"+(t=(255&t)<<16|65280&t|(16711680&t)>>>16).toString(16)).slice(-6)}catch(e){return"none"}}))}else{var r=l.createElement("i");r.title="Raphaël Colour Picker",r.style.display="none",l.body.appendChild(r),ne=re((function(e){return r.style.color=e,l.defaultView.getComputedStyle(r,f).getPropertyValue("color")}))}return ne(e)},oe=function(){return"hsb("+[this.h,this.s,this.b]+")"},se=function(){return"hsl("+[this.h,this.s,this.l]+")"},ie=function(){return this.hex};function re(e,t,n){return function o(){var s=Array[r].slice.call(arguments,0),i=s.join("►"),l=o.cache=o.cache||{},c=o.count=o.count||[];return l[a](i)||(c[b]>=1e3&&delete l[c.shift()],c[A](i),l[i]=e[u](t,s)),n?n(l[i]):l[i]}}t.hsb2rgb=function(e,n,o,s){return t.is(e,"object")&&"h"in e&&"s"in e&&"b"in e&&(o=e.b,n=e.s,s=(e=e.h).o),t.hsl2rgb(e,n,o/2,s)},t.hsl2rgb=function(e,n,o,s){t.is(e,"object")&&"h"in e&&"s"in e&&"l"in e&&(o=e.l,n=e.s,e=e.h),(e>1||n>1||o>1)&&(e/=360,n/=100,o/=100);var i,r,a,l={},c=["r","g","b"];if(n){r=2*o-(i=o<.5?o*(1+n):o+n-o*n);for(var d=0;d<3;d++)(a=e+1/3*-(d-1))<0&&a++,a>1&&a--,l[c[d]]=6*a<1?r+6*(i-r)*a:2*a<1?i:3*a<2?r+(i-r)*(2/3-a)*6:r}else l={r:o,g:o,b:o};return l.r*=255,l.g*=255,l.b*=255,l.hex="#"+(16777216|l.b|l.g<<8|l.r<<16).toString(16).slice(1),t.is(s,"finite")&&(l.opacity=s),l.toString=ie,l},t.rgb2hsb=function(e,n,o){if(null==n&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(o=e.b,n=e.g,e=e.r),null==n&&t.is(e,M)){var s=t.getRGB(e);e=s.r,n=s.g,o=s.b}(e>1||n>1||o>1)&&(e/=255,n/=255,o/=255);var i,r=C(e,n,o),a=k(e,n,o);if(a==r)return{h:0,s:0,b:r,toString:oe};var l=r-a;return i=e==r?(n-o)/l:n==r?2+(o-e)/l:4+(e-n)/l,(i/=6)<0&&i++,i>1&&i--,{h:i,s:l/r,b:r,toString:oe}},t.rgb2hsl=function(e,n,o){if(null==n&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(o=e.b,n=e.g,e=e.r),null==n&&t.is(e,M)){var s=t.getRGB(e);e=s.r,n=s.g,o=s.b}(e>1||n>1||o>1)&&(e/=255,n/=255,o/=255);var i,r,a=C(e,n,o),l=k(e,n,o),c=(a+l)/2;if(l==a)r={h:0,s:0,l:c};else{var d=a-l;i=e==a?(n-o)/d:n==a?2+(o-e)/d:4+(e-n)/d,(i/=6)<0&&i++,i>1&&i--,r={h:i,s:c<.5?d/(a+l):d/(2-a-l),l:c}}return r.toString=se,r},t._path2string=function(){return this.join(",")[G]($,"$1")},t.getRGB=re((function(e){if(!e||(e=g(e)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if("none"==e)return{r:-1,g:-1,b:-1,hex:"none"};!Y[a](e.toLowerCase().substring(0,2))&&"#"!=e.charAt()&&(e=ne(e));var n,o,s,i,r,l,c=e.match(F);return c?(c[2]&&(s=z(c[2].substring(5),16),o=z(c[2].substring(3,5),16),n=z(c[2].substring(1,3),16)),c[3]&&(s=z((r=c[3].charAt(3))+r,16),o=z((r=c[3].charAt(2))+r,16),n=z((r=c[3].charAt(1))+r,16)),c[4]&&(l=c[4].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),o=B(l[1]),"%"==l[1].slice(-1)&&(o*=2.55),s=B(l[2]),"%"==l[2].slice(-1)&&(s*=2.55),"rgba"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100)),c[5]?(l=c[5].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),o=B(l[1]),"%"==l[1].slice(-1)&&(o*=2.55),s=B(l[2]),"%"==l[2].slice(-1)&&(s*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(n/=360),"hsba"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100),t.hsb2rgb(n,o,s,i)):c[6]?(l=c[6].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),o=B(l[1]),"%"==l[1].slice(-1)&&(o*=2.55),s=B(l[2]),"%"==l[2].slice(-1)&&(s*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(n/=360),"hsla"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100),t.hsl2rgb(n,o,s,i)):((c={r:n,g:o,b:s}).hex="#"+(16777216|s|o<<8|n<<16).toString(16).slice(1),t.is(i,"finite")&&(c.opacity=i),c)):{r:-1,g:-1,b:-1,hex:"none",error:1}}),t),t.getColor=function(e){var t=this.getColor.start=this.getColor.start||{h:0,s:1,b:e||.75},n=this.hsb2rgb(t.h,t.s,t.b);return t.h+=.075,t.h>1&&(t.h=0,t.s-=.2,t.s<=0&&(this.getColor.start={h:0,s:1,b:t.b})),n.hex},t.getColor.reset=function(){delete this.start},t.parsePathString=re((function(e){if(!e)return null;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},o=[];return t.is(e,I)&&t.is(e[0],I)&&(o=le(e)),o[b]||g(e)[G](X,(function(e,t,s){var i=[],r=x.call(t);for(s[G](K,(function(e,t){t&&i[A](+t)})),"m"==r&&i[b]>2&&(o[A]([t].concat(i.splice(0,2))),r="l",t="m"==t?"l":"L");i[b]>=n[r]&&(o[A]([t].concat(i.splice(0,n[r]))),n[r]););})),o.toString=t._path2string,o})),t.findDotsAtSegment=function(e,t,n,o,s,i,r,a,l){var c=1-l,d=E(c,3)*e+3*E(c,2)*l*n+3*c*l*l*s+E(l,3)*r,p=E(c,3)*t+3*E(c,2)*l*o+3*c*l*l*i+E(l,3)*a,u=e+2*l*(n-e)+l*l*(s-2*n+e),h=t+2*l*(o-t)+l*l*(i-2*o+t),f=n+2*l*(s-n)+l*l*(r-2*s+n),m=o+2*l*(i-o)+l*l*(a-2*i+o),g=(1-l)*e+l*n,v=(1-l)*t+l*o,y=(1-l)*s+l*r,b=(1-l)*i+l*a,x=90-180*w.atan((u-f)/(h-m))/_;return(u>f||h<m)&&(x+=180),{x:d,y:p,m:{x:u,y:h},n:{x:f,y:m},start:{x:g,y:v},end:{x:y,y:b},alpha:x}};var ae=re((function(e){if(!e)return{x:0,y:0,width:0,height:0};for(var t,n=0,o=0,s=[],i=[],r=0,a=(e=ge(e))[b];r<a;r++)if("M"==(t=e[r])[0])n=t[1],o=t[2],s[A](n),i[A](o);else{var l=me(n,o,t[1],t[2],t[3],t[4],t[5],t[6]);s=s.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),n=t[5],o=t[6]}var c=k[u](0,s),d=k[u](0,i);return{x:c,y:d,width:C[u](0,s)-c,height:C[u](0,i)-d}})),le=function(e){var n=[];t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));for(var o=0,s=e[b];o<s;o++){n[o]=[];for(var i=0,r=e[o][b];i<r;i++)n[o][i]=e[o][i]}return n.toString=t._path2string,n},ce=re((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var n=[],o=0,s=0,i=0,r=0,a=0;"M"==e[0][0]&&(i=o=e[0][1],r=s=e[0][2],a++,n[A](["M",o,s]));for(var l=a,c=e[b];l<c;l++){var d=n[l]=[],p=e[l];if(p[0]!=x.call(p[0]))switch(d[0]=x.call(p[0]),d[0]){case"a":d[1]=p[1],d[2]=p[2],d[3]=p[3],d[4]=p[4],d[5]=p[5],d[6]=+(p[6]-o).toFixed(3),d[7]=+(p[7]-s).toFixed(3);break;case"v":d[1]=+(p[1]-s).toFixed(3);break;case"m":i=p[1],r=p[2];default:for(var u=1,h=p[b];u<h;u++)d[u]=+(p[u]-(u%2?o:s)).toFixed(3)}else{d=n[l]=[],"m"==p[0]&&(i=p[1]+o,r=p[2]+s);for(var f=0,m=p[b];f<m;f++)n[l][f]=p[f]}var g=n[l][b];switch(n[l][0]){case"z":o=i,s=r;break;case"h":o+=+n[l][g-1];break;case"v":s+=+n[l][g-1];break;default:o+=+n[l][g-2],s+=+n[l][g-1]}}return n.toString=t._path2string,n}),0,le),de=re((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var n=[],o=0,s=0,i=0,r=0,a=0;"M"==e[0][0]&&(i=o=+e[0][1],r=s=+e[0][2],a++,n[0]=["M",o,s]);for(var l=a,c=e[b];l<c;l++){var d=n[l]=[],p=e[l];if(p[0]!=H.call(p[0]))switch(d[0]=H.call(p[0]),d[0]){case"A":d[1]=p[1],d[2]=p[2],d[3]=p[3],d[4]=p[4],d[5]=p[5],d[6]=+(p[6]+o),d[7]=+(p[7]+s);break;case"V":d[1]=+p[1]+s;break;case"H":d[1]=+p[1]+o;break;case"M":i=+p[1]+o,r=+p[2]+s;default:for(var u=1,h=p[b];u<h;u++)d[u]=+p[u]+(u%2?o:s)}else for(var f=0,m=p[b];f<m;f++)n[l][f]=p[f];switch(d[0]){case"Z":o=i,s=r;break;case"H":o=d[1];break;case"V":s=d[1];break;case"M":i=n[l][n[l][b]-2],r=n[l][n[l][b]-1];default:o=n[l][n[l][b]-2],s=n[l][n[l][b]-1]}}return n.toString=t._path2string,n}),null,le),pe=function(e,t,n,o){return[e,t,n,o,n,o]},ue=function(e,t,n,o,s,i){var r=1/3,a=2/3;return[r*e+a*n,r*t+a*o,r*s+a*n,r*i+a*o,s,i]},he=function(e,t,n,o,s,i,r,a,l,c){var d,p=120*_/180,u=_/180*(+s||0),h=[],f=re((function(e,t,n){return{x:e*w.cos(n)-t*w.sin(n),y:e*w.sin(n)+t*w.cos(n)}}));if(c)T=c[0],M=c[1],k=c[2],E=c[3];else{e=(d=f(e,t,-u)).x,t=d.y;var m=(e-(a=(d=f(a,l,-u)).x))/2,g=(t-(l=d.y))/2,v=m*m/(n*n)+g*g/(o*o);v>1&&(n*=v=w.sqrt(v),o*=v);var y=n*n,x=o*o,C=(i==r?-1:1)*w.sqrt(S((y*x-y*g*g-x*m*m)/(y*g*g+x*m*m))),k=C*n*g/o+(e+a)/2,E=C*-o*m/n+(t+l)/2,T=w.asin(((t-E)/o).toFixed(9)),M=w.asin(((l-E)/o).toFixed(9));(T=e<k?_-T:T)<0&&(T=2*_+T),(M=a<k?_-M:M)<0&&(M=2*_+M),r&&T>M&&(T-=2*_),!r&&M>T&&(M-=2*_)}var I=M-T;if(S(I)>p){var P=M,N=a,A=l;M=T+p*(r&&M>T?1:-1),a=k+n*w.cos(M),l=E+o*w.sin(M),h=he(a,l,n,o,s,0,r,N,A,[M,P,k,E])}I=M-T;var R=w.cos(T),F=w.sin(T),O=w.cos(M),D=w.sin(M),L=w.tan(I/4),B=4/3*n*L,z=4/3*o*L,q=[e,t],H=[e+B*F,t-z*R],W=[a+B*D,l-z*O],U=[a,l];if(H[0]=2*q[0]-H[0],H[1]=2*q[1]-H[1],c)return[H,W,U].concat(h);for(var G=[],V=0,j=(h=[H,W,U].concat(h).join().split(","))[b];V<j;V++)G[V]=V%2?f(h[V-1],h[V],u).y:f(h[V],h[V+1],u).x;return G},fe=function(e,t,n,o,s,i,r,a,l){var c=1-l;return{x:E(c,3)*e+3*E(c,2)*l*n+3*c*l*l*s+E(l,3)*r,y:E(c,3)*t+3*E(c,2)*l*o+3*c*l*l*i+E(l,3)*a}},me=re((function(e,t,n,o,s,i,r,a){var l,c=s-2*n+e-(r-2*s+n),d=2*(n-e)-2*(s-n),p=e-n,h=(-d+w.sqrt(d*d-4*c*p))/2/c,f=(-d-w.sqrt(d*d-4*c*p))/2/c,m=[t,a],g=[e,r];return S(h)>"1e12"&&(h=.5),S(f)>"1e12"&&(f=.5),h>0&&h<1&&(l=fe(e,t,n,o,s,i,r,a,h),g[A](l.x),m[A](l.y)),f>0&&f<1&&(l=fe(e,t,n,o,s,i,r,a,f),g[A](l.x),m[A](l.y)),c=i-2*o+t-(a-2*i+o),p=t-o,h=(-(d=2*(o-t)-2*(i-o))+w.sqrt(d*d-4*c*p))/2/c,f=(-d-w.sqrt(d*d-4*c*p))/2/c,S(h)>"1e12"&&(h=.5),S(f)>"1e12"&&(f=.5),h>0&&h<1&&(l=fe(e,t,n,o,s,i,r,a,h),g[A](l.x),m[A](l.y)),f>0&&f<1&&(l=fe(e,t,n,o,s,i,r,a,f),g[A](l.x),m[A](l.y)),{min:{x:k[u](0,g),y:k[u](0,m)},max:{x:C[u](0,g),y:C[u](0,m)}}})),ge=re((function(e,t){for(var n=de(e),o=t&&de(t),s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},r=function(e,t){if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"].concat(he[u](0,[t.x,t.y].concat(e.slice(1))));break;case"S":e=["C",t.x+(t.x-(t.bx||t.x)),t.y+(t.y-(t.by||t.y))].concat(e.slice(1));break;case"T":t.qx=t.x+(t.x-(t.qx||t.x)),t.qy=t.y+(t.y-(t.qy||t.y)),e=["C"].concat(ue(t.x,t.y,t.qx,t.qy,e[1],e[2]));break;case"Q":t.qx=e[1],t.qy=e[2],e=["C"].concat(ue(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"].concat(pe(t.x,t.y,e[1],e[2]));break;case"H":e=["C"].concat(pe(t.x,t.y,e[1],t.y));break;case"V":e=["C"].concat(pe(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"].concat(pe(t.x,t.y,t.X,t.Y))}return e},a=function(e,t){if(e[t][b]>7){e[t].shift();for(var s=e[t];s[b];)e.splice(t++,0,["C"].concat(s.splice(0,6)));e.splice(t,1),d=C(n[b],o&&o[b]||0)}},l=function(e,t,s,i,r){e&&t&&"M"==e[r][0]&&"M"!=t[r][0]&&(t.splice(r,0,["M",i.x,i.y]),s.bx=0,s.by=0,s.x=e[r][1],s.y=e[r][2],d=C(n[b],o&&o[b]||0))},c=0,d=C(n[b],o&&o[b]||0);c<d;c++){n[c]=r(n[c],s),a(n,c),o&&(o[c]=r(o[c],i)),o&&a(o,c),l(n,o,s,i,c),l(o,n,i,s,c);var p=n[c],h=o&&o[c],f=p[b],m=o&&h[b];s.x=p[f-2],s.y=p[f-1],s.bx=B(p[f-4])||s.x,s.by=B(p[f-3])||s.y,i.bx=o&&(B(h[m-4])||i.x),i.by=o&&(B(h[m-3])||i.y),i.x=o&&h[m-2],i.y=o&&h[m-1]}return o?[n,o]:n}),null,le),ve=re((function(e){for(var n=[],o=0,s=e[b];o<s;o++){var i={},r=e[o].match(/^([^:]*):?([\d\.]*)/);if(i.color=t.getRGB(r[1]),i.color.error)return null;i.color=i.color.hex,r[2]&&(i.offset=r[2]+"%"),n[A](i)}for(o=1,s=n[b]-1;o<s;o++)if(!n[o].offset){for(var a=B(n[o-1].offset||0),l=0,c=o+1;c<s;c++)if(n[c].offset){l=n[c].offset;break}l||(l=100,c=s);for(var d=((l=B(l))-a)/(c-o+1);o<c;o++)a+=d,n[o].offset=a+"%"}return n})),ye=function(e,n,o,s){var i;return t.is(e,M)||t.is(e,"object")?(i=t.is(e,M)?l.getElementById(e):e).tagName?null==n?{container:i,width:i.style.pixelWidth||i.offsetWidth,height:i.style.pixelHeight||i.offsetHeight}:{container:i,width:n,height:o}:void 0:{container:1,x:e,y:n,width:o,height:s}},be=function(e,t){var n=this;for(var o in t)if(t[a](o)&&!(o in e))switch(typeof t[o]){case"function":!function(t){e[o]=e===n?t:function(){return t[u](n,arguments)}}(t[o]);break;case"object":e[o]=e[o]||{},be.call(this,e[o],t[o]);break;default:e[o]=t[o]}},xe=function(e,t){e==t.top&&(t.top=e.prev),e==t.bottom&&(t.bottom=e.next),e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next)},we=function(e,t){t.top!==e&&(xe(e,t),e.next=null,e.prev=t.top,t.top.next=e,t.top=e)},Ce=function(e,t){t.bottom!==e&&(xe(e,t),e.next=t.bottom,e.prev=null,t.bottom.prev=e,t.bottom=e)},ke=function(e,t,n){xe(e,n),t==n.top&&(n.top=e),t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e},Se=function(e,t,n){xe(e,n),t==n.bottom&&(n.bottom=e),t.prev&&(t.prev.next=e),e.prev=t.prev,t.prev=e,e.next=t},Ee=function(e){return function(){throw new Error("Raphaël: you are calling to method “"+e+"” of removed object")}};if(t.pathToRelative=ce,t.svg){n.svgns="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",L=function(e){return+e+.5*(~~e===e)};var _e=function(t,o){if(!o)return(t=l.createElementNS(n.svgns,t)).style.webkitTapHighlightColor="rgba(0,0,0,0)",t;for(var s in o)o[a](s)&&e(t,s,g(o[s]))};t.toString=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var Te=function(e,t){var n=_e("path");t.canvas&&t.canvas.appendChild(n);var o=new Ae(n,t);return o.type="path",Pe(o,{fill:"none",stroke:"#000",path:e}),o},Me=function(e,t,n){var o="linear",s=.5,i=.5,r=e.style;if(t=(t=g(t)[G](Z,(function(e,t,n){if(o="radial",t&&n){s=B(t);var r=2*((i=B(n))>.5)-1;E(s-.5,2)+E(i-.5,2)>.25&&(i=w.sqrt(.25-E(s-.5,2))*r+.5)&&.5!=i&&(i=i.toFixed(5)-1e-5*r)}return f}))).split(/\s*\-\s*/),"linear"==o){var a=t.shift();if(a=-B(a),isNaN(a))return null;var c=[0,0,w.cos(a*_/180),w.sin(a*_/180)],d=1/(C(S(c[2]),S(c[3]))||1);c[2]*=d,c[3]*=d,c[2]<0&&(c[0]=-c[2],c[2]=0),c[3]<0&&(c[1]=-c[3],c[3]=0)}var p=ve(t);if(!p)return null;var u=e.getAttribute(P);(u=u.match(/^url\(#(.*)\)$/))&&n.defs.removeChild(l.getElementById(u[1]));var h=_e(o+"Gradient");h.id=te(),_e(h,"radial"==o?{fx:s,fy:i}:{x1:c[0],y1:c[1],x2:c[2],y2:c[3]}),n.defs.appendChild(h);for(var m=0,v=p[b];m<v;m++){var y=_e("stop");_e(y,{offset:p[m].offset?p[m].offset:m?"100%":"0%","stop-color":p[m].color||"#fff"}),h.appendChild(y)}return _e(e,{fill:"url(#"+h.id+")",opacity:1,"fill-opacity":1}),r.fill=f,r.opacity=1,r.fillOpacity=1,1},Ie=function(e){var n=e.getBBox();_e(e.pattern,{patternTransform:t.format("translate({0},{1})",n.x,n.y)})},Pe=function(n,s){var i={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},r=n.node,c=n.attrs,d=n.rotate(),p=function(e,t){if(t=i[x.call(t)]){for(var n=e.attrs["stroke-width"]||"1",o={round:n,square:n,butt:0}[e.attrs["stroke-linecap"]||s["stroke-linecap"]]||0,a=[],l=t[b];l--;)a[l]=t[l]*n+(l%2?1:-1)*o;_e(r,{"stroke-dasharray":a.join(",")})}};s[a]("rotation")&&(d=s.rotation);var u=g(d).split(o);for(var h in u.length-1?(u[1]=+u[1],u[2]=+u[2]):u=null,B(d)&&n.rotate(0,!0),s)if(s[a](h)){if(!W[a](h))continue;var v=s[h];switch(c[h]=v,h){case"blur":n.blur(v);break;case"rotation":n.rotate(v,!0);break;case"href":case"title":case"target":var y=r.parentNode;if("a"!=x.call(y.tagName)){var w=_e("a");y.insertBefore(w,r),w.appendChild(r),y=w}"target"==h&&"blank"==v?y.setAttributeNS(n.paper.xlink,"show","new"):y.setAttributeNS(n.paper.xlink,h,v);break;case"cursor":r.style.cursor=v;break;case"clip-rect":var C=g(v).split(o);if(4==C[b]){n.clip&&n.clip.parentNode.parentNode.removeChild(n.clip.parentNode);var k=_e("clipPath"),S=_e("rect");k.id=te(),_e(S,{x:C[0],y:C[1],width:C[2],height:C[3]}),k.appendChild(S),n.paper.defs.appendChild(k),_e(r,{"clip-path":"url(#"+k.id+")"}),n.clip=S}if(!v){var E=l.getElementById(r.getAttribute("clip-path")[G](/(^url\(#|\)$)/g,f));E&&E.parentNode.removeChild(E),_e(r,{"clip-path":f}),delete n.clip}break;case"path":"path"==n.type&&_e(r,{d:v?c.path=de(v):"M0,0"});break;case"width":if(e(r,h,v),!c.fx)break;h="x",v=c.x;case"x":c.fx&&(v=-c.x-(c.width||0));case"rx":if("rx"==h&&"rect"==n.type)break;case"cx":u&&("x"==h||"cx"==h)&&(u[1]+=v-c[h]),e(r,h,v),n.pattern&&Ie(n);break;case"height":if(e(r,h,v),!c.fy)break;h="y",v=c.y;case"y":c.fy&&(v=-c.y-(c.height||0));case"ry":if("ry"==h&&"rect"==n.type)break;case"cy":u&&("y"==h||"cy"==h)&&(u[2]+=v-c[h]),e(r,h,v),n.pattern&&Ie(n);break;case"r":"rect"==n.type?_e(r,{rx:v,ry:v}):e(r,h,v);break;case"src":"image"==n.type&&r.setAttributeNS(n.paper.xlink,"href",v);break;case"stroke-width":r.style.strokeWidth=v,e(r,h,v),c["stroke-dasharray"]&&p(n,c["stroke-dasharray"]);break;case"stroke-dasharray":p(n,v);break;case"translation":var _=g(v).split(o);_[0]=+_[0]||0,_[1]=+_[1]||0,u&&(u[1]+=_[0],u[2]+=_[1]),gt.call(n,_[0],_[1]);break;case"scale":_=g(v).split(o),n.scale(+_[0]||1,+_[1]||+_[0]||1,isNaN(B(_[2]))?null:+_[2],isNaN(B(_[3]))?null:+_[3]);break;case P:var T=g(v).match(R);if(T){k=_e("pattern");var M=_e("image");k.id=te(),_e(k,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),_e(M,{x:0,y:0}),M.setAttributeNS(n.paper.xlink,"href",T[1]),k.appendChild(M);var I=l.createElement("img");I.style.cssText="position:absolute;left:-9999em;top-9999em",I.onload=function(){_e(k,{width:this.offsetWidth,height:this.offsetHeight}),_e(M,{width:this.offsetWidth,height:this.offsetHeight}),l.body.removeChild(this),n.paper.safari()},l.body.appendChild(I),I.src=T[1],n.paper.defs.appendChild(k),r.style.fill="url(#"+k.id+")",_e(r,{fill:"url(#"+k.id+")"}),n.pattern=k,n.pattern&&Ie(n);break}var N=t.getRGB(v);if(N.error){if(({circle:1,ellipse:1}[a](n.type)||"r"!=g(v).charAt())&&Me(r,v,n.paper)){c.gradient=v,c.fill="none";break}}else delete s.gradient,delete c.gradient,!t.is(c.opacity,"undefined")&&t.is(s.opacity,"undefined")&&_e(r,{opacity:c.opacity}),!t.is(c["fill-opacity"],"undefined")&&t.is(s["fill-opacity"],"undefined")&&_e(r,{"fill-opacity":c["fill-opacity"]});N[a]("opacity")&&_e(r,{"fill-opacity":N.opacity>1?N.opacity/100:N.opacity});case"stroke":N=t.getRGB(v),e(r,h,N.hex),"stroke"==h&&N[a]("opacity")&&_e(r,{"stroke-opacity":N.opacity>1?N.opacity/100:N.opacity});break;case"gradient":({circle:1,ellipse:1}[a](n.type)||"r"!=g(v).charAt())&&Me(r,v,n.paper);break;case"opacity":c.gradient&&!c[a]("stroke-opacity")&&_e(r,{"stroke-opacity":v>1?v/100:v});case"fill-opacity":if(c.gradient){var A=l.getElementById(r.getAttribute(P)[G](/^url\(#|\)$/g,f));if(A){var F=A.getElementsByTagName("stop");e(F[F[b]-1],"stop-opacity",v)}break}default:"font-size"==h&&(v=z(v,10)+"px");var O=h[G](/(\-.)/g,(function(e){return H.call(e.substring(1))}));r.style[O]=v,e(r,h,v)}}Ne(n,s),u?n.rotate(u.join(m)):B(d)&&n.rotate(d,!0)},Ne=function(e,n){if("text"==e.type&&(n[a]("text")||n[a]("font")||n[a]("font-size")||n[a]("x")||n[a]("y"))){var o=e.attrs,s=e.node,i=s.firstChild?z(l.defaultView.getComputedStyle(s.firstChild,f).getPropertyValue("font-size"),10):10;if(n[a]("text")){for(o.text=n.text;s.firstChild;)s.removeChild(s.firstChild);for(var r=g(n.text).split("\n"),c=0,d=r[b];c<d;c++)if(r[c]){var p=_e("tspan");c&&_e(p,{dy:1.2*i,x:o.x}),p.appendChild(l.createTextNode(r[c])),s.appendChild(p)}}else for(c=0,d=(r=s.getElementsByTagName("tspan"))[b];c<d;c++)c&&_e(r[c],{dy:1.2*i,x:o.x});_e(s,{y:o.y});var u=e.getBBox(),h=o.y-(u.y+u.height/2);h&&t.is(h,"finite")&&_e(s,{y:o.y+h})}},Ae=function(e,n){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.paper=n,this.attrs=this.attrs||{},this.transformations=[],this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1},!n.bottom&&(n.bottom=this),this.prev=n.top,n.top&&(n.top.next=this),n.top=this,this.next=null},Re=Ae[r];Ae[r].rotate=function(e,n,s){if(this.removed)return this;if(null==e)return this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(m):this._.rt.deg;var i=this.getBBox();return(e=g(e).split(o))[b]-1&&(n=B(e[1]),s=B(e[2])),e=B(e[0]),null!=n&&!1!==n?this._.rt.deg=e:this._.rt.deg+=e,null==s&&(n=null),this._.rt.cx=n,this._.rt.cy=s,n=null==n?i.x+i.width/2:n,s=null==s?i.y+i.height/2:s,this._.rt.deg?(this.transformations[0]=t.format("rotate({0} {1} {2})",this._.rt.deg,n,s),this.clip&&_e(this.clip,{transform:t.format("rotate({0} {1} {2})",-this._.rt.deg,n,s)})):(this.transformations[0]=f,this.clip&&_e(this.clip,{transform:f})),_e(this.node,{transform:this.transformations.join(m)}),this},Ae[r].hide=function(){return!this.removed&&(this.node.style.display="none"),this},Ae[r].show=function(){return!this.removed&&(this.node.style.display=""),this},Ae[r].remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this)delete this[e];this.removed=!0}},Ae[r].getBBox=function(){if(this.removed)return this;if("path"==this.type)return ae(this.attrs.path);if("none"==this.node.style.display){this.show();var e=!0}var t={};try{t=this.node.getBBox()}catch(e){}finally{t=t||{}}if("text"==this.type){t={x:t.x,y:1/0,width:0,height:0};for(var n=0,o=this.node.getNumberOfChars();n<o;n++){var s=this.node.getExtentOfChar(n);s.y<t.y&&(t.y=s.y),s.y+s.height-t.y>t.height&&(t.height=s.y+s.height-t.y),s.x+s.width-t.x>t.width&&(t.width=s.x+s.width-t.x)}}return e&&this.hide(),t},Ae[r].attr=function(e,n){if(this.removed)return this;if(null==e){var o={};for(var s in this.attrs)this.attrs[a](s)&&(o[s]=this.attrs[s]);return this._.rt.deg&&(o.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(o.scale=this.scale()),o.gradient&&"none"==o.fill&&(o.fill=o.gradient)&&delete o.gradient,o}if(null==n&&t.is(e,M))return"translation"==e?gt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(null==n&&t.is(e,I)){for(var i={},r=0,l=e.length;r<l;r++)i[e[r]]=this.attr(e[r]);return i}if(null!=n){var c={};c[e]=n}else null!=e&&t.is(e,"object")&&(c=e);for(var d in this.paper.customAttributes)if(this.paper.customAttributes[a](d)&&c[a](d)&&t.is(this.paper.customAttributes[d],"function")){var p=this.paper.customAttributes[d].apply(this,[].concat(c[d]));for(var u in this.attrs[d]=c[d],p)p[a](u)&&(c[u]=p[u])}return Pe(this,c),this},Ae[r].toFront=function(){if(this.removed)return this;this.node.parentNode.appendChild(this.node);var e=this.paper;return e.top!=this&&we(this,e),this},Ae[r].toBack=function(){return this.removed||this.node.parentNode.firstChild!=this.node&&(this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),Ce(this,this.paper),this.paper),this},Ae[r].insertAfter=function(e){if(this.removed)return this;var t=e.node||e[e.length-1].node;return t.nextSibling?t.parentNode.insertBefore(this.node,t.nextSibling):t.parentNode.appendChild(this.node),ke(this,e,this.paper),this},Ae[r].insertBefore=function(e){if(this.removed)return this;var t=e.node||e[0].node;return t.parentNode.insertBefore(this.node,t),Se(this,e,this.paper),this},Ae[r].blur=function(e){var t=this;if(0!=+e){var n=_e("filter"),o=_e("feGaussianBlur");t.attrs.blur=e,n.id=te(),_e(o,{stdDeviation:+e||1.5}),n.appendChild(o),t.paper.defs.appendChild(n),t._blur=n,_e(t.node,{filter:"url(#"+n.id+")"})}else t._blur&&(t._blur.parentNode.removeChild(t._blur),delete t._blur,delete t.attrs.blur),t.node.removeAttribute("filter")};var Fe=function(e,t,n,o){var s=_e("circle");e.canvas&&e.canvas.appendChild(s);var i=new Ae(s,e);return i.attrs={cx:t,cy:n,r:o,fill:"none",stroke:"#000"},i.type="circle",_e(s,i.attrs),i},Oe=function(e,t,n,o,s,i){var r=_e("rect");e.canvas&&e.canvas.appendChild(r);var a=new Ae(r,e);return a.attrs={x:t,y:n,width:o,height:s,r:i||0,rx:i||0,ry:i||0,fill:"none",stroke:"#000"},a.type="rect",_e(r,a.attrs),a},De=function(e,t,n,o,s){var i=_e("ellipse");e.canvas&&e.canvas.appendChild(i);var r=new Ae(i,e);return r.attrs={cx:t,cy:n,rx:o,ry:s,fill:"none",stroke:"#000"},r.type="ellipse",_e(i,r.attrs),r},Le=function(e,t,n,o,s,i){var r=_e("image");_e(r,{x:n,y:o,width:s,height:i,preserveAspectRatio:"none"}),r.setAttributeNS(e.xlink,"href",t),e.canvas&&e.canvas.appendChild(r);var a=new Ae(r,e);return a.attrs={x:n,y:o,width:s,height:i,src:t},a.type="image",a},Be=function(e,t,n,o){var s=_e("text");_e(s,{x:t,y:n,"text-anchor":"middle"}),e.canvas&&e.canvas.appendChild(s);var i=new Ae(s,e);return i.attrs={x:t,y:n,"text-anchor":"middle",text:o,font:W.font,stroke:"none",fill:"#000"},i.type="text",Pe(i,i.attrs),i},ze=function(t,n){return this.width=t||this.width,this.height=n||this.height,e(this.canvas,"width",this.width),e(this.canvas,"height",this.height),this},qe=function(){var e=ye[u](0,arguments),n=e&&e.container,o=e.x,s=e.y,i=e.width,r=e.height;if(!n)throw new Error("SVG container not found.");var a=_e("svg");return o=o||0,s=s||0,_e(a,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:i=i||512,height:r=r||342}),1==n?(a.style.cssText="position:absolute;left:"+o+"px;top:"+s+"px",l.body.appendChild(a)):n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),(n=new p).width=i,n.height=r,n.canvas=a,be.call(n,n,t.fn),n.clear(),n};n.clear=function(){for(var e=this.canvas;e.firstChild;)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=_e("desc")).appendChild(l.createTextNode("Created with Raphaël")),e.appendChild(this.desc),e.appendChild(this.defs=_e("defs"))},n.remove=function(){for(var e in this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Ee(e)}}if(t.vml){var He,We={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Ue=/([clmz]),?([^clmz]*)/gi,Ge=/ progid:\S+Blur\([^\)]+\)/g,Ve=/-?[^,\s-]+/g,je="1000 1000",Ye=10,$e={path:1,rect:1};function wt(e,n,o,s,i){return i?t.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",e+i,n,o-2*i,i,-i,s-2*i,2*i-o,2*i-s):t.format("M{0},{1}l{2},0,0,{3},{4},0z",e,n,o,s,-o)}t.toString=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version},Te=function(e,t){var n=He("group");n.style.cssText="position:absolute;left:0;top:0;width:"+t.width+"px;height:"+t.height+"px",n.coordsize=t.coordsize,n.coordorigin=t.coordorigin;var o=He("shape"),s=o.style;s.width=t.width+"px",s.height=t.height+"px",o.coordsize=je,o.coordorigin=t.coordorigin,n.appendChild(o);var i=new Ae(o,n,t),r={fill:"none",stroke:"#000"};return e&&(r.path=e),i.type="path",i.path=[],i.Path=f,Pe(i,r),t.canvas.appendChild(n),i},Pe=function(e,n){e.attrs=e.attrs||{};var s,i=e.node,r=e.attrs,c=i.style,d=(n.x!=r.x||n.y!=r.y||n.width!=r.width||n.height!=r.height||n.r!=r.r)&&"rect"==e.type,p=e;for(var u in n)n[a](u)&&(r[u]=n[u]);if(d&&(r.path=wt(r.x,r.y,r.width,r.height,r.r),e.X=r.x,e.Y=r.y,e.W=r.width,e.H=r.height),n.href&&(i.href=n.href),n.title&&(i.title=n.title),n.target&&(i.target=n.target),n.cursor&&(c.cursor=n.cursor),"blur"in n&&e.blur(n.blur),(n.path&&"path"==e.type||d)&&(i.path=function(e){var t=/[ahqstv]/gi,n=de;if(g(e).match(t)&&(n=ge),t=/[clmz]/g,n==de&&!g(e).match(t)){var o=g(e)[G](Ue,(function(e,t,n){var o=[],s="m"==x.call(t),i=We[t];return n[G](Ve,(function(e){s&&2==o[b]&&(i+=o+We["m"==t?"l":"L"],o=[]),o[A](L(e*Ye))})),i+o}));return o}var s,i,r=n(e);o=[];for(var a=0,l=r[b];a<l;a++){s=r[a],"z"==(i=x.call(r[a][0]))&&(i="x");for(var c=1,d=s[b];c<d;c++)i+=L(s[c]*Ye)+(c!=d-1?",":f);o[A](i)}return o.join(m)}(r.path)),null!=n.rotation&&e.rotate(n.rotation,!0),n.translation&&(s=g(n.translation).split(o),gt.call(e,s[0],s[1]),null!=e._.rt.cx&&(e._.rt.cx+=+s[0],e._.rt.cy+=+s[1],e.setBox(e.attrs,s[0],s[1]))),n.scale&&(s=g(n.scale).split(o),e.scale(+s[0]||1,+s[1]||+s[0]||1,+s[2]||null,+s[3]||null)),"clip-rect"in n){var h=g(n["clip-rect"]).split(o);if(4==h[b]){h[2]=+h[2]+ +h[0],h[3]=+h[3]+ +h[1];var v=i.clipRect||l.createElement("div"),y=v.style,w=i.parentNode;y.clip=t.format("rect({1}px {2}px {3}px {0}px)",h),i.clipRect||(y.position="absolute",y.top=0,y.left=0,y.width=e.paper.width+"px",y.height=e.paper.height+"px",w.parentNode.insertBefore(v,w),v.appendChild(w),i.clipRect=v)}n["clip-rect"]||i.clipRect&&(i.clipRect.style.clip=f)}if("image"==e.type&&n.src&&(i.src=n.src),"image"==e.type&&n.opacity&&(i.filterOpacity=q+".Alpha(opacity="+100*n.opacity+")",c.filter=(i.filterMatrix||f)+(i.filterOpacity||f)),n.font&&(c.font=n.font),n["font-family"]&&(c.fontFamily='"'+n["font-family"].split(",")[0][G](/^['"]+|['"]+$/g,f)+'"'),n["font-size"]&&(c.fontSize=n["font-size"]),n["font-weight"]&&(c.fontWeight=n["font-weight"]),n["font-style"]&&(c.fontStyle=n["font-style"]),null!=n.opacity||null!=n["stroke-width"]||null!=n.fill||null!=n.stroke||null!=n["stroke-width"]||null!=n["stroke-opacity"]||null!=n["fill-opacity"]||null!=n["stroke-dasharray"]||null!=n["stroke-miterlimit"]||null!=n["stroke-linejoin"]||null!=n["stroke-linecap"]){var S=(i=e.shape||i).getElementsByTagName(P)&&i.getElementsByTagName(P)[0],E=!1;if(!S&&(E=S=He(P)),"fill-opacity"in n||"opacity"in n){var _=((+r["fill-opacity"]+1||2)-1)*((+r.opacity+1||2)-1)*((+t.getRGB(n.fill).o+1||2)-1);_=k(C(_,0),1),S.opacity=_}if(n.fill&&(S.on=!0),null!=S.on&&"none"!=n.fill||(S.on=!1),S.on&&n.fill){var T=n.fill.match(R);T?(S.src=T[1],S.type="tile"):(S.color=t.getRGB(n.fill).hex,S.src=f,S.type="solid",t.getRGB(n.fill).error&&(p.type in{circle:1,ellipse:1}||"r"!=g(n.fill).charAt())&&Me(p,n.fill)&&(r.fill="none",r.gradient=n.fill))}E&&i.appendChild(S);var M=i.getElementsByTagName("stroke")&&i.getElementsByTagName("stroke")[0],I=!1;!M&&(I=M=He("stroke")),(n.stroke&&"none"!=n.stroke||n["stroke-width"]||null!=n["stroke-opacity"]||n["stroke-dasharray"]||n["stroke-miterlimit"]||n["stroke-linejoin"]||n["stroke-linecap"])&&(M.on=!0),("none"==n.stroke||null==M.on||0==n.stroke||0==n["stroke-width"])&&(M.on=!1);var N=t.getRGB(n.stroke);M.on&&n.stroke&&(M.color=N.hex),_=((+r["stroke-opacity"]+1||2)-1)*((+r.opacity+1||2)-1)*((+N.o+1||2)-1);var F=.75*(B(n["stroke-width"])||1);if(_=k(C(_,0),1),null==n["stroke-width"]&&(F=r["stroke-width"]),n["stroke-width"]&&(M.weight=F),F&&F<1&&(_*=F)&&(M.weight=1),M.opacity=_,n["stroke-linejoin"]&&(M.joinstyle=n["stroke-linejoin"]||"miter"),M.miterlimit=n["stroke-miterlimit"]||8,n["stroke-linecap"]&&(M.endcap="butt"==n["stroke-linecap"]?"flat":"square"==n["stroke-linecap"]?"square":"round"),n["stroke-dasharray"]){var O={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};M.dashstyle=O[a](n["stroke-dasharray"])?O[n["stroke-dasharray"]]:f}I&&i.appendChild(M)}if("text"==p.type)switch(c=p.paper.span.style,r.font&&(c.font=r.font),r["font-family"]&&(c.fontFamily=r["font-family"]),r["font-size"]&&(c.fontSize=r["font-size"]),r["font-weight"]&&(c.fontWeight=r["font-weight"]),r["font-style"]&&(c.fontStyle=r["font-style"]),p.node.string&&(p.paper.span.innerHTML=g(p.node.string)[G](/</g,"<")[G](/&/g,"&")[G](/\n/g,"<br>")),p.W=r.w=p.paper.span.offsetWidth,p.H=r.h=p.paper.span.offsetHeight,p.X=r.x,p.Y=r.y+L(p.H/2),r["text-anchor"]){case"start":p.node.style["v-text-align"]="left",p.bbx=L(p.W/2);break;case"end":p.node.style["v-text-align"]="right",p.bbx=-L(p.W/2);break;default:p.node.style["v-text-align"]="center"}},Me=function(e,t){e.attrs=e.attrs||{},e.attrs;var n,o="linear",s=".5 .5";if(e.attrs.gradient=t,t=(t=g(t)[G](Z,(function(e,t,n){return o="radial",t&&n&&(t=B(t),n=B(n),E(t-.5,2)+E(n-.5,2)>.25&&(n=w.sqrt(.25-E(t-.5,2))*(2*(n>.5)-1)+.5),s=t+m+n),f}))).split(/\s*\-\s*/),"linear"==o){var i=t.shift();if(i=-B(i),isNaN(i))return null}var r=ve(t);if(!r)return null;if(!(n=(e=e.shape||e.node).getElementsByTagName(P)[0]||He(P)).parentNode&&e.appendChild(n),r[b]){n.on=!0,n.method="none",n.color=r[0].color,n.color2=r[r[b]-1].color;for(var a=[],l=0,c=r[b];l<c;l++)r[l].offset&&a[A](r[l].offset+m+r[l].color);n.colors&&(n.colors.value=a[b]?a.join():"0% "+n.color),"radial"==o?(n.type="gradientradial",n.focus="100%",n.focussize=s,n.focusposition=s):(n.type="gradient",n.angle=(270-i)%360)}return 1},(Re=(Ae=function(e,n,o){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.X=0,this.Y=0,this.attrs={},this.Group=n,this.paper=o,this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1},!o.bottom&&(o.bottom=this),this.prev=o.top,o.top&&(o.top.next=this),o.top=this,this.next=null})[r]).rotate=function(e,t,n){return this.removed?this:null==e?this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(m):this._.rt.deg:((e=g(e).split(o))[b]-1&&(t=B(e[1]),n=B(e[2])),e=B(e[0]),null!=t?this._.rt.deg=e:this._.rt.deg+=e,null==n&&(t=null),this._.rt.cx=t,this._.rt.cy=n,this.setBox(this.attrs,t,n),this.Group.style.rotation=this._.rt.deg,this)},Re.setBox=function(e,t,n){if(this.removed)return this;var o=this.Group.style,s=this.shape&&this.shape.style||this.node.style;for(var i in e=e||{})e[a](i)&&(this.attrs[i]=e[i]);t=t||this._.rt.cx,n=n||this._.rt.cy;var r,l,c,d,p=this.attrs;switch(this.type){case"circle":r=p.cx-p.r,l=p.cy-p.r,c=d=2*p.r;break;case"ellipse":r=p.cx-p.rx,l=p.cy-p.ry,c=2*p.rx,d=2*p.ry;break;case"image":r=+p.x,l=+p.y,c=p.width||0,d=p.height||0;break;case"text":this.textpath.v=["m",L(p.x),", ",L(p.y-2),"l",L(p.x)+1,", ",L(p.y-2)].join(f),r=p.x-L(this.W/2),l=p.y-this.H/2,c=this.W,d=this.H;break;case"rect":case"path":if(this.attrs.path){var u=ae(this.attrs.path);r=u.x,l=u.y,c=u.width,d=u.height}else r=0,l=0,c=this.paper.width,d=this.paper.height;break;default:r=0,l=0,c=this.paper.width,d=this.paper.height}n=null==n?l+d/2:n;var h,m=(t=null==t?r+c/2:t)-this.paper.width/2,g=n-this.paper.height/2;o.left!=(h=m+"px")&&(o.left=h),o.top!=(h=g+"px")&&(o.top=h),this.X=$e[a](this.type)?-m:r,this.Y=$e[a](this.type)?-g:l,this.W=c,this.H=d,$e[a](this.type)?(s.left!=(h=-m*Ye+"px")&&(s.left=h),s.top!=(h=-g*Ye+"px")&&(s.top=h)):"text"==this.type?(s.left!=(h=-m+"px")&&(s.left=h),s.top!=(h=-g+"px")&&(s.top=h)):(o.width!=(h=this.paper.width+"px")&&(o.width=h),o.height!=(h=this.paper.height+"px")&&(o.height=h),s.left!=(h=r-m+"px")&&(s.left=h),s.top!=(h=l-g+"px")&&(s.top=h),s.width!=(h=c+"px")&&(s.width=h),s.height!=(h=d+"px")&&(s.height=h))},Re.hide=function(){return!this.removed&&(this.Group.style.display="none"),this},Re.show=function(){return!this.removed&&(this.Group.style.display="block"),this},Re.getBBox=function(){return this.removed?this:$e[a](this.type)?ae(this.attrs.path):{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}},Re.remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this.Group.parentNode.removeChild(this.Group),this.shape&&this.shape.parentNode.removeChild(this.shape),this)delete this[e];this.removed=!0}},Re.attr=function(e,n){if(this.removed)return this;if(null==e){var o={};for(var s in this.attrs)this.attrs[a](s)&&(o[s]=this.attrs[s]);return this._.rt.deg&&(o.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(o.scale=this.scale()),o.gradient&&"none"==o.fill&&(o.fill=o.gradient)&&delete o.gradient,o}if(null==n&&t.is(e,"string"))return"translation"==e?gt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(this.attrs&&null==n&&t.is(e,I)){var i,r={};for(s=0,i=e[b];s<i;s++)r[e[s]]=this.attr(e[s]);return r}var l;if(null!=n&&((l={})[e]=n),null==n&&t.is(e,"object")&&(l=e),l){for(var c in this.paper.customAttributes)if(this.paper.customAttributes[a](c)&&l[a](c)&&t.is(this.paper.customAttributes[c],"function")){var d=this.paper.customAttributes[c].apply(this,[].concat(l[c]));for(var p in this.attrs[c]=l[c],d)d[a](p)&&(l[p]=d[p])}l.text&&"text"==this.type&&(this.node.string=l.text),Pe(this,l),l.gradient&&({circle:1,ellipse:1}[a](this.type)||"r"!=g(l.gradient).charAt())&&Me(this,l.gradient),(!$e[a](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this},Re.toFront=function(){return!this.removed&&this.Group.parentNode.appendChild(this.Group),this.paper.top!=this&&we(this,this.paper),this},Re.toBack=function(){return this.removed||this.Group.parentNode.firstChild!=this.Group&&(this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild),Ce(this,this.paper)),this},Re.insertAfter=function(e){return this.removed||(e.constructor==bt&&(e=e[e.length-1]),e.Group.nextSibling?e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling):e.Group.parentNode.appendChild(this.Group),ke(this,e,this.paper)),this},Re.insertBefore=function(e){return this.removed||(e.constructor==bt&&(e=e[0]),e.Group.parentNode.insertBefore(this.Group,e.Group),Se(this,e,this.paper)),this},Re.blur=function(e){var n=this.node.runtimeStyle,o=n.filter;o=o.replace(Ge,f),0!=+e?(this.attrs.blur=e,n.filter=o+m+q+".Blur(pixelradius="+(+e||1.5)+")",n.margin=t.format("-{0}px 0 0 -{0}px",L(+e||1.5))):(n.filter=o,n.margin=0,delete this.attrs.blur)},Fe=function(e,t,n,o){var s=He("group"),i=He("oval");i.style,s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=je,s.coordorigin=e.coordorigin,s.appendChild(i);var r=new Ae(i,s,e);return r.type="circle",Pe(r,{stroke:"#000",fill:"none"}),r.attrs.cx=t,r.attrs.cy=n,r.attrs.r=o,r.setBox({x:t-o,y:n-o,width:2*o,height:2*o}),e.canvas.appendChild(s),r},Oe=function(e,t,n,o,s,i){var r=wt(t,n,o,s,i),a=e.path(r),l=a.attrs;return a.X=l.x=t,a.Y=l.y=n,a.W=l.width=o,a.H=l.height=s,l.r=i,l.path=r,a.type="rect",a},De=function(e,t,n,o,s){var i=He("group"),r=He("oval");r.style,i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=je,i.coordorigin=e.coordorigin,i.appendChild(r);var a=new Ae(r,i,e);return a.type="ellipse",Pe(a,{stroke:"#000"}),a.attrs.cx=t,a.attrs.cy=n,a.attrs.rx=o,a.attrs.ry=s,a.setBox({x:t-o,y:n-s,width:2*o,height:2*s}),e.canvas.appendChild(i),a},Le=function(e,t,n,o,s,i){var r=He("group"),a=He("image");r.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",r.coordsize=je,r.coordorigin=e.coordorigin,a.src=t,r.appendChild(a);var l=new Ae(a,r,e);return l.type="image",l.attrs.src=t,l.attrs.x=n,l.attrs.y=o,l.attrs.w=s,l.attrs.h=i,l.setBox({x:n,y:o,width:s,height:i}),e.canvas.appendChild(r),l},Be=function(e,n,o,s){var i=He("group"),r=He("shape"),a=r.style,l=He("path");l.style;var c=He("textpath");i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=je,i.coordorigin=e.coordorigin,l.v=t.format("m{0},{1}l{2},{1}",L(10*n),L(10*o),L(10*n)+1),l.textpathok=!0,a.width=e.width,a.height=e.height,c.string=g(s),c.on=!0,r.appendChild(c),r.appendChild(l),i.appendChild(r);var d=new Ae(c,i,e);return d.shape=r,d.textpath=l,d.type="text",d.attrs.text=s,d.attrs.x=n,d.attrs.y=o,d.attrs.w=1,d.attrs.h=1,Pe(d,{font:W.font,stroke:"none",fill:"#000"}),d.setBox(),e.canvas.appendChild(i),d},ze=function(e,t){var n=this.canvas.style;return e==+e&&(e+="px"),t==+t&&(t+="px"),n.width=e,n.height=t,n.clip="rect(0 "+e+" "+t+" 0)",this},l.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!l.namespaces.rvml&&l.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),He=function(e){return l.createElement("<rvml:"+e+' class="rvml">')}}catch(Ct){He=function(e){return l.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}qe=function(){var e=ye[u](0,arguments),n=e.container,o=e.height,s=e.width,i=e.x,r=e.y;if(!n)throw new Error("VML container not found.");var a=new p,c=a.canvas=l.createElement("div"),d=c.style;return i=i||0,r=r||0,(s=s||512)==+s&&(s+="px"),(o=o||342)==+o&&(o+="px"),a.width=1e3,a.height=1e3,a.coordsize="10000 10000",a.coordorigin="0 0",a.span=l.createElement("span"),a.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",c.appendChild(a.span),d.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",s,o),1==n?(l.body.appendChild(c),d.left=i+"px",d.top=r+"px",d.position="absolute"):n.firstChild?n.insertBefore(c,n.firstChild):n.appendChild(c),be.call(a,a,t.fn),a},n.clear=function(){this.canvas.innerHTML=f,this.span=l.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},n.remove=function(){for(var e in this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Ee(e);return!0}}var Xe=navigator.userAgent.match(/Version\/(.*?)\s/);"Apple Computer, Inc."==navigator.vendor&&(Xe&&Xe[1]<4||"iP"==navigator.platform.slice(0,2))?n.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});c.setTimeout((function(){e.remove()}))}:n.safari=function(){};for(var Ke=function(){this.returnValue=!1},Ze=function(){return this.originalEvent.preventDefault()},Je=function(){this.cancelBubble=!0},Qe=function(){return this.originalEvent.stopPropagation()},et=l.addEventListener?function(e,t,n,o){var s=h&&y[t]?y[t]:t,i=function(s){if(h&&y[a](t))for(var i=0,r=s.targetTouches&&s.targetTouches.length;i<r;i++)if(s.targetTouches[i].target==e){var l=s;(s=s.targetTouches[i]).originalEvent=l,s.preventDefault=Ze,s.stopPropagation=Qe;break}return n.call(o,s)};return e.addEventListener(s,i,!1),function(){return e.removeEventListener(s,i,!1),!0}}:l.attachEvent?function(e,t,n,o){var s=function(e){return(e=e||c.event).preventDefault=e.preventDefault||Ke,e.stopPropagation=e.stopPropagation||Je,n.call(o,e)};return e.attachEvent("on"+t,s),function(){return e.detachEvent("on"+t,s),!0}}:void 0,tt=[],nt=function(e){for(var t,n=e.clientX,o=e.clientY,s=l.documentElement.scrollTop||l.body.scrollTop,i=l.documentElement.scrollLeft||l.body.scrollLeft,r=tt.length;r--;){if(t=tt[r],h){for(var a,c=e.touches.length;c--;)if((a=e.touches[c]).identifier==t.el._drag.id){n=a.clientX,o=a.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}else e.preventDefault();n+=i,o+=s,t.move&&t.move.call(t.move_scope||t.el,n-t.el._drag.x,o-t.el._drag.y,n,o,e)}},ot=function(e){t.unmousemove(nt).unmouseup(ot);for(var n,o=tt.length;o--;)(n=tt[o]).el._drag={},n.end&&n.end.call(n.end_scope||n.start_scope||n.move_scope||n.el,e);tt=[]},st=v[b];st--;)!function(e){t[e]=Ae[r][e]=function(n,o){return t.is(n,"function")&&(this.events=this.events||[],this.events.push({name:e,f:n,unbind:et(this.shape||this.node||l,e,n,o||this)})),this},t["un"+e]=Ae[r]["un"+e]=function(t){for(var n=this.events,o=n[b];o--;)if(n[o].name==e&&n[o].f==t)return n[o].unbind(),n.splice(o,1),!n.length&&delete this.events,this;return this}}(v[st]);function it(){return this.x+m+this.y}Re.hover=function(e,t,n,o){return this.mouseover(e,n).mouseout(t,o||n)},Re.unhover=function(e,t){return this.unmouseover(e).unmouseout(t)},Re.drag=function(e,n,o,s,i,r){return this._drag={},this.mousedown((function(a){(a.originalEvent||a).preventDefault();var c=l.documentElement.scrollTop||l.body.scrollTop,d=l.documentElement.scrollLeft||l.body.scrollLeft;this._drag.x=a.clientX+d,this._drag.y=a.clientY+c,this._drag.id=a.identifier,n&&n.call(i||s||this,a.clientX+d,a.clientY+c,a),!tt.length&&t.mousemove(nt).mouseup(ot),tt.push({el:this,move:e,end:o,move_scope:s,start_scope:i,end_scope:r})})),this},Re.undrag=function(e,n,o){for(var s=tt.length;s--;)tt[s].el==this&&tt[s].move==e&&tt[s].end==o&&tt.splice(s++,1);!tt.length&&t.unmousemove(nt).unmouseup(ot)},n.circle=function(e,t,n){return Fe(this,e||0,t||0,n||0)},n.rect=function(e,t,n,o,s){return Oe(this,e||0,t||0,n||0,o||0,s||0)},n.ellipse=function(e,t,n,o){return De(this,e||0,t||0,n||0,o||0)},n.path=function(e){return e&&!t.is(e,M)&&!t.is(e[0],I)&&(e+=f),Te(t.format[u](t,arguments),this)},n.image=function(e,t,n,o,s){return Le(this,e||"about:blank",t||0,n||0,o||0,s||0)},n.text=function(e,t,n){return Be(this,e||0,t||0,g(n))},n.set=function(e){return arguments[b]>1&&(e=Array[r].splice.call(arguments,0,arguments[b])),new bt(e)},n.setSize=ze,n.top=n.bottom=null,n.raphael=t,Re.resetScale=function(){if(this.removed)return this;this._.sx=1,this._.sy=1,this.attrs.scale="1 1"},Re.scale=function(t,n,o,s){if(this.removed)return this;if(null==t&&null==n)return{x:this._.sx,y:this._.sy,toString:it};!+(n=n||t)&&(n=t);var i,r,a=this.attrs;if(0!=t){var l=this.getBBox(),c=l.x+l.width/2,d=l.y+l.height/2,p=S(t/this._.sx),u=S(n/this._.sy);o=+o||0==o?o:c,s=+s||0==s?s:d;var h=this._.sx>0,g=this._.sy>0,v=~~(t/S(t)),y=~~(n/S(n)),x=p*v,w=u*y,C=this.node.style,k=o+S(c-o)*x*(c>o==h?1:-1),E=s+S(d-s)*w*(d>s==g?1:-1),_=t*v>n*y?u:p;switch(this.type){case"rect":case"image":var T=a.width*p,M=a.height*u;this.attr({height:M,r:a.r*_,width:T,x:k-T/2,y:E-M/2});break;case"circle":case"ellipse":this.attr({rx:a.rx*p,ry:a.ry*u,r:a.r*_,cx:k,cy:E});break;case"text":this.attr({x:k,y:E});break;case"path":for(var I=ce(a.path),P=!0,N=h?x:p,A=g?w:u,R=0,F=I[b];R<F;R++){var O=I[R],D=H.call(O[0]);if("M"!=D||!P)if(P=!1,"A"==D)O[I[R][b]-2]*=N,O[I[R][b]-1]*=A,O[1]*=p,O[2]*=u,O[5]=+(v+y?!!+O[5]:!+O[5]);else if("H"==D)for(var L=1,B=O[b];L<B;L++)O[L]*=N;else if("V"==D)for(L=1,B=O[b];L<B;L++)O[L]*=A;else for(L=1,B=O[b];L<B;L++)O[L]*=L%2?N:A}var z=ae(I);i=k-z.x-z.width/2,r=E-z.y-z.height/2,I[0][1]+=i,I[0][2]+=r,this.attr({path:I})}!(this.type in{text:1,image:1})||1==v&&1==y?this.transformations?(this.transformations[2]=f,e(this.node,"transform",this.transformations.join(m)),a.fx=0,a.fy=0):(this.node.filterMatrix=f,C.filter=(this.node.filterMatrix||f)+(this.node.filterOpacity||f)):this.transformations?(this.transformations[2]="scale(".concat(v,",",y,")"),e(this.node,"transform",this.transformations.join(m)),i=-1==v?-a.x-(T||0):a.x,r=-1==y?-a.y-(M||0):a.y,this.attr({x:i,y:r}),a.fx=v-1,a.fy=y-1):(this.node.filterMatrix=q+".Matrix(M11=".concat(v,", M12=0, M21=0, M22=",y,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"),C.filter=(this.node.filterMatrix||f)+(this.node.filterOpacity||f)),a.scale=[t,n,o,s].join(m),this._.sx=t,this._.sy=n}return this},Re.clone=function(){if(this.removed)return null;var e=this.attr();return delete e.scale,delete e.translation,this.paper[this.type]().attr(e)};var rt={},at=function(e,n,o,s,i,r,a,l,c){if(e===o&&n===s&&i===a&&r==l){var d=a-e,p=l-n,u=Math.sqrt(d*d+p*p);if(null==c)return u;var h=c/u;return{start:{x:e,y:n},m:{x:e,y:n},n:{x:a,y:l},end:{x:a,y:l},x:e+h*d,y:n+h*p,alpha:90-180*w.atan(d/p)/_}}var f,m,g=0,v=100,y=[e,n,o,s,i,r,a,l].join(),b=rt[y];(!b&&(rt[y]=b={data:[]}),b.timer&&clearTimeout(b.timer),b.timer=setTimeout((function(){delete rt[y]}),2e3),null!=c)&&(v=10*~~at(e,n,o,s,i,r,a,l));for(var x=0;x<v+1;x++){if(b.data[c]>x?m=b.data[x*v]:(m=t.findDotsAtSegment(e,n,o,s,i,r,a,l,x/v),b.data[x]=m),x&&(g+=E(E(f.x-m.x,2)+E(f.y-m.y,2),.5)),null!=c&&g>=c)return m;f=m}if(null==c)return g},lt=function(e,n){return function(o,s,i){for(var r,a,l,c,d,p="",u={},h=0,f=0,m=(o=ge(o)).length;f<m;f++){if("M"==(l=o[f])[0])r=+l[1],a=+l[2];else{if(h+(c=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6]))>s){if(n&&!u.start){if(p+=["C",(d=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6],s-h)).start.x,d.start.y,d.m.x,d.m.y,d.x,d.y],i)return p;u.start=p,p=["M",d.x,d.y+"C",d.n.x,d.n.y,d.end.x,d.end.y,l[5],l[6]].join(),h+=c,r=+l[5],a=+l[6];continue}if(!e&&!n)return{x:(d=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6],s-h)).x,y:d.y,alpha:d.alpha}}h+=c,r=+l[5],a=+l[6]}p+=l}return u.end=p,(d=e?h:n?u:t.findDotsAtSegment(r,a,l[1],l[2],l[3],l[4],l[5],l[6],1)).alpha&&(d={x:d.x,y:d.y,alpha:d.alpha}),d}},ct=lt(1),dt=lt(),pt=lt(0,1);Re.getTotalLength=function(){if("path"==this.type)return this.node.getTotalLength?this.node.getTotalLength():ct(this.attrs.path)},Re.getPointAtLength=function(e){if("path"==this.type)return dt(this.attrs.path,e)},Re.getSubpath=function(e,t){if("path"==this.type){if(S(this.getTotalLength()-t)<"1e-6")return pt(this.attrs.path,e).end;var n=pt(this.attrs.path,t,1);return e?pt(n,e).end:n}},t.easing_formulas={linear:function(e){return e},"<":function(e){return E(e,3)},">":function(e){return E(e-1,3)+1},"<>":function(e){return(e*=2)<1?E(e,3)/2:(E(e-=2,3)+2)/2},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},elastic:function(e){if(0==e||1==e)return e;return E(2,-10*e)*w.sin(2*_*(e-.075)/.3)+1},bounce:function(e){var t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375}};var ut=[],ht=function(){for(var e=+new Date,n=0;n<ut[b];n++){var o=ut[n];if(!o.stop&&!o.el.removed){var s,i=e-o.start,r=o.ms,l=o.easing,c=o.from,d=o.diff,p=o.to,u=o.t,h=o.el,g={};if(i<r){var v=l(i/r);for(var y in c)if(c[a](y)){switch(U[y]){case"along":s=v*r*d[y],p.back&&(s=p.len-s);var x=dt(p[y],s);h.translate(d.sx-d.x||0,d.sy-d.y||0),d.x=x.x,d.y=x.y,h.translate(x.x-d.sx,x.y-d.sy),p.rot&&h.rotate(d.r+x.alpha,x.x,x.y);break;case T:s=+c[y]+v*r*d[y];break;case"colour":s="rgb("+[mt(L(c[y].r+v*r*d[y].r)),mt(L(c[y].g+v*r*d[y].g)),mt(L(c[y].b+v*r*d[y].b))].join(",")+")";break;case"path":s=[];for(var w=0,C=c[y][b];w<C;w++){s[w]=[c[y][w][0]];for(var k=1,S=c[y][w][b];k<S;k++)s[w][k]=+c[y][w][k]+v*r*d[y][w][k];s[w]=s[w].join(m)}s=s.join(m);break;case"csv":switch(y){case"translation":var E=v*r*d[y][0]-u.x,_=v*r*d[y][1]-u.y;u.x+=E,u.y+=_,s=E+m+_;break;case"rotation":s=+c[y][0]+v*r*d[y][0],c[y][1]&&(s+=","+c[y][1]+","+c[y][2]);break;case"scale":s=[+c[y][0]+v*r*d[y][0],+c[y][1]+v*r*d[y][1],2 in p[y]?p[y][2]:f,3 in p[y]?p[y][3]:f].join(m);break;case"clip-rect":for(s=[],w=4;w--;)s[w]=+c[y][w]+v*r*d[y][w]}break;default:var M=[].concat(c[y]);for(s=[],w=h.paper.customAttributes[y].length;w--;)s[w]=+M[w]+v*r*d[y][w]}g[y]=s}h.attr(g),h._run&&h._run.call(h)}else p.along&&(x=dt(p.along,p.len*!p.back),h.translate(d.sx-(d.x||0)+x.x-d.sx,d.sy-(d.y||0)+x.y-d.sy),p.rot&&h.rotate(d.r+x.alpha,x.x,x.y)),(u.x||u.y)&&h.translate(-u.x,-u.y),p.scale&&(p.scale+=f),h.attr(p),ut.splice(n--,1)}}t.svg&&h&&h.paper&&h.paper.safari(),ut[b]&&setTimeout(ht)},ft=function(e,n,o,s,i){var r=o-s;n.timeouts.push(setTimeout((function(){t.is(i,"function")&&i.call(n),n.animate(e,r,e.easing)}),s))},mt=function(e){return C(k(e,255),0)},gt=function(e,t){if(null==e)return{x:this._.tx,y:this._.ty,toString:it};switch(this._.tx+=+e,this._.ty+=+t,this.type){case"circle":case"ellipse":this.attr({cx:+e+this.attrs.cx,cy:+t+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+e+this.attrs.x,y:+t+this.attrs.y});break;case"path":var n=ce(this.attrs.path);n[0][1]+=+e,n[0][2]+=+t,this.attr({path:n})}return this};function vt(e){return function(n,o,s,i){var r={back:e};return t.is(s,"function")?i=s:r.rot=s,n&&n.constructor==Ae&&(n=n.attrs.path),n&&(r.along=n),this.animate(r,o,i)}}function yt(e,t,n,o,s,i){var r=3*t,a=3*(o-t)-r,l=1-r-a,c=3*n,d=3*(s-n)-c,p=1-c-d;function u(e){return((l*e+a)*e+r)*e}return function(e,t){var n=function(e,t){var n,o,s,i,c,d;for(s=e,d=0;d<8;d++){if(i=u(s)-e,S(i)<t)return s;if(S(c=(3*l*s+2*a)*s+r)<1e-6)break;s-=i/c}if(o=1,(s=e)<(n=0))return n;if(s>o)return o;for(;n<o;){if(i=u(s),S(i-e)<t)return s;e>i?n=s:o=s,s=(o-n)/2+n}return s}(e,t);return((p*n+d)*n+c)*n}(e,1/(200*i))}Re.animateWith=function(e,t,n,o,s){for(var i=0,r=ut.length;i<r;i++)ut[i].el.id==e.id&&(t.start=ut[i].start);return this.animate(t,n,o,s)},Re.animateAlong=vt(),Re.animateAlongBack=vt(1),Re.onAnimation=function(e){return this._run=e||0,this},Re.animate=function(e,n,s,i){var r=this;if(r.timeouts=r.timeouts||[],!t.is(s,"function")&&s||(i=s||null),r.removed)return i&&i.call(r),r;var l={},c={},d=!1,p={};for(var u in e)if(e[a](u)&&(U[a](u)||r.paper.customAttributes[a](u)))switch(d=!0,l[u]=r.attr(u),null==l[u]&&(l[u]=W[u]),c[u]=e[u],U[u]){case"along":var h=ct(e[u]),f=dt(e[u],h*!!e.back),m=r.getBBox();p[u]=h/n,p.tx=m.x,p.ty=m.y,p.sx=f.x,p.sy=f.y,c.rot=e.rot,c.back=e.back,c.len=h,e.rot&&(p.r=B(r.rotate())||0);break;case T:p[u]=(c[u]-l[u])/n;break;case"colour":l[u]=t.getRGB(l[u]);var v=t.getRGB(c[u]);p[u]={r:(v.r-l[u].r)/n,g:(v.g-l[u].g)/n,b:(v.b-l[u].b)/n};break;case"path":var y=ge(l[u],c[u]);l[u]=y[0];var x=y[1];p[u]=[];for(var w=0,C=l[u][b];w<C;w++){p[u][w]=[0];for(var k=1,S=l[u][w][b];k<S;k++)p[u][w][k]=(x[w][k]-l[u][w][k])/n}break;case"csv":var E=g(e[u]).split(o),_=g(l[u]).split(o);switch(u){case"translation":l[u]=[0,0],p[u]=[E[0]/n,E[1]/n];break;case"rotation":l[u]=_[1]==E[1]&&_[2]==E[2]?_:[0,E[1],E[2]],p[u]=[(E[0]-l[u][0])/n,0,0];break;case"scale":e[u]=E,l[u]=g(l[u]).split(o),p[u]=[(E[0]-l[u][0])/n,(E[1]-l[u][1])/n,0,0];break;case"clip-rect":for(l[u]=g(l[u]).split(o),p[u]=[],w=4;w--;)p[u][w]=(E[w]-l[u][w])/n}c[u]=E;break;default:for(E=[].concat(e[u]),_=[].concat(l[u]),p[u]=[],w=r.paper.customAttributes[u][b];w--;)p[u][w]=((E[w]||0)-(_[w]||0))/n}if(d){var M=t.easing_formulas[s];if(!M)if((M=g(s).match(D))&&5==M[b]){var I=M;M=function(e){return yt(e,+I[1],+I[2],+I[3],+I[4],n)}}else M=function(e){return e};ut.push({start:e.start||+new Date,ms:n,easing:M,from:l,diff:p,to:c,el:r,t:{x:0,y:0}}),t.is(i,"function")&&(r._ac=setTimeout((function(){i.call(r)}),n)),1==ut[b]&&setTimeout(ht)}else{var P,N=[];for(var A in e)e[a](A)&&V.test(A)&&(u={value:e[A]},"from"==A&&(A=0),"to"==A&&(A=100),u.key=z(A,10),N.push(u));for(N.sort(J),N[0].key&&N.unshift({key:0,value:r.attrs}),w=0,C=N[b];w<C;w++)ft(N[w].value,r,n/100*N[w].key,n/100*(N[w-1]&&N[w-1].key||0),N[w-1]&&N[w-1].value.callback);(P=N[N[b]-1].value.callback)&&r.timeouts.push(setTimeout((function(){P.call(r)}),n))}return this},Re.stop=function(){for(var e=0;e<ut.length;e++)ut[e].el.id==this.id&&ut.splice(e--,1);for(e=0,ii=this.timeouts&&this.timeouts.length;e<ii;e++)clearTimeout(this.timeouts[e]);return this.timeouts=[],clearTimeout(this._ac),delete this._ac,this},Re.translate=function(e,t){return this.attr({translation:e+" "+t})},Re.toString=function(){return"Raphaël’s object"},t.ae=ut;var bt=function(e){if(this.items=[],this[b]=0,this.type="set",e)for(var t=0,n=e[b];t<n;t++)!e[t]||e[t].constructor!=Ae&&e[t].constructor!=bt||(this[this.items[b]]=this.items[this.items[b]]=e[t],this[b]++)};for(var xt in bt[r][A]=function(){for(var e,t,n=0,o=arguments[b];n<o;n++)!(e=arguments[n])||e.constructor!=Ae&&e.constructor!=bt||(this[t=this.items[b]]=this.items[t]=e,this[b]++);return this},bt[r].pop=function(){return delete this[this[b]--],this.items.pop()},Re)Re[a](xt)&&(bt[r][xt]=function(e){return function(){for(var t=0,n=this.items[b];t<n;t++)this.items[t][e][u](this.items[t],arguments);return this}}(xt));bt[r].attr=function(e,n){if(e&&t.is(e,I)&&t.is(e[0],"object"))for(var o=0,s=e[b];o<s;o++)this.items[o].attr(e[o]);else for(var i=0,r=this.items[b];i<r;i++)this.items[i].attr(e,n);return this},bt[r].animate=function(e,n,o,s){(t.is(o,"function")||!o)&&(s=o||null);var i,r,a=this.items[b],l=a,c=this;for(s&&(r=function(){!--a&&s.call(c)}),o=t.is(o,M)?o:r,i=this.items[--l].animate(e,n,o,r);l--;)this.items[l]&&!this.items[l].removed&&this.items[l].animateWith(i,e,n,o,r);return this},bt[r].insertAfter=function(e){for(var t=this.items[b];t--;)this.items[t].insertAfter(e);return this},bt[r].getBBox=function(){for(var e=[],t=[],n=[],o=[],s=this.items[b];s--;){var i=this.items[s].getBBox();e[A](i.x),t[A](i.y),n[A](i.x+i.width),o[A](i.y+i.height)}return{x:e=k[u](0,e),y:t=k[u](0,t),width:C[u](0,n)-e,height:C[u](0,o)-t}},bt[r].clone=function(e){e=new bt;for(var t=0,n=this.items[b];t<n;t++)e[A](this.items[t].clone());return e},t.registerFont=function(e){if(!e.face)return e;this.fonts=this.fonts||{};var t={w:e.w,face:{},glyphs:{}},n=e.face["font-family"];for(var o in e.face)e.face[a](o)&&(t.face[o]=e.face[o]);if(this.fonts[n]?this.fonts[n][A](t):this.fonts[n]=[t],!e.svg)for(var s in t.face["units-per-em"]=z(e.face["units-per-em"],10),e.glyphs)if(e.glyphs[a](s)){var i=e.glyphs[s];if(t.glyphs[s]={w:i.w,k:{},d:i.d&&"M"+i.d[G](/[mlcxtrv]/g,(function(e){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[e]||"M"}))+"z"},i.k)for(var r in i.k)i[a](r)&&(t.glyphs[s].k[r]=i.k[r])}return e},n.getFont=function(e,n,o,s){if(s=s||"normal",o=o||"normal",n=+n||{normal:400,bold:700,lighter:300,bolder:800}[n]||400,t.fonts){var i,r=t.fonts[e];if(!r){var l=new RegExp("(^|\\s)"+e[G](/[^\w\d\s+!~.:_-]/g,f)+"(\\s|$)","i");for(var c in t.fonts)if(t.fonts[a](c)&&l.test(c)){r=t.fonts[c];break}}if(r)for(var d=0,p=r[b];d<p&&((i=r[d]).face["font-weight"]!=n||i.face["font-style"]!=o&&i.face["font-style"]||i.face["font-stretch"]!=s);d++);return i}},n.print=function(e,n,s,i,r,a,l){a=a||"middle",l=C(k(l||0,1),-1);var c,d=this.set(),p=g(s).split(f),u=0;if(t.is(i,s)&&(i=this.getFont(i)),i){c=(r||16)/i.face["units-per-em"];for(var h=i.face.bbox.split(o),m=+h[0],v=+h[1]+("baseline"==a?h[3]-h[1]+ +i.face.descent:(h[3]-h[1])/2),y=0,x=p[b];y<x;y++){var w=y&&i.glyphs[p[y-1]]||{},S=i.glyphs[p[y]];u+=y?(w.w||i.w)+(w.k&&w.k[p[y]]||0)+i.w*l:0,S&&S.d&&d[A](this.path(S.d).attr({fill:"#000",stroke:"none",translation:[u,0]}))}d.scale(c,c,m,v).translate(e-m,n-v)}return d},t.format=function(e,n){var o=t.is(n,I)?[0].concat(n):arguments;return e&&t.is(e,M)&&o[b]-1&&(e=e[G](i,(function(e,t){return null==o[++t]?f:o[t]}))),e||f},t.ninja=function(){return d.was?c.Raphael=d.is:Raphael=void 0,t},t.el=Re,t.st=bt[r],yn.exports=t}();const bn={BLUE:"#6495ED",ORANGE:"#FFA500",PINK:"#FF00AF",GREEN:"#28AE7B",PURPLE:"#9D38BD",RED:"#DF0030",GRAY:"gray",BLACK:"black",LIGHT_BLUE:"#9AB8ED",LIGHT_ORANGE:"#EDD19B",LIGHT_PINK:"#ED9BD3",LIGHT_GREEN:"#9BEDCE",LIGHT_PURPLE:"#DA9BED",LIGHT_RED:"#ED9AAC",LIGHT_GRAY:"#ED9B9B",LIGHT_BLACK:"#ED9B9B",GRAY10:"#D6D6D6",GRAY20:"#CDCDCD",GRAY30:"#B3B3B3",GRAY40:"#9A9A9A",GRAY50:"#808080",GRAY60:"#666666",GRAY70:"#4D4D4D",GRAY80:"#333333",GRAY90:"#1A1A1A",BLUE_A:"#CCFAFF",BLUE_B:"#80F6FF",BLUE_C:"#63D9EA",BLUE_D:"#11ACCD",BLUE_E:"#0C7F99",TEAL_A:"#94FFF5",TEAL_B:"#26EDD5",TEAL_C:"#01D1C1",TEAL_D:"#01A995",TEAL_E:"#208170",GREEN_A:"#B6FFB0",GREEN_B:"#8AF281",GREEN_C:"#74CF70",GREEN_D:"#1FAB54",GREEN_E:"#0D923F",GOLD_A:"#FFD0A9",GOLD_B:"#FFBB71",GOLD_C:"#FF9C39",GOLD_D:"#E07D10",GOLD_E:"#A75A05",RED_A:"#FCA9A9",RED_B:"#FF8482",RED_C:"#F9685D",RED_D:"#E84D39",RED_E:"#BC2612",MAROON_A:"#FFBDE0",MAROON_B:"#FF92C6",MAROON_C:"#ED5FA6",MAROON_D:"#CA337C",MAROON_E:"#9E034E",PURPLE_A:"#DDD7FF",PURPLE_B:"#C6B9FC",PURPLE_C:"#AA87FF",PURPLE_D:"#7854AB",PURPLE_E:"#543B78",MINT_A:"#F5F9E8",MINT_B:"#EDF2DF",MINT_C:"#E0E5CC",GRAY_A:"#F6F7F7",GRAY_B:"#F0F1F2",GRAY_C:"#E3E5E6",GRAY_D:"#D6D8DA",GRAY_E:"#BABEC2",GRAY_F:"#888D93",GRAY_G:"#626569",GRAY_H:"#3B3E40",GRAY_I:"#21242C",KA_BLUE:"#314453",KA_GREEN:"#71B307",_BACKGROUND:"#FDFDFD",INTERACTING:"#71B307",INTERACTIVE:"#71B307",DYNAMIC:"#6495ED"};function xn(e,t){const n=P.default(e).find("."+t);return 0===n.length?P.default("<span>").addClass(t).appendTo(P.default(e)):n}function wn(e,t){let n=0;!function o(){e.scrollHeight>18||n>=10?t():(n++,setTimeout(o,100))}()}var Cn={processMath:async function(e,t,n,o){const s=P.default(e);if(null==s.attr("data-math-formula")||n){const n=xn(s,"katex-holder"),i=xn(s,"mathjax-holder"),r=i.find("script[type='math/tex']")[0];null==t&&(s.attr("data-math-formula")?t=s.attr("data-math-formula"):r&&(t=r.text||r.textContent)),t=null!=t?t+"":"",t=Ce.cleanMath(t),s.attr("data-math-formula",t);const a=await Y().getKaTeX();try{if(a.render(t,n[0],{colorIsTextColor:!0}),"mathjax"===s.attr("data-math-type")&&"undefined"!=typeof MathJax){const e=MathJax.Hub.getJaxFor(r);if(e){const t=e.SourceElement();t.previousSibling&&t.previousSibling.className&&e.Remove()}}return s.attr("data-math-type","katex"),void(o&&wn(e,o))}catch(e){if(Y().logKaTeXError(t,e),e instanceof a.ParseError)throw e}s.attr("data-math-type","mathjax"),r?"text"in r?r.text=t:r.textContent=t:i.append("<script type='math/tex'>"+t.replace(/<\//g,"< /")+"<\/script>"),"undefined"!=typeof MathJax&&(MathJax.Hub.Queue(["Reprocess",MathJax.Hub,i[0]]),o&&MathJax.Hub.Queue((function(){const t=MathJax.Callback((function(){}));return wn(e,(function(){o(),t()})),t})))}},cleanupMath:function(e){const t=P.default(e);if(t.attr("data-math-formula")){if("undefined"!=typeof MathJax){const e=MathJax.Hub.getJaxFor(t.find("script")[0]);if(e){const t=e.SourceElement();t.previousSibling&&t.previousSibling.className&&e.Remove()}}t.text(t.attr("data-math-formula")),t.attr("data-math-formula",null),t.attr("data-math-type",null)}return e},retrieveMathFormula:function(e){return P.default(e).attr("data-math-formula")}};const{processMath:kn}=Cn;function Sn(e,t){return"number"==typeof e&&(e=[e,e]),t=t*Math.PI/180,[e[0]*Math.cos(t),e[1]*Math.sin(t)]}const En={unscaledSvgPath:function(e){return!0===e[0]?"":P.default.map(e,(function(e,t){return!0===e?"z":(0===t?"M":"L")+e[0]+" "+e[1]})).join("")},getDistance:function(e,t){return p.point.distanceToPoint(e,t)},coordDiff:function(e,t){return M.default.map(t,(function(n,o){return t[o]-e[o]}))},snapCoord:function(e,t){return M.default.map(e,(function(e,n){return Ce.roundToNearest(t[n],e)}))},findAngle:function(e,t,n){if(void 0===n){const n=e[0]-t[0],o=e[1]-t[1];return n||o?(180+180*Math.atan2(-o,-n)/Math.PI+360)%360:0}return En.findAngle(e,n)-En.findAngle(t,n)},graphs:{}},_n=En.Graphie=function(){};M.default.extend(_n.prototype,{cartToPolar:function(e,t){const n=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2));let o=Math.atan2(e[1],e[0]);return o<0&&(o+=2*Math.PI),t||(o=180*o/Math.PI),[n,o]},polar:Sn});const Tn={center:[-.5,-.5],above:[-.5,-1],"above right":[0,-1],right:[0,-.5],"below right":[0,0],below:[-.5,0],"below left":[-1,0],left:[-1,-.5],"above left":[-1,-1]},Mn={"stroke-width":null};En.createGraphie=function(e){let t,n,o=40,s=40;P.default(e).css("position","relative");const i=yn.exports(e);P.default(e).children("div").css("position","absolute");let r={"stroke-width":2,fill:"none"};const a=function(e){if("number"==typeof e)return a([e,e]);const t=e[0],n=e[1];return[t*o,n*s]},l=function e(i){if("number"==typeof i)return e([i,i]);const r=i[0],a=i[1];return[(r-t[0])*o,(n[1]-a)*s]},c=function(e){if("number"==typeof e)return c([e,e]);const i=e[0],r=e[1];return[i/o+t[0],n[1]-r/s]},d=function(e){return"number"==typeof e?d([e,e]):[e[0]/o,e[1]/s]},u=function(e,t){const n=P.default(e),o=n.data("labelDirection");let[s,i]=t;if(0===s&&0===i&&([s,i]=[1,1],xe.log("Label size was 0x0 in graphie.js; using 1x1 instead")),n.css("visibility",""),"number"==typeof o){const e=Math.cos(o),t=Math.sin(o),r=Math.min(s/2/Math.abs(e),i/2/Math.abs(t));n.css({marginLeft:-s/2+e*r,marginTop:-i/2-t*r})}else{const e=Tn[o||"center"];n.css({marginLeft:Math.round(s*e[0]),marginTop:Math.round(i*e[1])})}},h=function(e,t){return P.default.map(e,(function(e,n){if(!0===e)return"z";const o=t?e:l(e);return(0===n?"M":"L")+Ce.bound(o[0])+" "+Ce.bound(o[1])})).join("")},f=function(e,n,o){const s=function(t){return(e*t+n)*t+o};if(0===e){const e=M.default.map(t,(function(e){return[e,s(e)]}));return h(e)}const i=-n/(2*e),r=i+Math.max(Math.abs(i-t[0]),Math.abs(i-t[1])),a=[i,s(i)],c=[r,s(r)],d=[a[0],a[1]-(c[1]-a[1])],p=Math.abs(a[0]-c[0]),u=[a[0]-p,c[1]],f=[a[0]+p,c[1]],m=M.default.map([u,d,f],l),g=M.default.map(M.default.flatten(m),Ce.bound);return"M"+g[0]+","+g[1]+" Q"+g[2]+","+g[3]+" "+g[4]+","+g[5]},m=function(e,n,o,s){const i=Math.abs(Math.PI/(2*n)),r=function(t){return e*Math.sin(n*t-o)+s},a=function(t){return e*n*Math.cos(o-n*t)},c=function(e,t){const n=e+i*t,o=n+i,s=[n,2*n/3+1*o/3,1*n/3+2*o/3,o],c=[r(n),r(n)+a(n)*(o-n)/3,r(o)-a(o)*(o-n)/3,r(o)];return M.default.map(M.default.zip(s,c),l)},d=t[1]-t[0],p=Math.ceil(d/i)+1;let u=o/n;const h=u-t[0];u-=i*Math.ceil(h/i);let f=c(u,0),m="M"+f[0][0]+","+f[0][1]+" C"+f[1][0]+","+f[1][1]+" "+f[2][0]+","+f[2][1]+" "+f[3][0]+","+f[3][1];for(let e=1;e<p;e++)f=c(u,e),m+=" C"+f[1][0]+","+f[1][1]+" "+f[2][0]+","+f[2][1]+" "+f[3][0]+","+f[3][1];return m};En.svgPath=h;const g=function(e){const r={scale:function(e){"number"==typeof e&&(e=[e,e]),o=e[0],s=e[1],i.setSize((t[1]-t[0])*o,(n[1]-n[0])*s)},clipRect:function(e){const t=e[0],n=e[1];return t[1]+=n[1],{"clip-rect":l(t).concat(a(n)).join(" ")}},strokeWidth:function(e){return{"stroke-width":parseFloat(e)}},rx:function(e){return{rx:a([e,0])[0]}},ry:function(e){return{ry:a([0,e])[1]}},r:function(e){const t=a([e,e]);return{rx:t[0],ry:t[1]}}},c={};return P.default.each(e||{},(function(e,t){const n=r[e];if("function"==typeof n)P.default.extend(c,n(t));else{const n=e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase();c[n]=t}})),c},v=function e(t){const n=t.constructor.prototype;if(n===yn.exports.el){if("path"===t.type&&void 0===t.arrowheadsDrawn){const e=.6+.4*t.attr("stroke-width"),n=t.getTotalLength(),o=i.set(),s=i.path(b.isMobile?"M-4,4 C-4,4 -0.25,0 -0.25,0 C-0.25,0 -4,-4 -4,-4":"M-3 4 C-2.75 2.5 0 0.25 0.75 0C0 -0.25 -2.75 -2.5 -3 -4"),r=t.getPointAtLength(n-.4),a=t.getPointAtLength(n-.75*e),l=180*Math.atan2(r.y-a.y,r.x-a.x)/Math.PI,c=t.attr();delete c.path;let d=t.getSubpath(0,n-.75*e);return d=i.path(d).attr(c),d.arrowheadsDrawn=!0,t.remove(),s.rotate(l,b.isMobile?1e-5:.75,0).scale(e,e,.75,0).translate(a.x,a.y).attr(c).attr({"stroke-linejoin":"round","stroke-linecap":"round"}),s.arrowheadsDrawn=!0,o.push(d),o.push(s),o}}else if(n===yn.exports.st)for(let n=0,o=t.items.length;n<o;n++)e(t.items[n]);return t},y={circle:function(e,t){return i.ellipse(...l(e).concat(a([t,t])))},rect:function(e,t,n,o){const s=l([e,t+o]),r=a([n,o]),c=i.rect(...s.concat(r));return b.isMobile&&(c.node.style.shapeRendering="crispEdges"),c},ellipse:function(e,t){return i.ellipse(...l(e).concat(a(t)))},fixedEllipse:function(e,t,n,o){const s=l(e),i=a(t),r=2*i[0]*n+o,c=2*i[1]*n+o,d=s[0]-r/2,p=s[1]-c/2,u=document.createElement("div");P.default(u).css({position:"absolute",width:r+"px",height:c+"px",left:d+"px",top:p+"px"});return{wrapper:u,visibleShape:yn.exports(u,r,c).ellipse(r/2,c/2,i[0],i[1])}},arc:function(e,t,n,o,s){n=(n%360+360)%360,o=(o%360+360)%360;const r=l(e),c=a(t),d=Sn(t,n),p=Sn(t,o),u=l([e[0]+d[0],e[1]+d[1]]),h=l([e[0]+p[0],e[1]+p[1]]),f=((o-n)%360+360)%360>180;return i.path("M"+u.join(" ")+"A"+c.join(" ")+" 0 "+(f?1:0)+" 0 "+h.join(" ")+(s?"L"+r.join(" ")+"z":""))},path:function(e){const t=i.path(h(e));return t.graphiePath=e,t},fixedPath:function(e,t,n){e=M.default.map(e,l),t=t?l(t):null,n=n||h;const o=M.default.min(M.default.pluck(e,0)),s=M.default.max(M.default.pluck(e,0)),i=M.default.min(M.default.pluck(e,1)),r=M.default.max(M.default.pluck(e,1)),a=[4,4],c=[o,i];e=M.default.map(e,(function(e){return p.vector.add(p.vector.subtract(e,c),p.vector.scale(a,.5))}));const d=s-o+a[0],u=r-i+a[1],f=c[0]-a[0]/2,m=c[1]-a[1]/2,g=document.createElement("div");P.default(g).css({position:"absolute",width:d+"px",height:u+"px",left:f+"px",top:m+"px",transformOrigin:t?d/2+t[0]+"px "+(u/2+t[1])+"px":null});return{wrapper:g,visibleShape:yn.exports(g,d,u).path(n(e))}},scaledPath:function(e){const t=i.path(h(e,!0));return t.graphiePath=e,t},line:function(e,t){const n=this.path([e,t]);return b.isMobile&&(n.node.style.shapeRendering="crispEdges"),n},parabola:function(e,t,n){return i.path(f(e,t,n))},fixedLine:function(e,t,n){const o=[n,n];e=l(e),t=l(t);const s=[Math.min(e[0],t[0]),Math.min(e[1],t[1])];e=p.vector.add(p.vector.subtract(e,s),p.vector.scale(o,.5)),t=p.vector.add(p.vector.subtract(t,s),p.vector.scale(o,.5));const i=s[0]-o[0]/2,r=s[1]-o[1]/2,a=Math.abs(e[0]-t[0])+o[0],c=Math.abs(e[1]-t[1])+o[1],d=document.createElement("div");P.default(d).css({position:"absolute",width:a+"px",height:c+"px",left:i+"px",top:r+"px",transformOrigin:e[0]+"px "+e[1]+"px"});const u=yn.exports(d,a,c),h="M"+e[0]+" "+e[1]+" L"+t[0]+" "+t[1],f=u.path(h);return f.graphiePath=[e,t],{wrapper:d,visibleShape:f}},sinusoid:function(e,t,n,o){return i.path(m(e,t,n,o))},grid:function(e,t){const n=r.step||[1,1],o=i.set();let s=n[0]*Math.ceil(e[0]/n[0]);for(;s<=e[1];s+=n[0])o.push(this.line([s,t[0]],[s,t[1]]));let a=n[1]*Math.ceil(t[0]/n[1]);for(;a<=t[1];a+=n[1])o.push(this.line([e[0],a],[e[1],a]));return o},label:function(t,n,o,s){s=void 0===s||s;const i=P.default("<span>").addClass("graphie-label"),a=r["label-distance"];i.css(P.default.extend({},{position:"absolute",padding:(null!=a?a:7)+"px",color:"black"})).data("labelDirection",o).appendTo(e),i.setPosition=function(e){const t=l(e);i.css({left:t[0],top:t[1]})},i.setPosition(t);const c=i[0];return i.processMath=function(e,t){kn(c,e,t,(function(){const e=c.scrollWidth,t=c.scrollHeight;u(c,[e,t])}))},i.processText=function(e){i.html(e);const t=c.scrollWidth,n=c.scrollHeight;u(c,[t,n])},s?i.processMath(n,!1):i.processText(n),i},plotParametric:function(e,t,n,o){o=o||function(e){return[e,0]};const a=e=>Math.abs(e[1])>5e5?[e[0],Math.min(Math.max(e[1],-5e5),5e5)]:e,l=t=>a(e(t)),c=e=>a(o(e));r.strokeLinejoin||(r.strokeLinejoin="round"),r.strokeLinecap||(r.strokeLinecap="round");const d=t[0],p=t[1];let u=(p-d)/(r["plot-points"]||800);0===u&&(u=1);const h=i.set();let f=[],m=En.coordDiff(l(d),c(d)),g=d;for(let e=d;e<=p;e+=u){const t=l(e),o=c(e),i=En.coordDiff(t,o);if(i[1]<0!=m[1]<0&&Math.abs(i[1]-m[1])>2*s||isNaN(i[1])){if(n){f.push(t);for(let t=e-u;t>=g;t-=u)f.push(c(t));g=e}h.push(this.path(f)),f=[],n&&f.push(t)}else f.push(t);m=i}if(n)for(let e=p-u;e>=g;e-=u)f.push(c(e));return h.push(this.path(f)),h},plotPolar:function(e,t){const n=t[0],s=t[1];return r["plot-points"]||(r["plot-points"]=2*(s-n)*o),this.plotParametric((function(t){return Sn(e(t),180*t/Math.PI)}),t)},plot:function(e,t,n,s,i){const a=t[0],l=t[1];if(r["plot-points"]||(r["plot-points"]=2*(l-a)*o),n){if(i)throw new we("Can't shade area between functions with swapped axes.",be.Internal);return this.plotParametric((function(t){return[e(t),t]}),t,s)}if(i){if(s)return this.plotParametric((function(t){return[t,e(t)]}),t,s,(function(e){return[e,i(e)]}));throw new we("fn2 should only be set when 'shade' is True.",be.Internal)}return this.plotParametric((function(t){return[t,e(t)]}),t,s)},plotPiecewise:function(e,t){const n=i.set(),o=this;return M.default.times(e.length,(function(s){const i=e[s],r=t[s],a=o.plotParametric((function(e){return[e,i(e)]}),r);M.default.each(a,(function(e){n.push(e)}))})),n},plotEndpointCircles:function(e){const t=i.set(),n=this;return M.default.each(e,(function(e,o){t.push(n.circle(e,.15))})),t},plotAsymptotes:function(e,t){const n=t[0],o=t[1],a=(o-n)/(r["plot-points"]||800),l=i.set();let c=e(n);for(let t=n;t<=o;t+=a){const n=e(t);n<0!=c<0&&Math.abs(n-c)>2*s&&l.push(this.line([t,s],[t,-s])),c=n}return l}},b=new _n;return M.default.extend(b,{raphael:i,init:function(r){let a=r.scale||[40,40];if(a="number"==typeof a?[a,a]:a,o=a[0],s=a[1],null==r.range)throw new we("range should be specified in graph init",be.Internal);t=r.range[0],n=r.range[1];const l=(t[1]-t[0])*o,c=(n[1]-n[0])*s;return i.setSize(l,c),P.default(e).css({width:l,height:c}),this.range=r.range,this.scale=a,this.dimensions=[l,c],this.xpixels=l,this.ypixels=c,this.isMobile=r.isMobile,this},style:function(e,t){const n=g(e);if("function"==typeof t){const e=r;r=P.default.extend({},r,n);const o=t.call(b);return r=e,o}P.default.extend(r,n)},scalePoint:l,scaleVector:a,unscalePoint:c,unscaleVector:d,svgPath:h,svgParabolaPath:f,svgSinusoidPath:m}),P.default.each(y,(function(e){b[e]=function(){const t=arguments[arguments.length-1],n=r;let o;if("object"!=typeof t||M.default.isArray(t))r=P.default.extend({},r),o=y[e](...arguments);else{r={...r,...g(t)};const n=[].slice.call(arguments,0,arguments.length-1);o=y[e](...n)}const s=o.constructor.prototype;return s===yn.exports.el||s===yn.exports.st?(o.attr(r),r.arrows&&(o=v(o))):o instanceof P.default&&o.css({...r,...Mn}),r=n,o}})),b.graphInit=function(e){e=e||{},P.default.each(e,(function(t,n){t.match(/.*Opacity$/)||"range"===t||"number"!=typeof n||(e[t]=[n,n]),"range"!==t&&"gridRange"!==t||(n.constructor===Array?n[0].constructor!==Array&&(e[t]=[[-n[0],n[0]],[-n[1],n[1]]]):"number"==typeof n&&(e[t]=[[-n,n],[-n,n]]))}));const t=e.range||[[-10,10],[-10,10]],n=e.gridRange||e.range,o=e.scale||[20,20],s=null==e.grid||e.grid,i=e.gridOpacity||.1,r=e.gridStep||[1,1],a=null==e.axes||e.axes,l=e.axisArrows||"",c=e.axisOpacity||1,d=e.axisCenter||[Math.min(Math.max(t[0][0],0),t[0][1]),Math.min(Math.max(t[1][0],0),t[1][1])],p=null!=e.axisLabels&&e.axisLabels,u=null==e.ticks||e.ticks,h=e.tickStep||[2,2],f=e.tickLen||[5,5],m=e.tickOpacity||1,g=e.labels||e.labelStep||!1,v=e.labelStep||[1,1],y=e.labelOpacity||1;let b=e.unityLabels||!1;const x=e.labelFormat||function(e){return e};let w=e.xLabelFormat||x,C=e.yLabelFormat||x;const k=null==e.smartLabelPositioning||e.smartLabelPositioning,S=[[t[0][0]-(t[0][0]>0?1:0),t[0][1]+(t[0][1]<0?1:0)],[t[1][0]-(t[1][0]>0?1:0),t[1][1]+(t[1][1]<0?1:0)]];if(M.default.isArray(b)||(b=[b,b]),k){const e=function(e){return function(t){return(e(t)+"").replace(/-(\d)/g,"\\llap{-}$1")}};w=e(w),C=e(C)}if(this.init({range:S,scale:o,isMobile:e.isMobile}),s&&this.grid(n[0],n[1],{stroke:e.isMobile?bn.GRAY_C:"#000000",opacity:e.isMobile?1:i,step:r,strokeWidth:e.isMobile?1:2}),a&&("<->"===l||!0===l?this.style({stroke:e.isMobile?bn.GRAY_G:"#000000",opacity:e.isMobile?1:c,strokeWidth:e.isMobile?1:2,arrows:"->"},(function(){t[1][0]<0&&t[1][1]>0&&(this.path([d,[n[0][0],d[1]]]),this.path([d,[n[0][1],d[1]]])),t[0][0]<0&&t[0][1]>0&&(this.path([d,[d[0],n[1][0]]]),this.path([d,[d[0],n[1][1]]]))})):"->"!==l&&""!==l||this.style({stroke:"#000000",opacity:c,strokeWidth:2,arrows:l},(function(){this.path([[n[0][0],d[1]],[n[0][1],d[1]]]),this.path([[d[0],n[1][0]],[d[0],n[1][1]]])})),p&&2===p.length&&(this.label([n[0][1],d[1]],p[0],"right"),this.label([d[0],n[1][1]],p[1],"above"))),u){const s=e.isMobile;this.style({stroke:e.isMobile?bn.GRAY_G:"#000000",opacity:e.isMobile?1:m,strokeWidth:1},(function(){let e=r[0]*h[0],i=f[0]/o[1],a=n[0][0],c=n[0][1];if(t[1][0]<0&&t[1][1]>0){for(let t=e+d[0];t<=c;t+=e)(t<c||!l)&&this.line([t,-i+d[1]],[t,s?0:i+d[1]]);for(let t=-e+d[0];t>=a;t-=e)(t>a||!l)&&this.line([t,-i+d[1]],[t,s?0:i+d[1]])}if(e=r[1]*h[1],i=f[1]/o[0],a=n[1][0],c=n[1][1],t[0][0]<0&&t[0][1]>0){for(let t=e+d[1];t<=c;t+=e)(t<c||!l)&&this.line([-i+d[0],t],[s?0:i+d[0],t]);for(let t=-e+d[1];t>=a;t-=e)(t>a||!l)&&this.line([-i+d[0],t],[s?0:i+d[0],t])}}))}g&&this.style({stroke:e.isMobile?bn.GRAY_G:"#000000",opacity:e.isMobile?1:y},(function(){let e=r[0]*h[0]*v[0],t=n[0][0],o=n[0][1];const s=d[0]<0?"above":"below",i=d[0]<0?"right":"left",a=0===d[0]&&0!==d[1],c=0!==d[0]&&0===d[1],p=0!==d[0]||0!==d[1],u=b[0]||p,f=b[1]||p;for(let t=(a?0:e)+d[0];t<=o;t+=e)(t<o||!l)&&this.label([t,d[1]],w(t),s);for(let n=-e*(u?1:2)+d[0];n>=t;n-=e)(n>t||!l)&&this.label([n,d[1]],w(n),s);e=r[1]*h[1]*v[1],t=n[1][0],o=n[1][1];for(let t=(c?0:e)+d[1];t<=o;t+=e)(t<o||!l)&&this.label([d[0],t],C(t),i);for(let n=-e*(f?1:2)+d[1];n>=t;n-=e)(n>t||!l)&&this.label([d[0],n],C(n),i)}))},b},function(e,t,n,o){if(void 0!==e){var s="virtualMouseBindings",i="virtualTouchID",r="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),a="clientX clientY pageX pageY screenX screenY".split(" "),l=e.event.mouseHooks?e.event.mouseHooks.props:[],c=e.event.props.concat(l),d={},p=0,u=0,h=0,f=!1,m=[],g=!1,v=!1,y="addEventListener"in n,b=e(n),x=1,w=0;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var C=0;C<r.length;C++)e.event.special[r[C]]=L(r[C]);y&&n.addEventListener("click",(function(t){var n,o,s,r,a,l=m.length,c=t.target;if(l)for(n=t.clientX,o=t.clientY,threshold=e.vmouse.clickDistanceThreshold,s=c;s;){for(r=0;r<l;r++)if(a=m[r],s===c&&Math.abs(a.x-n)<threshold&&Math.abs(a.y-o)<threshold||e.data(s,i)===a.touchID)return t.preventDefault(),void t.stopPropagation();s=s.parentNode}}),!0)}function k(e){for(;e&&void 0!==e.originalEvent;)e=e.originalEvent;return e}function S(t){for(var n,o,i={};t;){for(o in n=e.data(t,s))n[o]&&(i[o]=i.hasVirtualBinding=!0);t=t.parentNode}return i}function E(){v=!0}function _(){v=!1}function T(){M(),p=setTimeout((function(){p=0,w=0,m.length=0,g=!1,E()}),e.vmouse.resetTimerDuration)}function M(){p&&(clearTimeout(p),p=0)}function I(t,n,o){var i;return(o&&o[t]||!o&&function(t,n){for(var o;t;){if((o=e.data(t,s))&&(!n||o[n]))return t;t=t.parentNode}return null}(n.target,t))&&(i=function(t,n){var o,s,i,r,l,d,p,u,h,f=t.type;if((t=e.Event(t)).type=n,o=t.originalEvent,s=e.event.props,f.search(/mouse/)>-1&&(s=c),o)for(p=s.length;p;)t[r=s[--p]]=o[r];if(f.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),-1!==f.search(/^touch/)&&(f=(i=k(o)).touches,l=i.changedTouches,d=f&&f.length?f[0]:l&&l.length?l[0]:void 0))for(u=0,h=a.length;u<h;u++)t[r=a[u]]=d[r];return t}(n,t),e(n.target).trigger(i)),i}function P(t){var n=e.data(t.target,i);if(!(g||w&&w===n)){var o=I("v"+t.type,t);o&&(o.isDefaultPrevented()&&t.preventDefault(),o.isPropagationStopped()&&t.stopPropagation(),o.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function N(t){var n,o,s=k(t).touches;if(s&&1===s.length&&(o=S(n=t.target)).hasVirtualBinding){w=x++,e.data(n,i,w),M(),_(),f=!1;var r=k(t).touches[0];u=r.pageX,h=r.pageY,I("vmouseover",t,o),I("vmousedown",t,o)}}function A(e){v||(f||I("vmousecancel",e,S(e.target)),f=!0,T())}function R(t){if(!v){var n=k(t).touches[0],o=i,s=e.vmouse.moveDistanceThreshold,i=i||Math.abs(n.pageX-u)>s||Math.abs(n.pageY-h)>s,r=S(t.target);i&&!o&&I("vmousecancel",t,r),I("vmousemove",t,r),T()}}function F(e){if(!v){E();var t,n=S(e.target);if(I("vmouseup",e,n),!f){var o=I("vclick",e,n);o&&o.isDefaultPrevented()&&(t=k(e).changedTouches[0],m.push({touchID:w,x:t.clientX,y:t.clientY}),g=!0)}I("vmouseout",e,n),f=!1,T()}}function O(t){var n,o=e.data(t,s);if(o)for(n in o)if(o[n])return!0;return!1}function D(){}function L(t){var n=t.substr(1);return{setup:function(o,i){O(this)||e.data(this,s,{}),e.data(this,s)[t]=!0,d[t]=(d[t]||0)+1,1===d[t]&&b.bind(n,P),e(this).bind(n,D),y&&(d.touchstart=(d.touchstart||0)+1,1===d.touchstart&&b.bind("touchstart",N).bind("touchend",F).bind("touchmove",R).bind("scroll",A))},teardown:function(o,i){--d[t],d[t]||b.unbind(n,P),y&&(--d.touchstart,d.touchstart||b.unbind("touchstart",N).unbind("touchmove",R).unbind("touchend",F).unbind("scroll",A));var r=e(this),a=e.data(this,s);a&&(a[t]=!1),r.unbind(n,D),O(this)||r.removeData(s)}}}}(window.jQuery,window,document);var In={pluck:function(e,t){return M.default.object(M.default.map(e,(function(e,n){return[n,e[t]]})))},mapObject:function(e,t){const n={};return M.default.each(M.default.keys(e),(function(o){n[o]=t(e[o],o)})),n},mapObjectFromArray:function(e,t){const n={};return M.default.each(e,(function(e){n[e]=t(e)})),n}};const Pn=M.default.extend({transform:function(e){const t=mn.getPrefixedTransform();this.wrapper.style[t]=e},toFront:function(){const e=this.wrapper.parentNode;e&&e.appendChild(this.wrapper)},toBack:function(){const e=this.wrapper.parentNode;e.firstChild!==this.wrapper&&e.insertBefore(this.wrapper,e.firstChild)},remove:function(){this.visibleShape.remove(),P.default(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){const t=p.vector.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=mn.getCanUse3dTransform(),o="translateX("+t[0]+"px) translateY("+t[1]+"px)"+(n?" translateZ(0)":"");this.transform(o)},hide:function(){this.visibleShape.hide()},show:function(){this.visibleShape.show()}},In.mapObjectFromArray(["attr","animate"],(function(e){return function(){this.visibleShape[e](...arguments)}}))),Nn={maxScale:1,mouselayer:!1,shadow:!1,disableMouseEventsOnWrapper:!1},An=function(e,t,n,o){o=M.default.extend({},Nn,o);const s=e.fixedEllipse(t,n,o.maxScale,o.padding);if(M.default.extend(this,s,{graphie:e,initialPoint:t}),o.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",o.interactiveKindForTesting),o.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),o.shadow){const e="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))",t=this.wrapper;t.style.webkitFilter=e,t.style.filter=e,this.moveTo=function(e){const t=p.vector.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=mn.getCanUse3dTransform(),o="translateX("+Math.round(t[0])+"px) translateY("+Math.round(t[1])+"px)"+(n?" translateZ(0)":"");this.transform(o)}}o.disableMouseEventsOnWrapper&&(this.wrapper.style.pointerEvents="none",this.visibleShape.node.style.pointerEvents="auto")};M.default.extend(An.prototype,Pn);const Rn={thickness:2,mouselayer:!1},Fn=function(e,t,n,o){o=M.default.extend({},Rn,o);const s=[e.range[0][0],0],i=[e.range[0][1],0];M.default.extend(this,e.fixedLine(s,i,o.thickness)),o.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",o.interactiveKindForTesting),this.visibleShape.attr(o.normalStyle),M.default.extend(this,{graphie:e,initialPoint:e.scalePoint(s),initialLength:p.point.distanceToPoint(e.scalePoint(s),e.scalePoint(i))}),o.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,n)};M.default.extend(Fn.prototype,Pn,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){const n=this.graphie.scalePoint(e),o=this.graphie.scalePoint(t),s=p.vector.polarDegFromCart(p.vector.subtract(o,n)),i=s[0],r=Ce.bound(s[1]),a=p.vector.subtract(n,this.initialPoint),l=Ce.bound(i/this.initialLength),c=mn.getCanUse3dTransform(),d="translateX("+a[0]+"px) translateY("+a[1]+"px) "+(c?" translateZ(0)":"")+"rotate("+r+"deg) scaleX("+l+") scaleY(1)";this.transform(d)}});const On={center:null,createPath:null,mouselayer:!1},Dn=function(e,t,n){n=M.default.extend({},On,n),M.default.extend(this,e.fixedPath(t,n.center,n.createPath)),M.default.extend(this,{graphie:e,initialPoint:e.scalePoint(M.default.head(t))}),n.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper)};M.default.extend(Dn.prototype,Pn);const{getCanUse3dTransform:Ln}=mn;function Bn(e){return M.default.reduce(e,(function(e,t){return e+t}),0)}function zn(){const e=M.default.zip(...arguments);return M.default.map(e,Bn)}function qn(e){return M.default.map(e,(function(e){return-1*e}))}function Hn(e){const t=11.374597405497571;return 58.919514629750836*Math.exp(-.037587715462826674*e)+t}function Wn(e,t){return[e*Math.cos(t),e*Math.sin(t)*-1]}function Un(e,t){return Wn(e,t*Math.PI/180)}let Gn=!1;const Vn={animate:function(){},attr:function(){},remove:function(){}};function jn(e,t){this.set=e.raphael.set(),this.cx=t[0],this.cy=t[1];const n=this,o=e.unscaleVector(180.5)[0],s=e.scalePoint([this.cx-o,this.cy+o-e.unscaleVector(10.5)[1]]),i=e.mouselayer.image("https://ka-perseus-graphie.s3.amazonaws.com/e9d032f2ab8b95979f674fbfa67056442ba1ff6a.png",s[0],s[1],360,180);this.set.push(i),i.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});const r=function(n,s){const i=e.scaleVector(o);i[0]-=16,i[1]-=16;const r=e.scalePoint(t);return Math.sin((n+90)*Math.PI/180)*(i[0]+s)+r[0]+","+(Math.cos((n+90)*Math.PI/180)*(i[1]+s)+r[1])},a=e.raphael.path(" M"+r(180,6)+" L"+r(180,2)+" L"+r(183,10)+" L"+r(180,18)+" L"+r(180,14)+" A"+(e.scaleVector(o)[0]+10)+","+(e.scaleVector(o)[1]+10)+",0,0,1,"+r(170,14)+" L"+r(170,18)+" L"+r(167,10)+" L"+r(170,2)+" L"+r(170,6)+" A"+(e.scaleVector(o)[0]+10)+","+(e.scaleVector(o)[1]+10)+",0,0,0,"+r(180,6)+" Z").attr({stroke:null,fill:bn.INTERACTIVE});this.set.push(a),this.centerPoint=e.addMovablePoint({coord:t,visible:!1}),this.rotateHandle=e.addMovablePoint({bounded:!1,coord:[Math.sin(275*Math.PI/180)*o+this.cx,Math.cos(275*Math.PI/180)*o+this.cy],onMove:function(e,t){const o=180*Math.atan2(n.centerPoint.coord[1]-t,n.centerPoint.coord[0]-e)/Math.PI;n.rotate(-o-5,!0)}}),this.rotateHandle.constraints.fixedDistance.dist=o,this.rotateHandle.constraints.fixedDistance.point=this.centerPoint,this.rotateHandle.visibleShape.remove(),this.rotateHandle.mouseTarget.attr({scale:2});let l=!1,c=!1;const d=function(){return c||l},p=P.default(this.rotateHandle.mouseTarget.getMouseTarget());p.bind("vmousedown",(function(e){l=!0,p.css("cursor","-webkit-grabbing"),p.css("cursor","grabbing"),a.animate({scale:1.5,fill:bn.INTERACTING},50),P.default(document).bind("vmouseup.rotateHandle",(function(e){l=!1,p.css("cursor","-webkit-grab"),p.css("cursor","grab"),d()||a.animate({scale:1,fill:bn.INTERACTIVE},50),P.default(document).unbind("vmouseup.rotateHandle")}))})),p.bind("vmouseover",(function(e){c=!0,a.animate({scale:1.5,fill:bn.INTERACTING},50)})),p.bind("vmouseout",(function(e){c=!1,d()||a.animate({scale:1,fill:bn.INTERACTIVE},50)}));const u=P.default.map(this.set,(function(e){return e.node}));return this.makeTranslatable=function(){P.default(u).css("cursor","move"),p.css("cursor","-webkit-grab"),p.css("cursor","grab"),P.default(u).bind("vmousedown",(function(t){t.preventDefault();let o=t.pageX-P.default(e.raphael.canvas.parentNode).offset().left,s=t.pageY-P.default(e.raphael.canvas.parentNode).offset().top;P.default(document).bind("vmousemove.protractor",(function(t){let i=t.pageX-P.default(e.raphael.canvas.parentNode).offset().left,r=t.pageY-P.default(e.raphael.canvas.parentNode).offset().top;i=Math.max(10,Math.min(e.xpixels-10,i)),r=Math.max(10,Math.min(e.ypixels-10,r));const a=i-o,l=r-s;P.default.each(n.set.items,(function(){this.translate(a,l)})),n.centerPoint.setCoord([n.centerPoint.coord[0]+a/e.scale[0],n.centerPoint.coord[1]-l/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+a/e.scale[0],n.rotateHandle.coord[1]-l/e.scale[1]]),o=i,s=r})),P.default(document).one("vmouseup",(function(e){P.default(document).unbind("vmousemove.protractor")}))}))},this.rotation=0,this.rotate=function(t,n){const o=e.scalePoint(this.centerPoint.coord);return n&&(this.rotation=0),this.set.rotate(this.rotation+t,o[0],o[1]),this.rotation=this.rotation+t,this},this.moveTo=function(t,o){const s=e.scalePoint(n.centerPoint.coord),i=e.scalePoint([t,o]),r=2*En.getDistance(s,i);P.default({x:s[0],y:s[1]}).animate({x:i[0],y:i[1]},{duration:r,step:function(t,o){let s=0,i=0;"x"===o.prop?s=t-e.scalePoint(n.centerPoint.coord)[0]:"y"===o.prop&&(i=t-e.scalePoint(n.centerPoint.coord)[1]),P.default.each(n.set.items,(function(){this.translate(s,i)})),n.centerPoint.setCoord([n.centerPoint.coord[0]+s/e.scale[0],n.centerPoint.coord[1]-i/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+s/e.scale[0],n.rotateHandle.coord[1]-i/e.scale[1]])}})},this.rotateTo=function(e){Math.abs(this.rotation-e)>180&&(this.rotation+=360);const t=5*Math.abs(this.rotation-e);P.default({0:this.rotation}).animate({0:e},{duration:t,step:function(e,t){n.rotate(e,!0),n.rotateHandle.setCoord([Math.sin((e+275)*Math.PI/180)*o+n.centerPoint.coord[0],Math.cos((e+275)*Math.PI/180)*o+n.centerPoint.coord[1]])}})},this.remove=function(){this.set.remove()},this.makeTranslatable(),this}function Yn(e,t){M.default.defaults(t,{center:[0,0],pixelsPerUnit:40,ticksPerUnit:10,units:10,label:"",style:{fill:null,stroke:bn.GRAY}});const n=M.default.extend({},t.style,{strokeWidth:1}),o=M.default.extend({},t.style,{strokeWidth:2}),s=t.units*t.pixelsPerUnit,i=e.unscalePoint(p.vector.subtract(e.scalePoint(t.center),p.vector.scale([s,-50],.5))),r=t.pixelsPerUnit/e.scale[0],a=50/e.scale[0],l=p.vector.add(i,[t.units*r,a]);let c;if(10===t.ticksPerUnit)c={10:1,5:.55,1:.35};else{const e=[1,.6,.45,.3];c={};for(let n=t.ticksPerUnit;n>=1;n/=2)c[n]=1*(e.shift()||.2)}const d=M.default.keys(c).sort((function(e,t){return t-e}));const u=i[0],h=i[1],f=l[0],m=l[1],g=t.units*t.ticksPerUnit+1,v=e.raphael.set(),y=1/e.scale[0];v.push(e.line([u-y,h],[f+y,h],o)),v.push(e.line([u-y,m],[f+y,m],o)),M.default.times(g,(function(s){const i=s/t.ticksPerUnit,l=u+i*r,p=function(e){for(let t=0;t<d.length;t++){const n=d[t];if(e%n==0)return c[n]}return 0}(s)*a,f=0===s||s===g-1?o:n;if(v.push(e.line([l,h],[l,h+p],f)),i%1==0){const n=e.scalePoint([l,m]);let o,s;0===i?(o=t.label,s={mm:13,cm:11,m:8,km:11,in:8,ft:8,yd:10,mi:10}[o]||3*o.toString().length):(o=i,s=-3*(i.toString().length+1));const r=e.raphael.text(n[0]+s,n[1]+10,o);r.attr({"font-family":"KaTeX_Main","font-size":"12px",color:"#444"}),v.push(r)}}));const b=e.mouselayer.path(En.svgPath([i,[u,m],l,[f,h],!0]));b.attr({fill:"#000",opacity:0,stroke:"#000","stroke-width":2}),v.push(b),b.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});const x=P.default.map(v,(function(e){return e.node}));P.default(x).css("cursor","move"),P.default(x).bind("vmousedown",(function(t){t.preventDefault();let n=t.pageX-P.default(e.raphael.canvas.parentNode).offset().left,o=t.pageY-P.default(e.raphael.canvas.parentNode).offset().top;P.default(document).bind("vmousemove.ruler",(function(t){let s=t.pageX-P.default(e.raphael.canvas.parentNode).offset().left,i=t.pageY-P.default(e.raphael.canvas.parentNode).offset().top;s=Math.max(10,Math.min(e.xpixels-10,s)),i=Math.max(10,Math.min(e.ypixels-10,i));const r=s-n,a=i-o;v.translate(r,a),w.setCoord([w.coord[0]+r/e.scale[0],w.coord[1]-a/e.scale[1]]),C.setCoord([C.coord[0]+r/e.scale[0],C.coord[1]-a/e.scale[1]]),n=s,o=i})),P.default(document).one("vmouseup",(function(e){P.default(document).unbind("vmousemove.ruler")}))}));const w=e.addMovablePoint({coord:i,normalStyle:{fill:bn.INTERACTIVE,"fill-opacity":0,stroke:bn.INTERACTIVE},highlightStyle:{fill:bn.INTERACTING,"fill-opacity":.1,stroke:bn.INTERACTING},pointSize:6,onMove:function(t,n){const o=C.coord[1]-n,s=C.coord[0]-t,i=180*Math.atan2(o,s)/Math.PI,r=p.vector.scale(p.vector.add([t,n],C.coord),.5),a=e.scalePoint(r),l=p.vector.scale(p.vector.add(w.coord,C.coord),.5),c=e.scalePoint(l),d=p.vector.subtract(a,c);v.rotate(-i,c[0],c[1]),v.translate(d[0],d[1])}}),C=e.addMovablePoint({coord:[f,h],normalStyle:{fill:bn.INTERACTIVE,"fill-opacity":0,stroke:bn.INTERACTIVE},highlightStyle:{fill:bn.INTERACTING,"fill-opacity":.1,stroke:bn.INTERACTING},pointSize:6,onMove:function(t,n){const o=n-w.coord[1],s=t-w.coord[0],i=180*Math.atan2(o,s)/Math.PI,r=p.vector.scale(p.vector.add([t,n],w.coord),.5),a=e.scalePoint(r),l=p.vector.scale(p.vector.add(w.coord,C.coord),.5),c=e.scalePoint(l),d=p.vector.subtract(a,c);v.rotate(-i,c[0],c[1]),v.translate(d[0],d[1])}});return w.constraints.fixedDistance.dist=s/e.scale[0],w.constraints.fixedDistance.point=C,C.constraints.fixedDistance.dist=s/e.scale[0],C.constraints.fixedDistance.point=w,this.remove=function(){v.remove(),w.remove(),C.remove()},this}function $n(e,t){if(this.graphie=e,M.default.extend(this,t),M.default.defaults(this,{normalStyle:{stroke:bn.INTERACTIVE,"stroke-width":2,fill:bn.INTERACTIVE},highlightStyle:{stroke:bn.INTERACTING,"stroke-width":2,fill:bn.INTERACTING},labelStyle:{stroke:bn.DYNAMIC,"stroke-width":1,color:bn.DYNAMIC},angleStyle:{stroke:bn.DYNAMIC,"stroke-width":1,color:bn.DYNAMIC},allowReflex:!0}),!this.points||3!==this.points.length)throw new we("MovableAngle requires 3 points",be.InvalidInput);this.points=M.default.map(t.points,(function(t){return M.default.isArray(t)?e.addMovablePoint({coord:t,visible:!1,constraints:{fixed:!0},normalStyle:this.normalStyle}):t}),this),this.coords=M.default.pluck(this.points,"coord"),null==this.reflex&&(this.allowReflex?this.reflex=this._getClockwiseAngle(this.coords)>180:this.reflex=!1),this.rays=M.default.map([0,2],(function(t){return e.addMovableLineSegment({pointA:this.points[1],pointZ:this.points[t],fixed:!0,extendRay:!0})}),this),this.temp=[],this.labeledAngle=e.label([0,0],"","center",this.labelStyle),this.fixed||(this.addMoveHandlers(),this.addHighlightHandlers()),this.update()}M.default.extend(En.Graphie.prototype,{addMouseLayer:function(e){const t=this;e=M.default.extend({allowScratchpad:!1,setDrawingAreaAvailable:function(){}},e);if(t.mouselayer=yn.exports(t.raphael.canvas.parentNode,t.xpixels,t.ypixels),P.default(t.mouselayer.canvas).css("z-index",2),e.onClick||e.onMouseDown||e.onMouseMove||e.onMouseOver||e.onMouseOut){const n=t.mouselayer.rect(0,0,t.xpixels,t.ypixels).attr({fill:"#000",opacity:0});let o=!1;P.default(t.mouselayer.canvas).on("vmousedown",(function(s){s.target===n[0]&&(e.onMouseDown&&e.onMouseDown(t.getMouseCoord(s)),o=!0,e.onMouseMove&&P.default(document).bind("vmousemove.mouseLayer",(function(n){o&&(n.preventDefault(),e.onMouseMove(t.getMouseCoord(n)))})),P.default(document).bind("vmouseup.mouseLayer",(function(n){P.default(document).unbind(".mouseLayer"),o&&e.onClick&&e.onClick(t.getMouseCoord(n)),o=!1})))})),e.onMouseOver&&P.default(t.mouselayer.canvas).on("vmouseover",(function(n){e.onMouseOver(t.getMouseCoord(n))})),e.onMouseOut&&P.default(t.mouselayer.canvas).on("vmouseout",(function(n){e.onMouseOut(t.getMouseCoord(n))}))}e.allowScratchpad||e.setDrawingAreaAvailable(!1),t._mouselayerWrapper=document.createElement("div"),P.default(t._mouselayerWrapper).css({position:"absolute",left:0,top:0,zIndex:2}),t._visiblelayerWrapper=document.createElement("div"),P.default(t._visiblelayerWrapper).css({position:"absolute",left:0,top:0});const n=t.raphael.canvas.parentNode;n.appendChild(t._visiblelayerWrapper),n.appendChild(t._mouselayerWrapper),t.addToMouseLayerWrapper=function(e){this._mouselayerWrapper.appendChild(e)},t.addToVisibleLayerWrapper=function(e){this._visiblelayerWrapper.appendChild(e)}},getMousePx:function(e){return[e.pageX-P.default(this.raphael.canvas.parentNode).offset().left,e.pageY-P.default(this.raphael.canvas.parentNode).offset().top]},getMouseCoord:function(e){return this.unscalePoint(this.getMousePx(e))},labelAngle:function(e){const t=this;M.default.defaults(e,{point1:[0,0],vertex:[0,0],point3:[0,0],label:null,numArcs:1,showRightAngleMarker:!0,pushOut:0,clockwise:!1,style:{}});let n=void 0===e.text?"":e.text;const o=e.vertex,s=t.scalePoint(o);let i,r;e.clockwise?(i=e.point1,r=e.point3):(i=e.point3,r=e.point1);const a=En.findAngle(i,o),l=En.findAngle(r,o),c=(l+360-a)%360,d=(a+c/2)%360;let p=5*e.pushOut+Hn(c);const u=[];if(Math.abs(c-90)<1e-9&&e.showRightAngleMarker){const n=zn(s,Un(p,a)),o=zn(s,Un(p,l));p*=Math.SQRT2;const i=zn(s,Un(p,d));M.default.each([n,o],(function(n){u.push(t.scaledPath([n,i],e.style))}))}else M.default.times(e.numArcs,(function(n){u.push(t.arc(o,t.unscaleVector(p),a,l,e.style)),p+=3}));if(n){const o=n.match(/\$deg(\d)?/);if(o){const e=o[1]||1;n=n.replace(o[0],Ce.toFixedApprox(c,e)+"^{\\circ}")}const i=zn(s,Un(p+15,d)),r=t.unscalePoint(i);e.label?(e.label.setPosition(r),e.label.processMath(n,!0)):t.label(r,n,"center",e.style)}return u},labelSide:function(e){const t=this;let n,o;M.default.defaults(e,{point1:[0,0],point2:[0,0],label:null,text:"",numTicks:0,numArrows:0,clockwise:!1,style:{}}),e.clockwise?(n=e.point1,o=e.point2):(n=e.point2,o=e.point1);const s=[(n[0]+o[0])/2,(n[1]+o[1])/2],i=t.scalePoint(s),r=Math.atan2(o[1]-n[1],o[0]-n[0]),a=r+Math.PI/2,l=[];let c=0;if(e.numTicks){const n=e.numTicks,o=5,s=5,d=M.default.extend({},e.style,{strokeWidth:2});M.default.times(n,(function(e){const c=Wn(o*(e-(n-1)/2),r),p=Wn(s,a),u=[zn(i,c,p),zn(i,c,qn(p))];l.push(t.scaledPath(u,d))})),c+=o*(n-1)+15}if(e.numArrows){const s=e.numArrows,a=[n,o].sort((function(e,t){return e[1]===t[1]?e[0]-t[0]:e[1]-t[1]}))[0],d=t.scalePoint(a),p=M.default.extend({},e.style,{arrows:"->",strokeWidth:2}),u=5;M.default.times(s,(function(e){let o=Wn(c+u*e,r);a!==n&&(o=qn(o));const s=zn(i,o);l.push(t.scaledPath([d,s],p))}))}let d=e.text;if(d){const s=d.match(/\$len(\d)?/);if(s){const e=En.getDistance(n,o),t=s[1]||1;d=d.replace(s[0],Ce.toFixedApprox(e,t))}const r=Wn(20,a),l=zn(i,r),c=t.unscalePoint(l);e.label?(e.label.setPosition(c),e.label.processMath(d,!0)):t.label(c,d,"center",e.style)}return l},labelVertex:function(e){const t=this;if(M.default.defaults(e,{point1:null,vertex:[0,0],point3:null,label:null,text:"",clockwise:!1,style:{}}),!e.text)return;const n=e.vertex,o=t.scalePoint(n);let s,i;e.clockwise?(s=e.point1,i=e.point3):(s=e.point3,i=e.point1);let r,a=135;if(s&&i){const e=En.findAngle(s,n);a=(En.findAngle(i,n)+360-e)%360,r=(e+a/2+180)%360}else if(s){r=En.findAngle(n,s)+90}else if(i){r=En.findAngle(i,n)+90}else r=135;const l=zn(o,Un(10+Hn(360-a),r)),c=t.unscalePoint(l);e.label?(e.label.setPosition(c),e.label.processMath(e.text,!0)):t.label(c,e.text,"center",e.style)},addMovablePoint:function(e){const t=P.default.extend(!0,{graph:this,coord:[0,0],snapX:0,snapY:0,pointSize:4,highlight:!1,dragging:!1,visible:!0,bounded:!0,constraints:{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},lineStarts:[],lineEnds:[],polygonVertices:[],normalStyle:{},highlightStyle:{fill:bn.INTERACTING,stroke:bn.INTERACTING},labelStyle:{color:bn.INTERACTIVE},vertexLabel:"",mouseTarget:null},e),n=t.constraints.fixed?bn.DYNAMIC:bn.INTERACTIVE;t.normalStyle=M.default.extend({},{fill:n,stroke:n},e.normalStyle),void 0!==e.coordX&&(t.coord[0]=e.coordX),void 0!==e.coordY&&(t.coord[1]=e.coordY);const o=t.graph,s=function(e){t.visible&&t.bounded&&!t.constraints.fixed&&(e=o.constrainToBounds(e,10));let n=e[0],s=e[1];if(0!==t.snapX&&(n=Math.round(n/t.snapX)*t.snapX),0!==t.snapY&&(s=Math.round(s/t.snapY)*t.snapY),t.constraints.fixedDistance.snapPoints){const i=o.scalePoint(e);let r=i[0],a=i[1];const l=2*Math.PI/t.constraints.fixedDistance.snapPoints,c=t.constraints.fixedDistance.dist,d=t.constraints.fixedDistance.point,p=(d[0]-o.range[0][0])*o.scale[0],u=(-d[1]+o.range[1][1])*o.scale[1];let h=r-p,f=-a+u,m=Math.atan(f/h);h<0&&(m+=Math.PI),m=Math.round(m/l)*l,h=c*Math.cos(m),f=c*Math.sin(m),r=h+p,a=-f+u,n=Ce.roundTo(5,r/o.scale[0]+o.range[0][0]),s=Ce.roundTo(5,o.range[1][1]-a/o.scale[1])}return t.applyConstraint([n,s])};t.applyConstraint=function(e,n,o){let s=e.slice();const i={};if(o?P.default.extend(i,{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},n):P.default.extend(i,this.constraints,n),i.constrainX)s=[this.coord[0],e[1]];else if(i.constrainY)s=[e[0],this.coord[1]];else if("number"==typeof i.fixedAngle.angle&&"number"==typeof i.fixedDistance.dist){const e=i.fixedAngle.vertex.coord||i.fixedAngle.vertex,t=i.fixedAngle.ref.coord||i.fixedAngle.ref,n=i.fixedDistance.point.coord||i.fixedDistance.point,o=(i.fixedAngle.angle+En.findAngle(t,e))*Math.PI/180,r=i.fixedDistance.dist;s[0]=r*Math.cos(o)+n[0],s[1]=r*Math.sin(o)+n[1]}else if("number"==typeof i.fixedAngle.angle){const t=i.fixedAngle.vertex.coord||i.fixedAngle.vertex,n=i.fixedAngle.ref.coord||i.fixedAngle.ref,o=(i.fixedAngle.angle+En.findAngle(n,t))*Math.PI/180,r=En.findAngle(e,t)*Math.PI/180;let a=En.getDistance(e,t)*Math.cos(o-r);a=a<1?1:a,s[0]=a*Math.cos(o)+t[0],s[1]=a*Math.sin(o)+t[1]}else if("number"==typeof i.fixedDistance.dist){const t=i.fixedDistance.point.coord||i.fixedDistance.point;let n=En.findAngle(e,t);const o=i.fixedDistance.dist;n=n*Math.PI/180,s[0]=o*Math.cos(n)+t[0],s[1]=o*Math.sin(n)+t[1]}else i.fixed&&(s=t.coord);return s},t.coord=s(t.coord);if(t.visible&&o.style(t.normalStyle,(function(){const e=[t.pointSize/o.scale[0],t.pointSize/o.scale[1]],n={maxScale:2,padding:2};t.visibleShape=new An(o,t.coord,e,n),t.visibleShape.attr(M.default.omit(t.normalStyle,"scale")),t.visibleShape.toFront()})),t.normalStyle.scale=1,t.highlightStyle.scale=2,t.vertexLabel&&(t.labeledVertex=this.label([0,0],"","center",t.labelStyle)),t.drawLabel=function(){t.vertexLabel&&t.graph.labelVertex({vertex:t.coord,label:t.labeledVertex,text:t.vertexLabel,style:t.labelStyle})},t.drawLabel(),t.grab=function(e){e=e||[0,0],P.default(document).bind("vmousemove.point vmouseup.point",(function(n){n.preventDefault(),t.dragging=!0,Gn=!0;let i=p.vector.add(o.getMouseCoord(n),e);i=s(i);let r,a,l=i[0],c=i[1];if("vmousemove"===n.type){let e=!0;if(M.default.isFunction(t.onMove)){const n=t.onMove(l,c);!1===n&&(e=!1),M.default.isArray(n)&&(l=n[0],c=n[1])}if(r=(l-o.range[0][0])*o.scale[0],a=(-c+o.range[1][1])*o.scale[1],e){const e=o.unscalePoint([r,a]);t.visibleShape.moveTo(e),t.mouseTarget.moveTo(e),t.coord=[l,c],t.updateLineEnds(),P.default(t).trigger("move")}t.drawLabel()}else if("vmouseup"===n.type){if(P.default(document).unbind(".point"),t.dragging=!1,Gn=!1,M.default.isFunction(t.onMoveEnd)){const e=t.onMoveEnd(l,c);if(M.default.isArray(e)){l=e[0],c=e[1],r=(l-o.range[0][0])*o.scale[0],a=(-c+o.range[1][1])*o.scale[1];const n=o.unscalePoint([r,a]);t.visibleShape.moveTo(n),t.mouseTarget.moveTo(n),t.coord=[l,c]}}t.highlight||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())}}))},t.visible&&!t.constraints.fixed){if(!t.mouseTarget){const e=o.unscaleVector(16),n={mouselayer:!0,padding:0,disableMouseEventsOnWrapper:!0,interactiveKindForTesting:"movable-point"};t.mouseTarget=new An(o,t.coord,e,n),t.mouseTarget.attr({fill:"#000",opacity:0})}const e=P.default(t.mouseTarget.getMouseTarget());e.css("cursor","move"),e.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)t.highlight=!0,Gn||(t.visibleShape.animate(t.highlightStyle,50),t.onHighlight&&t.onHighlight());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||Gn||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();const n=t.coord,s=o.getMouseCoord(e),i=!("ontouchstart"in window)?[0,0]:p.vector.subtract(n,s);t.grab(i)}}))}return t.moveTo=function(e,n,o){const s=5*En.getDistance(this.graph.scalePoint([e,n]),this.graph.scalePoint(this.coord)),i=o&&function(e){t.coord=e,t.updateLineEnds()};this.visibleShape.animateTo([e,n],s,i),this.mouseTarget.animateTo([e,n],s,i),this.coord=[e,n],M.default.isFunction(this.onMove)&&this.onMove(e,n)},t.updateLineEnds=function(){P.default(this.lineStarts).each((function(){this.coordA=t.coord,this.transform()})),P.default(this.lineEnds).each((function(){this.coordZ=t.coord,this.transform()})),P.default(this.polygonVertices).each((function(){this.transform()}))},t.setCoord=function(e){this.visible&&(this.visibleShape.moveTo(e),null!=this.mouseTarget&&this.mouseTarget.moveTo(e)),this.coord=e.slice()},t.setCoordConstrained=function(e){this.setCoord(s(e))},t.toBack=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toBack(),this.visibleShape.toBack())},t.toFront=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toFront(),this.visibleShape.toFront())},t.remove=function(){this.visibleShape&&this.visibleShape.remove(),this.mouseTarget&&this.mouseTarget.remove(),this.labeledVertex&&this.labeledVertex.remove()},t},addMovableLineSegment:function(e){const t=P.default.extend({graph:this,coordA:[0,0],coordZ:[1,1],snapX:0,snapY:0,fixed:!1,ticks:0,normalStyle:{},highlightStyle:{stroke:bn.INTERACTING,"stroke-width":6},labelStyle:{stroke:bn.INTERACTIVE,color:bn.INTERACTIVE},highlight:!1,dragging:!1,tick:[],extendLine:!1,extendRay:!1,constraints:{fixed:!1,constrainX:!1,constrainY:!1},sideLabel:"",vertexLabels:[],numArrows:0,numTicks:0,movePointsWithLine:!1},e),n=t.fixed?bn.DYNAMIC:bn.INTERACTIVE;t.normalStyle=M.default.extend({},{"stroke-width":2,stroke:n},e.normalStyle),t.arrowStyle=M.default.extend({},t.normalStyle,{color:t.normalStyle.stroke}),void 0!==e.pointA?(t.coordA=e.pointA.coord,t.pointA.lineStarts.push(t)):void 0!==e.coordA&&(t.coordA=e.coordA.slice()),void 0!==e.pointZ?(t.coordZ=e.pointZ.coord,t.pointZ.lineEnds.push(t)):void 0!==e.coordA&&(t.coordA=t.coordA.slice());const o=t.graph;o.style(t.normalStyle);for(let e=0;e<t.ticks;++e)t.tick[e]=Vn;let s=En.unscaledSvgPath([[0,0],[1,0]]);for(let e=0;e<t.ticks;++e){const n=.5-(t.ticks-1+2*e)/o.scale[0];s+=En.unscaledSvgPath([[n,-7],[n,7]])}if(e={thickness:Math.max(t.normalStyle["stroke-width"],t.highlightStyle["stroke-width"])},t.visibleLine=new Fn(o,[0,0],[1,0],e),t.visibleLine.attr(t.normalStyle),!t.fixed){const e={thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"};t.mouseTarget=new Fn(o,[0,0],[1,0],e),t.mouseTarget.attr({fill:"#000",opacity:0})}if(t.transform=function(e){e&&("object"==typeof this.pointA&&(this.coordA=this.pointA.coord),"object"==typeof this.pointZ&&(this.coordZ=this.pointZ.coord));const n=function(e,n,o){const s=(e=t.graph).range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),i=e.unscaleVector(p.vector.cartFromPolarDeg([1,o])),r=p.vector.scale(p.vector.normalize(i),s),a=p.vector.add(n,r),l=p.vector.polarDegFromCart(i)[1];return e.constrainToBoundsOnAngle(a,4,l*Math.PI/180)},s=function(e){const t=e.graph.scalePoint(e.coordA),n=e.graph.scalePoint(e.coordZ);return p.vector.polarDegFromCart(p.vector.subtract(n,t))[1]}(this);let i=this.coordA,r=this.coordZ;this.extendLine?(i=n(o,i,360-s),r=n(o,r,(540-s)%360)):this.extendRay&&(r=n(o,i,360-s));const a=[this.visibleLine];this.fixed||a.push(this.mouseTarget),M.default.each(a,(function(e){e.moveTo(i,r)}));const l=function(e,t){const o=[.75,0];let s=[[-3,4],[-2.75,2.5],[0,.25],o,[0,-.25],[-2.75,-2.5],[-3,-4]];s=M.default.map(s,(function(e){const t=p.vector.subtract(e,o),n=p.vector.scale(t,1.4);return p.vector.add(o,n)}));const i=M.default.map(s,e.unscalePoint),r={center:e.unscalePoint(o),createPath:function(e){let t="M"+e[0][0]+" "+e[0][1];for(let n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t}},a=new Dn(e,i,r);return a.attr(M.default.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),a.toCoordAtAngle=function(t,s){const i=e.scalePoint(n(e,t,s)),r=Ln();a.transform("translateX("+(i[0]+1.4*o[0])+"px) translateY("+(i[1]+1.4*o[1])+"px) "+(r?"translateZ(0) ":"")+"rotate("+(360-Ce.bound(s))+"deg)")},a};null==this._arrows&&(this._arrows=[],this.extendLine?(this._arrows.push(l(o,this.normalStyle)),this._arrows.push(l(o,this.normalStyle))):this.extendRay&&this._arrows.push(l(o,this.normalStyle)));const c=[this.coordA,this.coordZ],d=[360-s,(540-s)%360];M.default.each(this._arrows,(function(e,t){e.toCoordAtAngle(c[t],d[t])})),M.default.invoke(this.temp,"remove"),this.temp=[];const u=this.coordA[0]<this.coordZ[0]||this.coordA[0]===this.coordZ[0]&&this.coordA[1]>this.coordZ[1];this.sideLabel&&this.temp.push(this.graph.labelSide({point1:this.coordA,point2:this.coordZ,label:this.labeledSide,text:this.sideLabel,numArrows:this.numArrows,numTicks:this.numTicks,clockwise:u,style:this.labelStyle})),this.vertexLabels.length&&(this.graph.labelVertex({vertex:this.coordA,point3:this.coordZ,label:this.labeledVertices[0],text:this.vertexLabels[0],clockwise:u,style:this.labelStyle}),this.graph.labelVertex({point1:this.coordA,vertex:this.coordZ,label:this.labeledVertices[1],text:this.vertexLabels[1],clockwise:u,style:this.labelStyle})),this.temp=M.default.flatten(this.temp)},t.toBack=function(){t.fixed||t.mouseTarget.toBack(),t.visibleLine.toBack()},t.toFront=function(){t.fixed||t.mouseTarget.toFront(),t.visibleLine.toFront()},t.remove=function(){t.fixed||t.mouseTarget.remove(),t.visibleLine.remove(),t.labeledSide&&t.labeledSide.remove(),t.labeledVertices&&M.default.invoke(t.labeledVertices,"remove"),t._arrows&&M.default.invoke(t._arrows,"remove"),t.temp.length&&M.default.invoke(t.temp,"remove")},t.hide=function(){t.visibleLine.hide(),t.temp.length&&M.default.invoke(t.temp,"hide"),t._arrows&&M.default.invoke(t._arrows,"hide")},t.show=function(){t.visibleLine.show(),t.temp.length&&M.default.invoke(t.temp,"show"),t._arrows&&M.default.invoke(t._arrows,"show")},t.sideLabel&&(t.labeledSide=this.label([0,0],"","center",t.labelStyle)),t.vertexLabels.length&&(t.labeledVertices=M.default.map(t.vertexLabels,(function(e){return this.label([0,0],"","center",t.labelStyle)}),this)),!t.fixed&&!t.constraints.fixed){const e=P.default(t.mouseTarget.getMouseTarget());e.css("cursor","move"),e.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Gn||(t.highlight=!0,t.visibleLine.animate(t.highlightStyle,50),t.arrowStyle=M.default.extend({},t.arrowStyle,{color:t.highlightStyle.stroke,stroke:t.highlightStyle.stroke}),t.transform());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=M.default.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();let n=(e.pageX-P.default(o.raphael.canvas.parentNode).offset().left)/o.scale[0]+o.range[0][0],s=o.range[1][1]-(e.pageY-P.default(o.raphael.canvas.parentNode).offset().top)/o.scale[1];t.snapX>0&&(n=Math.round(n/t.snapX)*t.snapX),t.snapY>0&&(s=Math.round(s/t.snapY)*t.snapY);const i=[t.coordA[0]-n,t.coordA[1]-s],r=[t.coordZ[0]-n,t.coordZ[1]-s],a=-Math.min(o.scaleVector(i)[0],o.scaleVector(r)[0]),l=Math.max(o.scaleVector(i)[0],o.scaleVector(r)[0]),c=Math.max(o.scaleVector(i)[1],o.scaleVector(r)[1]),d=-Math.min(o.scaleVector(i)[1],o.scaleVector(r)[1]);P.default(document).bind("vmousemove.lineSegment vmouseup.lineSegment",(function(e){e.preventDefault(),t.dragging=!0,Gn=!0;let n=e.pageX-P.default(o.raphael.canvas.parentNode).offset().left,s=e.pageY-P.default(o.raphael.canvas.parentNode).offset().top;n=Math.max(a+10,Math.min(o.xpixels-10-l,n)),s=Math.max(c+10,Math.min(o.ypixels-10-d,s));let p=n/o.scale[0]+o.range[0][0],u=o.range[1][1]-s/o.scale[1];if(t.snapX>0&&(p=Math.round(p/t.snapX)*t.snapX),t.snapY>0&&(u=Math.round(u/t.snapY)*t.snapY),"vmousemove"===e.type){t.constraints.constrainX&&(p=t.coordA[0]-i[0]),t.constraints.constrainY&&(u=t.coordA[1]-i[1]);const e=p+i[0]-t.coordA[0],n=u+i[1]-t.coordA[1];t.coordA=[p+i[0],u+i[1]],t.coordZ=[p+r[0],u+r[1]],t.transform(),t.movePointsWithLine&&("object"==typeof t.pointA&&t.pointA.setCoord([t.pointA.coord[0]+e,t.pointA.coord[1]+n]),"object"==typeof t.pointZ&&t.pointZ.setCoord([t.pointZ.coord[0]+e,t.pointZ.coord[1]+n])),M.default.isFunction(t.onMove)&&t.onMove(e,n)}else"vmouseup"===e.type&&(P.default(document).unbind(".lineSegment"),t.dragging=!1,Gn=!1,t.highlight||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=M.default.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform()),M.default.isFunction(t.onMoveEnd)&&t.onMoveEnd());P.default(t).trigger("move")}))}}))}return void 0!==t.pointA&&t.pointA.toFront(),void 0!==t.pointZ&&t.pointZ.toFront(),t.transform(),t},addMovablePolygon:function(e){const t=this,n=P.default.extend({snapX:0,snapY:0,fixed:!1,constrainToGraph:!0,normalStyle:{},highlightStyle:{stroke:bn.INTERACTING,"stroke-width":2,fill:bn.INTERACTING,"fill-opacity":.05},pointHighlightStyle:{fill:bn.INTERACTING,stroke:bn.INTERACTING},labelStyle:{stroke:bn.DYNAMIC,"stroke-width":1,color:bn.DYNAMIC},angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],updateOnPointMove:!0,closed:!0},M.default.omit(e,"points")),o=n.fixed?bn.DYNAMIC:bn.INTERACTIVE;n.normalStyle=M.default.extend({"stroke-width":2,"fill-opacity":0,fill:o,stroke:o},e.normalStyle),n.points=e.points;const s=function(e){return!M.default.isArray(e)};if(n.update=function(){const e=n.points.length;n.coords=M.default.map(n.points,(function(e,t){return s(e)?e.coord:e})),n.left=M.default.min(M.default.pluck(n.coords,0)),n.right=M.default.max(M.default.pluck(n.coords,0)),n.top=M.default.max(M.default.pluck(n.coords,1)),n.bottom=M.default.min(M.default.pluck(n.coords,1));let o=M.default.map(n.coords,(function(e){return t.scalePoint(e)}));n.closed?o.push(!0):o=o.concat(M.default.clone(o).reverse()),n.path=En.unscaledSvgPath(o),M.default.invoke(n.temp,"remove"),n.temp=[];const i=function(e){const t=M.default.zip(e,e.slice(1).concat(e.slice(0,1)));return Bn(M.default.map(t,(function(e){const t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])})))>0}(n.coords);(n.angleLabels.length||n.showRightAngleMarkers.length)&&M.default.each(n.labeledAngles,(function(o,s){n.temp.push(t.labelAngle({point1:n.coords[(s-1+e)%e],vertex:n.coords[s],point3:n.coords[(s+1)%e],label:o,text:n.angleLabels[s],showRightAngleMarker:n.showRightAngleMarkers[s],numArcs:n.numArcs[s],clockwise:i,style:n.labelStyle}))})),n.sideLabels.length&&M.default.each(n.labeledSides,(function(o,s){n.temp.push(t.labelSide({point1:n.coords[s],point2:n.coords[(s+1)%e],label:o,text:n.sideLabels[s],numArrows:n.numArrows[s],numTicks:n.numTicks[s],clockwise:i,style:n.labelStyle}))})),n.vertexLabels.length&&M.default.each(n.labeledVertices,(function(o,s){t.labelVertex({point1:n.coords[(s-1+e)%e],vertex:n.coords[s],point3:n.coords[(s+1)%e],label:o,text:n.vertexLabels[s],clockwise:i,style:n.labelStyle})})),n.temp=M.default.flatten(n.temp)},n.transform=function(){n.update(),n.visibleShape.attr({path:n.path}),n.fixed||n.mouseTarget.attr({path:n.path})},n.remove=function(){n.visibleShape.remove(),n.fixed||n.mouseTarget.remove(),n.labeledAngles&&M.default.invoke(n.labeledAngles,"remove"),n.labeledSides&&M.default.invoke(n.labeledSides,"remove"),n.labeledVertices&&M.default.invoke(n.labeledVertices,"remove"),n.temp.length&&M.default.invoke(n.temp,"remove")},n.toBack=function(){n.fixed||n.mouseTarget.toBack(),n.visibleShape.toBack()},n.toFront=function(){n.fixed||n.mouseTarget.toFront(),n.visibleShape.toFront()},n.updateOnPointMove&&M.default.each(M.default.filter(n.points,s),(function(e){e.polygonVertices.push(n)})),n.coords=new Array(n.points.length),n.angleLabels.length){const e=Math.max(n.angleLabels.length,n.showRightAngleMarkers.length);n.labeledAngles=M.default.times(e,(function(){return this.label([0,0],"","center",n.labelStyle)}),this)}return n.sideLabels.length&&(n.labeledSides=M.default.map(n.sideLabels,(function(e){return this.label([0,0],"","center",n.labelStyle)}),this)),n.vertexLabels.length&&(n.labeledVertices=M.default.map(n.vertexLabels,(function(e){return this.label([0,0],"","center",n.labelStyle)}),this)),n.update(),n.visibleShape=t.raphael.path(n.path),n.visibleShape.attr(n.normalStyle),n.fixed||(n.mouseTarget=t.mouselayer.path(n.path),n.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"}),P.default(n.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Gn&&!n.dragging||(n.highlight=!0,n.visibleShape.animate(n.highlightStyle,50),M.default.each(M.default.filter(n.points,s),(function(e){e.visibleShape.animate(n.pointHighlightStyle,50)})));else if("vmouseout"===e.type){if(n.highlight=!1,!n.dragging){n.visibleShape.animate(n.normalStyle,50);const e=M.default.filter(n.points,s);M.default.any(M.default.pluck(e,"dragging"))||M.default.each(e,(function(e){e.visibleShape.animate(e.normalStyle,50)}))}}else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),M.default.each(M.default.filter(n.points,s),(function(e){e.dragging=!0}));let o=(e.pageX-P.default(t.raphael.canvas.parentNode).offset().left)/t.scale[0]+t.range[0][0],i=t.range[1][1]-(e.pageY-P.default(t.raphael.canvas.parentNode).offset().top)/t.scale[1];n.snapX>0&&(o=Math.round(o/n.snapX)*n.snapX),n.snapY>0&&(i=Math.round(i/n.snapY)*n.snapY);let r=o,a=i;const l=n.coords.slice(),c=(o-n.left)*t.scale[0],d=(n.right-o)*t.scale[0],p=(n.top-i)*t.scale[1],u=(i-n.bottom)*t.scale[1];P.default(document).bind("vmousemove.polygon vmouseup.polygon",(function(e){e.preventDefault(),n.dragging=!0,Gn=!0;let h=e.pageX-P.default(t.raphael.canvas.parentNode).offset().left,f=e.pageY-P.default(t.raphael.canvas.parentNode).offset().top;n.constrainToGraph&&(h=Math.max(c+10,Math.min(t.xpixels-10-d,h)),f=Math.max(p+10,Math.min(t.ypixels-10-u,f)));let m=h/t.scale[0]+t.range[0][0],g=t.range[1][1]-f/t.scale[1];if(n.snapX>0&&(m=Math.round(m/n.snapX)*n.snapX),n.snapY>0&&(g=Math.round(g/n.snapY)*n.snapY),"vmousemove"===e.type){let e=m-o,t=g-i,c=!0;if(M.default.isFunction(n.onMove)){const s=n.onMove(e,t);!1===s?c=!1:M.default.isArray(s)&&(e=s[0],t=s[1],m=o+e,g=i+t)}const d=function(n){return[l[n][0]+e,l[n][1]+t]};c&&(M.default.each(n.points,(function(e,t){s(e)?e.setCoord(d(t)):n.points[t]=d(t)})),n.transform(),P.default(n).trigger("move"),r=m,a=g)}else if("vmouseup"===e.type){P.default(document).unbind(".polygon");const e=M.default.filter(n.points,s);M.default.each(e,(function(e){e.dragging=!1})),n.dragging=!1,Gn=!1,n.highlight||(n.visibleShape.animate(n.normalStyle,50),M.default.each(e,(function(e){e.visibleShape.animate(e.normalStyle,50)}))),M.default.isFunction(n.onMoveEnd)&&n.onMoveEnd(r-o,a-i)}}))}}))),M.default.invoke(M.default.filter(n.points,s),"toFront"),n},constrainToBounds:function(e,t){const n=this.unscalePoint([t,this.ypixels-t]),o=this.unscalePoint([this.xpixels-t,t]);return[Math.max(n[0],Math.min(o[0],e[0])),Math.max(n[1],Math.min(o[1],e[1]))]},constrainToBoundsOnAngle:function(e,t,n){const o=this.unscalePoint([t,this.ypixels-t]),s=this.unscalePoint([this.xpixels-t,t]);let i=e.slice();return i[0]<o[0]?i=[o[0],i[1]+(o[0]-i[0])*Math.tan(n)]:i[0]>s[0]&&(i=[s[0],i[1]-(i[0]-s[0])*Math.tan(n)]),i[1]<o[1]?i=[i[0]+(o[1]-i[1])/Math.tan(n),o[1]]:i[1]>s[1]&&(i=[i[0]-(i[1]-s[1])/Math.tan(n),s[1]]),i},addMovableAngle:function(e){return new $n(this,e)},addCircleGraph:function(e){const t=this,n=P.default.extend({center:[0,0],radius:2,snapX:.5,snapY:.5,snapRadius:.5,minRadius:1,centerConstraints:{},centerNormalStyle:{},centerHighlightStyle:{stroke:bn.INTERACTING,fill:bn.INTERACTING},circleNormalStyle:{stroke:bn.INTERACTIVE,"fill-opacity":0},circleHighlightStyle:{stroke:bn.INTERACTING,fill:bn.INTERACTING,"fill-opacity":.05}},e),o=n.centerConstraints.fixed?bn.DYNAMIC:bn.INTERACTIVE,s=e?e.centerNormalStyle:null;n.centerNormalStyle=M.default.extend({},{fill:o,stroke:o},s),n.centerPoint=t.addMovablePoint({graph:t,coord:n.center,normalStyle:n.centerNormalStyle,snapX:n.snapX,snapY:n.snapY,constraints:n.centerConstraints}),n.circ=t.circle(n.center,n.radius,n.circleNormalStyle),n.perim=t.mouselayer.circle(t.scalePoint(n.center)[0],t.scalePoint(n.center)[1],t.scaleVector(n.radius)[0]).attr({"stroke-width":20,opacity:.002}),n.centerConstraints.fixed||P.default(n.centerPoint.mouseTarget.getMouseTarget()).on("vmouseover vmouseout",(function(e){n.centerPoint.highlight||n.centerPoint.dragging?n.circ.animate(n.circleHighlightStyle,50):n.circ.animate(n.circleNormalStyle,50)})),n.toFront=function(){n.circ.toFront(),n.perim.toFront(),n.centerPoint.visibleShape.toFront(),n.centerConstraints.fixed||n.centerPoint.mouseTarget.toFront()},n.centerPoint.onMove=function(e,o){n.toFront(),n.circ.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(o)[1]}),n.perim.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(o)[1]}),n.onMove&&n.onMove(e,o)},P.default(n.centerPoint).on("move",(function(){n.center=this.coord,P.default(n).trigger("move")})),n.setCenter=function(e,t){n.centerPoint.setCoord([e,t]),n.centerPoint.onMove(e,t),n.center=[e,t]},n.setRadius=function(e){n.radius=e,n.perim.attr({r:t.scaleVector(e)[0]}),n.circ.attr({rx:t.scaleVector(e)[0],ry:t.scaleVector(e)[1]})},n.remove=function(){n.centerPoint.remove(),n.circ.remove(),n.perim.remove()};const i=[[-1*Math.PI,-.875*Math.PI,"ew-resize"],[-.875*Math.PI,-.625*Math.PI,"nesw-resize"],[-.625*Math.PI,-.375*Math.PI,"ns-resize"],[-.375*Math.PI,-.125*Math.PI,"nwse-resize"],[-.125*Math.PI,.125*Math.PI,"ew-resize"],[.125*Math.PI,.375*Math.PI,"nesw-resize"],[.375*Math.PI,.625*Math.PI,"ns-resize"],[.625*Math.PI,.875*Math.PI,"nwse-resize"],[.875*Math.PI,1*Math.PI,"ew-resize"]];return P.default(n.perim.node).on("vmousemove",(e=>{let[t,o]=this.getMouseCoord(e);t-=n.center[0],o-=n.center[1];const s=Math.atan2(o,t);i.forEach((function(e){const[t,o,i]=e;s>=t&&s<o&&P.default(n.perim.node).css("cursor",i)}))})),P.default(n.perim.node).css("cursor","nesw-resize"),n.perim.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),P.default(n.perim.node).on("vmouseover vmouseout vmousedown",(function(e){if("vmouseover"===e.type)n.highlight=!0,Gn||(n.circ.animate(n.circleHighlightStyle,50),n.centerPoint.visibleShape.animate(n.centerHighlightStyle,50));else if("vmouseout"===e.type)n.highlight=!1,n.dragging||n.centerPoint.dragging||(n.circ.animate(n.circleNormalStyle,50),n.centerPoint.visibleShape.animate(n.centerNormalStyle,50));else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),n.toFront();const o=n.radius;P.default(document).on("vmousemove vmouseup",(function(e){if(e.preventDefault(),n.dragging=!0,Gn=!0,"vmousemove"===e.type){const o=t.constrainToBounds(t.getMouseCoord(e),10);let s=En.getDistance(n.centerPoint.coord,o);s=Math.max(n.minRadius,Math.round(s/n.snapRadius)*n.snapRadius);const i=n.radius;let r=!0;if(n.onResize){const e=n.onResize(s,i);M.default.isNumber(e)?s=e:!1===e&&(r=!1)}r&&(n.setRadius(s),P.default(n).trigger("move"))}else"vmouseup"===e.type&&(P.default(document).off("vmousemove vmouseup"),n.dragging=!1,Gn=!1,n.onResizeEnd&&n.onResizeEnd(n.radius,o))}))}})),n},addRotateHandle:function(e){const t=this;let n=e.center;const o=e.radius,s=e.lengthAngle||30,i=e.hideArrow||!1,r=e.mouseTarget,a=M.default.uniqueId("rotateHandle");M.default.isArray(n)&&(n={coord:n});const l=t.addMovablePoint({coord:p.point.addVector(n.coord,p.vector.cartFromPolarDeg(o,e.angleDeg||0)),constraints:{fixedDistance:{dist:o,point:n}},mouseTarget:r});n.toFront();let c,d=n.coord,u=l.coord,h=u,f=!1,m=!1;const g=function(o){if(i)return;const r=p.vector.subtract(o,n.coord),a=p.vector.polarDegFromCart(r)[1];c&&c.remove(),c=function(e,t,n,o,s,i,r){const a=function(o,s){const r=n+s,a=p.vector.cartFromPolarDeg([r,i+o]),l=p.vector.add(t,a),c=e.scalePoint(l);return c[0]+","+c[1]},l=e.scaleVector(n-o),c=e.scaleVector(n+o);return e.raphael.path(" M"+a(s,-o)+" L"+a(s,-3*o)+" L"+a(2*s,0)+" L"+a(s,3*o)+" L"+a(s,o)+" A"+c[0]+","+c[1]+",0,0,1,"+a(-s,o)+" L"+a(-s,3*o)+" L"+a(-2*s,0)+" L"+a(-s,-3*o)+" L"+a(-s,-o)+" A"+l[0]+","+l[1]+",0,0,0,"+a(s,-o)+" Z").attr({stroke:null,fill:r?bn.INTERACTING:bn.INTERACTIVE})}(t,n.coord,e.radius,f||m?e.hoverWidth/2:e.width/2,s,a,f||m)};P.default(n).on("move."+a,(function(){const e=p.vector.subtract(n.coord,d);l.setCoord(p.vector.add(l.coord,e)),g(l.coord),d=n.coord,l.constraints.fixedDistance.point=n,u=l.coord})),l.onMove=function(t,o){f||(h=u,f=!0);let s=[t,o];if(e.onMove){const t=p.vector.polarDegFromCart(p.vector.subtract(u,n.coord)),o=p.vector.polarDegFromCart(p.vector.subtract(s,n.coord)),i=t[1],r=o[1];let a=e.onMove(r,i);null!=a&&!0!==a&&(!1===a&&(a=i),s=p.vector.add(n.coord,p.vector.cartFromPolarDeg([t[0],a])))}return g(s),u=s,s},l.onMoveEnd=function(){if(f=!1,g(l.coord),e.onMoveEnd){const t=p.vector.polarDegFromCart(p.vector.subtract(h,n.coord)),o=p.vector.polarDegFromCart(p.vector.subtract(l.coord,n.coord));e.onMoveEnd(o[1],t[1])}},l.visibleShape.remove(),r||l.mouseTarget.attr({scale:2});const v=P.default(l.mouseTarget.getMouseTarget());v.bind("vmouseover",(function(e){m=!0,g(l.coord)})),v.bind("vmouseout",(function(e){m=!1,g(l.coord)})),g(l.coord);const y=l.remove;return l.remove=function(){y.call(l),c&&c.remove(),P.default(n).off("move."+a)},l.update=function(){g(l.coord)},l},addReflectButton:function(e){const t=this,n=e.line,o=t.addMovablePoint({constraints:e.constraints,coord:p.line.midpoint([n.pointA.coord,n.pointZ.coord]),snapX:t.snap[0],snapY:t.snap[1],onMove:function(e,t){return!1},onMoveEnd:function(t,n){e.onMoveEnd&&e.onMoveEnd.call(this,t,n)}});let s,i=!1,r=!1;const a=function(){return i},l=M.default.map([0,1],(function(t){const n=t?e.highlightStyle:e.normalStyle;return M.default.map([0,1],(function(e){return M.default.defaults({"fill-opacity":e},n)}))})),c=function(e){return r&&(e=!e),l[+a()][+e]},d=function(n,o){s&&s.remove(),s=function(e,t,n,o,s,i,r){p.point.equal(n[0],n[1])&&(n=[n[0],p.point.addVector(n[0],[1,1])]);const a=p.vector.normalize(p.vector.subtract(n[1],n[0])),l=p.vector.scale(a,o/2),c=p.vector.scale(a,s),d=p.vector.rotateDeg(c,90),u=p.vector.rotateDeg(c,-90),h=p.vector.negate(l),f=p.vector.rotateDeg(l,90),m=p.vector.rotateDeg(l,-90),g=p.point.addVectors(t,d),v=p.point.addVectors(t,u),y=p.point.addVectors(t,d,l,f),b=p.point.addVectors(t,d,h,f),x=p.point.addVectors(t,u,l,m),w=p.point.addVectors(t,u,h,m),C=e.path([g,y,b,!0],i),k=e.path([v,x,w,!0],r);return{remove:function(){C.remove(),k.remove()}}}(t,n,o,a()?1.5*e.size:e.size,a()?.125*e.size:.25,c(0),c(1))},u=function(e,t){e=e||n.pointA.coord,t=t||n.pointZ.coord;const s=p.line.midpoint([e,t]);o.setCoord(s),d(s,[e,t])};P.default(n).on("move",M.default.bind(u,o,null,null));const h=P.default(o.mouseTarget.getMouseTarget());h.on("vclick",(function(){!1!==e.onClick()&&(r=!r,d(o.coord,[n.pointA.coord,n.pointZ.coord]))})),n.pointA.toFront(),n.pointZ.toFront(),o.visibleShape.remove();const f=t.scaleVector(e.size)[0]/20;o.mouseTarget.attr({scale:1.5*f}),h.css("cursor","pointer"),h.bind("vmouseover",(function(e){i=!0,d(o.coord,[n.pointA.coord,n.pointZ.coord])})),h.bind("vmouseout",(function(e){i=!1,d(o.coord,[n.pointA.coord,n.pointZ.coord])}));const m=o.remove;return o.remove=function(){s.remove(),m.call(o)},o.update=u,o.isFlipped=function(){return r},u(),o},protractor:function(e){return new jn(this,e)},ruler:function(e){return new Yn(this,e||{})},addPoints:zn}),M.default.extend($n.prototype,{points:[],snapDegrees:0,snapOffsetDeg:0,angleLabel:"",numArcs:1,pushOut:0,fixed:!1,addMoveHandlers:function(){const e=this.graphie;function t(t,n){return En.getDistance(e.scalePoint(t),e.scalePoint(n))<30}const n=this.points;n[1].onMove=function(o,s){const i=n[1].coord,r=[o,s],a=zn(r,qn(i));let l=!0;const c={};return M.default.each([0,2],(function(o){let s=zn(n[o].coord,a),i=En.findAngle(r,s);i*=Math.PI/180,s=e.constrainToBoundsOnAngle(s,10,i),c[o]=s,t(r,s)&&(l=!1)})),l&&M.default.each(c,(function(e,t){n[t].setCoord(e)})),l};const o=this.snapDegrees,s=this.snapOffsetDeg;M.default.each([0,2],(function(i){n[i].onMove=function(i,r){const a=[i,r],l=n[1].coord;if(t(l,a))return!1;if(o){let t=En.findAngle(a,l);t=Math.round((t-s)/o)*o+s;const n=En.getDistance(a,l);return zn(l,e.polar(n,t))}return!0}})),P.default(n).on("move",function(){this.update(),P.default(this).trigger("move")}.bind(this))},addHighlightHandlers:function(){const e=this.points[1];e.onHighlight=function(){M.default.each(this.points,(function(e){e.visibleShape.animate(this.highlightStyle,50)}),this),M.default.each(this.rays,(function(e){e.visibleLine.animate(this.highlightStyle,50),e.arrowStyle=M.default.extend({},e.arrowStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke})}),this),this.angleStyle=M.default.extend({},this.angleStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke}),this.update()}.bind(this),e.onUnhighlight=function(){M.default.each(this.points,(function(e){e.visibleShape.animate(this.normalStyle,50)}),this),M.default.each(this.rays,(function(e){e.visibleLine.animate(e.normalStyle,50),e.arrowStyle=M.default.extend({},e.arrowStyle,{color:e.normalStyle.stroke,stroke:e.normalStyle.stroke})}),this),this.angleStyle=M.default.extend({},this.angleStyle,{color:bn.DYNAMIC,stroke:bn.DYNAMIC}),this.update()}.bind(this)},_getClockwiseAngle:function(e){return En.findAngle(e[2],e[0],e[1])+0},isReflex:function(){return this.reflex},isClockwise:function(){return this._getClockwiseAngle(this.coords)>180===this.reflex},getClockwiseCoords:function(){return this.isClockwise()?M.default.clone(this.coords):M.default.clone(this.coords).reverse()},update:function(e){const t=this.coords;this.coords=M.default.pluck(this.points,"coord"),M.default.invoke(this.points,"updateLineEnds");const n=this._getClockwiseAngle(t),o=this._getClockwiseAngle(this.coords),s=n>180,i=o>180;this.allowReflex&&(null==e&&(e=s!==i&&Math.abs(o-n)<180),e&&(this.reflex=!this.reflex)),M.default.invoke(this.temp,"remove"),this.temp=this.graphie.labelAngle({point1:this.coords[0],vertex:this.coords[1],point3:this.coords[2],label:this.labeledAngle,text:this.angleLabel,numArcs:this.numArcs,pushOut:this.pushOut,clockwise:this.reflex===i,style:this.angleStyle})},remove:function(){M.default.invoke(this.rays,"remove"),M.default.invoke(this.temp,"remove"),this.labeledAngle.remove()}});const Xn=Ye.nestedMap,Kn=Ye.deepEq;function Zn(e){M.default.extend(this,e)}const Jn=function(){throw new we("Abstract method! Must be implemented by Graphie Movable"+this.constructor.displayName,be.NotAllowed)};M.default.extend(Zn.prototype,{movableProps:[],add:Jn,modify:Jn,remove:Jn,toFront:function(){},componentDidMount:function(){}});const Qn=function(e){const t=function(e){if(!(this instanceof t))throw new we("Use createElement or JSX with graphie movables",be.NotAllowed);return this.props=function(e,t){return M.default.extend({},e,{children:M.default.filter(M.default.flatten(t),M.default.identity)})}(e,e.children||[]),this};return e.displayName=e.displayName||M.default.uniqueId("GraphieClass"),t.displayName=e.displayName,t.prototype=new Zn(e),t.prototype.constructor=t,t};var eo={GraphieMovable:Zn,createClass:Qn,createSimpleClass:function(e){return Qn({displayName:e.name||M.default.uniqueId("GraphieSimpleClass"),movableProps:["children"],add:function(t){this._elements=e(t,this.props),this._prevProps=this.props},modify:function(e){if(!Kn(this.props,this._prevProps))return this.remove(),this.add(e),this._prevProps=this.props,"reordered"},remove:function(){Xn(this._elements,(e=>{e&&e.remove()})),this._elements=null,this._prevProps=null},toFront:function(){Xn(this._elements,(e=>{M.default.isFunction(e.toFront)&&e.toFront()}))}})}};const to=function(e){const t=e.graphie.scalePoint(e.coord(0)),n=e.graphie.scalePoint(e.coord(1));return p.vector.polarDegFromCart(p.vector.subtract(n,t))[1]},no=function(e,t,n){const o=e.range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),s=e.unscaleVector(p.vector.cartFromPolarDeg([1,n])),i=p.vector.scale(p.vector.normalize(s),o),r=p.vector.add(t,i),a=p.vector.polarDegFromCart(s)[1];return e.constrainToBoundsOnAngle(r,4,a*Math.PI/180)},oo=function(e,t){const n=[.75,0];let o=[[-3,4],[-2.75,2.5],[0,.25],n,[0,-.25],[-2.75,-2.5],[-3,-4]];o=M.default.map(o,(function(e){const t=p.vector.subtract(e,n),o=p.vector.scale(t,1.4);return p.vector.add(n,o)}));const s=M.default.map(o,e.unscalePoint),i={center:e.unscalePoint(n),createPath:function(e){let t="M"+e[0][0]+" "+e[0][1];for(let n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t}},r=new Dn(e,s,i);return r.attr(M.default.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),r.toCoordAtAngle=function(t,o){const s=e.scalePoint(no(e,t,o));r.transform("translateX("+(s[0]+1.4*n[0])+"px) translateY("+(s[1]+1.4*n[1])+"px) translateZ(0) rotate("+(360-Ce.bound(o))+"deg)")},r},so={draw:function(){this.draw()},pointsToFront:function(e){M.default.invoke(e.points,"toFront")}};so.standard=[so.draw,so.pointsToFront];const io={draw:function(){this.draw()}};io.standard=[io.draw];const ro={basic:function(e){const t=this.graphie;let n=this.coord(0),o=this.coord(1);if(!this.state.visibleShape){const e={thickness:10};this.state.visibleShape=new Fn(t,n,o,e),this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}const s=to(this);e.extendLine?(n=no(t,n,360-s),o=no(t,o,(540-s)%360)):e.extendRay&&(o=no(t,o,360-s));const i=[this.state.visibleShape];this.mouseTarget()&&i.push(this.mouseTarget()),M.default.each(i,(function(e){e.moveTo(n,o)}))},arrows:function(e){null==this._arrows&&(this._arrows=[],e.extendLine?(this._arrows.push(oo(this.graphie,this.normalStyle())),this._arrows.push(oo(this.graphie,this.normalStyle()))):e.extendRay&&this._arrows.push(oo(this.graphie,this.normalStyle())));const t=to(this),n=[360-t,(540-t)%360];M.default.each(this._arrows,(function(e,t){e.toCoordAtAngle(this.coord(t),n[t])}),this)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(e.highlightStyle,50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(e.normalStyle,50)}};ro.standard=[ro.basic,ro.arrows,ro.highlight];const ao={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},arrows:function(){null!=this._arrows&&M.default.invoke(this._arrows,"remove"),this._arrows=null}};ao.standard=[ao.basic,ao.arrows];const lo={fixed:function(){return function(){return!1}},snap:function(e){return function(t,n){if(null===e)return!0;let o=p.vector.subtract(t,n);return e=e||this.graphie.snap,o=p.point.roundTo(o,e),p.vector.add(n,o)}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(o,s){const i=this.graphie,r=p.vector.subtract(o,s);e=e||i.range,void 0===t&&(t=i.snap);let a=i.unscalePoint([n,i.ypixels-n]),l=i.unscalePoint([i.xpixels-n,n]);t&&(a=p.point.ceilTo(a,t),l=p.point.floorTo(l,t));const c=M.default.map(this.coords(),(function(e,t){const n=p.vector.subtract(l,e);return[p.vector.subtract(a,e),n]})),d=M.default.reduce(c,(function(e,t){const n=t[0],o=t[1];return[Math.max(n[0],Math.min(o[0],e[0])),Math.max(n[1],Math.min(o[1],e[1]))]}),r);return p.vector.add(s,d)}},standard:null},co={updatePoints:function(e,t){const n=p.vector.subtract(e,t);M.default.each(this.state.points,(function(e){e.setCoord(p.vector.add(e.coord(),n))}))},standard:null};var po={add:so,modify:io,draw:ro,remove:ao,onMoveStart:{standard:null},constraints:lo,onMove:co,onMoveEnd:{standard:null}};const uo=mn.assert,ho=mn.normalizeOptions,fo=["add","draw","remove","onMoveStart","constraints","onMove","onMoveEnd"],mo={points:null,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,extendLine:!1,extendRay:!1},go={visibleShape:null,mouseTarget:null},vo=function(e,t,n){uo(null!=e),uo(null!=n),M.default.extend(this,{graphie:e,movable:t,state:{id:M.default.uniqueId("movableLine")}}),this.modify(M.default.extend({},go,n))};M.default.extend(vo,po),mn.createGettersFor(vo,M.default.extend({},mo,go)),mn.addMovableHelperMethodsTo(vo),M.default.extend(vo.prototype,{cloneState:function(){return M.default.extend(this.movable.cloneState(),{coords:this.coords()},this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id},ho(fo,In.pluck(po,"standard")),mo)},modify:function(e){this.update(M.default.extend(this._createDefaultState(),e))},update:function(e){const t=this,n=this.graphie,o=t.state=M.default.extend(t.state,ho(fo,e)),s=o.static?bn.DYNAMIC:bn.INTERACTIVE;if(o.normalStyle=M.default.extend({stroke:s,"stroke-width":2},o.normalStyle),o.highlightStyle=M.default.extend({stroke:bn.INTERACTING,"stroke-width":3},o.highlightStyle),!o.static&&!o.mouseTarget){const e={thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"};o.mouseTarget=new Fn(n,this.coord(0),this.coord(1),e),o.mouseTarget.attr({fill:"#000",opacity:0})}o.static&&o.mouseTarget&&(o.mouseTarget.remove(),o.mouseTarget=null),t.movable.modify(M.default.extend({},o,{mouseTarget:o.mouseTarget,add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){const o=p.vector.subtract(e,n);t._totalDelta=p.vector.add(t._totalDelta,o);let s=p.vector.add(t._initialRefCoord,t._totalDelta);s=t._applyConstraints(s,t._prevRefCoord),!1!==s&&(t._fireEvent(t.state.onMove,s,t._prevRefCoord),t._prevRefCoord=s)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),o.added||(t.prevState={},t._fireEvent(o.add,t.cloneState(),t.prevState),o.added=!0,M.default.invoke(o.points,"listen","onMove",o.id,t.draw.bind(t)),t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},coords:function(){return M.default.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.points&&M.default.invoke(this.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove()},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}});const yo={path:"M8.70710678,12.2928932 C8.31658249,11.9023689 7.68341751,11.9023689 7.29289322,12.2928932 C6.90236893,12.6834175 6.90236893,13.3165825 7.29289322,13.7071068 L9.82842712,16.2426407 C10.2207367,16.6349502 10.8574274,16.6328935 11.2471942,16.2380576 L16.7116603,10.7025237 C17.0996535,10.3094846 17.0955629,9.67633279 16.7025237,9.28833966 C16.3094846,8.90034653 15.6763328,8.90443714 15.2883397,9.29747629 L10.5309507,14.1167372 L8.70710678,12.2928932 Z",width:24,height:24},bo={path:"M6.072 10.4l6.175-7.058a1 1 0 1 1 1.506 1.317L6.769 12.64a1 1 0 0 1-1.55-.054L2.203 8.604a1 1 0 1 1 1.594-1.208L6.072 10.4z",width:16,height:16},xo={path:"M99.669 13.048q0 3.36-2.352 5.712l-41.664 41.664q-2.408 2.408-5.88 2.408t-5.712-2.408l-41.664-41.664q-2.408-2.24-2.408-5.712t2.408-5.88l4.76-4.816q2.52-2.352 5.88-2.352t5.656 2.352l31.136 31.136 31.08-31.136q2.352-2.352 5.712-2.352t5.88 2.352l4.816 4.816q2.352 2.52 2.352 5.88z",width:100,height:63.034},wo={path:"M62.808 49.728q0 3.36-2.352 5.88l-41.72 41.664q-2.352 2.408-5.768 2.408t-5.768-2.408l-4.872-4.76q-2.352-2.52-2.352-5.88t2.352-5.712l31.08-31.136-31.08-31.024q-2.352-2.52-2.352-5.88t2.352-5.712l4.872-4.76q2.296-2.408 5.768-2.408t5.768 2.408l41.72 41.664q2.352 2.296 2.352 5.656z",width:63.034,height:100},Co={path:"M100.035 50.046q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},ko={path:"M50.046 83.676q1.767 0 2.907-1.14l29.526-29.526q1.197-1.197 1.197-2.907t-1.197-2.964l-5.928-5.928q-1.197-1.14-2.964-1.14t-2.907 1.14l-12.312 12.312l0-32.661q0-1.71-1.254-2.964t-2.907-1.254l-8.322 0q-1.71 0-2.964 1.254t-1.254 2.964l0 32.661l-12.312-12.312q-1.197-1.254-2.907-1.254t-2.907 1.254l-5.928 5.928q-1.197 1.197-1.197 2.964t1.197 2.907l29.469 29.526q1.197 1.14 2.964 1.14zm49.989-33.63q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},So={path:"M54.207 83.391q1.653 0 2.907-1.254t1.254-2.907l0-32.718l12.312 12.312q1.254 1.254 2.964 1.254t2.907-1.254l5.928-5.928q1.197-1.197 1.14-2.964 0-1.767-1.14-2.907l-29.526-29.526q-1.197-1.14-2.907-1.14t-2.964 1.14l-29.469 29.526q-1.197 1.254-1.197 2.964t1.197 2.907l5.928 5.928q1.197 1.197 2.907 1.197t2.907-1.197l12.312-12.312l0 32.718q0 1.653 1.254 2.907t2.964 1.254l8.322 0zm45.828-33.345q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},Eo={path:"M50.046 8.322q-8.493 0-16.188 3.306-15.561 6.669-22.173 22.23-3.363 7.695-3.363 16.188t3.306 16.188 8.949 13.281q5.586 5.586 13.281 8.892t16.188 3.306 16.188-3.306 13.281-8.892 8.892-13.281 3.306-16.188-3.306-16.188-8.892-13.281-13.281-8.949q-7.695-3.306-16.188-3.306zm0 91.713q-13.623 0-25.137-6.726t-18.183-18.183q-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.126q-11.514 6.726-25.08 6.726z",width:100,height:99.944},_o={path:"M58.368 81.225l0-12.369q0-.912-.57-1.539t-1.425-.627l-12.54 0q-.855-.057-1.482.627t-.684 1.539l0 12.369q-.057.855.627 1.482t1.539.684l12.54 0q.855 0 1.425-.627t.57-1.539zm1.026-62.871q0-1.596-2.223-1.71l-14.307 0q-2.109 0-2.223 1.71l1.14 40.47q0 .627.627 1.14t1.539.456l12.084 0q.912-.057 1.539-.513t.684-1.083zm-9.348-18.354q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669z",width:100,height:99.944},To={path:"M37.964 76.048q-2.576 0-4.368-1.792l-31.864-31.864q-1.792-1.792-1.792-4.368t1.792-4.368l8.736-8.68q1.792-1.792 4.368-1.792t4.312 1.792l18.816 18.872 42-42.056q1.792-1.792 4.368-1.792t4.312 1.792l8.736 8.736q1.792 1.792 1.792 4.368t-1.792 4.312l-55.048 55.048q-1.792 1.792-4.368 1.792z",width:100,height:76.637},Mo={path:"M99.758 43.09l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-29.45 0l0 29.45q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-29.45l-29.45 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l29.45 0l0-29.45q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836l0 29.45l29.45 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:100},Io={path:"M100.464 80.808q0 3.404-2.368 5.772l-11.47 11.544q-2.368 2.368-5.772 2.368t-5.698-2.368l-24.864-24.864-24.864 24.864q-2.368 2.368-5.772 2.368t-5.772-2.368l-11.47-11.544q-2.368-2.368-2.368-5.772t2.368-5.698l24.864-24.864-24.864-24.864q-2.368-2.368-2.368-5.772t2.368-5.772l11.47-11.47q2.368-2.368 5.772-2.368t5.772 2.368l24.864 24.864 24.864-24.864q2.294-2.368 5.698-2.368t5.772 2.368l11.47 11.47q2.368 2.368 2.368 5.772t-2.368 5.772l-24.864 24.864 24.864 24.864q2.368 2.294 2.368 5.698z",width:100,height:100},Po={path:"M15.1052249,9.55978547 L22.0028147,9.55978545 C23.6568673,9.55978545 23.9349557,10.3753626 22.6181351,11.3858845 L16.9943688,15.7015366 L19.2518801,22.8294455 C19.7526645,24.4106317 19.0984455,24.8825885 17.769353,23.8673293 L12.0490577,19.4977438 L6.5116497,23.8422153 C5.20921411,24.8640642 4.53299569,24.4067544 5.00266927,22.8160582 L7.10332364,15.7015366 L1.42794544,11.3634306 C0.110226041,10.3562014 0.383967283,9.54239221 2.0409646,9.54574013 L8.9924676,9.55978547 L11.1485117,2.72669438 C11.6458693,1.15043244 12.4548928,1.15900049 12.9494787,2.72669438 L15.1052249,9.55978547 Z",width:24,height:24},No={path:"M3.74890556,17.9799506 C2.19251241,16.1970909 1.10103636,13.4971457 1.13090903,11.1491783 C1.17160478,7.95052637 4.01704076,0.865059407 11.7028044,0.865059407 C19.388568,0.865059407 22.3026521,7.35203035 22.3026521,11.5879453 C22.3026521,15.8238603 19.386629,20.5574509 13.6832464,21.7131548 L13.6757539,17.3722171 C17.0812986,16.2190517 18.331158,14.1944123 18.3311578,11.5879451 C18.3311574,8.16554692 15.6664205,5.03476549 11.7028048,5.20494205 C7.73918903,5.37511861 5.59244567,8.66930079 5.59244567,11.1491783 C5.59244567,12.9090077 6.11128139,14.1753512 6.93640437,15.3053215 L8.14052356,14.2949456 C8.98559348,13.5858477 9.6994861,13.9070448 9.73489556,15.0076413 L9.91284941,20.5388014 C9.94832683,21.6415103 9.09967118,22.3514475 8.02194403,22.1254594 L2.60571602,20.9897332 C1.5259204,20.7633114 1.34338662,19.9984207 2.18070755,19.295825 L3.74890556,17.9799506 Z",width:23,height:23},Ao={path:"M31.293 37.506q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.218 0q-.912-.057-1.482-.627t-.57-1.482l0-37.506q0-2.109 2.052-2.109l4.218 0zm18.753 2.109l0 37.506q0 .912-.57 1.482t-1.539.627l-4.161 0q-1.995 0-2.109-2.109l0-37.506q.057-.912.627-1.482t1.482-.627l4.161 0q.969.057 1.539.627t.57 1.482zm14.592-2.109q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.161 0q-.969-.057-1.539-.627t-.57-1.482l0-37.506q0-2.109 2.109-2.109l4.161 0zm10.431 49.248l0-61.731l-58.368 0l0 61.731q.057 2.679.969 3.819t1.083 1.14l54.207 0q.171 0 1.14-1.083t.969-3.876zm-43.776-70.11l29.184 0l-3.135-7.581q-.456-.57-1.14-.741l-20.634 0q-.627.114-1.083.741zm-31.293 2.109q0-1.995 2.109-2.109l20.121 0l4.56-10.83q.969-2.394 3.477-4.104 2.565-1.71 5.187-1.71l20.805 0q2.622 0 5.187 1.71t3.477 4.104l4.56 10.83l20.178 0q.912.057 1.482.627t.57 1.482l0 4.161q0 1.995-2.052 2.109l-6.27 0l0 61.731q0 5.415-3.078 9.348t-7.353 3.933l-54.207 0q-4.275 0-7.353-3.819t-3.078-9.177l0-62.016l-6.213 0q-.969 0-1.539-.57t-.57-1.539l0-4.161z",width:91.681,height:100},Ro={path:"M10,6.6C10,7.2,9.8,8,9.3,9.1c0,0,0,0.1-0.1,0.1S9.2,9.3,9.2,9.4c0,0,0,0.1-0.1,0.1C9,9.6,9,9.6,8.9,9.6 c-0.1,0-0.1,0-0.1-0.1c0,0,0-0.1,0-0.1c0,0,0-0.1,0-0.1s0-0.1,0-0.1c0-0.3,0-0.5,0-0.7c0-0.4,0-0.7-0.1-1C8.6,7.1,8.5,6.9,8.4,6.7S8.2,6.3,8,6.1C7.8,5.9,7.6,5.8,7.4,5.7S6.9,5.5,6.7,5.5S6.1,5.4,5.8,5.4c-0.3,0-0.6,0-1,0H3.6v1.4c0,0.1,0,0.2-0.1,0.3C3.4,7.1,3.3,7.1,3.2,7.1C3.1,7.1,3,7.1,3,7L0.1,4.1C0,4.1,0,4,0,3.9s0-0.2,0.1-0.3L3,0.8C3,0.7,3.1,0.7,3.2,0.7c0.1,0,0.2,0,0.3,0.1C3.5,0.9,3.6,0.9,3.6,1v1.4h1.2c2.6,0,4.3,0.7,4.9,2.2C9.9,5.2,10,5.8,10,6.6z",width:10,height:10},Fo={path:"M8,13 L16,13 C16.5522847,13 17,12.5522847 17,12 C17,11.4477153 16.5522847,11 16,11 L8,11 C7.44771525,11 7,11.4477153 7,12 C7,12.5522847 7.44771525,13 8,13 Z",width:24,height:24};var Oo=Object.freeze({__proto__:null,iconCheck:yo,iconCheckMedium:bo,iconChevronDown:xo,iconChevronRight:wo,iconCircle:Co,iconCircleArrowDown:ko,iconCircleArrowUp:So,iconCircleThin:Eo,iconDesktop:{path:"M94.208 52.119l0-43.746q0-.69-.506-1.15t-1.196-.506l-84.088 0q-.69 0-1.196.506t-.506 1.15l0 43.746q0 .69.506 1.196t1.196.506l84.088 0q.69 0 1.196-.506t.506-1.196zm6.716-43.746l0 57.224q0 3.45-2.484 5.934t-5.934 2.484l-28.566 0q0 3.128 2.53 7.774.828 1.61.828 2.622t-1.012 2.07q-1.012 1.012-2.346.966l-26.91 0q-1.38 0-2.392-1.012t-1.012-2.024q0-1.058 1.656-4.14t1.748-6.256l-28.612 0q-3.45 0-5.934-2.484t-2.484-5.934l0-57.224q0-3.45 2.484-5.934t5.934-2.438l84.088 0q3.45 0 5.98 2.438 2.438 2.484 2.438 5.934z",width:100,height:86.648},iconDropdownArrow:{path:"M9 9.8c0 .5.7 1.7 1.5 2.8 1.5 1.9 1.5 1.9 3 0C15.7 9.7 15.4 9 12 9c-1.6 0-3 .4-3 .8z",width:24,height:24},iconExclamationSign:_o,iconGear:{path:"M1152 896q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm512-109v222q0 12-8 23t-20 13l-185 28q-19 54-39 91 35 50 107 138 10 12 10 25t-9 23q-27 37-99 108t-94 71q-12 0-26-9l-138-108q-44 23-91 38-16 136-29 186-7 28-36 28h-222q-14 0-24.5-8.5t-11.5-21.5l-28-184q-49-16-90-37l-141 107q-10 9-25 9-14 0-25-11-126-114-165-168-7-10-7-23 0-12 8-23 15-21 51-66.5t54-70.5q-27-50-41-99l-183-27q-13-2-21-12.5t-8-23.5v-222q0-12 8-23t19-13l186-28q14-46 39-92-40-57-107-138-10-12-10-24 0-10 9-23 26-36 98.5-107.5t94.5-71.5q13 0 26 10l138 107q44-23 91-38 16-136 29-186 7-28 36-28h222q14 0 24.5 8.5t11.5 21.5l28 184q49 16 90 37l142-107q9-9 24-9 13 0 25 10 129 119 165 170 7 8 7 22 0 12-8 23-15 21-51 66.5t-54 70.5q26 50 41 98l183 28q13 2 21 12.5t8 23.5z",width:1792,height:1792},iconMobilePhone:{path:"M36.04 89.557q0-2.584-1.836-4.42t-4.42-1.836-4.352 1.836q-1.836 1.836-1.836 4.42t1.836 4.352 4.42 1.836q2.652-.068 4.42-1.836t1.768-4.352zm16.184-12.444l0-54.74q0-1.088-.748-1.768t-1.768-.68l-39.78 0q-1.088 0-1.768.748t-.68 1.7l0 54.74q0 1.02.748 1.768t1.7.68l39.78 0q1.02-.068 1.768-.748t.748-1.7zm-14.892-65.892q0-1.224-1.292-1.292l-12.444 0q-1.224.068-1.224 1.292t1.224 1.224l12.444 0q1.292 0 1.292-1.224zm22.372-1.292l0 79.628q0 3.944-2.992 6.936t-7.004 2.992l-39.78 0q-4.012 0-7.004-2.924-2.924-2.924-2.924-7.004l0-79.628q0-4.012 2.924-6.936t7.004-2.992l39.78 0q4.012-.068 7.004 2.924t2.992 7.004z",width:60.013,height:100},iconOk:To,iconPlus:Mo,iconRemove:Io,iconStar:Po,iconTryAgain:No,iconTablet:{path:"M45.322 90.706q0-1.86-1.302-3.224-1.364-1.364-3.224-1.364t-3.224 1.364-1.302 3.224q0 1.86 1.364 3.224 1.302 1.364 3.162 1.302 1.86.062 3.224-1.302t1.302-3.224zm27.218-11.346l0-68.014q0-.93-.682-1.612t-1.55-.682l-58.962 0q-.93 0-1.612.682t-.682 1.612l0 68.014q0 .93.682 1.612t1.612.62l58.962 0q.992-.062 1.612-.682t.62-1.55zm9.114-68.014l0 77.066q0 4.65-3.348 7.998t-7.998 3.348l-58.962 0q-4.65 0-7.998-3.348t-3.348-7.998l0-77.066q0-4.65 3.348-7.998t7.998-3.348l58.962 0q4.65 0 7.998 3.348t3.348 7.998z",width:81.852,height:100},iconTrash:Ao,iconUndo:Ro,iconMinus:Fo});const Do={constrain:function(){this.constrain()}};Do.standard=[Do.constrain];const Lo={draw:function(){this.draw()}};Lo.standard=[Lo.draw];const Bo={basic:function(e,t){const n=this.graphie;if(!this.state.visibleShape){const t=[this.pointSize()/n.scale[0],this.pointSize()/n.scale[1]],o={maxScale:Math.max(this.highlightStyle().scale,this.normalStyle().scale),padding:10,shadow:e.shadow};this.state.visibleShape=new An(n,this.coord(),t,o),this.state.visibleShape.attr(M.default.omit(this.normalStyle(),"scale")),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}e.normalStyle===t.normalStyle||M.default.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.moveTo(this.coord()),this.mouseTarget()&&this.mouseTarget().moveTo(this.coord())},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};Bo.standard=[Bo.basic,Bo.highlight];const zo={basic:function(){this.state.visibleShape&&(this.state.visibleShape.remove(),this.state.visibleShape=null)}};zo.standard=zo.basic;const qo={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,p.point.roundTo(t,e))}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(o,s,i){const r=this.graphie;e=e||r.range,void 0===t&&(t=r.snap);let a=r.unscalePoint([n,r.ypixels-n]),l=r.unscalePoint([r.xpixels-n,n]);if(t&&(a=p.point.ceilTo(a,t),l=p.point.floorTo(l,t)),i&&i.onOutOfBounds)return(o[0]>l[0]||o[0]<a[0]||o[1]>l[1]||o[1]<a[1])&&(i.onSkipRemaining(),i.onOutOfBounds()),o;return[Math.max(a[0],Math.min(l[0],o[0])),Math.max(a[1],Math.min(l[1],o[1]))]}},standard:null};var Ho={add:Do,modify:Lo,draw:Bo,remove:zo,onMoveStart:{standard:null},constraints:qo,onMove:{standard:null},onMoveEnd:{standard:null},onClick:{standard:null}};const Wo=mn.assert,Uo=mn.normalizeOptions,{processMath:Go}=Cn,Vo=M.default.keys(Ho),jo={coord:[0,0],pointSize:4,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,shadow:!1,tooltip:!1},Yo={added:!1,hasMoved:!1,visibleShape:null,outOfBounds:!1,mouseTarget:null,touchOffset:null},$o=[],Xo=function(e,t,n){M.default.extend(this,{graphie:e,movable:t,state:{id:M.default.uniqueId("movablePoint")}}),this.modify(M.default.extend({},Yo,n))};function Ko(e){const t=M.default.zip(e,e.slice(1).concat(e.slice(0,1))),n=M.default.map(t,(function(e){const t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])}));return o=n,M.default.reduce(o,(function(e,t){return e+t}),0)>0;var o}M.default.extend(Xo,Ho),mn.createGettersFor(Xo,M.default.extend({},jo,Yo)),mn.addMovableHelperMethodsTo(Xo),M.default.extend(Xo.prototype,{cloneState:function(){return M.default.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id},Uo(Vo,In.pluck(Ho,"standard")),jo)},modify:function(e){this.update(M.default.extend(this._createDefaultState(),e))},_showTooltip:function(e){this._tooltip||(this._tooltip=document.createElement("div"),this._tooltip.className="tooltip-content",this.state.visibleShape.wrapper.className="tooltip",this.state.visibleShape.wrapper.appendChild(this._tooltip),$o.push((()=>{this.state.added&&this._hideTooltip()}))),this._tooltip.firstChild&&this._tooltip.removeChild(this._tooltip.firstChild),this.state.visibleShape.wrapper.className="tooltip visible",this._tooltip.appendChild(document.createElement("span")),"string"==typeof e?Go(this._tooltip.firstChild,e,!1):"function"==typeof e?e(this._tooltip.firstChild):this._tooltip.firstChild.appendChild(e)},_hideTooltip:function(){this._tooltip&&(this.state.visibleShape.wrapper.className="tooltip")},update:function(e){const t=this,n=t.graphie,o=M.default.extend(t.state,Uo(Vo,e));Wo(p.point.is(o.coord));const s=o.static?bn.DYNAMIC:bn.INTERACTIVE;if(o.normalStyle=M.default.extend({fill:s,stroke:s,scale:1},o.normalStyle),o.highlightStyle=M.default.extend({fill:bn.INTERACTING,stroke:bn.INTERACTING,scale:2},o.highlightStyle),!o.static&&!o.mouseTarget){const e=t.state.coord,s=n.unscaleVector(24),i={mouselayer:!0,padding:0,interactiveKindForTesting:"movable-point"};o.mouseTarget=new An(n,e,s,i),o.mouseTarget.attr({fill:"#000",opacity:0})}const i=()=>{this._showTooltip((e=>{A.render(_.createElement("span",{style:{fontSize:"2em"}},_.createElement(V,G({},Ao,{style:{position:"static",color:bn.INTERACTIVE,marginLeft:9,marginRight:9}}))),e)}))};let r=o.coord;t.movable.modify(M.default.extend({},o,{add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:e=>{if(o.hasMoved=!1,r=o.coord,null==o.touchOffset){const t=!("ontouchstart"in window);o.touchOffset=t?[0,0]:p.vector.subtract(r,e)}const n=o.visibleShape.wrapper;if(o.shadow){const e="none";n.style.webkitFilter=e,n.style.filter=e}if(o.showHairlines&&o.showHairlines(o.coord),$o.forEach((e=>e())),o.tooltip&&(o.xOnlyTooltip?this._showTooltip("".concat(o.coord[0])):this._showTooltip("(".concat(o.coord[0],", ").concat(o.coord[1],")")),o.shadow)){const e=n.getElementsByClassName("tooltip-content")[0],t="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=t,e.style.filter=t}t._fireEvent(o.onMoveStart,r,r),t.draw()},onMove:(e,n)=>{const s=p.vector.add(e,o.touchOffset);t.moveTo(s),o.showHairlines&&(this.state.outOfBounds?o.hideHairlines():o.showHairlines(o.coord)),o.tooltip&&(this.state.outOfBounds||(o.xOnlyTooltip?this._showTooltip("".concat(o.coord[0])):this._showTooltip("(".concat(o.coord[0],", ").concat(o.coord[1],")")))),o.onRemove&&this.state.outOfBounds&&i()},onMoveEnd:()=>{t.isHovering()&&!o.hasMoved&&t._fireEvent(o.onClick,o.coord,r);const e=o.visibleShape.wrapper;if(o.shadow){const t="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=t,e.style.filter=t}if(o.hideHairlines&&o.hideHairlines(),o.hasMoved)this._hideTooltip();else if(o.onRemove){i();const t=e.getElementsByClassName("tooltip-content")[0];t.style.webkitFilter="none",t.style.filter="none",this._tooltip.firstChild.addEventListener("touchstart",(e=>{e.stopPropagation()}),!0),this._tooltip.firstChild.addEventListener("touchend",(e=>{o.onRemove(),e.stopPropagation()}),!0)}else o.tooltip&&this._hideTooltip();o.outOfBounds&&o.onRemove(),t._fireEvent(o.onMoveEnd,o.coord,r),o.hasMoved=!1,o.touchOffset=null,t.draw()}})),o.added||(t.prevState={},t._fireEvent(o.add,t.cloneState(),t.prevState),o.added=!0,t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){const e=this._applyConstraints(this.coord(),this.coord());return p.point.is(e)&&this.setCoord(e),!1!==e},setCoord:function(e){Wo(p.point.is(e,2)),this.state.coord=M.default.clone(e),this.draw()},setCoordConstrained:function(e){Wo(p.point.is(e,2));const t=this._applyConstraints(e,this.coord());!1!==t&&(this.state.coord=M.default.clone(t),this.draw())},moveTo:function(e){const t=this.state;this.state.outOfBounds=!1;const n=this._applyConstraints(e,t.coord,t.onRemove?{onOutOfBounds:()=>{this.state.outOfBounds=!0}}:{});if(!1!==n&&(p.point.is(n)&&(e=n),!p.point.equal(e,t.coord))){const n=t.coord;t.coord=e,t.hasMoved=!0,this._fireEvent(t.onMove,t.coord,n),this.draw()}},normalStyle:function(){return M.default.clone(this.state.normalStyle)},highlightStyle:function(){return M.default.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()},grab:function(e){this.state.touchOffset=[0,0],this.movable.grab(e),this.moveTo(e)}});const Zo={constrain:function(){this.constrain()},pointsToFront:function(e){M.default.invoke(e.points,"toFront")}};Zo.standard=[Zo.constrain,Zo.pointsToFront];const Jo={draw:function(){this.draw()}};Jo.standard=[Jo.draw];const Qo={basic:function(e,t){const n=this.graphie,o=this.path(e);this.state.visibleShape||(this.state.visibleShape=n.raphael.path(o),this.state.visibleShape.attr(this.normalStyle())),e.normalStyle===t.normalStyle||M.default.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.attr({path:o}),this.mouseTarget()&&this.mouseTarget().attr({path:o})},labels:function(e,t){const n=this.graphie,o=this,s=M.default.invoke(e.points,"coord"),i=Ko(s),r=s.length;null!=o.state._labelCache&&M.default.invoke(o.state._labelCache,"remove"),o.state._labelCache=[],(e.angleLabels.length||e.showRightAngleMarkers.length)&&(null==o.state._labeledAngles&&(o.state._labeledAngles=M.default.times(Math.max(e.angleLabels.length,e.showRightAngleMarkers.length),(function(){return n.label([0,0],"","center",e.labelStyle)}))),M.default.each(o.state._labeledAngles,(function(t,a){o.state._labelCache.push(n.labelAngle({point1:s[(a-1+r)%r],vertex:s[a],point3:s[(a+1)%r],label:t,text:e.angleLabels[a],showRightAngleMarker:e.showRightAngleMarkers[a],numArcs:e.numArcs[a],clockwise:i,style:e.labelStyle}))}))),e.sideLabels.length&&(null==o.state._labeledSides&&(o.state._labeledSides=M.default.map(e.sideLabels,(function(t){return n.label([0,0],"","center",e.labelStyle)}))),M.default.each(o.state._labeledSides,(function(t,a){o.state._labelCache.push(n.labelSide({point1:s[a],point2:s[(a+1)%r],label:t,text:e.sideLabels[a],numArrows:e.numArrows[a],numTicks:e.numTicks[a],clockwise:i,style:e.labelStyle}))}))),e.vertexLabels.length&&(null==o.state._labeledVertices&&(o.state._labeledVertices=M.default.map(e.vertexLabels,(function(t){return n.label([0,0],"","center",e.labelStyle)}))),M.default.each(o.state._labeledVertices,(function(t,a){o.state._labelCache.push(n.labelVertex({point1:s[(a-1+r)%r],vertex:s[a],point3:s[(a+1)%r],label:t,text:e.vertexLabels[a],clockwise:i,style:e.labelStyle}))}))),o.state._labelCache=M.default.flatten(o.state._labelCache)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};Qo.standard=[Qo.basic,Qo.labels,Qo.highlight];const es={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},labels:function(){const e=[this.state._labeledSides,this.state._labeledVertices,this.state._labeledAngles,this.state._labelCache];M.default.each(e,(function(e){null!=e&&e.length&&M.default.invoke(e,"remove")}))}};es.standard=[es.basic,es.labels];const ts={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,p.point.roundTo(t,e))}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(o,s){const i=this.graphie,r=p.vector.subtract(o,s);e=e||i.range,void 0===t&&(t=i.snap);let a=i.unscalePoint([n,i.ypixels-n]),l=i.unscalePoint([i.xpixels-n,n]);t&&(a=p.point.ceilTo(a,t),l=p.point.floorTo(l,t));const c=M.default.map(this.coords(),(function(e,t){const n=p.vector.subtract(l,e);return[p.vector.subtract(a,e),n]})),d=M.default.reduce(c,(function(e,t){const n=t[0],o=t[1];return[Math.max(n[0],Math.min(o[0],e[0])),Math.max(n[1],Math.min(o[1],e[1]))]}),r);return p.vector.add(s,d)}},standard:null},ns={updatePoints:function(e,t){const n=p.vector.subtract(e,t);M.default.each(this.state.points,(function(e){e.setCoord(p.vector.add(e.coord(),n))}))},standard:null};var os={add:Zo,modify:Jo,draw:Qo,remove:es,onMoveStart:{standard:null},constraints:ts,onMove:ns,onMoveEnd:{standard:null},onClick:{standard:null}};const ss=mn.assert,is=mn.normalizeOptions,rs=M.default.keys(os),as={points:null,angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],closed:!0,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,labelStyle:null},ls={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},cs=function(e,t,n){ss(null!=e),ss(null!=n),M.default.extend(this,{graphie:e,movable:t,state:{id:M.default.uniqueId("movablePolygon")}}),this.modify(M.default.extend({},ls,n))};M.default.extend(cs,os),mn.createGettersFor(cs,M.default.extend({},as,ls)),mn.addMovableHelperMethodsTo(cs),M.default.extend(cs.prototype,{cloneState:function(){return M.default.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id},is(rs,In.pluck(os,"standard")),as)},modify:function(e){this.update(M.default.extend(this._createDefaultState(),e))},update:function(e){const t=this,n=t.graphie,o=M.default.extend(t.state,is(rs,e)),s=o.static?bn.DYNAMIC:bn.INTERACTIVE;o.normalStyle=M.default.extend({},o.normalStyle,{"stroke-width":2,"fill-opacity":0,fill:s,stroke:s},e.normalStyle),o.highlightStyle=M.default.extend({},{stroke:bn.INTERACTING,"stroke-width":2,fill:bn.INTERACTING,"fill-opacity":.05},o.highlightStyle),o.labelStyle=M.default.extend({},{stroke:bn.DYNAMIC,"stroke-width":1,color:bn.DYNAMIC},o.labelStyle),o.static||o.mouseTarget||(o.mouseTarget=n.mouselayer.path(this.path()),o.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"})),t.movable.modify(M.default.extend({},o,{modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){const o=p.vector.subtract(e,n);t._totalDelta=p.vector.add(t._totalDelta,o);let s=p.vector.add(t._initialRefCoord,t._totalDelta);s=t._applyConstraints(s,t._prevRefCoord),!1!==s&&(t._fireEvent(t.state.onMove,s,t._prevRefCoord),t._prevRefCoord=s)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),M.default.invoke(o.points,"listen","onMove",o.id,t.draw.bind(t)),o.added||(t.prevState={},t._fireEvent(o.add,t.cloneState(),t.prevState),o.added=!0,t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},path:function(e){const t=this.graphie;e=e||this.state;let n=M.default.map(e.points,(function(e){return t.scalePoint(e.coord())}));return e.closed?n.push(!0):n=n.concat(M.default.clone(n).reverse()),En.unscaledSvgPath(n)},coords:function(){return M.default.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.points&&M.default.invoke(this.state.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){if(null==this.points||0===this.points.length)return;const e=this.coord(0),t=this._applyConstraints(e,e);!1!==t&&this._fireEvent(this.state.onMove,t,e)},normalStyle:function(){return M.default.clone(this.state.normalStyle)},highlightStyle:function(){return M.default.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}});const ds=mn.normalizeOptions,ps=mn.assert,us=["add","modify","draw","remove","onMoveStart","onMove","onMoveEnd","onClick"],hs={cursor:null},fs={added:!1,isHovering:!1,isMouseOver:!1,isDragging:!1,mouseTarget:null},ms=function(e,t){M.default.extend(this,{graphie:e,state:{id:M.default.uniqueId("movable")}}),this.modify(M.default.extend({},fs,t))};mn.createGettersFor(ms,M.default.extend({},hs,fs)),mn.addMovableHelperMethodsTo(ms),M.default.extend(ms.prototype,{cloneState:function(){return M.default.clone(this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id,add:[],modify:[],draw:[],remove:[],onMoveStart:[],onMove:[],onMoveEnd:[],onClick:[]},hs)},modify:function(e){this.update(M.default.extend({},this._createDefaultState(),e))},grab:function(e){ps(p.point.is(e));const t=this,n=t.graphie,o=t.state;o.isHovering=!0,o.isDragging=!0,n.isDragging=!0;const s=e;let i=s;t._fireEvent(o.onMoveStart,s,s);const r=function(e){e.preventDefault();const s=n.getMouseCoord(e);t._fireEvent(o.onMove,s,i),t.draw(),i=s},a=function(e){P.default(document).unbind("vmousemove",r),P.default(document).unbind("vmouseup",a),o.isHovering&&t._fireEvent(o.onClick,i,s),o.isHovering=t.state.isMouseOver,o.isDragging=!1,n.isDragging=!1,t._fireEvent(o.onMoveEnd,i,s),t.draw()};P.default(document).bind("vmousemove",r),P.default(document).bind("vmouseup",a)},update:function(e){const t=this,n=t.graphie,o=t.cloneState(),s=M.default.extend(t.state,ds(us,e));if(s.mouseTarget&&!o.mouseTarget){let e;e=s.mouseTarget.getMouseTarget?P.default(s.mouseTarget.getMouseTarget()):P.default(s.mouseTarget[0]);!("ontouchstart"in window)&&(e.on("vmouseover",(function(){s.isMouseOver=!0,n.isDragging||(s.isHovering=!0),t.state.added&&t.draw()})),e.on("vmouseout",(function(){s.isMouseOver=!1,s.isDragging||(s.isHovering=!1),t.state.added&&t.draw()}))),e[0].addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),e.on("vmousedown",(function(e){if(0!==e.which&&1!==e.which)return;e.preventDefault();const o=n.getMouseCoord(e);t.grab(o)}))}if(s.mouseTarget&&void 0!==s.cursor){let e;e=s.mouseTarget.getMouseTarget?P.default(s.mouseTarget.getMouseTarget()):P.default(s.mouseTarget[0]),e.css("cursor",s.cursor||"")}s.added||(t._fireEvent(s.modify,t.cloneState(),{}),s.added=!0,t.prevState=t.cloneState()),t._fireEvent(s.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.mouseTarget&&(P.default(this.state.mouseTarget).off(),this.state.mouseTarget.remove(),this.state.mouseTarget=null)},toBack:function(){this.state.mouseTarget&&this.state.mouseTarget.toBack()},toFront:function(){this.state.mouseTarget&&this.state.mouseTarget.toFront()}});const gs={MovablePoint:Xo,addMovablePoint:function(e,t){const n=new ms(e,{});return new Xo(e,n,t)},MovableLine:vo,addMovableLine:function(e,t){const n=new ms(e,{});return new vo(e,n,t)},MovablePolygon:cs,addMovablePolygon:function(e,t){const n=new ms(e,{});return new cs(e,n,t)},addMaybeMobileMovablePoint:function(e,t){const n=e.props.apiOptions.isMobile,o=n?{stroke:"#ffffff","stroke-width":3,fill:bn.INTERACTIVE}:{stroke:bn.INTERACTIVE,fill:bn.INTERACTIVE},s=Object.assign(o,t.normalStyle),i=Object.assign(n?{...o,"stroke-width":0,scale:.75}:{},t.highlightStyle),r=Object.assign({normalStyle:s,highlightStyle:i,shadow:n,tooltip:n&&e.props.showTooltips,showHairlines:e.showHairlines,hideHairlines:e.hideHairlines},n?{pointSize:7}:{});return gs.addMovablePoint(e.graphie,Object.assign(t,r))}},vs=eo.createClass({displayName:"MovablePoint",movableProps:["children"],_getProps:function(){if(this.props.isMobile){const e=this.props.isMobile,t=e?{stroke:"#ffffff","stroke-width":3,fill:bn.INTERACTIVE}:{stroke:bn.INTERACTIVE,fill:bn.INTERACTIVE},n=e?Object.assign(t,this.props.mobileStyleOverride||{}):Object.assign(t,this.props.normalStyle),o=e?{...t,"stroke-width":0,scale:.75}:this.props.highlightStyle,s=Object.assign({normalStyle:n,highlightStyle:o,shadow:e,tooltip:e&&this.props.showTooltips},e?{pointSize:7}:{});return Object.assign(this.props,s)}return this.props},add:function(e){this.point=gs.addMovablePoint(e,this._getProps())},modify:function(){this.point.modify(this._getProps())},remove:function(){this.point.remove()},toFront:function(){this.point.toFront()},grab:function(e){this.point.grab(e)}});M.default.extend(vs,gs.MovablePoint);const ys=eo.createClass({displayName:"MovableLine",movableProps:["children"],add:function(e){const t=M.default.pluck(this.props.children,"point"),n=M.default.extend({},this.props,{points:t});this.line=gs.addMovableLine(e,n)},modify:function(){const e=M.default.pluck(this.props.children,"point"),t=M.default.extend({},this.props,{points:e});this.line.modify(t)},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}});M.default.extend(ys,gs.MovableLine);const bs=eo.createSimpleClass(((e,t)=>{let n=t.coord;t.unscaled&&(n=e.unscalePoint(n));let o=null;return Y().JIPT.useJIPT?(o=e.label(n,t.text,t.direction,!1,t.style),Y().graphieMovablesJiptLabels.addLabel(o,t.tex)):o=e.label(n,t.text,t.direction,t.tex,t.style),o})),xs=eo.createClass({displayName:"Line",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.line=this.graphie.line(t.start,t.end,t.style)},modify:function(){const e=this.props,t=this.graphie.svgPath([e.start,e.end]);this.line.attr(M.default.extend({},e.style,{path:t}))},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}}),ws=eo.createClass({displayName:"Parabola",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.parabola=this.graphie.parabola(t.a,t.b,t.c,t.style)},modify:function(){const e=this.props,t=this.graphie.svgParabolaPath(e.a,e.b,e.c);this.parabola.attr(M.default.extend({},e.style,{path:t}))},remove:function(){this.parabola.remove()},toFront:function(){this.parabola.toFront()}}),Cs=eo.createClass({displayName:"Sinusoid",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.sinusoid=this.graphie.sinusoid(t.a,t.b,t.c,t.d,t.style)},modify:function(){const e=this.props,t=this.graphie.svgSinusoidPath(e.a,e.b,e.c,e.d);this.sinusoid.attr(M.default.extend({},e.style,{path:t}))},remove:function(){this.sinusoid.remove()},toFront:function(){this.sinusoid.toFront()}}),ks=eo.createSimpleClass(((e,t)=>e.plot(t.fn,t.range,t.style))),Ss=eo.createSimpleClass(((e,t)=>e.plotParametric(t.fn,t.range,t.style))),Es=eo.createSimpleClass(((e,t)=>e.ellipse(t.coord,e.unscaleVector([4,4]),{fill:t.color||bn.BLACK,stroke:t.color||bn.BLACK}))),_s=eo.createClass({displayName:"Path",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.path=this.graphie.path(t.coords,t.style)},modify:function(){const e=this.props,t=this.graphie.svgPath(e.coords);this.path.attr({path:t})},remove:function(){this.path.remove()},toFront:function(){this.path.toFront()}});var Ts={Arc:eo.createSimpleClass(((e,t)=>{let n=t.center,o=t.radius;return t.unscaled&&(n=e.unscalePoint(n),o=e.unscaleVector(o)),e.arc(n,o,t.startAngle,t.endAngle,t.sector,t.style)})),Circle:eo.createSimpleClass(((e,t)=>e.circle(t.center,t.radius,t.style))),Label:bs,Line:xs,MovableLine:ys,MovablePoint:vs,Parabola:ws,Path:_s,Plot:ks,PlotParametric:Ss,Point:Es,Sinusoid:Cs,Rect:eo.createSimpleClass(((e,t)=>e.rect(t.x,t.y,t.width,t.height,t.style)))};const Ms=eo.GraphieMovable,Is=En.createGraphie,{deepEq:Ps,nestedMap:Ns}=Ye,{assert:As}=mn;class Rs extends _.Component{constructor(){super(...arguments),U(this,"getGraphie",(()=>this._graphie)),U(this,"_range",(()=>M.default.map(this.props.range,(e=>e[0]>=e[1]?[-10,10]:e)))),U(this,"_box",(()=>M.default.map(this.props.box,(e=>e>0?e:340)))),U(this,"_scale",(()=>{const e=this._box(),t=this._range();return M.default.map(e,((e,n)=>e/(t[n][1]-t[n][0])))})),U(this,"_setupGraphie",(()=>{this._removeMovables();const e=N.default.findDOMNode(this.refs.graphieDiv);P.default(e).empty();const t=this._graphie=Is(e);t.init({range:this._range(),scale:this._scale(),isMobile:this.props.isMobile}),this.props.addMouseLayer&&t.addMouseLayer({onClick:this.props.onClick,onMouseDown:this.props.onMouseDown,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),t.snap=this.props.options.snapStep||[1,1],this.props.responsive&&(P.default(e).css({width:"100%",height:"100%"}),t.raphael.setSize("100%","100%")),this.props.setup(t,M.default.extend({range:this._range(),scale:this._scale()},this.props.options))})),U(this,"_removeMovables",(()=>{M.default.invoke(this._movables,"remove"),this._movables={}})),U(this,"_renderMovables",((e,t)=>{const n=t.graphie,o=t.oldMovables,s=t.newMovables,i=e=>{M.default.each(e.movableProps,(n=>{e.props[n]=this._renderMovables(e.props[n],t)}))};let r=!1;return Ns(e,(e=>{if(!e)return t.nextKey++,e;const a=new e.type(e.props);As(a instanceof Ms,"All children of a Graphie component must be Graphie movables");const l=e.key,c=null==l?"_no_id_"+t.nextKey:l;t.nextKey++;const d=e.ref;i(a);const p=o[c];if(p)if(a.constructor===p.constructor){p.props=a.props;"reordered"===p.modify(n)&&(r=!0),s[c]=p}else null==l&&xe.error("Replacing a <Graphie> child with a child of a different type. Please add keys to your <Graphie> children",be.Internal),p.remove(),a.add(n),r=!0,s[c]=a;else a.add(n),r=!0,s[c]=a;return r&&s[c].toFront(),d&&(this.movables[d]=s[c]),s[c]}))})),U(this,"_updateMovables",(()=>{const e=this._graphie,t=this._movables,n={};this._movables=n,this.movables={},this._renderMovables(this.props.children,{nextKey:1,graphie:e,oldMovables:t,newMovables:n}),M.default.each(t,((e,t)=>{n[t]||e.remove()}))}))}componentDidMount(){this._setupGraphie(),this._updateMovables()}shouldComponentUpdate(e){return!M.default.isEqual(this.props,e)}componentDidUpdate(e){this.props.setup!==e.setup&&xe.error("<Graphie> was given a new setup function. This is a bad idea; please refactor your code to give the same setup function reference to <Graphie> on every render.",be.Internal),Ps(this.props.options,e.options)&&Ps(this.props.box,e.box)&&Ps(this.props.range,e.range)||this._setupGraphie(),this._updateMovables()}render(){return _.createElement("div",{className:"graphie-container"},_.createElement("div",{className:"graphie",ref:"graphieDiv"}))}}U(Rs,"propTypes",{addMouseLayer:I.default.bool,box:I.default.arrayOf(I.default.number).isRequired,children:I.default.node,isMobile:I.default.bool,onClick:I.default.func,onMouseDown:I.default.func,onMouseMove:I.default.func,onMouseUp:I.default.func,options:I.default.shape({snapStep:I.default.arrayOf(I.default.number)}),range:I.default.arrayOf(I.default.arrayOf(I.default.number)),responsive:I.default.bool,setDrawingAreaAvailable:I.default.func,setup:I.default.func.isRequired}),U(Rs,"defaultProps",{range:[[-10,10],[-10,10]],options:{},responsive:!1,addMouseLayer:!0}),M.default.extend(Rs,eo),M.default.extend(Rs,Ts);const Fs="pending",Os="loading",Ds="loaded",Ls="failed";class Bs extends _.Component{constructor(e){super(e),U(this,"img",void 0),U(this,"createLoader",(()=>{this.destroyLoader(),this.img=new Image,this.img.onload=this.handleLoad,this.img.onerror=this.handleError,this.img.src=this.props.src})),U(this,"destroyLoader",(()=>{this.img&&(this.img.onload=null,this.img.onerror=null,this.img=null)})),U(this,"handleLoad",(e=>{this.destroyLoader(),this.setState({status:Ds}),this.props.onLoad&&this.props.onLoad(e)})),U(this,"handleError",(e=>{this.destroyLoader(),this.setState({status:Ls}),this.props.onError&&this.props.onError(e)})),U(this,"renderImg",(()=>{const{src:e,imgProps:t}=this.props;let n=null,o=null;null!=t.onClick&&(n=e=>{13!==e.keyCode&&32!==e.keyCode||t.onClick&&t.onClick(e)},o=e=>{32===e.keyCode&&e.preventDefault()});const s=Y().staticUrl;return _.createElement("img",G({src:s(e),onKeyUp:n,onKeyDown:o},t))})),this.state={status:e.src?Os:Fs}}componentDidMount(){this.state.status===Os&&this.createLoader()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({status:e.src?Os:Fs})}componentDidUpdate(e,t){this.state.status!==Os||this.img||this.createLoader(),t.status!==this.state.status&&this.props.onUpdate(this.state.status)}componentWillUnmount(){this.destroyLoader()}render(){switch(this.state.status){case Ds:return this.renderImg();case Ls:if(this.props.children)return this.props.children;break;default:if(this.props.preloader)return this.props.preloader()}return null}}const zs={},qs=/^file\+graphie\:/,Hs=/\/([^/]+)$/;function Ws(e){return/\.(jpg|jpeg)$/i.test(e)}function Us(){const{JIPT:e,kaLocale:t}=Y();return e.useJIPT?"en-pt":t}function Gs(){return"en"!==Us()}const Vs=/\/(?=[^/]+$)/;function js(e){return _.createElement("span",{style:{background:"url(/images/spinner.gif) no-repeat",backgroundPosition:"center",width:"100%",height:"100%",position:"absolute",minWidth:"20px"}})}class Ys extends _.Component{constructor(e){super(e),U(this,"_isMounted",void 0),U(this,"onDataLoaded",((e,t)=>{if(this._isMounted&&e.labels&&e.range){const n=e.labels.reduce(((e,t)=>({...e,[t.content]:!1})),{});this.setState({dataLoaded:!0,labelDataIsLocalized:t,labelsRendered:n,labels:e.labels,range:e.range})}})),U(this,"onImageLoad",(()=>{this.sizeProvided()?this.setState({imageLoaded:!0}):Ye.getImageSize(this.props.src,((e,t)=>{this._isMounted&&this.setState({imageLoaded:!0,imageDimensions:[e,t]})}))})),U(this,"setupGraphie",((e,t)=>{M.default.map(t.labels,(t=>{const{JIPT:n}=Y();if(n.useJIPT&&this.state.labelDataIsLocalized){const n=e.label(t.coordinates,t.content,t.alignment,!1);Y().svgImageJiptLabels.addLabel(n,t.typesetAsMath)}else if(t.coordinates){const n=e.label(t.coordinates,t.content,t.alignment,t.typesetAsMath,{"font-size":100*this.props.scale+"%"}),o=n[0].style;let s=this._tryGetPixels(o.top),i=this._tryGetPixels(o.left);if(null===s||null===i){const e=n.position();s=e.top,i=e.left}const r=(this.props.height||0)*this.props.scale,a=(this.props.width||0)*this.props.scale;n.css({top:s/r*100+"%",left:i/a*100+"%"}),M.default.each(t.style,((e,t)=>{n.css(t,e)}))}this.setState({labelsRendered:{...this.state.labelsRendered,[t.content]:!0}})}))})),U(this,"_handleZoomClick",(e=>{(P.default(e.target).width()<this.props.width||this.props.zoomToFullSizeOnMobile)&&cn.handleZoomClick(e,this.props.zoomToFullSizeOnMobile),this.props.trackInteraction&&this.props.trackInteraction()})),U(this,"handleUpdate",(e=>{this.props.onUpdate(),Ye.isLabeledSVG(this.props.src)||"loaded"!==e||this.setState({imageLoaded:!0})})),e.setAssetStatus(e.src,!1),this._isMounted=!1,this.state={imageLoaded:!1,imageDimensions:null,dataLoaded:!1,labelDataIsLocalized:!1,labels:[],labelsRendered:{},range:[[0,0],[0,0]]}}componentDidMount(){this._isMounted=!0,Ye.isLabeledSVG(this.props.src)&&this.loadResources()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({imageLoaded:!1,dataLoaded:!1})}shouldComponentUpdate(e,t){if(!M.default.isEqual(this.props,e))return!0;return this.isLoadedInState(this.state)!==this.isLoadedInState(t)}componentDidUpdate(e,t){const n=this.isLoadedInState(t),o=this.isLoadedInState(this.state);Ye.isLabeledSVG(this.props.src)&&!o&&this.loadResources(),!n&&o&&this.props.setAssetStatus(this.props.src,!0)}componentWillUnmount(){this._isMounted=!1}isLoadedInState(e){return Ye.isLabeledSVG(this.props.src)?e.imageLoaded&&e.dataLoaded:e.imageLoaded}loadResources(){const e=function(e){const t=e.match(Hs);if(null==t)throw new we("not a valid URL",be.InvalidInput);return t&&t[1]}(this.props.src);if(zs[e])if(zs[e].loaded){const{data:t,localized:n}=zs[e];this.onDataLoaded(t,n)}else zs[e].dataCallbacks.push(this.onDataLoaded);else{const t={loaded:!1,dataCallbacks:[this.onDataLoaded],data:null,localized:Gs()};zs[e]=t;const n=(n,o)=>{!function(e,t){t={callbackName:"callback",success:P.default.noop,error:P.default.noop,...t};const n=document.createElement("script");function o(){document.head&&document.head.removeChild(n),delete window[t.callbackName]}n.setAttribute("async",""),n.setAttribute("src",e),window[t.callbackName]=function(){o(),t.success.apply(null,arguments)},n.addEventListener("error",(function(){o(),t.error.apply(null,arguments)})),document.head&&document.head.appendChild(n)}(n,{callbackName:"svgData"+e,success:e=>{t.data=e,t.loaded=!0,M.default.each(t.dataCallbacks,(e=>{e(t.data,t.localized)}))},error:o})};Gs()?n(function(e){if(qs.test(e))return Ye.getDataUrl(e);const[t,n]=Ye.getBaseUrl(e).split(Vs);return"".concat(t,"/").concat(Us(),"/").concat(n,"-data.json")}(this.props.src),((e,o,s)=>{t.localized=!1,n(Ye.getDataUrl(this.props.src),((e,t,n)=>{xe.error("Data load failed for svg-image",be.Service,{cause:n,loggedMetadata:{dataUrl:Ye.getDataUrl(this.props.src),status:t}})}))})):n(Ye.getDataUrl(this.props.src),((e,t,n)=>{xe.error("Data load failed for svg-image",be.Service,{cause:n,loggedMetadata:{dataUrl:Ye.getDataUrl(this.props.src),status:t}})}))}}sizeProvided(){return null!=this.props.width&&null!=this.props.height}_tryGetPixels(e){return(e=e||"").endsWith("px")&&parseFloat(e)||null}render(){const e=this.props.src,t={alt:this.props.alt,title:this.props.title,tabIndex:"0"};this.props.alt&&this.props.overrideAriaHidden&&(t["aria-hidden"]=!0);const n=this.props.width&&this.props.width*this.props.scale,o=this.props.height&&this.props.height*this.props.scale,s={width:n,height:o},i=this.props.responsive&&!(!n||!o);let r;this.props.extraGraphie&&this.props.extraGraphie.labels.length&&(r=_.createElement(Rs,{box:this.props.extraGraphie.box,range:this.props.extraGraphie.range,options:{labels:this.props.extraGraphie.labels},responsive:!0,addMouseLayer:!1,setup:this.setupGraphie}));const a=void 0===this.props.preloader?js:this.props.preloader,l=a?()=>a(s):null;if(!Ye.isLabeledSVG(e)){if(i){const s=S.default({zoomable:(n||0)>700,"svg-image":!0});return t.onClick=this._handleZoomClick,_.createElement(dn,{className:s,width:n,height:o,constrainHeight:this.props.constrainHeight,allowFullBleed:this.props.allowFullBleed&&Ws(e)},_.createElement(Bs,{src:e,imgProps:t,preloader:l,onUpdate:this.handleUpdate}),r)}return t.style=s,_.createElement(Bs,{src:e,preloader:l,imgProps:t,onUpdate:this.handleUpdate})}const c=Ye.getSvgUrl(e);let d;if(this.isLoadedInState(this.state)){let e;if(this.sizeProvided())e=[n,o];else{if(!this.state.imageDimensions)throw new we("svg-image has no dimensions",be.InvalidInput,{metadata:{src:this.props.src}});e=[this.state.imageDimensions[0]*this.props.scale,this.state.imageDimensions[1]*this.props.scale]}const t=[40*this.props.scale,40*this.props.scale];d=_.createElement(Rs,{ref:"graphie",box:e,scale:t,range:this.state.range,options:M.default.pick(this.state,"labels"),responsive:i,addMouseLayer:!1,setup:this.setupGraphie})}return i?_.createElement(dn,{className:"svg-image",width:n,height:o,constrainHeight:this.props.constrainHeight},_.createElement(Bs,{src:c,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:l,imgProps:t}),d,r):(t.style=s,_.createElement("div",{className:"unresponsive-svg-image",style:s},_.createElement(Bs,{src:c,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:l,imgProps:t}),d))}}U(Ys,"defaultProps",{constrainHeight:!1,onUpdate:()=>{},responsive:!0,src:"",scale:1,zoomToFullSizeOnMobile:!1,setAssetStatus:(e,t)=>{}});class $s extends _.Component{constructor(e){super(e),U(this,"_hasRendered",void 0),U(this,"handleRender",(()=>{this.props.onRender(),this.setState({rendered:!0}),this.props.onRender(),this._hasRendered||(this._hasRendered=!0,this.props.setAssetStatus(this.props.children,!0))})),this.props.setAssetStatus(this.props.children,!1),this.state={rendered:!1},this._hasRendered=!1}render(){const{TeX:e}=Y();return _.createElement(e,{onRender:this.handleRender},this.props.children)}}U($s,"defaultProps",{onRender:()=>{},setAssetStatus:(e,t)=>{}});class Xs extends _.Component{constructor(){super(...arguments),U(this,"_isMounted",void 0),U(this,"_observer",void 0),U(this,"_measuringInitialized",void 0),U(this,"_originalWidth",void 0),U(this,"_node",void 0),U(this,"state",{visible:!1,marginBottomPx:0,zoomed:!0}),U(this,"reset",(()=>{this._isMounted&&this.state.visible&&(this._originalWidth=null,this.setState({visible:!1,compactHeight:null,expandedHeight:null,zoomed:!0},(()=>{this.measureAndScaleChildToFit(!1)})))})),U(this,"stopPropagationIfZoomed",(e=>{this.state.zoomed||e.stopPropagation()})),U(this,"handleClickIfZoomed",(e=>{this.state.zoomed||(e.stopPropagation(),this.handleClick())})),U(this,"handleClick",(()=>{this.setState({zoomed:!this.state.zoomed})}))}componentDidMount(){this._isMounted=!0,this.maybeInitializeMeasuring()}componentDidUpdate(){this.maybeInitializeMeasuring()}componentWillUnmount(){window.removeEventListener("resize",this.reset),this._observer&&this._observer.disconnect(),this._isMounted=!1}maybeInitializeMeasuring(){const e=this.props.readyToMeasure&&!this._measuringInitialized;this._isMounted&&e&&(this._measuringInitialized=!0,this._node=N.default.findDOMNode(this),setTimeout((()=>this.measureAndScaleChildToFit(!1)),0),window.MutationObserver&&(this._observer=new MutationObserver((e=>{if(this._isMounted)for(const t of e)if(t.target!==this._node){this.measureAndScaleChildToFit(this.state.zoomed);break}})),this._observer.observe(this._node,{childList:!0,subtree:!0,attributes:!0})),window.addEventListener("resize",this.reset))}measureAndScaleChildToFit(e){if(!this._isMounted)return;const t={width:this._node.offsetWidth,height:this._node.offsetHeight},n=this.props.computeChildBounds(this._node,t),o=n.width+1,s=n.height+1;if(o>t.width){const n=t.width/o;this.setState({scale:n,zoomed:e,compactHeight:Math.ceil(n*s),expandedHeight:s}),setTimeout((()=>{this._isMounted&&this.setState({visible:!0})}))}else this.setState({visible:!0})}render(){const{visible:e,scale:t,compactHeight:n,expandedHeight:o,zoomed:s}=this.state,{animateHeight:i}=this.props,r=i?"opacity transform height":"opacity transform",a=e?{transitionProperty:r,WebkitTransitionProperty:r,msTransitionProperty:r,transitionDuration:"0.3s",WebkitTransitionDuration:"0.3s",msTransitionDuration:"0.3s",transitionTimingFunction:"ease-out",WebkitTransitionTimingfunction:"ease-out",msTransitionTmingFunction:"ease-out"}:{},l=e?"":" translate(0, 8px)",c=(null!=t?t:1).toString(),d=s?"scale(1, 1) ".concat(l):"scale(".concat(c,", ").concat(c,") ").concat(l),p={display:"block",width:"100%",height:s?o:n,transform:d,WebkitTransform:d,msTransform:d,transformOrigin:"0 0",WebkitTransformOrigin:"0 0",msTransformOrigin:"0 0",opacity:e?1:0,WebkitTapHighlightColor:"transparent",...a};return _.createElement("span",{onClick:this.handleClick,onClickCapture:this.handleClickIfZoomed,onTouchCancelCapture:this.stopPropagationIfZoomed,onTouchEndCapture:this.stopPropagationIfZoomed,onTouchStartCapture:this.stopPropagationIfZoomed,style:p},this.props.children)}}U(Xs,"defaultProps",{animateHeight:!1,readyToMeasure:!0,computeChildBounds:e=>{const t=e.firstElementChild;return{width:t.offsetWidth,height:t.offsetHeight}}});const Ks=(e,t)=>{const n=e.querySelector(".katex-html")||e.querySelector(".MathJax"),o={width:n.offsetWidth,height:n.offsetHeight};return{width:Math.max(t.width,o.width),height:Math.max(t.height,o.height)}};class Zs extends _.Component{constructor(){super(),U(this,"handleRender",(()=>{this.setState({isRendered:!0})})),this.state={isRendered:!1}}render(){return _.createElement(Xs,{readyToMeasure:this.state.isRendered,computeChildBounds:Ks},_.createElement(sn.Consumer,null,(e=>{let{setAssetStatus:t}=e;return _.createElement($s,{onRender:this.handleRender,setAssetStatus:t},this.props.children)})))}}class Js extends _.Component{constructor(e){super(e),this.state={error:""}}componentDidCatch(e,t){this.setState({error:e.toString()}),xe.error("Perseus error boundary caught error",be.Internal,{cause:e,loggedMetadata:{info:t.toString()}})}render(){return this.state.error?_.createElement("svg",{height:"16",width:"16",viewBox:"0 0 16 16"},_.createElement("path",{d:"m8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-3c0.55 0 1-0.45 1-1s-0.45-1-1-1-1 0.45-1 1 0.45 1 1 1zm0-9c-0.55 0-1 0.45-1 1v4c0 0.55.45 1 1 1s1-0.45 1-1v-4c0-0.55-0.45-1-1-1z",fill:"#d92916",fillRule:"evenodd"})):this.props.children}}function Qs(){}class ei{constructor(e,t,n,o){U(this,"_tracked",void 0),U(this,"setting",void 0),U(this,"track",void 0),U(this,"trackApi",void 0),U(this,"widgetID",void 0),U(this,"widgetType",void 0),U(this,"_track",(e=>{this._tracked&&!this.setting||(this._tracked=!0,this.trackApi({type:this.widgetType,id:this.widgetID,...e}))})),e?(this._tracked=!1,this.trackApi=e,this.widgetType=t,this.widgetID=n,this.setting=o,this.track=this._track):this.track=Qs}}const ti={fence:{match:R.default.defaultRules.fence.match,order:1,parse:(e,t,n)=>e[3]},paragraph:{match:R.default.defaultRules.paragraph.match,order:2,parse:(e,t,n)=>e[1]}},ni=R.default.parserFor(ti);var oi={parseToArray:e=>{const t=e.replace(/^\n\s*\n/,"")+"\n\n";return ni(t,{inline:!1})},joinFromArray:e=>e.join("\n\n")};class si{constructor(){U(this,"previousContent",null),U(this,"runLinter",i.debounce(((e,t)=>{"undefined"!=typeof KA&&e!==this.previousContent&&(this.previousContent=e,""!==e?fetch("/api/internal/translations/lint_poentry?preview=1&lang=en",{headers:{"Content-Type":"application/json"},body:JSON.stringify({msgid:e,msgstr:e,format:"perseus_text",filename:""}),method:"POST"}).then((e=>e.status>=400?{status:"error",message:"Could not run i18n linter."}:e.json()),(e=>({status:"error",message:"Could not run i18n linter."}))).then((e=>{"error"===e.status?t(["Some part of this text makes it untranslatable. The specific message from the i18n linter was: "+e.message.replace(/\n/g," ")]):t([])})):t([]))}),1e3))}applyLintErrors(e,t){if(t.length){const n=t.join("\n\n");e.unshift({content:{type:"text",content:""},insideTable:!1,message:n,ruleName:"legacy-error",severity:vt.Severity.ERROR,type:"lint"})}}}class ri extends _.Component{render(){const e=this.props.className?"paragraph "+this.props.className:"paragraph";return _.createElement("div",{className:e,"data-perseus-component-index":this.props.translationIndex,"data-perseus-paragraph-index":this.props.paragraphIndex},this.props.children)}}var ai=e=>e.replace(/\{align[*]?\}/g,"{aligned}").replace(/[\u00a0]/g," ");const{interactiveSizes:li}=me,ci={SMALL:"small",MEDIUM:"medium",LARGE:"large",XLARGE:"xlarge"},di=e=>e?e<=512?ci.SMALL:e<=688?ci.MEDIUM:ci.LARGE:ci.MEDIUM,pi=e=>e===ci.SMALL?[li.defaultBoxSizeSmall,li.defaultBoxSizeSmall]:[li.defaultBoxSize,li.defaultBoxSize];var ui=Object.freeze({__proto__:null,containerSizeClass:ci,getClassFromWidth:di,getInteractiveBoxFromSizeClass:pi});const hi=["default"],fi={},mi={},gi=(e,t)=>{fi[e]=t},vi=e=>{e.forEach((e=>{gi(e.name,e)})),Mi()},yi=e=>M.default.has(fi,e)?fi[e].getWidget?fi[e].getWidget():fi[e].widget:null,bi=e=>fi[e]?fi[e].version||{major:0,minor:0}:null,xi=()=>{const e={};return M.default.each(M.default.keys(fi),(function(t){e[t]=bi(t)})),e},wi=e=>{const t=fi[e.type].accessible;return"function"==typeof t?t(e.options):!!t},Ci=e=>{const t=e.type;if(!M.default.isString(t))throw new we("widget type must be a string, but was: "+t,be.Internal);const n=fi[t];if(null==n)return e;const o=e.version||{major:0,minor:0},s=n.version||{major:0,minor:0};if(o.major>s.major||o.major===s.major&&o.minor>s.minor)return e;let i=M.default.clone(e.options)||{};const r=n.propUpgrades||{};if(0!==M.default.keys(i).length)for(let e=o.major+1;e<=s.major;e++)r[String(e)]?i=r[String(e)](i):xe.error("No upgrade found for widget. Cannot render.",be.Internal,{loggedMetadata:{type:t,fromMajorVersion:e-1,toMajorVersion:e}});i={...t in mi?mi[t].defaultProps:{},...i};let a=e.alignment;null!=a&&"default"!==a||(a=Ei(t)[0]);let l=e.static;return null==l&&(l=false),M.default.extend({},e,{version:s,graded:null==e.graded||e.graded,alignment:a,static:l,options:i})},ki=(e,t)=>{const n=e.type,o=fi[n];if(null==o)return e.options;let s;return s=e.static?Ii(n)||M.default.identity:o.transform||M.default.identity,s(e.options,t)},Si=(e,t)=>{if(!t)throw new we("traverseRenderer must be provided, but was not",be.Internal);if(!e||!e.type||!fi[e.type])return e;const n=fi[e.type],o=e.options;if(n.traverseChildWidgets&&o){const s=n.traverseChildWidgets(o,t);return M.default.extend({},e,{options:s})}return e},Ei=e=>{const t=fi[e];return t&&t.supportedAlignments||hi},_i=e=>{const t=fi[e];let n;return t?(n=t.getDefaultAlignment?t.getDefaultAlignment():t.defaultAlignment,n||"block"):"block"},Ti=["block","inline-block","inline","float-left","float-right","full-width"],Mi=()=>{M.default.each(fi,(function(e){if(e.defaultAlignment&&!M.default.contains(Ti,e.defaultAlignment))throw new we("Widget '"+e.displayName+"' has an invalid defaultAlignment value: "+e.defaultAlignment,be.InvalidInput);if(e.supportedAlignments){const t=M.default.difference(e.supportedAlignments,Ti);if(t.length)throw new we("Widget '"+e.displayName+"' has an invalid value for supportedAlignments: "+t.join(" "),be.InvalidInput)}}))},Ii=e=>{const t=fi[e];return t&&t.staticTransform},Pi=e=>{const t=fi[e];return t&&t.tracking||""},Ni=e=>{const t=fi[e];return t&&t.isLintable||false};var Ai=Object.freeze({__proto__:null,registerWidget:gi,registerWidgets:vi,registerEditors:e=>{e.forEach((e=>{if(!e.widgetName)throw new we("Editor ".concat(e.displayName," doesn't have a widgetName property"),be.Internal);mi[e.widgetName]=e}))},getWidget:yi,getEditor:e=>M.default.has(mi,e)?mi[e]:null,getTransform:e=>M.default.has(fi,e)?fi[e].transform||M.default.identity:null,getVersion:bi,getVersionVector:xi,getPublicWidgets:()=>M.default.pick(fi,M.default.reject(M.default.keys(fi),(function(e){return fi[e].hidden}))),isAccessible:wi,getAllWidgetTypes:()=>M.default.keys(fi),upgradeWidgetInfoToLatestVersion:Ci,getRendererPropsForWidgetInfo:ki,traverseChildWidgets:Si,getSupportedAlignments:Ei,getDefaultAlignment:_i,validateAlignments:Mi,supportsStaticMode:e=>{const t=fi[e];return t&&null!=t.staticTransform},getStaticTransform:Ii,getTracking:Pi,isLintable:Ni});class Ri extends _.Component{constructor(){super(...arguments),U(this,"state",{sizeClass:ci.MEDIUM,widgetProps:this.props.initialProps}),U(this,"getWidget",(()=>this.refs.widget)),U(this,"replaceWidgetProps",(e=>{this.setState({widgetProps:e})}))}componentDidMount(){if(this.state.widgetProps.apiOptions.isMobile){const e=N.default.findDOMNode(this).offsetWidth;this.setState({sizeClass:di(e)})}}render(){let e=S.default({"perseus-widget-container":!0,"widget-highlight":this.props.shouldHighlight,"widget-nohighlight":!this.props.shouldHighlight});const t=this.props.type,n=yi(t);if(null==n)return console.warn("Widget type '".concat(t,"' not found!")),_.createElement("div",{className:e});let o=this.state.widgetProps.alignment;"default"===o&&(o=_i(t)),e+=" widget-"+o;const s=this.state.widgetProps.apiOptions,i=this.state.widgetProps.static||s.readOnly,r={width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:3},a=Ni(t)?this.props.linterContext:{...this.props.linterContext,highlightLint:!1};return _.createElement("div",{className:e,style:i?{position:"relative",overflow:"visible"}:{}},_.createElement(n,G({},this.state.widgetProps,{linterContext:a,containerSizeClass:this.state.sizeClass,ref:"widget"})),i&&_.createElement("div",{style:r}))}UNSAFE_componentWillReceiveProps(e){if(this.props.type!==e.type)throw new Error("WidgetContainer can't change widget type; set a different key instead to recreate the container.")}shouldComponentUpdate(e,t){return this.props.shouldHighlight!==e.shouldHighlight||this.props.type!==e.type||this.state.widgetProps!==t.widgetProps||this.state.sizeClass!==t.sizeClass}}U(Ri,"defaultProps",{linterContext:nn});const{mapObject:Fi,mapObjectFromArray:Oi}=In,Di=/\S/,Li=/(web\+graphie|https):\/\/[^\s]*/,Bi=()=>{},zi=["content","problemNum","widgets"];class qi extends _.Component{constructor(e,t){var n;super(e,t),n=this,U(this,"_currentFocus",void 0),U(this,"_foundTextNodes",void 0),U(this,"_interactionTrackers",void 0),U(this,"_isMounted",void 0),U(this,"_isTwoColumn",void 0),U(this,"_notGorgon",void 0),U(this,"lastRenderedMarkdown",void 0),U(this,"reuseMarkdown",void 0),U(this,"translationIndex",void 0),U(this,"widgetIds",void 0),U(this,"getApiOptions",(()=>({...ee.defaults,...this.props.apiOptions}))),U(this,"_getInitialWidgetState",(e=>{const t=this._getAllWidgetsInfo(e);return{widgetInfo:t,widgetProps:this._getAllWidgetsStartProps(t,e)}})),U(this,"_getAllWidgetsInfo",(e=>Fi(e.widgets,((e,t)=>{if(!e.type||!e.alignment){const n={};e.type||(n.type=t.split(" ")[0]),e.alignment||(n.alignment="default"),e=M.default.extend({},e,n)}return Ci(e)})))),U(this,"_getAllWidgetsStartProps",((e,t)=>Fi(e,(e=>ki(e,t.problemNum))))),U(this,"_getDefaultWidgetInfo",(e=>{const t=Ye.rTypeFromWidgetId.exec(e);return null==t?{}:{type:t[1],graded:!0,options:{}}})),U(this,"_getWidgetInfo",(e=>this.state.widgetInfo[e]||this._getDefaultWidgetInfo(e))),U(this,"renderWidget",((e,t,n)=>{const o=this.state.widgetInfo[t];if(o&&"full-width"===o.alignment&&(n.foundFullWidth=!0),o){const n=o&&o.type||e,s=M.default.contains(this.props.highlightedWidgets,t);return _.createElement(Js,{key:"container:"+t},_.createElement(Ri,{ref:"container:"+t,type:n,initialProps:this.getWidgetProps(t),shouldHighlight:s,linterContext:en.pushContextStack(this.props.linterContext,"widget")}))}return null})),U(this,"getWidgetProps",(e=>{const t=this.getApiOptions(),o=this.state.widgetProps[e]||{};let s=null;const i=this.state.widgetInfo[e];this.props.reviewMode&&i&&(s=i.options),this._interactionTrackers||(this._interactionTrackers={});let r=this._interactionTrackers[e];return r||(r=this._interactionTrackers[e]=new ei(t.trackInteraction,i&&i.type,e,Pi(i&&i.type))),{...o,ref:e,widgetId:e,alignment:i&&i.alignment,static:i&&i.static&&!this.props.problemNum,problemNum:this.props.problemNum,apiOptions:this.getApiOptions(),keypadElement:this.props.keypadElement,questionCompleted:this.props.questionCompleted,onFocus:M.default.partial(this._onWidgetFocus,e),onBlur:M.default.partial(this._onWidgetBlur,e),findWidgets:this.findWidgets,reviewModeRubric:s,onChange:function(t,o){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n._setWidgetProps(e,t,o,s)},trackInteraction:r.track,isLastUsedWidget:e===this.state.lastUsedWidgetId}})),U(this,"getSerializedState",(e=>Fi(e||this.state.widgetProps,((e,t)=>{const n=this.getWidgetInstance(t);return n&&n.getSerializedState?n.getSerializedState():e})))),U(this,"restoreSerializedState",((e,t)=>{const n=M.default.keys(e),o=M.default.keys(this.state.widgetProps);if(n.length!==o.length||M.default.intersection(n,o).length!==n.length)return void xe.error("Refusing to restore bad serialized state:",be.Internal,{loggedMetadata:{serializedState:JSON.stringify(e),currentProps:JSON.stringify(this.state.widgetProps)}});let s=1;const i=()=>{--s,t&&0===s&&t()};this.setState({widgetProps:Fi(e,((e,t)=>{const n=this.getWidgetInstance(t);if(n&&n.restoreSerializedState){++s;const o=n.restoreSerializedState(e,i);return M.default.extend({},this.state.widgetProps[t],o)}return e}))},(()=>{setTimeout(i,0)}))})),U(this,"showRationalesForCurrentlySelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{const t=this.getWidgetInstance(e);t&&t.showRationalesForCurrentlySelectedChoices&&t.showRationalesForCurrentlySelectedChoices(this._getWidgetInfo(e).options)}))})),U(this,"deselectIncorrectSelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{const t=this.getWidgetInstance(e);t&&t.deselectIncorrectSelectedChoices&&t.deselectIncorrectSelectedChoices()}))})),U(this,"findInternalWidgets",(e=>{let t;if("string"==typeof e)if(-1!==e.indexOf(" ")){const n=e;t=(e,t,o)=>e===n}else{const n=e;t=(e,t,o)=>t.type===n}else t=e;return this.widgetIds.filter((e=>{const n=this._getWidgetInfo(e),o=this.getWidgetInstance(e);return t(e,n,o)})).map(this.getWidgetInstance)})),U(this,"findWidgets",(e=>[...this.findInternalWidgets(e),...this.props.findExternalWidgets(e)])),U(this,"getWidgetInstance",(e=>{const t=this.refs["container:"+e];return t?t.getWidget():null})),U(this,"_onWidgetFocus",(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!M.default.isArray(t))throw new we("widget props.onFocus focusPath must be an Array, but was"+JSON.stringify(t),be.Internal);n._setCurrentFocus([e].concat(t))})),U(this,"_onWidgetBlur",((e,t)=>{const n=this._currentFocus,o=[e].concat(t);M.default.isEqual(o,n)&&M.default.defer((()=>{M.default.isEqual(this._currentFocus,n)&&this._setCurrentFocus(null)}))})),U(this,"getContent",((e,t)=>t.jiptContent||e.content)),U(this,"shouldRenderJiptPlaceholder",((e,t)=>Y().JIPT.useJIPT&&null==t.jiptContent&&-1!==e.content.indexOf("crwdns"))),U(this,"replaceJiptContent",((e,t)=>{if(null==t)this.setState({jiptContent:e});else{/^\s*(`{3,}|~{3,})\s*(\S+)?\s*\n([\s\S]+?)\s*\1\s*$/.test(e)||(/\S\n\s*\n\S/.test(e)?e="$\\large{\\red{\\text{Please translate each paragraph to a single paragraph.}}}$":/^\s*$/.test(e)&&(e="$\\large{\\red{\\text{Translated paragraph is currently empty}}}$"));const n=this.getContent(this.props,this.state),o=oi.parseToArray(n);o[t]=e,this.setState({jiptContent:oi.joinFromArray(o)})}})),U(this,"outputMarkdown",((e,t)=>{if(M.default.isArray(e)){const n=t.key,o=[];let s=!1;for(let n=0;n<e.length;n++){t.key=n,t.paragraphIndex=n;const i=this.outputMarkdown(e[n],t),r="string"==typeof i;"string"==typeof i&&s?o[o.length-1]+=i:o.push(i),s=r}return t.key=n,o}this._foundTextNodes=!1,t.foundFullWidth=!1;const n=this.outputNested(e,t);let o;return o=null!=this.translationIndex?null:S.default({"perseus-paragraph-centered":!this._foundTextNodes,"perseus-paragraph-full-width":t.foundFullWidth&&1===e.content.length}),_.createElement(ri,{key:t.key,className:o,translationIndex:this.translationIndex,paragraphIndex:t.paragraphIndex},_.createElement(Js,null,n))})),U(this,"outputNested",((e,t)=>{if(M.default.isArray(e)){const n=t.key,o=[];let s=!1;for(let n=0;n<e.length;n++){t.key=n;const i=this.outputNested(e[n],t),r="string"==typeof i;"string"==typeof i&&s?o[o.length-1]+=i:o.push(i),s=r}return t.key=n,o}return this.outputNode(e,this.outputNested,t)})),U(this,"outputNode",((e,t,n)=>{const o=this.getApiOptions(),s=o.imagePlaceholder;if("widget"===e.type){const t=o.widgetPlaceholder;return t||(this._foundTextNodes=!0,M.default.contains(this.widgetIds,e.id)?_.createElement("span",{key:n.key,className:"renderer-widget-error"},["Widget [[","☃"," ",e.id,"]] already exists."].join("")):(this.widgetIds.push(e.id),this.renderWidget(e.widgetType,e.id,n)))}if("blockMath"===e.type){const t=ai(e.content),s={overflowX:"auto",overflowY:"hidden",paddingTop:10,paddingBottom:10,marginTop:-10,marginBottom:-10};if(o.isMobile){const e=16,o={marginLeft:-e,marginRight:-e},i={paddingLeft:e,paddingRight:e},r={...s,...Hi.mobileZoomableParentFix};return _.createElement("div",{key:n.key,className:"perseus-block-math",style:o},_.createElement(Js,null,_.createElement("div",{className:"perseus-block-math-inner",style:{...r,...i}},_.createElement(Zs,null,t))))}return _.createElement("div",{key:n.key,className:"perseus-block-math"},_.createElement(Js,null,_.createElement("div",{className:"perseus-block-math-inner",style:s},_.createElement(sn.Consumer,null,(e=>{let{setAssetStatus:n}=e;return _.createElement($s,{setAssetStatus:n},t)})))))}if("math"===e.type){const t=e.content.replace(/\{align[*]?\}/g,"{aligned}");return _.createElement("span",{key:n.key,style:{whiteSpace:"nowrap"}},_.createElement(Js,null,_.createElement("span",null),_.createElement(sn.Consumer,null,(e=>{let{setAssetStatus:n}=e;return _.createElement($s,{onRender:this.props.onRender,setAssetStatus:n},t)})),_.createElement("span",null)))}if("image"===e.type){if(s)return s;const t=M.default.has(this.props.images,e.target)?this.props.images[e.target]:null,i=!n.inTable;return _.createElement(Js,{key:n.key},_.createElement(sn.Consumer,null,(n=>{let{setAssetStatus:s}=n;return _.createElement(Ys,G({setAssetStatus:s,src:it.sanitizeUrl(e.target),alt:e.alt,title:e.title,responsive:i,onUpdate:this.props.onRender,zoomToFullSizeOnMobile:o.isMobile&&o.isArticle},t))})))}if("columns"===e.type)return this._isTwoColumn=!0,_.createElement(Js,{key:n.key},it.ruleOutput(e,t,n));if("text"===e.type)return Di.test(e.content)&&(this._foundTextNodes=!0),s&&Li.test(e.content)?s:e.content;if("table"===e.type||"titledTable"===e.type){const s=it.ruleOutput(e,t,{...n,isMobile:o.isMobile,inTable:!0});if(!o.isMobile)return s;const i=16,r={marginLeft:-i,marginRight:-i},a={...{paddingLeft:0,paddingRight:0},...Hi.mobileZoomableParentFix},l=_.createElement("div",{style:{...a,overflowX:"auto"}},_.createElement(Js,null,_.createElement(Xs,{animateHeight:!0},s)));return _.createElement("div",{style:r},l)}return _.createElement(Js,{key:n.key},it.ruleOutput(e,t,n))})),U(this,"handleRender",(e=>{const t=this.props.onRender,n=e.onRender;if(t!==Bi||n!==Bi){const e=P.default(N.default.findDOMNode(this)).find("img");n!==Bi&&e.off("load",n),t!==Bi&&e.on("load",t)}t()})),U(this,"_setCurrentFocus",(e=>{const t=this.getApiOptions();if(n=e,o=this._currentFocus,!(null===n||null===o?n===o:M.default.every(n,((e,t)=>{if(null!=o)return M.default.isEqual(e,o[t])})))){const n=this._currentFocus;n&&this.blurPath(n),this._currentFocus=e,t.onFocusChange(this._currentFocus,n)}var n,o})),U(this,"focus",(()=>{let e,t;for(let n=0;n<this.widgetIds.length;n++){const o=this.widgetIds[n],s=this.getWidgetInstance(o),i=s&&s.focus&&s.focus();if(i){e=o,t=i;break}}if(e){let n;return"object"==typeof t?(n=[e].concat(t.path||[]),xe.error("Renderer received a focus result of type 'object' instead of the expected type 'boolean'",be.Internal,{loggedMetadata:{focusResult:JSON.stringify(t),currentProps:JSON.stringify(this.state.widgetProps)}})):n=[e],this._setCurrentFocus(n),!0}})),U(this,"getDOMNodeForPath",(e=>{const t=M.default.first(e),n=M.default.rest(e),o=this.getWidgetInstance(t),s=o&&o.getDOMNodeForPath;return s?s(n):0===n.length?N.default.findDOMNode(o):void 0})),U(this,"getGrammarTypeForPath",(e=>{const t=M.default.first(e),n=M.default.rest(e),o=this.getWidgetInstance(t);if(o&&o.getGrammarTypeForPath)return o.getGrammarTypeForPath(n)})),U(this,"getInputPaths",(()=>{const e=[];return M.default.each(this.widgetIds,(t=>{const n=this.getWidgetInstance(t);if(n&&n.getInputPaths){const o=n.getInputPaths();M.default.each(o,(n=>{const o=[t].concat(n);e.push(o)}))}})),e})),U(this,"focusPath",(e=>{if(M.default.isEqual(this._currentFocus,e))return;this._currentFocus&&this.blurPath(this._currentFocus);const t=M.default.first(e),n=M.default.rest(e),o=this.getWidgetInstance(t);o&&o.focusInputPath&&o.focusInputPath(n)})),U(this,"blurPath",(e=>{if(!M.default.isEqual(this._currentFocus,e))return;const t=M.default.first(e),n=M.default.rest(e);if(this.getWidgetInstance(t)){const e=this.getWidgetInstance(t);e&&e.blurInputPath&&e.blurInputPath(n)}})),U(this,"blur",(()=>{this._currentFocus&&this.blurPath(this._currentFocus)})),U(this,"serialize",(()=>{const e={};return M.default.each(this.state.widgetInfo,(function(t,n){const o=this.getWidgetInstance(n).serialize();M.default.isEmpty(o)||(e[n]=o)}),this),e})),U(this,"emptyWidgets",(()=>M.default.filter(this.widgetIds,(e=>{const t=this._getWidgetInfo(e);if(t.static)return!1;const n=this.getWidgetInstance(e);if(n&&n.simpleValidate){const e=n.simpleValidate(t.options,null);return Ye.scoreIsEmpty(e)}})))),U(this,"_setWidgetProps",((e,t,n,o)=>{this.setState((n=>{const s={...n.widgetProps,[e]:{...n.widgetProps[e],...t}},i=o?n.lastUsedWidgetId:e;return o||this.props.onSerializedStateUpdated(this.getSerializedState(s)),{lastUsedWidgetId:i,widgetProps:s}}),(()=>{setTimeout((()=>{const t=n&&n();o||this.props.onInteractWithWidget(e),!1!==t&&this._setCurrentFocus([e])}),0)}))})),U(this,"setInputValue",((e,t,n)=>{var o;const s=M.default.first(e),i=M.default.rest(e),r=this.getWidgetInstance(s);null==r||null===(o=r.setInputValue)||void 0===o||o.call(r,i,t,n)})),U(this,"getUserInput",(()=>this.widgetIds.map((e=>{const t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),U(this,"getWidgetIds",(()=>this.widgetIds)),U(this,"getUserInputForWidgets",(()=>Oi(this.widgetIds,(e=>{const t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),U(this,"scoreWidgets",(()=>{const e=this.state.widgetInfo,t=this.getApiOptions().onInputError,n=M.default.filter(this.widgetIds,(t=>{const n=e[t],o=null==(null==n?void 0:n.graded)||n.graded,s=!(null==n||!n.static);return o&&!s})),o={};return M.default.each(n,(n=>{const s=e[n],i=this.getWidgetInstance(n);i&&i.simpleValidate&&(o[n]=i.simpleValidate(null==s?void 0:s.options,t))})),o})),U(this,"score",(()=>M.default.reduce(this.scoreWidgets(),Ye.combineScores,Ye.noScore))),U(this,"guessAndScore",(()=>[this.getUserInput(),this.score()])),U(this,"examples",(()=>{const e=this.widgetIds,t=M.default.compact(M.default.map(e,(e=>{const t=this.getWidgetInstance(e);return null!=t&&t.examples?t.examples():null})));if(!t.length)return null;return M.default.all(t,(function(e){return M.default.isEqual(t[0],e)}))?t[0]:null})),U(this,"handleNotGorgonLintErrors",(e=>{this._isMounted&&this.setState({notGorgonLintErrors:e})})),this._notGorgon=new si,this.state={jiptContent:null,notGorgonLintErrors:[],lastUsedWidgetId:null,...this._getInitialWidgetState(e)}}componentDidMount(){this._isMounted=!0,this.handleRender({}),this._currentFocus=null,this.props.serializedState&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}UNSAFE_componentWillReceiveProps(e){M.default.isEqual(M.default.pick(this.props,zi),M.default.pick(e,zi))||this.setState(this._getInitialWidgetState(e))}shouldComponentUpdate(e,t){if(this.props.alwaysUpdate)return!0;const n=!M.default.isEqual(this.state,t);return!M.default.isEqual(this.props,e)||n}UNSAFE_componentWillUpdate(e,t){const n=this.shouldRenderJiptPlaceholder(this.props,this.state),o=this.shouldRenderJiptPlaceholder(e,t),s=this.getContent(this.props,this.state),i=this.getContent(e,t),r=this.props.highlightedWidgets,a=e.highlightedWidgets;this.reuseMarkdown=!n&&!o&&s===i&&M.default.isEqual(this.state.notGorgonLintErrors,t.notGorgonLintErrors)&&(!this.props.linterContext.highlightLint||M.default.isEqual(this.props.widgets,e.widgets))&&this.props.linterContext.highlightLint===e.linterContext.highlightLint&&r===a}componentDidUpdate(e,t){this.handleRender(e),M.default.each(this.widgetIds,(e=>{const t=this.refs["container:"+e];t&&t.replaceWidgetProps(this.getWidgetProps(e))})),this.props.serializedState&&!M.default.isEqual(this.props.serializedState,this.getSerializedState())&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}componentWillUnmount(){this.widgetIds=[],null!=this.translationIndex&&Y().rendererTranslationComponents.removeComponentAtIndex(this.translationIndex),this._isMounted=!1}render(){const e=this.getApiOptions(),{KatexProvider:t}=Y();if(this.reuseMarkdown)return this.lastRenderedMarkdown;const n=this.getContent(this.props,this.state);if(this.widgetIds=[],this.shouldRenderJiptPlaceholder(this.props,this.state)&&(this.translationIndex||(this.translationIndex=Y().rendererTranslationComponents.addComponent(this)),!e.isArticle))return _.createElement(t,null,_.createElement("div",{"data-perseus-component-index":this.translationIndex},n));this._isTwoColumn=!1;const o=it.parse(n,{isJipt:null!=this.translationIndex});if(this.props.linterContext.highlightLint){const e={content:this.props.content,widgets:this.props.widgets,...this.props.linterContext};en.runLinter(o,e,!0),this._notGorgon.applyLintErrors(o,[...this.state.notGorgonLintErrors,...this.props.legacyPerseusLint||[]])}const s=this.outputMarkdown(o,{baseElements:e.baseElements}),i=S.default({[te.RENDERER]:!0,[te.RESPONSIVE_RENDERER]:!0,[te.TWO_COLUMN_RENDERER]:this._isTwoColumn});return this.lastRenderedMarkdown=_.createElement(t,null,_.createElement("div",{className:i},s)),this.lastRenderedMarkdown}}U(qi,"defaultProps",{content:"",widgets:{},images:{},highlightedWidgets:[],questionCompleted:!1,onRender:Bi,onInteractWithWidget:function(){},findExternalWidgets:()=>[],alwaysUpdate:!1,reviewMode:!1,serializedState:null,onSerializedStateUpdated:()=>{},linterContext:nn});const Hi={mobileZoomableParentFix:{transform:"translate3d(0,0,0)"}},Wi={fontSize:"150%"},Ui={fontSize:"120%"},Gi={fontSize:"130%"},Vi=[()=>[_.createElement("span",{key:"plus",style:Ui},"+"),"+"],()=>[_.createElement("span",{key:"minus",style:Wi},"-"),"-"],e=>{const{TeX:t}=Y();return e.convertDotToTimes?[_.createElement(t,{key:"times",style:Wi},k.doNotTranslate("\\times")),"\\times"]:[_.createElement(t,{key:"times",style:Wi},k.doNotTranslate("\\cdot")),"\\cdot"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"frac",style:Wi},k.doNotTranslate("\\frac{x}{y}")),e=>{const t=e.latex();e.typedText("/"),e.latex()===t&&e.cmd("\\frac")}]}],ji={basic:Vi,"basic+div":Vi.concat([()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"div"},k.doNotTranslate("\\div")),"\\div"]}]),trig:[()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"sin"},k.doNotTranslate("\\sin")),"\\sin"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"cos"},k.doNotTranslate("\\cos")),"\\cos"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"tan"},k.doNotTranslate("\\tan")),"\\tan"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"theta",style:Gi},k.doNotTranslate("\\theta")),"\\theta"]},()=>{const{TeX:e}=Y();return[_.createElement("span",{key:"phi"},_.createElement("span",{className:"perseus-sr-only"},k.doNotTranslate("phi")),_.createElement(e,{key:"pi",style:Gi},k.doNotTranslate("\\phi"))),"\\phi"]}],prealgebra:[()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"sqrt"},k.doNotTranslate("\\sqrt{x}")),"\\sqrt"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"nthroot"},k.doNotTranslate("\\sqrt[3]{x}")),e=>{e.typedText("nthroot3"),e.keystroke("Right")}]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"pow",style:Ui},k.doNotTranslate("a^b")),e=>{const t=e.latex();e.typedText("^"),e.latex()===t&&e.typedText("a^b")}]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"pi",style:Ui},k.doNotTranslate("\\pi")),"\\pi"]}],logarithms:[()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"log"},k.doNotTranslate("\\log")),"\\log"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"ln"},k.doNotTranslate("\\ln")),"\\ln"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"log_b"},k.doNotTranslate("\\log_b")),e=>{e.typedText("log_"),e.keystroke("Right"),e.typedText("("),e.keystroke("Left"),e.keystroke("Left")}]}],"basic relations":[()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"eq"},"="),"="]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"lt"},k.doNotTranslate("\\lt")),"\\lt"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"gt"},k.doNotTranslate("\\gt")),"\\gt"]}],"advanced relations":[()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"neq"},k.doNotTranslate("\\neq")),"\\neq"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"leq"},k.doNotTranslate("\\leq")),"\\leq"]},()=>{const{TeX:e}=Y();return[_.createElement(e,{key:"geq"},k.doNotTranslate("\\geq")),"\\geq"]}]},Yi=I.default.arrayOf(I.default.oneOf(M.default(ji).keys()));class $i extends _.Component{render(){const e=M.default.sortBy(this.props.sets,(e=>M.default.keys(ji).indexOf(e))),t=M.default(e).map((e=>ji[e])),n=M.default(t).map((e=>e.map((e=>{const t=e(this.props);return _.createElement("button",{onClick:()=>this.props.onInsert(t[1]),className:"tex-button",key:t[0].key,type:"button"},t[0])})))),o=M.default(n).map(((e,t)=>_.createElement("div",{className:"clearfix tex-button-row",key:this.props.sets[t]},e)));return _.createElement("div",{className:"".concat(this.props.className||""," preview-measure")},o)}}U($i,"propTypes",{sets:Yi.isRequired,onInsert:I.default.func.isRequired,className:I.default.string}),U($i,"buttonSets",ji),U($i,"buttonSetsType",Yi);const Xi=I.default;class Ki extends _.Component{constructor(){super(...arguments),U(this,"mouseDown",void 0),U(this,"state",{focused:!1}),U(this,"handleFocus",(()=>{this.setState({focused:!0})})),U(this,"handleMouseDown",(e=>{const t=N.default.findDOMNode(this).contains(e.target);this.mouseDown=t,t||this.setState({focused:!1})})),U(this,"handleMouseUp",(()=>{this.mouseDown&&this.focus(),this.mouseDown=!1})),U(this,"handleBlur",(e=>{this.mouseDown||N.default.findDOMNode(this).contains(e.relatedTarget)||this.setState({focused:!1})})),U(this,"_shouldShowButtons",(()=>"always"===this.props.buttonsVisible||"never"!==this.props.buttonsVisible&&this.state.focused)),U(this,"insert",(e=>{const t=this.mathField();M.default(e).isFunction()?e(t):"\\"===e[0]?t.cmd(e).focus():t.write(e).focus(),t.focus()})),U(this,"mathField",(e=>D.default.getInterface(2).MathField(N.default.findDOMNode(this.refs.mathinput),e))),U(this,"focus",(()=>{this.mathField().focus(),this.setState({focused:!0})})),U(this,"blur",(()=>{this.mathField().blur(),this.setState({focused:!1})}))}render(){let e=S.default({"perseus-math-input":!0,"mq-editable-field":!0,"mq-math-mode":!0});this.props.className&&(e=e+" "+this.props.className);let t=null;return this._shouldShowButtons()&&(t=_.createElement($i,{sets:this.props.buttonSets,className:"math-input-buttons absolute",convertDotToTimes:this.props.convertDotToTimes,onInsert:this.insert})),_.createElement("div",{style:{display:"inline-block"}},_.createElement("div",{style:{display:"inline-block"}},_.createElement("span",{className:e,ref:"mathinput","aria-label":this.props.labelText,onFocus:this.handleFocus,onBlur:this.handleBlur})),_.createElement("div",{style:{position:"relative"},onBlur:this.handleBlur},t))}componentWillUnmount(){window.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}componentDidMount(){window.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp);let e=!1;this.mathField({autoCommands:"pi theta phi sqrt nthroot",charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:!0,spaceBehavesLikeTab:!0,handlers:{edited:t=>{let n=t.latex();if(n=n.replace(/<>/g,"\\ne"),this.props.convertDotToTimes){n=n.replace(/\\cdot/g,"\\times");const e=t.__controller.cursor[D.default.L];e&&"\\cdot "===e.ctrlSeq&&(t.__controller.backspace(),t.cmd("\\times"))}else n=n.replace(/\\times/g,"\\cdot");e&&this.props.value!==n&&this.props.onChange(n)},enter:()=>{P.default(N.default.findDOMNode(this.refs.mathinput)).submit()},upOutOf:e=>{e.typedText("^")}}}),this.mathField().latex(this.props.value),e=!0}}U(Ki,"propTypes",{value:Xi.string,onChange:Xi.func.isRequired,convertDotToTimes:Xi.bool,buttonsVisible:Xi.oneOf(["always","never","focused"]),buttonSets:$i.buttonSetsType.isRequired,labelText:I.default.string,onFocus:Xi.func,onBlur:Xi.func}),U(Ki,"defaultProps",{value:"",convertDotToTimes:!1,buttonsVisible:"focused"});class Zi extends _.Component{constructor(){super(...arguments),U(this,"focus",(()=>{N.default.findDOMNode(this).focus()})),U(this,"blur",(()=>{N.default.findDOMNode(this).blur()})),U(this,"getValue",(()=>{var e;return null===(e=N.default.findDOMNode(this))||void 0===e?void 0:e.value})),U(this,"getStringValue",(()=>{var e;return null===(e=N.default.findDOMNode(this))||void 0===e?void 0:e.value.toString()})),U(this,"setSelectionRange",((e,t)=>{N.default.findDOMNode(this).setSelectionRange(e,t)})),U(this,"getSelectionStart",(()=>N.default.findDOMNode(this).selectionStart)),U(this,"getSelectionEnd",(()=>N.default.findDOMNode(this).selectionEnd))}render(){const{labelText:e,...t}=this.props;return _.createElement("input",G({},t,{type:"text","aria-label":e,onChange:e=>this.props.onChange(e.target.value)}))}}U(Zi,"propTypes",{value:I.default.string,onChange:I.default.func.isRequired,className:I.default.string,labelText:I.default.string,onFocus:I.default.func,onBlur:I.default.func,disabled:I.default.bool}),U(Zi,"defaultProps",{value:"",disabled:!1});const Ji=O.default({displayName:"Triangle",propTypes:{color:I.default.string.isRequired,left:I.default.number.isRequired,top:I.default.number.isRequired,width:I.default.number.isRequired,height:I.default.number.isRequired,horizontalDirection:I.default.oneOf(["left","right"]).isRequired,verticalDirection:I.default.oneOf(["top","bottom"]).isRequired},render:function(){let e,t,n,o;const s="".concat(this.props.width,"px solid transparent");"right"===this.props.horizontalDirection?e=s:t=s;const i="".concat(this.props.height,"px solid ").concat(this.props.color);return"top"===this.props.verticalDirection?n=i:o=i,_.createElement("div",{style:{display:"block",height:0,width:0,position:"absolute",left:this.props.left,top:this.props.top,borderLeft:e,borderRight:t,borderTop:n,borderBottom:o}})}}),Qi=O.default({displayName:"TooltipArrow",propTypes:{position:I.default.string,visibility:I.default.string,left:I.default.number,top:I.default.number,color:I.default.string.isRequired,border:I.default.string.isRequired,width:I.default.number.isRequired,height:I.default.number.isRequired,horizontalDirection:I.default.oneOf(["left","right"]).isRequired,verticalDirection:I.default.oneOf(["top","bottom"]).isRequired},getDefaultProps:function(){return{position:"relative",visibility:"visible",left:0,top:0}},render:function(){const e="top"===this.props.verticalDirection,t=e?0:1,n=e?0:-1;return _.createElement("div",{style:{display:"block",position:this.props.position,visibility:this.props.visibility,left:this.props.left,top:this.props.top,width:this.props.width+2,height:this.props.height+1,marginTop:-1,marginBottom:-2,zIndex:10}},_.createElement(Ji,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.border,left:0,top:n,width:this.props.width+2,height:this.props.height+2}),_.createElement(Ji,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.color,left:1,top:t,width:this.props.width,height:this.props.height}))}}),er={top:{top:"-100%"},bottom:{top:0}},tr={left:{targetLeft:0},right:{targetLeft:"100%"}},nr={left:{tooltipLeft:0,arrowLeft:e=>0},right:{tooltipLeft:"-100%",arrowLeft:e=>-e-2}},or=O.default({displayName:"Tooltip",propTypes:{show:I.default.bool.isRequired,className:I.default.string,arrowSize:I.default.number,borderColor:I.default.string,verticalPosition:I.default.oneOf(Object.keys(er)),horizontalPosition:I.default.oneOf(Object.keys(tr)),horizontalAlign:I.default.oneOf(Object.keys(nr)),children:I.default.arrayOf(I.default.element).isRequired,targetContainerStyle:I.default.any},getDefaultProps:function(){return{className:"",arrowSize:10,borderColor:"#ccc",verticalPosition:"bottom",horizontalPosition:"left",horizontalAlign:"left",targetContainerStyle:{}}},getInitialState:function(){return{height:null}},componentDidMount:function(){this._updateHeight()},UNSAFE_componentWillReceiveProps:function(){this.setState({height:null})},componentDidUpdate:function(){this._updateHeight()},_renderToolTipDiv:function(e){const t=Object.assign({},tr[this.props.horizontalPosition],nr[this.props.horizontalAlign],er[this.props.verticalPosition]);let n,o;return e?(n=_.createElement(Qi,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,position:"absolute",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:2-this.props.arrowSize,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),o=_.createElement(Qi,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,visibility:"hidden",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10})):(n=_.createElement(Qi,{verticalDirection:"bottom",horizontalDirection:this.props.horizontalAlign,color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),o=null),_.createElement("div",{style:{position:"relative",height:0,display:this.props.show?"block":"none"}},_.createElement("div",{ref:"tooltipContainer",className:"tooltipContainer",style:{position:"absolute",height:this.state.height||void 0,left:t.targetLeft}},n,_.createElement("div",{className:this.props.className,ref:"tooltipContent",style:{position:"relative",top:t.top,left:t.tooltipLeft,border:"1px solid "+this.props.borderColor,WebkitBoxShadow:"0 1px 3px "+this.props.borderColor,MozBoxShadow:"0 1px 3px "+this.props.borderColor,boxShadow:"0 1px 3px "+this.props.borderColor,zIndex:9}},this.props.children.slice(1)),o))},_updateHeight:function(){const e=N.default.findDOMNode(this.refs.tooltipContainer).offsetHeight;e!==this.state.height&&this.setState({height:e})},render:function(){const e="top"===this.props.verticalPosition;return _.createElement("span",null,e&&this._renderToolTipDiv(e),_.createElement("div",{style:this.props.targetContainerStyle},this.props.children[0]),!e&&this._renderToolTipDiv())}}),{captureScratchpadTouchStart:sr}=Ye;class ir extends _.Component{constructor(){super(...arguments),U(this,"state",{focused:!1,showExamples:!1}),U(this,"_getUniqueId",(()=>"input-with-examples-".concat(btoa(this.props.id).replace(/=/g,"")))),U(this,"_getInputClassName",(()=>{if("tex"===this.props.type)return this.props.className;let e=te.INPUT+" "+te.INTERACTIVE;return this.state.focused&&(e+=" "+te.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),U(this,"_getPropsForInputType",(()=>{const e={"aria-describedby":this._getUniqueId(),ref:"input",className:this._getInputClassName(),labelText:this.props.labelText,value:this.props.value,onFocus:this._handleFocus,onBlur:this._handleBlur,disabled:this.props.disabled};return"tex"===this.props.type?e:(M.default.extend(e,{onChange:this.props.onChange,onTouchStart:sr}),"math"===this.props.type?M.default.extend({buttonSet:this.props.buttonSet,buttonsVisible:this.props.buttonsVisible,convertDotToTimes:this.props.convertDotToTimes},e):"text"===this.props.type?M.default.extend({autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:"false"},e):void 0)})),U(this,"_getComponentForInputType",(()=>{switch(this.props.type){case"tex":return le;case"math":return Ki;case"text":return Zi;default:return null}})),U(this,"_renderInput",(()=>{const e=this._getPropsForInputType(),t=this._getComponentForInputType();return _.createElement(t,e)})),U(this,"_handleFocus",(()=>{this.props.onFocus(),this.setState({focused:!0,showExamples:!0})})),U(this,"show",(()=>{this.setState({showExamples:!0})})),U(this,"hide",(()=>{this.setState({showExamples:!1})})),U(this,"_handleBlur",(()=>{this.props.onBlur(),this.setState({focused:!1,showExamples:!1})})),U(this,"focus",(()=>{this.refs.input.focus()})),U(this,"blur",(()=>{this.refs.input.blur()})),U(this,"handleChange",(e=>{this.props.onChange(e.target.value)}))}render(){const e=this._renderInput();if("tex"===this.props.type)return e;const t=M.default.map(this.props.examples,(e=>"- "+e)).join("\n"),n=this.props.shouldShowExamples&&this.state.showExamples;return _.createElement(or,{ref:"tooltip",className:"perseus-formats-tooltip preview-measure",horizontalPosition:"left",horizontalAlign:"left",verticalPosition:"bottom",arrowSize:10,borderColor:"#ccc",show:n},e,_.createElement("div",{id:this._getUniqueId()},_.createElement(qi,{content:t,linterContext:en.pushContextStack(this.props.linterContext,"input-with-examples")})))}}U(ir,"propTypes",{type:I.default.oneOf(["math","text","tex"]),value:I.default.string,onChange:I.default.func.isRequired,className:I.default.string,examples:I.default.arrayOf(I.default.string).isRequired,shouldShowExamples:I.default.bool,convertDotToTimes:I.default.bool,buttonSet:I.default.string,buttonsVisible:I.default.oneOf(["always","never","focused"]),labelText:I.default.string,onFocus:I.default.func,onBlur:I.default.func,disabled:I.default.bool,id:I.default.string.isRequired,linterContext:tn}),U(ir,"defaultProps",{type:"text",shouldShowExamples:!0,onFocus:function(){},onBlur:function(){},disabled:!1,linterContext:nn});var rr=["key","ref","containerSizeClass","widgetId","onChange","problemNum","apiOptions","questionCompleted","findWidgets","onRemove","id","onBlur","onFocus","trackInteraction","keypadElement"];const ar='Usage:\n this.change({propName: 5}, callback);\n this.change("propName", 5, callback);\n this.change("propName")',lr=function(e,t,n){const o=M.default.omit(e.props,rr),s=M.default.extend(o,t);e.props.onChange(s,n)},cr=function(e,t,n,o){if(void 0===n)return M.default.partial(cr,e,t);const s={};s[t]=n,lr(e,s,o)},dr=function(e,t,n){if(M.default.isObject(e)&&void 0===n)return lr(this,e,n=t);if("string"==typeof e)return cr(this,e,t,n);throw new we("Invalid types sent to this.change(): "+M.default.toArray(arguments).join()+"\n"+ar,be.Internal)},pr={onChange:I.default.func.isRequired};var ur=Object.freeze({__proto__:null,change:dr,propTypes:pr});const{KeypadInput:hr}=e.components,{KeypadTypes:fr}=e.consts,mr=k._("Sorry, I don't understand that!"),gr=e=>e.replace(/([_^])([^{])/g,"$1{$2}");class vr extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"displayName","Expression"),U(this,"state",{showErrorTooltip:!1,showErrorText:!1}),U(this,"componentDidMount",(()=>{this._isMounted=!0})),U(this,"componentDidUpdate",(e=>{M.default.isEqual(this.props.value,e.value)&&M.default.isEqual(this.props.functions,e.functions)||(clearTimeout(this.errorTimeout),this.parse(this.props.value,this.props).parsed?this.setState({showErrorTooltip:!1}):this.errorTimeout=setTimeout((()=>{!1!==this.props.apiOptions.onInputError(null,this.props.value,mr)&&this.setState({showErrorTooltip:!0})}),2e3))})),U(this,"componentWillUnmount",(()=>{clearTimeout(this.errorTimeout),this._isMounted=!1})),U(this,"_isMounted",!1),U(this,"errorTimeout",null),U(this,"simpleValidate",((e,t)=>(t=t||function(){},vr.validate(this.getUserInput(),e,t)))),U(this,"getUserInput",(()=>vr.getUserInputFromProps(this.props))),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"parse",((e,t)=>{const n=M.default.pick(t||this.props,"functions");return M.default.extend(n,{decimal_separator:k.getDecimalSeparator()}),E.default.parse(gr(e),n)})),U(this,"changeAndTrack",((e,t)=>{this.change("value",e,t),this.props.trackInteraction()})),U(this,"_handleFocus",(()=>{this.props.onFocus([])})),U(this,"_handleBlur",(()=>{this.props.onBlur([])})),U(this,"focus",(()=>(this.props.apiOptions.customKeypad&&this.refs.input.focus(),!0))),U(this,"focusInputPath",(e=>{this.refs.input.focus()})),U(this,"blurInputPath",(e=>{this.refs.input.blur()})),U(this,"insert",(e=>{this.props.apiOptions.staticRender||this.refs.input.insert(e)})),U(this,"getInputPaths",(()=>[[]])),U(this,"getGrammarTypeForPath",(e=>"expression")),U(this,"setInputValue",((e,t,n)=>{this.props.onChange({value:t},n)}))}static validate(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};const o=M.default.clone(t);M.default.extend(o,{decimal_separator:k.getDecimalSeparator()});const s=e=>{const n=E.default.parse(e.value,t);return n.parsed?Ee.expression.createValidatorFunctional(n.expr,M.default({}).extend(o,{simplify:e.simplify,form:e.form})):(xe.error("Unable to parse solution answer for expression",be.InvalidInput,{loggedMetadata:{rubric:JSON.stringify(t)}}),null)};let i,r,a,l=!0;for(const n of t.answerForms||[]){const t=s(n);if(!t)continue;const o=t(e);if(o.correct){i=n,r=o.message||"";break}l=l&&o.empty,"correct"===n.considered&&o.ungraded&&!a&&(a=o)}if(!i)return a?{type:"invalid",message:a.message,suppressAlmostThere:a.suppressAlmostThere}:l?{type:"invalid",message:null}:{type:"points",earned:0,total:1};if("ungraded"===i.considered){return{type:"invalid",message:!1===n(null,e,r)?null:r}}return{type:"points",earned:"correct"===i.considered?1:0,total:1,message:r}}static getUserInputFromProps(e){return gr(e.value)}static getOneCorrectAnswerFromRubric(e){const t=(e.answerForms||[]).filter((e=>"correct"===e.considered));if(0!==t.length)return t[0].value}render(){if(this.props.apiOptions.customKeypad)return _.createElement(hr,{ref:"input",value:this.props.value,keypadElement:this.props.keypadElement,onChange:this.changeAndTrack,onFocus:()=>{var e;null===(e=this.props.keypadElement)||void 0===e||e.configure(this.props.keypadConfiguration,(()=>{this._isMounted&&this._handleFocus()}))},onBlur:this._handleBlur});if(this.props.apiOptions.staticRender)return _.createElement(ir,{ref:"input",value:this.props.value,type:"tex",examples:[],shouldShowExamples:!1,onChange:this.changeAndTrack,onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,linterContext:this.props.linterContext});const e=_.createElement("span",{className:"error-tooltip",role:"tooltip"},_.createElement(or,{className:"error-text-container",horizontalPosition:"right",horizontalAlign:"left",verticalPosition:"top",arrowSize:10,borderColor:"#fcc335",show:this.state.showErrorText},_.createElement("span",{className:"error-icon","data-test-id":"test-error-icon",onMouseEnter:()=>{this.setState({showErrorText:!0})},onMouseLeave:()=>{this.setState({showErrorText:!1})},onClick:()=>{this.setState({showErrorText:!this.state.showErrorText})}},_.createElement(V,_o)),_.createElement("div",{className:"error-text"},mr))),t=S.default({"perseus-widget-expression":!0,"show-error-tooltip":this.state.showErrorTooltip});return _.createElement("div",{className:t},_.createElement(Ki,{ref:"input",className:te.INTERACTIVE,value:this.props.value,onChange:this.changeAndTrack,convertDotToTimes:this.props.times,buttonsVisible:this.props.buttonsVisible||"focused",buttonSets:this.props.buttonSets,onFocus:this._handleFocus,onBlur:this._handleBlur}),this.state.showErrorTooltip&&e)}}U(vr,"defaultProps",{value:"",times:!1,functions:[],buttonSets:["basic","trig","prealgebra","logarithms"],onFocus:()=>{},onBlur:()=>{},apiOptions:ee.defaults,linterContext:nn});const yr=e=>{const t=fr.EXPRESSION,n={},o={};for(const t of e.answerForms){const s=E.default.parse(t.value,e);if(s.parsed){const e=s.expr,t=e=>"pi"===e||"theta"===e,i=e=>t(e)?e.toUpperCase():e;for(const t of e.getVars())n[i(t)]=!0;for(const t of e.getConsts())o[i(t)]=!0}}const s=Object.keys(n);s.sort();const i=Object.keys(o);i.sort();const r=[...s,...i];return r.length||r.push("PI"),{keypadType:t,extraKeys:r}};var br={name:"expression",displayName:"Expression / Equation",defaultAlignment:"inline-block",widget:vr,transform:e=>{const{times:t,functions:n,buttonSets:o,buttonsVisible:s}=e;return{keypadConfiguration:yr(e),times:t,functions:n,buttonSets:o,buttonsVisible:s}},version:{major:1,minor:0},propUpgrades:{1:e=>({times:e.times,buttonSets:e.buttonSets,functions:e.functions,buttonsVisible:e.buttonsVisible,answerForms:[{considered:"correct",form:e.form,simplify:e.simplify,value:e.value}]})},isLintable:!0};class xr extends _.Component{render(){const e=M.default.uniq(this.props.answers),t=M.default.map(e,(e=>_.createElement("dd",{key:e},e)));return _.createElement("dl",{className:"perseus-possible-answers"},_.createElement("dt",null,k.doNotTranslate("Correct Answer")),t)}}U(xr,"propTypes",{answers:I.default.arrayOf(I.default.string)});const{KeypadInput:wr}=e.components,{KeypadTypes:Cr}=e.consts,{keypadElementPropType:kr}=e.propTypes,Sr=O.default({displayName:"SimpleKeypadInput",propTypes:{keypadElement:kr,onFocus:I.default.func,value:I.default.oneOfType([I.default.string,I.default.number])},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},focus(){this.refs.input.focus()},blur(){this.refs.input.blur()},getValue:function(){return this.props.value},render(){const e=this,{keypadElement:t,onFocus:n,value:o,...s}=e.props;return _.createElement(wr,G({ref:"input",keypadElement:t,onFocus:()=>{t?t.configure({keypadType:Cr.FRACTION},(()=>{e._isMounted&&n&&n()})):n&&n()},value:null==o?"":""+o},s))}}),Er=ie,_r={number:{name:"Numbers",forms:"integer, decimal, proper, improper, mixed"},decimal:{name:"Decimals",forms:"decimal"},integer:{name:"Integers",forms:"integer"},rational:{name:"Fractions and mixed numbers",forms:"integer, proper, improper, mixed"},improper:{name:"Improper numbers (no mixed)",forms:"integer, proper, improper"},mixed:{name:"Mixed numbers (no improper)",forms:"integer, proper, mixed"},percent:{name:"Numbers or percents",forms:"integer, decimal, proper, improper, mixed, percent"},pi:{name:"Numbers with pi",forms:"pi"}},Tr={integer:function(e){return k._("an integer, like $6$")},proper:function(e){return"optional"===e.simplify?k._("a *proper* fraction, like $1/2$ or $6/10$"):k._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return"optional"===e.simplify?k._("an *improper* fraction, like $10/7$ or $14/8$"):k._("a *simplified improper* fraction, like $7/4$")},mixed:function(e){return k._("a mixed number, like $1\\ 3/4$")},decimal:function(e){return k._("an *exact* decimal, like $0.75$")},percent:function(e){return k._("a percent, like $12.34\\%$")},pi:function(e){return k._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}};class Mr extends _.Component{constructor(){super(...arguments),U(this,"shouldShowExamples",(()=>"number"!==this.props.answerType&&!this.props.apiOptions.staticRender)),U(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t)})),U(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),U(this,"_handleFocus",(()=>{this.props.onFocus([]);const{interactionCallback:e}=this.props.apiOptions;e&&e()})),U(this,"_handleBlur",(()=>{this.props.onBlur([])})),U(this,"focus",(()=>(this.refs.input.focus(),!0))),U(this,"focusInputPath",(e=>{this.refs.input.focus()})),U(this,"blurInputPath",(e=>{this.refs.input.blur()})),U(this,"getInputPaths",(()=>[[]])),U(this,"getGrammarTypeForPath",(e=>"number")),U(this,"setInputValue",((e,t,n)=>{this.props.onChange({currentValue:t},n)})),U(this,"getUserInput",(()=>Mr.getUserInputFromProps(this.props))),U(this,"simpleValidate",((e,t)=>(t=t||function(){},Mr.validate(this.getUserInput(),e,t)))),U(this,"examples",(()=>{const e=this.props.answerType,t=_r[e].forms.split(/\s*,\s*/),n=M.default.map(t,(function(e){return Tr[e](this.props)}),this);return[k._("**Your answer should be** ")].concat(n)}))}render(){if(this.props.apiOptions.customKeypad){const e=_.createElement(Sr,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur});return this.props.rightAlign?_.createElement("div",{className:"perseus-input-right-align"},e):e}const e=this.props.reviewModeRubric;let t=null,n=null;if(this.props.apiOptions.satStyling&&e){const o=this.simpleValidate(e);if(t="points"===o.type&&o.earned===o.total,!t){let t=String(e.value);e.inexact&&e.maxError&&(t+=" ± "+e.maxError);const o=[t];n=_.createElement(xr,{answers:o})}}const o={};o["perseus-input-size-"+this.props.size]=!0,o["perseus-input-right-align"]=this.props.rightAlign,o[te.CORRECT]=e&&t&&this.props.currentValue,o[te.INCORRECT]=e&&!t&&this.props.currentValue,o[te.UNANSWERED]=e&&!this.props.currentValue;const s=_.createElement(ir,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:S.default(o),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,linterContext:this.props.linterContext});return n?_.createElement("span",{className:"perseus-input-with-answer-blurb"},s,n):s}static validate(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{};null==t.answerType&&(t.answerType="number");const o=Ee.number.createValidatorFunctional(t.value,{simplify:t.simplify,inexact:t.inexact||void 0,maxError:t.maxError,forms:_r[t.answerType].forms})(Er(e.currentValue));if(o.empty){return{type:"invalid",message:!1===(null==n?void 0:n(null,e.currentValue,o.message))?null:o.message}}return{type:"points",earned:o.correct?1:0,total:1,message:o.message}}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){if(null==e.value)return;let t=String(e.value);return e.inexact&&e.maxError&&(t+=" ± "+e.maxError),t}}U(Mr,"defaultProps",{currentValue:"",size:"normal",answerType:"number",rightAlign:!1,apiOptions:ee.defaults,linterContext:nn});var Ir={name:"input-number",displayName:"Number text box (old)",defaultAlignment:"inline-block",hidden:!0,widget:Mr,transform:e=>{const{simplify:t,size:n,answerType:o,rightAlign:s}=e;return{simplify:t,size:n,answerType:o,rightAlign:s}},isLintable:!0};const Pr=ie,Nr=[{title:"Integers",value:"integer",content:"6"},{title:"Decimals",value:"decimal",content:"0.75"},{title:"Proper fractions",value:"proper",content:"⅗"},{title:"Improper fractions",value:"improper",content:"⁷⁄₄"},{title:"Mixed numbers",value:"mixed",content:"1¾"},{title:"Numbers with π",value:"pi",content:"π"}],Ar={integer:()=>k._("an integer, like $6$"),proper:e=>"optional"===e.simplify?k._("a *proper* fraction, like $1/2$ or $6/10$"):k._("a *simplified proper* fraction, like $3/5$"),improper:e=>"optional"===e.simplify?k._("an *improper* fraction, like $10/7$ or $14/8$"):k._("a *simplified improper* fraction, like $7/4$"),mixed:()=>k._("a mixed number, like $1\\ 3/4$"),decimal:()=>k._("an *exact* decimal, like $0.75$"),pi:()=>k._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")};class Rr extends _.Component{constructor(){super(...arguments),U(this,"state",{previousValues:[""]}),U(this,"getAnswerBlurb",(e=>{let t,n;if(this.props.apiOptions.satStyling&&e){const o=this.simpleValidate(e);if(t="points"===o.type&&o.earned===o.total,!t){const t=M.default.filter(e.answers,(e=>"correct"===e.status)),o=M.default.map(t,(e=>{let t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);let n=Ce.toNumericString(e.value,t);return e.maxError&&(n+=" ± "+Ce.toNumericString(e.maxError,t)),n}));n=_.createElement(xr,{answers:o})}}return[n,!!t]})),U(this,"getClasses",((e,t)=>{const n={};return n["perseus-input-size-"+this.props.size]=!0,n["perseus-input-right-align"]=this.props.rightAlign,n[te.CORRECT]=t&&e&&this.props.currentValue,n[te.INCORRECT]=t&&!e&&this.props.currentValue,n[te.UNANSWERED]=t&&!this.props.currentValue,n})),U(this,"examples",(()=>{var e;const t=0!==(null===(e=this.props.answerForms)||void 0===e?void 0:e.length)?this.props.answerForms:M.default.map(M.default.keys(Ar),(e=>({name:e,simplify:"required"})));let n=M.default.map(t,(e=>Ar[e.name](e)));return n=M.default.uniq(n),[k._("**Your answer should be** ")].concat(n)})),U(this,"shouldShowExamples",(()=>{var e,t;const n=0===(null===(e=this.props.answerForms)||void 0===e?void 0:e.length),o=M.default.uniq(null===(t=this.props.answerForms)||void 0===t?void 0:t.map((e=>e.name))).length>=M.default.size(Ar);return!n&&!o})),U(this,"simpleValidate",(e=>Rr.validate(this.getUserInput(),e))),U(this,"focus",(()=>(this.refs.input.focus(),!0))),U(this,"focusInputPath",(e=>{this.refs.input.focus()})),U(this,"blurInputPath",(e=>{this.refs.input.blur()})),U(this,"getInputPaths",(()=>[[]])),U(this,"getGrammarTypeForPath",(e=>"number")),U(this,"setInputValue",((e,t,n)=>{this.props.onChange({currentValue:t},n)})),U(this,"getUserInput",(()=>Rr.getUserInputFromProps(this.props))),U(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t),this.props.trackInteraction()})),U(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),U(this,"_handleFocus",(()=>{this.props.onFocus([]);const{interactionCallback:e}=this.props.apiOptions;e&&e()})),U(this,"_handleBlur",(()=>{this.props.onBlur([])}))}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){const t=M.default.filter(e.answers,(e=>"correct"===e.status)),n=M.default.map(t,(e=>{let t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);let n=Ce.toNumericString(e.value,t);return e.maxError&&(n+=" ± "+Ce.toNumericString(e.maxError,t)),n}));if(0!==n.length)return n[0]}static validate(e,t){const n=M.default.pluck(Nr,"value"),o=e=>Ee.number.createValidatorFunctional(e.value,{message:e.message,simplify:"correct"===e.status?e.simplify:"optional",inexact:!0,maxError:e.maxError,forms:e.strict&&e.answerForms&&0!==e.answerForms.length?e.answerForms:n}),s=Pr(e.currentValue),i=M.default.where(t.answers,{status:"correct"}),r=i.every((e=>Math.abs(e.value)<=1));let a=M.default.find(M.default.map(i,(e=>{let n=s;t.coefficient&&(n?"-"===n&&(n=-1):n=1);return o(e)(Or(n,r))})),(e=>e.correct||e.empty));if(!a){const e=[].concat(M.default.where(t.answers,{status:"ungraded"}),M.default.where(t.answers,{status:"wrong"})),n=M.default.find(e,(e=>o(e)(Or(s,r)).correct));a={empty:!!n&&"ungraded"===n.status,correct:!!n&&"correct"===n.status,message:n?n.message:null,guess:s}}return a.empty?{type:"invalid",message:a.message}:{type:"points",earned:a.correct?1:0,total:1,message:a.message}}render(){const e=this.props.reviewModeRubric,t=this.getAnswerBlurb(e),n=t[0],o=t[1],s=this.getClasses(o,e);let i=this.props.labelText;null!=i&&""!==i||(i=k._("Your answer:"));const r=e=>this.props.rightAlign?_.createElement("div",{className:"perseus-input-right-align"},e):e;if(this.props.apiOptions.customKeypad)return r(_.createElement(Sr,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur}));const a=_.createElement(ir,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:S.default(s),labelText:i,type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,highlightLint:this.props.highlightLint});return n?_.createElement("span",{className:"perseus-input-with-answer-blurb"},a,n):this.props.apiOptions.satStyling?_.createElement("label",{className:"perseus-input-with-label"},_.createElement("span",{className:"perseus-input-label","aria-hidden":"true"},k.doNotTranslate("Answer:")),a):_.createElement("div",null,a)}}U(Rr,"defaultProps",{currentValue:"",size:"normal",rightAlign:!1,apiOptions:ee.defaults,coefficient:!1,answerForms:[],labelText:"",linterContext:nn,multipleNumberInput:!1});const Fr=function(e){const t=M.default.flatten(e),n=(o=t,s=M.default.isEqual,M.default.reduce(o,((e,t)=>M.default.find(e,s.bind(null,t))?e:e.concat([t])),[]));var o,s;return M.default.sortBy(n,(e=>M.default.keys(Ar).indexOf(e.name)))},Or=(e,t)=>{if("string"!=typeof e||!e.endsWith("%"))return e;const n=parseFloat(e.slice(0,-1));return isNaN(n)?e:t?n/100:n};var Dr={name:"numeric-input",displayName:"Number text box",defaultAlignment:"inline-block",accessible:!0,widget:Rr,transform:function(e){return M.default.extend(M.default.omit(e,"answers"),{answerForms:Fr(M.default.map(e.answers,(e=>M.default.map(e.answerForms,(t=>({simplify:e.simplify,name:t}))))))})},isLintable:!0};const Lr={getUserInput:function(){return M.default.omit(this.props,rr)},getUserInputFromProps:function(e){return M.default.omit(e,rr)}};class Br extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"displayName","PassageRef"),U(this,"_isMounted",void 0),U(this,"_throttledUpdateRange",void 0),U(this,"state",{lineRange:null,content:null}),U(this,"getUserInput",(()=>Lr.getUserInput.call(this))),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"_deferredUpdateRange",(()=>{M.default.defer(this._updateRange)})),U(this,"_updateRange",(()=>{const e=this.props.findWidgets("passage "+this.props.passageNumber)[0];let t=null;e&&(t=e.getReference(this.props.referenceNumber)),this._isMounted&&(t?this.setState({lineRange:[t.startLine,t.endLine],content:t.content}):this.setState({lineRange:null,content:null}))})),U(this,"simpleValidate",(e=>Br.validate(this.getUserInput(),e)))}shouldComponentUpdate(e,t){return!M.default.isEqual(this.props,e)||!M.default.isEqual(this.state,t)}render(){const e=this.state.lineRange;let t,n;if(t=e?e[0]===e[1]?k.$_("line %(lineNumber)s",{lineNumber:e[0]}):k.$_("lines %(lineRange)s",{lineRange:e[0]+"–"+e[1]}):k.$_("lines %(lineRange)s",{lineRange:"?".concat("–","?")}),this.props.summaryText){const e=it.parseInline(this.props.summaryText);n=_.createElement("span",{"aria-hidden":!0}," ","(“",it.basicOutput(e),"”)")}else n=null;return _.createElement("span",null,t,n,e&&_.createElement("div",{className:"perseus-sr-only"},this.state.content))}componentDidMount(){this._isMounted=!0,this._deferredUpdateRange(),this._throttledUpdateRange=M.default.throttle(this._deferredUpdateRange,500),window.addEventListener("resize",this._throttledUpdateRange)}componentDidUpdate(){this._deferredUpdateRange()}componentWillUnmount(){window.removeEventListener("resize",this._throttledUpdateRange),this._isMounted=!1}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}U(Br,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});var zr={name:"passage-ref",displayName:"PassageRef (SAT only)",defaultAlignment:"inline",widget:Br,transform:e=>({passageNumber:e.passageNumber,referenceNumber:e.referenceNumber,summaryText:e.summaryText}),version:{major:0,minor:1}};const{pureXsMax:qr,pureSmMin:Hr,pureSmMax:Wr,pureMdMin:Ur,pureMdMax:Gr,pureLgMin:Vr,pureLgMax:jr,pureXlMin:Yr}=me;var $r={xs:"@media screen and (max-width: ".concat(qr,")"),sm:"@media screen and (min-width: ".concat(Hr,") and ")+"(max-width: ".concat(Wr,")"),md:"@media screen and (min-width: ".concat(Ur,") and ")+"(max-width: ".concat(Gr,")"),lg:"@media screen and (min-width: ".concat(Vr,") and ")+"(max-width: ".concat(jr,")"),xl:"@media screen and (min-width: ".concat(Yr,")"),xsOrSmaller:"@media screen and (max-width: ".concat(qr,")"),smOrSmaller:"@media screen and (max-width: ".concat(Wr,")"),mdOrSmaller:"@media screen and (max-width: ".concat(Gr,")"),lgOrSmaller:"@media screen and (max-width: ".concat(jr,")"),smOrLarger:"@media screen and (min-width: ".concat(Hr,")"),mdOrLarger:"@media screen and (min-width: ".concat(Ur,")"),lgOrLarger:"@media screen and (min-width: ".concat(Vr,")"),xlOrLarger:"@media screen and (min-width: ".concat(Yr,")")};const{zIndexAboveScratchpad:Xr,zIndexInteractiveComponent:Kr,radioBorderColor:Zr,checkedColor:Jr,circleSize:Qr,radioMarginWidth:ea}=me;var ta=d.StyleSheet.create({perseusInteractive:{zIndex:Kr,position:"relative"},aboveScratchpad:{position:"relative",zIndex:Xr},blankBackground:{backgroundColor:"#FDFDFD"},perseusSrOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1},responsiveLabel:{[$r.smOrSmaller]:{fontSize:14,lineHeight:1.3},[$r.md]:{fontSize:17,lineHeight:1.4},[$r.lgOrLarger]:{fontSize:20,lineHeight:1.4}},responsiveInput:{display:"inline-block",WebkitAppearance:"none",appearance:"none","::-ms-check":{display:"none"},backgroundColor:"#fff",border:"2px solid #fff",boxShadow:"0 0px 0px 1px ".concat(Zr),outline:"none",boxSizing:"border-box",flexShrink:0,marginBottom:1,marginLeft:1,marginRight:1,marginTop:1,height:Qr-2,width:Qr-2},responsiveRadioInput:{borderRadius:"50%",":checked":{backgroundColor:Jr,border:"none",borderRadius:"50%",boxShadow:"inset 0px 0px 0px 2px white, "+"0 0px 0px 2px ".concat(Jr),marginTop:ea,marginBottom:ea,marginLeft:ea,marginRight:ea,height:Qr-2*ea,width:Qr-2*ea}},responsiveRadioInputActive:{backgroundColor:"#fff",border:"2px solid #fff",borderRadius:"50%",boxShadow:"0 0px 0px 2px ".concat(Jr),marginTop:ea,marginBottom:ea,marginLeft:ea,marginRight:ea,height:Qr-2*ea,width:Qr-2*ea,":checked":{backgroundColor:"#fff"}},disableTextSelection:{userSelect:"none"}});"undefined"==typeof HTMLElement||HTMLElement.prototype.scrollTo||(HTMLElement.prototype.scrollTo=function(e,t){this.scrollLeft=e,this.scrollTop=t});const na=(e,t)=>{"function"==typeof e.scrollTo?e.scrollTo(0,t):"scrollTop"in e&&(e.scrollTop=t)},oa=e=>e===document.body||null==e?window:e.scrollHeight>e.clientHeight?e:oa(e.parentElement),sa=(e,t)=>{setTimeout((()=>{const n=oa(e),o=e.getBoundingClientRect(),s=n===window?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect();let i=0;const r=n===window?window.scrollY:n.scrollTop;if(o.bottom>s.bottom){let e=o.bottom-s.bottom;o.top+e<s.top&&(e=o.top-s.top),i=r+e}else if(o.top<s.top){i=r+(o.top-s.top)}!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;const s=e===window?window.pageYOffset:e.scrollTop,i=t,r=i-s,a=17,l=n/a;let c=0;const d=setInterval((function(){if(c<l){const t=c/l,n=(1-Math.cos(Math.PI*t))/2;na(e,s+r*n),c+=1}else na(e,i),clearInterval(d),o&&o()}),a)}(n,i,750,t)}),0)};class ia extends _.Component{render(){const e={borderColor:this.props.visible?this.props.color:"transparent"};return _.createElement("span",{className:d.css(ra.ring),style:e},this.props.children)}}U(ia,"defaultProps",{visible:!0,color:"#71B307"});const ra=d.StyleSheet.create({ring:{margin:"auto",display:"inline-block",borderRadius:"50%",borderWidth:2,padding:2,borderStyle:"solid"}});function aa(e){const t=k._("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z").split(" ");return e<t.length?t[e]:" "}class la extends _.Component{constructStyles(e,t,n){let o,s="#0084CE",i="#0084CE";return e?t?(s="#009900",i=n?de:"#009900",o=n?"#009900":de):n&&(s="#990000",i=de,o="#990000"):n&&(i=de,o="#0084CE"),{color:i,backgroundColor:o,borderColor:s}}render(){const{letter:e,a11yText:t,reviewMode:n,checked:o,correct:s,crossedOut:i}=this.props,{color:r,backgroundColor:a,borderColor:l}=this.constructStyles(n,s,o);return _.createElement("div",{className:d.css(ua.iconWrapper)},_.createElement("div",{className:d.css(ua.satCircle),style:{backgroundColor:a,borderColor:l}}),_.createElement("div",{style:{color:r},className:d.css(ua.letter)},_.createElement("span",{className:"perseus-sr-only"},t),_.createElement("span",{"aria-hidden":"true"},e)),i&&_.createElement(da,{color:l,sat:!0}))}}class ca extends _.Component{getChoiceInner(){const{letter:e,showCorrectness:t,correct:n}=this.props;return t?n?_.createElement(V,G({},yo,{style:{position:"relative",top:-1}})):_.createElement(V,Fo):e}getDynamicStyles(){const{checked:e,showCorrectness:t,pressed:n,primaryProductColor:o,correct:s,transparentBackground:i}=this.props;if(!t&&n)return{borderColor:o,color:o,backgroundColor:i?"transparent":de};if(e){const e=t&&s?"#71B307":o;return{color:de,backgroundColor:e,borderColor:e}}return{borderColor:ue,color:ue}}render(){const{a11yText:e,checked:t,crossedOut:n,showCorrectness:o,correct:s,focused:i,primaryProductColor:r,previouslyAnswered:a}=this.props,l=this.getDynamicStyles();return _.createElement("div",{className:d.css(ua.iconWrapper)},_.createElement(ia,{color:r,visible:i},_.createElement("div",{style:l,className:d.css(ua.libraryCircle,o&&s&&ua.libraryCircleCorrect,o&&!s&&ua.libraryCircleIncorrect,o&&!s&&(t||a)&&ua.libraryCircleIncorrectAnswered),"data-is-radio-icon":!0},_.createElement("div",{className:"perseus-sr-only"},e),_.createElement("div",{"aria-hidden":!0},this.getChoiceInner()))),n&&_.createElement(da,{color:l.borderColor}))}}function da(e){const t=e.sat?29:28;return _.createElement("svg",{width:t,height:t,viewBox:"0 0 ".concat(t," ").concat(t),className:d.css(ua.crossOutLine)},_.createElement("line",{x1:2,x2:t-2,y1:t-2,y2:2,stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}))}class pa extends _.Component{a11yText(e){const{checked:t,correct:n,crossedOut:o,showCorrectness:s}=this.props;return s&&n?t?k._("(Choice %(letter)s, Checked, Correct)",{letter:e}):o?k._("(Choice %(letter)s, Crossed out, Correct)",{letter:e}):k._("(Choice %(letter)s, Correct)",{letter:e}):s&&!n?t?k._("(Choice %(letter)s, Checked, Incorrect)",{letter:e}):o?k._("(Choice %(letter)s, Crossed out, Incorrect)",{letter:e}):k._("(Choice %(letter)s, Incorrect)",{letter:e}):t?k._("(Choice %(letter)s, Checked)",{letter:e}):o?k._("(Choice %(letter)s, Crossed out)",{letter:e}):k._("(Choice %(letter)s)",{letter:e})}render(){const{pos:e,reviewMode:t,checked:n,crossedOut:o,correct:s,product:i,showCorrectness:r,pressed:a,focused:l,primaryProductColor:c,previouslyAnswered:d,transparentBackground:p}=this.props,u=aa(e);return"sat"===i?_.createElement(la,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:n,correct:s,crossedOut:o}):_.createElement(ca,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:n,crossedOut:o,pressed:a,focused:l,correct:s,showCorrectness:r,primaryProductColor:c,previouslyAnswered:d,transparentBackground:p})}}U(pa,"defaultProps",{primaryProductColor:"#71B307"});const ua=d.StyleSheet.create({satCircle:{display:"block",borderRadius:25,borderStyle:"solid",borderWidth:2,content:"''",height:25,width:25,top:1,left:1},iconWrapper:{display:"inline-block",position:"relative"},crossOutLine:{position:"absolute",top:"calc(50% - ".concat(14,"px)"),left:"calc(50% - ".concat(14,"px)")},libraryCircle:{width:24,height:24,boxSizing:"border-box",borderRadius:24,borderStyle:"solid",borderWidth:2,fontFamily:"'Proxima Nova',sans-serif",fontWeight:"bold",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1px"},libraryCircleCorrect:{fontSize:24},libraryCircleIncorrect:{fontSize:24,borderColor:ue,color:ue},libraryCircleIncorrectAnswered:{backgroundColor:"#F86700",borderColor:"#F86700",color:de},letter:{border:"2px solid transparent",width:25,height:25,position:"absolute",top:1,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:ce,fontSize:13}});class ha extends _.Component{render(){const{color:e,pathClassName:t,className:n,title:o,style:s,alt:i}=this.props;let{icon:r,size:a}=this.props,l="";"string"==typeof r&&(r={path:r,width:10,height:10}),"number"!=typeof a&&(a=1,l="em");const c=a,d=c/r.height*r.width,p=!!this.props.focusable;return _.createElement("svg",{role:"img",alt:i,"aria-label":o,"aria-hidden":!o||null,className:n,style:s,focusable:p.toString(),width:d+l,height:c+l,viewBox:"".concat(0," ").concat(0," ").concat(r.width," ").concat(r.height)},!!o&&_.createElement("title",null,o),_.createElement("path",{className:t,fill:e,d:r.path}))}}function fa(){return fa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},fa.apply(this,arguments)}function ma(e,t){if(null==e)return{};var n,o,s={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(s[n]=e[n]);return s}U(ha,"defaultProps",{color:"currentColor"});const ga="@media (max-width: 1023px)",va="@media (min-width: 1024px)",ya={display:"block"},ba='Lato, "Noto Sans", sans-serif',xa=d.StyleSheet.create({Title:fa({},ya,{fontFamily:ba,fontWeight:900,[va]:{fontSize:36,lineHeight:"40px"},[ga]:{fontSize:28,lineHeight:"32px"}}),Tagline:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:20,lineHeight:"24px"}),HeadingLarge:fa({},ya,{fontFamily:ba,fontWeight:700,[va]:{fontSize:28,lineHeight:"32px"},[ga]:{fontSize:24,lineHeight:"28px"}}),HeadingMedium:fa({},ya,{fontFamily:ba,fontWeight:700,[va]:{fontSize:24,lineHeight:"28px"},[ga]:{fontSize:22,lineHeight:"26px"}}),HeadingSmall:fa({},ya,{fontFamily:ba,fontWeight:700,fontSize:20,lineHeight:"24px"}),HeadingXSmall:fa({},ya,{fontFamily:ba,fontWeight:700,fontSize:12,lineHeight:"16px",letterSpacing:.6,textTransform:"uppercase"}),BodySerifBlock:fa({},ya,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:22,lineHeight:"28px"}),BodySerif:fa({},ya,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:18,lineHeight:"22px"}),BodyMonospace:fa({},ya,{fontFamily:"Inconsolata, monospace",fontWeight:400,fontSize:17,lineHeight:"22px"}),Body:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:16,lineHeight:"22px"}),LabelLarge:fa({},ya,{fontFamily:ba,fontWeight:700,fontSize:16,lineHeight:"20px"}),LabelMedium:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:16,lineHeight:"20px"}),LabelSmall:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:14,lineHeight:"18px"}),LabelXSmall:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:12,lineHeight:"16px"}),Caption:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:14,lineHeight:"20px"}),Footnote:fa({},ya,{fontFamily:ba,fontWeight:400,fontSize:12,lineHeight:"18px"})}),wa=["style","children"];class Ca extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,wa);return _.createElement(m.Text,fa({},o,{style:[xa.Title,t]}),n)}}Ca.defaultProps={tag:"h1"};const ka=["style","children"];class Sa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,ka);return _.createElement(m.Text,fa({},o,{style:[xa.HeadingLarge,t]}),n)}}Sa.defaultProps={tag:"h2"};const Ea=["style","children"];class _a extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ea);return _.createElement(m.Text,fa({},o,{style:[xa.HeadingMedium,t]}),n)}}_a.defaultProps={tag:"h3"};const Ta=["style","children"];class Ma extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ta);return _.createElement(m.Text,fa({},o,{style:[xa.HeadingSmall,t]}),n)}}Ma.defaultProps={tag:"h4"};const Ia=["style","children"];class Pa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ia);return _.createElement(m.Text,fa({},o,{style:[xa.HeadingXSmall,t]}),n)}}Pa.defaultProps={tag:"h4"};const Na=["style","children"];class Aa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Na);return _.createElement(m.Text,fa({},o,{style:[xa.BodySerifBlock,t]}),n)}}Aa.defaultProps={tag:"span"};const Ra=["style","children"];class Fa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ra);return _.createElement(m.Text,fa({},o,{style:[xa.BodySerif,t]}),n)}}Fa.defaultProps={tag:"span"};const Oa=["style","children"];class Da extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Oa);return _.createElement(m.Text,fa({},o,{style:[xa.BodyMonospace,t]}),n)}}Da.defaultProps={tag:"span"};const La=["style","children"];class Ba extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,La);return _.createElement(m.Text,fa({},o,{style:[xa.Body,t]}),n)}}Ba.defaultProps={tag:"span"};const za=["style","children"];class qa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,za);return _.createElement(m.Text,fa({},o,{style:[xa.LabelLarge,t]}),n)}}qa.defaultProps={tag:"span"};const Ha=["style","children"];class Wa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ha);return _.createElement(m.Text,fa({},o,{style:[xa.LabelMedium,t]}),n)}}Wa.defaultProps={tag:"span"};const Ua=["style","children"];class Ga extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ua);return _.createElement(m.Text,fa({},o,{style:[xa.LabelSmall,t]}),n)}}Ga.defaultProps={tag:"span"};const Va=["style","children"];class ja extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Va);return _.createElement(m.Text,fa({},o,{style:[xa.LabelXSmall,t]}),n)}}ja.defaultProps={tag:"span"};const Ya=["style","children"];class $a extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Ya);return _.createElement(m.Text,fa({},o,{style:[xa.Tagline,t]}),n)}}$a.defaultProps={tag:"span"};const Xa=["style","children"];class Ka extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Xa);return _.createElement(m.Text,fa({},o,{style:[xa.Caption,t]}),n)}}Ka.defaultProps={tag:"span"};const Za=["style","children"];class Ja extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ma(e,Za);return _.createElement(m.Text,fa({},o,{style:[xa.Footnote,t]}),n)}}Ja.defaultProps={tag:"span"};var Qa=Object.freeze({__proto__:null,black:"#000000",grayDarker:"#333333",grayDark:"#555555",gray:"#999999",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",white:"#FFFFFF",blue:"#005A88",blueDark:"#2C3747",green:"#76A005",red:"#CF5044",yellow:"#FFC40D",orange:"#BF4F04",pink:"#C3325F",purple:"#7A43B6",bodyBackground:"#FFFFFF",textColor:"#444444",linkColor:"#005987",linkColorHover:"#678D00",sansFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",serifFontFamily:"Georgia,'Times New Roman',Times,serif",monoFontFamily:"Monaco,Menlo,Consolas,'Courier New',monospace",baseFontSize:"14px",baseFontFamily:"inherit",baseLineHeight:"20px",altFontFamily:"Georgia,'Times New Roman',Times,serif",headingsFontFamily:"inherit",headingsFontWeight:"bold",headingsColor:"inherit",fontSizeLarge:"18px",fontSizeSmall:"12px",fontSizeMini:"10.5px",paddingLarge:"11px 19px",paddingSmall:"2px 10px",paddingMini:"0 6px",baseBorderRadius:"4px",borderRadiusLarge:"6px",borderRadiusSmall:"3px",tableBackground:"#000000",tableBackgroundAccent:"#F9F9F9",tableBackgroundHover:"#F5F5F5",tableBorder:"#DDDDDD",btnBackground:"#FFFFFF",btnBackgroundHighlight:"rgb(230, 230, 230)",btnBorder:"#CCCCCC",btnPrimaryBackground:"#0088CC",btnPrimaryBackgroundHighlight:"rgb(0, 68, 204)",btnInfoBackground:"#5BC0DE",btnInfoBackgroundHighlight:"#2F96B4",btnSuccessBackground:"#62C462",btnSuccessBackgroundHighlight:"#51A351",btnWarningBackground:"rgb(251, 180, 81)",btnWarningBackgroundHighlight:"#F89406",btnDangerBackground:"#EE5F5B",btnDangerBackgroundHighlight:"#BD362F",btnInverseBackground:"#444444",btnInverseBackgroundHighlight:"#222222",inputBackground:"#FFFFFF",inputBorder:"#CCCCCC",inputBorderRadius:"4px",inputDisabledBackground:"#EEEEEE",formActionsBackground:"#F5F5F5",inputHeight:"30px",dropdownBackground:"#FFFFFF",dropdownBorder:"rgba(0, 0, 0, 0.2)",dropdownDividerTop:"#E5E5E5",dropdownDividerBottom:"#FFFFFF",dropdownLinkColor:"#333333",dropdownLinkColorHover:"#FFFFFF",dropdownLinkColorActive:"#FFFFFF",dropdownLinkBackgroundActive:"#0088CC",dropdownLinkBackgroundHover:"#0088CC",zindexDropdown:1e3,zindexPopover:1010,zindexTooltip:1030,zindexFixedNavbar:1030,zindexHeader:1060,zindexModalBackdrop:1070,zindexModal:1080,zindexAboveModal:1090,iconSpritePath:"../img/glyphicons-halflings.png",iconWhiteSpritePath:"../img/glyphicons-halflings-white.png",placeholderText:"#999999",hrBorder:"#EEEEEE",horizontalComponentOffset:"180px",wellBackground:"#F5F5F5",navbarCollapseWidth:"979px",navbarCollapseDesktopWidth:"980px",navbarHeight:"40px",navbarBackgroundHighlight:"#FFFFFF",navbarBackground:"rgb(242, 242, 242)",navbarBorder:"rgb(212, 212, 212)",navbarText:"#777777",navbarLinkColor:"#777777",navbarLinkColorHover:"#333333",navbarLinkColorActive:"#555555",navbarLinkBackgroundHover:"#000000",navbarLinkBackgroundActive:"rgb(230, 230, 230)",navbarBrandColor:"#777777",navbarInverseBackground:"#111111",navbarInverseBackgroundHighlight:"#222222",navbarInverseBorder:"#252525",navbarInverseText:"#999999",navbarInverseLinkColor:"#999999",navbarInverseLinkColorHover:"#FFFFFF",navbarInverseLinkColorActive:"#FFFFFF",navbarInverseLinkBackgroundHover:"#000000",navbarInverseLinkBackgroundActive:"#111111",navbarInverseSearchBackground:"rgb(82, 82, 82)",navbarInverseSearchBackgroundFocus:"#FFFFFF",navbarInverseSearchBorder:"#111111",navbarInverseSearchPlaceholderColor:"#CCCCCC",navbarInverseBrandColor:"#999999",paginationBackground:"#FFFFFF",paginationBorder:"#DDDDDD",paginationActiveBackground:"#F5F5F5",heroUnitBackground:"#EEEEEE",heroUnitHeadingColor:"inherit",heroUnitLeadColor:"inherit",warningText:"#C09853",warningBackground:"#FCF8E3",warningBorder:"rgb(251, 239, 213)",errorText:"#B94A48",errorBackground:"#F2DEDE",errorBorder:"rgb(238, 211, 215)",successText:"#468847",successBackground:"#DFF0D8",successBorder:"rgb(212, 232, 197)",infoText:"#4A7C17",infoBackground:"#EDF2DF",infoBorder:"rgb(228, 232, 197)",tooltipColor:"#FFFFFF",tooltipBackground:"#000000",tooltipArrowWidth:"5px",tooltipArrowColor:"#000000",popoverBackground:"#FFFFFF",popoverArrowWidth:"10px",popoverArrowColor:"#FFFFFF",popoverTitleBackground:"rgb(247, 247, 247)",popoverArrowOuterWidth:"11px",popoverArrowOuterColor:"rgba(0, 0, 0, 0.25)",gridColumns:"12",gridColumnWidth:"60px",gridGutterWidth:"20px",gridRowWidth:"940px",gridColumnWidth1200:"70px",gridGutterWidth1200:"30px",gridRowWidth1200:"1170px",gridColumnWidth768:"42px",gridGutterWidth768:"20px",gridRowWidth768:"724px",fluidGridColumnWidth:"6.382978723404255%",fluidGridGutterWidth:"2.127659574468085%",fluidGridColumnWidth1200:"5.982905982905983%",fluidGridGutterWidth1200:"2.564102564102564%",fluidGridColumnWidth768:"5.801104972375691%",fluidGridGutterWidth768:"2.7624309392265194%",kaGreen:"#71B307",kaGreenLight:"#BED47A",kaBlue:"#314453",kaBlueLight:"#4D6779",grayExtraDark:"#111111",grayExtraLight:"#EEEEEE",graySuperLight:"#F7F7F7",whiteDark:"#FDFDFD",dark:"#21242C",blueDarkUnsaturated:"#3B414E",blueDarkSaturated:"#1F3043",blueLight:"#A9C0D1",greenLight:"#C6D1AD",greenDark:"#356700",yellowGreen:"#9DB63B",okGreen:"#A7CF5B",alertRed:"#C42420",coral:"#EE6666",grayBlue:"#9AB3B9",lightPageBackground:"#FDFDFD",yclaBlue:"#49BAD5",yclaTeal:"#56D0B3",yclaTealDark:"#50C1A7",yclaGreenDark:"#3D9A82",yclaGreen:"#81C262",learnstormBlue:"#4898FC",homepageBlue:"#46A8BF",backgroundBlue:"#00294A",teacherSignupBlue:"#335d7d",homepageGreen:"#2B8E7B",streakColor:"#F79734",facebookColor:"#1A60A2",blueGoogleColor:"#2CAFE2",redGoogleColor:"#BF4434",homepageColor:"#2D585E",lightTextColor:"#898989",fontSizeTiny:"11px",fontSizeNormal:"14px",fontSizeMedium:"16px",fontSizeExtraLarge:"24px",fontSizeHuge:"36px",fontSizeBakana:"48px",fontSizeBananas:"60px",fixedWidthFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",contentPadding:"20px",primaryButtonBackground:"#89B908",primaryButtonBorder:"#76A005",buttonTextColor:"rgb(122, 122, 122)",buttonBorderRadius:"3px",basicBorderColor:"#CCCCCC",minContainerWidth:"1000px",maxContainerWidth:"1200px",formHintColor:"#999999",guidelineExampleText:"#606060",hoverCardWidth:"450px",menuHighlightColor:"#96AB4F",menuHighlightBorderColor:"#76A005",menuActiveTextColor:"#FFFFFF",menuInactiveTextColor:"#444444",menuSubheaderTextColor:"rgb(120, 120, 120)",menuBorderColor:"#94A170",unreadBackgroundColor:"#ECEEF4",menuLineHeight:"18px",menuSubheaderLineHeight:"17px",menuSubheaderFontSize:"9px",notificationBarColor:"#4858A4",modalBodyTopPadding:"20px",modalDialogPadding:"15px",modalSectionPadding:"9px",mathDomain1:"#11ACCD",mathDomain2:"#63D9EA",mathDomain3:"#027d97",mathDomain4:"#085566",partnerContentDomain1:"#01A995",partnerContentDomain2:"#01D1C1",partnerContentDomain3:"#208170",partnerContentDomain4:"#144F44",csDomain1:"#1FAB54",csDomain2:"#74CF70",csDomain3:"#0D923F",csDomain4:"#085E29",economicsDomain1:"#E07D10",economicsDomain2:"#FFBE26",economicsDomain3:"#A75A05",economicsDomain4:"#953C02",collegeCareersMoreDomain1:"#01A995",collegeCareersMoreDomain2:"#01D1C1",collegeCareersMoreDomain3:"#208170",collegeCareersMoreDomain4:"#144F44",humanitiesDomain1:"#E84D39",humanitiesDomain2:"#FF8482",humanitiesDomain3:"#BE2612",humanitiesDomain4:"#8C1C0D",gtpDomain1:"#1865F2",gtpDomain2:"#1865F2",gtpDomain3:"#1865F2",gtpDomain4:"#1865F2",scienceDomain1:"#CA337C",scienceDomain2:"#FF92C6",scienceDomain3:"#9E034E",scienceDomain4:"#6B0235",testPrepDomain1:"#1865F2",testPrepDomain2:"#1865F2",testPrepDomain3:"#1865F2",testPrepDomain4:"#1865F2",defaultDomain1:"#1865F2",defaultDomain2:"#66afe9",defaultDomain3:"#1152b0",defaultDomain4:"#0d3d82",defaultDomainColor:"#314453",defaultSubjectColor:"#4D6779",defaultTopicColor:"#6A8DA6",defaultHoverColor:"#314453",defaultLinkColor:"#314453",defaultLinkHoverColor:"#6A8DA6",scienceDomainColor:"#94424F",scienceSubjectColor:"#9D4A5A",scienceTopicColor:"#C55F73",scienceHoverColor:"#94424F",scienceLinkColor:"#94424F",scienceLinkHoverColor:"#C55F73",humanitiesDomainColor:"#AD3434",humanitiesSubjectColor:"#C13B31",humanitiesTopicColor:"#D24A45",humanitiesHoverColor:"#AD3434",humanitiesLinkColor:"#AD3434",humanitiesLinkHoverColor:"#D24A45",economicsDomainColor:"#B77033",economicsSubjectColor:"#BF7B34",economicsTopicColor:"#D1933B",economicsHoverColor:"#B77033",economicsLinkColor:"#B77033",economicsLinkHoverColor:"#D1933B",csDomainColor:"#437A39",csSubjectColor:"#53893E",csTopicColor:"#689B51",csHoverColor:"#437A39",csLinkColor:"#437A39",csLinkHoverColor:"#689B51",partnerContentDomainColor:"#218270",partnerContentSubjectColor:"#2C8D7B",partnerContentTopicColor:"#329A86",partnerContentHoverColor:"#218270",partnerContentLinkColor:"#218270",partnerContentLinkHoverColor:"#329A86",essayDomainColor:"#0071B3",mathDomainColor:"#1C758A",mathSubjectColor:"#46A8BF",mathTopicColor:"#4FBAD4",mathHoverColor:"#1C758A",mathLinkColor:"#1C758A",mathLinkHoverColor:"#4FBAD4",testPrepDomainColor:"#644172",testPrepSubjectColor:"#7E5F8E",testPrepTopicColor:"#9A72AC",testPrepHoverColor:"#644172",testPrepLinkColor:"#644172",testPrepLinkHoverColor:"#9A72AC",collegeCareersMoreDomainColor:"#218270",collegeCareersMoreSubjectColor:"#2C8D7B",collegeCareersMoreTopicColor:"#329A86",collegeCareersMoreHoverColor:"#218270",collegeCareersMoreLinkColor:"#218270",collegeCareersMoreLinkHoverColor:"#329A86",satDomainColor:"#0084CE",satSubjectColor:"#0084CE",satTopicColor:"#0084CE",satHoverColor:"#0084CE",satLinkColor:"#0084CE",satLinkHoverColor:"#0084CE",colorProficient:"#1C758A",colorPracticed:"rgb(158, 221, 235)",colorMastery1:"rgb(90, 197, 221)",colorMastery2:"rgb(42, 174, 203)",colorMastery3:"#1C758A",colorSuggested:"#73982C",colorReview:"#E35D04",colorNotStarted:"#CCCCCC",colorStarted:"#C7E5F7",colorStruggling:"#C30202",colorPersonal:"#00809C",colorPractice:"#96D9FF",colorEnergyPoints:"#005987",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1200px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1199px"});const el={white:"#FFFFFF",gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:"#BABEC2",gray72:"#999A9D",gray68:"#888D93",gray55:"#707378",gray41:"#626569",gray25:"#3B3E40",gray17:"#21242C",gray10:"#1499af",black:"#000000",alertRed:"#C42420",homepageBlue:"#46A8BF",kaBlue:"#314453",kaBlueLight:"#4D6779",kaGreen:"#71B307",kaGreenLight:"#BED47A",learnstormBlue:"#4898FC",backgroundBlue:"#00294A",adminGreen:"#78C008",kaBlueExtraLight:"#39c2db",kaBlueHover:"#0c7f99",kaGreenHover:"#518005",skyDark:"#001f4d",recommendationGold:"#ffbe26",starAced:"#ff9c39",google:"#C1432f",modernGoogle:"#be2612",modernGoogleHover:"#8c1c0d",facebook:"#4267B2",modernFacebook:"#4267B2",modernFacebookHover:"#00294a",wonderBlocksGold:"#FFB100",wonderBlocksLightBlue:"#37C5FD",breadcrumbs:"rgba(255, 255, 255, 0.7)"},tl={color:el.breadcrumbs,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased"},nl={regular:"inherit"},ol={subjectHeadingDesktop:{fontFamily:"inherit",fontSize:50,fontWeight:"bold",lineHeight:"61px"},subjectHeadingMobile:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingDesktop:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingMobile:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingDesktop:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingMobile:{fontFamily:"inherit",fontSize:20,fontWeight:"bold",lineHeight:"24px"},smallSubheadingDesktop:{fontFamily:"inherit",fontSize:20,lineHeight:1.25},smallSubheadingMobile:{fontFamily:"inherit",fontSize:15,lineHeight:1.25},smallHeading:{color:el.gray25,fontFamily:"inherit",fontSize:17,fontWeight:"bold",lineHeight:"23px"},smallHeadingMobile:{color:el.gray25,fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},accentHeading:{color:el.gray68,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase"},bodyLarge:{fontFamily:nl.regular,fontSize:20,lineHeight:"30px"},bodySmall:{fontFamily:nl.regular,fontSize:17,fontWeight:"normal",lineHeight:"23px"},bodySmallBold:{fontFamily:nl.regular,fontSize:17,fontWeight:"bold",lineHeight:"23px"},bodyXsmall:{fontFamily:nl.regular,fontSize:15,lineHeight:"22px"},bodyXsmallBold:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"22px"},breadcrumb:tl,breadcrumbSmall:{...tl,fontSize:12,lineHeight:"13px"},labelLarge:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},labelMedium:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},labelSmall:{fontFamily:nl.regular,fontSize:12,lineHeight:"14px"},caption:{fontFamily:nl.regular,fontSize:14,fontStyle:"italic",lineHeight:"17px"},desktopScalingOnMobile:{MozTextSizeAdjust:"100%",MsTextSizeAdjust:"100%",WebkitTextSizeAdjust:"100%"},modalSubtitle:{fontSize:12,lineHeight:1.65,WebkitFontSmoothing:"antialiased",fontWeight:"bold"},wonderBlocksHeader:{paddingLeft:16,paddingRight:16,paddingBottom:24,paddingTop:34,[$r.mdOrLarger]:{paddingBottom:32}},wonderBlocksTitle:{color:el.white,fontWeight:900,fontSize:28,lineHeight:"32px",margin:0,[$r.mdOrLarger]:{fontSize:36,lineHeight:"40px"}},wonderBlocksLabelLarge:{fontSize:16,lineHeight:"20px",fontWeight:700}};var sl=Object.freeze({__proto__:null,colors:el,borderRadius:4,fonts:nl,typography:ol});class il extends _.PureComponent{constructor(){super(...arguments),U(this,"_handleTooltipButtonRef",(e=>{e&&this.props.usingKeyboardFocus&&e.focus()}))}_getAriaLabel(){const{crossedOut:e,pos:t}=this.props,n=aa(t);return e?k._("Bring back Choice %(letter)s",{letter:n}):k._("Cross out Choice %(letter)s",{letter:n})}render(){const{crossedOut:e,pos:t,primaryProductColor:n,theme:o}=this.props,s="day"===o?n:L.default.white;return _.createElement("button",{type:"button","aria-label":this._getAriaLabel(),className:d.css([rl.tooltipButton]),onClick:()=>this.props.onClick(),onMouseDown:e=>e.preventDefault(),onFocus:()=>this.props.onFocus(),onBlur:()=>this.props.onBlur(),disabled:this.props.disabled,tabIndex:this.props.tabFocusable?0:-1,ref:this._handleTooltipButtonRef},_.createElement(pa,{pos:t,product:"library",crossedOut:!this.props.crossedOut,primaryProductColor:s,pressed:!0,checked:!1,focused:!1,correct:!1,showCorrectness:!1,reviewMode:!1,previouslyAnswered:!1,transparentBackground:!0}),_.createElement(qa,{style:{color:s}},e?k._("Bring back"):k._("Cross out")))}}U(il,"defaultProps",{primaryProductColor:el.kaGreen});const rl=d.StyleSheet.create({tooltipButton:{background:"none",border:"none",font:"inherit",padding:0,cursor:"pointer",textDecoration:"none",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"}});class al{constructor(e,t,n){U(this,"_intersectionObserver",void 0),U(this,"_onVisibilityChange",void 0),U(this,"_handleIntersection",(e=>{for(const t of e)this._onVisibilityChange(t.isIntersecting,t.rootBounds)})),this._intersectionObserver=new IntersectionObserver(this._handleIntersection,{root:e,threshold:Number.EPSILON,rootMargin:n}),this._onVisibilityChange=t}setTargetElement(e){this._intersectionObserver.disconnect(),this._intersectionObserver.observe(e)}disconnect(){this._intersectionObserver.disconnect()}}class ll extends _.PureComponent{render(){const{direction:e,pxFromStart:t,pxFromEnd:n}=this.props,o=[cl.wrapper,"horizontal"===e&&cl.wrapperHorizontal,"vertical"===e&&cl.wrapperVertical],s=[cl.content,"horizontal"===e&&cl.contentHorizontal,"vertical"===e&&cl.contentVertical];return 0===t?_.createElement("div",{className:d.css(...o)},_.createElement("div",{className:d.css(...s)},this.props.children)):0===n?_.createElement("div",{className:d.css(...o,cl.wrapperAlignToEnd)},_.createElement("div",{className:d.css(...s)},this.props.children)):_.createElement("div",{className:d.css(...o)},_.createElement("div",{style:{flexShrink:n,flexBasis:t}}),_.createElement("div",{className:d.css(...s)},this.props.children),_.createElement("div",{style:{flexShrink:t,flexBasis:n}}))}}const cl=d.StyleSheet.create({wrapper:{display:"flex",overflow:"hidden"},wrapperHorizontal:{flexDirection:"row",width:"100%"},wrapperVertical:{flexDirection:"column",height:"100%"},wrapperAlignToEnd:{justifyContent:"flex-end"},content:{flex:"0 0 auto"},contentHorizontal:{maxWidth:"100%"},contentVertical:{maxHeight:"100%"}}),dl=parseInt("6px");function pl(e){const{color:t,inverted:n}=e;return n?{backgroundColor:t,textColor:L.default.white}:{backgroundColor:L.default.white,textColor:t}}class ul extends _.PureComponent{render(){const{onClick:e,onMouseEnter:t,onMouseLeave:n,side:o}=this.props.tooltipProps,{backgroundColor:s}=pl(this.props.tooltipProps);let i,r,a;if("top"===o)i=["0,0","".concat(9,",").concat(9),"".concat(18,",0")],r=18,a=9;else if("right"===o)i=["".concat(9,",0"),"0,".concat(9),"".concat(9,",").concat(18)],r=9,a=18;else if("bottom"===o)i=["0,".concat(9),"".concat(9,",0"),"".concat(18,",").concat(9)],r=18,a=9;else{if("left"!==o)throw new we("unexpected side ".concat(o),be.InvalidInput);i=["0,0","".concat(9,",").concat(9),"0,".concat(18)],r=9,a=18}return _.createElement("svg",{width:r,height:a,className:d.css(hl.tooltipArrow)},_.createElement("filter",{id:"tooltip-dropshadow-".concat(o),height:"150%"},_.createElement("feOffset",{dx:0,dy:1,result:"offsetblur"}),_.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:2}),_.createElement("feComponentTransfer",null,_.createElement("feFuncA",{type:"linear",slope:.1})),_.createElement("feMerge",null,_.createElement("feMergeNode",null),_.createElement("feMergeNode",{in:"SourceGraphic"}))),_.createElement("polyline",{fill:s,stroke:s,points:i.join(" "),className:d.css(e&&hl.tooltipArrowShapeWithOnClick),onClick:e,onMouseEnter:t,onMouseLeave:n}),_.createElement("polyline",{fill:s,points:i.join(" "),stroke:"rgba(0, 0, 0, 0.1)",filter:"url(#tooltip-dropshadow-".concat(o,")")}))}}const hl=d.StyleSheet.create({tooltipArrow:{display:"block",userSelect:"none"},tooltipArrowShapeWithOnClick:{pointerEvents:"auto",cursor:"pointer"}});var fl=d.StyleSheet.create({srOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1}});class ml extends _.PureComponent{constructor(){super(...arguments),U(this,"_handleClickClose",(()=>this.props.dismiss()))}_renderCloseButton(e){const{inverted:t,dismissOnClickClose:n}=this.props.tooltipProps;if(!n)return null;const o=e.get("button-description"),s=this.getA11yHeaderId(e);return _.createElement("button",{className:d.css(gl.closeIcon),onClick:this._handleClickClose,"aria-describedby":"".concat(o," ").concat(s)},_.createElement(ha,{title:k._("Close"),icon:"M6.26353762,4.99851587 L9.73097464,1.53107884 C10.0836373,1.17841618 10.0842213,0.612127047 9.73530496,0.263210718 C9.38395604,-0.0881381913 8.81874474,-0.0837668714 8.46743686,0.267541014 L4.99999981,3.73497806 L1.5325628,0.267541051 C1.1812549,-0.0837668481 0.616043606, -0.0881381955 0.264694717,0.263210694 C-0.0842215912,0.612127004 -0.0836375768,1.17841613 0.269025093,1.5310788 L3.73646206,4.9985158 L0.269025109,8.46595276 C-0.083637537,8.81861541 -0.0842215923, 9.38490462 0.264694642,9.73382106 C0.616043456,10.0851701 1.18125469, 10.0807988 1.53256259,9.72949093 L4.99999988,6.26205363 L8.46743739, 9.72949117 C8.8187453,10.0807991 9.38395655,10.0851704 9.73530537, 9.73382138 C10.0842216,9.38490498 10.0836375,8.81861579 9.73097488, 8.46595313 L6.26353762,4.99851587 Z",size:10,color:t?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.15)"}),_.createElement("div",{id:o,className:d.css(fl.srOnly)},k._("Closes the tooltip: ")))}getA11yHeaderId(e){const{tooltipProps:{a11y:t}}=this.props;return t&&t.title?"string"==typeof t.title?e.get("header"):t.title.id:this.getA11yContentId(e)}getA11yContentId(e){return e.get("content")}renderTooltip(e){const{content:t,dismissOnClickClose:n,noPadding:o,onClick:s,onMouseEnter:i,onMouseLeave:r,a11y:a,testId:l}=this.props.tooltipProps,c=a&&a.title,p=a&&a.assertiveness,{backgroundColor:u,textColor:h}=pl(this.props.tooltipProps),f=this.getA11yHeaderId(e),m=this.getA11yContentId(e);return _.createElement("div",{className:d.css(gl.tooltipBubble,!o&&gl.tooltipBubbleWithPadding,n&&gl.tooltipBubbleWithCloseIcon,s&&gl.tooltipBubbleWithOnClick),onClick:s,onMouseEnter:i,onMouseLeave:r,style:{backgroundColor:u,color:h},role:"region","aria-labelledby":f,"aria-describedby":m===f?null:m,"data-test-id":l},this._renderCloseButton(e),_.createElement("div",{"aria-live":p},"string"==typeof c?_.createElement("div",{className:d.css(fl.srOnly),id:f},c):null,_.createElement("div",{id:m,className:d.css(gl.tooltipContent)},t)))}render(){return _.createElement(m.UniqueIDProvider,{mockOnFirstRender:!1,scope:"tooltip-bubble"},(e=>this.renderTooltip(e)))}}const gl=d.StyleSheet.create({tooltipBubble:{boxSizing:"border-box",position:"relative",...ol.labelMedium,borderRadius:dl,border:"1px solid rgba(0, 0, 0, 0.1)",boxShadow:"".concat(0,"px ").concat(1,"px ")+"".concat(4,"px 0px ")+"rgba(0, 0, 0, ".concat(.1,")"),userSelect:"none"},tooltipBubbleWithPadding:{padding:"10px 23px"},tooltipBubbleWithCloseIcon:{paddingRight:34},tooltipBubbleWithOnClick:{cursor:"pointer"},tooltipContent:{userSelect:"auto"},closeIcon:{display:"block",position:"absolute",right:10,top:10,padding:0,background:"inherit",border:"none"}});class vl extends _.PureComponent{constructor(){super(...arguments),U(this,"_mountRemeasureTimeout",void 0),U(this,"state",{targetElementClientRect:null,rootElementClientRect:null}),U(this,"_handleScroll",(e=>{const{rootElement:t,targetElement:n}=this.props,o=e.target;t.contains(o)&&o.contains(n)&&this.remeasure()})),U(this,"remeasure",(()=>{const{targetElement:e,rootElement:t}=this.props;this.setState({targetElementClientRect:e.getBoundingClientRect(),rootElementClientRect:t.getBoundingClientRect()})}))}componentDidMount(){this._mountRemeasureTimeout=setTimeout(this.remeasure,0),window.addEventListener("resize",this.remeasure),window.addEventListener("scroll",this._handleScroll,!0)}componentWillUnmount(){this._mountRemeasureTimeout&&clearTimeout(this._mountRemeasureTimeout),window.removeEventListener("resize",this.remeasure),window.removeEventListener("scroll",this._handleScroll,!0)}_computeTargetPointOffsets(e,t){const{offset:n,offsetFrom:o,side:s}=this.props.tooltipProps,i=e,r=t;let a,l=n;if("arrow"===o&&(l+=9),"top"===s)a={left:i.left+i.width/2,top:i.top-l};else if("bottom"===s)a={left:i.left+i.width/2,top:i.bottom+l};else if("left"===s)a={left:i.left-l,top:i.top+i.height/2};else{if("right"!==s)throw new we("unexpected side ".concat(s),be.InvalidInput);a={left:i.right+l,top:i.top+i.height/2}}return{pxFromTop:a.top-r.top,pxFromBottom:r.bottom-a.top,pxFromLeft:a.left-r.left,pxFromRight:r.right-a.left}}_renderBubble(e){const{isAboveModal:t}=this.props,{side:n,tooltipMargin:o}=this.props.tooltipProps;let s;const i={},r={},a={};if("top"===n||"bottom"===n)s=yl.tooltipBubblePositionerTopBottom,r.direction="horizontal",r.pxFromStart=e.pxFromLeft,r.pxFromEnd=e.pxFromRight,a.marginLeft=o,a.marginRight=o;else{if("left"!==n&&"right"!==n)throw new we("unexpected side ".concat(n),be.InvalidInput);s=yl.tooltipBubblePositionerLeftRight,r.direction="vertical",r.pxFromStart=e.pxFromTop,r.pxFromEnd=e.pxFromBottom,a.marginTop=o,a.marginBottom=o}if("top"===n)i.bottom=e.pxFromBottom;else if("bottom"===n)i.top=e.pxFromTop;else if("left"===n)i.right=e.pxFromRight;else{if("right"!==n)throw new we("unexpected side ".concat(n),be.InvalidInput);i.left=e.pxFromLeft}return _.createElement("div",{className:d.css(yl.tooltipBubblePositioner,s,t&&yl.tooltipAboveModal),style:i},_.createElement(ll,r,_.createElement("div",{className:d.css(yl.tooltipBubbleWrapper),style:a},_.createElement(ml,{tooltipProps:this.props.tooltipProps,dismiss:this.props.dismiss}))))}_renderArrow(e,t){const{isAboveModal:n}=this.props,{side:o,tooltipMargin:s}=this.props.tooltipProps,i={};if("top"===o)i.bottom=e.pxFromBottom-9+1;else if("bottom"===o)i.top=e.pxFromTop-9+1;else if("left"===o)i.right=e.pxFromRight-9+1;else{if("right"!==o)throw new we("unexpected side ".concat(o),be.InvalidInput);i.left=e.pxFromLeft-9+1}const r=s+dl;if("top"===o||"bottom"===o){const n=r,o=t.width-18-r;i.left=e.pxFromLeft-9,i.left=Math.min(i.left,o),i.left=Math.max(i.left,n)}else{if("left"!==o&&"right"!==o)throw new we("unexpected side ".concat(o),be.InvalidInput);{const n=r,o=t.height-18-r;i.top=e.pxFromTop-9,i.top=Math.min(i.top,o),i.top=Math.max(i.top,n)}}return _.createElement("div",{className:d.css(yl.tooltipArrowPositioner,n&&yl.tooltipAboveModal),style:i},_.createElement(ul,{tooltipProps:this.props.tooltipProps}))}_buildMediaFilterStyle(){const{media:e}=this.props.tooltipProps;if(!e)return null;return d.StyleSheet.create({mediaFilter:{display:"none",[e]:{display:"block"}}}).mediaFilter}render(){const{targetElementClientRect:e,rootElementClientRect:t}=this.state;if(!e||!t)return null;const n=this._computeTargetPointOffsets(e,t);return _.createElement("div",{className:d.css(this._buildMediaFilterStyle())},this._renderBubble(n),this._renderArrow(n,t))}}const yl=d.StyleSheet.create({tooltipBubblePositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"},tooltipAboveModal:{zIndex:1090},tooltipBubblePositionerTopBottom:{left:0,width:"100%"},tooltipBubblePositionerLeftRight:{top:0,height:"100%"},tooltipBubbleWrapper:{pointerEvents:"auto"},tooltipArrowPositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"}});class bl extends _.Component{constructor(){super(...arguments),U(this,"_mountNode",void 0),U(this,"_tooltipPositioner",void 0)}componentDidMount(){const e=document.createElement("div");this._mountNode=e,this.props.rootElement.appendChild(e),this._renderInMountNode(e)}componentDidUpdate(){const e=this._mountNode;e&&this._renderInMountNode(e)}componentWillUnmount(){const e=this._mountNode;e&&(N.default.unmountComponentAtNode(e),this.props.rootElement.removeChild(e))}remeasure(){this._tooltipPositioner&&this._tooltipPositioner.remeasure()}_renderInMountNode(e){const{tooltipProps:t,dismiss:n,rootElement:o,targetElement:s,isAboveModal:i}=this.props;N.default.render(_.createElement(vl,{tooltipProps:t,dismiss:n,rootElement:o,targetElement:s,isAboveModal:i,ref:e=>this._tooltipPositioner=e}),e)}render(){return null}}const xl=Object.freeze({side:"top",offset:0,offsetFrom:"bubble",tooltipMargin:0,noPadding:!1,color:el.gray17,inverted:!1,dismissOnClickClose:!1,toggleOnHover:!0,showOnMount:!1});class wl extends _.PureComponent{constructor(e){super(e),U(this,"_rootElement",void 0),U(this,"_wrapper",void 0),U(this,"_targetElement",void 0),U(this,"_tooltipPortal",void 0),U(this,"_visibilityObserver",void 0),U(this,"_isMounted",void 0),U(this,"_targetElementMountTimeout",void 0),U(this,"_handleVisibilityChange",(e=>{this.setState({targetElementIsVisible:e})})),U(this,"_handleMouseEnter",(()=>{this.setState({hovered:!0})})),U(this,"_handleMouseLeave",(()=>{this.setState({hovered:!1})})),U(this,"_handleDismiss",(()=>{null==this.props.dismissed&&this.setState({dismissed:!0}),this.props.onDismiss&&this.props.onDismiss()})),this._isMounted=!1,this.state={dismissed:null!=e.dismissed&&e.dismissed,hovered:!1,targetElementIsVisible:!1}}componentDidMount(){this._isMounted=!0,this._registerVisibilityObserver()}UNSAFE_componentWillReceiveProps(e){null!=e.dismissed&&this.setState({dismissed:e.dismissed})}UNSAFE_componentWillUpdate(){this._registerVisibilityObserver()}componentWillUnmount(){this._isMounted=!1,this._targetElementMountTimeout&&clearTimeout(this._targetElementMountTimeout),this._visibilityObserver.disconnect()}_findRootElement(){return this.context.modalContainerElement||document.getElementById("mission-task-container")||document.getElementById("outer-wrapper")||document.body}_registerVisibilityObserver(){const e=this._findRootElement();if(!e)throw new we("Failed to mount NewTooltip: we need a #outer-wrapper or document.body element.",be.Internal);if(e===this._rootElement)return;this._rootElement=e,this._visibilityObserver&&this._visibilityObserver.disconnect(),this._visibilityObserver=function(e,t,n){return new al(e,t,n)}(e,this._handleVisibilityChange);const t=this._wrapper;if(!t)throw new we("NewTooltip expected a wrapper element after mount",be.Internal);let n=t;for(;n.hasAttribute("data-tooltip-wrapper");)if(n=n.childNodes[0],!n)throw new we("NewTooltip expected wrapper element to have a child",be.Internal);this._targetElement=n,this._targetElementMountTimeout=setTimeout((()=>{const e=this._targetElement;if(!e)throw new we("NewTooltip should have a target element after mounting.",be.Internal);Y().isDevServer&&"inline"===getComputedStyle(e).display&&(xe.error("Warning: The children of a NewTooltip element must be block-like, but this element seems to have `display: inline`. This could break position tracking.",be.Internal),xe.log("NewTooltip Target Element:",{targetElement:e.outerHTML})),this._visibilityObserver.setTargetElement(e),this.forceUpdate()}),0)}_shouldShowTooltip(){const{toggleOnHover:e,showOnMount:t}=this.props,{dismissed:n,targetElementIsVisible:o}=this.state;return!1!==o&&(!n&&(!!t||!(!e||!this.state.hovered)))}remeasure(){this._tooltipPortal&&this._tooltipPortal.remeasure()}render(){const{children:e,toggleOnHover:t}=this.props,{children:n,...o}=this.props;return _.createElement("div",{className:d.css(Cl.targetElement),onMouseEnter:t?this._handleMouseEnter:void 0,onMouseLeave:t?this._handleMouseLeave:void 0,ref:e=>this._wrapper=e,"data-tooltip-wrapper":!0,"data-test-id":"question-id"},e,this._targetElement&&this._shouldShowTooltip()&&_.createElement(bl,{tooltipProps:o,dismiss:this._handleDismiss,rootElement:this._rootElement,targetElement:this._targetElement,isAboveModal:!!this.context.modalContainerElement,ref:e=>this._tooltipPortal=e}))}}U(wl,"defaultProps",xl),wl.contextTypes={modalContainerElement:I.default.instanceOf(HTMLElement)};const Cl=d.StyleSheet.create({targetElement:{display:"inline"}});class kl extends _.PureComponent{constructor(){super(...arguments),U(this,"_handleKeyDown",(e=>{"Tab"===e.key&&(this.props.onDismiss(),e.preventDefault())}))}_renderTooltipContent(){return _.createElement("div",{onKeyDown:this._handleKeyDown},_.createElement(il,this.props.buttonProps))}render(){return _.createElement("div",null,_.createElement(wl,{content:this._renderTooltipContent(),offsetFrom:"arrow",offset:10,dismissed:this.props.dismissed,showOnMount:!0,toggleOnHover:!1,onClick:()=>this.props.buttonProps.onClick(),media:$r.mdOrLarger},this.props.children),!this.props.dismissed&&_.createElement(Sl,{onDismiss:this.props.onDismiss}))}}class Sl extends _.PureComponent{constructor(){super(...arguments),U(this,"_handleGlobalClick",(()=>{this.props.onDismiss()})),U(this,"_handleGlobalKeyup",(e=>{"Escape"===e.key&&this.props.onDismiss()}))}componentDidMount(){setTimeout((()=>{window.addEventListener("click",this._handleGlobalClick),window.addEventListener("keyup",this._handleGlobalKeyup)}),0)}componentWillUnmount(){window.removeEventListener("click",this._handleGlobalClick),window.removeEventListener("keyup",this._handleGlobalKeyup)}render(){return null}}const El={path:"M27.218 6.82l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:27.284};class _l extends _.PureComponent{constructor(){super(...arguments),U(this,"_menu",void 0),U(this,"_menuButton",void 0),U(this,"_crossOutButtonIsFocused",void 0),U(this,"state",{hovered:!1,opened:!1,slidePanelCovered:!0,usingKeyboardFocus:!1,wasCrossedOutOnLastOpen:!1}),U(this,"_openMenu",(()=>{const e=null!=this._menu&&this._menu.contains(document.activeElement);this.setState({opened:!0,usingKeyboardFocus:e,wasCrossedOutOnLastOpen:this.props.crossedOut})})),U(this,"_closeMenu",(()=>{this._crossOutButtonIsFocused&&this._menuButton&&this._menuButton.focus(),this.setState({opened:!1,slidePanelCovered:!0})})),U(this,"_handleMenuClick",((e,t)=>{t?this._openMenu():this._closeMenu(),e.preventDefault()})),U(this,"_handleCrossedOutButtonClick",(e=>{this.props.onCrossedOutChange(e),this._closeMenu()})),U(this,"_handleSlideTransitionEnd",(()=>{this.state.opened&&this.setState({slidePanelCovered:!1})}))}UNSAFE_componentWillReceiveProps(e){e.enabled||this._closeMenu()}_getButtonProps(e){const t=this.state.wasCrossedOutOnLastOpen;return{onClick:()=>{this._handleCrossedOutButtonClick(!t)},onFocus:()=>{this._crossOutButtonIsFocused=!0},onBlur:()=>{this._crossOutButtonIsFocused=!1},crossedOut:t,pos:this.props.pos,primaryProductColor:this.props.primaryProductColor,usingKeyboardFocus:this.state.usingKeyboardFocus,theme:e}}_getMenuIconColor(){return this.state.opened?this.props.primaryProductColor:this.state.hovered?L.default.offBlack:L.default.offBlack50}_renderMenu(){const{pos:e,isSatProduct:t}=this.props,{opened:n}=this.state,o=d.css(Tl.menu,t&&Tl.spacing);return _.createElement("div",{ref:e=>this._menu=e,className:o,onClick:e=>this._handleMenuClick(e,!n),onMouseEnter:()=>this.setState({hovered:!0}),onMouseLeave:()=>this.setState({hovered:!1})},_.createElement(kl,{dismissed:!this.state.opened,onDismiss:this._closeMenu,buttonProps:this._getButtonProps("day")},_.createElement("button",{type:"button","aria-label":k._("Open menu for Choice %(letter)s",{letter:aa(e)}),className:d.css([Tl.menuButton]),onClick:e=>this._handleMenuClick(e,!n),onMouseDown:e=>e.preventDefault(),ref:e=>this._menuButton=e},_.createElement(ha,{className:d.css(Tl.menuIcon),icon:El,size:3,color:this._getMenuIconColor()}))))}_renderSlidePanel(){const e=this._getButtonProps("night"),{slidePanelCovered:t}=this.state;return _.createElement("div",{className:d.css(Tl.slidePanel,t&&Tl.slidePanelCovered),onClick:e.onClick,"aria-hidden":t},_.createElement(il,G({},e,{disabled:t,tabFocusable:!t})))}render(){const{enabled:e}=this.props,{opened:t}=this.state;return _.createElement("div",{className:d.css(Tl.wrapper)},_.createElement("div",{className:d.css(Tl.slidingContent,e&&Tl.slidingContentEnabled,t&&Tl.slidingContentOpen),onTransitionEnd:this._handleSlideTransitionEnd},_.createElement("div",{className:d.css(Tl.content)},this.props.children),e&&this._renderMenu()),e&&this._renderSlidePanel())}}const Tl=d.StyleSheet.create({wrapper:{display:"block",position:"relative"},slidingContent:{display:"flex",flexDirection:"row",alignItems:"stretch"},slidingContentEnabled:{[$r.smOrSmaller]:{transition:"transform 0.2s ease-out",backgroundColor:L.default.white}},slidingContentOpen:{[$r.smOrSmaller]:{transform:"translateX(-".concat(96,"px)")}},content:{display:"block",flex:"1 1 0"},menu:{cursor:"pointer",boxSizing:"border-box",width:32,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",[$r.smOrSmaller]:{paddingRight:8}},menuButton:{background:"none",border:"none",font:"inherit",padding:0,textAlign:"inherit",cursor:"pointer",display:"flex",flexDirection:"column",justifyContent:"center",height:16},menuIcon:{display:"block"},slidePanel:{position:"absolute",top:0,right:0,boxSizing:"border-box",width:96,height:"100%",paddingLeft:8,paddingRight:8,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",background:L.default.offBlack50,cursor:"pointer",[$r.mdOrLarger]:{display:"none"}},spacing:{paddingRight:12},slidePanelCovered:{zIndex:-1}});class Ml extends _.Component{_renderText(){const{checked:e,correct:t,crossedOut:n}=this.props;return t?e?k._("Correct (selected)"):n?k._("Correct (but you crossed it out)"):k._("Correct"):e?k._("Incorrect (selected)"):k._("Incorrect")}render(){const{checked:e,correct:t,previouslyAnswered:n}=this.props;let o;return o=t?Il.correct:e||n?Il.incorrectAnswered:Il.incorrect,_.createElement("div",{className:d.css(Il.text,o)},this._renderText())}}const Il=d.StyleSheet.create({text:{alignItems:"center",display:"flex",fontSize:12,height:32,textTransform:"uppercase"},correct:{color:"#71B307"},incorrectAnswered:{color:"#F86700"},incorrect:{color:ue}});class Pl extends _.Component{constructor(){super(...arguments),U(this,"_inputElement",void 0),U(this,"handleClick",(e=>{this.props.onChecked(!this.props.checked)})),U(this,"handleKeyUp",(e=>{" "===e.key&&(this.props.onChecked(!this.props.checked),e.preventDefault())})),U(this,"handleChange",(e=>{!this.props.checked&&e.target.checked&&this.props.onChecked(!0)})),U(this,"handleKeyDown",(e=>{" "===e.key?e.preventDefault():"ArrowUp"===e.key||"ArrowLeft"===e.key?(this.props.goToPrevChoice(),e.preventDefault()):"ArrowDown"!==e.key&&"ArrowRight"!==e.key||(this.props.goToNextChoice(),e.preventDefault())})),U(this,"handleRef",(e=>{this._inputElement=e,this.props.inputRef&&this.props.inputRef(e)}))}render(){const{inputRef:e,onChecked:t,goToPrevChoice:n,goToNextChoice:o,...s}=this.props;return _.createElement("input",G({},s,{type:"radio",onChange:this.handleChange,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,ref:this.handleRef}))}}U(Pl,"propTypes",{checked:I.default.bool.isRequired,inputRef:I.default.func,onChecked:I.default.func.isRequired,goToPrevChoice:I.default.func.isRequired,goToNextChoice:I.default.func.isRequired});const Nl={backgroundColor:"#E4F3F9",outline:"2px solid ".concat("#0084CE"),zIndex:1};class Al extends _.Component{constructor(){super(...arguments),U(this,"justFinishedTouch",void 0),U(this,"justFinishedTimeoutID",void 0),U(this,"_input",void 0),U(this,"state",{isInputFocused:!1,isInputActive:!1}),U(this,"onInputFocus",(()=>{this.setState({isInputFocused:!0})})),U(this,"onInputBlur",(()=>{this.setState({isInputFocused:!1})})),U(this,"onInputMouseDown",(e=>{"mousedown"===e.type&&this.justFinishedTouch||(this.setState({isInputActive:!0}),this.props.apiOptions.satStyling&&this._input&&this._input.focus())})),U(this,"onInputMouseUp",(e=>{if("mouseup"!==e.type||!this.justFinishedTouch){if("touchend"===e.type)return this.justFinishedTouch=!0,null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID),void(this.justFinishedTimeoutID=setTimeout((()=>{this.setState({isInputActive:!1}),this.justFinishedTouch=!1}),10));this.setState({isInputActive:!1}),this.props.apiOptions.satStyling&&this._input&&this._input.focus()}})),U(this,"onInputMouseOut",(()=>{this.setState({isInputActive:!1})})),U(this,"inputRef",(e=>{this._input=e})),U(this,"renderOptionStatus",(()=>{const{correct:e,checked:t,crossedOut:n,reviewMode:o,previouslyAnswered:s}=this.props;return this.props.apiOptions.satStyling?null:o||s?_.createElement(Ml,{checked:t,correct:e,crossedOut:n,previouslyAnswered:s}):null})),U(this,"renderChoiceIcon",(()=>{const{radioStyleVersion:e,primaryProductColor:t}=this.props.apiOptions.styling;return void 0!==e&&"final"===e||this.props.apiOptions.satStyling?_.createElement(pa,{pos:this.props.pos,correct:this.props.correct,crossedOut:this.props.crossedOut,pressed:this.state.isInputActive,focused:this.state.isInputFocused,checked:this.props.checked,showCorrectness:this.props.showCorrectness,reviewMode:this.props.reviewMode,product:this.props.apiOptions.satStyling?"sat":"library",primaryProductColor:t,previouslyAnswered:this.props.previouslyAnswered}):null})),U(this,"_setChecked",(e=>{e?this._sendChange({checked:!0,crossedOut:!1}):this._sendChange({checked:!1})})),U(this,"_setCrossedOut",(e=>{e?this._sendChange({checked:!1,crossedOut:!0}):this._sendChange({crossedOut:!1})})),U(this,"_sendChange",(e=>{const t=null!=e.checked?e.checked:this.props.checked,n=null!=e.crossedOut?e.crossedOut:this.props.crossedOut;this.props.onChange({checked:t,crossedOut:n})})),U(this,"focusInput",(()=>{var e;null===(e=this._input)||void 0===e||e.focus()}))}UNSAFE_componentWillUpdate(e){this.state.isInputFocused&&e.disabled&&this.setState({isInputFocused:!1})}componentWillUnmount(){null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID)}render(){const e=this.props.apiOptions.satStyling,t=this.props.apiOptions.isMobile,{radioStyleVersion:n}=this.props.apiOptions.styling,o=void 0!==n&&"final"===n,s=S.default(this.props.className,"checkbox-label",d.css(Rl.label,t&&ta.disableTextSelection,!e&&Rl.responsiveLabel,e&&Rl.satLabel)),i=S.default(d.css(this.state.isInputFocused&&Rl.satDescriptionInputFocused,this.state.isInputActive&&Rl.satDescriptionInputActive)),r=this.props.showCorrectness&&!this.props.correct,a=this.props.checked&&!r,l={type:this.props.type,name:this.props.groupName,id:"".concat(this.props.groupName,"-choice-").concat(this.props.pos),checked:a,disabled:this.props.disabled,onFocus:this.onInputFocus,onBlur:this.onInputBlur,className:d.css(!o&&ta.perseusInteractive,!o&&Rl.input,!o&&ta.responsiveInput,!o&&!e&&ta.responsiveRadioInput,!o&&!e&&this.state.isInputActive&&ta.responsiveRadioInputActive,o&&ta.perseusSrOnly,e&&ta.perseusSrOnly,e&&this.props.reviewMode&&Rl.satReviewInput)};let c=null;c="radio"===this.props.type?_.createElement(Pl,G({onChecked:e=>this._setChecked(e),goToPrevChoice:this.props.goToPrevChoice,goToNextChoice:this.props.goToNextChoice,inputRef:this.inputRef},l)):_.createElement("input",G({onChange:e=>this._setChecked(e.target.checked),ref:this.inputRef},l));const{reviewMode:p,correct:u,checked:h}=this.props,f=e&&p&&u,m=e&&p&&!u&&h,g=S.default("description",f&&"sat-correct",m&&"sat-incorrect",d.css(!e&&Rl.description,e&&Rl.satDescription,f&&Rl.satDescriptionCorrect,f&&h&&Rl.satDescriptionCorrectChecked,m&&Rl.satDescriptionIncorrectChecked)),v=S.default("checkbox",d.css(ta.perseusInteractive,!e&&Rl.choiceIconWrapper,e&&Rl.satCheckboxOptionContent)),y=S.default("checkbox-and-option",d.css(!e&&Rl.intermediateResponsiveCheckbox,!e&&p&&Rl.intermediateResponsiveCheckboxReview)),b=S.default("perseus-radio-rationale-content",d.css(Rl.rationale,!e&&Rl.nonSatRationale,e&&Rl.satReviewRationale)),x=this.props.editMode?"div":"label",w=this.props.apiOptions.crossOutEnabled&&!this.props.showCorrectness,C=!e&&!p&&this.props.apiOptions.readOnly||w&&this.props.crossedOut;return _.createElement("div",{className:e?i:void 0},_.createElement(_l,{enabled:w,pos:this.props.pos,primaryProductColor:this.props.apiOptions.styling.primaryProductColor,crossedOut:this.props.crossedOut,onCrossedOutChange:this._setCrossedOut,isSatProduct:e},_.createElement(x,{htmlFor:this.props.editMode?void 0:l.id,className:s,style:{opacity:C?.5:1}},_.createElement("div",{className:g,onMouseDown:this.onInputMouseDown,onMouseUp:this.onInputMouseUp,onMouseOut:this.onInputMouseOut,onTouchStart:this.onInputMouseDown,onTouchEnd:this.onInputMouseUp},_.createElement("div",{className:y},_.createElement("span",{className:v},c,this.renderChoiceIcon()),_.createElement("span",{className:S.default(te.RADIO.OPTION_CONTENT,te.INTERACTIVE,d.css(e&&Rl.satRadioOptionContent,e&&p&&Rl.satReviewRadioOptionContent)),style:{cursor:"default"}},_.createElement("div",{className:d.css(Rl.optionStatusContainer)},this.renderOptionStatus()),_.createElement("div",null,this.props.content))),this.props.showRationale&&_.createElement("div",{className:b,"data-test-id":"perseus-radio-rationale-content-".concat(this.props.pos)},this.props.rationale)))))}}U(Al,"propTypes",{apiOptions:I.default.shape({satStyling:I.default.bool,isMobile:I.default.bool,styling:I.default.shape({radioStyleVersion:I.default.oneOf(["intermediate","final"]),primaryProductColor:I.default.string}),readOnly:I.default.bool}),checked:I.default.bool,className:I.default.string,rationale:I.default.node,content:I.default.node,correct:I.default.bool,deselectEnabled:I.default.bool,disabled:I.default.bool,editMode:I.default.bool,groupName:I.default.string,isLastChoice:I.default.bool,pos:I.default.number,reviewMode:I.default.bool,showRationale:I.default.bool,showCorrectness:I.default.bool,type:I.default.string,crossedOut:I.default.bool,previouslyAnswered:I.default.bool,onChange:I.default.func,goToPrevChoice:I.default.func.isRequired,goToNextChoice:I.default.func.isRequired}),U(Al,"defaultProps",{apiOptions:{styling:{}},checked:!1,classSet:{},correct:!1,disabled:!1,editMode:!1,onChange:function(){},showRationale:!1,type:"radio",pos:0,previouslyAnswered:!1});const Rl=d.StyleSheet.create({description:{display:"inline-block",width:"100%"},satDescription:{display:"block",position:"relative",boxSizing:"border-box",cursor:"pointer",marginLeft:0,padding:"17px 14px"},satDescriptionInputFocused:{...Nl,display:"block"},satDescriptionInputActive:{...Nl,backgroundColor:"#D0EDF4"},satDescriptionCorrect:{color:"#009900"},satDescriptionCorrectChecked:{backgroundColor:"#E4F7E4"},satDescriptionIncorrectChecked:{color:"#990000",backgroundColor:"#F2EBEB"},input:{display:"inline-block",width:20,margin:3,marginLeft:-20,marginRight:0,float:"none"},satReviewInput:{pointerEvents:"none"},satRadioOptionContent:{userSelect:"text",display:"block",marginLeft:45,cursor:"inherit"},satReviewRadioOptionContent:{fontWeight:"bold"},satCheckboxOptionContent:{position:"absolute",display:"block",top:"50%",margin:"-16px 0 0 0",width:"auto"},choiceIconWrapper:{display:"flex",marginRight:12,flexShrink:0},optionStatusContainer:{display:"block"},rationale:{display:"block"},nonSatRationale:{padding:"16px 16px",paddingTop:0,marginLeft:44,[$r.smOrSmaller]:{padding:"12px 16px",paddingTop:0}},satReviewRationale:{marginTop:13,marginLeft:45},label:{display:"block",transition:"opacity 0.2s ease-out"},responsiveLabel:{WebkitTapHighlightColor:"transparent",display:"flex",alignItems:"stretch"},satLabel:{cursor:"pointer"},intermediateResponsiveCheckbox:{display:"flex",alignItems:"center",padding:"16px 16px",[$r.smOrSmaller]:{padding:"12px 16px"}},intermediateResponsiveCheckboxReview:{alignItems:"flex-start"}});class Fl extends _.Component{constructor(){super(...arguments),U(this,"_choice",void 0),U(this,"focusInput",(()=>{this._choice.focusInput()}))}render(){const e={...this.props,className:S.default(this.props.className,"none-of-above"),content:this.props.showContent?this.props.content:_.createElement(qi,{key:"noneOfTheAboveRenderer",content:k._("None of the above")}),ref:e=>this._choice=e};return _.createElement(Al,e)}}U(Fl,"propTypes",{className:I.default.string,content:I.default.node,showContent:I.default.bool}),U(Fl,"defaultProps",{showContent:!0});const{captureScratchpadTouchStart:Ol}=Ye,Dl=I.default.arrayOf(I.default.shape({checked:I.default.bool,crossedOut:I.default.bool,content:I.default.node,rationale:I.default.node,hasRationale:I.default.bool,showRationale:I.default.bool,showCorrectness:I.default.bool,correct:I.default.bool,originalIndex:I.default.number,isNoneOfTheAbove:I.default.bool}));class Ll extends _.Component{constructor(){super(...arguments),U(this,"state",{radioGroupName:M.default.uniqueId("perseus_radio_")}),U(this,"updateChoice",((e,t)=>{let n;n=t.checked&&!this.props.multipleSelect?this.props.choices.map((e=>!1)):this.props.choices.map((e=>e.checked));const o=this.props.choices.map((e=>e.crossedOut));n[e]=t.checked,o[e]=t.crossedOut,this.props.onChange({checked:n,crossedOut:o})})),U(this,"focus",(e=>(N.default.findDOMNode(this.refs["radio"+(e||0)]).focus(),!0))),U(this,"getInstructionsText",(()=>this.props.multipleSelect?this.props.countChoices?k._("Choose %(numCorrect)s answers:",{numCorrect:this.props.numCorrect}):k._("Choose all answers that apply:"):k._("Choose 1 answer:"))),U(this,"deselectEnabled",(()=>this.props.apiOptions.isMobile||this.props.deselectEnabled)),U(this,"goToChoice",(e=>{const t=this.props.choices.length;e<0&&(e+=t),e>=t&&(e-=t);const n=this.refs["radio".concat(e)];if(!n)return void xe.error("found no choice at index ".concat(e,", even after ")+"wrapping it to be within bounds",be.Internal,{loggedMetadata:{choices:JSON.stringify(this.props.choices)}});n.focusInput();const o=this.props.choices.map((e=>e.crossedOut)),s=this.props.choices.map((e=>!1));this.props.choices[e].crossedOut||(s[e]=!0),this.props.onChange({checked:s,crossedOut:o})}))}componentDidUpdate(e){const{apiOptions:t,choices:n,isLastUsedWidget:o,reviewModeRubric:s}=this.props;if(t.canScrollPage&&o&&s&&!e.reviewModeRubric){const e=n.findIndex((e=>e.checked));if(e>=0){const t=N.default.findDOMNode(this.refs["radio"+e]);sa(t)}}}render(){const e=this.props.multipleSelect?"checkbox":"radio",t=this.props.reviewModeRubric,n=!!t,o=Ll.styles,s=this.props.apiOptions.satStyling,i=this.props.apiOptions.isMobile,r=this.props.choices,a=r[0].highlighted,l=r[r.length-1].highlighted,c=S.default("perseus-widget-radio",!this.props.editMode&&"perseus-rendered-radio",d.css(o.radio,!s&&o.responsiveRadioContainer,!s&&a&&i&&o.radioContainerFirstHighlighted,!s&&l&&i&&o.radioContainerLastHighlighted,s&&o.satRadio)),p=S.default("instructions",d.css(o.instructions,i&&o.instructionsMobile)),u=this.getInstructionsText(),h=!s,f=d.css(o.responsiveFieldset),m=_.createElement("fieldset",{className:"perseus-widget-radio-fieldset ".concat(f)},_.createElement("legend",{className:"perseus-sr-only"},u),h&&_.createElement("div",{className:p},u),_.createElement("ul",{className:c},this.props.choices.map((function(i,r){let a=Al;const l={ref:"radio".concat(r),apiOptions:this.props.apiOptions,checked:i.checked,crossedOut:i.crossedOut,previouslyAnswered:i.previouslyAnswered,reviewMode:n,correct:i.correct,rationale:i.rationale,content:i.content,disabled:this.props.apiOptions.readOnly||i.disabled,editMode:this.props.editMode,groupName:this.state.radioGroupName,isLastChoice:r===this.props.choices.length-1,showCorrectness:n||!!i.showCorrectness,showRationale:i.hasRationale&&(n||i.showRationale),type:e,pos:r,deselectEnabled:this.deselectEnabled(),onChange:e=>{this.updateChoice(r,e)},goToPrevChoice:()=>this.goToChoice(r-1),goToNextChoice:()=>this.goToChoice(r+1)};i.isNoneOfTheAbove&&(a=Fl,M.default.extend(l,{showContent:i.revealNoneOfTheAbove}));const c=this.props.choices[r+1],p=!!c&&c.highlighted,u=e=>{const r=s&&n&&e,a=s&&n&&c&&c.checked;return d.css(ta.aboveScratchpad,o.item,!s&&o.responsiveItem,!s&&e&&o.selectedItem,!s&&e&&i.highlighted&&o.aboveBackdrop,!s&&e&&i.highlighted&&this.props.apiOptions.isMobile&&o.aboveBackdropMobile,!s&&p&&this.props.apiOptions.isMobile&&o.nextHighlighted,s&&o.satRadioOption,r&&!i.correct&&o.satRadioOptionIncorrect,r&&i.correct&&o.satRadioOptionCorrect,a&&!c.correct&&o.satRadioOptionNextIncorrect,a&&c.correct&&o.satRadioOptionNextCorrect,s&&t&&o.satReviewRadioOption)};u(!0);const h=S.default(u(i.checked),te.RADIO.OPTION,i.checked&&te.RADIO.SELECTED,n&&t.choices[r].correct&&te.CORRECT,n&&!t.choices[r].correct&&te.INCORRECT);let f=null,m=null;return this.props.editMode&&(m=e=>{let t=e.target;for(;t&&t!==f;){if(t.getAttribute("data-is-radio-icon"))return void this.updateChoice(r,{checked:!i.checked});t=t.parentNode}}),_.createElement("li",{key:r,ref:e=>f=e,className:h,onClick:m,onTouchStart:this.props.labelWrap?Ol:null},_.createElement(a,l))}),this)));return _.createElement("div",{className:d.css(!s&&o.responsiveContainer)},m)}}U(Ll,"propTypes",{apiOptions:I.default.shape({readOnly:I.default.bool,satStyling:I.default.bool,isMobile:I.default.bool,styling:I.default.shape({radioStyleVersion:I.default.oneOf(["intermediate","final"])}),canScrollPage:I.default.bool}),choices:Dl,deselectEnabled:I.default.bool,editMode:I.default.bool,labelWrap:I.default.bool,countChoices:I.default.bool,numCorrect:I.default.number,multipleSelect:I.default.bool,reviewModeRubric:I.default.shape({choices:Dl}),onChange:I.default.func,isLastUsedWidget:I.default.bool}),U(Ll,"styles",d.StyleSheet.create({instructions:{display:"block",color:he,fontSize:14,lineHeight:1.25,fontStyle:"normal",fontWeight:"bold",marginBottom:16},instructionsMobile:{fontSize:18,[$r.smOrSmaller]:{fontSize:16},[$r.xl]:{fontSize:20}},radio:{width:"100%"},responsiveRadioContainer:{borderBottom:"1px solid ".concat("#BABEC2"),borderTop:"1px solid ".concat("#BABEC2"),width:"auto",[$r.smOrSmaller]:{marginLeft:-16,marginRight:-16}},radioContainerFirstHighlighted:{borderTop:"1px solid rgba(0, 0, 0, 0)"},radioContainerLastHighlighted:{borderBottom:"1px solid rgba(0, 0, 0, 0)"},satRadio:{background:"none",marginLeft:0,userSelect:"none"},satRadioOption:{margin:0,padding:0,borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc"}},satRadioOptionCorrect:{borderBottomColor:"#00CC00",":first-child":{borderTopColor:"#00CC00"}},satRadioOptionIncorrect:{borderBottomColor:"#CC5252",":first-child":{borderTopColor:"#CC5252"}},satRadioOptionNextCorrect:{borderBottomColor:"#00CC00"},satRadioOptionNextIncorrect:{borderBottomColor:"#CC5252"},satReviewRadioOption:{pointerEvents:"none"},item:{marginLeft:20},inlineItem:{display:"inline-block",paddingLeft:20,verticalAlign:"middle"},responsiveItem:{marginLeft:0,padding:0,":not(:last-child)":{borderBottom:"1px solid ".concat("#BABEC2")}},selectedItem:{background:"white"},aboveBackdrop:{position:"relative",zIndex:1062},aboveBackdropMobile:{boxShadow:"0 0 4px 0 rgba(0, 0, 0, 0.2),0 0 2px 0 rgba(0, 0, 0, 0.1)",":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},nextHighlighted:{":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},responsiveContainer:{overflow:"auto",marginLeft:-16,marginRight:-16,paddingLeft:16},responsiveFieldset:{paddingRight:16}})),U(Ll,"defaultProps",{editMode:!1});class Bl extends _.Component{constructor(){super(...arguments),U(this,"_renderRenderer",(e=>{let t=1;const n={},o=(e=e||"").replace(/\{\{passage-ref (\d+) (\d+)(?: "([^"]*)")?\}\}/g,((e,o,s,i)=>{const r="passage-ref "+t;return t++,n[r]={type:"passage-ref",graded:!1,options:{passageNumber:parseInt(o),referenceNumber:parseInt(s),summaryText:i},version:zr.version},"[["+Ye.snowman+" "+r+"]]"}));return _.createElement(qi,{key:"choiceContentRenderer",content:o,widgets:n,findExternalWidgets:this.props.findWidgets,alwaysUpdate:!0,linterContext:{...this.props.linterContext,blockHighlight:!0}})})),U(this,"focus",(e=>this.refs.baseRadio.focus(e))),U(this,"updateChoices",(e=>{const{choiceStates:t,choices:n}=this.props;let o;o=t?t.map((e=>({...e}))):n.map((()=>({selected:!1,crossedOut:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1,readOnly:!1}))),o.forEach(((t,n)=>{t.selected=e.checked[n],t.crossedOut=e.crossedOut[n]})),this.props.onChange({choiceStates:o}),this.props.trackInteraction()})),U(this,"getUserInput",(()=>Bl.getUserInputFromProps(this.props))),U(this,"simpleValidate",(e=>Bl.validate(this.getUserInput(),e))),U(this,"showRationalesForCurrentlySelectedChoices",(e=>{const{choiceStates:t}=this.props;if(t){const n=this.simpleValidate(e),o="points"===n.type&&n.total===n.earned,s=t.map((e=>({...e,highlighted:e.selected,rationaleShown:e.selected||e.rationaleShown||o,readOnly:e.selected||e.readOnly||o,correctnessShown:e.selected||e.correctnessShown,previouslyAnswered:e.previouslyAnswered||e.selected})));this.props.onChange({choiceStates:s},null,!0)}})),U(this,"deselectIncorrectSelectedChoices",(()=>{if(this.props.choiceStates){const e=this.props.choiceStates.map(((e,t)=>({...e,selected:e.selected&&!!this.props.choices[t].correct,highlighted:!1})));this.props.onChange({choiceStates:e},null,!1)}}))}render(){let e,t=this.props.choices;return e=this.props.static?M.default.map(t,(e=>({selected:e.correct,crossedOut:e.crossedOut,readOnly:!0,highlighted:!1,rationaleShown:!0,correctnessShown:!0,previouslyAnswered:!1}))):this.props.choiceStates?this.props.choiceStates:this.props.values?M.default.map(this.props.values,(e=>({selected:e,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))):M.default.map(t,(()=>({selected:!1,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))),t=M.default.map(t,((t,n)=>{const o=t.isNoneOfTheAbove&&!t.content?k._("None of the above"):t.content,{selected:s,crossedOut:i,rationaleShown:r,correctnessShown:a,readOnly:l,highlighted:c,previouslyAnswered:d}=e[n],p=this.props.reviewModeRubric&&this.props.reviewModeRubric.choices[n];return{content:this._renderRenderer(o),checked:s,correct:void 0===t.correct?!!p&&p.correct:t.correct,disabled:l,hasRationale:!!t.clue,rationale:this._renderRenderer(t.clue),showRationale:r,showCorrectness:a,isNoneOfTheAbove:t.isNoneOfTheAbove,revealNoneOfTheAbove:this.props.questionCompleted&&s,crossedOut:i,highlighted:c,previouslyAnswered:d}})),_.createElement(Ll,{ref:"baseRadio",labelWrap:!0,multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:this.props.numCorrect,choices:t,onChange:this.updateChoices,reviewModeRubric:this.props.reviewModeRubric,deselectEnabled:this.props.deselectEnabled,apiOptions:this.props.apiOptions,isLastUsedWidget:this.props.isLastUsedWidget})}static validate(e,t){const n=M.default.reduce(e.choicesSelected,((e,t)=>e+(t?1:0)),0);if(0===n)return{type:"invalid",message:null};if(e.numCorrect>1&&n!==e.numCorrect)return{type:"invalid",message:k._("Please choose the correct number of answers.")};if(e.noneOfTheAboveSelected&&n>1)return{type:"invalid",message:k._("'None of the above' may not be selected when other answers are selected.")};return{type:"points",earned:M.default.all(e.choicesSelected,((n,o)=>{let s;return s=e.noneOfTheAboveIndex===o?M.default.all(t.choices,((e,t)=>o===t||!e.correct)):!!t.choices[o].correct,s===n}))?1:0,total:1,message:null}}static getUserInputFromProps(e){if(e.choiceStates){let t=null,n=!1;const o=e.choiceStates,s=o.map((()=>!1)),i=e.countChoices,r=e.numCorrect;for(let i=0;i<s.length;i++){const r=e.choices[i].originalIndex;s[r]=o[i].selected,e.choices[i].isNoneOfTheAbove&&(t=r,s[i]&&(n=!0))}return{countChoices:i,choicesSelected:s,numCorrect:r,noneOfTheAboveIndex:t,noneOfTheAboveSelected:n}}if(e.values){let t=null,n=!1;const o=e.values.slice(),s=e.countChoices,i=e.numCorrect;for(let s=0;s<e.values.length;s++){const i=e.choices[s].originalIndex;o[i]=e.values[s],e.choices[s].isNoneOfTheAbove&&(t=i,o[s]&&(n=!0))}return{choicesSelected:o,noneOfTheAboveIndex:t,noneOfTheAboveSelected:n,countChoices:s,numCorrect:i}}return{choicesSelected:M.default.map(e.choices,(()=>!1))}}}U(Bl,"defaultProps",{choices:[{}],displayCount:null,multipleSelect:!1,countChoices:!1,deselectEnabled:!1,linterContext:nn});const{shuffle:zl,random:ql}=Ye,Hl=[[k._("False"),k._("True")],[k._("No"),k._("Yes")]],Wl=(e,t)=>{const n=((e,t)=>{let n=e.choices.slice();return n=M.default.map(n,((e,t)=>M.default.extend({},e,{originalIndex:t,correct:Boolean(e.correct)}))),function(e){let t=null;const n=M.default.reject(e,(function(e,n){if(e.isNoneOfTheAbove)return t=e,!0}));return t&&n.push(t),n}((e=>{const t=e.map((e=>e.content));return Hl.some((e=>M.default.isEqual(t,e)))?[e[1],e[0]]:e})(function(n){const o=void 0===t?ql:t;return e.randomize?zl(n,null!=o?o:0):n}(n)))})(e,t),o=M.default.reduce(e.choices,(function(e,t){return t.correct?e+1:e}),0),{hasNoneOfTheAbove:s,multipleSelect:i,countChoices:r,deselectEnabled:a}=e;return{numCorrect:o,hasNoneOfTheAbove:s,multipleSelect:i,countChoices:r,deselectEnabled:a,choices:n,selectedChoices:M.default.pluck(n,"correct")}};var Ul={name:"radio",displayName:"Multiple choice",accessible:!0,widget:Bl,transform:Wl,staticTransform:Wl,version:{major:1,minor:0},propUpgrades:{1:e=>{let t,n;if(e.noneOfTheAbove)throw new Error("radio widget v0 no longer supports auto noneOfTheAbove");return t=e.choices,n=!1,M.default.extend(M.default.omit(e,"noneOfTheAbove"),{choices:t,hasNoneOfTheAbove:n})}},isLintable:!0},Gl=[Ul,Ir,Dr,br];class Vl extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"state",{uniqueId:M.default.uniqueId("perseus_radio_")}),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"getUserInput",(()=>Vl.getUserInputFromProps(this.props))),U(this,"onChange",((e,t)=>{const n=[...this.props.values];n[e]=t,this.change("values",n),this.props.trackInteraction()})),U(this,"simpleValidate",(e=>Vl.validate(this.getUserInput(),e)))}render(){const e=this,t=this.props.apiOptions.isMobile;let n=this.props.items.map(((e,t)=>[e,t]));this.props.randomizeItems&&(n=Ye.shuffle(n,this.props.problemNum));const o=_.createElement("table",{className:"categorizer-table "+d.css(jl.mobileTable)},_.createElement("thead",null,_.createElement("tr",null,_.createElement("th",null," "),this.props.categories.map(((e,t)=>_.createElement("th",{className:d.css(jl.header),key:t},_.createElement(qi,{content:e,linterContext:this.props.linterContext})))))),_.createElement("tbody",null,n.map((n=>{const o=n[0],s=n[1],i=e.state.uniqueId+"_"+s;return _.createElement("tr",{key:s},_.createElement("td",null,_.createElement(qi,{content:o,linterContext:this.props.linterContext})),e.props.categories.map(((n,o)=>{const r=e.props.values[s]===o;return _.createElement("td",{className:"category "+d.css(jl.cell),key:o},_.createElement("div",{className:te.INTERACTIVE,role:"button","aria-label":n,onClick:this.onChange.bind(this,s,o)},t&&_.createElement("input",{type:"radio",name:i,className:d.css(ta.responsiveInput,ta.responsiveRadioInput),checked:r,onChange:this.onChange.bind(this,s,o),onClick:e=>e.stopPropagation()}),!t&&_.createElement("span",{className:d.css(jl.radioSpan,r&&jl.checkedRadioSpan,this.props.static&&r&&jl.staticCheckedRadioSpan)},r?_.createElement(V,Co):_.createElement(V,Eo))))})))})))),s=S.default({"categorizer-container":!0,"static-mode":this.props.static}),i=this.props.apiOptions.isMobile?[jl.fullBleedContainer]:[];return _.createElement("div",{className:s+" "+d.css(...i)},o)}static validate(e,t){let n=!0,o=!0;return M.default.each(t.values,(function(t,s){null==e.values[s]&&(n=!1),e.values[s]!==t&&(o=!1)})),n?{type:"points",earned:o?1:0,total:1,message:null}:{type:"invalid",message:k._("Make sure you select something for every row.")}}static getUserInputFromProps(e){return Lr.getUserInputFromProps(e)}}U(Vl,"defaultProps",{items:[],categories:[],values:[],linterContext:nn});const jl=d.StyleSheet.create({mobileTable:{[$r.smOrSmaller]:{minWidth:"auto"}},fullBleedContainer:{[$r.mdOrSmaller]:{marginLeft:-16,marginRight:-16,overflowX:"auto"}},header:{textAlign:"center",verticalAlign:"bottom"},cell:{textAlign:"center",padding:0,color:"#ccc",verticalAlign:"middle"},radioSpan:{fontSize:30,paddingRight:3,":hover":{color:"#999"}},checkedRadioSpan:{color:"#333"},staticCheckedRadioSpan:{color:"#888"}});var Yl={name:"categorizer",displayName:"Categorizer",widget:Vl,transform:e=>M.default.pick(e,"items","categories","randomizeItems"),staticTransform:e=>M.default.pick(e,"items","categories","values","randomizeItems"),isLintable:!0};let $l;const Xl=e=>new URL(e,($l||($l=window.location),$l).origin),{updateQueryString:Kl}=Ye;function Zl(e){const{InitialRequestUrl:t}=Y(),n="/computer-programming/program/"+"".concat(e,"/embedded?embed=yes&author=no");return(o=t.protocol)&&"file:"===o.toLowerCase()?"https://khanacademy.org".concat(n):Xl(n).href;var o}class Jl extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"handleMessageEvent",(e=>{let t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(M.default.isUndefined(t.testsPassed))return;const n=t.testsPassed?"correct":"incorrect";this.change({status:n,message:t.message})})),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"simpleValidate",(e=>Jl.validate({status:this.props.status,message:this.props.message},e)))}static validate(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}componentDidMount(){P.default(window).on("message",this.handleMessageEvent)}componentWillUnmount(){P.default(window).off("message",this.handleMessageEvent)}render(){if(!this.props.programID)return _.createElement("div",null);let e,t=!1,n=Zl(this.props.programID);const o={height:this.props.height,width:"100%"};if(this.props.showEditor?(n+="&editor=yes",e="perseus-scratchpad-editor"):(n+="&editor=no&width=".concat(688),e="perseus-scratchpad","webpage"!==this.props.programType&&(t=!0)),this.props.showButtons?(n+="&buttons=yes",o.height+=67):n+="&buttons=no",this.props.settings){const e={};M.default.each(this.props.settings,(function(t){t.name&&t.value&&(e[t.name]=t.value)})),n=Kl(n,"settings",JSON.stringify(e))}const s=["allow-popups","allow-same-origin","allow-scripts","allow-top-navigation"].join(" ");return _.createElement("div",{className:d.css(Ql.widthOverride,t&&Ql.container)},_.createElement("iframe",{sandbox:s,src:n,style:o,className:e,allowFullScreen:!0}))}}U(Jl,"propTypes",{...pr,programID:I.default.string,programType:I.default.oneOf(["pjs","sql","webpage"]),width:I.default.number,height:I.default.number,settings:I.default.array,showEditor:I.default.bool,showButtons:I.default.bool,status:I.default.oneOf(["incomplete","incorrect","correct"]),message:I.default.string}),U(Jl,"defaultProps",{showEditor:!1,showButtons:!1,status:"incomplete",message:null});const Ql=d.StyleSheet.create({widthOverride:{width:820},container:{margin:"auto"}});var ec={name:"cs-program",displayName:"CS Program",supportedAlignments:["block","full-width"],widget:Jl,hidden:!0};class tc extends _.Component{componentDidMount(){this.props.trackInteraction()}render(){return _.createElement(m.View,{style:oc.tooltipBody},_.createElement(qi,{apiOptions:this.props.apiOptions,content:this.props.content,widgets:this.props.widgets}))}}U(tc,"propTypes",{apiOptions:ee.propTypes,content:I.default.string,trackInteraction:I.default.func.isRequired,widgets:I.default.objectOf(I.default.any)});class nc extends _.Component{constructor(){super(...arguments),U(this,"getUserInput",(()=>({}))),U(this,"simpleValidate",(e=>nc.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const e=_.createElement(tc,{apiOptions:this.props.apiOptions,content:this.props.definition,key:this.props.definition,trackInteraction:this.props.trackInteraction,widgets:this.props.widgets});return _.createElement(z.default,{content:e,placement:"top"},_.createElement("span",{className:"perseus-widget-definition"},_.createElement(m.View,{style:oc.definitionLink},this.props.togglePrompt)))}}U(nc,"defaultProps",{togglePrompt:"define me",definition:"definition goes here"});const oc={tooltipBody:{color:L.default.offBlack,display:"block",fontSize:20,fontWeight:500,lineHeight:"30px",margin:B.default.xSmall_8},definitionLink:{borderBottom:"dashed 1px ".concat(L.default.blue),color:L.default.blue,cursor:"pointer",display:"inline-block",textDecoration:"none"}};var sc={name:"definition",displayName:"Definition",accessible:!0,defaultAlignment:"inline",widget:nc,transform:M.default.identity};class ic extends _.Component{constructor(){super(...arguments),U(this,"focus",(()=>(N.default.findDOMNode(this).focus(),!0))),U(this,"_handleChangeEvent",(e=>{this._handleChange(parseInt(e.target.value))})),U(this,"_handleChange",(e=>{this.props.trackInteraction(),this.props.onChange({selected:e})})),U(this,"getUserInput",(()=>({value:this.props.selected}))),U(this,"simpleValidate",(e=>ic.validate(this.getUserInput(),e)))}static validate(e,t){const n=e.value;if(0===n)return{type:"invalid",message:null};return{type:"points",earned:t.choices[n-1].correct?1:0,total:1,message:null}}render(){const e=[_.createElement(y.OptionItem,{key:"placeholder",value:"0",disabled:!0,label:this.props.placeholder}),...this.props.choices.map(((e,t)=>_.createElement(y.OptionItem,{key:String(t+1),value:String(t+1),label:e})))];return _.createElement("div",{onClick:e=>{e.stopPropagation()},onTouchStart:e=>{e.stopPropagation()}},_.createElement(y.SingleSelect,{onChange:e=>this._handleChange(parseInt(e)),selectedValue:String(this.props.selected),disabled:this.props.apiOptions.readOnly},e))}}U(ic,"defaultProps",{choices:[],selected:0,placeholder:"",apiOptions:ee.defaults});var rc={name:"dropdown",displayName:"Drop down",defaultAlignment:"inline-block",accessible:!0,widget:ic,transform:e=>({placeholder:e.placeholder,choices:M.default.map(e.choices,(e=>e.content))})};class ac extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"state",{expanded:!1}),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"_onClick",(()=>{this.setState({expanded:!this.state.expanded}),this.props.trackInteraction()})),U(this,"getUserInput",(()=>({}))),U(this,"simpleValidate",(e=>ac.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const{Link:e}=this.props.apiOptions.baseElements,{isArticle:t,isMobile:n}=this.props.apiOptions,o=this.state.expanded?this.props.hidePrompt:this.props.showPrompt;let s;const i="javascript:void(0)",r=this._onClick;s=n?_.createElement("div",{className:d.css(pc.linkContainer)},_.createElement("a",{className:d.css(pc.mobileExplanationLink),href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},o),this.state.expanded&&_.createElement("svg",{className:d.css(pc.disclosureArrow)},_.createElement("polygon",{style:{fill:dc},points:"0,".concat(cc," ")+"".concat(lc,",").concat(cc," ")+"".concat(lc/2,",0")}))):t?_.createElement("div",{className:d.css(pc.linkContainer,pc.articleLink)},_.createElement(e,{className:d.css(pc.explanationLink),style:pc.explanationLink,href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},"[".concat(o,"]"))):_.createElement("div",{className:d.css(pc.linkContainer,pc.exerciseLink)},_.createElement(e,{className:d.css(pc.explanationLink),href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},"[".concat(o,"]")));const a=n?pc.contentExpandedMobile:pc.contentExpanded;return _.createElement("div",{className:d.css(pc.container)},s,this.state.expanded&&_.createElement("div",{className:d.css(pc.content,n&&pc.contentMobile,this.state.expanded&&a),ref:"content"},_.createElement(qi,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,linterContext:this.props.linterContext})))}}U(ac,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{},linterContext:nn});const lc=30,cc=14,dc="#F0F1F2",pc=d.StyleSheet.create({container:{display:"inline",position:"relative"},linkContainer:{display:"inline-block"},explanationLink:{fontStyle:"italic",color:"#007d96"},articleLink:{fontSize:20,lineHeight:"30px"},exerciseLink:{fontSize:14,lineHeight:"19.6px"},mobileExplanationLink:{color:"#71B307",borderBottom:"dashed 1px ".concat("#71B307"),textDecoration:"none",[$r.xl]:{fontSize:22,lineHeight:1.4},[$r.lgOrSmaller]:{fontSize:20,lineHeight:1.5},[$r.smOrSmaller]:{fontSize:18,lineHeight:1.2}},content:{position:"relative",transition:"margin-top 0.1s"},contentExpanded:{borderLeft:"5px solid #ccc",marginLeft:-23,paddingLeft:23,paddingBottom:10,marginBottom:cc,marginTop:cc},contentExpandedMobile:{boxSizing:"content-box",paddingTop:32,paddingBottom:32,marginTop:cc},contentMobile:{background:dc,marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16},disclosureArrow:{bottom:-(cc+5),height:cc,left:"50%",marginLeft:-lc/2,position:"absolute",width:lc}});var uc={name:"explanation",displayName:"Explanation",accessible:!0,defaultAlignment:"inline",widget:ac,transform:M.default.identity,isLintable:!0};function hc(e,t){return hc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},hc(e,t)}function fc(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,hc(e,t)}function mc(e){return"/"===e.charAt(0)}function gc(e,t){for(var n=t,o=n+1,s=e.length;o<s;n+=1,o+=1)e[n]=e[o];e.pop()}var vc="production"===process.env.NODE_ENV;function yc(e,t){if(!vc){if(e)return;var n="Warning: "+t;"undefined"!=typeof console&&console.warn(n);try{throw Error(n)}catch(e){}}}var bc="production"===process.env.NODE_ENV,xc="Invariant failed";function wc(e,t){if(!e){if(bc)throw new Error(xc);var n="function"==typeof t?t():t;throw new Error(n?xc+": "+n:xc)}}function Cc(e){return"/"===e.charAt(0)?e:"/"+e}function kc(e){return"/"===e.charAt(0)?e.substr(1):e}function Sc(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function Ec(e,t){return Sc(e,t)?e.substr(t.length):e}function _c(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function Tc(e){var t=e.pathname,n=e.search,o=e.hash,s=t||"/";return n&&"?"!==n&&(s+="?"===n.charAt(0)?n:"?"+n),o&&"#"!==o&&(s+="#"===o.charAt(0)?o:"#"+o),s}function Mc(e,t,n,o){var s;"string"==typeof e?(s=function(e){var t=e||"/",n="",o="",s=t.indexOf("#");-1!==s&&(o=t.substr(s),t=t.substr(0,s));var i=t.indexOf("?");return-1!==i&&(n=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===n?"":n,hash:"#"===o?"":o}}(e),s.state=t):(void 0===(s=fa({},e)).pathname&&(s.pathname=""),s.search?"?"!==s.search.charAt(0)&&(s.search="?"+s.search):s.search="",s.hash?"#"!==s.hash.charAt(0)&&(s.hash="#"+s.hash):s.hash="",void 0!==t&&void 0===s.state&&(s.state=t));try{s.pathname=decodeURI(s.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+s.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(s.key=n),o?s.pathname?"/"!==s.pathname.charAt(0)&&(s.pathname=function(e,t){void 0===t&&(t="");var n,o=e&&e.split("/")||[],s=t&&t.split("/")||[],i=e&&mc(e),r=t&&mc(t),a=i||r;if(e&&mc(e)?s=o:o.length&&(s.pop(),s=s.concat(o)),!s.length)return"/";if(s.length){var l=s[s.length-1];n="."===l||".."===l||""===l}else n=!1;for(var c=0,d=s.length;d>=0;d--){var p=s[d];"."===p?gc(s,d):".."===p?(gc(s,d),c++):c&&(gc(s,d),c--)}if(!a)for(;c--;c)s.unshift("..");!a||""===s[0]||s[0]&&mc(s[0])||s.unshift("");var u=s.join("/");return n&&"/"!==u.substr(-1)&&(u+="/"),u}(s.pathname,o.pathname)):s.pathname=o.pathname:s.pathname||(s.pathname="/"),s}function Ic(){var e=null;var t=[];return{setPrompt:function(t){return"production"!==process.env.NODE_ENV&&yc(null==e,"A history supports only one prompt at a time"),e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,o,s){if(null!=e){var i="function"==typeof e?e(t,n):e;"string"==typeof i?"function"==typeof o?o(i,s):("production"!==process.env.NODE_ENV&&yc(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),s(!0)):s(!1!==i)}else s(!0)},appendListener:function(e){var n=!0;function o(){n&&e.apply(void 0,arguments)}return t.push(o),function(){n=!1,t=t.filter((function(e){return e!==o}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];t.forEach((function(e){return e.apply(void 0,n)}))}}}var Pc=!("undefined"==typeof window||!window.document||!window.document.createElement);function Nc(e,t){t(window.confirm(e))}function Ac(){try{return window.history.state||{}}catch(e){return{}}}function Rc(e){void 0===e&&(e={}),Pc||("production"!==process.env.NODE_ENV?wc(!1,"Browser history needs a DOM"):wc(!1));var t,n=window.history,o=(-1===(t=window.navigator.userAgent).indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&window.history&&"pushState"in window.history,s=!(-1===window.navigator.userAgent.indexOf("Trident")),i=e,r=i.forceRefresh,a=void 0!==r&&r,l=i.getUserConfirmation,c=void 0===l?Nc:l,d=i.keyLength,p=void 0===d?6:d,u=e.basename?_c(Cc(e.basename)):"";function h(e){var t=e||{},n=t.key,o=t.state,s=window.location,i=s.pathname+s.search+s.hash;return"production"!==process.env.NODE_ENV&&yc(!u||Sc(i,u),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+i+'" to begin with "'+u+'".'),u&&(i=Ec(i,u)),Mc(i,o,n)}function f(){return Math.random().toString(36).substr(2,p)}var m=Ic();function g(e){fa(M,e),M.length=n.length,m.notifyListeners(M.location,M.action)}function v(e){(function(e){return void 0===e.state&&-1===navigator.userAgent.indexOf("CriOS")})(e)||x(h(e.state))}function y(){x(h(Ac()))}var b=!1;function x(e){if(b)b=!1,g();else{m.confirmTransitionTo(e,"POP",c,(function(t){t?g({action:"POP",location:e}):function(e){var t=M.location,n=C.indexOf(t.key);-1===n&&(n=0);var o=C.indexOf(e.key);-1===o&&(o=0);var s=n-o;s&&(b=!0,S(s))}(e)}))}}var w=h(Ac()),C=[w.key];function k(e){return u+Tc(e)}function S(e){n.go(e)}var E=0;function _(e){1===(E+=e)&&1===e?(window.addEventListener("popstate",v),s&&window.addEventListener("hashchange",y)):0===E&&(window.removeEventListener("popstate",v),s&&window.removeEventListener("hashchange",y))}var T=!1;var M={length:n.length,action:"POP",location:w,createHref:k,push:function(e,t){"production"!==process.env.NODE_ENV&&yc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var s="PUSH",i=Mc(e,t,f(),M.location);m.confirmTransitionTo(i,s,c,(function(e){if(e){var t=k(i),r=i.key,l=i.state;if(o)if(n.pushState({key:r,state:l},null,t),a)window.location.href=t;else{var c=C.indexOf(M.location.key),d=C.slice(0,c+1);d.push(i.key),C=d,g({action:s,location:i})}else"production"!==process.env.NODE_ENV&&yc(void 0===l,"Browser history cannot push state in browsers that do not support HTML5 history"),window.location.href=t}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&yc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var s="REPLACE",i=Mc(e,t,f(),M.location);m.confirmTransitionTo(i,s,c,(function(e){if(e){var t=k(i),r=i.key,l=i.state;if(o)if(n.replaceState({key:r,state:l},null,t),a)window.location.replace(t);else{var c=C.indexOf(M.location.key);-1!==c&&(C[c]=i.key),g({action:s,location:i})}else"production"!==process.env.NODE_ENV&&yc(void 0===l,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(t)}}))},go:S,goBack:function(){S(-1)},goForward:function(){S(1)},block:function(e){void 0===e&&(e=!1);var t=m.setPrompt(e);return T||(_(1),T=!0),function(){return T&&(T=!1,_(-1)),t()}},listen:function(e){var t=m.appendListener(e);return _(1),function(){_(-1),t()}}};return M}var Fc={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+kc(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:kc,decodePath:Cc},slash:{encodePath:Cc,decodePath:Cc}};function Oc(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function Dc(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function Lc(e){window.location.replace(Oc(window.location.href)+"#"+e)}function Bc(e){void 0===e&&(e={}),Pc||("production"!==process.env.NODE_ENV?wc(!1,"Hash history needs a DOM"):wc(!1));var t=window.history,n=-1===window.navigator.userAgent.indexOf("Firefox"),o=e,s=o.getUserConfirmation,i=void 0===s?Nc:s,r=o.hashType,a=void 0===r?"slash":r,l=e.basename?_c(Cc(e.basename)):"",c=Fc[a],d=c.encodePath,p=c.decodePath;function u(){var e=p(Dc());return"production"!==process.env.NODE_ENV&&yc(!l||Sc(e,l),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+e+'" to begin with "'+l+'".'),l&&(e=Ec(e,l)),Mc(e)}var h=Ic();function f(e){fa(_,e),_.length=t.length,h.notifyListeners(_.location,_.action)}var m=!1,g=null;function v(){var e,t,n=Dc(),o=d(n);if(n!==o)Lc(o);else{var s=u(),r=_.location;if(!m&&(t=s,(e=r).pathname===t.pathname&&e.search===t.search&&e.hash===t.hash))return;if(g===Tc(s))return;g=null,function(e){if(m)m=!1,f();else{var t="POP";h.confirmTransitionTo(e,t,i,(function(n){n?f({action:t,location:e}):function(e){var t=_.location,n=w.lastIndexOf(Tc(t));-1===n&&(n=0);var o=w.lastIndexOf(Tc(e));-1===o&&(o=0);var s=n-o;s&&(m=!0,C(s))}(e)}))}}(s)}}var y=Dc(),b=d(y);y!==b&&Lc(b);var x=u(),w=[Tc(x)];function C(e){"production"!==process.env.NODE_ENV&&yc(n,"Hash history go(n) causes a full page reload in this browser"),t.go(e)}var k=0;function S(e){1===(k+=e)&&1===e?window.addEventListener("hashchange",v):0===k&&window.removeEventListener("hashchange",v)}var E=!1;var _={length:t.length,action:"POP",location:x,createHref:function(e){var t=document.querySelector("base"),n="";return t&&t.getAttribute("href")&&(n=Oc(window.location.href)),n+"#"+d(l+Tc(e))},push:function(e,t){"production"!==process.env.NODE_ENV&&yc(void 0===t,"Hash history cannot push state; it is ignored");var n="PUSH",o=Mc(e,void 0,void 0,_.location);h.confirmTransitionTo(o,n,i,(function(e){if(e){var t=Tc(o),s=d(l+t);if(Dc()!==s){g=t,function(e){window.location.hash=e}(s);var i=w.lastIndexOf(Tc(_.location)),r=w.slice(0,i+1);r.push(t),w=r,f({action:n,location:o})}else"production"!==process.env.NODE_ENV&&yc(!1,"Hash history cannot PUSH the same path; a new entry will not be added to the history stack"),f()}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&yc(void 0===t,"Hash history cannot replace state; it is ignored");var n="REPLACE",o=Mc(e,void 0,void 0,_.location);h.confirmTransitionTo(o,n,i,(function(e){if(e){var t=Tc(o),s=d(l+t);Dc()!==s&&(g=t,Lc(s));var i=w.indexOf(Tc(_.location));-1!==i&&(w[i]=t),f({action:n,location:o})}}))},go:C,goBack:function(){C(-1)},goForward:function(){C(1)},block:function(e){void 0===e&&(e=!1);var t=h.setPrompt(e);return E||(S(1),E=!0),function(){return E&&(E=!1,S(-1)),t()}},listen:function(e){var t=h.appendListener(e);return S(1),function(){S(-1),t()}}};return _}function zc(e,t,n){return Math.min(Math.max(e,t),n)}function qc(e){void 0===e&&(e={});var t=e,n=t.getUserConfirmation,o=t.initialEntries,s=void 0===o?["/"]:o,i=t.initialIndex,r=void 0===i?0:i,a=t.keyLength,l=void 0===a?6:a,c=Ic();function d(e){fa(g,e),g.length=g.entries.length,c.notifyListeners(g.location,g.action)}function p(){return Math.random().toString(36).substr(2,l)}var u=zc(r,0,s.length-1),h=s.map((function(e){return Mc(e,void 0,"string"==typeof e?p():e.key||p())})),f=Tc;function m(e){var t=zc(g.index+e,0,g.entries.length-1),o=g.entries[t];c.confirmTransitionTo(o,"POP",n,(function(e){e?d({action:"POP",location:o,index:t}):d()}))}var g={length:h.length,action:"POP",location:h[u],index:u,entries:h,createHref:f,push:function(e,t){"production"!==process.env.NODE_ENV&&yc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var o="PUSH",s=Mc(e,t,p(),g.location);c.confirmTransitionTo(s,o,n,(function(e){if(e){var t=g.index+1,n=g.entries.slice(0);n.length>t?n.splice(t,n.length-t,s):n.push(s),d({action:o,location:s,index:t,entries:n})}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&yc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var o="REPLACE",s=Mc(e,t,p(),g.location);c.confirmTransitionTo(s,o,n,(function(e){e&&(g.entries[g.index]=s,d({action:o,location:s}))}))},go:m,goBack:function(){m(-1)},goForward:function(){m(1)},canGo:function(e){var t=g.index+e;return t>=0&&t<g.entries.length},block:function(e){return void 0===e&&(e=!1),c.setPrompt(e)},listen:function(e){return c.appendListener(e)}};return g}var Hc="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function Wc(e){var t=[];return{on:function(e){t.push(e)},off:function(e){t=t.filter((function(t){return t!==e}))},get:function(){return e},set:function(n,o){e=n,t.forEach((function(t){return t(e,o)}))}}}var Uc=T.default.createContext||function(e,t){var n,o,i="__create-react-context-"+function(){var e="__global_unique_id__";return Hc[e]=(Hc[e]||0)+1}()+"__",r=function(e){function n(){var t;return(t=e.apply(this,arguments)||this).emitter=Wc(t.props.value),t}fc(n,e);var o=n.prototype;return o.getChildContext=function(){var e;return(e={})[i]=this.emitter,e},o.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var n,o=this.props.value,s=e.value;((i=o)===(r=s)?0!==i||1/i==1/r:i!=i&&r!=r)?n=0:(n="function"==typeof t?t(o,s):1073741823,"production"!==process.env.NODE_ENV&&yc((1073741823&n)===n,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: "+n),0!==(n|=0)&&this.emitter.set(e.value,n))}var i,r},o.render=function(){return this.props.children},n}(s.Component);r.childContextTypes=((n={})[i]=I.default.object.isRequired,n);var a=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).state={value:e.getValue()},e.onUpdate=function(t,n){0!=((0|e.observedBits)&n)&&e.setState({value:e.getValue()})},e}fc(n,t);var o=n.prototype;return o.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?1073741823:t},o.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?1073741823:e},o.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},o.getValue=function(){return this.context[i]?this.context[i].get():e},o.render=function(){return(e=this.props.children,Array.isArray(e)?e[0]:e)(this.state.value);var e},n}(s.Component);return a.contextTypes=((o={})[i]=I.default.object,o),{Provider:r,Consumer:a}},Gc={exports:{}},Vc=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)};Gc.exports=td,Gc.exports.parse=Yc,Gc.exports.compile=function(e,t){return Xc(Yc(e,t),t)},Gc.exports.tokensToFunction=Xc,Gc.exports.tokensToRegExp=ed;var jc=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function Yc(e,t){for(var n,o=[],s=0,i=0,r="",a=t&&t.delimiter||"/";null!=(n=jc.exec(e));){var l=n[0],c=n[1],d=n.index;if(r+=e.slice(i,d),i=d+l.length,c)r+=c[1];else{var p=e[i],u=n[2],h=n[3],f=n[4],m=n[5],g=n[6],v=n[7];r&&(o.push(r),r="");var y=null!=u&&null!=p&&p!==u,b="+"===g||"*"===g,x="?"===g||"*"===g,w=n[2]||a,C=f||m;o.push({name:h||s++,prefix:u||"",delimiter:w,optional:x,repeat:b,partial:y,asterisk:!!v,pattern:C?Zc(C):v?".*":"[^"+Kc(w)+"]+?"})}}return i<e.length&&(r+=e.substr(i)),r&&o.push(r),o}function $c(e){return encodeURI(e).replace(/[\/?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}function Xc(e,t){for(var n=new Array(e.length),o=0;o<e.length;o++)"object"==typeof e[o]&&(n[o]=new RegExp("^(?:"+e[o].pattern+")$",Qc(t)));return function(t,o){for(var s="",i=t||{},r=(o||{}).pretty?$c:encodeURIComponent,a=0;a<e.length;a++){var l=e[a];if("string"!=typeof l){var c,d=i[l.name];if(null==d){if(l.optional){l.partial&&(s+=l.prefix);continue}throw new TypeError('Expected "'+l.name+'" to be defined')}if(Vc(d)){if(!l.repeat)throw new TypeError('Expected "'+l.name+'" to not repeat, but received `'+JSON.stringify(d)+"`");if(0===d.length){if(l.optional)continue;throw new TypeError('Expected "'+l.name+'" to not be empty')}for(var p=0;p<d.length;p++){if(c=r(d[p]),!n[a].test(c))throw new TypeError('Expected all "'+l.name+'" to match "'+l.pattern+'", but received `'+JSON.stringify(c)+"`");s+=(0===p?l.prefix:l.delimiter)+c}}else{if(c=l.asterisk?encodeURI(d).replace(/[?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})):r(d),!n[a].test(c))throw new TypeError('Expected "'+l.name+'" to match "'+l.pattern+'", but received "'+c+'"');s+=l.prefix+c}}else s+=l}return s}}function Kc(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function Zc(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function Jc(e,t){return e.keys=t,e}function Qc(e){return e&&e.sensitive?"":"i"}function ed(e,t,n){Vc(t)||(n=t||n,t=[]);for(var o=(n=n||{}).strict,s=!1!==n.end,i="",r=0;r<e.length;r++){var a=e[r];if("string"==typeof a)i+=Kc(a);else{var l=Kc(a.prefix),c="(?:"+a.pattern+")";t.push(a),a.repeat&&(c+="(?:"+l+c+")*"),i+=c=a.optional?a.partial?l+"("+c+")?":"(?:"+l+"("+c+"))?":l+"("+c+")"}}var d=Kc(n.delimiter||"/"),p=i.slice(-d.length)===d;return o||(i=(p?i.slice(0,-d.length):i)+"(?:"+d+"(?=$))?"),i+=s?"$":o&&p?"":"(?="+d+"|$)",Jc(new RegExp("^"+i,Qc(n)),t)}function td(e,t,n){return Vc(t)||(n=t||n,t=[]),n=n||{},e instanceof RegExp?function(e,t){var n=e.source.match(/\((?!\?)/g);if(n)for(var o=0;o<n.length;o++)t.push({name:o,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return Jc(e,t)}(e,t):Vc(e)?function(e,t,n){for(var o=[],s=0;s<e.length;s++)o.push(td(e[s],t,n).source);return Jc(new RegExp("(?:"+o.join("|")+")",Qc(n)),t)}(e,t,n):function(e,t,n){return ed(Yc(e,n),t,n)}(e,t,n)}var nd,od={exports:{}},sd={};var id,rd,ad={};
|
|
8
|
+
/** @license React v16.13.1
|
|
9
|
+
* react-is.development.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/rd=od,"production"===process.env.NODE_ENV?rd.exports=function(){if(nd)return sd;nd=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,r=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,h=e?Symbol.for("react.memo"):60115,f=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var u=e.$$typeof;switch(u){case t:switch(e=e.type){case l:case c:case o:case i:case s:case p:return e;default:switch(e=e&&e.$$typeof){case a:case d:case f:case h:case r:return e;default:return u}}case n:return u}}}function x(e){return b(e)===c}return sd.AsyncMode=l,sd.ConcurrentMode=c,sd.ContextConsumer=a,sd.ContextProvider=r,sd.Element=t,sd.ForwardRef=d,sd.Fragment=o,sd.Lazy=f,sd.Memo=h,sd.Portal=n,sd.Profiler=i,sd.StrictMode=s,sd.Suspense=p,sd.isAsyncMode=function(e){return x(e)||b(e)===l},sd.isConcurrentMode=x,sd.isContextConsumer=function(e){return b(e)===a},sd.isContextProvider=function(e){return b(e)===r},sd.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},sd.isForwardRef=function(e){return b(e)===d},sd.isFragment=function(e){return b(e)===o},sd.isLazy=function(e){return b(e)===f},sd.isMemo=function(e){return b(e)===h},sd.isPortal=function(e){return b(e)===n},sd.isProfiler=function(e){return b(e)===i},sd.isStrictMode=function(e){return b(e)===s},sd.isSuspense=function(e){return b(e)===p},sd.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===c||e===i||e===s||e===p||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===h||e.$$typeof===r||e.$$typeof===a||e.$$typeof===d||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y||e.$$typeof===m)},sd.typeOf=b,sd}():rd.exports=(id||(id=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,r=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,h=e?Symbol.for("react.memo"):60115,f=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var u=e.$$typeof;switch(u){case t:var m=e.type;switch(m){case l:case c:case o:case i:case s:case p:return m;default:var g=m&&m.$$typeof;switch(g){case a:case d:case f:case h:case r:return g;default:return u}}case n:return u}}}var x=l,w=c,C=a,k=r,S=t,E=d,_=o,T=f,M=h,I=n,P=i,N=s,A=p,R=!1;function F(e){return b(e)===c}ad.AsyncMode=x,ad.ConcurrentMode=w,ad.ContextConsumer=C,ad.ContextProvider=k,ad.Element=S,ad.ForwardRef=E,ad.Fragment=_,ad.Lazy=T,ad.Memo=M,ad.Portal=I,ad.Profiler=P,ad.StrictMode=N,ad.Suspense=A,ad.isAsyncMode=function(e){return R||(R=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),F(e)||b(e)===l},ad.isConcurrentMode=F,ad.isContextConsumer=function(e){return b(e)===a},ad.isContextProvider=function(e){return b(e)===r},ad.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},ad.isForwardRef=function(e){return b(e)===d},ad.isFragment=function(e){return b(e)===o},ad.isLazy=function(e){return b(e)===f},ad.isMemo=function(e){return b(e)===h},ad.isPortal=function(e){return b(e)===n},ad.isProfiler=function(e){return b(e)===i},ad.isStrictMode=function(e){return b(e)===s},ad.isSuspense=function(e){return b(e)===p},ad.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===c||e===i||e===s||e===p||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===h||e.$$typeof===r||e.$$typeof===a||e.$$typeof===d||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y||e.$$typeof===m)},ad.typeOf=b}()),ad);var ld=od.exports,cd={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},dd={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},pd={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ud={};function hd(e){return ld.isMemo(e)?pd:ud[e.$$typeof]||cd}ud[ld.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},ud[ld.Memo]=pd;var fd=Object.defineProperty,md=Object.getOwnPropertyNames,gd=Object.getOwnPropertySymbols,vd=Object.getOwnPropertyDescriptor,yd=Object.getPrototypeOf,bd=Object.prototype;var xd=function e(t,n,o){if("string"!=typeof n){if(bd){var s=yd(n);s&&s!==bd&&e(t,s,o)}var i=md(n);gd&&(i=i.concat(gd(n)));for(var r=hd(t),a=hd(n),l=0;l<i.length;++l){var c=i[l];if(!(dd[c]||o&&o[c]||a&&a[c]||r&&r[c])){var d=vd(n,c);try{fd(t,c,d)}catch(e){}}}}return t},wd=function(e){var t=Uc();return t.displayName=e,t},Cd=wd("Router-History"),kd=wd("Router"),Sd=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={location:t.history.location},n._isMounted=!1,n._pendingLocation=null,t.staticContext||(n.unlisten=t.history.listen((function(e){n._isMounted?n.setState({location:e}):n._pendingLocation=e}))),n}fc(t,e),t.computeRootMatch=function(e){return{path:"/",url:"/",params:{},isExact:"/"===e}};var n=t.prototype;return n.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&(this.unlisten(),this._isMounted=!1,this._pendingLocation=null)},n.render=function(){return T.default.createElement(kd.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},T.default.createElement(Cd.Provider,{children:this.props.children||null,value:this.props.history}))},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(Sd.propTypes={children:I.default.node,history:I.default.object.isRequired,staticContext:I.default.object},Sd.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&yc(e.history===this.props.history,"You cannot change <Router history>")});var Ed=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).history=qc(t.props),t}return fc(t,e),t.prototype.render=function(){return T.default.createElement(Sd,{history:this.history,children:this.props.children})},t}(T.default.Component);if("production"!==process.env.NODE_ENV&&(Ed.propTypes={initialEntries:I.default.array,initialIndex:I.default.number,getUserConfirmation:I.default.func,keyLength:I.default.number,children:I.default.node},Ed.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&yc(!this.props.history,"<MemoryRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { MemoryRouter as Router }`.")}),T.default.Component,"production"!==process.env.NODE_ENV){var _d=I.default.oneOfType([I.default.func,I.default.string]);I.default.bool,_d.isRequired}"production"!==process.env.NODE_ENV&&(I.default.bool,I.default.string,I.default.oneOfType([I.default.string,I.default.object]).isRequired);var Td={},Md=0;function Id(e,t){void 0===t&&(t={}),("string"==typeof t||Array.isArray(t))&&(t={path:t});var n=t,o=n.path,s=n.exact,i=void 0!==s&&s,r=n.strict,a=void 0!==r&&r,l=n.sensitive,c=void 0!==l&&l;return[].concat(o).reduce((function(t,n){if(!n&&""!==n)return null;if(t)return t;var o=function(e,t){var n=""+t.end+t.strict+t.sensitive,o=Td[n]||(Td[n]={});if(o[e])return o[e];var s=[],i={regexp:Gc.exports(e,s,t),keys:s};return Md<1e4&&(o[e]=i,Md++),i}(n,{end:i,strict:a,sensitive:c}),s=o.regexp,r=o.keys,l=s.exec(e);if(!l)return null;var d=l[0],p=l.slice(1),u=e===d;return i&&!u?null:{path:n,url:"/"===n&&""===d?"/":d,isExact:u,params:r.reduce((function(e,t,n){return e[t.name]=p[n],e}),{})}}),null)}function Pd(e){return 0===T.default.Children.count(e)}function Nd(e,t,n){var o=e(t);return"production"!==process.env.NODE_ENV&&yc(void 0!==o,"You returned `undefined` from the `children` function of <Route"+(n?' path="'+n+'"':"")+">, but you should have returned a React element or `null`"),o||null}var Ad=function(e){function t(){return e.apply(this,arguments)||this}return fc(t,e),t.prototype.render=function(){var e=this;return T.default.createElement(kd.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?wc(!1,"You should not use <Route> outside a <Router>"):wc(!1));var n=e.props.location||t.location,o=fa({},t,{location:n,match:e.props.computedMatch?e.props.computedMatch:e.props.path?Id(n.pathname,e.props):t.match}),s=e.props,i=s.children,r=s.component,a=s.render;return Array.isArray(i)&&Pd(i)&&(i=null),T.default.createElement(kd.Provider,{value:o},o.match?i?"function"==typeof i?"production"!==process.env.NODE_ENV?Nd(i,o,e.props.path):i(o):i:r?T.default.createElement(r,o):a?a(o):null:"function"==typeof i?"production"!==process.env.NODE_ENV?Nd(i,o,e.props.path):i(o):null)}))},t}(T.default.Component);function Rd(e){return"/"===e.charAt(0)?e:"/"+e}function Fd(e,t){if(!e)return t;var n=Rd(e);return 0!==t.pathname.indexOf(n)?t:fa({},t,{pathname:t.pathname.substr(n.length)})}function Od(e){return"string"==typeof e?e:Tc(e)}function Dd(e){return function(){"production"!==process.env.NODE_ENV?wc(!1,"You cannot %s with <StaticRouter>"):wc(!1)}}function Ld(){}"production"!==process.env.NODE_ENV&&(Ad.propTypes={children:I.default.oneOfType([I.default.func,I.default.node]),component:function(e,t){if(e[t]&&!od.exports.isValidElementType(e[t]))return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component")},exact:I.default.bool,location:I.default.object,path:I.default.oneOfType([I.default.string,I.default.arrayOf(I.default.string)]),render:I.default.func,sensitive:I.default.bool,strict:I.default.bool},Ad.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&yc(!(this.props.children&&!Pd(this.props.children)&&this.props.component),"You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored"),"production"!==process.env.NODE_ENV&&yc(!(this.props.children&&!Pd(this.props.children)&&this.props.render),"You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored"),"production"!==process.env.NODE_ENV&&yc(!(this.props.component&&this.props.render),"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored")},Ad.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&yc(!(this.props.location&&!e.location),'<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.'),"production"!==process.env.NODE_ENV&&yc(!(!this.props.location&&e.location),'<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.')});var Bd=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).handlePush=function(e){return t.navigateTo(e,"PUSH")},t.handleReplace=function(e){return t.navigateTo(e,"REPLACE")},t.handleListen=function(){return Ld},t.handleBlock=function(){return Ld},t}fc(t,e);var n=t.prototype;return n.navigateTo=function(e,t){var n=this.props,o=n.basename,s=void 0===o?"":o,i=n.context,r=void 0===i?{}:i;r.action=t,r.location=function(e,t){return e?fa({},t,{pathname:Rd(e)+t.pathname}):t}(s,Mc(e)),r.url=Od(r.location)},n.render=function(){var e=this.props,t=e.basename,n=void 0===t?"":t,o=e.context,s=void 0===o?{}:o,i=e.location,r=void 0===i?"/":i,a=ma(e,["basename","context","location"]),l={createHref:function(e){return Rd(n+Od(e))},action:"POP",location:Fd(n,Mc(r)),push:this.handlePush,replace:this.handleReplace,go:Dd(),goBack:Dd(),goForward:Dd(),listen:this.handleListen,block:this.handleBlock};return T.default.createElement(Sd,fa({},a,{history:l,staticContext:s}))},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(Bd.propTypes={basename:I.default.string,context:I.default.object,location:I.default.oneOfType([I.default.string,I.default.object])},Bd.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&yc(!this.props.history,"<StaticRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { StaticRouter as Router }`.")});var zd=function(e){function t(){return e.apply(this,arguments)||this}return fc(t,e),t.prototype.render=function(){var e=this;return T.default.createElement(kd.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?wc(!1,"You should not use <Switch> outside a <Router>"):wc(!1));var n,o,s=e.props.location||t.location;return T.default.Children.forEach(e.props.children,(function(e){if(null==o&&T.default.isValidElement(e)){n=e;var i=e.props.path||e.props.from;o=i?Id(s.pathname,fa({},e.props,{path:i})):t.match}})),o?T.default.cloneElement(n,{location:s,computedMatch:o}):null}))},t}(T.default.Component);if("production"!==process.env.NODE_ENV&&(zd.propTypes={children:I.default.node,location:I.default.object},zd.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&yc(!(this.props.location&&!e.location),'<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.'),"production"!==process.env.NODE_ENV&&yc(!(!this.props.location&&e.location),'<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.')}),T.default.useContext,"production"!==process.env.NODE_ENV&&"undefined"!=typeof window){var qd=window,Hd="__react_router_build__",Wd={cjs:"CommonJS",esm:"ES modules",umd:"UMD"};if(qd[Hd]&&"esm"!==qd[Hd]){var Ud=Wd[qd[Hd]];throw new Error("You are loading the "+Wd.esm+" build of React Router on a page that is already running the "+Ud+" build, so things won't work right.")}qd[Hd]="esm"}var Gd=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).history=Rc(t.props),t}return fc(t,e),t.prototype.render=function(){return T.default.createElement(Sd,{history:this.history,children:this.props.children})},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(Gd.propTypes={basename:I.default.string,children:I.default.node,forceRefresh:I.default.bool,getUserConfirmation:I.default.func,keyLength:I.default.number},Gd.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&yc(!this.props.history,"<BrowserRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { BrowserRouter as Router }`.")});var Vd=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).history=Bc(t.props),t}return fc(t,e),t.prototype.render=function(){return T.default.createElement(Sd,{history:this.history,children:this.props.children})},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(Vd.propTypes={basename:I.default.string,children:I.default.node,getUserConfirmation:I.default.func,hashType:I.default.oneOf(["hashbang","noslash","slash"])},Vd.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&yc(!this.props.history,"<HashRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { HashRouter as Router }`.")});var jd=function(e,t){return"function"==typeof e?e(t):e},Yd=function(e,t){return"string"==typeof e?Mc(e,null,null,t):e},$d=function(e){return e},Xd=T.default.forwardRef;void 0===Xd&&(Xd=$d);var Kd=Xd((function(e,t){var n=e.innerRef,o=e.navigate,s=e.onClick,i=ma(e,["innerRef","navigate","onClick"]),r=i.target,a=fa({},i,{onClick:function(e){try{s&&s(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||r&&"_self"!==r||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),o())}});return a.ref=$d!==Xd&&t||n,T.default.createElement("a",a)}));"production"!==process.env.NODE_ENV&&(Kd.displayName="LinkAnchor");var Zd=Xd((function(e,t){var n=e.component,o=void 0===n?Kd:n,s=e.replace,i=e.to,r=e.innerRef,a=ma(e,["component","replace","to","innerRef"]);return T.default.createElement(kd.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?wc(!1,"You should not use <Link> outside a <Router>"):wc(!1));var n=e.history,l=Yd(jd(i,e.location),e.location),c=l?n.createHref(l):"",d=fa({},a,{href:c,navigate:function(){var t=jd(i,e.location),o=Tc(e.location)===Tc(Yd(t));(s||o?n.replace:n.push)(t)}});return $d!==Xd?d.ref=t||r:d.innerRef=r,T.default.createElement(o,d)}))}));if("production"!==process.env.NODE_ENV){var Jd=I.default.oneOfType([I.default.string,I.default.object,I.default.func]),Qd=I.default.oneOfType([I.default.string,I.default.func,I.default.shape({current:I.default.any})]);Zd.displayName="Link",Zd.propTypes={innerRef:Qd,onClick:I.default.func,replace:I.default.bool,target:I.default.string,to:Jd.isRequired}}var ep=function(e){return e},tp=T.default.forwardRef;void 0===tp&&(tp=ep);var np=tp((function(e,t){var n=e["aria-current"],o=void 0===n?"page":n,s=e.activeClassName,i=void 0===s?"active":s,r=e.activeStyle,a=e.className,l=e.exact,c=e.isActive,d=e.location,p=e.sensitive,u=e.strict,h=e.style,f=e.to,m=e.innerRef,g=ma(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return T.default.createElement(kd.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?wc(!1,"You should not use <NavLink> outside a <Router>"):wc(!1));var n=d||e.location,s=Yd(jd(f,n),n),v=s.pathname,y=v&&v.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),b=y?Id(n.pathname,{path:y,exact:l,sensitive:p,strict:u}):null,x=!!(c?c(b,n):b),w="function"==typeof a?a(x):a,C="function"==typeof h?h(x):h;x&&(w=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((function(e){return e})).join(" ")}(w,i),C=fa({},C,r));var k=fa({"aria-current":x&&o||null,className:w,style:C,to:s},g);return ep!==tp?k.ref=t||m:k.innerRef=m,T.default.createElement(Zd,k)}))}));if("production"!==process.env.NODE_ENV){np.displayName="NavLink";var op=I.default.oneOf(["page","step","location","date","time","true","false"]);np.propTypes=fa({},Zd.propTypes,{"aria-current":op,activeClassName:I.default.string,activeStyle:I.default.object,className:I.default.oneOfType([I.default.string,I.default.func]),exact:I.default.bool,isActive:I.default.func,location:I.default.object,sensitive:I.default.bool,strict:I.default.bool,style:I.default.oneOfType([I.default.object,I.default.func])})}const sp=e=>{switch(e){case"link":return{triggerOnEnter:!0,triggerOnSpace:!1};case"checkbox":case"radio":case"listbox":case"option":return{triggerOnEnter:!1,triggerOnSpace:!0};default:return{triggerOnEnter:!0,triggerOnSpace:!0}}},ip={onClick:()=>{},onMouseEnter:()=>{},onMouseLeave:()=>{},onMouseDown:()=>{},onMouseUp:()=>{},onDragStart:()=>{},onTouchStart:()=>{},onTouchEnd:()=>{},onTouchCancel:()=>{},onKeyDown:()=>{},onKeyUp:()=>{},tabIndex:0},rp=13,ap=32,lp={hovered:!1,focused:!1,pressed:!1,waiting:!1};class cp extends _.Component{static getDerivedStateFromProps(e,t){return e.disabled?fa({},lp,{focused:t.focused}):null}constructor(e){super(e),this.handleClick=e=>{const{onClick:t,beforeNav:n,safeWithNav:o}=this.props;this.enterClick||((t||n||o)&&(this.waitingForClick=!1),this.runCallbackAndMaybeNavigate(e))},this.handleMouseEnter=e=>{1===e.buttons?(this.dragging=!0,this.setState({pressed:!0})):this.waitingForClick||this.setState({hovered:!0})},this.handleMouseLeave=()=>{this.waitingForClick||(this.dragging=!1,this.setState({hovered:!1,pressed:!1,focused:!1}))},this.handleMouseDown=()=>{this.setState({pressed:!0})},this.handleMouseUp=e=>{this.dragging&&(this.dragging=!1,this.handleClick(e)),this.setState({pressed:!1,focused:!1})},this.handleDragStart=e=>{this.dragging=!0,e.preventDefault()},this.handleTouchStart=()=>{this.setState({pressed:!0})},this.handleTouchEnd=()=>{this.setState({pressed:!1}),this.waitingForClick=!0},this.handleTouchCancel=()=>{this.setState({pressed:!1}),this.waitingForClick=!0},this.handleKeyDown=e=>{const{onKeyDown:t,role:n}=this.props;t&&t(e);const o=e.which||e.keyCode,{triggerOnEnter:s,triggerOnSpace:i}=sp(n);s&&o===rp||i&&o===ap?(e.preventDefault(),this.setState({pressed:!0})):s||o!==rp||(this.enterClick=!0)},this.handleKeyUp=e=>{const{onKeyUp:t,role:n}=this.props;t&&t(e);const o=e.which||e.keyCode,{triggerOnEnter:s,triggerOnSpace:i}=sp(n);s&&o===rp||i&&o===ap?(this.setState({pressed:!1,focused:!0}),this.runCallbackAndMaybeNavigate(e)):s||o!==rp||(this.enterClick=!1)},this.handleFocus=e=>{this.setState({focused:!0})},this.handleBlur=e=>{this.setState({focused:!1,pressed:!1})},this.state=lp,this.waitingForClick=!1,this.enterClick=!1,this.dragging=!1}navigateOrReset(e){if(e){const{history:e,href:t,skipClientNav:n,target:o}=this.props;t&&("_blank"===o?(window.open(t,"_blank"),this.setState({waiting:!1})):e&&!n?(e.push(t),this.setState({waiting:!1})):window.location.assign(t))}else this.setState({waiting:!1})}handleSafeWithNav(e,t){const{skipClientNav:n,history:o}=this.props;return o&&!n||"_blank"===this.props.target?(e(),this.navigateOrReset(t),Promise.resolve()):(this.state.waiting||this.setState({waiting:!0}),e().then((()=>{this.state.waiting||this.setState({waiting:!0})})).catch((e=>{})).finally((()=>{this.navigateOrReset(t)})))}runCallbackAndMaybeNavigate(e){const{onClick:t,beforeNav:n,safeWithNav:o,href:s,type:i}=this.props;let r=!0,a=!0;if(t&&t(e),e.defaultPrevented&&(r=!1,a=!1),e.preventDefault(),!s&&"submit"===i&&a){let t=e.currentTarget;for(;t;){if(t instanceof window.HTMLFormElement){const e=new window.Event("submit",{cancelable:!0});t.dispatchEvent(e);break}t=t.parentElement}}if(n)this.setState({waiting:!0}),n().then((()=>o?this.handleSafeWithNav(o,r):this.navigateOrReset(r))).catch((()=>{}));else{if(o)return this.handleSafeWithNav(o,r);this.navigateOrReset(r)}}render(){const e=this.props.disabled?fa({},ip,{onFocus:this.handleFocus,onBlur:this.handleBlur}):{onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseDown:this.handleMouseDown,onMouseUp:this.handleMouseUp,onDragStart:this.handleDragStart,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onTouchCancel:this.handleTouchCancel,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onFocus:this.handleFocus,onBlur:this.handleBlur,tabIndex:0};e.rel=this.props.rel||("_blank"===this.props.target?"noopener noreferrer":void 0);const{children:t}=this.props;return t&&t(this.state,e)}}cp.defaultProps={disabled:!1};const dp=e=>"string"==typeof e&&(!/^(https?:)?\/\//i.test(e)&&!/^([^#]*#[\w-]*|[\w\-.]+:)/.test(e)),pp=(hp="withRouter("+((up=cp).displayName||up.name)+")",fp=function(e){var t=e.wrappedComponentRef,n=ma(e,["wrappedComponentRef"]);return T.default.createElement(kd.Consumer,null,(function(e){return e||("production"!==process.env.NODE_ENV?wc(!1,"You should not use <"+hp+" /> outside a <Router>"):wc(!1)),T.default.createElement(up,fa({},n,e,{ref:t}))}))},fp.displayName=hp,fp.WrappedComponent=up,"production"!==process.env.NODE_ENV&&(fp.propTypes={wrappedComponentRef:I.default.oneOfType([I.default.string,I.default.func,I.default.object])}),xd(fp,up));var up,hp,fp;function mp(e,t,n){return n&&!0!==t&&e&&dp(e)?pp:cp}const gp=["href","onClick","skipClientNav","beforeNav","safeWithNav","style","target","testId","onKeyDown","onKeyUp","hideDefaultFocusRing","light","disabled"],vp=m.addStyle("a"),yp=m.addStyle("button"),bp=m.addStyle(Zd);class xp extends _.Component{constructor(...e){super(...e),this.getCorrectTag=(e,t,n)=>{const o=this.props.href&&!this.props.disabled,s=t&&!this.props.skipClientNav&&dp(this.props.href||"");return o&&s&&this.props.href?_.createElement(bp,fa({},n,{to:this.props.href,role:this.props.role,target:this.props.target||void 0,"aria-disabled":this.props.disabled?"true":void 0}),this.props.children(e)):o&&!s?_.createElement(vp,fa({},n,{href:this.props.href,role:this.props.role,target:this.props.target||void 0,"aria-disabled":this.props.disabled?"true":void 0}),this.props.children(e)):_.createElement(yp,fa({},n,{type:"button","aria-disabled":this.props.disabled}),this.props.children(e))}}renderClickableBehavior(e){const t=this.props,{href:n,onClick:o,skipClientNav:s,beforeNav:i,safeWithNav:r,style:a,target:l,testId:c,onKeyDown:d,onKeyUp:p,hideDefaultFocusRing:u,light:h,disabled:f}=t,m=ma(t,gp),g=mp(n,s,e),v=e=>[wp.reset,wp.link,!u&&e.focused&&(h?wp.focusedLight:wp.focused),a];return i?_.createElement(g,{href:n,onClick:o,beforeNav:i,safeWithNav:r,onKeyDown:d,onKeyUp:p,disabled:f},((t,n)=>this.getCorrectTag(t,e,fa({},m,{"data-test-id":c,style:v(t)},n)))):_.createElement(g,{href:n,onClick:o,safeWithNav:r,onKeyDown:d,onKeyUp:p,target:l,disabled:f},((t,n)=>this.getCorrectTag(t,e,fa({},m,{"data-test-id":c,style:v(t)},n))))}render(){return _.createElement(kd.Consumer,null,(e=>this.renderClickableBehavior(e)))}}xp.defaultProps={light:!1,disabled:!1,"aria-label":""};const wp=d.StyleSheet.create({reset:{border:"none",margin:0,padding:0,width:"auto",overflow:"visible",background:"transparent",textDecoration:"none",color:"inherit",font:"inherit",boxSizing:"border-box",touchAction:"manipulation",userSelect:"none",outline:"none",lineHeight:"normal",WebkitFontSmoothing:"inherit",MozOsxFontSmoothing:"inherit"},link:{cursor:"pointer"},focused:{outline:`solid 2px ${L.default.blue}`},focusedLight:{outline:`solid 2px ${L.default.white}`}}),Cp={xsmall:16,small:24,medium:48,large:96},kp={xsmall:"M7.237.741C7.165.393 6.95.154 6.656.053A1.01 1.01 0 0 0 6.18.01c-.053.009-.053.009-.087.017C2.553.949 0 4.214 0 7.91 0 12.36 3.598 16 8 16c4.4 0 8-3.647 8-8.112a1.02 1.02 0 0 0-.118-.423.877.877 0 0 0-.808-.48.909.909 0 0 0-.81.46c-.09.151-.13.296-.146.455-.08 3.493-2.737 6.207-6.118 6.207-3.41 0-6.118-2.74-6.118-6.196 0-2.843 1.936-5.291 4.644-6.022.1-.028.224-.082.352-.177a.928.928 0 0 0 .36-.97z",small:"M10.598.943c-.093-.449-.362-.748-.732-.875a1.314 1.314 0 0 0-.723-.033C3.83 1.417 0 6.317 0 11.864 0 18.538 5.398 24 12 24c6.598 0 12-5.471 12-12.16a1.333 1.333 0 0 0-.154-.548c-.193-.368-.544-.606-1.023-.606-.472 0-.825.229-1.035.585-.117.2-.169.39-.189.582-.124 5.472-4.294 9.73-9.599 9.73-5.349 0-9.599-4.3-9.599-9.72 0-4.46 3.036-8.299 7.28-9.444.127-.036.291-.107.458-.232.373-.28.57-.711.46-1.244z",medium:"M44.19 23.455a1.91 1.91 0 1 1 3.801 0h.003c.004.18.006.363.006.545 0 13.255-10.745 24-24 24S0 37.255 0 24 10.745 0 24 0c.182 0 .364.002.545.006V.01a1.91 1.91 0 1 1 0 3.801v.015A20.564 20.564 0 0 0 24 3.818C12.854 3.818 3.818 12.854 3.818 24c0 11.146 9.036 20.182 20.182 20.182 11.146 0 20.182-9.036 20.182-20.182 0-.182-.003-.364-.007-.545h.015z",large:"M88.38 46.91a3.818 3.818 0 1 1 7.602 0h.006c.008.362.012.725.012 1.09 0 26.51-21.49 48-48 48S0 74.51 0 48 21.49 0 48 0c.365 0 .728.004 1.09.012v.005a3.818 3.818 0 1 1 0 7.602v.032c-.362-.01-.725-.015-1.09-.015C25.708 7.636 7.636 25.708 7.636 48c0 22.292 18.072 40.364 40.364 40.364 22.292 0 40.364-18.072 40.364-40.364 0-.365-.005-.728-.015-1.09h.032z"},Sp={light:L.default.white,dark:L.default.offBlack16},Ep=m.addStyle("path");class _p extends _.Component{render(){const{size:e,light:t,style:n}=this.props,o=Cp[e],s=kp[e],i=t?Sp.light:Sp.dark,r=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:`0 0 ${o} ${o}`},_.createElement(Ep,{style:[Tp.loadingSpinner,{fill:i}],fillRule:"nonzero",d:s}));return _.createElement(m.View,{style:[Tp.spinnerContainer,n]},r)}}_p.defaultProps={size:"large",light:!1};const Tp=d.StyleSheet.create({spinnerContainer:{justifyContent:"center"},loadingSpinner:{transformOrigin:"50% 50%",animationName:{"0%":{transform:"rotate(0deg)"},"50%":{transform:"rotate(180deg)"},"100%":{transform:"rotate(360deg)"}},animationDuration:"1.1s",animationIterationCount:"infinite",animationTimingFunction:"linear"}}),Mp=e=>({small:16,medium:24,large:48,xlarge:96}[e]),Ip=["color","icon","size","style"],Pp=m.addStyle("svg");class Np extends _.PureComponent{render(){const e=this.props,{color:t,icon:n,size:o,style:s}=e,i=ma(e,Ip),{assetSize:r,path:a}=((e,t)=>{if(e[t])return{assetSize:t,path:e[t]};{const n=Mp(t),o=Object.keys(e),s=e=>{const t=Mp(e)-n;return t>0?Number.POSITIVE_INFINITY:Math.abs(t)},i=o.sort(((e,t)=>s(e)-s(t)))[0];if(i&&e[i])return{assetSize:i,path:e[i]};throw new Error("Icon does not contain any valid asset sizes!")}})(n,o),l=Mp(o),c=Mp(r);return _.createElement(Pp,fa({},i,{style:[Ap.svg,s],width:l,height:l,viewBox:`0 0 ${c} ${c}`}),_.createElement("path",{fill:t,d:a}))}}Np.defaultProps={color:"currentColor",size:"small"};const Ap=d.StyleSheet.create({svg:{display:"inline-block",verticalAlign:"text-bottom",flexShrink:0,flexGrow:0}}),Rp=["children","skipClientNav","color","disabled","focused","hovered","href","kind","light","pressed","size","style","testId","type","spinner","icon","id","waiting"],Fp=m.addStyle("a"),Op=m.addStyle("button"),Dp=m.addStyle(Zd);class Lp extends _.Component{renderInner(e){const t=this.props,{children:n,skipClientNav:o,color:s,disabled:i,focused:r,hovered:a,href:l,kind:c,light:d,pressed:p,size:u,style:h,testId:m,type:g,spinner:v,icon:y,id:b}=t,x=ma(t,Rp),w="destructive"===s?f.SemanticColor.controlDestructive:f.SemanticColor.controlDefault,C=qp(w,c,d,y?8+("small"===u?16:24):0,u),k=v||i,S=fa({"data-test-id":m,id:b,role:"button",style:[[Bp.shared,k&&Bp.disabled,y&&Bp.withIcon,C.default,k&&C.disabled,"tertiary"!==c&&!k&&(p?C.active:(a||r)&&C.focus),"small"===u&&Bp.small,"xlarge"===u&&Bp.xlarge],h]},x),E="small"===u?Ga:qa,T=_.createElement(E,{style:[Bp.text,"xlarge"===u&&Bp.xlargeText,y&&Bp.textWithIcon,v&&Bp.hiddenText,"tertiary"===c&&Bp.textWithFocus,"tertiary"===c&&!k&&(p?C.active:(a||r)&&C.focus)]},y&&_.createElement(Np,{size:u,color:"currentColor",icon:y,style:Bp.icon}),n),M=_.createElement(_.Fragment,null,T,v&&_.createElement(_p,{style:Bp.spinner,size:{medium:"small",small:"xsmall",xlarge:"medium"}[u],light:"primary"===c}));return l&&!k?e&&!o&&dp(l)?_.createElement(Dp,fa({},S,{to:l}),M):_.createElement(Fp,fa({},S,{href:l}),M):_.createElement(Op,fa({type:g||"button"},S,{"aria-disabled":k}),M)}render(){return _.createElement(kd.Consumer,null,(e=>this.renderInner(e)))}}const Bp=d.StyleSheet.create({shared:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:40,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16,border:"none",borderRadius:4,cursor:"pointer",outline:"none",textDecoration:"none",boxSizing:"border-box",touchAction:"manipulation",userSelect:"none",":focus":{WebkitTapHighlightColor:"rgba(0,0,0,0)"}},withIcon:{paddingLeft:12},disabled:{cursor:"auto"},small:{height:32},xlarge:{height:60},text:{alignItems:"center",fontWeight:"bold",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",pointerEvents:"none"},xlargeText:{fontSize:18,lineHeight:"20px"},textWithIcon:{display:"flex"},textWithFocus:{position:"relative"},hiddenText:{visibility:"hidden"},spinner:{position:"absolute"},icon:{paddingRight:B.default.xSmall_8}}),zp={},qp=(e,t,n,o,s)=>{const i=e+t+n.toString()+o.toString()+s;if(zp[i])return zp[i];const{white:r,white50:a,white64:l,offBlack32:c,offBlack50:p,darkBlue:u}=L.default,h=f.mix(f.fade(e,.32),r),m=f.mix(c,e),g="xlarge"===s?B.default.xLarge_32:B.default.medium_16;let v={};if("primary"===t)v={default:{background:n?r:e,color:n?e:r,paddingLeft:g,paddingRight:g},focus:{boxShadow:`0 0 0 1px ${n?u:r}, 0 0 0 3px ${n?r:e}`},active:{boxShadow:`0 0 0 1px ${n?u:r}, 0 0 0 3px ${n?h:m}`,background:n?h:m,color:n?m:h},disabled:{background:n?h:c,color:n?e:l,cursor:"default",":focus":{boxShadow:`0 0 0 1px ${n?c:r}, 0 0 0 3px ${n?h:c}`}}};else if("secondary"===t)v={default:{background:"none",color:n?r:e,borderColor:n?a:p,borderStyle:"solid",borderWidth:1,paddingLeft:o?g-4:g,paddingRight:g},focus:{background:n?"transparent":r,borderColor:n?r:e,borderWidth:2,paddingLeft:o?g-5:g-1,paddingRight:g-1},active:{background:n?m:h,color:n?h:m,borderColor:n?h:m,borderWidth:2,paddingLeft:o?g-5:g-1,paddingRight:g-1},disabled:{color:n?a:c,borderColor:n?h:c,cursor:"default",":focus":{borderColor:n?a:c,borderWidth:2,paddingLeft:o?g-5:g-1,paddingRight:g-1}}};else{if("tertiary"!==t)throw new Error("Button kind not recognized");v={default:{background:"none",color:n?r:e,paddingLeft:0,paddingRight:0},focus:{":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${o}px)`,right:0,bottom:0,background:n?r:e,borderRadius:2}},active:{color:n?h:m,":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${o}px)`,right:0,bottom:"calc(50% - 11px)",background:n?h:m,borderRadius:2}},disabled:{color:n?h:c,cursor:"default"}}}return zp[i]=d.StyleSheet.create(v),zp[i]},Hp=["href","type","children","skipClientNav","spinner","disabled","onClick","beforeNav","safeWithNav","tabIndex","target","rel"],Wp=["tabIndex"];class Up extends _.Component{renderClickableBehavior(e){const t=this.props,{href:n,type:o,children:s,skipClientNav:i,spinner:r,disabled:a,onClick:l,beforeNav:c,safeWithNav:d,tabIndex:p,target:u,rel:h}=t,f=ma(t,Hp),m=mp(n,i,e),g=(e,t)=>{let{tabIndex:l}=t,c=ma(t,Wp);return _.createElement(Lp,fa({},f,e,c,{disabled:a,spinner:r||e.waiting,skipClientNav:i,href:n,target:u,type:o,tabIndex:p||l}),s)};return c?_.createElement(m,{disabled:r||a,href:n,role:"button",type:o,onClick:l,beforeNav:c,safeWithNav:d,rel:h},g):_.createElement(m,{disabled:r||a,href:n,role:"button",type:o,onClick:l,safeWithNav:d,target:u,rel:h},g)}render(){return _.createElement(kd.Consumer,null,(e=>this.renderClickableBehavior(e)))}}Up.defaultProps={color:"default",kind:"primary",light:!1,size:"medium",disabled:!1,spinner:!1};class Gp extends _.Component{render(){const{apiOptions:e,answerBarState:t,onCheckAnswer:n,onNextQuestion:o}=this.props,s={...Vp.answerBar,backgroundColor:"CORRECT"===t?L.default.offWhite:"white",justifyContent:"CORRECT"!==t||o?"space-between":"center"},i="INCORRECT"===t?_.createElement("span",{style:Vp.text},_.createElement("span",{style:Vp.tryAgainIcon},_.createElement(V,No)),_.createElement("span",{style:{marginLeft:8}},k._("Keep trying"))):_.createElement("span",null);if("CORRECT"!==t){const o="INCORRECT"===t?k._("Try again"):k._("Check");return _.createElement("div",{style:s},i,_.createElement(Up,{disabled:e.readOnly||"ACTIVE"!==t,onClick:n},o))}return _.createElement("div",{style:s},_.createElement("span",{style:Vp.text},_.createElement("span",{style:{fontSize:28,color:L.default.green}},_.createElement(V,G({},Po,{style:{marginBottom:5}}))),_.createElement("span",{role:"alert","aria-label":k._("Correct!"),style:{marginLeft:8}},k._("Correct!"))),o&&_.createElement(Up,{onClick:o},k._("Next question")))}}const Vp={answerBar:{display:"flex",alignItems:"center",height:68,marginLeft:-16,marginRight:-16,marginBottom:-16,marginTop:16,paddingLeft:16,paddingRight:10,borderTop:"1px solid ".concat(L.default.offBlack50)},tryAgainIcon:{fontSize:28,color:"#63D9EA",transform:"scale(-1,1) rotate(-268deg)"},text:{display:"flex",flexDirection:"row",alignItems:"center",fontWeight:"bold",fontSize:17}},jp="ungraded",Yp="correct",$p="incorrect",Xp="invalid",Kp=(e,t)=>{switch(e){case"HIDDEN":case"INACTIVE":return t?"ACTIVE":e;case"ACTIVE":return t?e:"INACTIVE";case"INCORRECT":return t?"ACTIVE":"INACTIVE";default:return e}},Zp=k._("We couldn't grade your answer."),Jp=k._("It looks like you left something blank or ")+k._("entered in an invalid answer.");class Qp extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"state",{status:jp,showHint:!1,message:"",answerBarState:"HIDDEN"}),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"_onInteractWithWidget",(e=>{if(this.setState({status:jp,message:""}),this.refs.renderer){this.change("widgets",this.props.widgets);const e=0===this.refs.renderer.emptyWidgets().length,t=this.state.answerBarState;this.setState({answerBarState:Kp(t,e)})}})),U(this,"_checkAnswer",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices();const e=this.refs.renderer.score(),t="points"===e.type?e.total===e.earned?Yp:$p:Xp,n="points"===e.type?e.message||"":e.message?"".concat(Zp," ").concat(e.message):"".concat(Zp," ").concat(Jp);this.setState({status:t,message:n,answerBarState:"correct"===t?"CORRECT":"INCORRECT"}),this.props.trackInteraction({status:t})})),U(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),U(this,"setInputValue",((e,t,n)=>this.refs.renderer.setInputValue(e,t,n))),U(this,"focus",(()=>this.refs.renderer.focus())),U(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),U(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){const e=M.default.extend({},ee.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}});let t=null,n=null;this.state.status===Yp?(n=_.createElement(V,G({},To,{style:{color:"#526f03"}})),t=k._("Correct")):this.state.status===$p&&(n=_.createElement(V,G({},Io,{style:{color:"#ff5454"}})),t=k._("Incorrect"));const o=this.props.inGradedGroupSet?d.css(eu.gradedGroupInSet):d.css(eu.gradedGroup),s=S.default({[o]:e.isMobile,"perseus-graded-group":!0,"answer-correct":!e.isMobile&&this.state.status===Yp,"answer-incorrect":!e.isMobile&&this.state.status===$p}),{answerBarState:i}=this.state,r="CORRECT"===i,a=e.readOnly||e.isMobile&&r;return _.createElement("div",{className:s},!!this.props.title&&_.createElement("div",{className:d.css(eu.title)},this.props.title),_.createElement(qi,G({},this.props,{ref:"renderer",apiOptions:{...e,readOnly:a},onInteractWithWidget:this._onInteractWithWidget,linterContext:this.props.linterContext})),!e.isMobile&&n&&_.createElement("div",{className:"group-icon"},n),!e.isMobile&&t&&_.createElement("div",{className:d.css(fl.srOnly),role:"alert","aria-label":t},t),!e.isMobile&&_.createElement("p",null,this.state.message),!e.isMobile&&_.createElement(Up,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this._checkAnswer},k._("Check")),!e.isMobile&&r&&this.props.onNextQuestion&&_.createElement(Up,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this.props.onNextQuestion,style:{marginLeft:5}},k._("Next question")),this.props.hint&&this.props.hint.content&&(this.state.showHint?_.createElement("div",null,_.createElement("button",{tabIndex:"0",className:d.css(eu.explanationTitle),onClick:()=>this.setState({showHint:!1}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!1})}},k._("Hide explanation")),_.createElement(qi,G({},this.props.hint,{ref:"hints-renderer",apiOptions:e,linterContext:this.props.linterContext}))):_.createElement("button",{tabIndex:"0",onClick:()=>this.setState({showHint:!0}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!0})},className:d.css(eu.showHintLink)},k._("Explain"))),e.isMobile&&"HIDDEN"!==i&&_.createElement(Gp,{apiOptions:e,answerBarState:i,onCheckAnswer:this._checkAnswer,onNextQuestion:this.props.onNextQuestion}))}}U(Qp,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null,hasHint:!1,linterContext:nn});const eu=d.StyleSheet.create({gradedGroupInSet:{marginLeft:0,paddingLeft:0},gradedGroup:{borderTop:"1px solid ".concat(pe),borderBottom:"1px solid ".concat(pe),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"},showHintLink:{backgroundColor:"unset",fontSize:14,padding:0,border:"none",marginTop:20,color:"#71B307",cursor:"pointer",display:"block",clear:"both"},explanationTitle:{backgroundColor:"unset",marginTop:20,color:"#71B307",marginBottom:10,cursor:"pointer",fontSize:14,padding:0,border:"none",display:"block",clear:"both"},title:{fontSize:12,color:pe,textTransform:"uppercase",marginBottom:11,letterSpacing:.8}});var tu={name:"graded-group",displayName:"Graded group (articles only)",widget:Qp,traverseChildWidgets:function(e,t){return M.default.extend({},e,t(e))},hidden:!1,tracking:"all",isLintable:!0};const nu=tu.widget;class ou extends _.Component{render(){const e=[];for(let t=0;t<this.props.numGroups;t++)e.push(_.createElement("div",{role:"button","aria-label":k._("Skip to %(title)s",{title:this.props.groupTitles[t]}),key:t,className:d.css(ru.indicator,t===this.props.currentGroup&&ru.selectedIndicator),onClick:()=>this.props.onChangeCurrentGroup(t)}));return _.createElement("div",{className:d.css(ru.indicatorContainer)},e)}}class su extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"_childGroup",void 0),U(this,"state",{currentGroup:0}),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"getInputPaths",(()=>this._childGroup.getInputPaths())),U(this,"setInputValue",((e,t,n)=>this._childGroup.setInputValue(e,t,n))),U(this,"focus",(()=>this._childGroup.focus())),U(this,"focusInputPath",(e=>{this._childGroup.focusInputPath(e)})),U(this,"blurInputPath",(e=>{this._childGroup.blurInputPath(e)})),U(this,"handleNextQuestion",(()=>{const{currentGroup:e}=this.state;e<this.props.gradedGroups.length-1&&this.setState({currentGroup:e+1})}))}shouldComponentUpdate(e,t){return e.gradedGroups,e!==this.props||t!==this.state}render(){const{JIPT:e}=Y();if(e.useJIPT&&this.props.gradedGroups.length>1)return _.createElement("div",{className:d.css(ru.container)},this.props.gradedGroups.map(((e,t)=>_.createElement(nu,G({key:t},this.props,e,{inGradedGroupSet:!1,linterContext:this.props.linterContext})))));const t=this.props.gradedGroups[this.state.currentGroup];if(!t)return _.createElement("span",null,k.doNotTranslate("No current group..."));const n=this.props.gradedGroups.length,o=this.state.currentGroup<n-1?this.handleNextQuestion:null;return _.createElement("div",{className:d.css(ru.container)},_.createElement("div",{className:d.css(ru.top)},_.createElement("div",{className:d.css(ru.title)},t.title),_.createElement("div",{className:d.css(ru.spacer)}),_.createElement(ou,{numGroups:n,currentGroup:this.state.currentGroup,groupTitles:this.props.gradedGroups.map((e=>e.title)),onChangeCurrentGroup:e=>this.setState({currentGroup:e})})),_.createElement(nu,G({key:this.state.currentGroup,ref:e=>this._childGroup=e},this.props,t,{inGradedGroupSet:!0,title:null,onNextQuestion:o,linterContext:this.props.linterContext})))}}U(su,"defaultProps",{gradedGroups:[],linterContext:nn});var iu={name:"graded-group-set",displayName:"Graded group set (articles only)",widget:su,traverseChildWidgets:function(e,t){return{groups:e.gradedGroups.map(t)}},hidden:!1,tracking:"all",isLintable:!0};const ru=d.StyleSheet.create({top:{display:"flex",flexDirection:"row"},spacer:{flex:1},title:{fontSize:12,color:pe,textTransform:"uppercase",marginBottom:11,letterSpacing:.8},indicatorContainer:{display:"flex",flexDirection:"row"},indicator:{width:10,height:10,borderRadius:5,backgroundColor:"#AAAAAA",marginLeft:5,cursor:"pointer"},selectedIndicator:{backgroundColor:"#71B307"},container:{borderTop:"1px solid ".concat(pe),borderBottom:"1px solid ".concat(pe),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"}});class au extends _.Component{constructor(){super(...arguments),U(this,"container",void 0)}componentWillUnmount(){this.container=null}focus(){if(this.container)return this.container.focus(),!0}toggleSelect(e){const t=this.props.value;this.props.allowEmpty?this.props.onChange(t!==e?e:null):this.props.onChange(e)}render(){const e=this.props.value,t=this.props.buttons.map(((t,n)=>_.createElement("button",{title:t.title,type:"button",id:""+n,ref:"button"+n,key:""+n,className:d.css(lu.buttonStyle,t.value===e&&lu.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)));return _.createElement("div",{style:{display:"inline-block"},ref:e=>this.container=e},t)}}U(au,"defaultProps",{value:null,allowEmpty:!0});const lu=d.StyleSheet.create({buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:2}},selectedStyle:{backgroundColor:"#ddd"}}),cu={url:null};function du(e){let t=e[0],n=e[1],o=e[2];const s=e[3];t<0&&(t*=-1,n*=-1,o*=-1);const i=2*Math.PI;for(n<0&&(n*=-1,o*=-1,o+=i/2);o>0;)o-=i;for(;o<0;)o+=i;return[t,n,o,s]}function pu(e){let t=e[0],n=e[1],o=e[2];const s=e[3];t<0&&(t*=-1,n*=-1,o*=-1);const i=Math.PI;for(n<0&&(n*=-1,o*=-1,o+=i/2);o>0;)o-=i;for(;o<0;)o+=i;return[t,n,o,s]}const uu={areEqual:function(e,t){return Ye.deepEq(e,t)},Movable:Rs.Plot,getPropsForCoeffs:function(e){return{fn:M.default.partial(this.getFunctionForCoeffs,e)}}},hu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/67aaf581e6d9ef9038c10558a1f70ac21c11c9f8.png",defaultCoords:[[.25,.75],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],o=n[0]-t[0],s=n[1]-t[1];if(0===o)return;const i=s/o;return[i,n[1]-i*n[0]]},getFunctionForCoeffs:function(e,t){return e[0]*t+e[1]},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1];return"y = "+n.toFixed(3)+"x + "+o.toFixed(3)}}),fu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/e23d36e6fc29ee37174e92c9daba2a66677128ab.png",defaultCoords:[[.5,.5],[.75,.75]],Movable:Rs.Parabola,getCoefficients:function(e){const t=e[0],n=e[1],o=t[0],s=t[1],i=(n[1]-s)/((n[0]-o)*(n[0]-o));return[i,-2*o*i,i*o*o+s]},getFunctionForCoeffs:function(e,t){return(e[0]*t+e[1])*t+e[2]},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2]}},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2];return"y = "+n.toFixed(3)+"x^2 + "+o.toFixed(3)+"x + "+s.toFixed(3)}}),mu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/3d68e7718498475f53b206c2ab285626baf8857e.png",defaultCoords:[[.5,.5],[.6,.6]],Movable:Rs.Sinusoid,getCoefficients:function(e){const t=e[0],n=e[1],o=n[1]-t[1],s=Math.PI/(2*(n[0]-t[0]));return[o,s,t[0]*s,t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2],i=e[3];return n*Math.sin(o*t-s)+i},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2],d:e[3]}},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2],i=t[3];return"y = "+n.toFixed(3)+" sin("+o.toFixed(3)+"x - "+s.toFixed(3)+") + "+i.toFixed(3)},areEqual:function(e,t){return Ye.deepEq(du(e),du(t))}}),gu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/7db80d23c35214f98659fe1cf0765811c1bbfbba.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],o=n[1]-t[1],s=Math.PI/(4*(n[0]-t[0]));return[o,s,t[0]*s,t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2],i=e[3];return n*Math.tan(o*t-s)+i},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2],i=t[3];return"y = "+n.toFixed(3)+" sin("+o.toFixed(3)+"x - "+s.toFixed(3)+") + "+i.toFixed(3)},areEqual:function(e,t){return Ye.deepEq(pu(e),pu(t))}}),vu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/9cbfad55525e3ce755a31a631b074670a5dad611.png",defaultCoords:[[.5,.55],[.75,.75]],defaultAsymptote:[[0,.5],[1,.5]],extraCoordConstraint:function(e,t,n,o,s){const i=M.default.head(o)[1];return M.default.all(n,(e=>e[1]!==i))},extraAsymptoteConstraint:function(e,t,n,o,s){const i=e[1];if(M.default.all(n,(e=>e[1]>i))||M.default.all(n,(e=>e[1]<i)))return[t[0],i];const r=t[1];if(M.default.all(n,(e=>e[1]>r))){const e=M.default.min(M.default.map(n,(e=>e[1])));return[t[0],e-s.snapStep[1]]}const a=M.default.max(M.default.map(n,(e=>e[1])));return[t[0],a+s.snapStep[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){const n=e[0],o=e[1],s=M.default.head(t)[1],i=Math.log((n[1]-s)/(o[1]-s))/(n[0]-o[0]);return[(n[1]-s)/Math.exp(i*n[0]),i,s]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2];return n*Math.exp(o*t)+s},getEquationString:function(e,t){if(!t)return null;const n=this.getCoefficients(e,t),o=n[0],s=n[1],i=n[2];return"y = "+o.toFixed(3)+"e^("+s.toFixed(3)+"x) + "+i.toFixed(3)}}),yu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/f6491e99d34af34d924bfe0231728ad912068dc3.png",defaultCoords:[[.55,.5],[.75,.75]],defaultAsymptote:[[.5,0],[.5,1]],extraCoordConstraint:function(e,t,n,o,s){const i=M.default.head(o)[0];return M.default.all(n,(e=>e[0]!==i))&&n[0][1]!==n[1][1]},extraAsymptoteConstraint:function(e,t,n,o,s){const i=e[0];if(M.default.all(n,(e=>e[0]>i))||M.default.all(n,(e=>e[0]<i)))return[i,t[1]];const r=t[0];if(M.default.all(n,(e=>e[0]>r))){return[M.default.min(M.default.map(n,(e=>e[0])))-s.snapStep[0],t[1]]}return[M.default.max(M.default.map(n,(e=>e[0])))+s.snapStep[0],t[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){const n=e=>[e[1],e[0]],o=vu.getCoefficients(M.default.map(e,n),M.default.map(t,n)),s=-o[2]/o[0],i=1/o[0];return[1/o[1],i,s]},getFunctionForCoeffs:function(e,t,n){const o=e[0],s=e[1],i=e[2];return o*Math.log(s*t+i)},getEquationString:function(e,t){if(!t)return null;const n=this.getCoefficients(e,t),o=n[0],s=n[1],i=n[2];return"y = ln("+o.toFixed(3)+"x + "+s.toFixed(3)+") + "+i.toFixed(3)}}),bu=M.default.extend({},uu,{url:"https://ka-perseus-graphie.s3.amazonaws.com/8256a630175a0cb1d11de223d6de0266daf98721.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],o=n[0]-t[0],s=n[1]-t[1];if(0===o)return;let i=Math.abs(s/o);n[1]<t[1]&&(i*=-1);return[i,t[0],t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2];return n*Math.abs(t-o)+s},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2];return"y = "+n.toFixed(3)+"| x - "+o.toFixed(3)+"| + "+s.toFixed(3)}}),xu={linear:hu,quadratic:fu,sinusoid:mu,tangent:gu,exponential:vu,logarithm:yu,absolute_value:bu},wu=M.default.keys(xu);function Cu(e){return xu[e]}const ku=(e,t)=>{if(e.type!==t.correct.type)return{type:"points",earned:0,total:1,message:null};if(null==e.coords)return{type:"invalid",message:null};const n=Cu(e.type),o=n.getCoefficients(e.coords,e.asymptote),s=n.getCoefficients(t.correct.coords,t.correct.asymptote);return null==o||null==s?{type:"invalid",message:null}:n.areEqual(o,s)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}},Su=(e,t,n,o)=>e.map((e=>{const s=e.map(((e,o)=>{const s=t[o],i=n[o],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(s,i),a=Math.round(e*r);return s[0]+i*a}));return p.point.roundTo(s,o)})),Eu=(e,t,n,o)=>e?Su(e,t,n,o):e,_u=(e,t)=>{const n=Cu(e),o=Ye.snapStepFromGridStep([1,1]);return{type:e,asymptote:Eu(n.defaultAsymptote,t.range,t.step,o),coords:null}},Tu=M.default.first,Mu=(e,t)=>{const n=e.gridStep||Ye.getGridStep(e.range,e.step,t);return{gridStep:n,snapStep:e.snapStep||Ye.snapStepFromGridStep(n)}},Iu={labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:cu,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0,showTooltips:!1},Pu=_u("linear",Iu),Nu={graph:Iu,plot:Pu,availableTypes:[Pu.type]},Au=e=>{const t=e.charAt(0).toUpperCase()+e.substring(1),n=Y().staticUrl;return{value:e,title:t,content:_.createElement("img",{src:n(Cu(e).url),alt:t})}};var Ru=Object.freeze({__proto__:null,DEFAULT_BACKGROUND_IMAGE:cu,allTypes:wu,functionForType:Cu,validate:ku,getEquationString:e=>{const t=e.plot;if(t.type&&t.coords){return Cu(t.type).getEquationString(t.coords,t.asymptote)||""}return""},pointsFromNormalized:Su,maybePointsFromNormalized:Eu,defaultPlotProps:_u,chooseType:Tu,getGridAndSnapSteps:Mu,DEFAULT_GRAPHER_PROPS:Nu,typeToButton:Au});const Fu=Rs.MovablePoint,Ou=Rs.MovableLine;const Du={padding:"5px 5px"};class Lu extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"_coords",(()=>{const e=this.props,t=e.graph,n=e.model&&Eu(e.model.defaultCoords,t.range,t.step,t.snapStep);return e.coords||n||null})),U(this,"_asymptote",(()=>this.props.asymptote)),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"renderPlot",(()=>{const e=this.props.model,t=this.props.graph.range[0],n={stroke:this.props.isMobile?bn.BLUE_C:bn.DYNAMIC,...this.props.isMobile?{"stroke-width":3}:{}},o=e.getCoefficients(this._coords(),this._asymptote());if(!o)return;const s=e.getPropsForCoeffs(o,t);return _.createElement(e.Movable,G({},s,{key:this.props.model.url,range:t,style:n}))})),U(this,"renderAsymptote",(()=>{const e=this.props.model,t=this.props.graph,n=this._asymptote(),o={strokeDasharray:"- "};return n&&_.createElement(Ou,{onMove:(e,t)=>{const n=p.vector.subtract(e,t),o=M.default.map(this._asymptote(),(e=>p.vector.add(e,n)));this.props.onChange({asymptote:o})},constraints:[gs.MovableLine.constraints.bound(),gs.MovableLine.constraints.snap(),(n,o)=>{const s=p.vector.subtract(n,o),i=M.default.map(this._asymptote(),(e=>p.vector.add(e,s)));return!e.extraAsymptoteConstraint||e.extraAsymptoteConstraint(n,o,this._coords(),i,t)}],normalStyle:o,highlightStyle:o},M.default.map(n,((e,t)=>_.createElement(Fu,{key:"asymptoteCoord-".concat(t),coord:e,static:!0,draw:null,extendLine:!0,showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))))}))}render(){const e=M.default.map(this._coords(),((e,t)=>_.createElement(Fu,{key:t,coord:e,static:this.props.static,constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>{const n=M.default.all(this._coords(),((n,o)=>t===o||!n||!p.number.equal(e[0],n[0])));if(!n)return!1;if(this.props.model&&this.props.model.extraCoordConstraint){const n=this.props.model.extraCoordConstraint,o=M.default.clone(this._coords()),s=M.default.clone(o[t]);return o[t]=e,n(e,s,o,this._asymptote(),this.props.graph)}return n}],onMove:(e,n)=>{let o;const s=this._asymptote();o=s&&this.props.model.allowReflectOverAsymptote&&function(e,t,n){const o=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1]);return o(n[0],n[1],t)>0!=o(n[0],n[1],e)>0}(e,n,s)?M.default.map(this._coords(),(e=>p.point.reflectOverLine(e,s))):M.default.clone(this._coords()),o[t]=e,this.props.onChange({coords:o})},showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))),t=this.props.graph.box,n=this.props.graph.backgroundImage;let o=null;if(n.url){const e=t[0]/fe.defaultBoxSize;o=_.createElement(Ys,{src:n.url,width:n.width,height:n.height,scale:e})}return _.createElement("div",{className:"perseus-widget perseus-widget-grapher",style:{width:t[0],height:t[1],boxSizing:"initial"}},_.createElement("div",{className:"graphie-container above-scratchpad",style:{width:t[0],height:t[1]}},o,_.createElement(Rs,G({},this.props.graph,{setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this.props.model&&this.renderPlot(),this.props.model&&this.renderAsymptote(),this.props.model&&e)))}}U(Lu,"defaultProps",{graph:{range:[[-10,10],[-10,10]],step:[1,1]},coords:null,asymptote:null,isMobile:!1});class Bu extends _.Component{constructor(){super(...arguments),U(this,"horizHairline",void 0),U(this,"vertHairline",void 0),U(this,"handlePlotChanges",(e=>{const t=M.default.extend({},this.props.plot,e);this.props.onChange({plot:t}),this.props.trackInteraction()})),U(this,"handleActiveTypeChange",(e=>{const t=this.props.graph,n=M.default.extend({},this.props.plot,_u(e,t));this.props.onChange({plot:n})})),U(this,"_setupGraphie",((e,t)=>{const n=this.props.apiOptions.isMobile;if("graph"===t.markings?(e.graphInit({range:t.range,scale:M.default.pluck(t.gridConfig,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,snapStep:t.snapStep,tickStep:n?this._calculateMobileTickStep(t.gridStep,t.step,t.range):M.default.pluck(t.gridConfig,"tickStep"),labelStep:1,unityLabels:M.default.pluck(t.gridConfig,"unityLabel"),isMobile:n}),e.label([0,t.range[1][1]],t.labels[1],n?"below right":"above"),e.label([t.range[0][1],0],t.labels[0],n?"above left":"right")):"grid"===t.markings?e.graphInit({range:t.range,scale:M.default.pluck(t.gridConfig,"scale"),gridStep:t.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:n}):"none"===t.markings&&e.init({range:t.range,scale:M.default.pluck(t.gridConfig,"scale")}),this.props.apiOptions.isMobile){const t={normalStyle:{strokeWidth:1}};this.horizHairline=new Fn(e,[0,0],[0,0],t),this.horizHairline.attr({stroke:bn.INTERACTIVE}),this.horizHairline.hide(),this.vertHairline=new Fn(e,[0,0],[0,0],t),this.vertHairline.attr({stroke:bn.INTERACTIVE}),this.vertHairline.hide()}})),U(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.props.graph.range[0][0],e[1]],[this.props.graph.range[0][1],e[1]]),this.horizHairline.show(),this.vertHairline.moveTo([e[0],this.props.graph.range[1][0]],[e[0],this.props.graph.range[1][1]]),this.vertHairline.show())})),U(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&(this.horizHairline.hide(),this.vertHairline.hide())}))}render(){const e=this.props.plot.type,t=this.props.plot.coords,n=this.props.plot.asymptote,o=_.createElement("div",{style:Du,className:"above-scratchpad"},_.createElement(au,{value:e,allowEmpty:!0,buttons:M.default.map(this.props.availableTypes,Au),onChange:this.handleActiveTypeChange})),s=pi(this.props.containerSizeClass),i={...this.props.graph,...Mu(this.props.graph,s[0]),gridConfig:this._getGridConfig({...this.props.graph,box:s,...Mu(this.props.graph,s[0])})},r={graph:{box:s,range:i.range,step:i.step,snapStep:i.snapStep,backgroundImage:i.backgroundImage,options:i,setup:this._setupGraphie},onChange:this.handlePlotChanges,model:e&&Cu(e),coords:t,asymptote:n,static:this.props.static,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile,showTooltips:this.props.graph.showTooltips,showHairlines:this.showHairlines,hideHairlines:this.hideHairlines};return _.createElement("div",null,_.createElement(Lu,r),this.props.availableTypes.length>1&&o)}_getGridConfig(e){return e.step.map(((t,n)=>Ye.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])))}_calculateMobileTickStep(e,t,n){const o=Ye.constrainedTickStepsFromTickSteps(t,n);return o[0]=o[0]/e[0],o[1]=o[1]/e[1],o}simpleValidate(e){return ku(this.getUserInput(),e)}getUserInput(){return Bu.getUserInputFromProps(this.props)}focus(){}static validate(e,t){return ku(e,t)}static getUserInputFromProps(e){return e.plot}}U(Bu,"defaultProps",Nu);const zu=e=>{const t={availableTypes:e.availableTypes,graph:e.graph};if(1===t.availableTypes.length){const e=t.graph,n=Tu(t.availableTypes);t.plot=_u(n,e)}return t};var qu={name:"grapher",displayName:"Grapher",widget:Bu,transform:zu,staticTransform:e=>({...zu(e),availableTypes:[e.correct.type],plot:e.correct})};class Hu extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"getUserInput",(()=>this.refs.renderer.getUserInput())),U(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),U(this,"restoreSerializedState",((e,t)=>(this.refs.renderer.restoreSerializedState(e,t),null))),U(this,"simpleValidate",(e=>this.refs.renderer.score())),U(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),U(this,"setInputValue",((e,t,n)=>this.refs.renderer.setInputValue(e,t,n))),U(this,"focus",(()=>this.refs.renderer.focus())),U(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),U(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)})),U(this,"showRationalesForCurrentlySelectedChoices",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices()}))}componentDidMount(){this.forceUpdate()}render(){const e=M.default.extend({},ee.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=M.default.indexOf(this.props.findWidgets("group"),this),n=this.props.apiOptions.groupAnnotator(t,this.props.widgetId),o=this.refs.renderer&&this.refs.renderer.score(),s=o&&"invalid"!==o.type,i=o&&"invalid"===o.type;return _.createElement("div",{className:S.default({"perseus-group":!0,"perseus-group-valid-answer":s,"perseus-group-invalid-answer":i})},n,_.createElement(qi,G({},this.props,{ref:"renderer",apiOptions:e,findExternalWidgets:this.props.findWidgets,reviewMode:!!this.props.reviewModeRubric,onInteractWithWidget:e=>{this.refs.renderer&&this.change("widgets",this.refs.renderer.props.widgets)},linterContext:this.props.linterContext})),this.props.icon&&_.createElement("div",{className:"group-icon"},this.props.icon))}}U(Hu,"defaultProps",{content:"",widgets:{},images:{},linterContext:nn});var Wu={name:"group",displayName:"Group (SAT only)",widget:Hu,traverseChildWidgets:function(e,t){return M.default.extend({},e,t(e))},hidden:!1,isLintable:!0};const{updateQueryString:Uu}=Ye;class Gu extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"getUserInput",(()=>Lr.getUserInput.call(this))),U(this,"handleMessageEvent",(e=>{let t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(M.default.isUndefined(t.testsPassed))return;const n=t.testsPassed?"correct":"incorrect";this.change({status:n,message:t.message})})),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"simpleValidate",(e=>Gu.validate(this.getUserInput(),e)))}componentDidMount(){P.default(window).on("message",this.handleMessageEvent)}componentWillUnmount(){P.default(window).off("message",this.handleMessageEvent)}render(){const e={width:String(this.props.width),height:String(this.props.height)},{InitialRequestUrl:t}=Y();Object.entries(e).forEach((t=>{let[n,o]=t;o.endsWith("%")||o.endsWith("px")||(e[n]=o+"px")}));let n=this.props.url;if(n&&n.length&&0!==n.indexOf("http")&&(n="https://www.khanacademy.org/computer-programming/program/"+n+"/embedded?buttons=no&embed=yes&editor=no&author=no",n=Uu(n,"width",this.props.width),n=Uu(n,"height",this.props.height),n=Uu(n,"origin",t.origin)),this.props.settings){const e={};M.default.each(this.props.settings,(function(t){t.name&&t.value&&(e[t.name]=t.value)})),n=Uu(n,"settings",JSON.stringify(e))}let o="allow-same-origin allow-scripts";return o+=" allow-top-navigation",_.createElement("iframe",{sandbox:"allow-same-origin allow-scripts allow-top-navigation",style:e,src:n,allowFullScreen:this.props.allowFullScreen})}}U(Gu,"propTypes",{...pr,width:I.default.oneOfType([I.default.string,I.default.number]),height:I.default.oneOfType([I.default.string,I.default.number]),url:I.default.string,settings:I.default.array,status:I.default.oneOf(["incomplete","incorrect","correct"]),message:I.default.string,allowFullScreen:I.default.bool,allowTopNavigation:I.default.bool}),U(Gu,"defaultProps",{status:"incomplete",message:null,allowFullScreen:!1,allowTopNavigation:!1}),M.default.extend(Gu,{validate:function(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}});var Vu={name:"iframe",displayName:"Iframe",widget:Gu,hidden:!0};const ju=[0,10];class Yu extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"getUserInput",(()=>null)),U(this,"simpleValidate",(e=>Yu.validate(this.getUserInput(),e))),U(this,"focus",(()=>{}))}render(){let e,t;const{apiOptions:n}=this.props,o=this.props.backgroundImage;if(o.url&&(e=_.createElement(Ys,{src:o.url,alt:this.props.alt,overrideAriaHidden:!0,width:o.width,height:o.height,preloader:n.imagePreloader,extraGraphie:{box:this.props.box,range:this.props.range,labels:this.props.labels},trackInteraction:this.props.trackInteraction,zoomToFullSizeOnMobile:n.isMobile,constrainHeight:n.isMobile,allowFullBleed:n.isMobile})),this.props.alt&&(t=_.createElement("span",{className:"perseus-sr-only"},_.createElement(qi,{content:this.props.alt,apiOptions:n,linterContext:this.props.linterContext}))),n.isMobile){let o;if(this.props.title||this.props.caption){let e=this.props.title;e&&(this.props.caption&&!/[.?!"']\s*$/.test(e)&&(e+="."),e="**".concat(e,"** "));const t=S.default({"perseus-image-caption":!0,"has-title":!!e}),s=this.props.alignment,i="block"===s||"full-width"===s?null:"0 !important";o=_.createElement("div",{className:t},_.createElement("div",{className:d.css($u.caption),style:{minWidth:i}},_.createElement(qi,{content:e+this.props.caption,apiOptions:n,linterContext:this.props.linterContext})))}return _.createElement("div",{className:"perseus-image-widget"},e,t,o)}let s,i;return this.props.title&&(s=_.createElement("div",{className:"perseus-image-title"},_.createElement(qi,{content:this.props.title,apiOptions:n,linterContext:this.props.linterContext}))),this.props.caption&&(i=_.createElement("div",{className:"perseus-image-caption"},_.createElement(qi,{content:this.props.caption,apiOptions:n,linterContext:this.props.linterContext}))),_.createElement("div",{className:"perseus-image-widget"},s,e,t,i)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}U(Yu,"defaultProps",{alignment:"block",title:"",range:[ju,ju],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:"",linterContext:nn});const $u=d.StyleSheet.create({caption:{display:"inline-block",marginTop:16,maxWidth:640,[$r.lgOrSmaller]:{maxWidth:540},[$r.smOrSmaller]:{maxWidth:450}}});var Xu={name:"image",accessible:e=>{const t=e.backgroundImage;return!(t&&t.url&&!e.alt)},defaultAlignment:"block",supportedAlignments:["block","full-width"],displayName:"Image",widget:Yu,isLintable:!0};const Ku=Rs.Label,Zu=Rs.Line,Ju=Rs.MovablePoint,Qu=Rs.MovableLine,eh=Rs.Plot,th=Rs.PlotParametric,nh=Rs.Point,oh=Rs.Rect,{unescapeMathMode:sh}=Ye,ih=(e,t)=>{let n=e+"||"+(t=t||{}).decimal_separator+"||";const o=t.functions,s=o?o.length:0;for(let e=0;e<s;e++)n+=o[e]+"|";return n},rh=Object.create(null),ah=(e,t)=>{const n=ih(e,t);let o=rh[n];return o||(o=E.default.parse(e,t),rh[n]=o,o)},lh=Object.create(null),ch=(e,t)=>{const n=ih(e,t);let o=lh[n];if(o)return o;const s=E.default.parse(e,t).expr;return o=s?s.compile():function(){return 0},lh[n]=o,o};class dh extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"state",{variables:ph(this.props.elements),functions:uh(this.props.elements)}),U(this,"_setupGraphie",((e,t)=>{e.graphInit(M.default.extend({},t,{grid:M.default.contains(["graph","grid"],this.props.graph.markings),axes:M.default.contains(["graph"],this.props.graph.markings),ticks:M.default.contains(["graph"],this.props.graph.markings),labels:M.default.contains(["graph"],this.props.graph.markings),labelFormat:function(e){return"\\small{"+e+"}"},axisArrows:"<->",unityLabels:!1}))})),U(this,"_updatePointLocation",((e,t)=>{const n=M.default.clone(this.state.variables);n["x_"+e]=t[0],n["y_"+e]=t[1],this.setState({variables:n}),this.props.trackInteraction()})),U(this,"_updateLineLocation",((e,t)=>{const n=this._eval("("+e.endX+")-("+e.startX+")"),o=this._eval("("+e.endY+")-("+e.startY+")"),s=p.vector.add(t,[n,o]),i=M.default.clone(this.state.variables);i["x_"+e.startSubscript]=t[0],i["y_"+e.startSubscript]=t[1],i["x_"+e.endSubscript]=s[0],i["y_"+e.endSubscript]=s[1],this.setState({variables:i}),this.props.trackInteraction()})),U(this,"_eval",((e,t)=>{const n=ch(e,{functions:this.state.functions}),o=M.default.extend({},this.state.variables,t);return M.default.each(M.default.keys(o),(e=>{if(M.default.isString(o[e])){const t=ch(o[e],{functions:this.state.functions});o[e]=function(e){return t(M.default.extend({},o,{x:e}))}}})),n(o)||0})),U(this,"_extractVars",(e=>{if(null==e)return[];let t=[];return M.default.each(e.args(),(function(e){e&&"Expr"===e.constructor.name&&(t=t.concat(this._extractVars(e)))}),this),"Var"===e.name()&&t.push(e.prettyPrint()),t})),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"getUserInput",(()=>({}))),U(this,"simpleValidate",(e=>dh.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){M.default.isEqual(this.props.elements,e.elements)||this.setState({variables:ph(e.elements),functions:uh(e.elements)})}render(){const e=this.props.graph.range;let t=this.props.graph.labels;return"graph"===this.props.graph.markings&&(t=this.props.graph.labels.map((e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e))),_.createElement(Rs,{box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},"graph"===this.props.graph.markings&&_.createElement(Ku,{coord:[0,e[1][1]],text:t[1],direction:"above"}),"graph"===this.props.graph.markings&&_.createElement(Ku,{coord:[e[0][1],0],text:t[0],direction:"right"}),M.default.map(this.props.elements,(function(e,t){if("point"===e.type)return _.createElement(nh,{key:e.key,coord:[this._eval(e.options.coordX),this._eval(e.options.coordY)],color:e.options.color});if("line"===e.type){const t=[this._eval(e.options.startX),this._eval(e.options.startY)],n=[this._eval(e.options.endX),this._eval(e.options.endY)];return _.createElement(Zu,{key:e.key,start:t,end:n,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,arrows:e.options.arrows}})}if("movable-point"===e.type){const t=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];return"snap"===e.options.constraint?t.push(Ju.constraints.snap(e.options.snap)):"x"===e.options.constraint?t.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&t.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})])),_.createElement(Ju,{key:e.key,coord:[this.state.variables["x_"+e.options.varSubscript],this.state.variables["y_"+e.options.varSubscript]],constraints:t,foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap,onMove:M.default.partial(this._updatePointLocation,e.options.varSubscript)})}if("movable-line"===e.type){const t=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];"snap"===e.options.constraint?t.push(Ju.constraints.snap(e.options.snap)):"x"===e.options.constraint?t.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&t.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})]));const n=[this.state.variables["x_"+e.options.startSubscript],this.state.variables["y_"+e.options.startSubscript]],o=[this.state.variables["x_"+e.options.endSubscript],this.state.variables["y_"+e.options.endSubscript]];return _.createElement(Qu,{key:e.key,constraints:t,onMove:M.default.bind(this._updateLineLocation,this,e.options),foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap},_.createElement(Ju,{coord:n,static:!0,normalStyle:{stroke:"none",fill:"none"}}),_.createElement(Ju,{coord:o,static:!0,normalStyle:{stroke:"none",fill:"none"}}))}if("function"===e.type){const t=t=>this._eval(e.options.value,{x:t}),n=M.default.without(this._extractVars(ah(e.options.value).expr),"x"),o=M.default.object(n,M.default.map(n,(e=>this.state.variables[e]))),s=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return _.createElement(eh,{key:e.key,fn:t,foo_fn:e.options.value,foo_varvalues:o,range:s,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("parametric"===e.type){const t=t=>[this._eval(e.options.x,{t:t}),this._eval(e.options.y,{t:t})],n=M.default.without(this._extractVars(ah(e.options.x).expr).concat(this._extractVars(ah(e.options.y).expr)),"t"),o=M.default.object(n,M.default.map(n,(e=>this.state.variables[e]))),s=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return _.createElement(th,{key:e.key,fn:t,foo_fnx:e.options.x,foo_fny:e.options.y,foo_varvalues:o,range:s,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("label"===e.type){const n=[this._eval(e.options.coordX),this._eval(e.options.coordY)];return _.createElement(Ku,{key:t+1,coord:n,text:sh(e.options.label),style:{color:e.options.color}})}return"rectangle"===e.type?_.createElement(oh,{key:t+1,x:this._eval(e.options.coordX),y:this._eval(e.options.coordY),width:M.default.max([this._eval(e.options.width),0]),height:M.default.max([this._eval(e.options.height),0]),style:{stroke:"none",fill:e.options.color}}):void 0}),this))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}U(dh,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});const ph=e=>{const t={};return M.default.each(M.default.where(e,{type:"movable-point"}),(e=>{const n=e.options.varSubscript,o=ah(e.options.startX||"0").expr,s=ah(e.options.startY||"0").expr;let i=0,r=0;o&&(i=o.eval({})||0),s&&(r=s.eval({})||0),t["x_"+n]=i,t["y_"+n]=r})),M.default.each(M.default.where(e,{type:"movable-line"}),(e=>{const n=e.options.startSubscript,o=e.options.endSubscript,s=ah(e.options.startX||"0").expr,i=ah(e.options.startY||"0").expr,r=ah(e.options.endX||"0").expr,a=ah(e.options.endY||"0").expr;let l=0,c=0,d=0,p=0;s&&(l=s.eval({})||0),i&&(c=i.eval({})||0),r&&(d=r.eval({})||0),a&&(p=a.eval({})||0),t["x_"+n]=l,t["y_"+n]=c,t["x_"+o]=d,t["y_"+o]=p})),M.default.each(M.default.where(e,{type:"function"}),(e=>{t[e.options.funcName]=e.options.value})),t},uh=e=>M.default.map(M.default.where(e,{type:"function"}),(e=>e.options.funcName));var hh={name:"interaction",displayName:"Interaction",widget:dh,transform:M.default.identity,hidden:!0},fh=/^\s+|\s+$/g,mh=/^[-+]0x[0-9a-f]+$/i,gh=/^0b[01]+$/i,vh=/^0o[0-7]+$/i,yh=parseInt,bh="object"==typeof gn&&gn&&gn.Object===Object&&gn,xh="object"==typeof self&&self&&self.Object===Object&&self,wh=bh||xh||Function("return this")(),Ch=Object.prototype.toString,kh=Math.max,Sh=Math.min,Eh=function(){return wh.Date.now()};function _h(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Th(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==Ch.call(e)}(e))return NaN;if(_h(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=_h(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(fh,"");var n=gh.test(e);return n||vh.test(e)?yh(e.slice(2),n?2:8):mh.test(e)?NaN:+e}var Mh=function(e,t,n){var o,s,i,r,a,l,c=0,d=!1,p=!1,u=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=o,i=s;return o=s=void 0,c=t,r=e.apply(i,n)}function f(e){return c=e,a=setTimeout(g,t),d?h(e):r}function m(e){var n=e-l;return void 0===l||n>=t||n<0||p&&e-c>=i}function g(){var e=Eh();if(m(e))return v(e);a=setTimeout(g,function(e){var n=t-(e-l);return p?Sh(n,i-(e-c)):n}(e))}function v(e){return a=void 0,u&&o?h(e):(o=s=void 0,r)}function y(){var e=Eh(),n=m(e);if(o=arguments,s=this,l=e,n){if(void 0===a)return f(l);if(p)return a=setTimeout(g,t),h(l)}return void 0===a&&(a=setTimeout(g,t)),r}return t=Th(t)||0,_h(n)&&(d=!!n.leading,i=(p="maxWait"in n)?kh(Th(n.maxWait)||0,t):i,u="trailing"in n?!!n.trailing:u),y.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=s=a=void 0},y.flush=function(){return void 0===a?r:v(Eh())},y};const Ih={fontStyle:"italic",fontWeight:"bold",fontSize:"32px",width:"100%",height:"100%",textAlign:"center",backgroundColor:"white",position:"absolute",zIndex:1,transition:"opacity .25s ease-in-out","-moz-transition":"opacity .25s ease-in-out","-webkit-transition":"opacity .25s ease-in-out"},Ph={position:"relative",top:"25%"};class Nh extends _.Component{constructor(){super(...arguments),U(this,"protractor",void 0),U(this,"ruler",void 0),U(this,"_graphie",void 0),U(this,"_hasSetupGraphieThisUpdate",void 0),U(this,"_shouldSetupGraphie",void 0),U(this,"reset",(()=>{this._setupGraphie(!1)})),U(this,"graphie",(()=>this._graphie)),U(this,"pointsFromNormalized",((e,t)=>{const n=this;return M.default.map(e,(function(e){return M.default.map(e,(function(e,o){const s=n.props.range[o];if(t)return s[0]+(s[1]-s[0])*e;const i=n.props.step[o],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(s,i),a=Math.round(e*r);return s[0]+i*a}))}))})),U(this,"_setupGraphie",(e=>{if(this._hasSetupGraphieThisUpdate)return;const t=N.default.findDOMNode(this.refs.graphieDiv);P.default(t).empty();const n=this.props.labels.map((e=>Ye.unescapeMathMode(e))),o=this.props.range,s=this._graphie=En.createGraphie(t),i=this._getGridConfig();s.snap=this.props.snapStep,"graph"===this.props.markings?(s.graphInit({range:o,scale:M.default.pluck(i,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:this.props.gridStep,tickStep:M.default.pluck(i,"tickStep"),labelStep:1,unityLabels:M.default.pluck(i,"unityLabel"),isMobile:this.props.isMobile}),s.label([0,o[1][1]],n[1],this.props.isMobile?"below right":"above"),s.label([o[0][1],0],n[0],this.props.isMobile?"above left":"right")):"grid"===this.props.markings?s.graphInit({range:o,scale:M.default.pluck(i,"scale"),gridStep:this.props.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:this.props.isMobile}):"none"===this.props.markings&&s.init({range:o,scale:M.default.pluck(i,"scale"),isMobile:this.props.isMobile});let r;if(this.props.instructions){r=P.default("<div/>"),M.default.each(Ih,(function(e,t){r.css(t,e)})),r.css("opacity",.5);const e=P.default("<span/>",{text:this.props.instructions});M.default.each(Ph,(function(t,n){e.css(n,t)})),r.append(e),P.default(t).append(r)}else r=void 0;const a=r||this.props.onMouseDown?M.default.bind((function(e){r&&(r.remove(),r=null),this.props.onMouseDown(e)}),this):null,l=r?function(){r&&r.css("opacity",0)}:null,c=r?function(){r&&r.css("opacity",.5)}:null;s.addMouseLayer({onClick:this.props.onClick,onMouseDown:a,onMouseOver:l,onMouseOut:c,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,allowScratchpad:!0,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this._updateProtractor(),this._updateRuler(),this._hasSetupGraphieThisUpdate=!0,!e&&this.props.onGraphieUpdated&&this.props.onGraphieUpdated(s)})),U(this,"_getGridConfig",(()=>{const e=this;return M.default.map(e.props.step,(function(t,n){return Ye.gridDimensionConfig(t,e.props.range[n],e.props.box[n],e.props.gridStep[n])}))})),U(this,"_updateProtractor",(()=>{if(this.protractor&&this.protractor.remove(),this.props.showProtractor){const e=this.pointsFromNormalized([[.5,.05]])[0];this.protractor=this._graphie.protractor(e)}})),U(this,"_updateRuler",(()=>{if(this.ruler&&this.ruler.remove(),this.props.showRuler){const e=this.pointsFromNormalized([[.5,.25]])[0],t=this._graphie.range[0][1]-this._graphie.range[0][0];this.ruler=this._graphie.ruler({center:e,label:this.props.rulerLabel,pixelsPerUnit:this._graphie.scale[0],ticksPerUnit:this.props.rulerTicks,units:Math.round(.8*t)})}})),U(this,"toJSON",(()=>M.default.pick(this.props,"range","step","markings","labels","backgroundImage","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep")))}render(){let e;const t=this.props.backgroundImage;if(t.url){const n=this.props.box[0]/fe.defaultBoxSize;e=_.createElement(Ys,{src:t.url,width:t.width,height:t.height,scale:n,responsive:!1})}else e=null;return _.createElement("div",{className:"graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]},onMouseOut:this.onMouseOut,onMouseOver:this.onMouseOver,onClick:this.onClick},e,_.createElement("div",{className:"graphie",ref:"graphieDiv"}))}componentDidMount(){this._setupGraphie(!0)}componentDidUpdate(){this._hasSetupGraphieThisUpdate=!1,this._shouldSetupGraphie&&(this._setupGraphie(!1),this._shouldSetupGraphie=!1)}UNSAFE_componentWillReceiveProps(e){const t=this;M.default.each(["labels","range","step","markings","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep"],(function(n){M.default.isEqual(t.props[n],e[n])||(t._shouldSetupGraphie=!0)}))}}U(Nh,"propTypes",{box:I.default.array.isRequired,labels:I.default.arrayOf(I.default.string),range:I.default.arrayOf(I.default.arrayOf(I.default.number)),step:I.default.arrayOf(I.default.number),gridStep:I.default.arrayOf(I.default.number),snapStep:I.default.arrayOf(I.default.number),markings:I.default.string,backgroundImage:I.default.shape({url:I.default.string}),showProtractor:I.default.bool,showRuler:I.default.bool,rulerLabel:I.default.string,rulerTicks:I.default.number,onGraphieUpdated:I.default.func,instructions:I.default.string,onClick:I.default.func,setDrawingAreaAvailable:I.default.func,isMobile:I.default.bool}),U(Nh,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[.5,.5],markings:"graph",backgroundImage:{url:null},showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,instructions:null,onGraphieUpdated:null,onClick:null,onMouseDown:null,isMobile:!1});const{number:Ah,point:Rh}=F.default,{DeprecationMixin:Fh}=Ye,Oh=Ye.eq,Dh=Ye.deepEq;function Lh(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])}function Bh(e,t,n){return Oh(Lh(e,t,n),0)}function zh(e){return Oh(e,0)?0:e>0?1:-1}function qh(e,t,n){return n[0]<=Math.max(e[0],t[0])&&n[0]>=Math.min(e[0],t[0])&&n[1]<=Math.max(e[1],t[1])&&n[1]>=Math.min(e[1],t[1])}function Hh(e,t){const n=[[e[0],e[1],t[0]],[e[0],e[1],t[1]],[t[0],t[1],e[0]],[t[0],t[1],e[1]]],o=M.default.map(n,(function(e){return zh(Lh(...e))}));if(o[0]!==o[1]&&o[2]!==o[3])return!0;for(let e=0;e<4;e++)if(0===o[e]&&qh(...n[e]))return!0;return!1}function Wh(e,t){return M.default.map(M.default.zip(e,t),(function(e){return e[0]-e[1]}))}function Uh(e){return Math.sqrt(M.default.reduce(e,(function(e,t){return e+Math.pow(t,2)}),0))}function Gh(e){return M.default.zip(e,Xh(e)).map((function(e){return Uh(Wh(...e))}))}function Vh(e){const t=M.default.zip(Xh(e,-1),e,Xh(e,1)),n=M.default.map(t,(function(e){const t=Wh(e[1],e[0]),n=Wh(e[2],e[1]),o=Math.acos((s=t,i=n,M.default.reduce(M.default.zip(s,i),(function(e,t){return e+t[0]*t[1]}),0)/(Uh(t)*Uh(n))));var s,i;return zh(Lh(...e))>0?o:-o})),o=M.default.reduce(n,(function(e,t){return e+t}),0);return M.default.map(n,(function(e){return o>0?Math.PI-e:Math.PI+e}))}function jh(e,t,n){if(e.length!==t.length)return!1;const o=e.length,s=Vh(e),i=Vh(t),r=Gh(e),a=Gh(t);for(let e=0;e<2*o;e++){let t=i.slice(),l=a.slice();if(e>=o&&(t.reverse(),l.reverse(),l=Xh(l,1)),t=Xh(t,e),l=Xh(l,e),Dh(s,t)){const e=M.default.zip(r,l),t=M.default.map(e,(function(e){return e[0]/e[1]})),o=M.default.all(t,(function(e){return Oh(t[0],e)})),s=M.default.all(e,(function(e){return Ah.equal(e[0],e[1],n)}));if(o&&s)return!0}}return!1}function Yh(e,t){return e<t||Oh(e,t)}function $h(e){let[t,n,o,s]=e;t<0&&(t*=-1,n*=-1,o*=-1);const i=2*Math.PI;for(n<0&&(n*=-1,o*=-1,o+=i/2);o>0;)o-=i;for(;o<0;)o+=i;return[t,n,o,s]}function Xh(e,t){return t=void 0===t?1:t%e.length,e.slice(t).concat(e.slice(0,t))}function Kh(e){return e.replace(/(?:^|-)(.)/g,(function(e,t){return t.toUpperCase()}))}function Zh(e,t){if(Oh(e[0],t[0]))return"x = "+e[0].toFixed(3);const n=(t[1]-e[1])/(t[0]-e[0]),o=e[1]-n*e[0];return"y = "+n.toFixed(3)+"x + "+o.toFixed(3)}const Jh={showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},Qh=e=>ef(e)&&(null==e.graph.coords||0===e.graph.coords.length),ef=e=>"point"===e.graph.type&&"unlimited"===e.graph.numPoints||"polygon"===e.graph.type&&"unlimited"===e.graph.numSides,tf=(e,t)=>new we("".concat(e," called but current graph type is not a '").concat(t,"'"),be.NotAllowed,{metadata:{graphType:t}});class nf extends _.Component{constructor(){super(...arguments),U(this,"angle",void 0),U(this,"circle",void 0),U(this,"graphie",void 0),U(this,"horizHairline",void 0),U(this,"line",void 0),U(this,"lines",void 0),U(this,"parabola",void 0),U(this,"pointA",void 0),U(this,"pointB",void 0),U(this,"pointC",void 0),U(this,"points",void 0),U(this,"polygon",void 0),U(this,"shouldResetGraphie",void 0),U(this,"sinusoid",void 0),U(this,"trashCan",void 0),U(this,"vertHairline",void 0),U(this,"state",{shouldShowInstructions:Qh(this.props)}),U(this,"_getShouldShowInstructions",(e=>(e=e||this.props,this.isClickToAddPoints(e)&&(null==e.graph.coords||0===e.graph.coords.length)))),U(this,"deprecatedProps",Jh),U(this,"setGraphie",(e=>{this.graphie=e,this.setupGraphie()})),U(this,"handleAddPointsMouseDown",(e=>{if(!this.isClickToAddPoints())throw new we("handleAddPointsClick should not be registeredwhen isClickToAddPoints() is false",be.NotAllowed);if(!this.isCoordInTrash(e)){let n;if("point"===this.props.graph.type){if(n=this.createPointForPointsType(e,this.points.length),!n.constrain())return void n.remove();this.points.push(n);const t=this.points.length-1;this.points[t].grab(e),this.updateCoordsFromPoints()}else if("polygon"===this.props.graph.type){var t;if(null!==(t=this.polygon)&&void 0!==t&&t.closed())return;n=this.createPointForPolygonType(e,this.points.length),this.points.push(n);const o=this.points.length-1;this.points[o].grab(e),this.updatePolygon()}this.setState({shouldShowInstructions:!1})}})),U(this,"resetGraphie",(()=>{this.shouldResetGraphie=!1,this.parabola=null,this.sinusoid=null,this.refs.graph.reset()})),U(this,"setupGraphie",(()=>{var e,t;(this.setTrashCanVisibility(0),this.isClickToAddPoints()&&this.setTrashCanVisibility(.5),this.props.apiOptions.isMobile)&&(this.horizHairline=new Fn(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:bn.INTERACTIVE}),null===(e=this.horizHairline)||void 0===e||e.hide(),this.vertHairline=new Fn(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.vertHairline.attr({stroke:bn.INTERACTIVE}),null===(t=this.vertHairline)||void 0===t||t.hide());this["add"+Kh(this.props.graph.type)+"Controls"]()})),U(this,"showHairlines",(e=>{var t,n,o,s;this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(null===(t=this.horizHairline)||void 0===t||t.moveTo([this.props.range[0][0],e[1]],[this.props.range[0][1],e[1]]),null===(n=this.horizHairline)||void 0===n||n.show(),null===(o=this.vertHairline)||void 0===o||o.moveTo([e[0],this.props.range[1][0]],[e[0],this.props.range[1][1]]),null===(s=this.vertHairline)||void 0===s||s.show())})),U(this,"hideHairlines",(()=>{var e,t;this.props.apiOptions.isMobile&&(null===(e=this.horizHairline)||void 0===e||e.hide(),null===(t=this.vertHairline)||void 0===t||t.hide())})),U(this,"setTrashCanVisibility",(e=>{const t=this.graphie;if(Ah.equal(e,0))this.trashCan&&(this.trashCan.remove(),this.trashCan=null);else if(!this.props.apiOptions.isMobile){var n,o;if(!this.trashCan)this.trashCan=null==t||null===(o=t.raphael)||void 0===o?void 0:o.image("https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png",t.xpixels-40,t.ypixels-40,40,40);null===(n=this.trashCan)||void 0===n||n.attr({opacity:e})}})),U(this,"isClickToAddPoints",(e=>(e=e||this.props,ef(e)))),U(this,"_lineStroke",(()=>this.props.isMobile?{"stroke-width":3}:{})),U(this,"addLine",(e=>{const t=this,n=t.graphie,o=nf.getLineCoords(t.props.graph,t.props),s=t.points=M.default.map(o,(e=>gs.addMaybeMobileMovablePoint(this,{coord:e,constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap()],onMove:()=>{const e=M.default.extend({},t.props.graph,{coords:M.default.invoke(s,"coord")});t.onChange({graph:e})}}))),i={points:s,static:!0,normalStyle:{stroke:this.props.apiOptions.isMobile?bn.BLUE_C:bn.INTERACTIVE,...this._lineStroke()}};"line"===e?i.extendLine=!0:"ray"===e&&(i.extendRay=!0),t.line=gs.addMovableLine(n,i),s[0].listen("constraints","isLine",(e=>!Rh.equal(e,s[1].coord()))),s[1].listen("constraints","isLine",(e=>!Rh.equal(e,s[0].coord())))})),U(this,"removeLine",(()=>{var e;M.default.invoke(this.points,"remove"),null===(e=this.line)||void 0===e||e.remove()})),U(this,"addLinearControls",(()=>{this.addLine("line")})),U(this,"removeLinearControls",(()=>{this.removeLine()})),U(this,"addQuadraticControls",(()=>{if("quadratic"!==this.props.graph.type)throw tf("addQuadraticControls","quadratic");let e=this.props.graph.coords;e||(e=nf.defaultQuadraticCoords(this.props));const t=()=>{const e=M.default.extend({},this.props.graph,{coords:[n.coord(),o.coord(),s.coord()]});this.onChange({graph:e}),this.updateQuadratic()};let n=null;n=this.pointA=gs.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>!n||e[0]!==o.coord()[0]&&e[0]!==s.coord()[0]],onMove:t});let o=null;o=this.pointB=gs.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>!o||e[0]!==n.coord()[0]&&e[0]!==s.coord()[0]],onMove:t});let s=null;s=this.pointC=gs.addMaybeMobileMovablePoint(this,{coord:e[2],constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>!s||e[0]!==n.coord()[0]&&e[0]!==o.coord()[0]],onMove:t}),this.updateQuadratic()})),U(this,"updateQuadratic",(()=>{const e=nf.getCurrentQuadraticCoefficients(this.props);if(!e)return;const t=e[0],n=e[1],o=e[2];if(this.parabola){var s,i;const e=null===(s=this.graphie)||void 0===s?void 0:s.svgParabolaPath(t,n,o);null===(i=this.parabola)||void 0===i||i.attr({path:e})}else{var r,a,l;this.parabola=null===(r=this.graphie)||void 0===r?void 0:r.parabola(t,n,o),null===(a=this.parabola)||void 0===a||a.attr({stroke:this.props.apiOptions.isMobile?bn.BLUE_C:bn.DYNAMIC,...this._lineStroke()}),null===(l=this.parabola)||void 0===l||l.toBack()}})),U(this,"removeQuadraticControls",(()=>{var e,t,n;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),null===(n=this.pointC)||void 0===n||n.remove(),this.parabola&&(this.parabola.remove(),this.parabola=null)})),U(this,"addSinusoidControls",(()=>{if("sinusoid"!==this.props.graph.type)throw tf("addSinusoidControls","sinusoid");let e=this.props.graph.coords;e||(e=nf.defaultSinusoidCoords(this.props));const t=()=>{const e=M.default.extend({},this.props.graph,{coords:[n.coord(),o.coord()]});this.onChange({graph:e}),this.updateSinusoid()};let n=null;n=this.pointA=gs.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>!n||e[0]!==o.coord()[0]],onMove:t});const o=this.pointB=gs.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>!n||e[0]!==n.coord()[0]],onMove:t});this.updateSinusoid()})),U(this,"updateSinusoid",(()=>{const e=nf.getCurrentSinusoidCoefficients(this.props);if(!e)return;const t=e[0],n=e[1],o=e[2],s=e[3];if(this.sinusoid){var i,r;const e=null===(i=this.graphie)||void 0===i?void 0:i.svgSinusoidPath(t,n,o,s);null===(r=this.sinusoid)||void 0===r||r.attr({path:e})}else{var a,l,c;this.sinusoid=null===(a=this.graphie)||void 0===a?void 0:a.sinusoid(t,n,o,s),null===(l=this.sinusoid)||void 0===l||l.attr({stroke:this.props.apiOptions.isMobile?bn.BLUE_C:bn.DYNAMIC,...this._lineStroke()}),null===(c=this.sinusoid)||void 0===c||c.toBack()}})),U(this,"removeSinusoidControls",(()=>{var e,t;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),this.sinusoid&&(this.sinusoid.remove(),this.sinusoid=null)})),U(this,"addCircleControls",(()=>{const e=this.graphie,t=M.default.min(e.snap),n=this.circle=null==e?void 0:e.addCircleGraph({center:this.props.graph.center||[0,0],radius:this.props.graph.radius||M.default.min(this.props.step),snapX:e.snap[0],snapY:e.snap[1],minRadius:t,snapRadius:t});P.default(n).on("move",(()=>{const e=M.default.extend({},this.props.graph,{center:n.center,radius:n.radius});this.onChange({graph:e})}))})),U(this,"removeCircleControls",(()=>{var e;null===(e=this.circle)||void 0===e||e.remove()})),U(this,"addLinearSystemControls",(()=>{const e=this.graphie,t=nf.getLinearSystemCoords(this.props.graph,this.props),n=[bn.INTERACTIVE,bn.GREEN],o=this.points=M.default.map(t,((e,t)=>{const o=[];for(let s=0;s<e.length;s+=1){const i=e[s];o.push(gs.addMaybeMobileMovablePoint(this,{coord:i,constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),e=>{const t=o[1-s];if(t)return!Rh.equal(e,t.coord())}],onMove:()=>{const e=M.default.extend({},this.props.graph,{coords:M.default.map(this.points,(e=>M.default.invoke(e,"coord")))});this.onChange({graph:e})},normalStyle:{fill:n[t]},highlightStyle:{fill:n[t]}}))}return o}));this.lines=M.default.map(o,((t,o)=>gs.addMovableLine(e,{points:t,static:!0,extendLine:!0,normalStyle:{stroke:n[o]}})))})),U(this,"removeLinearSystemControls",(()=>{M.default.invoke(this.lines,"remove"),M.default.map(this.points,(e=>M.default.invoke(e,"remove")))})),U(this,"isCoordInTrash",(e=>{if(this.props.apiOptions.isMobile)return!1;const t=this.graphie,n=null==t?void 0:t.scalePoint(e);return n[0]>=t.xpixels-40&&n[1]>=t.ypixels-40})),U(this,"createPointForPointsType",((e,t)=>{const n=this,o=()=>{n.points=M.default.filter(n.points,(function(e){return e!==s})),n.updateCoordsFromPoints(),setTimeout(s.remove.bind(s),0)};let s=null;return s=gs.addMaybeMobileMovablePoint(this,{coord:e,constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),function(e){return M.default.all(n.points,(function(t){return s===t||!Rh.equal(e,t.coord())}))}],onMoveStart:function(){n.isClickToAddPoints()&&n.setTrashCanVisibility(1)},onMove:n.updateCoordsFromPoints,onMoveEnd:function(e){n.isClickToAddPoints()&&(n.isCoordInTrash(e)&&o(),n.setTrashCanVisibility(.5))},...this.props.apiOptions.isMobile&&n.isClickToAddPoints()?{onRemove:o}:{}}),s})),U(this,"removePoint",(e=>{let t=null;return this.points=M.default.filter(this.points,(function(n,o){return n!==e||(t=o,!1)})),t})),U(this,"createPointForPolygonType",((e,t)=>{if("polygon"!==this.props.graph.type)throw tf("createPointForPolygonType","polygon");const n=!M.default.contains(["angles","sides"],this.props.graph.snapTo),o=e=>(t+e+this.points.length)%this.points.length,s=()=>{var e;const t=this.removePoint(r);var n;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&(this.points=Xh(this.points,t),null===(n=this.polygon)||void 0===n||n.update({closed:!1}));this.updatePolygon(),this.clearCoords(),setTimeout(r.remove.bind(r),0)},i=Mh(((e,t)=>{e.state.isInitialMove=t}),1e3),r=gs.addMaybeMobileMovablePoint(this,{coord:e,constraints:[gs.MovablePoint.constraints.bound(),n?gs.MovablePoint.constraints.snap():null,e=>{if(null==this.points||0===this.points.length)return!0;const n=M.default.invoke(this.points,"coord");if(n[t]=e,!this.isClickToAddPoints()){if(Bh(n[o(-2)],n[o(-1)],n[t])||Bh(n[o(-1)],n[t],n[o(1)])||Bh(n[t],n[o(1)],n[o(2)]))return!1;const e=M.default.zip(n,Xh(n));if(this.points.length>3)for(let t=-1;t<=0;t++){const n=e[o(t)],s=M.default.without(e,n,e[o(t-1)],e[o(t+1)]);for(let e=0;e<s.length;e++){if(Hh(n,s[e]))return!1}}}if("angles"===this.props.graph.snapTo&&this.points.length>2){var s,i;const e=M.default.map(Vh(n),(function(e){return 180*e/Math.PI}));M.default.each([-1,1],(function(t){e[o(t)]=Math.round(e[o(t)])}));const r=function(e,t,s){return(En.findAngle(n[o(e)],n[o(s)],n[o(t)])+360)%360},a=[e[o(-1)]-r(-2,-1,1),e[o(1)]-r(-1,1,2)];if(a[2]=180-(a[0]+a[1]),M.default.any(a,(function(e){return Yh(e,1)})))return!1;const l=Uh(Wh(n[o(-1)],n[o(1)])),c=1===zh(Lh(n[o(-1)],n[o(1)],n[t])),d=Math.sin(a[1]*Math.PI/180)/Math.sin(a[2]*Math.PI/180)*l,p=En.findAngle(n[o(1)],n[o(-1)]),u=null===(s=this.graphie)||void 0===s?void 0:s.polar(d,p+(c?1:-1)*a[0]);return null===(i=this.graphie)||void 0===i?void 0:i.addPoints(n[o(-1)],u)}if("sides"===this.props.graph.snapTo&&this.points.length>1){var r,a;const e=M.default.map([[n[o(-1)],n[t]],[n[t],n[o(1)]],[n[o(-1)],n[o(1)]]],(function(e){return Uh(Wh(...e))}));if(M.default.each([0,1],(function(t){e[t]=Math.round(e[t])})),Yh(e[1]+e[2],e[0])||Yh(e[0]+e[2],e[1])||Yh(e[0]+e[1],e[2]))return!1;const s=(l=e[0],c=e[2],d=e[1],180*Math.acos((l*l+c*c-d*d)/(2*l*c))/Math.PI),i=En.findAngle(n[o(1)],n[o(-1)]),p=1===zh(Lh(n[o(-1)],n[o(1)],n[t])),u=null===(r=this.graphie)||void 0===r?void 0:r.polar(e[0],i+(p?1:-1)*s);return null===(a=this.graphie)||void 0===a?void 0:a.addPoints(n[o(-1)],u)}var l,c,d;return!0}],onMoveStart:()=>{this.isClickToAddPoints()&&this.setTrashCanVisibility(1)},onMove:()=>{var e;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&this.updateCoordsFromPoints()},onMoveEnd:e=>{const t=this.points.length>1&&(r===this.points[0]&&Rh.equal(e,M.default.last(this.points).coord())||r===M.default.last(this.points)&&Rh.equal(e,this.points[0].coord()));if(this.isClickToAddPoints()){if(this.isCoordInTrash(e))s();else if(t){const e=this.points.pop();var n,o;if(this.points.length>2)null===(n=this.polygon)||void 0===n||n.update({closed:!0}),this.updateCoordsFromPoints();else null===(o=this.polygon)||void 0===o||o.update({closed:!1}),this.clearCoords();this.updatePolygon(),setTimeout(e.remove.bind(e),0)}else{if(M.default.any(this.points,(function(t){return t!==r&&Rh.equal(t.coord(),e)}))){var a,l;if(this.removePoint(r),this.points.length<3)null===(l=this.polygon)||void 0===l||l.update({closed:!1}),this.clearCoords();else null!==(a=this.polygon)&&void 0!==a&&a.closed()&&this.updateCoordsFromPoints();this.updatePolygon(),setTimeout(r.remove.bind(r),0)}else{var c;const e=r===M.default.head(this.points)||r===M.default.last(this.points),t=!r.hasMoved(),n=!r.state.isInitialMove,o=!(null!==(c=this.polygon)&&void 0!==c&&c.closed()),s=this.points.length>2;var d;if(e&&t&&n&&o&&s)null===(d=this.polygon)||void 0===d||d.update({closed:!0}),this.updatePolygon(),this.updateCoordsFromPoints()}}this.setTrashCanVisibility(.5)}i(r,!1)},...this.props.apiOptions.isMobile&&this.isClickToAddPoints()?{onRemove:s}:{}});return r.state.isInitialMove=!0,r})),U(this,"updateCoordsFromPoints",(()=>{const e=M.default.extend({},this.props.graph,{coords:M.default.map(this.points,(function(e){return M.default.result(e,"coord")}))});this.onChange({graph:e})})),U(this,"clearCoords",(()=>{const e=M.default.extend({},this.props.graph,{coords:null});this.onChange({graph:e})})),U(this,"onChange",(e=>{this.props.onChange(e),this.props.trackInteraction()})),U(this,"addPointControls",(()=>{if("point"!==this.props.graph.type)throw tf("addPointControls","point");const e=nf.getPointCoords(this.props.graph,this.props);this.points=[],this.points=M.default.map(e,this.createPointForPointsType,this)})),U(this,"removePointControls",(()=>{M.default.invoke(this.points,"remove")})),U(this,"addSegmentControls",(()=>{if("segment"!==this.props.graph.type)throw tf("addSegmentControls","segment");const e=this,t=this.graphie,n=nf.getSegmentCoords(this.props.graph,this.props),o=e=>gs.addMaybeMobileMovablePoint(this,e);this.points=[],this.lines=M.default.map(n,(function(n,s){const i=function(){const t=M.default.extend({},e.props.graph,{coords:M.default.invoke(e.lines,"coords")});e.onChange({graph:t})},r=[];for(let e=0;e<n.length;e+=1){const t=n[e];r.push(o({coord:t,constraints:[gs.MovablePoint.constraints.bound(),gs.MovablePoint.constraints.snap(),t=>{const n=r[1-e];return!!n&&!Rh.equal(t,n.coord())}],onMove:i}))}e.points=e.points.concat(r);const a=gs.addMovableLine(t,{points:r,static:!1,constraints:[gs.MovableLine.constraints.bound(),gs.MovableLine.constraints.snap()],onMove:[gs.MovableLine.onMove.updatePoints,i],normalStyle:{stroke:this.props.apiOptions.isMobile?bn.BLUE_C:bn.INTERACTIVE,...this._lineStroke()},highlightStyle:{stroke:this.props.apiOptions.isMobile?bn.BLUE_C:bn.INTERACTING,...this._lineStroke()}});return M.default.invoke(r,"toFront"),a}),this)})),U(this,"removeSegmentControls",(()=>{M.default.invoke(this.points,"remove"),M.default.invoke(this.lines,"remove")})),U(this,"addRayControls",(()=>{this.addLine("ray")})),U(this,"removeRayControls",(()=>{this.removeLine()})),U(this,"addPolygonControls",(()=>{this.polygon=null;const e=nf.getPolygonCoords(this.props.graph,this.props);this.points=[],this.points=M.default.map(e,this.createPointForPolygonType,this),this.updatePolygon()})),U(this,"updatePolygon",(()=>{if("polygon"!==this.props.graph.type)throw tf("updatePolygon","polygon");let e;e=this.polygon?this.polygon.closed():this.points.length>=3;const t=this.graphie,n=this.points.length,o=!M.default.contains(["angles","sides"],this.props.graph.snapTo),s=M.default.times(n,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==n-1)?"angles"===this.props.graph.snapTo?"$deg0":"$deg1":""}),this),i=M.default.times(n,(function(t){return e||0!==t&&t!==n-1}),this),r=M.default.times(n,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==n-1)?1:0}),this),a=M.default.times(n,(function(t){return!this.props.graph.showSides||!e&&t===n-1?"":"sides"===this.props.graph.snapTo?"$len0":"$len1"}),this);if(null==this.polygon){const n=this;n.polygon=gs.addMovablePolygon(t,{constraints:[gs.MovablePolygon.constraints.bound(),o?gs.MovablePolygon.constraints.snap():null],closed:e,points:n.points,angleLabels:s,showRightAngleMarkers:i,numArcs:r,sideLabels:a,onMove:[gs.MovablePolygon.onMove.updatePoints,function(){this.closed()&&n.updateCoordsFromPoints()}],normalStyle:{stroke:this.props.apiOptions.isMobile?bn.BLUE_C:bn.INTERACTIVE,...this._lineStroke()}})}else this.polygon.update({closed:e,points:this.points,angleLabels:s,showRightAngleMarkers:i,numArcs:r,sideLabels:a})})),U(this,"removePolygonControls",(()=>{var e;M.default.invoke(this.points,"remove"),null===(e=this.polygon)||void 0===e||e.remove()})),U(this,"addAngleControls",(()=>{if("angle"!==this.props.graph.type)throw tf("addAngleControls","angle");const e=this.props.graph,t=this.graphie,n=nf.getAngleCoords(this.props.graph,this.props);var o,s;this.points=n.map((function(e,n){return null==t?void 0:t.addMovablePoint(M.default.extend({coord:e,normalStyle:{stroke:bn.INTERACTIVE,fill:bn.INTERACTIVE}},1===n?{snapX:t.snap[0],snapY:t.snap[1]}:{}))})),this.angle=null==t?void 0:t.addMovableAngle({points:this.points,snapDegrees:e.snapDegrees||1,snapOffsetDeg:e.angleOffsetDeg||0,angleLabel:e.showAngles?"$deg0":"",pushOut:2,allowReflex:(o=e.allowReflexAngles,s=!0,null==o?s:o)}),P.default(this.angle).on("move",(()=>{var t;this.onChange({graph:{...e,coords:null===(t=this.angle)||void 0===t?void 0:t.getClockwiseCoords()}})}))})),U(this,"removeAngleControls",(()=>{var e;M.default.invoke(this.points,"remove"),null===(e=this.angle)||void 0===e||e.remove()})),U(this,"toggleShowAngles",(()=>{if("polygon"!==this.props.graph.type)throw tf("toggleShowAngles","polygon");const e=M.default.extend({},this.props.graph,{showAngles:!this.props.graph.showAngles});this.onChange({graph:e})})),U(this,"toggleShowSides",(()=>{if("polygon"!==this.props.graph.type)throw tf("toggleShowSides","polygon");const e=M.default.extend({},this.props.graph,{showSides:!this.props.graph.showSides});this.onChange({graph:e})})),U(this,"getUserInput",(()=>nf.getUserInputFromProps(this.props))),U(this,"simpleValidate",(e=>nf.validate(this.getUserInput(),e,this))),U(this,"focus",P.default.noop)}UNSAFE_componentWillMount(){Fh.UNSAFE_componentWillMount.call(this)}componentDidMount(){this.setGraphie(this.refs.graph.graphie())}UNSAFE_componentWillReceiveProps(e){var t,n;this.isClickToAddPoints()!==this.isClickToAddPoints(e)&&(this.shouldResetGraphie=!0,this.setState({shouldShowInstructions:Qh(e)})),(null===(t=this.props.backgroundImage)||void 0===t?void 0:t.url)===(null===(n=e.backgroundImage)||void 0===n?void 0:n.url)&&this.props.backgroundImage===e.backgroundImage&&this.props.containerSizeClass===e.containerSizeClass||(this.shouldResetGraphie=!0)}componentDidUpdate(e,t){const n=e.graph.type,o=this.props.graph.type;(n!==o||"angle"===e.graph.type&&"angle"===this.props.graph.type&&this.areAngleGraphsEqual(e.graph,this.props.graph)||"point"===e.graph.type&&"point"===this.props.graph.type&&this.arePointGraphsEqual(e.graph,this.props.graph)||"polygon"===e.graph.type&&"polygon"===this.props.graph.type&&this.arePolygonGraphsEqual(e.graph,this.props.graph)||"segment"===e.graph.type&&"segment"===this.props.graph.type&&this.areSegmentGraphsEqual(e.graph,this.props.graph))&&(this["remove"+Kh(n)+"Controls"](),this["add"+Kh(o)+"Controls"]()),this.shouldResetGraphie&&this.resetGraphie()}areAngleGraphsEqual(e,t){return e.allowReflexAngles!==t.allowReflexAngles||e.angleOffsetDeg!==t.angleOffsetDeg||e.snapDegrees!==t.snapDegrees}arePointGraphsEqual(e,t){return e.numPoints!==t.numPoints}arePolygonGraphsEqual(e,t){return e.numSides!==t.numSides||e.showAngles!==t.showAngles||e.showSides!==t.showSides||e.snapTo!==t.snapTo}areSegmentGraphsEqual(e,t){return e.numSegments!==t.numSegments}render(){const e=pi(this.props.containerSizeClass);let t;this.isClickToAddPoints()&&this.state.shouldShowInstructions?"point"===this.props.graph.type?t=k._("Click to add points"):"polygon"===this.props.graph.type&&(t=k._("Click to add vertices")):t=void 0;const n=this.isClickToAddPoints()?this.handleAddPointsMouseDown:null,o=this.props.gridStep||Ye.getGridStep(this.props.range,this.props.step,e[0]),s=this.props.snapStep||Ye.snapStepFromGridStep(o),i=this.props.apiOptions.isMobile;return _.createElement("div",{className:"perseus-widget perseus-widget-interactive-graph",style:{width:e[0],height:e[1]}},_.createElement(Nh,{instructions:t,ref:"graph",box:e,labels:this.props.labels,range:this.props.range,step:i?Ye.constrainedTickStepsFromTickSteps(this.props.step,this.props.range):this.props.step,gridStep:o,snapStep:s,markings:this.props.markings,backgroundImage:this.props.backgroundImage,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onMouseDown:n,onGraphieUpdated:this.setGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:i}))}static getQuadraticCoefficients(e){const t=e[0],n=e[1],o=e[2],s=(t[0]-n[0])*(t[0]-o[0])*(n[0]-o[0]);if(0===s)return;return[(o[0]*(n[1]-t[1])+n[0]*(t[1]-o[1])+t[0]*(o[1]-n[1]))/s,(o[0]*o[0]*(t[1]-n[1])+n[0]*n[0]*(o[1]-t[1])+t[0]*t[0]*(n[1]-o[1]))/s,(n[0]*o[0]*(n[0]-o[0])*t[1]+o[0]*t[0]*(o[0]-t[0])*n[1]+t[0]*n[0]*(t[0]-n[0])*o[1])/s]}static getSinusoidCoefficients(e){const t=e[0],n=e[1],o=n[1]-t[1],s=Math.PI/(2*(n[0]-t[0]));return[o,s,t[0]*s,t[1]]}static getLineCoords(e,t){return e.coords||nf.pointsFromNormalized(t,[[.25,.75],[.75,.75]])}static getPointCoords(e,t){const n=e.numPoints||1;let o=e.coords;if(o)return o;switch(n){case 1:o=[e.coord||[0,0]];break;case 2:o=[[-5,0],[5,0]];break;case 3:o=[[-5,0],[0,0],[5,0]];break;case 4:o=[[-6,0],[-2,0],[2,0],[6,0]];break;case 5:o=[[-6,0],[-3,0],[0,0],[3,0],[6,0]];break;case 6:o=[[-5,0],[-3,0],[-1,0],[1,0],[3,0],[5,0]];break;case"unlimited":o=[]}const s=nf.normalizeCoords(o,[[-10,10],[-10,10]]);return nf.pointsFromNormalized(t,s)}static getLinearSystemCoords(e,t){return e.coords||M.default.map([[[.25,.75],[.75,.75]],[[.25,.25],[.75,.25]]],(e=>nf.pointsFromNormalized(t,e)))}static getPolygonCoords(e,t){if("polygon"!==e.type)throw tf("toggleShowSides","polygon");let n=e.coords;if(n)return n;const o=e.numSides||3;if("unlimited"===o)n=[];else{const t=2*Math.PI/o,s=(1/o-.5)*Math.PI,i="sides"===e.snapTo?Math.sqrt(3)/3*7:4;n=M.default.times(o,(function(e){return[i*Math.cos(e*t+s),i*Math.sin(e*t+s)]}))}n=nf.normalizeCoords(n,[[-10,10],[-10,10]]);const s=!M.default.contains(["angles","sides"],e.snapTo);return n=nf.pointsFromNormalized(t,n,!s),n}static getSegmentCoords(e,t){const n=e.coords;if(n)return n;const o=e.numSegments||1,s=[[-10,10],[-10,10]];return{1:[5],2:[5,-5],3:[5,0,-5],4:[6,2,-2,-6],5:[6,3,0,-3,-6],6:[5,3,1,-1,-3,-5]}[o].map((function(e){let n=[[-5,e],[5,e]];return n=nf.normalizeCoords(n,s),n=nf.pointsFromNormalized(t,n),n}))}static getAngleCoords(e,t){let n=e.coords;if(n)return n;const o=e.snapDegrees||1;let s=o;for(;s<20;)s+=o;s=s*Math.PI/180;const i=(e.angleOffsetDeg||0)*Math.PI/180;n=nf.pointsFromNormalized(t,[[.85,.5],[.5,.5]]);const r=Uh(Wh(...n));return n[0]=[n[1][0]+r*Math.cos(i),n[1][1]+r*Math.sin(i)],n[2]=[n[1][0]+r*Math.cos(s+i),n[1][1]+r*Math.sin(s+i)],n}static normalizeCoords(e,t){return M.default.map(e,(function(e){return M.default.map(e,(function(e,n){const o=t[n][1]-t[n][0];return(e+t[n][1])/o}))}))}static getEquationString(e){const t="get"+Kh(e.graph.type)+"EquationString";return nf[t](e)}static pointsFromNormalized(e,t,n){return M.default.map(t,(function(t){return M.default.map(t,(function(t,o){const s=e.range[o];if(n)return s[0]+(s[1]-s[0])*t;const i=e.step[o],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(s,i),a=Math.round(t*r);return s[0]+i*a}))}))}static getLinearEquationString(e){const t=nf.getLineCoords(e.graph,e);if(Oh(t[0][0],t[1][0]))return"x = "+t[0][0].toFixed(3);const n=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),o=t[0][1]-n*t[0][0];return Oh(n,0)?"y = "+o.toFixed(3):"y = "+n.toFixed(3)+"x + "+o.toFixed(3)}static getCurrentQuadraticCoefficients(e){const t=e.graph.coords||nf.defaultQuadraticCoords(e);return nf.getQuadraticCoefficients(t)}static defaultQuadraticCoords(e){return nf.pointsFromNormalized(e,[[.25,.75],[.5,.25],[.75,.75]])}static getQuadraticEquationString(e){const t=nf.getCurrentQuadraticCoefficients(e);return"y = "+t[0].toFixed(3)+"x^2 + "+t[1].toFixed(3)+"x + "+t[2].toFixed(3)}static getCurrentSinusoidCoefficients(e){const t=e.graph.coords||nf.defaultSinusoidCoords(e);return nf.getSinusoidCoefficients(t)}static defaultSinusoidCoords(e){return nf.pointsFromNormalized(e,[[.5,.5],[.65,.6]])}static getSinusoidEquationString(e){const t=nf.getCurrentSinusoidCoefficients(e);return"y = "+t[0].toFixed(3)+"sin("+t[1].toFixed(3)+"x - "+t[2].toFixed(3)+") + "+t[3].toFixed(3)}static getCircleEquationString(e){const t=e.graph,n=t.center||[0,0],o=t.radius||2;return"center ("+n[0]+", "+n[1]+"), radius "+o}static getLinearSystemEquationString(e){const t=nf.getLinearSystemCoords(e.graph,e);return"\n"+Zh(t[0][0],t[0][1])+"\n"+Zh(t[1][0],t[1][1])+"\n"+function(e,t){const n=e[0][0],o=e[0][1],s=e[1][0],i=e[1][1],r=t[0][0],a=t[0][1],l=t[1][0],c=t[1][1],d=(n-s)*(a-c)-(o-i)*(r-l);if(Math.abs(d)<1e-9)return"Lines are parallel";const p=((n*i-o*s)*(a-c)-(o-i)*(r*c-a*l))/d;return"Intersection: ("+(((n*i-o*s)*(r-l)-(n-s)*(r*c-a*l))/d).toFixed(3)+", "+p.toFixed(3)+")"}(t[0],t[1])}static getPointEquationString(e){if("point"!==e.graph.type)throw tf("getPointEquationString","point");return nf.getPointCoords(e.graph,e).map((function(e){return"("+e[0]+", "+e[1]+")"})).join(", ")}static getSegmentEquationString(e){if("segment"!==e.graph.type)throw tf("getSegmentEquationString","segment");const t=nf.getSegmentCoords(e.graph,e);return M.default.map(t,(function(e){return"["+M.default.map(e,(function(e){return"("+e.join(", ")+")"})).join(" ")+"]"})).join(" ")}static getRayEquationString(e){if("ray"!==e.graph.type)throw tf("createPointForPolygonType","ray");const t=nf.getLineCoords(e.graph,e),n=t[0],o=t[1];let s=nf.getLinearEquationString(e);return n[0]>o[0]?s+=" (for x <= "+n[0].toFixed(3)+")":n[0]<o[0]?s+=" (for x >= "+n[0].toFixed(3)+")":n[1]>o[1]?s+=" (for y <= "+n[1].toFixed(3)+")":s+=" (for y >= "+n[1].toFixed(3)+")",s}static getPolygonEquationString(e){if("polygon"!==e.graph.type)throw tf("getPolygonEquationString","polygon");const t=nf.getPolygonCoords(e.graph,e);return M.default.map(t,(function(e){return"("+e.join(", ")+")"})).join(" ")}static getAngleEquationString(e){if("angle"!==e.graph.type)throw tf("getAngleEquationString","angle");const t=nf.getAngleCoords(e.graph,e);return En.findAngle(t[2],t[0],t[1]).toFixed(0)+"° angle at ("+t[1].join(", ")+")"}static validate(e,t,n){const o=!!(e.coords||e.center&&e.radius);if(e.type===t.correct.type&&o)if("linear"===e.type&&"linear"===t.correct.type&&null!=e.coords){const n=e.coords,o=t.correct.coords;if(Bh(o[0],o[1],n[0])&&Bh(o[0],o[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("linear-system"===e.type&&"linear-system"===t.correct.type&&null!=e.coords){const n=e.coords,o=t.correct.coords;if(Bh(o[0][0],o[0][1],n[0][0])&&Bh(o[0][0],o[0][1],n[0][1])&&Bh(o[1][0],o[1][1],n[1][0])&&Bh(o[1][0],o[1][1],n[1][1])||Bh(o[0][0],o[0][1],n[1][0])&&Bh(o[0][0],o[0][1],n[1][1])&&Bh(o[1][0],o[1][1],n[0][0])&&Bh(o[1][0],o[1][1],n[0][1]))return{type:"points",earned:1,total:1,message:null}}else if("quadratic"===e.type&&"quadratic"===t.correct.type&&null!=e.coords){const n=this.getQuadraticCoefficients(e.coords),o=this.getQuadraticCoefficients(t.correct.coords);if(Dh(n,o))return{type:"points",earned:1,total:1,message:null}}else if("sinusoid"===e.type&&"sinusoid"===t.correct.type&&null!=e.coords){const n=this.getSinusoidCoefficients(e.coords),o=this.getSinusoidCoefficients(t.correct.coords),s=$h(n),i=$h(o);if(Dh(s,i))return{type:"points",earned:1,total:1,message:null}}else if("circle"===e.type&&"circle"===t.correct.type){if(Dh(e.center,t.correct.center)&&Oh(e.radius,t.correct.radius))return{type:"points",earned:1,total:1,message:null}}else if("point"===e.type&&"point"===t.correct.type&&null!=e.coords){var s;let o=nf.getPointCoords(t.correct,n);const i=null===(s=e.coords)||void 0===s?void 0:s.slice();if(o=o.slice(),null==i||i.sort(),o.sort(),Dh(i,o))return{type:"points",earned:1,total:1,message:null}}else if("polygon"===e.type&&"polygon"===t.correct.type&&null!=e.coords){var i,r;const n=null===(i=e.coords)||void 0===i?void 0:i.slice(),o=null===(r=t.correct.coords)||void 0===r?void 0:r.slice();let s;if("similar"===t.correct.match?s=jh(n,o,Number.POSITIVE_INFINITY):"congruent"===t.correct.match?s=jh(n,o,Ah.DEFAULT_TOLERANCE):"approx"===t.correct.match?s=jh(n,o,.1):(n.sort(),o.sort(),s=Dh(n,o)),s)return{type:"points",earned:1,total:1,message:null}}else if("segment"===e.type&&"segment"===t.correct.type&&null!=e.coords){var a;let n=e.coords.slice(),o=null===(a=t.correct.coords)||void 0===a?void 0:a.slice();if(n=M.default.invoke(n,"sort").sort(),o=M.default.invoke(o,"sort").sort(),Dh(n,o))return{type:"points",earned:1,total:1,message:null}}else if("ray"===e.type&&"ray"===t.correct.type&&null!=e.coords){const n=e.coords,o=t.correct.coords;if(Dh(n[0],o[0])&&Bh(o[0],o[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("angle"===e.type&&"angle"===t.correct.type){const n=e.coords,o=t.correct.coords;let s;if("congruent"===t.correct.match){const e=M.default.map([n,o],(function(e){return(En.findAngle(e[2],e[0],e[1])+360)%360}));s=Oh(...e)}else s=Dh(n[1],o[1])&&Bh(o[1],o[0],n[0])&&Bh(o[1],o[2],n[2]);if(s)return{type:"points",earned:1,total:1,message:null}}return!o||M.default.isEqual(e,t.graph)?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}static getUserInputFromProps(e){return e.graph}}U(nf,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:!1,showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,graph:{type:"linear"}});var of={name:"interactive-graph",displayName:"Interactive graph",widget:nf};class sf extends _.Component{constructor(){super(...arguments),U(this,"_input",void 0),U(this,"state",{isInputFocused:!1})}focusInput(){this._input&&this._input.focus()}handleClick(e){const{checked:t,onChange:n}=this.props;e.preventDefault(),this.focusInput(),n(!t)}handleKeyDown(e){const{onFocusPrevAnswer:t,onFocusNextAnswer:n}=this.props;switch(e.key){case"ArrowUp":e.preventDefault(),t();break;case"ArrowDown":e.preventDefault(),n()}}handleInputChange(e){e.preventDefault()}handleInputFocus(){this.setState({isInputFocused:!0})}handleInputBlur(){this.setState({isInputFocused:!1})}renderCheckmark(){const{checked:e}=this.props;return _.createElement("span",{className:d.css(af.checkmarkContainer)},e&&_.createElement(ha,{icon:bo,size:16,color:L.default.offBlack}))}render(){const{content:e,checked:t,groupName:n,index:o,inputType:s}=this.props,{isInputFocused:i}=this.state,r="".concat(n,"-").concat(o);return _.createElement("div",{className:d.css(af.answerChoice,i&&af.answerFocused),onClick:e=>this.handleClick(e),onKeyDown:e=>this.handleKeyDown(e)},_.createElement("span",{className:d.css(af.answerInputWrapper)},_.createElement("input",{className:d.css(ta.perseusSrOnly),checked:t,name:n,id:r,type:s,onChange:e=>this.handleInputChange(e),onFocus:()=>this.handleInputFocus(),onBlur:()=>this.handleInputBlur(),ref:e=>this._input=e}),this.renderCheckmark()),_.createElement("label",{htmlFor:r},_.createElement(qi,{content:e})))}}class rf extends _.Component{constructor(e){super(e),U(this,"_choices",void 0),this._choices=[],this.state={groupName:M.default.uniqueId("answer_choices_")}}focusAnswer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=this.props.choices.length;e<0?e+=t:e>=t&&(e-=t);const n=this._choices[e];n&&n.focusInput()}onAnswerChange(e,t){const{choices:n,multipleSelect:o,onChange:s}=this.props,i=[];for(let s=0;s<n.length;s++)i.push(o?s===e?t:n[s].checked:s===e&&t);s(i)}onFocusAnswer(e){this.focusAnswer(e)}render(){const{choices:e,multipleSelect:t}=this.props,{groupName:n}=this.state;return _.createElement("fieldset",null,e.map(((e,o)=>_.createElement(sf,G({},e,{key:e.content,groupName:n,index:o,inputType:t?"checkbox":"radio",onChange:e=>this.onAnswerChange(o,e),onFocusPrevAnswer:()=>this.onFocusAnswer(o-1),onFocusNextAnswer:()=>this.onFocusAnswer(o+1),ref:e=>this._choices[o]=e})))))}}const af=d.StyleSheet.create({answerChoice:{display:"flex",alignItems:"center",userSelect:"none",padding:"10px 16px 10px 0px",fontWeight:"bold",border:"solid 2px transparent",borderRadius:2,":active":{backgroundColor:"rgba(33, 36, 44, 0.08)"}},answerFocused:{borderColor:"#1865f2",":active":{borderColor:"transparent"}},answerInputWrapper:{marginRight:8},checkmarkContainer:{display:"flex",position:"relative",width:16,height:16,marginLeft:8}});class lf extends _.Component{constructor(){super(...arguments),U(this,"_icon",void 0),U(this,"state",{isFocused:!1})}handleFocus(){this.setState({isFocused:!0})}handleBlur(){this.setState({isFocused:!1})}renderIcon(){const{selected:e,showCorrectness:t,showSelected:n,showPulsate:o}=this.props,{isFocused:s}=this.state,i=n||s;let r,a;return t?(r=_.createElement(ha,{icon:"correct"===t?yo:Fo,size:24,color:L.default.white}),a="correct"===t?[cf.markerCorrect,i&&cf.markerCorrectSelected]:[cf.markerIncorrect,i&&cf.markerIncorrectSelected]):a=e&&e.length>0?[cf.markerFilled,i&&cf.markerFilledSelected]:[i?cf.markerUnfilledSelected:o&&cf.markerUnfilledPulsate],_.createElement("div",{className:d.css(cf.markerIcon,...a),ref:e=>this._icon=e},r)}render(){const{label:e,x:t,y:n,showCorrectness:o}=this.props,s="correct"===o;return _.createElement("button",{"aria-label":e,className:d.css(cf.unstyledButton,cf.marker,s&&cf.disabled),style:{left:"".concat(t,"%"),top:"".concat(n,"%")},tabIndex:s?-1:0,onFocus:()=>this.handleFocus(),onBlur:()=>this.handleBlur(),onClick:e=>this.props.onClick(e),onKeyDown:e=>this.props.onKeyDown(e)},this.renderIcon())}}U(lf,"defaultProps",{selected:[]});const cf=d.StyleSheet.create({unstyledButton:{padding:0,overflow:"visible",color:"inherit",font:"inherit",lineHeight:"normal",background:"none",border:"none"},marker:{position:"absolute",width:30,height:30,marginLeft:-15,marginTop:-15},disabled:{pointerEvents:"none"},markerIcon:{display:"flex",position:"relative",boxSizing:"content-box",width:16,height:16,marginLeft:5,cursor:"pointer",backgroundColor:"#1865f2",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 6px 0 ".concat("rgba(33, 36, 44, 0.32)")},markerUnfilledPulsate:{animationName:{"0%":{transform:"scale(1)"},"100%":{transform:"scale(1.5)"}},animationDirection:"alternate",animationDuration:"0.8s",animationIterationCount:"infinite",animationTimingFunction:"ease-in",transformOrigin:"50% 50%"},markerUnfilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:20,height:20,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:20},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerFilled:{width:8,height:8,marginLeft:9,borderRadius:8,boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerFilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:12,height:12,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:12},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerCorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#00a60e",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerCorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#167b1f",boxShadow:"none","::before":{display:"none"}}},markerIncorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#909195",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerIncorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#6c6e73",boxShadow:"none","::before":{display:"none"}}}});class df extends _.Component{static gradeMarker(e){const t={hasAnswers:!1,isCorrect:!1};return e.selected&&e.selected.length>0&&(t.hasAnswers=!0),e.answers.length>0?e.selected&&e.selected.length===e.answers.length&&(t.isCorrect=e.selected.every((t=>e.answers.includes(t)))):e.selected&&0!==e.selected.length||(t.isCorrect=!0),t}static validate(e,t){let n=0,o=0;for(const t of e.markers){const e=df.gradeMarker(t);e.hasAnswers&&n++,e.isCorrect&&o++}return n!==e.markers.length?{type:"invalid",message:null}:{type:"points",earned:o===e.markers.length?1:0,total:1,message:null}}static pointInTriangle(e,t,n,o){const s=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),i=s(e,t,n)<0,r=s(e,n,o)<0,a=s(e,o,t)<0;return i===r&&r===a}static imageSideForMarkerPosition(e,t){if(e<20)return"left";if(e>80)return"right";const n={x:20,y:0},o={x:80,y:0},s={x:80,y:100},i={x:20,y:100},r={x:50,y:50},a={top:[n,o,r],right:[r,o,s],bottom:[i,r,s],left:[n,r,i]},l={x:e,y:t};for(const e of Object.keys(a)){const t=a[e];if(df.pointInTriangle(l,...t))return e}return"center"}static navigateToMarkerIndex(e,t,n){const o=t[n],s=t.map(((e,t)=>{const n=e.x-o.x,s=e.y-o.y,i=Math.sqrt(n**2+s**2);return{index:t,dist:i,dir:{x:0!==i?n/i:0,y:0!==i?s/i:0}}})).filter((e=>e.index!==n&&"correct"!==t[e.index].showCorrectness)).sort(((t,n)=>{const o=Math.round(t.dist*(e.x*t.dir.x+e.y*t.dir.y)),s=Math.round(n.dist*(e.x*n.dir.x+e.y*n.dir.y));let i,r;return e.x>0?(i=t.dir.x>0&&0!==o,r=n.dir.x>0&&0!==s):e.x<0?(i=t.dir.x<0&&0!==o,r=n.dir.x<0&&0!==s):e.y>0?(i=t.dir.y>0&&0!==o,r=n.dir.y>0&&0!==s):e.y<0&&(i=t.dir.y<0&&0!==o,r=n.dir.y<0&&0!==s),i!==r?i?-1:1:o-s}));return s.length>0?s[0].index:n}constructor(e){super(e),U(this,"_markers",void 0),U(this,"_selectedMarkerPopup",void 0),U(this,"_answerChoices",void 0),U(this,"handleDocumentClick",(e=>{if(this._selectedMarkerPopup&&this._answerChoices){const t=N.default.findDOMNode(this._answerChoices),n=e.target,o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return e&&(e.contains(n)||t>0&&o(e.parentElement,t-1))};o(t)||this.dismissMarkerPopup()}})),U(this,"handleDocumentKeyDown",(e=>{this._selectedMarkerPopup&&27===e.keyCode&&(e.stopPropagation(),this.dismissMarkerPopup())})),this._markers=[],this.state={selectedMarkerIndex:-1,markersInteracted:!1}}componentDidMount(){document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeyDown,!0)}componentWillUnmount(){document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeyDown,!0)}simpleValidate(e){return df.validate(this.getUserInput(),e)}getUserInput(){const{markers:e}=this.props;return{markers:e}}showRationalesForCurrentlySelectedChoices(e){const{markers:t}=this.props,{onChange:n}=this.props;n({markers:t.map((e=>{const t=df.gradeMarker(e);return{...e,showCorrectness:t.hasAnswers?t.isCorrect?"correct":"incorrect":void 0}}))},null,!0)}dismissMarkerPopup(){const{selectedMarkerIndex:e}=this.state;-1!==e&&this.setState({selectedMarkerIndex:-1},(()=>{const t=this._markers[e];t&&N.default.findDOMNode(t).focus()}))}handleMarkerChange(e,t){const{markers:n,onChange:o}=this.props;o({markers:[...n.slice(0,e),{...t,showCorrectness:void 0},...n.slice(e+1)]})}handleMarkerClick(e,t){const{selectedMarkerIndex:n}=this.state;t.preventDefault(),n!==e?this.setState({selectedMarkerIndex:e,markersInteracted:!0},(()=>{setTimeout((()=>{this._answerChoices&&this._answerChoices.focusAnswer()}),100)})):this.dismissMarkerPopup()}handleMarkerKeyDown(e,t){const{markers:n}=this.props;if(n.length<2)return;const o={ArrowUp:{x:0,y:-1},ArrowRight:{x:1,y:0},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0}}[t.key];if(!o)return;t.preventDefault();const s=this._markers[df.navigateToMarkerIndex(o,n,e)];s&&N.default.findDOMNode(s).focus()}handleAnswerChoicesChangeForMarker(e,t){const{choices:n,markers:o,multipleAnswers:s}=this.props,i=n.filter(((e,n)=>t[n]));this.handleMarkerChange(e,{...o[e],selected:i}),s||this.dismissMarkerPopup()}renderAnswerChoicesForMarker(e,t){const{choices:n,multipleAnswers:o}=this.props,s=t.selected;return _.createElement("div",{className:S.default("perseus-label-image-widget-answer-choices",d.css(pf.scrollableChoices))},_.createElement(rf,{choices:n.map((e=>({content:e,checked:!!s&&s.includes(e)}))),multipleSelect:o,onChange:t=>this.handleAnswerChoicesChangeForMarker(e,t),ref:e=>this._answerChoices=e}))}renderMarkers(){const{markers:e,questionCompleted:t}=this.props,{selectedMarkerIndex:n,markersInteracted:o}=this.state;return e.map(((e,s)=>{const i=df.gradeMarker(e),r=_.createElement(lf,G({},e,{showCorrectness:t&&i.hasAnswers&&i.isCorrect?"correct":e.showCorrectness,showSelected:s===n,showPulsate:!o,key:"".concat(e.x,".").concat(e.y),onClick:e=>this.handleMarkerClick(s,e),onKeyDown:e=>this.handleMarkerKeyDown(s,e),ref:e=>this._markers[s]=e}));if(s!==n)return r;let a;return a=window.matchMedia($r.xsOrSmaller.replace("@media ","")).matches?e.y>50?"top":"bottom":{left:"right",top:"bottom",right:"left",bottom:"top",center:"top"}[df.imageSideForMarkerPosition(e.x,e.y)],_.createElement(b.Popover,{content:()=>_.createElement(b.PopoverContentCore,{style:pf.choicesPopover},this.renderAnswerChoicesForMarker(s,e)),placement:a,opened:!0,key:"".concat(e.x,".").concat(e.y),ref:e=>this._selectedMarkerPopup=e},r)}))}renderInstructions(){const{apiOptions:{isMobile:e},choices:t,multipleAnswers:n,hideChoicesFromInstructions:o}=this.props,s=e?n?k._("Tap each dot on the image to select all answers that apply."):k._("Tap each dot on the image to select an answer."):n?k._("Click each dot on the image to select all answers that apply."):k._("Click each dot on the image to select an answer."),i=k._("Choices:");return _.createElement("div",{className:S.default("perseus-label-image-widget-instructions",d.css(pf.instructions))},_.createElement("div",{className:d.css(pf.instructionsCaption)},s," ",!o&&i),!o&&_.createElement("div",{className:d.css(pf.instructionsChoices)},t.map(((e,t)=>_.createElement("div",{className:d.css(pf.instructionsChoice),key:t},_.createElement(qi,{content:e}))))))}render(){const{imageAlt:e,imageUrl:t,imageWidth:n,imageHeight:o}=this.props,{selectedMarkerIndex:s}=this.state;return _.createElement("div",null,this.renderInstructions(),_.createElement("div",{className:d.css(pf.markersCanvas),style:{maxWidth:n,maxHeight:o}},_.createElement("div",{className:d.css(pf.imageContainer,-1!==s&&pf.imageInteractionDisabled)},_.createElement(sn.Consumer,null,(s=>{let{setAssetStatus:i}=s;return _.createElement(Ys,{alt:e,src:t,width:n,height:o,setAssetStatus:i})}))),this.renderMarkers()))}}const pf=d.StyleSheet.create({instructions:{paddingBottom:16},instructionsCaption:{...ol.bodyXsmallBold,paddingBottom:16},instructionsChoices:{display:"flex",flexWrap:"wrap",margin:"-8px 0"},instructionsChoice:{display:"flex",alignItems:"center",margin:"8px 0",":not(:last-child)":{"::after":{content:"''",display:"inline-block",position:"relative",width:2,height:2,marginLeft:5,marginRight:5,background:"rgba(33, 36, 44, 0.32)",borderRadius:2}}},markersCanvas:{position:"relative"},imageContainer:{display:"flex"},imageInteractionDisabled:{pointerEvents:"none"},scrollableChoices:{paddingTop:8,paddingBottom:8,[$r.xsOrSmaller]:{maxHeight:250,overflowY:"auto"}},choicesPopover:{padding:0}});var uf={name:"label-image",displayName:"Label Image",widget:df,accessible:!0,isLintable:!0};const hf={display:"table",tableLayout:"fixed"},ff={display:"table-row"},mf={display:"table-cell",padding:5},gf={borderRadius:10,cursor:"pointer"},vf={padding:5,display:"inline-block"},yf={float:"right",paddingRight:5},bf={plus:()=>[[!1,!0,!1],[!0,!0,!0],[!1,!0,!1]],x:()=>[[!0,!1,!0],[!1,!0,!1],[!0,!1,!0]],"plus/x":e=>e%2?bf.x():bf.plus()};class xf extends _.Component{constructor(){super(...arguments),U(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){const e=this.props.value?"#55dd55":"#115511",t=M.default.extend({},gf,{width:this.props.size,height:this.props.size,backgroundColor:e});return _.createElement("div",{style:t,onClick:this._flip})}}U(xf,"propTypes",{value:I.default.bool.isRequired,size:I.default.number.isRequired});class wf extends _.Component{render(){return _.createElement("div",{style:hf,className:"no-select"},M.default.map(this.props.cells,((e,t)=>_.createElement("div",{key:t,style:ff},M.default.map(e,((e,n)=>_.createElement("div",{key:n,style:mf},_.createElement(xf,{value:e,size:this.props.size,onChange:M.default.partial(this.props.onChange,t,n)}))))))))}}U(wf,"propTypes",{cells:I.default.arrayOf(I.default.arrayOf(I.default.bool)).isRequired,size:I.default.number.isRequired});const Cf=(e,t,n,o)=>((e,t)=>M.default.map(e,((e,n)=>M.default.map(e,((e,o)=>t(n,o)?!e:e)))))(e,((e,s)=>{const i=e-t,r=s-n;return Math.abs(i)<=1&&Math.abs(r)<=1&&o[i+1][r+1]}));class kf extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"_currPattern",void 0),U(this,"_nextPattern",void 0),U(this,"_patternIndex",void 0),U(this,"getUserInput",(()=>Lr.getUserInput.call(this))),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"_width",(()=>0!==this.props.cells.length?this.props.cells[0].length:0)),U(this,"_initNextPatterns",(()=>{this._currPattern=bf[this.props.flipPattern](0),this._nextPattern=bf[this.props.flipPattern](1),this._patternIndex=2})),U(this,"_shiftPatterns",(()=>{this._currPattern=this._nextPattern,this._nextPattern=bf[this.props.flipPattern](this._patternIndex),this._patternIndex++})),U(this,"_flipTile",((e,t)=>{const n=Cf(this.props.cells,e,t,this._currPattern);this._shiftPatterns(),this.change({cells:n,moveCount:this.props.moveCount+1})})),U(this,"_reset",(()=>{this.change({cells:this.props.startCells,moveCount:0})})),U(this,"simpleValidate",(e=>Sf(e,this.getUserInput())))}render(){const e=60*this._width();return _.createElement("div",null,_.createElement(wf,{cells:this.props.cells,size:50,onChange:this._flipTile}),_.createElement("div",{style:{width:e}},_.createElement("div",{style:vf},k.ngettext("Moves: %(num)s","Moves: %(num)s",this.props.moveCount)),_.createElement("div",{style:yf},_.createElement("input",{type:"button",value:"Reset",onClick:this._reset,className:"simple-button"}))),_.createElement("div",{className:"clearfix"}))}componentDidMount(){this._initNextPatterns()}componentDidUpdate(e){e.flipPattern!==this.props.flipPattern&&this._initNextPatterns()}}U(kf,"propTypes",{...pr,cells:I.default.arrayOf(I.default.arrayOf(I.default.bool)),startCells:I.default.arrayOf(I.default.arrayOf(I.default.bool)),flipPattern:I.default.string.isRequired,moveCount:I.default.number.isRequired}),U(kf,"defaultProps",{cells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",moveCount:0});const Sf=function(e,t){if(M.default.all(t.cells,((t,n)=>M.default.all(t,((t,o)=>t===e.startCells[n][o])))))return{type:"invalid",message:k._("Click on the tiles to change the lights.")};return M.default.all(t.cells,(e=>M.default.all(e,(e=>e))))?{type:"points",earned:1,total:1,message:null}:e.gradeIncompleteAsWrong?{type:"points",earned:0,total:1,message:null}:{type:"invalid",message:k._("You must turn on all of the lights to continue.")}};var Ef={name:"lights-puzzle",displayName:"Lights Puzzle",hidden:!0,widget:kf,transform:function(e){return{cells:e.startCells,startCells:e.startCells,flipPattern:e.flipPattern}}};const _f=(e,t)=>{const n=e.offsetParent();return{top:t.top+n.scrollTop(),left:t.left+n.scrollLeft()}};class Tf extends _.Component{render(){const{layout:e}=this.props,t=d.css(Pf.card,Pf.placeholder,"horizontal"===e&&Pf.horizontalCard),n={width:this.props.width,height:this.props.height};return null!=this.props.margin&&(n.margin=this.props.margin),_.createElement("li",{className:t,style:n})}}U(Tf,"propTypes",{layout:I.default.oneOf(["horizontal","vertical"]),width:I.default.number.isRequired,height:I.default.number.isRequired});class Mf extends _.Component{constructor(){super(...arguments),U(this,"animationFrameRequest",null),U(this,"isMouseMoveUpBound",void 0),U(this,"_mounted",void 0),U(this,"state",{startPosition:{left:0,top:0},startMouse:{left:0,top:0},mouse:{left:0,top:0}}),U(this,"getCurrentPosition",(()=>({left:this.state.startPosition.left+this.state.mouse.left-this.state.startMouse.left,top:this.state.startPosition.top+this.state.mouse.top-this.state.startMouse.top}))),U(this,"bindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!0,P.default(document).on("mousemove",this.onMouseMove),P.default(document).on("mouseup",this.onMouseUp)})),U(this,"unbindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!1,P.default(document).off("mousemove",this.onMouseMove),P.default(document).off("mouseup",this.onMouseUp)})),U(this,"onMouseDown",(e=>{if("static"!==this.props.type)return;if(0!==e.button&&(null==e.touches||1!==e.touches.length))return;e.preventDefault();const t=Ye.extractPointerLocation(e);this.animationFrameRequest=requestAnimationFrame((()=>{const e=P.default(N.default.findDOMNode(this)),n=e.position(),o=_f(e,n);t&&this._mounted&&this.setState({startPosition:o,startMouse:t,mouse:t,dragging:!0},(function(){this.bindMouseMoveUp(),this.props.onMouseDown()}))}))})),U(this,"onMouseMove",(e=>{if("dragging"!==this.props.type||!this.state.dragging)return;e.preventDefault();const t=Ye.extractPointerLocation(e);t&&(this.animationFrameRequest=requestAnimationFrame((()=>{this.setState({mouse:t},this.props.onMouseMove)})))})),U(this,"onMouseUp",(e=>{if("dragging"!==this.props.type||!this.state.dragging)return;e.preventDefault();Ye.extractPointerLocation(e)&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp())}))}componentDidMount(){this._mounted=!0,this.isMouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!Ye.supportsPassiveEvents()&&{passive:!1})}componentWillUnmount(){this._mounted=!1,this.isMouseMoveUpBound&&this.unbindMouseMoveUp(),this.animationFrameRequest&&cancelAnimationFrame(this.animationFrameRequest),document.removeEventListener("touchmove",this.onMouseMove)}render(){const{includePadding:e,layout:t,type:n}=this.props;let o=d.css(Pf.card,Pf.draggable,"horizontal"===t&&Pf.horizontalCard,"vertical"===t&&Pf.verticalCard,"dragging"===n&&Pf.dragging,"disabled"===n&&Pf.disabled,!e&&Pf.unpaddedCard)+" "+te.INTERACTIVE+" perseus-sortable-draggable";e||(o+=" perseus-sortable-draggable-unpadded");const s={position:"static"};return"dragging"!==this.props.type&&"animating"!==this.props.type||M.default.extend(s,{position:"absolute"},this.getCurrentPosition()),this.props.width&&(s.width=this.props.width+1),this.props.height&&(s.height=this.props.height),null!=this.props.margin&&(s.margin=this.props.margin),_.createElement("li",{className:o,style:s,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},_.createElement(qi,{content:this.props.content,linterContext:en.pushContextStack(this.props.linterContext,"draggable"),onRender:this.props.onRender}))}componentDidUpdate(e){if(this.props.type!==e.type)if("animating"===this.props.type){const e=this.getCurrentPosition(),t=15*Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left-e.left,2)+Math.pow(this.props.endPosition.top-e.top,2)));P.default(N.default.findDOMNode(this)).animate(this.props.endPosition,{duration:Math.max(t,1),complete:this.props.onAnimationEnd})}else"static"===this.props.type&&P.default(N.default.findDOMNode(this)).finish()}}U(Mf,"propTypes",{content:I.default.string.isRequired,endPosition:I.default.object.isRequired,includePadding:I.default.bool,layout:I.default.oneOf(["horizontal","vertical"]),onAnimationEnd:I.default.func.isRequired,onMouseDown:I.default.func.isRequired,onMouseMove:I.default.func.isRequired,onMouseUp:I.default.func.isRequired,onRender:I.default.func.isRequired,type:I.default.oneOf(["static","dragging","animating","disabled"]),linterContext:tn}),U(Mf,"defaultProps",{includePadding:!0,type:"static",linterContext:nn});class If extends _.Component{constructor(e){super(e),U(this,"remeasureItems",M.default.debounce((()=>{this.setState({items:If.clearItemMeasurements(this.state.items)})}),20)),this.state={items:If.itemsFromProps(this.props),katex:null}}UNSAFE_componentWillReceiveProps(e){const t=this.props;M.default.isEqual(e.options,t.options)?e.layout===t.layout&&e.padding===t.padding&&e.disabled===t.disabled&&M.default.isEqual(e.constraints,t.constraints)||this.setState({items:If.clearItemMeasurements(this.state.items)}):this.setState({items:If.itemsFromProps(e)})}componentDidUpdate(){!this.state.items.length||this.state.items[0].width||this.state.items[0].height||setTimeout((()=>{this.measureItems()}),0)}componentDidMount(){Y().getKaTeX().then((e=>{this.setState({katex:e})}))}static itemsFromProps(e){const t=e.disabled?"disabled":"static";return e.options.map(((e,n)=>({option:e,key:n,type:t,endPosition:{},width:0,height:0})))}static clearItemMeasurements(e){return e.map((e=>({...e,width:0,height:0})))}measureItems(){let e=M.default.clone(this.state.items);const t=M.default.map(e,(function(e){return P.default(N.default.findDOMNode(this.refs[e.key]))}),this),n=M.default.invoke(t,"outerWidth"),o=M.default.invoke(t,"outerHeight"),{constraints:s,layout:i}=this.props;let r=null;null!=s&&s.width?r=M.default.max(n.concat(s.width)):"vertical"===i&&(r=M.default.max(n));let a=null;null!=s&&s.height?a=M.default.max(o.concat(s.height)):"horizontal"===i&&(a=M.default.max(o)),e=M.default.map(e,(function(e,t){return e.width=r||n[t],e.height=a||o[t],e})),this.setState({items:e},(()=>{this.props.onMeasure&&this.props.onMeasure({widths:n,heights:o})}))}render(){var e,t;if(this.props.waitForKatexLoad&&!this.state.katex)return _.createElement(_p,null);const n=[],{layout:o}=this.props,s=d.css(Pf.sortable)+" perseus-sortable",i=(null===(e=this.props.constraints)||void 0===e?void 0:e.width)||"vertical"===o,r=(null===(t=this.props.constraints)||void 0===t?void 0:t.height)||"horizontal"===o;return M.default.each(this.state.items,(function(e,t,s){const a=t===s.length-1,l="static"===e.type||"disabled"===e.type;let c;"horizontal"===this.props.layout?c="0 "+this.props.margin+"px 0 0":"vertical"===this.props.layout&&(c="0 0 "+this.props.margin+"px 0"),n.push(_.createElement(Mf,{content:e.option,key:e.key,type:e.type,ref:e.key,width:i?e.width:void 0,height:r?e.height:void 0,layout:o,includePadding:this.props.padding,margin:a&&l?0:c,endPosition:e.endPosition,linterContext:en.pushContextStack(this.props.linterContext,"sortable"),onRender:this.remeasureItems,onMouseDown:this.onMouseDown.bind(this,e.key),onMouseMove:this.onMouseMove.bind(this,e.key),onMouseUp:this.onMouseUp.bind(this,e.key),onTouchMove:this.onMouseMove.bind(this,e.key),onTouchEnd:this.onMouseUp.bind(this,e.key),onTouchCancel:this.onMouseUp.bind(this,e.key),onAnimationEnd:this.onAnimationEnd.bind(this,e.key)})),"dragging"!==e.type&&"animating"!==e.type||n.push(_.createElement(Tf,{key:"placeholder_"+e.key,ref:"placeholder_"+e.key,width:e.width,height:e.height,layout:o,margin:a?0:c}))}),this),_.createElement("ul",{className:s},n)}onMouseDown(e){const t=M.default.map(this.state.items,(function(t){return t.key===e&&(t.type="dragging"),t}));this.setState({items:t})}moveOptionToIndex(e,t){const{items:n}=this.state;if(t<0||t>n.length)throw new Error("index ".concat(t," out of bounds"));const o=M.default.clone(n),s=n.filter((t=>t.option===e))[0];if(null==s)throw new Error("option ".concat(e," not found"));const i=n.findIndex((e=>e.key===s.key));o.splice(i,1),o.splice(t,0,s),this.setState({items:o}),this.props.onChange&&this.props.onChange({})}onMouseMove(e){const t=P.default(N.default.findDOMNode(this.refs[e])),n=P.default(N.default.findDOMNode(this)),o=M.default.clone(this.state.items),s=M.default.findWhere(this.state.items,{key:e}),i=this.props.margin||0,r=M.default.indexOf(o,s);let a=0;if(o.splice(r,1),"horizontal"===this.props.layout){const e=t.offset().left-n.offset().left;let s,r=0;M.default.each(o,(function(t){s=t.width,e>r+s/2&&(a+=1),r+=s+i}))}else{const e=t.offset().top-n.offset().top;let s,r=0;M.default.each(o,(function(t){s=t.height,e>r+s/2&&(a+=1),r+=s+i}))}a!==r&&(o.splice(a,0,s),this.setState({items:o}))}onMouseUp(e){const t=requestAnimationFrame((()=>{const t=M.default.map(this.state.items,(function(t){if(t.key===e){t.type="animating";const n=P.default(N.default.findDOMNode(this.refs["placeholder_"+e])),o=n.position(),s=_f(n,o);t.endPosition=s}return t}),this);this.setState({items:t}),this.props.onChange&&this.props.onChange({})}));this.animationFrameRequest=t}onAnimationEnd(e){const t=M.default.map(this.state.items,(function(t){return t.key===e&&(t.type="static"),t}));this.setState({items:t})}getOptions(){return M.default.pluck(this.state.items,"option")}}U(If,"defaultProps",{layout:"horizontal",padding:!0,disabled:!1,constraints:{},onMeasure:function(){},margin:5,onChange:function(){},linterContext:nn,waitForKatexLoad:!0});const Pf=d.StyleSheet.create({sortable:{boxSizing:"border-box",float:"left",padding:0,margin:0},card:{boxSizing:"border-box",background:"#fff",border:"1px solid #ddd",borderRadius:4,cursor:"pointer",minWidth:25,minHeight:44,padding:10,listStyleType:"none",userSelect:"none",touchAction:"none"},placeholder:{background:"#ddd",border:"1px solid #ccc"},draggable:{textAlign:"center"},horizontalCard:{float:"left",cursor:"ew-resize"},verticalCard:{maxWidth:"100%",cursor:"ns-resize"},unpaddedCard:{padding:0},dragging:{background:"#ffedcd",opacity:.8},disabled:{backgroundColor:"inherit",border:"1px solid transparent",cursor:"default"}}),{shuffle:Nf,seededRNG:Af}=Ye;class Rf extends _.Component{constructor(){super(...arguments),U(this,"state",{leftHeight:0,rightHeight:0,katex:null}),U(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),U(this,"onMeasureLeft",(e=>{const t=M.default.max(e.heights);this.setState({leftHeight:t})})),U(this,"onMeasureRight",(e=>{const t=M.default.max(e.heights);this.setState({rightHeight:t})})),U(this,"getUserInput",(()=>this.state.katex?{left:this.refs.left.getOptions(),right:this.refs.right.getOptions()}:{left:[],right:[]})),U(this,"moveLeftOptionToIndex",((e,t)=>{this.refs.left.moveOptionToIndex(e,t)})),U(this,"moveRightOptionToIndex",((e,t)=>{this.refs.right.moveOptionToIndex(e,t)})),U(this,"simpleValidate",(e=>Rf.validate(this.getUserInput(),e)))}componentDidMount(){Y().getKaTeX().then((e=>this.setState({katex:e})))}render(){if(!this.state.katex)return _.createElement(_p,null);const e=Af(this.props.problemNum);let t;t=this.props.orderMatters?Nf(this.props.left,e,!0):this.props.left;const n=Nf(this.props.right,e,!0),o=M.default.any(this.props.labels),s={height:M.default.max([this.state.leftHeight,this.state.rightHeight])},i=this.props.apiOptions.isMobile?8:5;return _.createElement("table",{className:d.css(Ff.widget)+" perseus-widget-matcher"},_.createElement("tbody",null,o&&_.createElement("tr",{className:d.css(Ff.row)},_.createElement("th",{className:d.css(Ff.column,Ff.columnLabel)},_.createElement(qi,{content:this.props.labels[0]||"...",linterContext:this.props.linterContext})),_.createElement("th",{className:d.css(Ff.column,Ff.columnRight,Ff.columnLabel)},_.createElement(qi,{content:this.props.labels[1]||"...",linterContext:this.props.linterContext}))),_.createElement("tr",{className:d.css(Ff.row)},_.createElement("td",{className:d.css(Ff.column)},_.createElement(If,{options:t,layout:"vertical",padding:this.props.padding,disabled:!this.props.orderMatters,constraints:s,onMeasure:this.onMeasureLeft,onChange:this.changeAndTrack,margin:i,linterContext:this.props.linterContext,ref:"left"})),_.createElement("td",{className:d.css(Ff.column,Ff.columnRight)},_.createElement(If,{options:n,layout:"vertical",padding:this.props.padding,constraints:s,onMeasure:this.onMeasureRight,onChange:this.changeAndTrack,margin:i,linterContext:this.props.linterContext,ref:"right"})))))}}U(Rf,"propTypes",{apiOptions:ee.propTypes,labels:I.default.array,left:I.default.array,onChange:I.default.func,orderMatters:I.default.bool,padding:I.default.bool,problemNum:I.default.number,right:I.default.array,trackInteraction:I.default.func.isRequired,linterContext:tn}),U(Rf,"defaultProps",{left:[],right:[],labels:["",""],orderMatters:!1,padding:!0,problemNum:0,onChange:function(){},linterContext:nn}),M.default.extend(Rf,{validate:function(e,t){return{type:"points",earned:M.default.isEqual(e.left,t.left)&&M.default.isEqual(e.right,t.right)?1:0,total:1,message:null}}});const Ff=d.StyleSheet.create({widget:{paddingTop:5,maxWidth:"100%",minWidth:"auto"},row:{border:0},column:{padding:0,border:0},columnRight:{borderLeft:"1px solid #444"},columnLabel:{fontWeight:"inherit",borderBottom:"1px solid #444",padding:"0 ".concat(5,"px ").concat(5,"px ").concat(5,"px"),textAlign:"center"}});var Of={name:"matcher",displayName:"Two column matcher",widget:Rf,isLintable:!0};const{firstNumericalParse:Df,captureScratchpadTouchStart:Lf}=Ye,Bf=Ce.toNumericString,zf=Ce.getNumericFormat;class qf extends _.Component{constructor(){super(...arguments),U(this,"state",{format:this.props.format}),U(this,"getValue",(()=>this.parseInputValue(N.default.findDOMNode(this.refs.input).value))),U(this,"getStringValue",(()=>N.default.findDOMNode(this.refs.input).value.toString())),U(this,"parseInputValue",(e=>{if(""===e){const e=this.props.placeholder;return M.default.isFinite(e)?+e:null}const t=Df(e);return M.default.isFinite(t)?t:this.props.value})),U(this,"focus",(()=>{N.default.findDOMNode(this.refs.input).focus(),this._handleFocus()})),U(this,"blur",(()=>{N.default.findDOMNode(this.refs.input).blur(),this._handleBlur()})),U(this,"setSelectionRange",((e,t)=>{N.default.findDOMNode(this).setSelectionRange(e,t)})),U(this,"getSelectionStart",(()=>N.default.findDOMNode(this).selectionStart)),U(this,"getSelectionEnd",(()=>N.default.findDOMNode(this).selectionEnd)),U(this,"_checkValidity",(e=>{if(null==e)return!0;const t=Df(e),n=this.props.checkValidity;return M.default.isFinite(t)&&n(t)})),U(this,"_handleChange",(e=>{const t=e.target.value,n=this.parseInputValue(t),o=zf(t);this.props.onChange(n),o&&(this.props.onFormatChange(n,o),this.setState({format:o}))})),U(this,"_handleFocus",(()=>{this.props.onFocus&&this.props.onFocus()})),U(this,"_handleBlur",(e=>{e&&"keypress"===e.type&&13!==e.keyCode||(this._setValue(this.props.value,this.state.format),this.props.onBlur&&this.props.onBlur())})),U(this,"_onKeyDown",(e=>{if(this.props.onKeyDown&&this.props.onKeyDown(e),!this.props.useArrowKeys||!M.default.contains(["ArrowUp","ArrowDown"],e.key))return;let t=this.getValue();t===Math.floor(t)&&("ArrowUp"===e.key?t+=1:"ArrowDown"===e.key&&(t-=1),this._checkValidity(t)&&this.props.onChange(t))})),U(this,"_setValue",((e,t)=>{P.default(N.default.findDOMNode(this.refs.input)).val(Bf(e,t))}))}render(){let e=S.default({"number-input":!0,"invalid-input":!this._checkValidity(this.props.value),mini:"mini"===this.props.size,small:"small"===this.props.size,normal:"normal"===this.props.size});null!=this.props.className&&(e=e+" "+this.props.className);const{onFormatChange:t,checkValidity:n,useArrowKeys:o,...s}=this.props;return _.createElement("input",G({},s,{className:e,type:"text",ref:"input",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,onKeyPress:this._handleBlur,onKeyDown:this._onKeyDown,onTouchStart:Lf,defaultValue:Bf(this.props.value,this.state.format),value:void 0}))}componentDidUpdate(e){p.number.equal(this.getValue(),this.props.value)||this._setValue(this.props.value,this.state.format)}}U(qf,"propTypes",{value:I.default.number,format:I.default.string,placeholder:I.default.oneOfType([I.default.string,I.default.number]),onChange:I.default.func.isRequired,onFormatChange:I.default.func,checkValidity:I.default.func,size:I.default.string,label:I.default.oneOf(["put your labels outside your inputs!"])}),U(qf,"defaultProps",{value:null,placeholder:null,format:null,onFormatChange:()=>null,checkValidity:()=>!0,useArrowKeys:!1});const{assert:Hf}=mn,{stringArrayOfSize:Wf}=Ye,Uf={INPUT_MARGIN:4,INPUT_HEIGHT:38,INPUT_WIDTH:82},Gf={INPUT_MARGIN:3,INPUT_HEIGHT:30,INPUT_WIDTH:40},Vf={INPUT_MARGIN:4,INPUT_HEIGHT:36,INPUT_WIDTH:64};function jf(e,t){return[""+e,""+t]}const Yf=function(){return jf(0,0)},$f=function(e){return Hf(M.default.isArray(e)&&2===e.length),+e[0]},Xf=function(e){return Hf(M.default.isArray(e)&&2===e.length),+e[1]},Kf=function(e){return"answer"+$f(e)+","+Xf(e)},Zf=function(e){const t=[1,1];return M.default(e).each(((e,n)=>{let o=0;M.default(e).each(((e,t)=>{null!=e&&e.toString().length&&(o=t+1)})),t[1]=Math.max(t[1],o),o>0&&(t[0]=Math.max(t[0],n+1))})),t};class Jf extends _.Component{constructor(){super(...arguments),U(this,"cursorPosition",void 0),U(this,"state",{enterTheMatrix:0}),U(this,"getInputPaths",(()=>{const e=[],t=this.props.matrixBoardSize[0],n=this.props.matrixBoardSize[1];return M.default(t).times((t=>{M.default(n).times((n=>{const o=jf(t,n);e.push(o)}))})),e})),U(this,"getGrammarTypeForPath",(e=>"number")),U(this,"_handleFocus",((e,t)=>{this.props.onFocus(jf(e,t))})),U(this,"_handleBlur",((e,t)=>{this.props.onBlur(jf(e,t))})),U(this,"focus",(()=>(this.focusInputPath(Yf()),!0))),U(this,"focusInputPath",(e=>{const t=Kf(e);this.refs[t].focus()})),U(this,"blurInputPath",(e=>{0===e.length&&(e=Yf());const t=Kf(e);this.refs[t].blur()})),U(this,"getDOMNodeForPath",(e=>{const t=Kf(e);return N.default.findDOMNode(this.refs[t])})),U(this,"setInputValue",((e,t,n)=>{const o=$f(e),s=Xf(e);this.onValueChange(o,s,t,n)})),U(this,"handleKeyDown",((e,t,n)=>{const o=this.props.matrixBoardSize[0],s=this.props.matrixBoardSize[1];let i=null;const r=this.refs[Kf(jf(e,t))],a=r.getStringValue(),l=r.getSelectionStart(),c=r.getSelectionEnd();let d=null;if("ArrowUp"===n.key&&e>0?d=jf(e-1,t):"ArrowDown"===n.key&&e+1<o?d=jf(e+1,t):"ArrowLeft"===n.key&&t>0?0===l&&0===c&&(d=jf(e,t-1)):"ArrowRight"===n.key&&t+1<s?l===a.length&&(d=jf(e,t+1)):"Enter"===n.key?i=this.state.enterTheMatrix+1:"Escape"===n.key&&(i=0),d){n.preventDefault();const e=this.refs[Kf(d)],t=2*e.getStringValue().length;e.focus(),"ArrowRight"===n.key?e.setSelectionRange(0,0):e.setSelectionRange(t,t)}null!=i&&this.setState({enterTheMatrix:i})})),U(this,"onValueChange",((e,t,n,o)=>{const s=M.default.map(this.props.answers,M.default.clone);s[e]||(s[e]=[]),s[e][t]=n,this.props.onChange({answers:s},o),this.props.trackInteraction()})),U(this,"getUserInput",(()=>({answers:this.props.answers}))),U(this,"simpleValidate",(e=>Jf.validate(this.getUserInput(),e)))}componentDidMount(){this.cursorPosition=[0,0]}render(){let e;e=this.props.apiOptions.customKeypad?Vf:this.props.apiOptions.staticRender?Uf:Gf;const{INPUT_MARGIN:t,INPUT_HEIGHT:n,INPUT_WIDTH:o}=e,s=Zf(this.props.answers),i=this.props.matrixBoardSize[0],r=this.props.matrixBoardSize[1],a=this.props.cursorPosition[0],l=this.props.cursorPosition[1],c=Math.max(a,s[0]-1),d=Math.max(l,s[1]-1),p=(c+1)*(n+2*t),u=(d+1)*(o+2*t),h=S.default({"perseus-matrix":!0,"static-mode":this.props.static,"the-matrix":this.state.enterTheMatrix>=5});return _.createElement("div",{className:h},this.props.prefix&&_.createElement("div",{className:"matrix-prefix"},_.createElement(qi,{content:this.props.prefix,linterContext:this.props.linterContext})),_.createElement("div",{className:"matrix-input"},_.createElement("div",{className:"matrix-bracket bracket-left",style:{height:p}}),_.createElement("div",{className:"matrix-bracket bracket-right",style:{height:p,left:u}}),M.default(i).times((e=>{const s=this.props.answers[e];return _.createElement("div",{className:"matrix-row",key:e},M.default(r).times((i=>{const r=e>c||i>d,a={className:r?"outside":"inside",ref:Kf(jf(e,i)),value:s?s[i]:null,style:{height:n,width:o,margin:t},disabled:this.props.apiOptions.readOnly,onFocus:()=>{this.cursorPosition=[e,i],this.props.onChange({cursorPosition:[e,i]},(()=>!1)),this._handleFocus(e,i)},onBlur:()=>{e===this.cursorPosition[0]&&i===this.cursorPosition[1]&&this.props.onChange({cursorPosition:[0,0]},(()=>!1)),this._handleBlur(e,i)},onKeyDown:t=>{this.handleKeyDown(e,i,t)},onChange:(t,n)=>{this.onValueChange(e,i,t,n)}};let l;if(this.props.apiOptions.customKeypad){const e={margin:t,minWidth:o,minHeight:n,boxSizing:"border-box",backgroundColor:r?"#f3f3f3":"#fff"};l=_.createElement(Sr,G({},a,{style:e,scrollable:!0,keypadElement:this.props.keypadElement}))}else l=this.props.apiOptions.staticRender?_.createElement(le,a):this.props.numericInput?_.createElement(qf,a):_.createElement(Zi,a);return _.createElement("span",{key:i,className:"matrix-input-field"},l)})))}))),this.props.suffix&&_.createElement("div",{className:"matrix-suffix"},_.createElement(qi,{content:this.props.suffix,linterContext:this.props.linterContext})))}}U(Jf,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0],apiOptions:ee.defaults,linterContext:nn}),M.default.extend(Jf,{validate:function(e,t){const n=t.answers,o=e.answers,s=Zf(n),i=Zf(o),r=s[0]!==i[0]||s[1]!==i[1],a=Ee.number.createValidatorFunctional;let l=null,c=!1,d=!1;return M.default(i[0]).times((e=>{M.default(i[1]).times((t=>{if(null!=o[e][t]&&0!==o[e][t].toString().length||(c=!0),!r){const s=a(n[e][t],{simplify:!0})(o[e][t]);s.message&&(l=s.message),s.correct||(d=!0)}}))})),c?{type:"invalid",message:k._("Make sure you fill in all cells in the matrix.")}:r?{type:"points",earned:0,total:1,message:null}:{type:"points",earned:d?0:1,total:1,message:l}}});var Qf={name:"matrix",displayName:"Matrix",widget:Jf,transform:e=>{const t=M.default(e.matrixBoardSize[0]).times((function(){return Wf(e.matrixBoardSize[1])}));return e=M.default.pick(e,"matrixBoardSize","prefix","suffix"),M.default.extend(e,{answers:t})},staticTransform:e=>{const t=M.default.pick(e,"matrixBoardSize","prefix","suffix");return t.answers=M.default.map(e.answers,(e=>M.default.map(e,(e=>null!=e?String(e):"")))),t},isLintable:!0};const em={url:null,top:0,left:0},tm=O.default({displayName:"Measurer",propTypes:{apiOptions:ee.propTypes,box:I.default.arrayOf(I.default.number),image:I.default.shape({url:I.default.string,top:I.default.number,left:I.default.number}),showProtractor:I.default.bool,protractorX:I.default.number,protractorY:I.default.number,showRuler:I.default.bool,rulerLabel:I.default.string,rulerTicks:I.default.number,rulerPixels:I.default.number,rulerLength:I.default.number},getDefaultProps:function(){return{box:[480,480],image:{},showProtractor:!0,protractorX:7.5,protractorY:.5,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10}},getInitialState:function(){return{}},render:function(){const e=M.default.extend({},em,this.props.image);return _.createElement("div",{className:"perseus-widget perseus-widget-measurer graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]}},e.url&&_.createElement("div",{style:{position:"relative",top:e.top,left:e.left}},_.createElement(Ys,{src:e.url})),_.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this.setupGraphie()},componentDidUpdate:function(e){M.default.any(["box","showProtractor","showRuler","rulerLabel","rulerTicks","rulerPixels","rulerLength"],(function(t){return e[t]!==this.props[t]}),this)&&this.setupGraphie()},setupGraphie:function(){const e=N.default.findDOMNode(this.refs.graphieDiv);P.default(e).empty();const t=this.graphie=En.createGraphie(e),n=[40,40],o=[[0,this.props.box[0]/n[0]],[0,this.props.box[1]/n[1]]];t.init({range:o,scale:n}),t.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),this.protractor&&this.protractor.remove(),this.props.showProtractor&&(this.protractor=t.protractor([this.props.protractorX,this.props.protractorY])),this.ruler&&this.ruler.remove(),this.props.showRuler&&(this.ruler=t.ruler({center:[(o[0][0]+o[0][1])/2,(o[1][0]+o[1][1])/2],label:this.props.rulerLabel,pixelsPerUnit:this.props.rulerPixels,ticksPerUnit:this.props.rulerTicks,units:this.props.rulerLength}))},getUserInput:function(){return{}},simpleValidate:function(e){return tm.validate(this.getUserInput(),e)},focus:P.default.noop});M.default.extend(tm,{validate:function(e,t){return{type:"points",earned:1,total:1,message:null}}});var nm={name:"measurer",displayName:"Measurer",widget:tm,version:{major:1,minor:0},propUpgrades:{1:e=>M.default(e).chain().omit("imageUrl","imageTop","imageLeft").extend({image:{url:e.imageUrl,top:e.imageTop,left:e.imageLeft}}).value()}};function om(e,t){const n=new Path2D;e.lineWidth=lm.lineWidth,e.strokeStyle=lm.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n)}const sm={text:function(e,t){null!==t.value&&(e.fillStyle=lm.fgColor,e.font=lm.font,e.fillText(t.value,t.pos[0]-lm.fontSizePx/2+1,t.pos[1]+lm.fontSizePx/2))},"line:single":om,"line:double":function(e,t){let n=new Path2D;e.lineWidth=5*lm.lineWidth,e.strokeStyle=lm.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),n=new Path2D,e.lineWidth=3*lm.lineWidth,e.strokeStyle=lm.bgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n)},"line:triple":function(e,t){let n=new Path2D;e.lineWidth=7*lm.lineWidth,e.strokeStyle=lm.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),n=new Path2D,e.lineWidth=5*lm.lineWidth,e.strokeStyle=lm.bgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),om(e,t)}};const im={"line:single":0,"line:double":0,"line:triple":0,text:1};function rm(e,t){return im[e.type]-im[t.type]}function am(e,t){t.sort(rm).forEach(function(e){return function(t){sm[t.type](e,t)}}(e))}const lm={bgColor:"rgb(255, 255, 255)",fgColor:"rgb(0, 0, 0)",fontSizePx:12,lineWidth:1,font:"12px sans"};function cm(e,t,n,o){let s=e.symbol;if("C"===s&&1!==Object.keys(t).length&&(s=null),"1,0"===e.idx){const t=[0,0];return e.pos=t,e.baseAngle=-30+o,{type:"text",value:s,pos:t,idx:e.idx}}const i=t[e.connections.find((function(e){return t[e].pos}))],r=i.connections.indexOf(e.idx);let a=60,l=120;4===i.connections.length?(l=90,a=90):(n.find((t=>"triple"===t.bondType&&t.to===e.idx))||n.find((e=>"triple"===e.bondType&&e.to===i.idx)))&&(l=0,a=0);let c=0;const d=i.idx.split(":"),p=d[d.length-1].split(",")[0];c=parseInt(p)%2!=0?i.baseAngle-(a-l*r):i.baseAngle+(a-l*r);const u=function(e,t,n){const o=e[0],s=e[1];return[o+Math.cos(2*t*Math.PI/360)*n,s+-1*Math.sin(2*t*Math.PI/360)*n]}(i.pos,c,30);return e.pos=u,e.baseAngle=c,{type:"text",value:s,pos:u,idx:e.idx}}function dm(e,t){const n=function(e,t){let n=[e.pos[0],e.pos[1]],o=[t.pos[0],t.pos[1]];return"C"!==e.symbol&&(n=[t.pos[0]-.75*(t.pos[0]-e.pos[0]),t.pos[1]-.75*(t.pos[1]-e.pos[1])]),"C"!==t.symbol&&(o=[e.pos[0]-.75*(e.pos[0]-t.pos[0]),e.pos[1]-.75*(e.pos[1]-t.pos[1])]),[n,o]}(t[e.from],t[e.to]);return{type:"line:"+e.bondType,startPos:n[0],endPos:n[1]}}function pm(e){return e.join(":")}function um(e,t,n){if(null===n)return[e,t];if("atom"===n.type){const o=pm(n.idx);e[o]={idx:o,symbol:n.symbol,connections:[]},n.bonds&&n.bonds.forEach((function(n){const s=pm(n.to.idx);e[o].connections.push(s),t.push({from:o,to:s,bondType:n.bondType}),um(e,t,n.to),e[s].connections.push(o)}))}return[e,t]}function hm(e,t,n,o,s){if(0===t.length)return e;const i=t.shift(),r=n[i];return r.connections.forEach((function(e){n[e].pos||t.push(e)})),hm(e.concat(cm(r,n,o,s)),t,n,o,s)}function fm(e,t,n){return 0===n.length?e:fm(e.concat(dm(n[0],t)),t,n.slice(1))}var mm={layout:function(e,t){const n=um({},[],e),o=n[0],s=n[1];return fm(hm([],["1,0"],o,s,t),o,s)},_atomLayout:cm,_bondLayout:dm,_bondLength:30,_convertTree:um};const gm=new RegExp("^[A-Za-z\\[\\]()=#+-]*$"),vm=new RegExp("^(Cl|Br|[CONPSFBI]|\\[)");function ym(e){this.message=e}function bm(e,t,n){const o=t[0],s=t.slice(1);let i;i=Array.isArray(e)?[...e]:{...e||{}};let r=n;return s.length>0&&(r=bm(i[o],s,n)),i[o]=r,i}function xm(e,t){if(0===t.length)return e;if(""===e)throw new ym("Mismatched parentheses");const n=e[0],o=e.slice(1);return xm(o,"("===n?t.concat(n):")"===n?t.slice(1):t)}function wm(e,t){const n=e[0],o=e.slice(1);if("("===n){let e={...t,parens:t.parens+"("};e=function(e,t){const n=t.reduce((function(e,t){return e[t]}),e);return bm(e,t,n+1)}(t,["idx",t.idx.length-1,1]);let n=-1;t.idx[t.idx.length-1][0]%2==0&&(n=0);const s=km(o,{...e,idx:e.idx.concat([[n,0]]),parens:e.parens.concat("(")}),i=km(xm(o,["("]),e);return[s].concat(i)}if(")"===n){if("("!==t.parens[t.parens.length-1])throw new ym("Mismatched parentheses");return null}throw new ym("Invalid bare character: "+n)}function Cm(e,t){const n=function(e,t){let n=null,o=null;if("["===e[0]){const t=e.indexOf("]");if(-1===t)return["",e];n=e.slice(1,t),o=e.slice(t+1)}else n=vm.exec(e)[1],o=e.slice(n.length);return[n,o]}(e),o=n[0];if(""===o)return["error","Unable to parse bracketed atom."];const s=n[1],i=bm(t,["idx",t.idx.length-1],[1+t.idx[t.idx.length-1][0],0]);let r=km(s,bm(i,["bond","bondType"],"single"));!Array.isArray(r)&&r&&(r=[r]);const a={type:"atom",symbol:o,bonds:r,idx:i.idx};return t.bond?{type:"bond",bondType:t.bond.bondType,to:a}:a}function km(e,t){if(!function(e){return gm.test(e)}(e))throw new ym("Invalid input.");return e&&0!==e.length?(n=e,vm.test(n)?Cm(e,t||{idx:[[0,0]],parens:[],stack:[],bondModifiers:[]}):function(e){return"="===e||"#"===e}(e[0])?function(e,t){const n=e[0],o=e.slice(1);if("="===n)return km(o,bm(t,["bond","bondType"],"double"));if("#"===n)return km(o,bm(t,["bond","bondType"],"triple"));throw new ym("Invalid character: "+n)}(e,t):wm(e,t)):null;var n}var Sm=km,Em=ym;const{layout:_m}=mm,Tm=Sm,Mm=Em;class Im extends _.Component{constructor(){super(...arguments),U(this,"state",{parsedSmiles:null,error:null}),U(this,"stateFromSmiles",(e=>{try{this.setState({parsedSmiles:Tm(e),error:null})}catch(e){if(!(e instanceof Mm))throw e;this.setState({error:e.message})}})),U(this,"setCanvasBounds",((e,t)=>{const n=Math.max(...t.map((e=>e.pos?e.pos[0]:-1/0))),o=Math.max(...t.map((e=>e.pos?e.pos[1]:-1/0))),s=Math.min(...t.map((e=>e.pos?e.pos[0]:1/0))),i=Math.min(...t.map((e=>e.pos?e.pos[1]:1/0))),r=n-s+60,a=o-i+60;return e.width=r,e.height=a,[30-s,30-i]})),U(this,"canvasRender",(()=>{if(this.state.error||!this.state.parsedSmiles)return;const e=_m(this.state.parsedSmiles,this.props.rotationAngle),t=this.refs.canvas,n=this.setCanvasBounds(t,e),o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),o.save(),o.translate(n[0],n[1]),am(o,e),o.restore()}))}UNSAFE_componentWillMount(){this.stateFromSmiles(this.props.smiles)}componentDidMount(){this.canvasRender()}UNSAFE_componentWillReceiveProps(e){this.stateFromSmiles(e.smiles)}componentDidUpdate(){this.canvasRender()}render(){let e=_.createElement("canvas",{className:"molecule-canvas",id:this.props.id+"-molecule",ref:"canvas"},k.$_("A molecular structure drawing. SMILES notation: %(content)s",{content:this.props.smiles}));return this.state.error&&(e=_.createElement("div",{className:"error"},this.state.error)),_.createElement("div",{className:"molecule-canvas"},e)}}U(Im,"propTypes",{id:I.default.string.isRequired,rotationAngle:I.default.number,smiles:I.default.string});class Pm extends _.Component{constructor(){super(...arguments),U(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),U(this,"getUserInput",(()=>[])),U(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null})))}render(){return _.createElement(Im,{id:this.props.widgetId,smiles:this.props.smiles,rotationAngle:this.props.rotationAngle})}}U(Pm,"propTypes",{rotationAngle:I.default.number,smiles:I.default.string,widgetId:I.default.string}),U(Pm,"defaultProps",{rotationAngle:0});var Nm={name:"molecule-renderer",displayName:"Molecule renderer",hidden:!0,widget:Pm};const Am=Rs.MovablePoint,Rm=Rs.Line,{assert:Fm}=mn,Om={ge:"le",gt:"lt",le:"ge",lt:"gt"},Dm={ge:"gt",gt:"ge",le:"lt",lt:"le"};function Lm(e,t){return 1===t?""+e:"\\dfrac{".concat(e,"}{").concat(t,"}")}function Bm(e,t){if(e<0)return"-"+Bm(-e,t);const n=Math.floor(e/t);return 0===n?Lm(e,t):e-n*t==0?""+n:n+Lm(e-n*t,t)}const zm=(e,t,n,o,s)=>{if(o=o||n,"decimal"===t||"decimal ticks"===t)return e.label([n,-.53],Math.round(100*o)/100,"center");if("improper"===t){const t=Ce.toFraction(o);return e.label([n,-.17],Lm(t[0],t[1]),"below")}if("mixed"===t){const t=Ce.toFraction(o);return e.label([n,-.17],Bm(t[0],t[1]),"below")}if("non-reduced"===t){const t=Ce.toFraction(o);return e.label([n,-.17],function(e,t,n){return Lm(e*Math.floor(n/t),n)}(t[0],t[1],s),"below")}},qm=Rs.createSimpleClass(((e,t)=>{if(!M.default.isFinite(t.tickStep)||t.tickStep<=0)return[];const n=[],o=t.range,s=t.labelRange,i=null==s[0]?o[0]:s[0],r=null==s[1]?o[1]:s[1];let a;if("non-reduced"===t.labelStyle){const e=[i,r];for(let n=0;n<=t.numDivisions;n++){const s=o[0]+n*t.tickStep;e.push(s)}const n=e=>p.number.toFraction(e)[1],s=M.default.map(e,n);a=M.default.reduce(s,((e,t)=>Ce.getLCM(e,t)))}else a=void 0;for(let s=0;s<=t.numDivisions;s++){const i=o[0]+s*t.tickStep;n.push(e.line([i,-.2],[i,.2]));(t.labelTicks||"decimal ticks"===t.labelStyle)&&n.push(zm(e,t.labelStyle,i,i,a))}return n.push(e.style(t.isMobile?{color:bn.BLUE_D}:{},(()=>zm(e,t.labelStyle,i,i,a)))),n.push(e.style(t.isMobile?{color:bn.BLUE_D}:{},(()=>zm(e,t.labelStyle,r,r,a)))),e.style({stroke:t.isMobile?bn.BLUE_D:bn.DYNAMIC,strokeWidth:3.5},(()=>{n.push(e.line([i,-.2],[i,.2])),n.push(e.line([r,-.2],[r,.2]))})),n}));class Hm extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"state",{numDivisionsEmpty:!1}),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"isValid",(()=>{const e=this.props.range;let t=this.props.numLinePosition;const n=this.props.divisionRange;return t=null==t?e[0]:t,e[0]<e[1]&&p.number.sign(t-e[0])>=0&&p.number.sign(t-e[1])<=0&&n[0]<n[1]&&0<this.props.numDivisions&&0<this.props.snapDivisions})),U(this,"onNumDivisionsChange",((e,t)=>{const n=this.props.divisionRange.slice(),o=this.props.range[1]-this.props.range[0];if(e=(e=Math.round(e))<0?-1*e:e){const s=M.default.extend({},this.props,{tickStep:o/e}),i=this.snapNumLinePosition(s,this.props.numLinePosition);this.setState({numDivisionsEmpty:!1},(()=>{this.props.onChange({divisionRange:n,numDivisions:e,numLinePosition:i},t)}))}else this.setState({numDivisionsEmpty:!0},t)})),U(this,"_handleTickCtrlFocus",(()=>{this.props.onFocus(["tick-ctrl"])})),U(this,"_handleTickCtrlBlur",(()=>{this.props.onBlur(["tick-ctrl"])})),U(this,"focus",(()=>{if(this.props.isTickCtrl)return this.refs["tick-ctrl"].focus(),!0})),U(this,"focusInputPath",(e=>{1===e.length&&this.refs[e[0]].focus()})),U(this,"blurInputPath",(e=>{1===e.length&&this.refs[e[0]].blur()})),U(this,"getInputPaths",(()=>this.props.isTickCtrl?[["tick-ctrl"]]:[])),U(this,"getDOMNodeForPath",(e=>{if(1===e.length)return N.default.findDOMNode(this.refs[e[0]])})),U(this,"getGrammarTypeForPath",(e=>{if(1===e.length&&"tick-ctrl"===e[0])return"number"})),U(this,"setInputValue",((e,t,n)=>{1===e.length&&"tick-ctrl"===e[0]&&this.onNumDivisionsChange(t,n)})),U(this,"_renderGraphie",(()=>{const e=this.props.range,t=e[1]-e[0],n=M.default.pick(this.props,["range","isTickCtrl"]),o=M.default.extend({},this.props,{tickStep:t/this.props.numDivisions});return _.createElement(Rs,{ref:"graphie",key:this.props.labelStyle,box:[this.props.apiOptions.isMobile?288:460,80],options:n,onMouseDown:e=>{this.refs.graphie.movables.numberLinePoint.grab(e)},setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile},_.createElement(qm,G({},M.default.pick(o,["range","numDivisions","labelTicks","labelStyle","labelRange","tickStep"]),{isMobile:this.props.apiOptions.isMobile})),this._renderInequality(o),this._renderNumberLinePoint(o))})),U(this,"snapNumLinePosition",((e,t)=>{const n=e.range[0],o=e.range[1],s=e.tickStep/e.snapDivisions;let i=((e,t,n)=>Math.min(Math.max(e,t),n))(t,n,o);return i=n+p.number.roundTo(i-n,s),Fm(M.default.isFinite(i)),i})),U(this,"movePosition",(e=>{this.change({numLinePosition:e}),this.props.trackInteraction()})),U(this,"_renderNumberLinePoint",(e=>{const t=M.default(["lt","gt"]).contains(e.rel);let n;n=t?bn._BACKGROUND:e.static?bn.DYNAMIC:bn.INTERACTIVE;const o={fill:n,stroke:e.static?bn.DYNAMIC:bn.INTERACTIVE,"stroke-width":t?3:1},s={fill:t?bn._BACKGROUND:bn.INTERACTING,"stroke-width":t?3:1},i=e.isInequality?{stroke:bn.INTERACTIVE,"fill-opacity":t?0:1}:{};return _.createElement(Am,{ref:"numberLinePoint",pointSize:6,coord:[e.numLinePosition,0],constraints:[(e,t)=>[e[0],t[1]],(t,n)=>[this.snapNumLinePosition(e,t[0]),t[1]]],normalStyle:o,highlightStyle:s,onMove:e=>{this.movePosition(e[0])},isMobile:this.props.apiOptions.isMobile,mobileStyleOverride:i,showTooltips:this.props.showTooltips,xOnlyTooltip:!0})})),U(this,"handleReverse",(()=>{const e=Om[this.props.rel];this.props.onChange({rel:e})})),U(this,"handleToggleStrict",(()=>{const e=Dm[this.props.rel];this.props.onChange({rel:e})})),U(this,"_getInequalityEndpoint",(e=>{const t=M.default(["ge","gt"]).contains(e.rel),n=e.range,o=30*((n[1]-n[0])/400),s=n[0]-o,i=n[1]+o;return t?[i,0]:[s,0]})),U(this,"_renderInequality",(e=>{if(e.isInequality){const t=this._getInequalityEndpoint(e),n={arrows:"->",stroke:this.props.apiOptions.isMobile?bn.INTERACTIVE:bn.DYNAMIC,strokeWidth:3.5},o=["ge","gt"].includes(e.rel);return _.createElement(Rm,{start:[(o?.4:-.4)+e.numLinePosition,0],end:t,style:n})}return null})),U(this,"_setupGraphie",((e,t)=>{if(!this.isValid())return;const n=this.props.apiOptions.isMobile?228:400,o=t.range,s=(o[1]-o[0])/n,i=30*s,r=o[0]-i,a=o[1]+i,l="improper"===this.props.labelStyle||"mixed"===this.props.labelStyle||"non-reduced"===this.props.labelStyle?-1.5:-1;e.init({range:[[r,a],[l,1]],scale:[1/s,40],isMobile:this.props.apiOptions.isMobile});const c=(o[0]+o[1])/2;e.line([c,0],[a,0],{arrows:"->"}),e.line([c,0],[r,0],{arrows:"->"})})),U(this,"getUserInput",(()=>({numLinePosition:this.props.numLinePosition,rel:this.props.isInequality?this.props.rel:"eq",numDivisions:this.props.numDivisions,divisionRange:this.props.divisionRange}))),U(this,"simpleValidate",(e=>Hm.validate(this.getUserInput(),e)))}render(){const e=this.props.divisionRange,t=e[0]+"–"+e[1],n=this.props.numDivisions<e[0]||this.props.numDivisions>e[1],o=_.createElement("div",null,_.createElement("input",{type:"button",className:"simple-button",value:k._("Switch direction"),onClick:this.handleReverse}),_.createElement("input",{type:"button",className:"simple-button",value:M.default(["le","ge"]).contains(this.props.rel)?k._("Make circle open"):k._("Make circle filled"),onClick:this.handleToggleStrict}));let s;if(this.props.isTickCtrl){let t;t=this.props.apiOptions.customKeypad?Sr:this.props.apiOptions.staticRender?le:qf,s=_.createElement("label",null,k._("Number of divisions:")," ",_.createElement(t,{ref:"tick-ctrl",value:this.state.numDivisionsEmpty?null:this.props.numDivisions||e[0],checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onNumDivisionsChange,onFocus:this._handleTickCtrlFocus,onBlur:this._handleTickCtrlBlur,useArrowKeys:!0,keypadElement:this.props.keypadElement}))}return _.createElement("div",{className:"perseus-widget perseus-widget-interactive-number-line"},s,this.isValid()?this.props.isTickCtrl&&n?_.createElement("div",{className:"perseus-error"},k.$_("Please make sure the number of divisions is in the range %(divRangeString)s.",{divRangeString:t})):this._renderGraphie():_.createElement("div",{className:"perseus-error"},k.doNotTranslate("Invalid number line configuration.")),!this.props.static&&this.props.isInequality&&o)}}U(Hm,"defaultProps",{range:[0,10],labelStyle:"decimal",labelRange:[null,null],divisionRange:[1,12],labelTicks:!0,isTickCtrl:!1,isInequality:!1,numLinePosition:0,snapDivisions:2,showTooltips:!1,rel:"ge",apiOptions:ee.defaults}),M.default.extend(Hm,{validate:function(e,t){const n=t.range,o=e.divisionRange,s=null!=t.initialX?t.initialX:n[0],i=t.isInequality?"ge":"eq",r=t.correctRel||"eq",a=p.number.equal(e.numLinePosition,t.correctX||0),l=e.numDivisions>o[1]||e.numDivisions<o[0];return e.isTickCrtl&&l?{type:"invalid",message:"Number of divisions is outside the allowed range."}:a&&r===e.rel?{type:"points",earned:1,total:1,message:null}:e.numLinePosition===s&&e.rel===i?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var Wm={name:"number-line",displayName:"Number line",widget:Hm,transform:e=>{const t=M.default.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isTickCtrl","isInequality","showTooltips"]),n=null!=e.initialX?e.initialX:e.range[0],o=e.range[1]-e.range[0];let s;return s=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?o/e.tickStep:void 0,M.default.extend(t,{numLinePosition:n,numDivisions:s,snapDivisions:t.snapDivisions||void 0}),t},staticTransform:e=>{const t=M.default.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isInequality"]),n=null!=e.correctX?e.correctX:e.range[0],o=e.range[1]-e.range[0];let s;return s=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?o/e.tickStep:void 0,M.default.extend(t,{numLinePosition:n,numDivisions:s,rel:e.isInequality?e.correctRel:null,snapDivisions:t.snapDivisions||void 0}),t}};class Um extends _.Component{render(){return _.createElement("div",{className:"card-wrap "+te.INTERACTIVE,style:{width:this.props.width}},_.createElement("div",{className:"card placeholder",style:{height:this.props.height}}))}}U(Um,"propTypes",{width:I.default.number.isRequired,height:I.default.number.isRequired});class Gm extends _.Component{render(){return _.createElement("div",{className:"card-wrap "+te.INTERACTIVE},_.createElement("div",{className:"card drag-hint"}))}}const Vm=I.default.shape({left:I.default.number,top:I.default.number});class jm extends _.Component{constructor(){super(...arguments),U(this,"mouseMoveUpBound",void 0),U(this,"state",{dragging:!1}),U(this,"bindMouseMoveUp",(()=>{this.mouseMoveUpBound=!0,P.default(document).on("mousemove",this.onMouseMove),P.default(document).on("mouseup",this.onMouseUp)})),U(this,"unbindMouseMoveUp",(()=>{this.mouseMoveUpBound=!1,P.default(document).off("mousemove",this.onMouseMove),P.default(document).off("mouseup",this.onMouseUp)})),U(this,"onMouseDown",(e=>{e.preventDefault();const t=Ye.extractPointerLocation(e);t&&(this.setState({dragging:!0}),this.bindMouseMoveUp(),this.props.onMouseDown&&this.props.onMouseDown(t,this))})),U(this,"onMouseMove",(e=>{if(!this.state.dragging)return;e.preventDefault();const t=Ye.extractPointerLocation(e);t&&this.props.onMouseMove&&this.props.onMouseMove(t)})),U(this,"onMouseUp",(e=>{e.preventDefault();const t=Ye.extractPointerLocation(e);t&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp&&this.props.onMouseUp(t))}))}render(){let e={};this.props.floating&&(e={position:"absolute",left:this.props.startOffset.left,top:this.props.startOffset.top}),this.props.width&&(e.width=this.props.width);const t=["card"];this.props.stack&&t.push("stack"),this.props.floating&&!this.props.animating&&(t.push("dragging"),e.left+=this.props.mouse.left-this.props.startMouse.left,e.top+=this.props.mouse.top-this.props.startMouse.top);const n=M.default.pick(this.props,"content"),o=this.props.animating?P.default.noop:this.onMouseDown;return _.createElement("div",{className:"card-wrap "+te.INTERACTIVE,style:e,onMouseDown:o,onTouchStart:o,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},_.createElement("div",{className:t.join(" ")},_.createElement(qi,G({},n,{linterContext:this.props.linterContext}))))}shouldComponentUpdate(e,t){return this.props.floating||e.floating||this.props.content!==e.content||this.props.fakeRef!==e.fakeRef}componentDidMount(){this.mouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!Ye.supportsPassiveEvents()&&{passive:!1})}componentDidUpdate(e,t){if(this.props.animating&&!e.animating){const e=15*Math.sqrt(Math.sqrt(Math.pow(this.props.animateTo.left-this.props.startOffset.left,2)+Math.pow(this.props.animateTo.top-this.props.startOffset.top,2)));P.default(N.default.findDOMNode(this)).animate(this.props.animateTo,Math.max(e,1),this.props.onAnimationEnd)}}componentWillUnmount(){this.mouseMoveUpBound&&(xe.error("Removing an element with bound event handlers.",be.Internal),this.unbindMouseMoveUp(),Ye.resetTouchHandlers()),document.removeEventListener("touchmove",this.onMouseMove)}}U(jm,"propTypes",{floating:I.default.bool.isRequired,animating:I.default.bool,width:I.default.number,stack:I.default.bool,onMouseDown:I.default.func,onMouseMove:I.default.func,onMouseUp:I.default.func,startMouse:Vm,startOffset:Vm,animateTo:Vm,onAnimationEnd:I.default.func,linterContext:tn}),U(jm,"defaultProps",{stack:!1,animating:!1,linterContext:nn});class Ym extends _.Component{constructor(){super(...arguments),U(this,"state",{current:[],dragging:!1,placeholderIndex:null,dragKey:null,animating:!1,dragContent:null,dragWidth:null,dragHeight:null,offsetPos:null,animateTo:null,grabPos:null}),U(this,"onClick",((e,t,n,o)=>{const s=P.default(N.default.findDOMNode(o)),i=this.state.current.slice();let r,a=null;"current"===e?(i.splice(t,1),r=this.state.current[t],a=t):"bank"===e&&(r=this.props.options[t]),this.setState({current:i,dragging:!0,placeholderIndex:a,dragKey:r.key,dragContent:r.content,dragWidth:s.width(),dragHeight:s.height(),grabPos:n,mousePos:n,offsetPos:s.position()})})),U(this,"onRelease",(e=>{const t=this.refs.dragging;if(null==t)return;const n=this.isCardInBank(t),o=this.state.placeholderIndex||0,s=()=>{const e=this.state.current.slice();if(!n){const t={content:this.state.dragContent,key:M.default.uniqueId("perseus_draggable_card_"),width:this.state.dragWidth};e.splice(o,0,t)}this.props.onChange({current:e}),this.setState({current:e,dragging:!1,placeholderIndex:null,animating:!1}),this.props.trackInteraction()},i=P.default(N.default.findDOMNode(t)).position();let r=null;n?M.default.each(this.props.options,(function(e,t){if(e.content===this.state.dragContent){const e=N.default.findDOMNode(this.refs["bank"+t]);r=P.default(e).position()}}),this):null!=this.refs.placeholder&&(r=P.default(N.default.findDOMNode(this.refs.placeholder)).position()),null==r?s():this.setState({offsetPos:i,animateTo:r,onAnimationEnd:s,animating:!0,dragging:!1})})),U(this,"onMouseMove",(e=>{const t=this.refs.dragging;if(null==t)return;let n;n=this.isCardInBank(t)?null:this.findCorrectIndex(t,this.state.current),this.setState({mousePos:e,placeholderIndex:n})})),U(this,"findCorrectIndex",((e,t)=>{const n="horizontal"===this.props.layout,o=P.default(N.default.findDOMNode(this.refs.dragList)),s=o.offset().left,i=o.offset().top,r=P.default(N.default.findDOMNode(e)).offset().left-s,a=P.default(N.default.findDOMNode(e)).offset().top-i;let l=0,c=0,d=0;return n?M.default.each(t,(function(e,t){const n=N.default.findDOMNode(this.refs["sortable"+t]),o=P.default(n).outerWidth(!0);r>c+o/2&&(l+=1),c+=o}),this):M.default.each(t,(function(e,t){const n=N.default.findDOMNode(this.refs["sortable"+t]),o=P.default(n).outerHeight(!0);a>d+o/2&&(l+=1),d+=o}),this),l})),U(this,"isCardInBank",(e=>{if(null==e)return!1;const t="horizontal"===this.props.layout,n=P.default(N.default.findDOMNode(e)),o=P.default(N.default.findDOMNode(this.refs.bank)),s=n.offset(),i=o.offset(),r=n.outerHeight(!0),a=o.outerHeight(!0),l=o.outerWidth(!0),c=N.default.findDOMNode(this.refs.dragList);P.default(c).width();const d=n.outerWidth(!0);return t?s.top+r/2<i.top+a:s.left+d/2<i.left+l})),U(this,"setListValues",(e=>{const t=e.map((e=>({content:e})));this.props.onChange({current:t}),this.setState({current:t})})),U(this,"getUserInput",(()=>({current:M.default.map(this.props.current,(function(e){return e.content}))}))),U(this,"simpleValidate",(e=>Ym.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){M.default.isEqual(this.props.current,e.current)||this.setState({current:e.current})}render(){const e=this.state.dragging&&_.createElement(jm,{ref:"dragging",floating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,startMouse:this.state.grabPos,mouse:this.state.mousePos,width:this.state.dragWidth,onMouseUp:this.onRelease,onMouseMove:this.onMouseMove,key:this.state.dragKey||"draggingCard",linterContext:this.props.linterContext}),t=this.state.animating&&_.createElement(jm,{floating:!0,animating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,width:this.state.dragWidth,animateTo:this.state.animateTo,onAnimationEnd:this.state.onAnimationEnd,key:this.state.dragKey||"draggingCard",linterContext:this.props.linterContext}),n=M.default.map(this.state.current,(function(e,t){return _.createElement(jm,{key:"sortableCard".concat(t),ref:"sortable"+t,fakeRef:"sortable"+t,floating:!1,content:e.content,width:e.width,linterContext:this.props.linterContext,onMouseDown:this.state.animating?P.default.noop:this.onClick.bind(null,"current",t)})}),this);if(null!=this.state.placeholderIndex){const e=_.createElement(Um,{ref:"placeholder",width:this.state.dragWidth,height:this.state.dragHeight,key:"placeholder"});n.splice(this.state.placeholderIndex,0,e)}const o=n.length>0;n.push(e,t);const s=_.createElement("div",{className:"perseus-clearfix draggable-box"},!o&&_.createElement(Gm,null),_.createElement("div",{ref:"dragList"},n)),i=_.createElement("div",{ref:"bank",className:"bank perseus-clearfix"},M.default.map(this.props.options,((e,t)=>_.createElement(jm,{ref:"bank"+t,floating:!1,content:e.content,stack:!0,key:t,linterContext:this.props.linterContext,onMouseDown:this.state.animating?P.default.noop:this.onClick.bind(null,"bank",t),onMouseMove:this.onMouseMove,onMouseUp:this.onRelease})),this));return _.createElement("div",{className:"draggy-boxy-thing orderer height-"+this.props.height+" layout-"+this.props.layout+" above-scratchpad blank-background perseus-clearfix "+te.INTERACTIVE,ref:"orderer"},i,s)}}U(Ym,"defaultProps",{current:[],options:[],correctOptions:[],height:"normal",layout:"horizontal",linterContext:nn}),M.default.extend(Ym,{validate:function(e,t){if(0===e.current.length)return{type:"invalid",message:null};return{type:"points",earned:M.default.isEqual(e.current,M.default.pluck(t.correctOptions,"content"))?1:0,total:1,message:null}}});var $m={name:"orderer",displayName:"Orderer",widget:Ym,isLintable:!0};class Xm extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"getUserInput",(()=>Lr.getUserInput.call(this))),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"simpleValidate",(e=>Xm.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){return _.createElement(qi,{content:this.props.content,inline:!0,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext})}}U(Xm,"propTypes",{...pr,content:I.default.string,linterContext:tn}),U(Xm,"defaultProps",{content:"",linterContext:nn});var Km={name:"passage-ref-target",displayName:"PassageRefTarget",defaultAlignment:"inline",widget:Xm,hidden:!0,transform:e=>M.default.pick(e,"content"),version:{major:0,minor:0},isLintable:!0};function Zm(e,t,n,o){let s;return s="start"===t&&"start"===o?Range.START_TO_START:"start"===t&&"end"===o?Range.END_TO_START:"end"===t&&"start"===o?Range.START_TO_END:Range.END_TO_END,e.compareBoundaryPoints(s,n)}function Jm(e,t){const n=e.cloneRange();return n.setEnd(t.endContainer,t.endOffset),n}function Qm(e,t){return!(Zm(e,"end",t,"start")<0||Zm(t,"end",e,"start")<0)}function eg(e,t){if(!Qm(e,t))return null;return Jm(Zm(e,"start",t,"start")<0?e:t,Zm(e,"end",t,"end")>0?e:t)}function tg(e,t,n,o,s){let i=-1,r=o,a=s,l=0;for(;r<=a;){if(l++,l>2*t.length)throw new Error("Assertion error: Binary search isn't terminating? "+"lower=".concat(r,", upper=").concat(a));const o=Math.floor((r+a)/2);if("first"===n){Zm(t[o],"end",e,"start")<=0?r=o+1:(i=o,a=o-1)}else{Zm(t[o],"start",e,"end")>=0?a=o-1:(i=o,r=o+1)}}return i}function ng(e,t){const n={};let o=t.domRange,s=t.firstWordIndex,i=t.lastWordIndex;for(const t of Object.keys(e)){const r=e[t],a=eg(r.domRange,o);a?(o=a,s=Math.min(r.firstWordIndex,s),i=Math.max(r.lastWordIndex,i)):n[t]=r}const r={firstWordIndex:s,lastWordIndex:i,domRange:o},a=function(e){const t="".concat((new Date).getTime());if(!e.includes(t))return t;let n,o=0;do{n="".concat(t,"-").concat(o),o++}while(e.includes(n));return n}(Object.keys(n));return n[a]=r,n}function og(e,t,n){for(const t of Object.keys(e)){const i=e[t].domRange;if(Zm(o=i,"start",s=n,"start")<=0&&Zm(o,"end",s,"end")>=0)return null}var o,s;const i=function(e,t){const n=tg(e,t,"first",0,t.length-1);if(n<0)return null;const o=tg(e,t,"last",n,t.length-1);return o<0?null:[n,o]}(n,t);if(!i)return null;const[r,a]=i;return{firstWordIndex:r,lastWordIndex:a,domRange:Jm(t[r],t[a])}}function sg(e,t){const{firstWordIndex:n,lastWordIndex:o}=e.range,s=t[n];if(!s)throw new we("first word index ".concat(s," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),be.InvalidInput,{metadata:{firstWord:s,wordRanges:JSON.stringify(t)}});const i=t[o];if(!i)throw new we("last word index ".concat(i," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),be.InvalidInput,{metadata:{lastWord:i,wordRanges:JSON.stringify(t)}});return{firstWordIndex:n,lastWordIndex:o,domRange:Jm(s,i)}}function ig(e){const{firstWordIndex:t,lastWordIndex:n}=e;return{range:{type:"word-indexes",firstWordIndex:t,lastWordIndex:n}}}function rg(e,t){return{left:e.left-t.left,top:e.top-t.top}}function ag(e,t){let{left:n,top:o,width:s,height:i}=e;return{...rg({left:n,top:o},t),width:s,height:i}}function lg(e){const t=[];return cg(e.commonAncestorContainer,e,t),t}function cg(e,t,n){const o=new Range;if(o.selectNodeContents(e),e.nodeType===Node.TEXT_NODE){const r=Qm(s=t,i=o)?Jm(Zm(s,"start",i,"start")>0?s:i,Zm(s,"end",i,"end")<0?s:i):null;r&&function(e,t,n){const o=e.parentElement,s=window.getComputedStyle(o);let i=null;if("string"==typeof s.lineHeight&&s.lineHeight.endsWith("px")){const e=parseFloat(s.lineHeight);isNaN(e)||(i=e)}const r=Array.from(t.getClientRects());for(const e of r){const t={left:e.left,top:e.top,height:e.height,width:e.width};if(null!==i){const e=i-t.height;t.top-=e,t.height=i}n.push(t)}}(e,r,n)}else if(e.nodeType===Node.ELEMENT_NODE){if(!Qm(t,o))return;for(const o of Array.from(e.childNodes))cg(o,t,n)}var s,i}class dg extends _.PureComponent{constructor(){super(...arguments),U(this,"state",{cachedHighlightRects:this._computeRects(this.props),tooltipIsHovered:!1})}UNSAFE_componentWillReceiveProps(e){this.props.highlight===e.highlight&&this.props.offsetParent===e.offsetParent||this.setState({cachedHighlightRects:this._computeRects(e)})}_computeRects(e){const{highlight:t,offsetParent:n}=e,o=lg(t.domRange),{left:s,top:i}=n.getBoundingClientRect();return o.map((e=>ag(e,{left:s,top:i})))}_rectIsHovered(e,t){const n=rg(t,{left:e.left,top:e.top});return 0<=n.left&&n.left<e.width&&0<=n.top&&n.top<e.height}isHovered(e){if(!e)return!1;const{offsetParent:t}=this.props,{cachedHighlightRects:n}=this.state,{left:o,top:s}=t.getBoundingClientRect(),i=rg(e,{left:o,top:s});return n.some((e=>this._rectIsHovered(e,i)))}render(){const e=this.state.cachedHighlightRects;return _.createElement("div",null,e.map(((e,t)=>_.createElement("div",{key:t,className:d.css(pg.highlightRect),style:{position:"absolute",width:e.width,height:e.height,top:e.top,left:e.left,zIndex:this.props.zIndexes.belowContent}}))))}}const pg=d.StyleSheet.create({highlightRect:{background:"#fffabe"}});class ug extends _.PureComponent{constructor(){super(...arguments),U(this,"_tooltip",void 0)}componentDidUpdate(e){var t;this.props.focusNode===e.focusNode&&this.props.focusOffset===e.focusOffset&&this.props.offsetParent===e.offsetParent||(null===(t=this._tooltip)||void 0===t||t.remeasure())}_getFocusRect(){const{focusNode:e,focusOffset:t,offsetParent:n}=this.props,o=document.createRange();o.setStart(e,t),o.setEnd(e,t);const s=o.getClientRects()[0];if(!s)return xe.log('[Highlighting] Known bug: Could not determine the focus position, so did not show an "Add Highlight" tooltip. https://app.asana.com/0/329800276300868/413878480039713 (see also /r/asana-links)'),null;const{left:i,top:r}=n.getBoundingClientRect();return ag({left:s.left,top:s.top,width:s.width,height:s.height},{left:i,top:r})}render(){const e=this._getFocusRect();if(!e)return null;const t=_.createElement("div",{className:d.css(hg.tooltipLabel)},this.props.label);return _.createElement(wl,{content:t,color:el.kaBlue,inverted:!0,onClick:this.props.onClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,toggleOnHover:!1,showOnMount:!0,ref:e=>this._tooltip=e},_.createElement("div",{style:{position:"absolute",left:e.left,top:e.top,height:e.height}}))}}const hg=d.StyleSheet.create({tooltipLabel:{userSelect:"none"}});class fg extends _.PureComponent{constructor(){super(...arguments),U(this,"state",{hoveredHighlightKey:null,hoveringTooltipFor:null}),U(this,"_highlightRenderers",{}),U(this,"_handleMouseMove",(e=>{const t={left:e.clientX,top:e.clientY},n=this._getHoveredHighlightKey(t);this.setState({hoveredHighlightKey:n})}))}componentDidMount(){this._updateEditListeners(!1,this.props.editable)}UNSAFE_componentWillReceiveProps(e){this._updateEditListeners(this.props.editable,e.editable),null==this.state.hoveredHighlightKey||this.state.hoveredHighlightKey in e.highlights||this.setState({hoveredHighlightKey:null}),null==this.state.hoveringTooltipFor||this.state.hoveringTooltipFor in e.highlights||this.setState({hoveringTooltipFor:null})}componentWillUnmount(){this._updateEditListeners(this.props.editable,!1)}_updateEditListeners(e,t){!e&&t?window.addEventListener("mousemove",this._handleMouseMove):e&&!t&&(window.removeEventListener("mousemove",this._handleMouseMove),this.setState({hoveredHighlightKey:null,hoveringTooltipFor:null}))}_getHoveredHighlightKey(e){const{hoveringTooltipFor:t}=this.state;if("string"==typeof t)return t;return Object.keys(this.props.highlights).find((t=>{const n=this._highlightRenderers[t];return n&&n.isHovered(e)}))}_renderTooltip(){const{hoveredHighlightKey:e}=this.state;if(null==e)return null;const t=this.props.highlights[e];return _.createElement(ug,{label:k._("Remove highlight"),focusNode:t.domRange.endContainer,focusOffset:t.domRange.endOffset,offsetParent:this.props.offsetParent,onClick:()=>this.props.onRemoveHighlight(e),onMouseEnter:()=>this.setState({hoveringTooltipFor:e}),onMouseLeave:()=>this.setState({hoveringTooltipFor:null})})}render(){return _.createElement("div",null,Object.keys(this.props.highlights).map((e=>_.createElement(dg,{ref:t=>{t?this._highlightRenderers[e]=t:delete this._highlightRenderers[e]},key:e,highlight:this.props.highlights[e],highlightKey:e,offsetParent:this.props.offsetParent,zIndexes:this.props.zIndexes}))),this.props.editable&&this._renderTooltip())}}class mg extends _.PureComponent{constructor(){super(...arguments),U(this,"state",{mouseState:"up",trackedSelection:null}),U(this,"_handleSelectionChange",(()=>{this._updateTrackedSelection(this.props.buildHighlight),"down"===this.state.mouseState&&this.setState({mouseState:"down-and-selecting"})})),U(this,"_handleMouseDown",(()=>{this.setState({mouseState:"down"})})),U(this,"_handleMouseUp",(()=>{this.setState({mouseState:"up"})}))}componentDidMount(){this._updateListeners(!1,this.props.enabled)}UNSAFE_componentWillReceiveProps(e){this.props.buildHighlight!==e.buildHighlight&&this._updateTrackedSelection(e.buildHighlight),this._updateListeners(this.props.enabled,e.enabled)}componentWillUnmount(){this._updateListeners(this.props.enabled,!1)}_updateListeners(e,t){!e&&t?(window.addEventListener("mousedown",this._handleMouseDown),window.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("selectionchange",this._handleSelectionChange)):e&&!t&&(window.removeEventListener("mousedown",this._handleMouseDown),window.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("selectionchange",this._handleSelectionChange),this.setState({mouseState:"up",trackedSelection:null}))}_computeFocusAndRange(){const e=document.getSelection();if(!e||0===e.rangeCount)return null;const t=e.getRangeAt(0);if(t.collapsed)return null;return{focusNode:e.focusNode,focusOffset:e.focusOffset,range:t}}_computeTrackedSelection(e){const t=this._computeFocusAndRange();if(!t)return null;const{focusNode:n,focusOffset:o,range:s}=t,i=e(s);return i?{focusNode:n,focusOffset:o,proposedHighlight:i}:null}_updateTrackedSelection(e){const t=this._computeTrackedSelection(e);this.setState({trackedSelection:t})}render(){const{mouseState:e,trackedSelection:t}=this.state,n="down-and-selecting"===e;return this.props.children?_.createElement("div",null,this.props.children(t,n)):null}}class gg extends _.PureComponent{_handleAddHighlight(e){this.props.onAddHighlight(e);const t=document.getSelection();t&&t.collapseToEnd()}_selectionIsValid(e){if(!e)return!1;const{contentNode:t}=this.props,n=new Range;n.selectNodeContents(t);const o=new Range;o.setStart(e.focusNode,e.focusOffset),o.collapse(!0);return Qm(n,o)}render(){return _.createElement(mg,{buildHighlight:this.props.buildHighlight,enabled:this.props.editable},((e,t)=>_.createElement("div",null,_.createElement(fg,{editable:this.props.editable&&!this._selectionIsValid(e),highlights:this.props.highlights,offsetParent:this.props.offsetParent,onRemoveHighlight:this.props.onRemoveHighlight,zIndexes:this.props.zIndexes}),this._selectionIsValid(e)&&!t&&_.createElement(ug,{label:k._("Add highlight"),onClick:()=>this._handleAddHighlight(e.proposedHighlight),focusNode:e.focusNode,focusOffset:e.focusOffset,offsetParent:this.props.offsetParent}))))}}class vg extends _.PureComponent{constructor(){super(...arguments),U(this,"_container",void 0)}componentDidMount(){this._sendWordsUpdate()}componentDidUpdate(){this._sendWordsUpdate()}_sendWordsUpdate(){this.props.onWordsUpdate(this._getWordRanges())}_getWordRanges(){const e=this._container;if(!e)throw new we("invariant violation: `this._container` is not defined, but this method is only called after mount/update",be.NotAllowed);const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,(()=>NodeFilter.FILTER_ACCEPT),!1),n=[];let o=null;for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){"inline"!==getComputedStyle(e).display&&(o=null)}else if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue,s=/\S+/g;let i,r=null;for(;null!==(i=s.exec(t));){const s=i.index,a=i.index+i[0].length;let l;0===s&&o?(l=o,l.setEnd(e,a)):(l=e.ownerDocument.createRange(),l.setStart(e,s),l.setEnd(e,a),n.push(l)),a===t.length&&(r=l)}o=r}}return n}render(){return _.createElement("div",{ref:e=>this._container=e},this.props.children)}}class yg extends _.PureComponent{constructor(){super(...arguments),U(this,"_container",void 0),U(this,"_content",void 0),U(this,"state",{wordRanges:[]}),U(this,"_handleAddHighlight",(e=>{const t=ng(this._getDOMHighlights(),e),n={};for(const e of Object.keys(t))n[e]=ig(t[e]);this.props.onSerializedHighlightsUpdate(n)})),U(this,"_handleRemoveHighlight",(e=>{const{serializedHighlights:t}=this.props,n={...t};delete n[e],this.props.onSerializedHighlightsUpdate(n)})),U(this,"_handleWordsUpdate",(e=>{this.setState({wordRanges:e})}))}_buildHighlight(e){return og(this._getDOMHighlights(),this.state.wordRanges,e)}_getDOMHighlights(){const{serializedHighlights:e}=this.props,{wordRanges:t}=this.state,n={};for(const o of Object.keys(e))n[o]=sg(e[o],t);return n}render(){const e=this._getDOMHighlights();return _.createElement("div",{className:d.css(bg.container),ref:e=>this._container=e},_.createElement("div",null,this.props.enabled&&this._container&&this._content&&_.createElement(gg,{buildHighlight:e=>this._buildHighlight(e),contentNode:this._content,editable:this.props.editable,highlights:e,offsetParent:this._container,zIndexes:{belowContent:0},onAddHighlight:this._handleAddHighlight,onRemoveHighlight:this._handleRemoveHighlight})),_.createElement("div",{className:d.css(bg.content),ref:e=>this._content=e},_.createElement(vg,{onWordsUpdate:this._handleWordsUpdate},this.props.children)))}}const bg=d.StyleSheet.create({container:{position:"relative",zIndex:0},content:{position:"relative",zIndex:1}}),xg={display:"inline-block",width:0,visibility:"hidden"},wg={display:"inline",whiteSpace:"nowrap"},Cg={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",paddingLeft:10,paddingRight:10,userSelect:"none",WebkitUserSelect:"none"},kg={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",userSelect:"none",WebkitUserSelect:"none",width:22,height:22,borderRadius:"50%",textAlign:"center"};class Sg extends _.Component{constructor(){super(...arguments),U(this,"getRefContent",(()=>this.props.refContent))}render(){return _.createElement("span",{style:xg},k.doNotTranslate("_"))}}U(Sg,"propTypes",{refContent:I.default.node.isRequired});class Eg extends _.Component{render(){return _.createElement("span",{style:xg},k.doNotTranslate("_"))}}const _g={newline:R.default.defaultRules.newline,paragraph:R.default.defaultRules.paragraph,escape:R.default.defaultRules.escape,passageFootnote:{order:R.default.defaultRules.escape.order+.1,match:R.default.inlineRegex(/^\^/),parse:(e,t,n)=>{const o=n.lastFootnote.id+1,s={id:o,text:1===o?"*":""+o};return"*"===n.lastFootnote.text&&(n.lastFootnote.text=""+n.lastFootnote.id),n.lastFootnote=s,s},react:(e,t,n)=>_.createElement("sup",{key:n.key},e.text)},refStart:{order:R.default.defaultRules.escape.order+.2,match:function(e,t){const n=/^\{\{/.exec(e);if(n){let t=2,o=0;for(;t<e.length;){const n=e.slice(t,t+2);if("{{"===n)o++,t++;else if("}}"===n){if(!(o>0))break;o--,t++}t++}const s=e.slice(2,t);return[n[0],s]}return null},parse:(e,t,n)=>{if(!n.useRefs)return{ref:null,refContent:null};const o=n.lastRef+1;n.lastRef=o,n.currentRef.push(o);return{ref:o,refContent:t("(“"+e[1]+"”)\n\n",M.default.defaults({useRefs:!1},Tg))}},react:(e,t,n)=>{if(null==e.ref)return null;const o=t(e.refContent,{});return _.createElement(Sg,{ref:"start-ref-"+e.ref,key:"start-ref-"+e.ref,refContent:o})}},refEnd:{order:R.default.defaultRules.escape.order+.3,match:R.default.inlineRegex(/^\}\}/),parse:(e,t,n)=>{if(!n.useRefs)return{ref:null};return{ref:n.currentRef.pop()||null}},react:(e,t,n)=>null!=e.ref?_.createElement(Eg,{ref:"end-ref-"+e.ref,key:"end-ref-"+e.ref}):null},squareLabel:{order:R.default.defaultRules.escape.order+.4,match:R.default.inlineRegex(/^\[\[(\w+)\]\]( *)/),parse:(e,t,n)=>(n.firstQuestionRef||(n.firstQuestionRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,n)=>[_.createElement("span",{key:"visual-square",className:"perseus-passage-square-label",style:wg,"aria-hidden":"true"},_.createElement("span",{style:Cg},e.content)),_.createElement("span",{key:"alt-text",className:"perseus-sr-only"},k.$_("[Marker for question %(number)s]",{number:e.content})),e.space?" ":null]},circleLabel:{order:R.default.defaultRules.escape.order+.5,match:R.default.inlineRegex(/^\(\((\w+)\)\)( *)/),parse:(e,t,n)=>({content:e[1],space:e[2].length>0}),react:(e,t,n)=>[_.createElement("span",{key:"visual-circle",className:"perseus-passage-circle-label",style:wg,"aria-hidden":!0},_.createElement("span",{style:kg},e.content)),_.createElement("span",{key:"alt-text",className:"perseus-sr-only"},k.$_("[Circle marker %(number)s]",{number:e.content})),e.space?" ":null]},squareBracketRef:{order:R.default.defaultRules.escape.order+.6,match:R.default.inlineRegex(/^\[(\d+)\]( *)/),parse:(e,t,n)=>(n.firstSentenceRef||(n.firstSentenceRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,n)=>[_.createElement("span",{key:"visual-brackets",className:"perseus-passage-bracket-label","aria-hidden":"true"},"[",e.content,"]"),_.createElement("span",{key:"alt-text",className:"perseus-sr-only"},k.$_("[Sentence %(number)s]",{number:e.content})),e.space?" ":null]},highlight:{order:R.default.defaultRules.escape.order+.7,match:R.default.inlineRegex(/^{highlighting.start}(.+?){highlighting.end}/),parse:(e,t,n)=>({content:e[1]}),react:(e,t,n)=>[_.createElement("span",{key:0,className:"perseus-highlight"},e.content)]},reviewHighlight:{order:R.default.defaultRules.escape.order+.7,match:R.default.inlineRegex(/^{review-highlighting.start}(.+?){review-highlighting.end}/),parse:(e,t,n)=>({content:e[1]}),react:(e,t,n)=>[_.createElement("span",{key:0,className:"perseus-review-highlight"},e.content)]},strong:R.default.defaultRules.strong,u:R.default.defaultRules.u,em:R.default.defaultRules.em,del:R.default.defaultRules.del,text:{...R.default.defaultRules.text,react:(e,t,n)=>_.createElement("span",{key:n.key},e.content)}},Tg={currentRef:[],useRefs:!0,lastRef:0,lastFootnote:{id:0,text:""}},Mg=R.default.parserFor(_g);var Ig={parse:(e,t)=>{t=t||{};return Mg(e+"\n\n",M.default.extend(t,Tg))},output:R.default.reactFor(R.default.ruleOutput(_g,"react")),START_REF_PREFIX:"start-ref-",END_REF_PREFIX:"end-ref-",_rulesForTesting:_g};class Pg extends _.Component{constructor(){super(...arguments),U(this,"_cachedLineHeight",void 0),U(this,"$body",void 0),U(this,"$end",void 0)}measureLineHeight(){return"number"!=typeof this._cachedLineHeight&&this.forceMeasureLineHeight(),this._cachedLineHeight}forceMeasureLineHeight(){var e;this.$body.text(" "),this._cachedLineHeight=(e=this.$body,this.$end.offset().top-e.offset().top),this.$body.text("")}render(){return _.createElement("div",{className:d.css(Ng.measurer)},_.createElement("div",null,_.createElement("div",{ref:e=>this.$body=P.default(e),className:"paragraph"}),_.createElement("div",{ref:e=>this.$end=P.default(e)})))}}const Ng=d.StyleSheet.create({measurer:{position:"absolute",width:"100%",top:0,left:0}});class Ag extends _.Component{constructor(){super(...arguments),U(this,"_onResize",void 0),U(this,"_lineHeightMeasurer",void 0),U(this,"_stylesAppiedTimer",void 0),U(this,"state",{nLines:null,startLineNumbersAfter:0,stylesAreApplied:!1}),U(this,"_handleSerializedHighlightsUpdate",(e=>{this.props.onChange({highlights:e})}))}componentDidMount(){this._updateState(),this._onResize=M.default.throttle((()=>{this.shouldRenderJipt()||(this._lineHeightMeasurer.forceMeasureLineHeight(),this._updateState())}),500),window.addEventListener("resize",this._onResize),this._stylesAppiedTimer=window.setTimeout((()=>{this.setState({stylesAreApplied:!0})}),0)}shouldComponentUpdate(e,t){return!M.default.isEqual(this.props,e)||!M.default.isEqual(this.state,t)}componentDidUpdate(){this._updateState()}componentWillUnmount(){window.removeEventListener("resize",this._onResize),clearTimeout(this._stylesAppiedTimer)}_updateState(){this.shouldRenderJipt()||this.setState({nLines:this._measureLines(),startLineNumbersAfter:this._getInitialLineNumber()})}_measureLines(){const e=P.default(N.default.findDOMNode(this.refs.content)).height(),t=this._getLineHeight();return Math.round(e/t)}_getInitialLineNumber(){let e=!0;return this.props.findWidgets(((t,n)=>"passage"===n.type&&(t===this.props.widgetId&&(e=!1),e))).map((e=>e.getLineCount())).reduce(((e,t)=>e+t),0)}_getLineHeight(){return this._lineHeightMeasurer.measureLineHeight()}getLineCount(){return null!=this.state.nLines?this.state.nLines:this._measureLines()}_getStartRefLineNumber(e){const t=Ig.START_REF_PREFIX+e,n=this.refs[t];if(!n)return null;const o=P.default(N.default.findDOMNode(n));let s=o.next();0===s.length&&(s=o);const i=s.offset().top;return this.state.startLineNumbersAfter+1+this._convertPosToLineNumber(i)}_getEndRefLineNumber(e){const t=Ig.END_REF_PREFIX+e,n=this.refs[t];if(!n)return null;const o=P.default(N.default.findDOMNode(n));let s=o.prev();0===s.length&&(s=o);const i=s.height(),r=s.offset().top;let a=this._convertPosToLineNumber(r+i);return 0===i&&(a+=1),this.state.startLineNumbersAfter+a}_convertPosToLineNumber(e){const t=e-P.default(N.default.findDOMNode(this.refs.content)).offset().top,n=this._getLineHeight();return Math.round(t/n)}_getRefContent(e){const t=Ig.START_REF_PREFIX+e,n=this.refs[t];return n?n.getRefContent():null}getReference(e){const t=this._getStartRefLineNumber(e),n=this._getEndRefLineNumber(e);if(null==t||null==n)return null;return{startLine:t,endLine:n,content:this._getRefContent(e)}}getUserInput(){return null}simpleValidate(e){return Ag.validate(this.getUserInput(),e)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}_renderInstructions(e){const t=e.firstQuestionRef,n=e.firstSentenceRef;let o="";t&&(o+=k._("The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.",{questionSymbol:"[["+t+"]]",questionNumber:t})),n&&(o+=k._(" The symbol %(sentenceSymbol)s indicates that the following sentence is referenced in a question.",{sentenceSymbol:"["+n+"]"}));const s=Ig.parse(o);return _.createElement("div",{className:"perseus-widget-passage-instructions"},Ig.output(s))}shouldRenderJipt(){const{JIPT:e}=Y();return e.useJIPT&&-1!==this.props.passageText.indexOf("crwdns")}_renderContent(e){const t=this.state.stylesAreApplied,n=!this.props.reviewModeRubric;return _.createElement(yg,{editable:n,enabled:t,onSerializedHighlightsUpdate:this._handleSerializedHighlightsUpdate,serializedHighlights:this.props.highlights},_.createElement("div",{ref:"content"},_.createElement(Pg,{ref:e=>this._lineHeightMeasurer=e}),Ig.output(e)))}_hasFootnotes(){const e=this.props.footnotes;return!/^\s*$/.test(e)}_renderFootnotes(){const e=this.props.footnotes,t=Ig.parse(e);return Ig.output(t)}render(){let e;const t=this.state.nLines;this.props.showLineNumbers&&t&&(e=M.default.range(1,t+1).map((e=>{const t=e+this.state.startLineNumbersAfter;if(4===t){const e=k._("Line ");return _.createElement("span",{key:"line-marker",className:"line-marker"},e)}return _.createElement("span",{key:e},t)})));const n={firstSentenceRef:null,firstQuestionRef:null},o=this.props.passageText.replace(/("{1})([^"]*)("{1})/g,"“$2”"),s=Ig.parse(o,n),i=/\S/.test(this.props.passageTitle);return _.createElement("div",null,_.createElement("div",{className:"perseus-widget-passage-container"},this._renderInstructions(n),_.createElement("div",{className:"perseus-widget-passage"},i&&_.createElement("h3",{className:"passage-title"},_.createElement(qi,{content:this.props.passageTitle,linterContext:this.props.linterContext})),e&&_.createElement("div",{className:"line-numbers","aria-hidden":!0},e),!i&&_.createElement("h3",{className:"perseus-sr-only"},k._("Beginning of reading passage.")),_.createElement("div",{className:"passage-text"},this.shouldRenderJipt()?_.createElement(qi,{content:this.props.passageText}):this._renderContent(s)),this._hasFootnotes()&&[_.createElement("h4",{key:"footnote-start",className:"perseus-sr-only"},k._("Beginning of reading passage footnotes.")),_.createElement("div",{key:"footnotes",className:"footnotes"},this._renderFootnotes())],_.createElement("div",{className:"perseus-sr-only"},k._("End of reading passage.")))))}}U(Ag,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0,highlights:{},linterContext:nn});var Rg={name:"passage",displayName:"Passage (SAT only)",widget:Ag,transform:e=>M.default.pick(e,"passageTitle","passageText","footnotes","showLineNumbers"),isLintable:!0};const{deepEq:Fg}=Ye;I.default.oneOf(["bar","line","pic","histogram","dotplot"]),I.default.arrayOf(I.default.string),I.default.arrayOf(I.default.oneOfType([I.default.number,I.default.string])),I.default.number,I.default.number,I.default.number,I.default.number,I.default.number,I.default.string,I.default.arrayOf(I.default.number),I.default.number,I.default.arrayOf(I.default.number),I.default.bool;class Og extends _.Component{constructor(){super(...arguments),U(this,"shouldSetupGraphie",void 0),U(this,"_isMounted",!1),U(this,"horizHairline",void 0),U(this,"hairlineRange",void 0),U(this,"graphie",void 0),U(this,"state",{values:this.props.starting||[1],categoryHeights:{}}),U(this,"DOT_PLOT_POINT_SIZE",(()=>this.props.apiOptions.isMobile?6:4)),U(this,"DOT_PLOT_POINT_PADDING",(()=>8)),U(this,"DOT_TICK_POINT_SIZE",(()=>2)),U(this,"setupGraphie",(e=>{const t=this;t.shouldSetupGraphie=!1;const n=N.default.findDOMNode(t.refs.graphieDiv);P.default(n).empty();const o=En.createGraphie(n);t.graphie=o,t.graphie.pics=[],t.graphie.dotTicks=[];const s="bar"===t.props.type,i="line"===t.props.type,r="pic"===t.props.type,a="histogram"===t.props.type,l="dotplot"===t.props.type,c=r||l,d={},p=d,u=this.props.apiOptions.isMobile;p.graph={lines:[],bars:[],points:[],dividers:[]},p.scaleY=t.props.scaleY,p.dimX=t.props.categories.length;const h=u?[288,336]:t.props.plotDimensions;if(i)p.dimX+=u?-.2:1;else if(a)p.barPad=0,p.barWidth=1;else if(s)p.barPad=u?.08:.15,p.barWidth=1-2*p.barPad,p.dimX+=(u?-2:2)*p.barPad;else if(c){p.picBoxHeight=t.props.picBoxHeight,p.picBoxWidthPx=h[0]/t.props.categories.length;const e=h[0]-p.dimX*p.picBoxWidthPx;p.picPad=e/(2*p.dimX+2);const n=p.picBoxWidthPx+2*p.picPad;p.picPad=p.picPad/n,p.picBoxWidth=p.picBoxWidthPx/n,p.dimX+=2*p.picPad}l&&(p.picBoxHeight=2*this.DOT_PLOT_POINT_SIZE()+this.DOT_PLOT_POINT_PADDING()),p.dimY=Math.ceil(t.props.maxY/p.scaleY)*p.scaleY;let f=25;(s||i)&&u&&(f=0!==t.props.labels[1].length?17:11),l&&(f/=2),u&&c&&0===t.props.labels[1].length&&(f=0);let m=25,g=75;if(u&&(s||c)){const e=Math.max(0,...Object.values(t.state.categoryHeights));if(e){let t=25;c&&(t+=10),g=t+e}}if(p.scale=u?[(h[0]-4*f)/p.dimX,(h[1]-(m+g))/p.dimY]:M.default.map([p.dimX,p.dimY],(function(e,t){return h[t]/e})),c&&(p.scale[1]=p.picBoxHeight/p.scaleY),f/=p.scale[0],m/=p.scale[1],g/=p.scale[1],o.init({range:[[-3*f,p.dimX+f],[-g,p.dimY+m]],scale:p.scale,isMobile:this.props.apiOptions.isMobile}),o.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c){for(let e=u?p.scaleY:0;e<=p.dimY;e+=p.scaleY)o.label([0,e],Ce.roundToApprox(e,2),"left",!0),o.style({stroke:u?"#e9ebec":"#000",strokeWidth:1,opacity:u?1:.3},(function(){o.line([0,e],[p.dimX,e])}))}(s||i)&&u&&(t.graphie.dragPrompt=o.label([p.dimX/2,p.dimY/2],k._("Drag handles to make graph"),"center",!1).css("font-weight","bold").css("color",bn.KA_GREEN).css("display","none")),t.setupCategories(d),c&&u&&(t.graphie.dotPrompt=o.label([p.dimX/2,p.dimY/2],k._("Tap to add points"),"center",!1).css("font-weight","bold").css("color",bn.KA_GREEN).css("display","none")),c&&t.drawPicHeights(t.state.values,e.values),o.style({stroke:"#000",strokeWidth:2,opacity:1},(function(){c?l?o.style({stroke:u?bn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([u?0:.5,0],[p.dimX-(u?0:.5),0]))):(o.line([0,0],[p.dimX,0]),0===t.props.labels[1].length&&u||o.style({stroke:u?bn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([0,0],[0,p.dimY])))):(o.style({stroke:u?bn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([u?3*-f:0,0],[p.dimX+(u?f:0),0]))),(s||i)&&u||o.style({stroke:u?bn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([0,0],[0,p.dimY]))))})),o.label([p.dimX/2,u?-g:-35/p.scale[1]],t.props.labels[0],u?"above":"below",!1).css("font-weight","bold").css("color",u&&bn.GRAY_F),o.label([(u?-35:-60)/p.scale[0],p.dimY/2],t.props.labels[1],"center",!1).css("font-weight","bold").css("color",u&&bn.GRAY_F).addClass("rotate"),this.props.apiOptions.isMobile&&(this.horizHairline=new Fn(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:bn.INTERACTIVE}),this.horizHairline.hide(),this.hairlineRange=[[0,p.dimX],[0,p.dimY]])})),U(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.hairlineRange[0][0],e[1]],[this.hairlineRange[0][1],e[1]]),this.horizHairline.show())})),U(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&this.horizHairline.hide()})),U(this,"labelCategory",((e,t)=>{const n=this.props.apiOptions.isMobile,o=this.graphie;let s=!1;const i=(t+="").match(/^\$(.*)\$$/);i&&(t=i[1],s=!0);const r=Math.PI/180*45,a="translateX(-50%) translateX(".concat(5,"px) ")+"translateY(-50%) rotate(-".concat(45,"deg)"),l=n&&!i;return new Promise((i=>{o.style({color:n?bn.GRAY_G:"inherit",transform:l?a:"none",transformOrigin:"100%"},(()=>{const a=o.label([e,n?-.5:0],t,"below",s),c=14+(l?Math.round(a.height()*Math.cos(r)+(a.width()+5)*Math.sin(r)):a.height());i({category:t,height:c})}))}))})),U(this,"setupCategories",(e=>{const t=this,n=e,o=t.graphie,s=this.props.apiOptions.isMobile,i=[];"histogram"===t.props.type?(M.default.times(t.props.categories.length-1,(function(n){t.setupBar({index:n,startHeight:t.state.values[n],config:e,isHistogram:!0})})),M.default.each(t.props.categories,(function(e,r){const a=.5+r*n.barWidth;i.push(t.labelCategory(a,e));const l=6/n.scale[1];o.style({stroke:"#000",strokeWidth:s?1:2,opacity:1},(function(){o.line([a,-l],[a,0])}))}))):M.default.each(t.props.categories,(function(r,a){const l=t.state.values[a];let c;"bar"===t.props.type?c=t.setupBar({index:a,startHeight:l,config:e,isHistogram:!1}):"line"===t.props.type?c=t.setupLine(a,l,e):"pic"===t.props.type?c=t.setupPic(a,e):"dotplot"===t.props.type&&(c=t.setupDotplot(a,e));let d=0,p=-6/n.scale[1];"dotplot"!==t.props.type||s||(d=-p),"dotplot"===t.props.type?a%t.props.labelInterval!=0&&a!==t.props.categories.length-1||(i.push(t.labelCategory(c,r)),d*=1.5,p*=1.5):i.push(t.labelCategory(c,r)),o.style({stroke:s?bn.GRAY_G:"#000",strokeWidth:s?1:2,opacity:1},(function(){o.line([c,d],[c,p])}))})),Promise.all(i).then((e=>{if(t._isMounted){const n={};e.forEach((e=>{let{category:t,height:o}=e;return n[t]=o})),t.setState({categoryHeights:n})}}))})),U(this,"_clampValue",((e,t,n)=>Math.max(Math.min(e,n),t))),U(this,"_maybeShowDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="inline")})),U(this,"_maybeHideDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="none")})),U(this,"setupBar",(e=>{const t=this.props.apiOptions.isMobile,n=e.index,o=e.startHeight,s=e.config,i=e.isHistogram,r=this,a=r.graphie,l=s.barWidth/2;let c;c=i?.5+n*s.barWidth+l:(t?l:.5+s.barPad)+n;const d=function(e,n){const o=a.scalePoint(0);if(s.graph.bars[e].scale(1,Math.max(t?.2:.01,n/s.scaleY),o[0],o[1]),i){const t=s.graph.dividers[e-1],i=s.graph.dividers[e];if(t){const i=Math.min(r.state.values[e-1],n);t.scale(1,Math.max(.01,i/s.scaleY),o[0],o[1])}if(i){const t=Math.min(r.state.values[e+1],n);i.scale(1,Math.max(.01,t/s.scaleY),o[0],o[1])}}};if(a.style({stroke:"none",fill:t?bn.BLUE_C:bn.LIGHT_BLUE,opacity:1},(function(){s.graph.bars[n]=a.path([[c-l,0],[c-l,s.scaleY],[c+l,s.scaleY],[c+l,0],[c-l,0]])})),i&&n>0&&a.style({stroke:"#000",strokeWidth:1,opacity:.3},(function(){s.graph.dividers.push(a.path([[c-l,0],[c-l,s.scaleY]]))})),t){const e=s.scaleY/r.props.snapsPerLine;s.graph.lines[n]=gs.addMaybeMobileMovablePoint(this,{coord:[c,o],constraints:[(t,n,o)=>[c,this._clampValue(Math.round(t[1]/e)*e,0,s.dimY)]],onMoveStart:function(){s.graph.bars[n].attr({fill:bn.INTERACTIVE})},onMove:function(){const e=s.graph.lines[n].coord()[1],t=M.default.clone(r.state.values);t[n]=e,r.setState({values:t}),r.changeAndTrack({values:t}),r._maybeHideDragPrompt(),d(n,e)},onMoveEnd:function(){s.graph.bars[n].attr({fill:bn.BLUE_C})}}),s.graph.lines[n].state.visibleShape.wrapper.style.zIndex="1",r._maybeShowDragPrompt()}else s.graph.lines[n]=a.addMovableLineSegment({coordA:[c-l,o],coordZ:[c+l,o],snapY:s.scaleY/r.props.snapsPerLine,constraints:{constrainX:!0},normalStyle:{stroke:bn.INTERACTIVE,"stroke-width":this.props.static?0:4}}),s.graph.lines[n].onMove=function(e,t){let o=this.coordA[1];(o<0||o>s.dimY)&&(o=Math.min(Math.max(o,0),s.dimY),this.coordA[1]=this.coordZ[1]=o,this.transform());const i=M.default.clone(r.state.values);i[n]=o,r.setState({values:i}),r.changeAndTrack({values:i}),d(n,o)};return d(n,o),c})),U(this,"setupLine",((e,t,n)=>{const o=this.props.apiOptions.isMobile,s=this,i=n,r=s.graphie,a=e+(o?.4:1);if(o){const o=n.scaleY/s.props.snapsPerLine;i.graph.points[e]=gs.addMaybeMobileMovablePoint(this,{coord:[a,t],constraints:[(e,t,s)=>[a,this._clampValue(Math.round(e[1]/o)*o,0,n.dimY)]],onMove:function(){const t=i.graph.points[e].coord()[1],n=M.default.clone(s.state.values);n[e]=t,s.setState({values:n}),s.changeAndTrack({values:n}),s._maybeHideDragPrompt()}}),s._maybeShowDragPrompt(),e>0&&(i.graph.lines[e]=gs.addMovableLine(r,{points:[i.graph.points[e-1],i.graph.points[e]],constraints:gs.MovablePoint.constraints.fixed(),normalStyle:{stroke:bn.BLUE_C,"stroke-width":2},highlightStyle:{stroke:bn.BLUE_C,"stroke-width":2}}))}else i.graph.points[e]=r.addMovablePoint({coord:[a,t],constraints:{constrainX:!0},normalStyle:{fill:bn.INTERACTIVE,stroke:bn.INTERACTIVE},snapY:i.scaleY/s.props.snapsPerLine}),i.graph.points[e].onMove=function(t,n){n=Math.min(Math.max(n,0),i.dimY);const o=M.default.clone(s.state.values);return o[e]=n,s.setState({values:o}),s.changeAndTrack({values:o}),[t,n]},e>0&&(i.graph.lines[e]=r.addMovableLineSegment({pointA:i.graph.points[e-1],pointZ:i.graph.points[e],constraints:{fixed:!0},normalStyle:{stroke:"#9ab8ed","stroke-width":2}}));return a})),U(this,"setupDotplot",((e,t)=>{const n=this.graphie,o=this.props.apiOptions.isMobile;return this.setupTiledPlot(e,o?.5:1,t,((e,t)=>n.ellipse([e,t],[this.DOT_PLOT_POINT_SIZE()/n.scale[0],this.DOT_PLOT_POINT_SIZE()/n.scale[1]],{fill:bn.INTERACTIVE,stroke:bn.INTERACTIVE})))})),U(this,"setupPic",((e,t)=>{const n=this.graphie;return this.setupTiledPlot(e,0,t,((e,t)=>{const o=n.scalePoint([e,t]),s=this.props.picSize;return n.raphael.image(this.props.picUrl,o[0]-s/2,o[1]-s/2,s,s)}))})),U(this,"setupTiledPlot",((e,t,n,o)=>{const s=this,i=n,r=s.graphie,a=r.pics,l=r.dotTicks,c=e+.5+i.picPad;r.mouselayer.canvas.style.touchAction="none",a[e]=[],l[e]=[];const d=Math.round(i.dimY/i.scaleY)+1;return M.default(d).times((function(n){const d=((n-=1)+.5)*i.scaleY,p=c-i.picBoxWidth/2,u=d+.5*i.scaleY,h=r.scalePoint([p,u+t]),f=r.mouselayer.rect(h[0],h[1],i.picBoxWidthPx,i.picBoxHeight);P.default(f[0]).css({fill:"#000",opacity:0,cursor:"pointer"}).on("vmousedown",(function(n){n.preventDefault(),s.whichPicClicked=e,s.setPicHeight(e,u),P.default(document).on("vmouseup.plotTile",(function(e){P.default(document).unbind(".plotTile")})),P.default(document).on("vmousemove.plotTile",(function(e){e.preventDefault();const n=r.getMouseCoord(e)[1],o=Math.floor(n-t),a=(Math.max(-1,Math.floor(o/i.scaleY))+.5)*i.scaleY,l=Math.min(a+.5*i.scaleY,i.dimY);s.setPicHeight(s.whichPicClicked,l)}))})),n<0||(a[e][n]=o(c,d+t),l[e][n]=r.ellipse([c,d+t],[s.DOT_TICK_POINT_SIZE()/r.scale[0],s.DOT_TICK_POINT_SIZE()/r.scale[1]],{fill:"#dee1e3",stroke:"#dee1e3"}))})),c})),U(this,"setPicHeight",((e,t)=>{const n=M.default.clone(this.state.values);n[e]=t,this.drawPicHeights(n,this.state.values),this.setState({values:n}),this.changeAndTrack({values:n})})),U(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),U(this,"drawPicHeights",((e,t)=>{const n=this,o=n.graphie,s=o.pics,i=this.props.apiOptions.isMobile;if(i){const t=e.every((e=>0===e));o.dotPrompt[0].style.display=t?"inline":"none"}M.default.each(s,(function(s,r){M.default.each(s,(function(s,a){const l=(a+1)*n.props.scaleY,c=l<=e[r];if("dotplot"===n.props.type){const e=l<=t[r];c&&!e&&s.animate({"stroke-width":8},75,(()=>s.animate({"stroke-width":2},75)))}P.default(s[0]).css({display:c?"inline":"none"}),o.dotTicks[r][a][0].style.display=c||!i?"none":"inline"}))}))})),U(this,"getUserInput",(()=>this.state.values)),U(this,"simpleValidate",(e=>Og.validate(this.getUserInput(),e)))}render(){const e={marginBottom:this.props.labels[0]?75:0};return _.createElement("div",{className:"perseus-widget-plotter graphie "+te.INTERACTIVE,ref:"graphieDiv",style:e})}componentDidUpdate(e,t){this.shouldSetupGraphie=this.shouldSetupGraphie||!M.default.isEqual(this.state.categoryHeights,t.categoryHeights),this.shouldSetupGraphie&&this.setupGraphie(t)}componentDidMount(){this._isMounted=!0,this.setupGraphie(this.state)}UNSAFE_componentWillReceiveProps(e){this.shouldSetupGraphie=M.default.any(["type","labels","categories","scaleY","maxY","snapsPerLine","picUrl","labelInterval","static"],(function(t){return!M.default.isEqual(this.props[t],e[t])}),this),M.default.isEqual(this.props.starting,e.starting)||M.default.isEqual(this.state.values,e.starting)||(this.shouldSetupGraphie=!0,this.setState({values:e.starting}))}componentWillUnmount(){this._isMounted=!1}}U(Og,"propTypes",{onChange:I.default.func.isRequired,trackInteraction:I.default.func.isRequired}),U(Og,"defaultProps",{type:"bar",labels:["",""],categories:[""],scaleY:1,maxY:10,snapsPerLine:2,picSize:40,picBoxHeight:48,picUrl:"",plotDimensions:[380,300],labelInterval:1}),M.default.extend(Og,{validate:function(e,t){return Fg(e,t.starting)?{type:"invalid",message:null}:{type:"points",earned:Fg(e,t.correct)?1:0,total:1,message:null}}});const Dg=M.default.identity;var Lg={name:"plotter",displayName:"Plotter",widget:Og,staticTransform:Dg};class Bg extends _.Component{constructor(){super(...arguments),U(this,"arrowLength",100),U(this,"drawArrow",(()=>{const e=this.refs["arrowCanvas"+this.props.index],t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);const n=new Path2D;t.strokeStyle="rgb(0,0,0)",t.lineWidth=1.2,t.lineCap="round";n.moveTo(5,e.height/2),n.lineTo(e.width-5,e.height/2),n.moveTo(e.width-10,e.height/2-5),n.lineTo(e.width-5,e.height/2),n.moveTo(e.width-10,e.height/2+5),n.lineTo(e.width-5,e.height/2),t.stroke(n)}))}componentDidMount(){this.drawArrow()}componentDidUpdate(){this.drawArrow()}render(){return _.createElement("div",{className:"arrow-container"},_.createElement("div",{className:"above-text"},this.props.data.topText),_.createElement("canvas",{height:"30",id:"arrowCanvas"+this.props.index,ref:"arrowCanvas"+this.props.index,width:this.arrowLength},k._("Reaction arrow pointing to the right.")),_.createElement("div",{className:"below-text"},this.props.data.bottomText))}}U(Bg,"propTypes",{data:I.default.any,index:I.default.number});class zg extends _.Component{constructor(){super(...arguments),U(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),U(this,"getUserInput",(()=>[])),U(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null}))),U(this,"focus",(()=>!0))}render(){return _.createElement("div",{className:"reaction",ref:"reaction"},this.props.smiles.map(((e,t)=>{const n=this.props.widgetId+"-"+t;return _.createElement("div",{key:n,className:"molecule-container"},_.createElement(Im,{id:n,rotationAngle:this.props.rotationAngle[t],smiles:e}),t===this.props.smiles.length-1?null:_.createElement(Bg,{data:this.props.separators[t],index:t}))})))}}U(zg,"propTypes",{rotationAngle:I.default.arrayOf(I.default.number),separators:I.default.arrayOf(I.default.object),smiles:I.default.arrayOf(I.default.string),widgetId:I.default.string}),U(zg,"defaultProps",{smiles:[],rotationAngle:[],separators:[]});var qg={name:"reaction-diagram",displayName:"Chemical reaction",hidden:!0,widget:zg};class Hg extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"state",{visible:1}),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"_handleInteraction",(e=>{const t=parseInt(e.split(" ")[1]);if(t===this.state.visible-1){const e=this.refs.renderer.getWidgetInstance("group "+t);e.showRationalesForCurrentlySelectedChoices();const n=e.simpleValidate();"points"===n.type&&n.total===n.earned&&(this.setState({visible:this.state.visible+1}),this.props.trackInteraction({visible:this.state.visible+1}))}}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){const e=_.createElement(V,G({},To,{style:{color:"green"}})),t=M.default.chain(this.props.json).first(this.state.visible).map(((e,t)=>"[[".concat(Ye.snowman," group ").concat(t,"]]"))).join("\n\n").value(),n={};return M.default.each(this.props.json,((t,o)=>{const s="group ".concat(o);n[s]={type:"group",graded:!0,version:{major:0,minor:0},options:M.default.extend({},t,{icon:o<this.state.visible-1?e:null})}})),_.createElement("div",{className:"perseus-sequence"},_.createElement(qi,{ref:"renderer",content:t,widgets:n,onInteractWithWidget:this._handleInteraction,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext}))}}U(Hg,"propTypes",{...pr,apiOptions:ee.propTypes,json:I.default.arrayOf(I.default.shape({content:I.default.string,images:I.default.objectOf(I.default.any),widgets:I.default.objectOf(I.default.any)})),trackInteraction:I.default.func.isRequired,linterContext:tn}),U(Hg,"defaultProps",{json:[{content:"",widgets:{},images:{}}],linterContext:nn});var Wg={name:"sequence",displayName:"Graded Sequence",widget:Hg,traverseChildWidgets:function(e,t){let n=e.json;M.default.isArray(n)||(n=[n]);const o=M.default.map(n,(e=>t(e)));return M.default.extend({},e,{json:o})},tracking:"all",hidden:!0,isLintable:!0};const Ug="#aaa",Gg="#ccc",Vg="#fff",jg={borderBottom:"9px solid transparent",borderTop:"9px solid transparent",content:'" "',height:"0",position:"absolute",top:"0",width:"0"},Yg=d.StyleSheet.create({infoTip:{display:"inline-block",marginLeft:"5px",position:"relative"},infoTipContainer:{position:"absolute",top:"-12px",left:"22px",zIndex:1e3},infoTipTriangle:{height:"10px",left:"0",position:"absolute",top:"8px",width:"0",zIndex:1,":before":{...jg,borderRight:"9px solid #bbb",right:"0"},":after":{...jg,borderRight:"9px solid ".concat(Vg),right:"-1px"}},verticalShadow:{border:"1px solid ".concat(Gg),boxShadow:"0 1px 3px ".concat(Gg),borderBottom:"1px solid ".concat(Ug)},infoTipContentContainer:{background:Vg,padding:"5px 10px",width:"240px"}});class $g extends _.Component{constructor(){super(...arguments),U(this,"state",{hover:!1}),U(this,"handleMouseEnter",(()=>{this.setState({hover:!0})})),U(this,"handleMouseLeave",(()=>{this.setState({hover:!1})}))}render(){return _.createElement("div",{className:d.css(Yg.infoTip)},_.createElement("img",{alt:"",width:10,height:10,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo2N2M3NTAxYS04YmVlLTQ0M2MtYmRiNS04OGM2N2IxN2NhYzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUJCRTk4Qjc4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUJCRTk4QjY4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NGE5ZDI0OTMtODk1NC00OGFkLTlhMTgtZDAwM2MwYWNjNDJlIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjY3Yzc1MDFhLThiZWUtNDQzYy1iZGI1LTg4YzY3YjE3Y2FjMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pqm89uYAAADMSURBVHjaXJA9DoJAEIUH1M4TUHIFsCMGen9OwCGw1YRGW2ntKel0exsojHIBC0ouQAyUviFDstmXfNmZeS+zm7XSNCXRFiRgJf0bXIHixpbhGdxBBJYC1w/xaA424MhNEATkui71fU9KqfEU78UbD9PdbJRlOdae55GmhIP+1NV1TcMwkOM41DSNHvRtMhTHMRVFQW3b6mOLgx99kue5GRp/gIOZuZGvNpTNwjD8oliANU+qqqKu6/TQBdymN57AHjzBT+B6Jx79BRgAvc49kQA4yxgAAAAASUVORK5CYII=",onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave}),_.createElement("div",{className:d.css(Yg.infoTipContainer),style:{display:this.state.hover?"block":"none"}},_.createElement("div",{className:d.css(Yg.infoTipTriangle)}),_.createElement("div",{className:d.css(Yg.verticalShadow,Yg.infoTipContentContainer)},this.props.children)))}}class Xg extends _.Component{constructor(){super(...arguments),U(this,"state",{didMount:!1})}componentDidMount(){this.setState({didMount:!0})}render(){return this.state.didMount?_.createElement($g,this.props):_.createElement("div",null)}}const{assert:Kg}=mn,{Path:Zg,Arc:Jg,Circle:Qg,Label:ev,Line:tv,MovablePoint:nv,MovableLine:ov}=Rs;class sv extends _.Component{constructor(){super(...arguments),U(this,"_renderThresholdLine",(()=>{const e=[0,this._range()[1][1]],t=M.default.map(e,(e=>[this.state.threshold,e]));return _.createElement(ov,{onMove:this.handleMouseInteraction},M.default.map(t,((e,t)=>_.createElement(nv,{key:t,static:!0,coord:e,normalStyle:{stroke:"none",fill:"none"}}))))})),U(this,"_renderCircle",(()=>{const e=this.props.data,t=M.default.reduce(e,((e,t)=>e+t),0),n=M.default.reduce(e,((e,t,n)=>null!=this.state.threshold&&n<=this.state.threshold?e+t:e),0),o=n/t,s=1e-5,i=[this.props.box[0]-30,30],r=this._range()[0],a=Math.min(Math.max(this.state.threshold,r[0]),r[1]).toFixed(2);return[o>0&&(()=>{const e={key:"below",center:i,radius:20,startAngle:0,endAngle:o<1?360*o:359.99999,sector:1!==o,unscaled:!0,style:{fill:bn.LIGHT_RED,stroke:bn.RED}};return _.createElement(Jg,e)})(),o<1&&(()=>{const e={key:"above",center:i,radius:20,startAngle:o>0?360*o:s,endAngle:360,sector:0!==o,unscaled:!0,style:{fill:bn.LIGHT_BLUE,stroke:bn.BLUE}};return _.createElement(Jg,e)})(),(()=>{const e={key:"label",coord:[i[0],i[1]+30],text:n+" of "+t+" results below "+a+"%",direction:"center",tex:!1,unscaled:!0,style:{fontSize:"12px"}};return _.createElement(ev,e)})()]})),U(this,"_renderData",(()=>{const e=this.props.data;this._range();return M.default.map(e,((e,t)=>{if(!e)return;const n=null!=this.state.threshold&&t<=this.state.threshold,o={fill:n?bn.LIGHT_RED:bn.LIGHT_BLUE,stroke:n?bn.RED:bn.BLUE},s=[[t,0],[t,e],[t+1,e],[t+1,0]];return _.createElement(Zg,{key:t,coords:s,style:o})}))})),U(this,"_setupGraphie",((e,t)=>{const n=t.data,o=t.range,s=t.scale,i=o[0][1]-o[0][0],r=o[1][1]-0,a=Math.ceil(r/20);if(M.default.each(M.default.range(0,o[1][1],a),(t=>{n&&e.label([o[0][0],t],Ce.roundToApprox(t,2),"left",!0),e.line([o[0][0],t],[o[0][1],t],{stroke:"#000",strokeWidth:1,opacity:.3})})),n){const t=15,n=Math.ceil(i/t);M.default.each(M.default.range(o[0][0],o[0][1],n),(t=>{e.label([t,0],p.number.round(t,2),"below",!0);e.line([t,0],[t,-8/s[1]],{stroke:"#000",strokeWidth:1})}))}const l=[o[0][0],0],c=[o[0][0],o[1][1]];e.line(l,c,{stroke:"#000",strokeWidth:2,opacity:1});const d=o[0][0]+i/2,u=n?25:0;e.label([d,-u/s[1]],t.xAxisLabel,"below",!1).css("font-weight","bold");const h=0+r/2,f=n?55:28;e.label([o[0][0]-f/s[0],h],t.yAxisLabel,"center",!1).css("font-weight","bold").css("-webkit-transform","rotate(-90deg)")})),U(this,"handleMouseInteraction",(e=>{this.setState({threshold:e[0]})})),U(this,"_range",(e=>(e=e||this.props).data?this._getRangeForData(e.data):[[0,100],[-1,10]])),U(this,"_getRangeForData",(e=>{const t=M.default.indexOf(e,M.default.find(e,(e=>e>0))),n=Math.max(0,t-10),o=M.default.lastIndexOf(e,M.default.last(M.default.filter(e,(e=>e>0))));return[[n,Math.min(101,o+1+10)],[-1,M.default.max(e)]]})),U(this,"_getInitialThreshold",(e=>{const t=e[0];return t[0]+(t[1]-t[0])/3})),U(this,"state",{threshold:this._getInitialThreshold(this._range())})}UNSAFE_componentWillReceiveProps(e){const t=this._range(),n=this._range(e);Ye.deepEq(t,n)||this.setState({threshold:this._getInitialThreshold(n)})}render(){const e=this.props.data,t=this._range(),n={xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,box:this.props.box,range:t,data:e,scale:[Ye.scaleFromExtent(t[0],this.props.box[0]),Ye.scaleFromExtent(t[1],this.props.box[1])]},o=[t[0][0],0],s=[t[0][1],0];return _.createElement(Rs,{box:n.box,range:n.range,options:n,setup:this._setupGraphie,onMouseMove:this.handleMouseInteraction,onMouseDown:this.handleMouseInteraction,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable},_.createElement(tv,{start:o,end:s,style:{stroke:"#000",strokeWidth:1,opacity:1}}),e&&this._renderData(),e&&this._renderCircle(),e&&this._renderThresholdLine())}}U(sv,"propTypes",{data:I.default.arrayOf(I.default.number),xAxisLabel:I.default.string,yAxisLabel:I.default.string,box:I.default.arrayOf(I.default.number)}),U(sv,"defaultProps",{data:null,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",box:[400,400]});class iv extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"generateNumber",void 0),U(this,"state",{invalidInput:!1}),U(this,"calculateDisplayProportion",(()=>{const e=this.props.userProportion;return"percentage"===this.props.proportionOrPercentage?Math.round(100*e):e})),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"checkProportionValidity",(e=>e>=0&&"proportion"===this.props.proportionOrPercentage&&e<=1||"percentage"===this.props.proportionOrPercentage&&e<=100)),U(this,"handleUserProportionChange",((e,t)=>{let n;n="percentage"===this.props.proportionOrPercentage?e/100:e,null!=n&&(n=Math.min(1,Math.max(0,n))),this.props.onChange({userProportion:n},t)})),U(this,"handleSampleSizeChange",((e,t)=>{null!=e&&(e=Math.min(1e3,Math.max(0,Math.floor(e)))),this.props.onChange({sampleSize:e},t)})),U(this,"handleRunSimulation",(()=>{null!=this.props.numTrials&&null!=this.props.userProportion&&null!=this.props.sampleSize?(this.setState({invalidInput:!1}),this.props.onChange({data:this.generateData()}),this.props.trackInteraction()):this.setState({invalidInput:!0})})),U(this,"generateData",(e=>((e,t,n)=>{const o=()=>this.generateNumber()<n,s=M.default.times(101,(()=>0));return M.default.times(t,(()=>{const t=M.default.times(e,o),n=M.default.filter(t,M.default.identity).length,i=Math.floor(100*n/e);s[i]++})),s})((e=e||this.props).sampleSize,e.numTrials,e.userProportion))),U(this,"getInputPaths",(()=>[["userProportion"],["sampleSize"]])),U(this,"focus",(()=>{const e=M.default.head(this.getInputPaths());return this.focusInputPath(e),!0})),U(this,"focusInputPath",(e=>{Kg(e.length>0);const t=M.default.head(e);this.refs[t].focus()})),U(this,"blurInputPath",(e=>{Kg(e.length>0);const t=M.default.head(e);this.refs[t].blur()})),U(this,"getDOMNodeForPath",(e=>{Kg(e.length>0);const t=M.default.head(e);return N.default.findDOMNode(this.refs[t])})),U(this,"getGrammarTypeForPath",(e=>(Kg(e.length>0),"number"))),U(this,"setInputValue",((e,t,n)=>{Kg(e.length>0);const o=M.default.head(e);this["handle"+(o.charAt(0).toUpperCase()+o.slice(1))+"Change"](t,n)})),U(this,"getUserInput",(()=>null)),U(this,"simpleValidate",(e=>iv.validate(this.getUserInput(),e)))}UNSAFE_componentWillMount(){null!=this.props.randomSeed&&(this.generateNumber=Ye.seededRNG(this.props.randomSeed))}UNSAFE_componentWillReceiveProps(e){e.randomSeed!==this.props.randomSeed&&(this.generateNumber=Ye.seededRNG(e.randomSeed))}render(){const e={marginLeft:"5px"},t="0px 0px 0px 2px rgba(255, 165, 0, 1)",n=M.default.extend({},e,{WebkitBoxShadow:t,MozBoxShadow:t,boxShadow:t,transition:"all 0.15s"}),o=M.default.extend({},e,{transition:"all 0.15s"}),s=this.state.invalidInput?n:o,i=this.props.apiOptions.staticRender?le:qf,r=_.createElement("div",null,_.createElement(i,{ref:"userProportion",style:s,value:this.calculateDisplayProportion(),checkValidity:this.checkProportionValidity,disabled:this.props.apiOptions.readOnly,onChange:this.handleUserProportionChange,onFocus:()=>this.props.onFocus(["userProportion"]),onBlur:()=>this.props.onBlur(["userProportion"])}),_.createElement(Xg,null,_.createElement("p",null,k._("This controls the proportion or percentage that will be used in your simulation.")))),a=_.createElement("div",null,_.createElement(i,{ref:"sampleSize",style:s,value:this.props.sampleSize,checkValidity:e=>e>=0,disabled:this.props.apiOptions.readOnly,onChange:this.handleSampleSizeChange,onFocus:()=>this.props.onFocus(["sampleSize"]),onBlur:()=>this.props.onBlur(["sampleSize"])}),_.createElement(Xg,null,_.createElement("p",null,k._("This controls the sample size that will be used in your simulation. For example, if you set this to 100, then for each trial, responses from 100 participants will be simulated.")))),l=_.createElement("div",{style:{textAlign:"right"}},_.createElement("b",null,this.props.numTrials),_.createElement(Xg,null,_.createElement("p",null,k._("This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times.")))),c=[{title:this.props.proportionLabel+":",value:r},{title:k._("Sample size:"),value:a},{title:k._("Number of trials:"),value:l}],d=_.createElement("button",{className:"simple-button",style:{margin:"20px 0"},disabled:this.props.apiOptions.readOnly,onClick:this.handleRunSimulation},k._("Run simulation")),p={paddingBottom:this.props.data?40:0},u=_.createElement("div",{style:p},_.createElement(sv,{data:this.props.data,xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}));return _.createElement("div",null,(e=>{const t=_.createElement("thead",null,_.createElement("tr",null,_.createElement("th",null,k._("Parameter")),_.createElement("th",null,k._("Value")))),n=_.createElement("tbody",null,M.default.map(e,((e,t)=>_.createElement("tr",{key:t},_.createElement("td",null,e.title),_.createElement("td",null,e.value)))));return _.createElement("table",null,t,n)})(c),d,u)}}U(iv,"propTypes",{...pr,apiOptions:ee.propTypes,data:I.default.arrayOf(I.default.number),numTrials:I.default.number,proportionLabel:I.default.string,proportionOrPercentage:I.default.string,randomSeed:I.default.number,sampleSize:I.default.number,trackInteraction:I.default.func.isRequired,userProportion:I.default.number,xAxisLabel:I.default.string,yAxisLabel:I.default.string}),U(iv,"defaultProps",{data:null,userProportion:null,sampleSize:null,numTrials:null,randomSeed:0,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion",apiOptions:ee.defaults}),M.default.extend(iv,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var rv={name:"simulator",displayName:"Simulator",widget:iv,transform:e=>{const t=M.default.clone(e);return t.randomSeed=e.problemNum,t},hidden:!0};const{shuffle:av}=Ye;class lv extends _.Component{constructor(){super(...arguments),U(this,"_isMounted",void 0),U(this,"state",{changed:!1}),U(this,"handleChange",(e=>{this._isMounted&&this.setState({changed:!0},(()=>{setTimeout((()=>{this.props.onChange(e),this.props.trackInteraction()}),0)}))})),U(this,"getUserInput",(()=>({options:this.refs.sortable.getOptions()}))),U(this,"moveOptionToIndex",((e,t)=>{this.refs.sortable.moveOptionToIndex(e,t)})),U(this,"simpleValidate",(e=>this.state.changed?lv.validate(this.getUserInput(),e):{type:"invalid",message:null}))}static validate(e,t){return{type:"points",earned:M.default.isEqual(e.options,t.correct)?1:0,total:1,message:null}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1}render(){const e=av(this.props.correct,this.props.problemNum,!0),{apiOptions:t}=this.props,n=t.isMobile?8:5;return _.createElement("div",{className:"perseus-widget-sorter perseus-clearfix"},_.createElement(If,{options:e,layout:this.props.layout,margin:n,padding:this.props.padding,onChange:this.handleChange,linterContext:this.props.linterContext,ref:"sortable"}))}}U(lv,"propTypes",{apiOptions:ee.propTypes,correct:I.default.array,layout:I.default.oneOf(["horizontal","vertical"]),onChange:I.default.func,padding:I.default.bool,problemNum:I.default.number,trackInteraction:I.default.func.isRequired,linterContext:tn}),U(lv,"defaultProps",{correct:[],layout:"horizontal",padding:!0,problemNum:0,onChange:function(){},linterContext:nn});var cv={name:"sorter",displayName:"Sorter",widget:lv,isLintable:!0};const{assert:dv}=mn,{keypadElementPropType:pv}=e.propTypes,uv=function(e,t){return[""+e,""+t]},hv=function(e){return dv(M.default.isArray(e)&&2===e.length),+e[0]},fv=function(e){return dv(M.default.isArray(e)&&2===e.length),+e[1]},mv=function(e){return"answer"+hv(e)+","+fv(e)};class gv extends _.Component{constructor(){super(...arguments),U(this,"_getRows",(()=>this.props.answers.length)),U(this,"_getColumns",(()=>this.props.answers[0].length)),U(this,"getUserInput",(()=>M.default.map(this.props.answers,M.default.clone))),U(this,"onValueChange",((e,t,n)=>{const o=M.default.map(this.props.answers,M.default.clone);o[e][t]=n.target?n.target.value:n,this.props.onChange({answers:o}),this.props.trackInteraction()})),U(this,"onHeaderChange",((e,t)=>{const n=this.props.headers.slice();n[e]=t.content,this.props.onChange({headers:n})})),U(this,"simpleValidate",(e=>gv.validate(this.getUserInput(),e))),U(this,"_handleFocus",(e=>{this.props.onFocus(e)})),U(this,"_handleBlur",(e=>{this.props.onBlur(e)})),U(this,"focus",(()=>(this.focusInputPath(uv(0,0)),!0))),U(this,"focusInputPath",(e=>{const t=mv(e),n=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?n.focus():N.default.findDOMNode(n).focus()})),U(this,"blurInputPath",(e=>{const t=mv(e),n=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?n.blur():N.default.findDOMNode(n).blur()})),U(this,"getDOMNodeForPath",(e=>{const t=mv(e);return N.default.findDOMNode(this.refs[t])})),U(this,"getInputPaths",(()=>{const e=this._getRows(),t=this._getColumns(),n=[];return M.default(e).times((e=>{M.default(t).times((t=>{const o=uv(e,t);n.push(o)}))})),n})),U(this,"getGrammarTypeForPath",(e=>"number")),U(this,"setInputValue",((e,t,n)=>{const o=hv(e),s=fv(e),i=M.default.map(this.props.answers,M.default.clone);i[o][s]=t,this.props.onChange({answers:i},n)}))}render(){const e=this._getRows(),t=this._getColumns(),n=this.props.headers;let o,s;const i={};return this.props.apiOptions.customKeypad?(o=Sr,s={width:80},i.keypadElement=this.props.keypadElement):this.props.apiOptions.staticRender?(o=le,s={}):(o="input",s={}),_.createElement("table",{className:"perseus-widget-table-of-values non-markdown"},_.createElement("thead",null,_.createElement("tr",null,M.default.map(n,((e,t)=>this.props.editableHeaders?_.createElement("th",{key:t},_.createElement(this.props.Editor,{ref:"columnHeader"+t,apiOptions:this.props.apiOptions,content:e,widgetEnabled:!1,onChange:M.default.partial(this.onHeaderChange,t)})):_.createElement("th",{key:t},_.createElement(qi,{content:e,linterContext:this.props.linterContext})))))),_.createElement("tbody",null,M.default(e).times((e=>_.createElement("tr",{key:e},M.default(t).times((t=>_.createElement("td",{key:t},_.createElement(o,G({ref:mv(uv(e,t)),type:"text",value:this.props.answers[e][t],disabled:this.props.apiOptions.readOnly,onFocus:M.default.partial(this._handleFocus,uv(e,t)),onBlur:M.default.partial(this._handleBlur,uv(e,t)),onChange:M.default.partial(this.onValueChange,e,t),style:s},i))))))))))}}U(gv,"propTypes",{answers:I.default.arrayOf(I.default.arrayOf(I.default.string)),editableHeaders:I.default.bool,Editor:I.default.func,headers:I.default.arrayOf(I.default.string),keypadElement:pv,trackInteraction:I.default.func.isRequired,linterContext:tn}),U(gv,"defaultProps",function(){const e=M.default(4).times((function(){return Ye.stringArrayOfSize(1)}));return{apiOptions:ee.defaults,headers:[""],editableHeaders:!1,rows:4,columns:1,answers:e,linterContext:nn}}()),M.default.extend(gv,{validate:function(e,t){const n=function(e){return M.default.filter(e,(function(e){return M.default.some(e,M.default.identity)}))},o=n(t.answers),s=n(e);if(M.default.some(s,(function(e){return M.default.some(e,(function(e){return""===e}))}))||!s.length)return{type:"invalid",message:null};if(s.length!==o.length)return{type:"points",earned:0,total:1,message:null};const i=Ee.number.createValidatorFunctional;let r=null;return{type:"points",earned:M.default.every(o,(function(e){let t;for(t=0;t<s.length;t++){const n=s[t],o=M.default.every(n,(function(t,n){const o=e[n],s=i(o,{simplify:!0})(t);return s.message&&(r=s.message),s.correct}));if(o)return s.splice(t,1),!0}return!1}))?1:0,total:1,message:r}}});var vv={name:"table",displayName:"Table of values",accessible:!0,widget:gv,transform:e=>{const t=e.answers.length,n=e.answers[0].length,o=M.default(t).times((function(){return Ye.stringArrayOfSize(n)}));return M.default.extend({},e,{answers:o})},hidden:!0,isLintable:!0};const{deepEq:yv,getGridStep:bv,captureScratchpadTouchStart:xv}=Ye,{assert:wv}=mn,Cv={url:null};const kv={apiOptions:ee.defaults,gradeEmpty:!1,graphMode:"interactive",listMode:"dynamic",graph:{},tools:{translation:{enabled:!0,required:!1,constraints:{}},rotation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[1,6]},reflection:{enabled:!0,required:!1,constraints:{fixed:!1},coords:[[2,-4],[2,2]]},dilation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[6,6]}},drawSolutionShape:!0,starting:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]},correct:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]}};function Sv(e){return e.constraints.fixed?bn.DYNAMIC:bn.INTERACTIVE}function Ev(e){return String(Ce.roundTo(9,e))}function _v(e){const{TeX:t}=Y();return[_.createElement(t,{key:"("},"("),Ev(e[0]),_.createElement(t,{key:","},", {}"),Ev(e[1]),_.createElement(t,{key:")"},")")]}function Tv(e){const{TeX:t}=Y();return[_.createElement(t,{key:"<"},k.doNotTranslate("\\langle")),Ev(e[0]),_.createElement(t,{key:","},", {}"),Ev(e[1]),_.createElement(t,{key:">"},k.doNotTranslate("\\rangle"))]}function Mv(e,t){return e=M.default.clone(e).sort(p.point.compare),t=M.default.clone(t).sort(p.point.compare),M.default.all(M.default.map(e,(function(e,n){const o=t[n];return p.point.equal(e,o)})))}const Iv=e=>e.customKeypad?Sr:e.staticRender?le:qf,Pv={apply:function(e){return Nv[e.type].isValid(e)?Nv[e.type].apply(e):M.default.identity},append:function(e,t){const n=Pv._appendAndCollapseLastTwo(e,t);return Pv._collapseFinalNoOps(n)},_collapseFinalNoOps:function(e){return e.length&&Pv.isNoOp(M.default.last(e))?M.default.initial(e):e},_appendAndCollapseLastTwo:function(e,t){if(!e.length)return[t];const n=Pv.collapse(M.default.last(e),t);return M.default.initial(e).concat(n)},isNoOp:function(e){return Nv[e.type].isNoOp(e)},collapse:function(e,t){return e.type!==t.type?[e,t]:Pv.isEmpty(e)&&Pv.isEmpty(t)?[]:Pv.isValid(e)&&Pv.isValid(t)?Pv._collapseValidMonotypedTransforms(e,t):[e,t]},isValid:function(e){return Nv[e.type].isValid(e)},isEmpty:function(e){return Nv[e.type].isEmpty(e)},_collapseValidMonotypedTransforms:function(e,t){let n=Nv[e.type].collapse(e,t);return n?(M.default.isArray(n)||(n=[n]),M.default.each(n,(function(t){t.type=e.type})),n):[e,t]},toTeX:function(e){return Nv[e.type].toTeX(e)},ListItem:O.default({displayName:"ListItem",render:function(){if("dynamic"===this.props.mode)return _.createElement("div",null,Pv.toTeX(this.props.transform));if("interactive"===this.props.mode){const e=Nv[this.props.transform.type].Input;return _.createElement(e,G({ref:"transform",onChange:this.handleChange,onFocus:this.props.onFocus,onBlur:this.props.onBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions},this.props.transform))}throw new we("Invalid mode: "+this.props.mode,be.InvalidInput)},value:function(){return"interactive"===this.props.mode?M.default.extend({type:this.props.transform.type},this.refs.transform.value()):this.props.transform},handleChange:M.default.debounce((function(e){this.props.onChange(this.value(),e)}),300),_getComponentAtPath:function(e){const t=this.refs.transform,n=M.default.head(e);return t.refs[n]},focus:function(){const e=this.refs.transform,t=M.default.head(e.getInputPaths());t&&this.focusInputPath(t)},focusInputPath:function(e){this._getComponentAtPath(e).focus()},blurInputPath:function(e){this._getComponentAtPath(e).blur()},getDOMNodeForPath:function(e){return N.default.findDOMNode(this._getComponentAtPath(e))},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){t.length&&(t=parseFloat(t),isNaN(t))||this.refs.transform.setInputValue(e,t,n)},getInputPaths:function(){return"dynamic"===this.props.mode?[]:this.refs.transform.getInputPaths()}})},Nv={translation:{verbName:k._("Translate"),nounName:k._("Translation"),lowerNounName:k._("translation"),apply:function(e){return function(t){return p.vector.add(t,e.vector)}},isValid:function(e){return M.default.isFinite(e.vector[0])&&M.default.isFinite(e.vector[1])},isEmpty:function(e){return null===e.vector[0]&&null===e.vector[1]},isNoOp:function(e){return p.vector.equal(e.vector,[0,0])},collapse:function(e,t){return{vector:p.vector.add(e.vector,t.vector)}},toTeX:function(e){return k.$_("Translation by %(vector)s",{vector:Tv(e.vector)})},Input:class extends _.Component{constructor(){super(...arguments),U(this,"state",{vector:this.props.vector||[null,null]}),U(this,"value",(()=>({vector:[this.refs.x.getValue(),this.refs.y.getValue()]}))),U(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e),s=M.default.clone(this.state.vector);"x"===o?s[0]=t:"y"===o&&(s[1]=t),this.setState({vector:s},(()=>{this.props.onChange(n)}))})),U(this,"getInputPaths",(()=>[["x"],["y"]]))}componentDidUpdate(e){yv(this.props,e)||this.setState({vector:this.props.vector})}render(){const e=Iv(this.props.apiOptions),{TeX:t}=Y(),n=[_.createElement(t,{key:"<"},k.doNotTranslate("\\langle")),_.createElement(e,{key:"vec_x",ref:"x",placeholder:0,value:this.state.vector[0],useArrowKeys:!0,onChange:e=>{const t=this.state.vector[1];this.setState({vector:[e,t]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"x"),onBlur:M.default.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"vec_y",ref:"y",placeholder:0,value:this.state.vector[1],useArrowKeys:!0,onChange:e=>{const t=this.state.vector[0];this.setState({vector:[t,e]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"y"),onBlur:M.default.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:">"},k.doNotTranslate("\\rangle"))];return _.createElement("div",null,k.$_("Translation by %(vector)s",{vector:n}))}}},rotation:{verbName:k._("Rotate"),nounName:k._("Rotation"),lowerNounName:k._("rotation"),apply:function(e){return function(t){return p.point.rotateDeg(t,e.angleDeg,e.center)}},isValid:function(e){return M.default.isFinite(e.angleDeg)&&M.default.isFinite(e.center[0])&&M.default.isFinite(e.center[1])},isEmpty:function(e){return null===e.angleDeg&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return p.number.equal(e.angleDeg,0)},collapse:function(e,t){return!!p.point.equal(e.center,t.center)&&{center:e.center,angleDeg:e.angleDeg+t.angleDeg}},toTeX:function(e){return k.$_("Rotation by %(degrees)s about %(point)s",{degrees:(t=e.angleDeg,Ev(t)+"°"),point:_v(e.center)});var t},Input:class extends _.Component{constructor(){super(...arguments),U(this,"state",{center:this.props.center||[null,null],angleDeg:this.props.angleDeg||null}),U(this,"value",(()=>({angleDeg:this.refs.angleDeg.getValue(),center:[this.refs.centerX.getValue(),this.refs.centerY.getValue()]}))),U(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e);let s=M.default.clone(this.state.angleDeg);const i=M.default.clone(this.state.center);"angleDeg"===o?s=t:"centerX"===o?i[0]=t:"centerY"===o&&(i[1]=t),this.setState({angleDeg:s,center:i},(()=>{this.props.onChange(n)}))})),U(this,"getInputPaths",(()=>[["centerX"],["centerY"],["angleDeg"]]))}componentDidUpdate(e){yv(this.props,e)||this.setState({center:this.props.center,angleDeg:this.props.angleDeg})}render(){const e=Iv(this.props.apiOptions),{TeX:t}=Y(),n=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"X",ref:"centerX",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{const t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"centerX"),onBlur:M.default.partial(this.props.onBlur,"centerX"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"Y",ref:"centerY",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{const t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"centerY"),onBlur:M.default.partial(this.props.onBlur,"centerY"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")],o=[_.createElement(e,{key:"deg",ref:"angleDeg",placeholder:0,value:this.state.angleDeg,useArrowKeys:!0,onChange:e=>{this.setState({angleDeg:e},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"angleDeg"),onBlur:M.default.partial(this.props.onBlur,"angleDeg"),keypadElement:this.props.keypadElement}),"°"],s=k.$_("Rotation about %(point)s by %(degrees)s",{point:n,degrees:o});return _.createElement("div",null,s)}}},reflection:{verbName:k._("Reflect"),nounName:k._("Reflection"),lowerNounName:k._("reflection"),apply:function(e){return function(t){return p.point.reflectOverLine(t,e.line)}},isValid:function(e){return M.default.all(M.default.flatten(e.line),M.default.isFinite)&&!p.point.equal(e.line[0],e.line[1])},isEmpty:function(e){return M.default.all(M.default.flatten(e.line),M.default.isNull)},isNoOp:function(e){return!1},collapse:function(e,t){return!!p.line.equal(e.line,t.line)&&[]},toTeX:function(e){const t=e.line[0],n=e.line[1];return k.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:_v(t),point2:_v(n)})},Input:class extends _.Component{constructor(){super(...arguments),U(this,"state",{line:this.props.line||[[null,null],[null,null]]}),U(this,"changePoint",((e,t,n,o)=>{const s=M.default.map(this.state.line,M.default.clone);s[e][t]=n,this.setState({line:s},(()=>{this.props.onChange(o)}))})),U(this,"value",(()=>({line:[[this.refs.x1.getValue(),this.refs.y1.getValue()],[this.refs.x2.getValue(),this.refs.y2.getValue()]]}))),U(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e);let s,i;"x"===o[0]?s=0:"y"===o[0]&&(s=1),"1"===o[1]?i=0:"2"===o[1]&&(i=1),this.changePoint(i,s,t,n)})),U(this,"getInputPaths",(()=>[["x1"],["y1"],["x2"],["y2"]]))}componentDidUpdate(e){yv(this.props,e)||this.setState({line:this.props.line})}render(){const e=Iv(this.props.apiOptions),{TeX:t}=Y(),n=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"x1",ref:"x1",value:this.state.line[0][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,0),onFocus:M.default.partial(this.props.onFocus,"x1"),onBlur:M.default.partial(this.props.onBlur,"x1"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"y1",ref:"y1",value:this.state.line[0][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,1),onFocus:M.default.partial(this.props.onFocus,"y1"),onBlur:M.default.partial(this.props.onBlur,"y1"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")],o=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"x2",ref:"x2",value:this.state.line[1][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,0),onFocus:M.default.partial(this.props.onFocus,"x2"),onBlur:M.default.partial(this.props.onBlur,"x2"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"y2",ref:"y2",value:this.state.line[1][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,1),onFocus:M.default.partial(this.props.onFocus,"y2"),onBlur:M.default.partial(this.props.onBlur,"y2"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")];return _.createElement("div",null,k.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:n,point2:o}))}}},dilation:{verbName:k._("Dilate"),nounName:k._("Dilation"),lowerNounName:k._("dilation"),apply:function(e){return function(t){return function(e,t,n){const o=p.vector.subtract(e,t),s=p.vector.scale(o,n);return p.vector.add(t,s)}(t,e.center,e.scale)}},isValid:function(e){return M.default.isFinite(e.scale)&&M.default.isFinite(e.center[0])&&M.default.isFinite(e.center[1])},isEmpty:function(e){return null===e.scale&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return p.number.equal(e.scale,1)},collapse:function(e,t){return!!p.point.equal(e.center,t.center)&&{center:e.center,scale:e.scale*t.scale}},toTeX:function(e){const t=function(e){const t=Ce.toFraction(e,p.number.DEFAULT_TOLERANCE);return 1===t[1]?Ev(e):Ev(t[0])+"/"+Ev(t[1])}(e.scale);return k.$_("Dilation of scale %(scale)s about %(point)s",{scale:t,point:_v(e.center)})},Input:class extends _.Component{constructor(){super(...arguments),U(this,"state",{center:this.props.center||[null,null],scale:this.props.scale||null}),U(this,"value",(()=>({scale:this.refs.scale.getValue(),center:[this.refs.x.getValue(),this.refs.y.getValue()]}))),U(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e);let s=this.state.scale;const i=M.default.clone(this.state.center);"x"===o?i[0]=t:"y"===o?i[1]=t:"scale"===o&&(s=t),this.setState({scale:s,center:i},(()=>{this.props.onChange(n)}))})),U(this,"getInputPaths",(()=>[["x"],["y"],["scale"]]))}componentDidUpdate(e){yv(this.props,e)||this.setState({center:this.props.center,scale:this.props.scale})}render(){const e=Iv(this.props.apiOptions),{TeX:t}=Y(),n=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"point_x",ref:"x",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{const t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"x"),onBlur:M.default.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"point_y",ref:"y",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{const t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"y"),onBlur:M.default.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")],o=_.createElement(e,{ref:"scale",placeholder:1,value:this.state.scale,useArrowKeys:!0,onChange:e=>{this.setState({scale:e},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"scale"),onBlur:M.default.partial(this.props.onBlur,"scale"),keypadElement:this.props.keypadElement});return _.createElement("div",null,k.$_("Dilation about %(point)s by %(scale)s",{point:n,scale:o}))}}}},Av={getPointCountForType:function(e){const t=e.split("-");return"polygon"===t[0]?t[1]||3:"line"===t[0]||"lineSegment"===t[0]?2:"angle"===t[0]?3:"circle"===t[0]?2:"point"===t[0]?1:void 0},addMovableShape:function(e,t){if(t.editable&&t.translatable)throw new we("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously. options: "+JSON.stringify(t),be.InvalidInput);const n=M.default.map(t.shape.coords,(function(s){let i=!1,r=s;const a=e.addMovablePoint({coord:s,normalStyle:t.normalPointStyle,highlightStyle:t.highlightPointStyle,constraints:{fixed:!t.translatable&&!t.editable},visible:t.showPoints,snapX:t.snap&&t.snap[0]||0,snapY:t.snap&&t.snap[1]||0,bounded:!1,onMove:function(e,s){i||(r=a.coord,i=!0);let l=p.vector.subtract([e,s],a.coord);t.onMove&&(l=t.onMove(l[0],l[1])),t.translatable&&M.default.each(n,(function(e){e!==a&&e.setCoord(p.vector.add(e.coord,l))}));const c=a.coord,d=p.vector.add(a.coord,l);return a.coord=d,o.update(),a.coord=c,d},onMoveEnd:function(){if(t.onMoveEnd&&i){i=!1;const e=p.vector.subtract(a.coord,r);t.onMoveEnd(e[0],e[1])}o.update()}});return a.bounded=!0,a})),o=Av.addShape(e,t,n),s=o.remove;return o.remove=function(){s.apply(o),M.default.invoke(n,"remove")},o},addShape:function(e,t,n){n=n||t.shape.coords;const o=Av._typesOf(t.shape),s=t.shape.options||Av.defaultOptions(o),i=Av._mapTypes(o,n,(function(n,o,i){const r=M.default.extend({},t,s[i]);return Av._addType(e,n,o,r)})),r=M.default.filter(M.default.pluck(i,"update"),M.default.identity),a=M.default.filter(M.default.pluck(i,"remove"),M.default.identity),l=function(){return M.default.map(i,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:o,points:n,update:function(){M.default.invoke(r,"call")},remove:function(){M.default.invoke(a,"call")},toJSON:function(){const e=M.default.map(n,(function(e){return M.default.isArray(e)?e:e.coord}));return{type:o,coords:e,options:l()}},getOptions:l}},equal:function(e,t){const n=Av._typesOf(e),o=Av._typesOf(t);if(n.length!==o.length)return!1;const s=Av._mapTypes(n,e.coords,Av._combine),i=Av._mapTypes(o,t.coords,Av._combine);return M.default.all(M.default.map(s,(function(e,t){const n=i[t];return e.type===n.type&&Av._forType(e.type).equal(e.coords,n.coords)})))},_typesOf:function(e){let t=e.type;return M.default.isArray(t)||(t=[t]),M.default.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return M.default.map(e,(function(e){const t=Av._forType(e).defaultOptions;return M.default.extend({},t)}))},_forType:function(e){const t=e.split("-")[0];return Av[t]},_mapTypes:function(e,t,n,o){return M.default.map(e,(function(e,s){const i=Av.getPointCountForType(e),r=M.default.first(t,i);return t=M.default.rest(t,i),n.call(o,e,r,s)}))},_addType:function(e,t,n,o){const s=M.default.isArray(n[0])?{coordA:n[0],coordZ:n[1]}:{pointA:n[0],pointZ:n[1]};if("polygon"===(t=t.split("-")[0])){const t=e.addMovablePolygon(M.default.extend({},o,{fixed:!o.editable,snapX:o.snap&&o.snap[0]||0,snapY:o.snap&&o.snap[1]||0,points:n,constrainToGraph:!1}));return{update:t.transform.bind(t),remove:t.remove.bind(t)}}if("line"===t||"lineSegment"===t){const n=e.addMovableLineSegment(M.default.extend({},o,s,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:n.transform.bind(n,!0),remove:n.remove.bind(n)}}if("angle"===t){const t=!!o.editable&&null,s=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:n,normalStyle:o.normalStyle,reflex:o.reflex});return M.default.isArray(n[0])||o.editable||(n[0].remove(),n[2].remove()),{update:s.update.bind(s,t),remove:s.remove.bind(s),getOptions:function(){return{reflex:s.isReflex()}}}}if("circle"===t){let t={remove:M.default.identity};const s=function(){const s=n[0].coord||n[0],i=n[1].coord||n[1],r=p.point.distanceToPoint(s,i);t.remove(),t=e.circle(s,r,M.default.extend({stroke:bn.DYNAMIC,"stroke-width":2},o.normalStyle))};return s(),n[1].remove&&!o.editable&&n[1].remove(),{update:s,remove:function(){t.remove()}}}if("point"===t)return{update:null,remove:null};throw new we("Invalid shape type "+t,be.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:Mv},line:{equal:p.line.equal},lineSegment:{equal:Mv},angle:{equal:function(e,t){if(!p.point.equal(e[1],t[1]))return!1;const n=[e[1],e[0]],o=[e[1],e[2]],s=[t[1],t[0]],i=[t[1],t[2]],r=p.ray.equal(n,s)&&p.ray.equal(o,i),a=p.ray.equal(n,i)&&p.ray.equal(o,s);return r||a},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){const n=p.point.distanceToPoint(e[0],e[1]),o=p.point.distanceToPoint(t[0],t[1]);return p.point.equal(e[0],t[0])&&p.number.equal(n,o)}},point:{equal:p.point.equal}},Rv=Pv.ListItem;class Fv extends _.Component{constructor(){super(...arguments),U(this,"_transformationRefs",(()=>M.default.times(this.props.transformations.length,(e=>this.refs["transformation"+e])))),U(this,"value",(()=>M.default.invoke(this._transformationRefs(),"value"))),U(this,"handleChange",((e,t)=>{this.props.onChange(this.value(),t)})),U(this,"focusLast",(()=>{const e=this._transformationRefs();0!==e.length&&M.default.last(e).focus()}))}render(){if("static"===this.props.mode)return _.createElement("span",null);const e=M.default.map(this.props.transformations,(function(e,t){return _.createElement(Rv,{ref:"transformation"+t,key:"transformation"+t,transform:e,mode:this.props.mode,onChange:this.handleChange,onFocus:M.default.partial(this.props.onFocus,""+t),onBlur:M.default.partial(this.props.onBlur,""+t),keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions})}),this);return _.createElement("div",{className:"perseus-transformation-list"},e)}}class Ov extends _.Component{render(){const e=this.props.toggled?"simple-button exercise-orange toggled highlighted-tool-button":"simple-button";return _.createElement("button",{type:"button",className:e,disabled:this.props.disabled,onClick:this.props.onClick,onTouchStart:xv},this.props.children)}}class Dv extends _.Component{constructor(){super(...arguments),U(this,"state",{selected:null}),U(this,"changeSelected",(e=>{this.props.removeTool(this.state.selected),e&&e!==this.state.selected?(this.props.addTool(e),this.setState({selected:e})):this.setState({selected:null})}))}render(){const e=M.default.map(Nv,(function(e,t){if(this.props.enabled[t])return _.createElement(Ov,{key:t,disabled:this.props.apiOptions.readOnly,toggled:this.state.selected===t,onClick:this.changeSelected.bind(this,t)},e.verbName)}),this);return _.createElement("div",{className:"transformer-tools-bar"},_.createElement("span",{className:"simple-button-group"},e),_.createElement("button",{className:"transformer-undo-button simple-button",type:"button",disabled:this.props.apiOptions.readOnly,onClick:this.props.onUndoClick,onTouchStart:xv},_.createElement(V,Ro)," "+k._("Undo")),_.createElement("div",{className:"clear"}))}}class Lv extends _.Component{constructor(){super(...arguments),U(this,"changeSelected",(e=>{e&&this.props.addTool(e)}))}render(){const e=M.default.map(Nv,(function(e,t){if(this.props.enabled[t])return _.createElement(Ov,{key:t,toggled:!1,disabled:this.props.apiOptions.readOnly,onClick:this.changeSelected.bind(this,t)},_.createElement(V,Mo)," ",e.nounName)}),this);return _.createElement("div",{className:"transformer-tools-bar"},e,_.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,disabled:this.props.apiOptions.readOnly,onTouchStart:xv},_.createElement(V,Ro)," "+k._("Undo")),_.createElement("div",{className:"clear"}))}}class Bv extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"tools",void 0),U(this,"currentTool",void 0),U(this,"transformations",void 0),U(this,"shape",void 0),U(this,"dilationCircle",void 0),U(this,"rotatePoint",void 0),U(this,"rotateHandle",void 0),U(this,"shouldSetupGraphie",((e,t)=>!yv(t.starting,e.starting)||(t.graphMode!==e.graphMode||(t.listMode!==e.listMode||(t.drawSolutionShape!==e.drawSolutionShape||(!(!e.drawSolutionShape||yv(t.correct.shape,e.correct.shape))||!yv(this.tools,e.tools))))))),U(this,"graphie",(()=>this.refs.graph.graphie())),U(this,"setupGraphie",(e=>{this.props.drawSolutionShape&&this.props.correct.shape&&this.props.correct.shape.coords&&Av.addShape(e,{fixed:!0,shape:this.props.correct.shape,normalStyle:{stroke:bn.GRAY,"stroke-dasharray":"","stroke-width":2}}),this.currentTool=null,this.refs.toolsBar.changeSelected(null),this.addTransformerShape(this.props.starting.shape,!1),this.setTransformations(this.props.transformations),this.tools={translation:M.default.clone(this.props.tools.translation),rotation:M.default.clone(this.props.tools.rotation),reflection:M.default.clone(this.props.tools.reflection),dilation:M.default.clone(this.props.tools.dilation)}})),U(this,"setTransformations",(e=>{this.resetCoords(),this.transformations=M.default.clone(e),M.default.each(this.transformations,this.applyTransform)})),U(this,"addTransformerShape",((e,t)=>{const n=this,o=this.graphie();this.shape=Av.addMovableShape(o,{shape:e,editable:!1,showPoints:"static"!==this.props.graphMode,translatable:t,onMove:function(e,t){return e=Ce.roundToNearest(o.snap[0],e),t=Ce.roundToNearest(o.snap[1],t),n.addTransform({type:"translation",vector:[e,t]}),[e,t]},normalPointStyle:{fill:t?bn.INTERACTIVE:bn.DYNAMIC,stroke:t?bn.INTERACTIVE:bn.DYNAMIC},highlightPointStyle:{fill:bn.INTERACTING,stroke:bn.INTERACTING}})})),U(this,"addTool",(e=>{const t=this;if("interactive"===this.props.graphMode)if("translation"===e)this.currentTool=this.addTranslationTool();else if("rotation"===e)this.currentTool=this.addRotationTool();else if("reflection"===e)this.currentTool=this.addReflectionTool();else{if("dilation"!==e)throw new we("Invalid tool id: "+e,be.InvalidInput);this.currentTool=this.addDilationTool()}else{let n;if("translation"===e)n={type:"translation",vector:[null,null]};else if("rotation"===e)n={type:"rotation",center:[null,null],angleDeg:null};else if("reflection"===e)n={type:"reflection",line:[[null,null],[null,null]]};else{if("dilation"!==e)throw new we("Invalid tool id: "+e,be.InvalidInput);n={type:"dilation",center:[null,null],scale:null}}this.doTransform(n,(function(){t.refs.transformationList.focusLast()}))}})),U(this,"removeTool",(e=>{this.currentTool&&this.currentTool.remove(),this.currentTool=null})),U(this,"addTranslationTool",(()=>{var e,t;const n=this;return null===(e=this.shape)||void 0===e||e.remove(),this.addTransformerShape(null===(t=this.shape)||void 0===t?void 0:t.toJSON(),!0),{remove:function(){var e,t;null===(e=n.shape)||void 0===e||e.remove(),n.addTransformerShape(null===(t=n.shape)||void 0===t?void 0:t.toJSON(),!1)}}})),U(this,"snapCoord",(e=>{const t=this.graphie();return M.default.map(e,(function(e,n){return Ce.roundToNearest(t.snap[n],e)}))})),U(this,"normalizeReflectionCoords",(e=>{const t=this.snapCoord(p.line.midpoint(e)),n=p.vector.polarDegFromCart(p.vector.subtract(e[0],e[1])),o=[1,Ce.roundToNearest(45,n[1])],s=p.vector.cartFromPolarDeg(o);return M.default.map([-1,1],(function(e){const n=p.vector.add(t,p.vector.scale(s,e*this.scaleToCurrentRange(2)));return this.snapCoord(n)}),this)})),U(this,"addReflectionTool",(()=>{const e=this.props.tools.reflection;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),o=function(){t.changeTool("reflection",{coords:M.default.pluck(i,"coord")})},s=this.normalizeReflectionCoords(e.coords),i=M.default.map(s,(function(e){return n.addMovablePoint({coord:e,visible:!1})}),this);let r;const a=Sv(e);n.style({},(function(){r=n.addMovableLineSegment({fixed:e.constraints.fixed,constraints:e.constraints,pointA:i[0],pointZ:i[1],snapX:n.snap[0],snapY:n.snap[1],extendLine:!0,normalStyle:{stroke:a,"stroke-width":2,"stroke-dasharray":"- "},highlightStyle:{stroke:bn.INTERACTING,"stroke-width":2,"stroke-dasharray":"- "},movePointsWithLine:!0,onMoveEnd:o})}));const l=n.addReflectButton({fixed:e.constraints.fixed,line:r,size:this.scaleToCurrentRange(1),onClick:function(){t.doTransform({type:"reflection",line:M.default.pluck(i,"coord")}),c&&(c.setCoord(p.vector.add(l.coord,p.vector.subtract(l.coord,c.coord))),c.update())},normalStyle:{stroke:a,"stroke-width":2,fill:a},highlightStyle:{stroke:bn.INTERACTING,"stroke-width":3,fill:bn.INTERACTING},onMoveEnd:o});let c=null;if(!e.constraints.fixed){const e=p.vector.polarDegFromCart(p.vector.subtract(i[1].coord,i[0].coord))[1]+90;c=n.addRotateHandle({center:l,radius:this.scaleToCurrentRange(2),angleDeg:e,width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),lengthAngle:17,onMove:function(e){return Ce.roundToNearest(45,e)},onMoveEnd:o})}return P.default(r).on("move",(function(){l.update(),P.default(l).trigger("move")})),c&&P.default(c).on("move",(function(){const e=t.snapCoord(c.coord),n=p.vector.subtract(e,l.coord),o=l.isFlipped()?1:0;i[o].setCoord(p.vector.add(l.coord,p.vector.rotateDeg(n,90))),i[1-o].setCoord(p.vector.add(l.coord,p.vector.rotateDeg(n,-90))),r.transform(!0),l.update()})),{remove:function(){l.remove(),c&&c.remove(),r.remove(),i[0].remove(),i[1].remove()}}})),U(this,"scaleToCurrentRange",(e=>function(e,t){const n=t[0][1]-t[0][0],o=t[1][1]-t[1][0];return e*Math.max(n,o)/20}(e,this.refs.graph.props.range))),U(this,"addRotationTool",(()=>{const e=this.props.tools.rotation;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),o=Sv(e);return this.rotatePoint=n.addMovablePoint({constraints:e.constraints,coord:e.coord,snapX:n.snap[0],snapY:n.snap[1],normalStyle:{"stroke-dasharray":"",stroke:o,fill:o},highlightStyle:{"stroke-dasharray":"",stroke:bn.INTERACTING,fill:bn.INTERACTING}}),this.rotateHandle=n.addRotateHandle({center:this.rotatePoint,radius:this.scaleToCurrentRange(1.5),width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),onMove:function(e,n){const o=t.getRotationTransformFromAngle(t.rotatePoint.coord,e-n);return t.doTransform(o),n+o.angleDeg}}),this.rotatePoint.onMoveEnd=(e,n)=>{t.changeTool("rotation",{coord:[e,n]})},{remove:function(){var e,n;null===(e=t.rotateHandle)||void 0===e||e.remove(),null===(n=t.rotatePoint)||void 0===n||n.remove()}}})),U(this,"addDilationTool",(()=>{const e=this.props.tools.dilation;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),o=Sv(e);t.dilationCircle=n.addCircleGraph({centerConstraints:e.constraints,center:e.coord,radius:t.scaleToCurrentRange(2),snapX:n.snap[0],snapY:n.snap[1],minRadius:t.scaleToCurrentRange(1),snapRadius:t.scaleToCurrentRange(.5),onResize:function(e,n){t.doTransform({type:"dilation",center:t.dilationCircle.centerPoint.coord,scale:e/n})},circleNormalStyle:{stroke:o,"stroke-width":2,"stroke-dasharray":"- ","fill-opacity":0},circleHighlightStyle:{stroke:bn.INTERACTING,"stroke-width":2,"stroke-dasharray":"",fill:bn.INTERACTING,"fill-opacity":.05},centerNormalStyle:{stroke:o,fill:o,"stroke-width":2,"stroke-dasharray":""},centerHighlightStyle:{stroke:o,fill:o,"stroke-width":2,"stroke-dasharray":""}});const s=this.dilationCircle.centerPoint.onMoveEnd;return this.dilationCircle.centerPoint.onMoveEnd=function(){if(s){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];s(n)}t.changeTool("dilation",{coord:t.dilationCircle.centerPoint.coord})},{remove:function(){var e;null===(e=t.dilationCircle)||void 0===e||e.remove()}}})),U(this,"getRotationTransformFromAngle",((e,t)=>{(t=(t+360)%360)>180&&(t-=360);return{type:"rotation",center:e,angleDeg:15*Math.round(t/15)}})),U(this,"doTransform",((e,t)=>{this.applyTransform(e),this.addTransform(e,t)})),U(this,"applyTransform",(e=>{if("static"!==this.props.graphMode){const t=Pv.apply(e);this.applyCoordTransformation(t)}})),U(this,"applyCoordTransformation",(e=>{var t;M.default.each(this.shape.points,(function(t){const n=e(t.coord);t.setCoord(n)})),null===(t=this.shape)||void 0===t||t.update()})),U(this,"resetCoords",(()=>{var e;const t=this.props.starting.shape.coords;M.default.each(this.shape.points,(function(e,n){e.setCoord(t[n])})),null===(e=this.shape)||void 0===e||e.update()})),U(this,"handleUndoClick",(()=>{this.refs.toolsBar.changeSelected(null),this.props.transformations.length&&this.props.onChange({transformations:M.default.initial(this.props.transformations)})})),U(this,"setTransformationProps",((e,t)=>{this.props.onChange({transformations:e},t)})),U(this,"addTransform",((e,t)=>{this.transformations=Pv.append(this.transformations,e),this.props.onChange({transformations:M.default.clone(this.transformations)},t)})),U(this,"changeTool",((e,t)=>{const n=M.default.clone(this.props.tools);n[e]=M.default.extend({},this.props.tools[e],t),this.tools[e]=M.default.clone(n[e]),this.props.onChange({tools:n}),this.props.trackInteraction()})),U(this,"simpleValidate",(e=>Bv.validate(this.getUserInput(),e))),U(this,"getCoords",(()=>{const e=this.props.starting.shape.coords,t=this.props.transformations;return M.default.reduce(t,(function(e,t){return M.default.map(e,Pv.apply(t))}),e)})),U(this,"getEditorJSON",(()=>{const e=M.default.pick(this.props,"grading","starting","graphMode","listMode","tools","drawSolutionShape","gradeEmpty");return e.graph=this.refs.graph.toJSON(),e.version=1.2,e.answer=this.getUserInput(),e})),U(this,"getUserInput",(()=>{var e;return{transformations:this.props.transformations,shape:{type:this.shape.type,coords:this.getCoords(),options:null===(e=this.shape)||void 0===e?void 0:e.getOptions()}}})),U(this,"_handleFocus",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];e.props.onFocus(n)})),U(this,"_handleBlur",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];e.props.onBlur(n)})),U(this,"_getTransformationForID",(e=>{const t=["transformationList","transformation"+e];let n=this;return M.default.each(t,(e=>{n=n.refs[e]})),n})),U(this,"getInputPaths",(()=>{if("static"===this.props.listMode)return[];let e=[];return M.default.each(this.props.transformations,((t,n)=>{const o=this._getTransformationForID(n).getInputPaths(),s=M.default.map(o,(e=>[""+n].concat(e)));e=e.concat(s)})),e})),U(this,"_passToInner",(function(e,t){if(!t||!t.length)return;const n=M.default.rest(t),o=M.default.head(t),s=this._getTransformationForID(o);for(var i=arguments.length,r=new Array(i>2?i-2:0),a=2;a<i;a++)r[a-2]=arguments[a];return s[e](n,...r)})),U(this,"focus",(()=>{const e=this.getInputPaths();return e.length>0&&(this.focusInputPath(e[0]),!0)})),U(this,"focusInputPath",(e=>0!==e.length&&(wv(e.length>=2),this._passToInner("focusInputPath",e)))),U(this,"blurInputPath",(e=>0!==e.length&&(wv(e.length>=2),this._passToInner("blurInputPath",e)))),U(this,"setInputValue",((e,t,n)=>(wv(e.length>=2),this._passToInner("setInputValue",e,t,n)))),U(this,"getDOMNodeForPath",(e=>(wv(e.length>=2),this._passToInner("getDOMNodeForPath",e)))),U(this,"getGrammarTypeForPath",(e=>(wv(e.length>=2),this._passToInner("getGrammarTypeForPath",e))))}render(){const e=M.default.extend(function(e,t){const n=(e=e||{}).labels||["x","y"],o=e.range||[[-10,10],[-10,10]],s=e.step||[1,1];return{box:[t,t],labels:n,range:o,step:s,gridStep:e.gridStep||bv(o,s,t),valid:!0,backgroundImage:Cv,markings:"grid",showProtractor:!1}}(this.props.graph,400),this.props.graph),t="interactive"===this.props.graphMode,n=t?Dv:Lv,o=_.createElement("div",{style:{width:e.box[0]}},_.createElement(n,{ref:"toolsBar",enabled:(s=this.props.tools,i="enabled",M.default.object(M.default.map(s,(function(e,t){return[t,e[i]]})))),apiOptions:this.props.apiOptions,addTool:this.addTool,removeTool:this.removeTool,onUndoClick:this.handleUndoClick}));var s,i;return _.createElement("div",{className:"perseus-widget perseus-widget-transformer"},_.createElement(Nh,{ref:"graph",box:e.box,range:e.range,labels:e.labels,step:e.step,gridStep:e.gridStep,markings:e.markings,backgroundImage:e.backgroundImage,showProtractor:e.showProtractor,onGraphieUpdated:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!t&&k._("Add transformations below:"),"static"===this.props.graphMode&&[_.createElement("br",{key:"static-br"}),_.createElement("em",{key:"static-nomove"}," ",k._("Note: For this question, the shape will not move.")," ")],t&&o,_.createElement(Fv,{ref:"transformationList",mode:this.props.listMode,transformations:this.props.transformations,onChange:this.setTransformationProps,onFocus:this._handleFocus,onBlur:this._handleBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions}),!t&&o)}componentDidMount(){this.setupGraphie(this.graphie())}componentDidUpdate(e){this.shouldSetupGraphie(this.props,e)?this.refs.graph.reset():yv(this.props.transformations,this.transformations)||this.setTransformations(this.props.transformations)}static validate(e,t){for(const n in Nv)if(t.tools[n].required){const t=M.default.any(M.default.map(e.transformations,(function(e){return e.type===n&&!Pv.isEmpty(e)&&!Pv.isNoOp(e)})));if(!t)return{type:"invalid",message:k._("Your transformation must use a %(type)s.",{type:Nv[n].lowerNounName})}}return Av.equal(e.shape,t.correct.shape)?{type:"points",earned:1,total:1,message:null}:!t.gradeEmpty&&yv(e.shape.coords,t.starting.shape.coords)?{type:"invalid",message:k._("Use the interactive graph to define a correct transformation.")}:{type:"points",earned:0,total:1,message:null}}}U(Bv,"defaultProps",M.default.defaults({transformations:[]},kv));var zv,qv={name:"transformer",displayName:"Transformer",widget:Bv},Hv={exports:{}};zv=function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var s=t[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){var n=function(e){return e===Object(e)},o=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var o in n)e[o]=n[o]}return e};e.exports={isObject:n,merge:o,clone:function(e){return n(e)?Array.isArray(e)?e.slice():o(e):e}}},function(e,t,n){var o=n(0),s=o.clone,i=o.isObject,r=o.merge,a=n(2),l=n(3),c=n(4),d=function(e){return Array.isArray(e)?a:i(e)?l:"string"==typeof e?c:void 0},p=function(e){if(e instanceof p)return e;if(!(this instanceof p))return new p(e);var t=d(e);this._wrapped=t.thaw?t.thaw(e):e};p.prototype.freeze=function(){var e=this._wrapped,t=d(e);return t.freeze?t.freeze(e):e},p.prototype.zoom=function(e){return void 0===this._zoomStack&&(this._zoomStack=[]),this._zoomStack.push({zoom:e,wrapped:this._wrapped}),this._wrapped=p(this._wrapped).get(e),this},p.prototype.deZoom=function(){var e=this._zoomStack.pop();return this._wrapped=p(e.wrapped).set(e.zoom,this._wrapped).freeze(),this},p.prototype.get=function(e){for(var t=this._wrapped,n=0;n<e.length;n++)t=d(t).get(t,e[n]);return t},p.prototype.mod=function(e,t){var n=this._wrapped,o=s(n),i=d(n);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=i.mod(o,e[0],t);else{var r=e[0],a=e.slice(1);o[r]=p(n[r]).mod(a,t).freeze(),this._wrapped=o}return this},p.prototype.merge=function(e,t){return this._wrapped=p(this._wrapped).mod(e,(function(e){return r(e,t)})).freeze(),this},p.prototype.del=function(e){var t=this._wrapped,n=d(t);if(1===e.length)this._wrapped=n.del(t,e[0]);else{var o=e[0],i=e.slice(1),r=s(t);r[o]=p(t[o]).del(i).freeze(),this._wrapped=r}return this},p.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=p},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var o=e.splice();return o[t]=n,o},mod:function(e,t,n){var o=e.slice();return o[t]=n(e[t]),o},del:function(e,t){var n=e.slice();return n.splice(t,1),n}}},function(e,t,n){var o=n(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var s=o(e);return s[t]=n,s},mod:function(e,t,n){var s=o(e);return s[t]=n(e[t]),s},del:function(e,t){var n=o(e);return delete n[t],n}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var o=e.splice();return o[t]=n,o},mod:function(e,t,n){var o=e.splice();return o[t]=n(e[t]),o},del:function(e,t){var n=e.slice();return n.splice(t),n}}}])};var Wv=vn(Hv.exports=zv());class Uv{constructor(e){U(this,"order",void 0),U(this,"mantissa",void 0),U(this,"positive",void 0),U(this,"sigFigs",void 0),U(this,"sigDecs",void 0),this.order=Yv(e),this.mantissa=jv(e),this.positive=Vv(e),this.sigFigs=this.mantissa.length,this.sigDecs=this.order-this.mantissa.length}}function Gv(e){let t=0;for(let n=e.length-1;n>=0;n--){if("0"!=e.charAt(n))return t;t++}return t}function Vv(e){let t=!0,n=!1,o=!1,s="",i="",r=!0;for(let a=0;a<e.length;a++){const l=e.charAt(a);l>="1"&&l<="9"?(i+=s+l,s="",o=!0,t=!1):"0"==l?(n?o&&(i+=s+l,s=""):o&&(s+=l),t=!1):n||"."!=l?"e"==l||"E"==l&&a+1<e.length?(parseInt(e.substring(a+1,e.length)),a=e.length):!t||"+"!=l&&"-"!=l||"-"==l&&(r=!r):(i+=s,s="",n=!0,t=!1)}return""==i||r}function jv(e){let t=!1,n=!1,o="",s="",i="";for(let r=0;r<e.length;r++){const a=e.charAt(r);a>="1"&&a<="9"?(i+=o+a,o="",n=!0):"0"==a?t?n?(i+=o+a,o=""):s+=a:n?(s+=a,o+=a):s+=a:t||"."!=a?("e"==a||"E"==a&&r+1<e.length)&&(parseInt(e.substring(r+1,e.length)),r=e.length):(i+=o,o="",t=!0)}return""==i?s:i}function Yv(e){let t=!1,n=!1,o="",s="",i=0,r=0;for(let a=0;a<e.length;a++){const l=e.charAt(a);if(l>="1"&&l<="9")s+=o+l,o="",n=!0,t||(r++,i++);else if("0"==l)t?n?(s+=o+l,o=""):i--:(r++,n&&(i++,o+=l));else if(t||"."!=l){if("e"==l||"E"==l&&a+1<e.length){const t=parseInt(e.substring(a+1,e.length));i+=t,r+=t,a=e.length}}else s+=o,o="",t=!0}return""==s?r:i}function $v(e,t){const n=e.length-t-1;if(n<0)return"";if(n>=e.length-1)return e;const o=e.charAt(n+1),s=e.charAt(n);let i=!1;if(o>"5")i=!0;else if("5"==o){for(let t=n+2;t<e.length;t++)"0"!=e.charAt(t)&&(i=!0);s%2==1&&(i=!0)}let r="";for(let t=n;t>=0;t--){const n=e.charAt(t);if(i){let e;if("9"==n)e="0";else{switch(n){case"0":e="1";break;case"1":e="2";break;case"2":e="3";break;case"3":e="4";break;case"4":e="5";break;case"5":e="6";break;case"6":e="7";break;case"7":e="8";break;case"8":e="9"}i=!1}r=e+r}else r=n+r}return i&&(r="1"+r),r}class Xv extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"_errorTimeout",void 0),U(this,"_showError",(()=>{if(""===this.props.value)return;const e=P.default(N.default.findDOMNode(this.refs.error));e.is(":visible")||e.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)})),U(this,"_hideError",(()=>{const e=P.default(N.default.findDOMNode(this.refs.error));e.is(":visible")&&e.animate({top:50,opacity:.1},300,(function(){P.default(this).hide()}))})),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)})),U(this,"handleBlur",(()=>{this.props.onBlur([]),clearTimeout(this._errorTimeout),E.default.unitParse(this.props.value).parsed||this._showError()})),U(this,"handleChange",(e=>{this._hideError(),this.props.onChange({value:e.target.value})})),U(this,"simpleValidate",((e,t)=>Xv.validate(this.getUserInput(),e))),U(this,"getUserInput",(()=>this.props.value)),U(this,"getInputPaths",(()=>[[]])),U(this,"focusInputPath",(e=>{const t=N.default.findDOMNode(this.refs.input);t&&t.focus()})),U(this,"handleFocus",(()=>{this.props.onFocus([])})),U(this,"blurInputPath",(e=>{const t=N.default.findDOMNode(this.refs.input);t&&t.blur()})),U(this,"setInputValue",((e,t,n)=>{this.props.onChange({value:t},n)})),U(this,"getDOMNodeForPath",(()=>N.default.findDOMNode(this.refs.input))),U(this,"getGrammarTypeForPath",(e=>"unit"))}static validate(e,t){const n=E.default.unitParse(t.value).expr,o=E.default.unitParse(e);if(!o.parsed)return{type:"invalid",message:k._("I couldn't understand those units.")};let s=null;const i=t.sigfigs,r=(a=o.coefficient,new Uv(a).sigFigs===i);var a;let l,c;r||(s=k._("Check your significant figures."));try{const e=new E.default.Var("x"),t=new E.default.Eq(n.simplify(),"=",new E.default.Mul(e,o.expr.simplify())).solveLinearEquationForVariable(e);l=Number(t.eval()).toPrecision(i)===Number(1).toPrecision(i)}catch(e){l=!1}l||(s=k._("That answer is numerically incorrect."));const d=Kv(o.expr.simplify()),p=Kv(n.simplify());c="all"===t.accepting?E.default.compare(d,p).equal:M.default(t.acceptingUnits).any((e=>{const t=Kv(E.default.unitParse(e).unit.simplify());return E.default.compare(t,d).equal})),c||(s=k._("Check your units."));return{type:"points",earned:c&&l&&r?1:0,total:1,message:s}}render(){const e=this.props.apiOptions.staticRender?_.createElement(le,{onChange:this.handleChange,ref:"input",className:te.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur}):_.createElement("input",{onChange:this.handleChange,ref:"input",className:te.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur});return _.createElement("div",{className:"old-unit-input"},e,_.createElement("div",{ref:"error",className:"error",style:{display:"none"}},k._("I don't understand that")))}componentDidUpdate(){clearTimeout(this._errorTimeout),E.default.unitParse(this.props.value).parsed?this._hideError():this._errorTimeout=setTimeout(this._showError,2e3)}componentWillUnmount(){clearTimeout(this._errorTimeout)}}U(Xv,"defaultProps",{apiOptions:ee.defaults,value:""});const Kv=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()};var Zv={name:"unit-input",displayName:"Unit",defaultAlignment:"inline-block",widget:Xv,transform:e=>Wv(e).del(["value"]).freeze(),version:{major:0,minor:1},hidden:!0};const Jv=B.default.large_24,Qv={small:{query:"(max-width: 767px)",totalColumns:4,gutterWidth:B.default.medium_16,marginWidth:B.default.medium_16},medium:{query:"(min-width: 768px) and (max-width: 1023px)",totalColumns:8,gutterWidth:B.default.xLarge_32,marginWidth:B.default.large_24},large:{query:"(min-width: 1024px)",totalColumns:12,gutterWidth:B.default.xLarge_32,marginWidth:Jv,maxWidth:1120+2*Jv}},ey={large:{query:"(min-width: 1px)",totalColumns:12,gutterWidth:B.default.xLarge_32,marginWidth:B.default.medium_16}},ty={small:{query:"(max-width: 767px)",totalColumns:4,gutterWidth:B.default.medium_16,marginWidth:B.default.medium_16},large:{query:"(min-width: 768px)",totalColumns:12,gutterWidth:B.default.xLarge_32,marginWidth:B.default.xxLarge_48}},ny={ssrSize:"large",mediaSpec:Qv};_.createContext(ny),[].concat(Object.values(Qv).map((e=>e.query)),Object.values(ey).map((e=>e.query)),Object.values(ty).map((e=>e.query))),d.StyleSheet.create({grow:{flexGrow:1}});class oy extends _.Component{render(){const{size:e,style:t}=this.props;return _.createElement(m.View,{"aria-hidden":"true",style:[sy(e),t]})}}const sy=e=>({width:e,MsFlexBasis:e,MsFlexPreferredSize:e,WebkitFlexBasis:e,flexBasis:e,flexShrink:0}),iy=/^https?:\/\//,ry=e=>{const t=e.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/);return t&&11===t[7].length?t[7]:"videoNotFound"},ay=e=>{const{location:t}=e,{useVideo:n}=Y(),[o,s]=iy.test(t)?[ry(t),"YOUTUBE_ID"]:[t,"READABLE_ID"],i=n(o,s);switch(i.status){case"loading":return _.createElement(m.View,null,k._("Loading..."));case"success":{var r;const e=null===(r=i.data)||void 0===r?void 0:r.video;return _.createElement(m.View,{style:ly.transcriptLink},_.createElement(m.Text,null,null==e?void 0:e.title),_.createElement(oy,{size:10}),_.createElement(q.default,{href:"/transcript/"+((null==e?void 0:e.contentId)||"videoNotFound"),target:"_blank",className:"visited-no-recolor"},k._("See video transcript")))}default:return _.createElement(m.View,null,k._("Something went wrong."))}},ly=d.StyleSheet.create({transcriptLink:{flexDirection:"row",width:"100%",justifyContent:"center"}}),cy="{host}/embed_video?slug={slug}&internal_video_only=1",dy=/^https?:\/\//,py=/(khanacademy\.org|localhost)/;class uy extends _.Component{constructor(){var e;super(...arguments),e=this,U(this,"getUserInput",(()=>null)),U(this,"simpleValidate",(e=>uy.validate(null,e))),U(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return dr.apply(e,n)}))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const{InitialRequestUrl:e}=Y(),t=this.props.location;if(!t)return _.createElement("div",null);let n;if(dy.test(t))n=t;else{n=cy.replace("{slug}",t);let o="https://www.khanacademy.org";py.test(e.host)&&(o=e.origin),n=n.replace("{host}",o)}return _.createElement(m.View,null,_.createElement(dn,{width:1280,height:720,key:t+this.props.alignment},_.createElement(m.View,{style:fl.srOnly},k._("Khan Academy video wrapper")),_.createElement("iframe",{className:"perseus-video-widget",sandbox:"allow-same-origin allow-scripts",width:1280,height:720,src:n,allowFullScreen:!0})),_.createElement(ay,{location:t}))}}var hy=[Yl,ec,rc,uc,sc,qu,tu,iu,Wu,Vu,Xu,hh,of,uf,Ef,Qf,Of,nm,Nm,Wm,$m,Rg,zr,Km,Lg,qg,Wg,rv,cv,vv,qv,Zv,{name:"video",displayName:"Video",defaultAlignment:"block",supportedAlignments:["block","float-left","float-right","full-width"],widget:uy}];var fy=[...Gl,...hy];vi(fy);const my=xi();my["::renderer::"]=W;const{Keypad:gy}=e.components,vy={propTypes:{apiOptions:I.default.shape({customKeypad:I.default.bool,nativeKeypadProxy:I.default.func}),keypadStyle:I.default.any},getInitialState(){const e=this;let t=null;return e.props.apiOptions&&e.props.apiOptions.customKeypad&&e.props.apiOptions.nativeKeypadProxy&&(t=e.props.apiOptions.nativeKeypadProxy((()=>e.blur&&e.blur()))),{keypadElement:t}},componentDidMount(){const e=this;var t;e.props.apiOptions&&e.props.apiOptions.customKeypad&&!e.props.apiOptions.nativeKeypadProxy&&(e._keypadContainer=document.createElement("div"),null===(t=document.body)||void 0===t||t.appendChild(e._keypadContainer),N.default.render(_.createElement(gy,{onElementMounted:t=>{e.setState({keypadElement:t})},onDismiss:()=>{e.blur&&e.blur()},style:e.props.keypadStyle}),e._keypadContainer))},componentWillUnmount(){const e=this;e._keypadContainer&&(N.default.unmountComponentAtNode(e._keypadContainer),e._keypadContainer.parentNode&&e._keypadContainer.parentNode.removeChild(e._keypadContainer),e._keypadContainer=null)},keypadElement(){return this.state.keypadElement}},yy=I.default.shape({content:I.default.string,widgets:I.default.objectOf(I.default.any),images:I.default.objectOf(I.default.any)});class by extends _.Component{constructor(e){super(e),U(this,"_currentFocus",void 0),U(this,"keypadElement",(()=>vy.keypadElement.call(this))),U(this,"_handleFocusChange",((e,t)=>{e?this._setCurrentFocus(e):this._onRendererBlur(t)})),U(this,"_setCurrentFocus",(e=>{const t=this.keypadElement(),n=this._currentFocus;this._currentFocus=e;let o=!1;if(this._currentFocus){const[e,...t]=this._currentFocus;o=this.refs[e].getInputPaths().some((e=>Ye.inputPathsEqual(e,t)))}null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,n,o&&t&&t.getDOMNode()),t&&(o?t.activate():t.dismiss())})),U(this,"_onRendererBlur",(e=>{const t=this._currentFocus;Ye.inputPathsEqual(e,t)&&setTimeout((()=>{Ye.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))})),U(this,"blur",(()=>{if(this._currentFocus){const[e,...t]=this._currentFocus;this.refs[e].blurPath(t)}})),U(this,"_sections",(()=>Array.isArray(this.props.json)?this.props.json:[this.props.json])),this.state=vy.getInitialState.call(this)}componentDidMount(){vy.componentDidMount.call(this),this._currentFocus=null}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}componentWillUnmount(){vy.componentWillUnmount.call(this)}render(){const e={...ee.defaults,...this.props.apiOptions,isArticle:!0},t=S.default({"framework-perseus":!0,"perseus-article":!0,"bibliotron-article":this.props.useNewStyles,[te.MOBILE]:e.isMobile}),n=this._sections().map(((t,n)=>{const o="section-".concat(n);return _.createElement("div",{key:n,className:"clearfix"},_.createElement(qi,G({},t,{ref:o,key:n,key_:n,keypadElement:this.keypadElement(),apiOptions:{...e,onFocusChange:(e,t)=>{this._handleFocusChange(e&&[o].concat(e),t&&[o].concat(t))}},linterContext:en.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint})))}));return _.createElement("div",{className:t},n)}}U(by,"propTypes",{...vy.propTypes,apiOptions:I.default.shape({onFocusChange:I.default.func,isMobile:I.default.bool}),json:I.default.oneOfType([yy,I.default.arrayOf(yy)]).isRequired,useNewStyles:I.default.bool,linterContext:tn,legacyPerseusLint:I.default.arrayOf(I.default.string)}),U(by,"defaultProps",{apiOptions:{},useNewStyles:!1,linterContext:nn});class xy extends _.Component{constructor(){super(...arguments),U(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),U(this,"restoreSerializedState",((e,t)=>{this.refs.renderer.restoreSerializedState(e,t)}))}render(){const{apiOptions:e,className:t,hint:n,lastHint:o,lastRendered:s,pos:i,totalHints:r}=this.props,{isMobile:a}=e,l=S.default(!a&&"perseus-hint-renderer",a&&d.css(wy.newHint),a&&s&&d.css(wy.lastRenderedNewHint),o&&"last-hint",s&&"last-rendered",t),c={...e,customKeypad:!1,staticRender:!1};return _.createElement("div",{className:l,tabIndex:"-1"},!e.isMobile&&_.createElement("span",{className:"perseus-sr-only"},k._("Hint #%(pos)s",{pos:i+1})),!e.isMobile&&!e.satStyling&&r&&null!=i&&_.createElement("span",{className:"perseus-hint-label",style:{display:"block",color:e.hintProgressColor}},"".concat(i+1," / ").concat(r)),_.createElement(qi,{ref:"renderer",widgets:n.widgets,content:n.content||"",images:n.images,apiOptions:c,findExternalWidgets:this.props.findExternalWidgets,linterContext:en.pushContextStack(this.props.linterContext,"hint")}))}}U(xy,"defaultProps",{linterContext:nn});const wy=d.StyleSheet.create({newHint:{marginBottom:24,borderLeftColor:"#F6F7F7",borderLeftStyle:"solid",borderLeftWidth:4,[$r.lgOrSmaller]:{paddingLeft:16},[$r.smOrSmaller]:{paddingLeft:0},":focus":{outline:"none"}},lastRenderedNewHint:{marginBottom:0,borderLeftColor:"#71B307"}});class Cy extends _.Component{constructor(){super(...arguments),U(this,"state",{isFinalHelpPage:!1}),U(this,"_hintsVisible",(()=>null==this.props.hintsVisible||-1===this.props.hintsVisible?this.props.hints.length:this.props.hintsVisible)),U(this,"_cacheImagesInHint",(e=>{M.default.each(e.images,((e,t)=>{(new Image).src=Ye.getRealImageUrl(t)}))})),U(this,"_cacheHintImages",(()=>{this._hintsVisible()>0?M.default.each(this.props.hints,this._cacheImagesInHint):this.props.hints.length>0&&this._cacheImagesInHint(this.props.hints[0])})),U(this,"getApiOptions",(()=>({...ee.defaults,...this.props.apiOptions,readOnly:!1}))),U(this,"getSerializedState",(()=>M.default.times(this._hintsVisible(),(e=>this.refs["hintRenderer"+e].getSerializedState())))),U(this,"restoreSerializedState",((e,t)=>{let n=1;const o=()=>{--n,t&&0===n&&t()};M.default.each(e,((e,t)=>{const s=this.refs["hintRenderer"+t];s&&(++n,s.restoreSerializedState(e,o))})),o()}))}componentDidMount(){this._cacheHintImages()}UNSAFE_componentWillReceiveProps(e){e.hintsVisible-this.props.hintsVisible>1&&this.setState({isFinalHelpPage:!0})}componentDidUpdate(e,t){if(M.default.isEqual(e.hints,this.props.hints)&&e.hintsVisible===this.props.hintsVisible||this._cacheHintImages(),e.hintsVisible<this.props.hintsVisible){const e=this.props.hintsVisible-1;N.default.findDOMNode(this.refs["hintRenderer"+e]).focus()}}render(){const e=this.getApiOptions(),t=this._hintsVisible(),n=[],o=this.state.isFinalHelpPage;this.props.hints.slice(0,t).forEach(((s,i)=>{const r=i===this.props.hints.length-1&&!/\*\*/.test(s.content),a=i===t-1,l=_.createElement(xy,{lastHint:r,lastRendered:a,hint:s,pos:i,totalHints:this.props.hints.length,ref:"hintRenderer"+i,key:"hintRenderer"+i,apiOptions:e,findExternalWidgets:this.props.findExternalWidgets,linterContext:en.pushContextStack(this.props.linterContext,"hints["+i+"]")});o?n.push(l):s.replace&&n.length>0?n[n.length-1]=l:n.push(l)}));const{getAnotherHint:s}=e,i=s&&t>0&&t<this.props.hints.length,r="(".concat(t,"/").concat(this.props.hints.length,")"),a=S.default(this.props.className,e.isMobile&&t>0&&d.css(ky.mobileHintStylesHintsRenderer));return _.createElement("div",{className:a},e.isMobile&&t>0&&_.createElement("div",{className:d.css(ky.mobileHintStylesHintTitle,ta.responsiveLabel)},k._("Hints")),n,i&&_.createElement("button",{rel:"button",className:d.css(ky.linkButton,ky.getAnotherHintButton,e.isMobile&&ky.mobileHintStylesGetAnotherHintButton),onClick:e=>{e.preventDefault(),e.stopPropagation(),s&&s()}},_.createElement("span",{className:d.css(ky.plusText,e.isMobile&&ky.mobileHintStylesPlusText)},"+"),_.createElement("span",{className:d.css(ky.getAnotherHintText)},k._("Get another hint")," ",r)))}}U(Cy,"defaultProps",{linterContext:nn});const ky=d.StyleSheet.create({rendererMargins:{marginTop:16},linkButton:{cursor:"pointer",border:"none",backgroundColor:"transparent",fontSize:"100%",fontFamily:"inherit",fontWeight:"bold",color:"#71B307",padding:0,position:"relative"},plusText:{fontSize:20,position:"absolute",top:-3,left:0},getAnotherHintText:{marginLeft:16},mobileHintStylesHintsRenderer:{marginTop:64,border:"solid ".concat("#D6D8DA"),borderWidth:"1px 0 0 0",position:"relative",":before":{content:'""',display:"table",clear:"both"},":after":{content:'""',display:"table",clear:"both"}},mobileHintStylesHintTitle:{fontFamily:"inherit",fontStyle:"normal",fontWeight:"bold",color:he,paddingTop:16,paddingBottom:24,[$r.lgOrSmaller]:{paddingLeft:0},[$r.smOrSmaller]:{paddingLeft:20}},getAnotherHintButton:{marginTop:24},mobileHintStylesGetAnotherHintButton:{[$r.lgOrSmaller]:{paddingLeft:0},[$r.smOrSmaller]:{paddingLeft:20}},mobileHintStylesPlusText:{[$r.lgOrSmaller]:{left:0},[$r.smOrSmaller]:{left:20}}}),{mapObject:Sy}=In;class Ey extends _.Component{constructor(e){super(e),U(this,"questionRenderer",void 0),U(this,"hintsRenderer",void 0),U(this,"_currentFocus",void 0),U(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),U(this,"handleInteractWithWidget",(e=>{const t=M.default.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),this.state={...vy.getInitialState.call(this),hintsVisible:e.initialHintsVisible||0,questionCompleted:!1,questionHighlightedWidgets:[]}}componentDidMount(){vy.componentDidMount.call(this),this.props.controlPeripherals&&this.props.apiOptions.setDrawingAreaAvailable&&this.props.apiOptions.setDrawingAreaAvailable(!0),this._currentFocus=null,this.update()}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(){this.update()}componentWillUnmount(){vy.componentWillUnmount.call(this);const e=document.querySelector(this.props.workAreaSelector);null!=e&&A.unmountComponentAtNode(e);const t=document.querySelector(this.props.hintsAreaSelector);if(null!=t&&A.unmountComponentAtNode(t),this.props.controlPeripherals){const e=this.props.item.answerArea||{};e.calculator&&P.default("#calculator").hide(),e.periodicTable&&P.default(".periodic-table-info-box").hide(),e.zTable&&P.default(".z-table-info-box").hide(),e.tTable&&P.default(".t-table-info-box").hide(),e.chi2Table&&P.default(".chi2-table-info-box").hide()}}keypadElement(){return vy.keypadElement.call(this)}update(){const e={...ee.defaults,...this.props.apiOptions,onFocusChange:this._handleFocusChange},t=document.querySelector(this.props.workAreaSelector),n=document.querySelector(this.props.hintsAreaSelector);if(!t||!n)return;A.render(_.createElement(qi,G({ref:t=>{if(!t)return;this.questionRenderer=t;const{answerableCallback:n}=e;if(n){n(0===this.questionRenderer.emptyWidgets().length)}},keypadElement:this.keypadElement(),problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,savedState:this.props.savedState,linterContext:en.pushContextStack(this.props.linterContext,"question")},this.props.item.question,{legacyPerseusLint:this.props.legacyPerseusLint})),t),A.render(_.createElement(Cy,{ref:e=>this.hintsRenderer=e,hints:this.props.item.hints,hintsVisible:this.state.hintsVisible,apiOptions:e,linterContext:en.pushContextStack(this.props.linterContext,"hints")}),n);const o=this.props.item.answerArea||{};this.props.controlPeripherals?(P.default("#calculator").toggle(o.calculator||!1),P.default(".periodic-table-info-box").toggle(o.periodicTable||!1),P.default(".z-table-info-box").toggle(o.zTable||!1),P.default(".t-table-info-box").toggle(o.tTable||!1),P.default(".chi2-table-info-box").toggle(o.chi2Table||!1)):(o.calculator&&this.props.onShowCalculator&&this.props.onShowCalculator(),o.periodicTable&&this.props.onShowPeriodicTable&&this.props.onShowPeriodicTable(),o.zTable&&this.props.onShowZTable&&this.props.onShowZTable(),o.tTable&&this.props.onShowTTable&&this.props.onShowTTable(),o.chi2Table&&this.props.onShowChi2Table&&this.props.onShowChi2Table())}_setCurrentFocus(e){const t=this.keypadElement(),n=this._currentFocus;this._currentFocus=e;const o=this.getInputPaths(),s=this._currentFocus&&o.some((e=>Ye.inputPathsEqual(e,this._currentFocus)));null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,n,s&&t&&t.getDOMNode()),t&&(s?t.activate():t.dismiss())}_onRendererBlur(e){const t=this._currentFocus;Ye.inputPathsEqual(e,t)&&setTimeout((()=>{Ye.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))}_setWidgetProps(e,t,n){this.questionRenderer._setWidgetProps(e,t,n)}setInputValue(e,t,n){return this.questionRenderer.setInputValue(e,t,n)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}showHint(){this.state.hintsVisible<this.getNumHints()&&this.setState({hintsVisible:this.state.hintsVisible+1})}getNumHints(){return this.props.item.hints.length}scoreInput(){const e=this.questionRenderer.guessAndScore(),t=e[0],n=e[1],o=[t,[]],s=Ye.keScoreFromPerseusScore(n,o,this.questionRenderer.getSerializedState()),i=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:s.correct,questionHighlightedWidgets:i}),s}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){const e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),n=this.questionRenderer.getSerializedState();return Sy(e,((e,o)=>Ye.keScoreFromPerseusScore(e,t[o],n[o])))}getSerializedState(){var e;return{question:this.questionRenderer.getSerializedState(),hints:null===(e=this.hintsRenderer)||void 0===e?void 0:e.getSerializedState()}}restoreSerializedState(e,t){var n;let o=2;const s=()=>{--o,t&&0===o&&t()};this.questionRenderer.restoreSerializedState(e.question,s),null===(n=this.hintsRenderer)||void 0===n||n.restoreSerializedState(e.hints,s)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){return _.createElement("div",null)}}U(Ey,"defaultProps",{apiOptions:ee.defaults,controlPeripherals:!0,hintsAreaSelector:"#hintsarea",initialHintsVisible:0,workAreaSelector:"#workarea",reviewMode:!1,linterContext:nn});const _y={onRendered:e=>{}},Ty=_.createContext(_y),{mapObject:My}=In;class Iy extends _.Component{constructor(e){super(e),U(this,"questionRenderer",void 0),U(this,"hintsRenderer",void 0),U(this,"_currentFocus",void 0),U(this,"_fullyRendered",void 0),U(this,"blurTimeoutID",void 0),U(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),U(this,"handleInteractWithWidget",(e=>{const t=M.default.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),U(this,"setAssetStatus",((e,t)=>{const n={...this.state.assetStatuses,[e]:t};this.setState({assetStatuses:n})})),this.state={questionCompleted:!1,questionHighlightedWidgets:[],assetStatuses:{}},this._fullyRendered=!1}componentDidMount(){this._currentFocus=null,this._fullyRendered=!1}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(e,t){if(this.props.apiOptions.answerableCallback){const e=0===this.questionRenderer.emptyWidgets().length,{answerableCallback:t}=this.props.apiOptions;t&&t(e)}if(!this._fullyRendered){Object.values(this.state.assetStatuses).every(Boolean)&&(this._fullyRendered=!0,this.props.onRendered(!0))}}componentWillUnmount(){null!=this.blurTimeoutID&&(clearTimeout(this.blurTimeoutID),this.blurTimeoutID=null)}_setCurrentFocus(e){const{apiOptions:{isMobile:t,onFocusChange:n},keypadElement:o}=this.props,s=this._currentFocus;this._currentFocus=e;const i=this.getInputPaths(),r=this._currentFocus&&i.some((e=>Ye.inputPathsEqual(e,this._currentFocus)));null!=n&&n(this._currentFocus,s,r&&o&&o.getDOMNode(),r&&this.questionRenderer.getDOMNodeForPath(e)),o&&t&&(r?o.activate():o.dismiss())}_onRendererBlur(e){const t=this._currentFocus;M.default.isEqual(e,t)&&(this.blurTimeoutID=setTimeout((()=>{M.default.isEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}),0))}_setWidgetProps(e,t,n){this.questionRenderer._setWidgetProps(e,t,n)}setInputValue(e,t,n){return this.questionRenderer.setInputValue(e,t,n)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}getNumHints(){return this.props.item.hints.length}scoreInput(){const e=this.questionRenderer.guessAndScore(),t=e[0],n=e[1],o=[t,[]],s=Ye.keScoreFromPerseusScore(n,o,this.questionRenderer.getSerializedState()),i=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:s.correct,questionHighlightedWidgets:i}),s}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){const e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),n=this.questionRenderer.getSerializedState();return My(e,((e,o)=>Ye.keScoreFromPerseusScore(e,t[o],n)))}getSerializedState(){return{question:this.questionRenderer.getSerializedState(),hints:this.hintsRenderer.getSerializedState()}}restoreSerializedState(e,t){let n=2;const o=()=>{--n,t&&0===n&&t()};this.questionRenderer.restoreSerializedState(e.question,o),this.hintsRenderer.restoreSerializedState(e.hints,o)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){const e={...ee.defaults,...this.props.apiOptions,onFocusChange:this._handleFocusChange},t={assetStatuses:this.state.assetStatuses,setAssetStatus:this.setAssetStatus},n=_.createElement(sn.Provider,{value:t},_.createElement(qi,{keypadElement:this.props.keypadElement,problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,ref:e=>{null!=e&&(this.questionRenderer=e)},content:this.props.item.question.content,widgets:this.props.item.question.widgets,images:this.props.item.question.images})),o=_.createElement(Cy,{hints:this.props.item.hints,hintsVisible:this.props.hintsVisible,apiOptions:e,ref:e=>this.hintsRenderer=e});return _.createElement("div",null,_.createElement("div",null,n),_.createElement("div",{className:e.isMobile?void 0:d.css(Py.hintsContainer)},o))}}U(Iy,"defaultProps",{apiOptions:{},onRendered:e=>{}});const Py=d.StyleSheet.create({hintsContainer:{marginLeft:50}}),Ny=_.forwardRef(((e,t)=>_.createElement(Ty.Consumer,null,(n=>{let{onRendered:o}=n;return _.createElement(Iy,G({},e,{onRendered:o,ref:t}))}))));class Ay extends _.Component{render(){return _.createElement(au,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:_.createElement("span",null,"—")},{value:"->",content:_.createElement("span",null,"→")}],onChange:this.props.onChange})}}U(Ay,"defaultProps",{value:""});const Ry=[bn.BLACK,bn.BLUE,bn.GREEN,bn.PINK,bn.PURPLE,bn.RED,bn.GRAY],Fy=[bn.LIGHT_BLUE,bn.LIGHT_ORANGE,bn.LIGHT_PINK,bn.LIGHT_GREEN,bn.LIGHT_PURPLE,bn.LIGHT_RED,"#fff"];class Oy extends _.Component{render(){const e=this.props.lightColors?Fy:Ry;return _.createElement(au,{value:this.props.value,allowEmpty:!1,buttons:M.default.map(e,(e=>({value:e,content:_.createElement("span",null,_.createElement("span",{className:"colorpicker-circle",style:{background:e}})," ")}))),onChange:this.props.onChange})}}U(Oy,"defaultProps",{value:bn.BLACK,lightColors:!1});class Dy extends _.Component{render(){return _.createElement(au,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:_.createElement("span",null,"—")},{value:"-",content:_.createElement("span",null,"–––")},{value:"- ",content:_.createElement("span",null,"– –")},{value:".",content:_.createElement("span",null,"····")},{value:". ",content:_.createElement("span",null,"· · ·")}],onChange:this.props.onChange})}}U(Dy,"defaultProps",{value:""});class Ly extends _.Component{constructor(e){super(e),U(this,"toggle",(e=>{e.preventDefault(),this.setState({show:!this.state.show})})),this.state={show:e.initiallyVisible}}render(){return _.createElement("div",{className:"perseus-interaction-element"},_.createElement("a",{href:"#",className:"perseus-interaction-element-title "+(this.state.show?"open":"closed"),onClick:this.toggle},this.state.show?_.createElement(V,xo):_.createElement(V,wo),this.props.title),_.createElement("div",{className:"perseus-interaction-element-content "+(this.state.show?"enter":"leave")},this.props.children,(null!=this.props.onUp||null!=this.props.onDown||null!=this.props.onDelete)&&_.createElement("div",{className:"edit-controls"},null!=this.props.onUp&&_.createElement("button",{onClick:this.props.onUp},_.createElement(V,So)),null!=this.props.onDown&&_.createElement("button",{onClick:this.props.onDown},_.createElement(V,ko)),null!=this.props.onDelete&&_.createElement("button",{onClick:this.props.onDelete},_.createElement(V,Ao)))))}}U(Ly,"defaultProps",{initiallyVisible:!1,title:"More"});class By extends _.Component{constructor(){super(...arguments),U(this,"renderVisibleIcon",(()=>_.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:d.css(zy.icon)},_.createElement("defs",null,_.createElement("path",{id:"a",d:"M7.401 10.035c-1.424.748-2.599 1.905-3.544 3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"})),_.createElement("g",{fill:"none",fillRule:"evenodd"},_.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),_.createElement("mask",{id:"b",fill:"#fff"},_.createElement("use",{href:"#a"})),_.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),_.createElement("g",{fill:"#fff",mask:"url(#b)"},_.createElement("path",{d:"M0 0h24v24H0z"})))))),U(this,"renderHiddenIcon",(()=>_.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:d.css(zy.icon)},_.createElement("defs",null,_.createElement("path",{id:"a",d:"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48.258.604.401 1.268.401 1.966 0 1.02-.305 1.967-.828 2.757l2.535 2.536a1 1 0 0 1-1.414 1.414l-12-12a1 1 0 0 1 1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 0-4.001-4.001l4 4.001zM6.072 8.486l2.976 2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 2.363-3.085 3.929-4z"})),_.createElement("g",{fill:"none",fillRule:"evenodd"},_.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),_.createElement("mask",{id:"b",fill:"#fff"},_.createElement("use",{href:"#a"})),_.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),_.createElement("g",{fill:"#fff",mask:"url(#b)"},_.createElement("path",{d:"M0 0h24v24H0z"}))))))}render(){let e,t;return this.props.enabled?(e=zy.enabled,t=this.renderVisibleIcon()):(e=zy.disabled,t=this.renderHiddenIcon()),_.createElement("button",{className:d.css(zy.hud,this.props.fixedPosition&&zy.hudFixedPosition,e),onClick:e=>{this.props.onClick()}},t,this.props.message)}}U(By,"propTypes",{message:I.default.string.isRequired,enabled:I.default.bool.isRequired,onClick:I.default.func.isRequired,fixedPosition:I.default.bool}),U(By,"defaultProps",{fixedPosition:!0});const zy=d.StyleSheet.create({hud:{boxSizing:"border-box",height:36,padding:"9px 16px",borderRadius:18,fontFamily:ce,fontSize:"15px",lineHeight:"18px",color:de,userSelect:"none",borderWidth:0},hudFixedPosition:{bottom:20,position:"fixed",right:20,zIndex:1},icon:{width:24,height:24,marginRight:8,marginTop:-3,verticalAlign:"middle"},enabled:{backgroundColor:"#f86700",":hover":{backgroundColor:"#df5c00"},":active":{backgroundColor:"#c75300"}},disabled:{backgroundColor:pe,":hover":{backgroundColor:"#a1a5a9"},":active":{backgroundColor:ue}}});class qy extends _.Component{constructor(){super(...arguments),U(this,"toggleSelect",(e=>{const t=(this.props.values||[]).slice(0),n=this.props.allowEmpty;t.indexOf(e)>=0&&(t.length>1||n)?t.splice(t.indexOf(e),1):t.indexOf(e)<0&&t.push(e),this.props.onChange(t)}))}focus(){var e;return null===(e=A.findDOMNode(this))||void 0===e||e.focus(),!0}render(){const e=this.props.values||[],t=this.props.buttons.map(((t,n)=>{const o=e.indexOf(t.value)>=0;return _.createElement("button",{title:t.title,type:"button",id:""+n,key:""+n,ref:"button"+n,className:d.css(Hy.buttonStyle,o&&Hy.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)}));return _.createElement("div",{style:{display:"inline-block"}},t)}}U(qy,"defaultProps",{values:[],allowEmpty:!0});const Hy=d.StyleSheet.create({buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:2}},selectedStyle:{backgroundColor:"#ddd"}}),Wy=O.default({displayName:"PropCheckBox",propTypes:{labelAlignment:I.default.oneOf(["left","right"])},DEFAULT_PROPS:{label:null,onChange:null,labelAlignment:"left"},getDefaultProps:function(){return this.DEFAULT_PROPS},propName:function(){const e=M.default.find(M.default.keys(this.props),(function(e){return!M.default.has(this.DEFAULT_PROPS,e)}),this);if(!e)throw new we("Attempted to create a PropCheckBox with no prop!",be.InvalidInput);return e},_labelAlignLeft:function(){return"left"===this.props.labelAlignment},render:function(){const e=this.propName();return _.createElement("label",null,this._labelAlignLeft()&&this.props.label,_.createElement("input",{type:"checkbox",checked:this.props[e],onChange:this.toggle}),!this._labelAlignLeft()&&this.props.label)},toggle:function(){const e=this.propName(),t={};t[e]=!this.props[e],this.props.onChange(t)}}),Uy=()=>!0;class Gy extends _.Component{constructor(){super(...arguments),U(this,"onChange",((e,t)=>{const n=this.props.value;0===e?this.props.onChange([t,n[1]]):this.props.onChange([n[0],t])}))}render(){const e=this.props.value,t=this.props.checkValidity||Uy;return _.createElement("div",{className:"range-input"},_.createElement(qf,G({},this.props,{value:e[0],checkValidity:n=>t([n,e[1]]),onChange:this.onChange.bind(this,0),placeholder:this.props.placeholder[0]})),_.createElement(qf,G({},this.props,{value:e[1],checkValidity:n=>t([e[0],n]),onChange:this.onChange.bind(this,1),placeholder:this.props.placeholder[1]})))}}U(Gy,"propTypes",{value:I.default.array.isRequired,onChange:I.default.func.isRequired,placeholder:I.default.array,checkValidity:I.default.func}),U(Gy,"defaultProps",{placeholder:[null,null]});var Vy=Object.freeze({__proto__:null,ButtonGroup:au,Graph:Nh,Graphie:Rs,HUD:By,Icon:ha,InfoTip:Xg,InlineIcon:V,MathInput:Ki,MultiButtonGroup:qy,NumberInput:qf,PropCheckBox:Wy,RangeInput:Gy,SvgImage:Ys,TextInput:Zi,TexButtons:$i,TextListEditor:Z});var jy=Object.freeze({__proto__:null,devices:{PHONE:"phone",TABLET:"tablet",DESKTOP:"desktop"},lintGutterWidth:36,perseusFrameBorderWidth:1});const Yy=_.createContext({setKeypadElement:e=>{},keypadElement:null,setRenderer:e=>{},renderer:null,setScrollableElement:e=>{},scrollableElement:null}),$y=function(){},Xy=function(e,t,n,o){let s=e.content;if(null!=e.content){const n=t(e.content);void 0!==n&&(s=n)}const i=In.mapObject(e.widgets||{},(function(e,t){return null==e||null==e.type?e:n(e,t)})),r=M.default.extend({},e,{content:s,widgets:i}),a=o(r);return void 0!==a?a:r},Ky=function(e,t,n,o){return Xy(e,t=t||$y,function(e,t,n){const o=function(s,i){var r;const a=Ci(s),l=bi(a.type);let c;c=l&&(null===(r=a.version)||void 0===r?void 0:r.major)===l.major?Si(a,(t=>Xy(t,e,o,n))):a;const d=t(c,i);return void 0!==d?d:c};return o}(t,n=n||$y,o=o||$y),o)},Zy={type:"hint"},Jy=e=>({type:"array",elementShape:e});var Qy={content:{type:"content"},hint:Zy,hints:Jy(Zy),tags:{type:"tags"},arrayOf:Jy,shape:e=>({type:"object",shape:e})};class eb{constructor(e,t,n){U(this,"content",void 0),U(this,"hint",void 0),U(this,"tags",void 0),U(this,"array",void 0),this.content=e,this.hint=t,this.tags=n,this.array=nb}setContentMapper(e){return new eb(e,this.hint,this.tags)}setHintMapper(e){return new eb(this.content,e,this.tags)}setTagsMapper(e){return new eb(this.content,this.hint,e)}setArrayMapper(e){return new tb(this.content,this.hint,this.tags,e)}mapTree(e,t){return sb(e,t,[],this)}}class tb{constructor(e,t,n,o){U(this,"content",void 0),U(this,"hint",void 0),U(this,"tags",void 0),U(this,"array",void 0),this.content=e,this.hint=t,this.tags=n,this.array=o}setArrayMapper(e){return new tb(this.content,this.hint,this.tags,e)}mapTree(e,t){return sb(e,t,[],this)}}function nb(e){return e}function ob(){return new eb(nb,nb,nb)}function sb(e,t,n,o){if("content"===t.type){const s=e;return o.content(s,t,n)}if("hint"===t.type){const s=e;return o.hint(s,t,n)}if("tags"===t.type){const s=e;return o.tags(s,t,n)}if("array"===t.type){const s=e;if(!Array.isArray(s))throw new we('Invalid object of type "'.concat(typeof s,'" found at path ')+"".concat(["<root>"].concat(n).join("."),". Expected array."),be.Internal);const i=t.elementShape,r=s.map(((e,t)=>sb(e,i,n.concat(t),o)));return o.array(r,s,t,n)}if("object"===t.type){const s=e;if(s&&"object"!=typeof s)throw new we('Invalid object of type "'.concat(typeof s,'" found at ')+"path ".concat(["<root>"].concat(n).join("."),". Expected ")+'"object" type.',be.InvalidInput);const i=t.shape;if(!i)throw new we("Unexpected shape ".concat(JSON.stringify(t)," at path ")+"".concat(["<root>"].concat(n).join("."),"."),be.InvalidInput);const r={};return Object.keys(i).forEach((e=>{if(!(e in s))throw new we('Key "'.concat(e,'" is missing from shape at path ')+"".concat(["<root>"].concat(n).join("."),"."),be.InvalidInput);r[e]=sb(s[e],i[e],n.concat(e),o)})),r}throw new we("unexpected shape type ".concat(t.type),be.InvalidInput)}function ib(e){if("content"===e.type)return{__type:"content",content:"",images:{},widgets:{}};if("hint"===e.type)return{__type:"hint",replace:!1,content:"",images:{},widgets:{}};if("tags"===e.type)return[];if("array"===e.type)return[];if("object"===e.type){const t=e.shape,n={};return Object.keys(t).forEach((e=>{n[e]=ib(t[e])})),n}throw new we("unexpected shape type ".concat(e.type),be.InvalidInput)}function rb(e){if(Array.isArray(e))return e.length?"string"==typeof e[0]?Qy.tags:Qy.arrayOf(rb(e[0])):Qy.arrayOf(Qy.content);if("object"==typeof e&&("content"===e.__type||"item"===e.__type))return Qy.content;if("object"==typeof e&&"hint"===e.__type)return Qy.hint;if("object"==typeof e){const t={};return Object.keys(e).forEach((n=>{t[n]=rb(e[n])})),Qy.shape(t)}throw new we("unexpected multi-item node ".concat(JSON.stringify(e)),be.InvalidInput)}function ab(e){return e._multi}class lb extends _.Component{constructor(e){super(e),U(this,"rendererDataTreeMapper",void 0),U(this,"getRenderersMapper",void 0),U(this,"_handleSerializedStateUpdated",((e,t)=>{const{onSerializedStateUpdated:n}=this.props;if(n){const o=this._getSerializedState(this.props.serializedState);n(Wv(o).set(e,t).freeze())}})),this.rendererDataTreeMapper=ob().setContentMapper(((e,t,n)=>this._makeContentRendererData(e,n))).setHintMapper((e=>this._makeHintRendererData(e))).setTagsMapper((e=>null)),this.getRenderersMapper=ob().setContentMapper((e=>e.makeRenderer())).setHintMapper((e=>e.makeRenderer())).setArrayMapper(((e,t,n)=>this._annotateRendererArray(e,t,n))),this.state=this._tryMakeRendererState(this.props)}UNSAFE_componentWillReceiveProps(e){e.item!==this.props.item&&this.setState(this._tryMakeRendererState(e))}_tryMakeRendererState(e){try{return{rendererDataTree:this._makeRendererDataTree(e.item,e.shape),renderError:null}}catch(e){return xe.error("Error building tree state",be.Internal,{cause:e}),{rendererDataTree:null,renderError:e}}}_getRendererProps(){const{item:e,children:t,shape:n,serializedState:o,onSerializedStateUpdated:s,...i}=this.props;return i}_makeContentRendererData(e,t){const n={ref:null,makeRenderer:null},o=e=>n.ref=e,s=e=>this._findWidgets(n,e),i=e=>this._handleSerializedStateUpdated(t,e);return n.makeRenderer=()=>_.createElement(qi,G({},this._getRendererProps(),e,{ref:o,findExternalWidgets:s,serializedState:this.props.serializedState?Wv(this.props.serializedState).get(t):null,onSerializedStateUpdated:i})),n}_makeHintRendererData(e){const t=e=>this._findWidgets({},e);return{hint:e,findExternalWidgets:t,ref:null,makeRenderer:()=>_.createElement(Cy,G({},this._getRendererProps(),{findExternalWidgets:t,hints:[e]}))}}_makeRendererDataTree(e,t){const n=ab(e);return this.rendererDataTreeMapper.mapTree(n,t)}_findWidgets(e,t){const n=[];return this._mapRenderers((o=>{e!==o&&o.ref&&n.push(...o.ref.findInternalWidgets(t))})),n}_mapRenderers(e){const{rendererDataTree:t}=this.state;if(!t)return null;return ob().setContentMapper(e).setHintMapper(e).mapTree(t,this.props.shape)}_scoreFromRef(e){if(!e)return null;const[t,n]=e.guessAndScore();let o;return e.getSerializedState&&(o=e.getSerializedState()),Ye.keScoreFromPerseusScore(n,t,o)}getScores(){return this._mapRenderers((e=>this._scoreFromRef(e.ref)))}score(){const e=[],t=[],n=this._mapRenderers((n=>{var o;return n.ref?(n.ref.getSerializedState&&t.push(n.ref.getSerializedState()),e.push(n.ref.score()),null===(o=n.ref)||void 0===o?void 0:o.getUserInput()):null})),o=e.reduce(Ye.combineScores);return Ye.keScoreFromPerseusScore(o,n,t)}_getSerializedState(e){return this._mapRenderers(((t,n,o)=>t.ref?t.ref.getSerializedState():e?Wv(e).get(o):null))}restoreSerializedState(e,t){let n=0;const o=()=>{n--,t&&0===n&&t()};this._mapRenderers(((t,s,i)=>{var r;if(!t.ref)return;const a=Wv(e).get(i);a&&(n++,null===(r=t.ref)||void 0===r||r.restoreSerializedState(a,o))}))}_annotateRendererArray(e,t,n){if("hint"===n.elementShape.type){const n=t;(e=[...e]).firstN=e=>_.createElement(Cy,G({},this._getRendererProps(),{findExternalWidgets:n[0]?n[0].findExternalWidgets:void 0,hints:n.map((e=>e.hint)),hintsVisible:e}))}return e}_getRenderers(){return this.getRenderersMapper.mapTree(this.state.rendererDataTree,this.props.shape)}render(){return this.state.renderError?_.createElement("div",{className:d.css(cb.error)},k.$_("Error rendering: %(error)s",{error:String(this.state.renderError)})):this.props.children({renderers:this._getRenderers()})}}const cb=d.StyleSheet.create({error:{color:"red"}});function db(e){if("content"===e.type)return I.default.shape({__type:I.default.oneOf(["content","item"]).isRequired,content:I.default.string,images:I.default.objectOf(I.default.any),widgets:I.default.objectOf(I.default.any)});if("hint"===e.type)return I.default.shape({__type:I.default.oneOf(["hint"]).isRequired,content:I.default.string,images:I.default.objectOf(I.default.any),widgets:I.default.objectOf(I.default.any),replace:I.default.bool});if("tags"===e.type)return I.default.arrayOf(I.default.string.isRequired);if("array"===e.type){const t=db(e.elementShape);return I.default.arrayOf(t.isRequired)}if("object"===e.type){const t=e.shape,n={};return Object.keys(t).forEach((e=>{n[e]=db(t[e]).isRequired})),I.default.shape(n)}throw new we("unexpected shape type ".concat(e.type),be.InvalidInput)}var pb={MultiRenderer:lb,shapes:Qy,buildPropTypeForShape:function(e){return I.default.oneOfType([I.default.shape({_multi:db(e)}),I.default.oneOf([null,void 0])])},buildEmptyItemForShape:function(e){return{_multi:ib(e)}},findContentNodesInItem:function(e,t,n){const o=ab(e);ob().setContentMapper(n).mapTree(o,t)},findHintNodesInItem:function(e,t,n){const o=ab(e);ob().setHintMapper(n).mapTree(o,t)},inferItemShape:function(e){return rb(ab(e))}};const{findContentNodesInItem:ub,inferItemShape:hb}=pb,fb=function(e,t){let n=!0;return Ky(e,null,(function(e){n=n&&function(e,t){if(null==e||null==e.type)return!0;const n=Ci(e);return function(e,t){if(null==t)return!1;const n=e.version||{major:0,minor:0};return t.major>n.major||!(t.major<n.major)&&t.minor>=n.minor}(n,t[n.type])}(e,t)})),n},{findContentNodesInItem:mb,inferItemShape:gb}=pb;function vb(e,t){Ky(e,null,(function(e){e.type&&!wi(e)&&t.push(e.type)}))}const yb={serialize:function(){return M.default.omit(this.props,rr)}},bb=H,xb=W;exports.ApiOptions=ee,exports.ArrowPicker=Ay,exports.ArticleRenderer=by,exports.BaseRadio=Ll,exports.Categorizer=Yl,exports.Changeable=ur,exports.ClassNames=te,exports.ColorPicker=Oy,exports.DashPicker=Dy,exports.Dependencies=$,exports.EditorJsonify=yb,exports.ElementContainer=Ly,exports.Errors=be,exports.Expression=vr,exports.GrapherUtil=Ru,exports.GrapherWidget=qu,exports.HintRenderer=xy,exports.HintsRenderer=Cy,exports.InputNumber=Ir,exports.InteractiveGraphWidget=of,exports.ItemRenderer=Ey,exports.JiptParagraphs=oi,exports.KeypadContext=Yy,exports.KhanColors=bn,exports.KhanMath=Ce,exports.LoadingContext=Ty,exports.Log=xe,exports.MatrixWidget=Qf,exports.MultiItems=pb,exports.NumericInput=Dr,exports.PerseusError=we,exports.PerseusMarkdown=it,exports.PlotterWidget=Lg,exports.Radio=Ul,exports.Renderer=qi,exports.ServerItemRenderer=Ny,exports.SizingUtils=ui,exports.TableWidget=vv,exports.TransformerWidget=qv,exports.Util=Ye,exports.WIDGET_PROP_BLACKLIST=rr,exports.WidgetJsonifyDeprecated=Lr,exports.Widgets=Ai,exports.apiVersion=bb,exports.buildEmptyItemTreeForShape=ib,exports.buildMapper=ob,exports.components=Vy,exports.constants=jy,exports.displaySigFigs=function(e,t,n,o){const s=""+e;let i,r,a,l=Yv(s),c=jv(s),d=Vv(s),p=!1;if(0==e||""==c||"0"==c){c="";for(let e=0;e<t;e++)c+="0";l=t+n,n<0&&-n>=t&&(p=!0)}else{if(r=l-c.length-n,a=t-c.length,i=Math.min(a,r),i<0){let e=$v(c,-i);e.length>c.length+i&&(l++,r>a&&(e=$v(e,1))),c=e}else if(i>0)for(let e=0;e<i;e++)c+="0";""!=c&&"0"!=c||(c="0",d=!0,l=1+n,0!=l&&(p=!0))}let u="";if(d||(u+="-"),o||c.length>20||l>4||l<-2||l-c.length>0&&Gv(c)>0||p)u+=c.charAt(0),c.length>1&&(u+="."+c.substring(1,c.length)),l-1!=0&&(u+=" x 10^"+(l-1));else{let e="",t="",n=!0;if(l>0)if(c.length>l)e=c.substring(0,l),t=c.substring(l,c.length);else{e=c,n=0!=Gv(c);for(let t=0;t<l-c.length;t++)e+="0"}else{for(let e=0;e<-l;e++)t+="0";t+=c}u+=(""==e?"0":e)+(n?".":"")+t}return u},exports.globalConstants=Qa,exports.globalStyles=sl,exports.icons=Oo,exports.init=function(e){vi(Gl),vi(hy);return e.skipMathJax?Promise.resolve():new Promise(((e,t)=>{MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:"none","HTML-CSS":{availableFonts:["TeX"],imageFont:null,scale:100,showMathMenu:!1}}),MathJax.Hub.Configured(),MathJax.Hub.Queue(e)}))},exports.interactiveSizes=fe,exports.isItemRenderableByVersion=function(e,t){if(null==e||null==t)throw new we("missing parameter to Perseus.isRenderable.item",be.InvalidInput);if(e._multi){const n=hb(e);let o=!0;return ub(e,n,(e=>{fb(e,t)||(o=!1)})),o}return fb(e.question,t)},exports.itemDataVersion=xb,exports.itemToTree=ab,exports.itemVersion=my,exports.mediaQueries=$r,exports.preprocessTex=ai,exports.registerAllWidgetsForTesting=()=>{vi(fy)},exports.shapes=Qy,exports.traverse=Ky,exports.violatingWidgets=function(e){const t=[];if(e._multi){const n=gb(e);mb(e,n,(e=>vb(e,t)))}else vb(e.question,t);return M.default.uniq(t)},exports.widgets=fy;
|
|
2
16
|
//# sourceMappingURL=index.js.map
|