@classytic/labs 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/biology/enzyme-rate/preset.mjs +5 -5
- package/dist/biology/genetic-cross/core.d.mts +7 -7
- package/dist/biology/genetic-cross/core.mjs +4 -4
- package/dist/biology/genetic-cross/grid.mjs +132 -123
- package/dist/biology/genetic-cross/preset.mjs +4 -4
- package/dist/biology/genetic-cross/sex-linked.mjs +7 -7
- package/dist/biology/photosynthesis-factors/preset.mjs +8 -8
- package/dist/biology/respiration/preset.mjs +4 -4
- package/dist/biology/sequence/central-dogma.mjs +5 -5
- package/dist/biology/sequence/core.d.mts +6 -6
- package/dist/biology/sequence/core.mjs +1 -1
- package/dist/biology/sequence/preset.mjs +6 -6
- package/dist/blocks/authoring.mjs +5 -5
- package/dist/blocks/biology.d.mts +2 -2
- package/dist/blocks/biology.mjs +5 -5
- package/dist/blocks/chem.d.mts +2 -2
- package/dist/blocks/chem.mjs +13 -13
- package/dist/blocks/circuits.d.mts +293 -4
- package/dist/blocks/circuits.mjs +874 -9
- package/dist/blocks/discrete.d.mts +30 -2
- package/dist/blocks/discrete.mjs +74 -4
- package/dist/blocks/economics.mjs +1 -1
- package/dist/blocks/geography.mjs +1 -1
- package/dist/blocks/geometry.mjs +3 -3
- package/dist/blocks/ict.d.mts +90 -1
- package/dist/blocks/ict.mjs +217 -7
- package/dist/blocks/index.d.mts +3064 -657
- package/dist/blocks/index.mjs +9 -9
- package/dist/blocks/lab-block.mjs +5 -5
- package/dist/blocks/lab-config.d.mts +1 -1
- package/dist/blocks/lab-config.mjs +4 -4
- package/dist/blocks/lab-gallery.d.mts +1 -1
- package/dist/blocks/lab-gallery.mjs +2 -2
- package/dist/blocks/language.d.mts +6 -6
- package/dist/blocks/language.mjs +12 -12
- package/dist/blocks/lesson.mjs +4 -4
- package/dist/blocks/math.d.mts +577 -11
- package/dist/blocks/math.mjs +1648 -14
- package/dist/blocks/ml.d.mts +45 -1
- package/dist/blocks/ml.mjs +80 -6
- package/dist/blocks/physics.d.mts +9 -4
- package/dist/blocks/physics.mjs +75 -28
- package/dist/blocks/statistics.mjs +1 -1
- package/dist/build/CircuitEditor.d.mts +14 -0
- package/dist/build/CircuitEditor.mjs +787 -0
- package/dist/build/CircuitPlayer.d.mts +19 -0
- package/dist/build/CircuitPlayer.mjs +53 -0
- package/dist/build/CircuitScene.d.mts +61 -0
- package/dist/build/CircuitScene.mjs +383 -0
- package/dist/build/contract.d.mts +116 -0
- package/dist/build/editor-ops.d.mts +65 -0
- package/dist/build/editor-ops.mjs +306 -0
- package/dist/build/editor-ui.mjs +121 -0
- package/dist/build/flow.d.mts +14 -0
- package/dist/build/flow.mjs +119 -0
- package/dist/build/index.d.mts +10 -0
- package/dist/build/index.mjs +10 -0
- package/dist/build/parts/ammeter.d.mts +1 -0
- package/dist/build/parts/ammeter.mjs +32 -0
- package/dist/build/parts/bulb.d.mts +1 -0
- package/dist/build/parts/bulb.mjs +50 -0
- package/dist/build/parts/capacitor.d.mts +1 -0
- package/dist/build/parts/capacitor.mjs +26 -0
- package/dist/build/parts/cell.d.mts +1 -0
- package/dist/build/parts/cell.mjs +40 -0
- package/dist/build/parts/diode.d.mts +1 -0
- package/dist/build/parts/diode.mjs +33 -0
- package/dist/build/parts/index.d.mts +5 -0
- package/dist/build/parts/index.mjs +43 -0
- package/dist/build/parts/mosfet.d.mts +1 -0
- package/dist/build/parts/mosfet.mjs +95 -0
- package/dist/build/parts/node.d.mts +1 -0
- package/dist/build/parts/node.mjs +32 -0
- package/dist/build/parts/resistor.d.mts +1 -0
- package/dist/build/parts/resistor.mjs +49 -0
- package/dist/build/parts/shared.mjs +42 -0
- package/dist/build/parts/switch.d.mts +1 -0
- package/dist/build/parts/switch.mjs +34 -0
- package/dist/build/parts.d.mts +1 -0
- package/dist/build/registry.d.mts +9 -0
- package/dist/build/registry.mjs +15 -0
- package/dist/build/solve.d.mts +8 -0
- package/dist/build/solve.mjs +0 -0
- package/dist/catalog/registry.d.mts +2 -2
- package/dist/catalog/templates.d.mts +1 -1
- package/dist/catalog/templates.mjs +6 -6
- package/dist/chem/battery.mjs +1 -1
- package/dist/chem/bohr-atom.mjs +4 -4
- package/dist/chem/diffusion/preset.mjs +4 -4
- package/dist/chem/electrochem/preset.mjs +5 -5
- package/dist/chem/equilibrium/preset.d.mts +1 -1
- package/dist/chem/equilibrium/preset.mjs +6 -6
- package/dist/chem/gas-box/preset.mjs +6 -6
- package/dist/chem/kinetics/preset.mjs +6 -6
- package/dist/chem/periodic-trends/preset.mjs +7 -7
- package/dist/chem/reaction-lab.mjs +3 -3
- package/dist/chem/reaction-profile.mjs +4 -4
- package/dist/chem/solution/dilution.mjs +6 -6
- package/dist/chem/solution/field.d.mts +2 -2
- package/dist/chem/solution/field.mjs +2 -2
- package/dist/chem/solution/solution-box.mjs +7 -7
- package/dist/chem/stoichiometry/preset.mjs +5 -5
- package/dist/chem/titration/preset.mjs +5 -5
- package/dist/circuits/ac-dc/asset.mjs +1 -1
- package/dist/circuits/ac-dc/preset.mjs +2 -2
- package/dist/circuits/brownout/index.d.mts +1 -0
- package/dist/circuits/brownout/preset.d.mts +22 -0
- package/dist/circuits/brownout/preset.mjs +399 -0
- package/dist/circuits/capacitor-leak/preset.mjs +13 -8
- package/dist/circuits/circuit/asset.mjs +71 -14
- package/dist/circuits/circuit/preset.mjs +23 -5
- package/dist/circuits/circuit-builder.mjs +60 -132
- package/dist/circuits/circuit-lab.mjs +60 -40
- package/dist/circuits/cmos-gate/index.d.mts +1 -0
- package/dist/circuits/cmos-gate/preset.d.mts +75 -0
- package/dist/circuits/cmos-gate/preset.mjs +1491 -0
- package/dist/circuits/diode/index.d.mts +1 -0
- package/dist/circuits/diode/preset.d.mts +25 -0
- package/dist/circuits/diode/preset.mjs +266 -0
- package/dist/circuits/index.d.mts +7 -1
- package/dist/circuits/index.mjs +7 -1
- package/dist/circuits/rc-charging/index.d.mts +1 -0
- package/dist/circuits/rc-charging/preset.d.mts +27 -0
- package/dist/circuits/rc-charging/preset.mjs +329 -0
- package/dist/circuits/semiconductor/index.d.mts +1 -0
- package/dist/circuits/semiconductor/preset.d.mts +102 -0
- package/dist/circuits/semiconductor/preset.mjs +1855 -0
- package/dist/circuits/transistor/index.d.mts +1 -0
- package/dist/circuits/transistor/preset.d.mts +27 -0
- package/dist/circuits/transistor/preset.mjs +329 -0
- package/dist/commerce/accounting/core.d.mts +1 -1
- package/dist/commerce/accounting/equation-balance.mjs +5 -5
- package/dist/commerce/accounting/journal-poster.mjs +8 -8
- package/dist/commerce/accounting/statement-sorter.mjs +4 -4
- package/dist/commerce/economics/core.d.mts +2 -2
- package/dist/commerce/economics/core.mjs +1 -1
- package/dist/commerce/economics/demand-shift-vs-move.mjs +6 -6
- package/dist/commerce/economics/elasticity-revenue.mjs +6 -6
- package/dist/commerce/economics/market-equilibrium.mjs +5 -5
- package/dist/core/easing.d.mts +3 -3
- package/dist/core/easing.mjs +2 -2
- package/dist/core/numeric.d.mts +3 -3
- package/dist/core/numeric.mjs +2 -2
- package/dist/core/reactive.d.mts +1 -1
- package/dist/core/reactive.mjs +1 -1
- package/dist/core/rng.d.mts +2 -2
- package/dist/core/rng.mjs +1 -1
- package/dist/core/tex.mjs +2 -2
- package/dist/core/timeline.d.mts +1 -1
- package/dist/core/timeline.mjs +1 -1
- package/dist/core/util.mjs +11 -1
- package/dist/discrete/arrangements/preset.mjs +6 -14
- package/dist/discrete/bayes/preset.mjs +43 -35
- package/dist/discrete/binomial/preset.mjs +2 -2
- package/dist/discrete/combination-studio/figure.d.mts +6 -0
- package/dist/discrete/combination-studio/figure.mjs +159 -0
- package/dist/discrete/combination-studio/index.d.mts +2 -0
- package/dist/discrete/combination-studio/preset.d.mts +44 -0
- package/dist/discrete/combination-studio/preset.mjs +440 -0
- package/dist/discrete/core/combinatorics.d.mts +23 -3
- package/dist/discrete/core/combinatorics.mjs +38 -3
- package/dist/discrete/core/pigeonhole.d.mts +1 -1
- package/dist/discrete/core/pigeonhole.mjs +1 -1
- package/dist/discrete/core/probability.d.mts +3 -3
- package/dist/discrete/core/probability.mjs +3 -3
- package/dist/discrete/core/sets.d.mts +1 -1
- package/dist/discrete/counting-slots/preset.mjs +8 -8
- package/dist/discrete/counting-tree/preset.mjs +65 -8
- package/dist/discrete/expected-value/preset.mjs +13 -13
- package/dist/discrete/hypergeometric/preset.mjs +48 -15
- package/dist/discrete/index.d.mts +4 -2
- package/dist/discrete/index.mjs +4 -2
- package/dist/discrete/karnaugh/preset.mjs +26 -20
- package/dist/discrete/lln/preset.mjs +44 -3
- package/dist/discrete/logic-circuit/preset.mjs +2 -2
- package/dist/discrete/monte-carlo/preset.d.mts +1 -1
- package/dist/discrete/monte-carlo/preset.mjs +14 -14
- package/dist/discrete/monty-hall/preset.mjs +6 -6
- package/dist/discrete/outcome-builder/preset.mjs +3 -3
- package/dist/discrete/pascal/preset.mjs +37 -7
- package/dist/discrete/rules.d.mts +20 -0
- package/dist/discrete/rules.mjs +264 -0
- package/dist/discrete/sample-space/preset.mjs +4 -4
- package/dist/discrete/selection/preset.mjs +7 -13
- package/dist/discrete/truth-table/preset.mjs +32 -9
- package/dist/discrete/venn/preset.mjs +71 -48
- package/dist/geography/cycle-lab/preset.mjs +17 -10
- package/dist/geography/cycles.d.mts +3 -3
- package/dist/geography/cycles.mjs +3 -3
- package/dist/geometry/board/preset.d.mts +2 -0
- package/dist/geometry/board/preset.mjs +11 -15
- package/dist/geometry/builder.mjs +3 -3
- package/dist/ict/number-systems/base-odometer.mjs +4 -4
- package/dist/ict/number-systems/bit-grouper.d.mts +1 -1
- package/dist/ict/number-systems/bit-grouper.mjs +4 -4
- package/dist/ict/number-systems/place-value-dial.d.mts +1 -1
- package/dist/ict/number-systems/place-value-dial.mjs +3 -3
- package/dist/ict/number-systems/wheel.d.mts +3 -3
- package/dist/ict/number-systems/wheel.mjs +4 -4
- package/dist/kit/annotate.mjs +3 -3
- package/dist/kit/answer-check.d.mts +2 -2
- package/dist/kit/answer-check.mjs +34 -6
- package/dist/kit/ask.d.mts +19 -0
- package/dist/kit/ask.mjs +46 -0
- package/dist/kit/bar-strip.mjs +53 -0
- package/dist/kit/calc.d.mts +33 -0
- package/dist/kit/calc.mjs +27 -0
- package/dist/kit/carrier-engine.mjs +147 -0
- package/dist/kit/clue-scene.d.mts +86 -0
- package/dist/kit/clue-scene.mjs +424 -0
- package/dist/kit/cluster.d.mts +30 -0
- package/dist/kit/cluster.mjs +81 -0
- package/dist/kit/controls.mjs +11 -5
- package/dist/kit/coords.d.mts +88 -0
- package/dist/kit/coords.mjs +192 -0
- package/dist/kit/data-scene.d.mts +27 -0
- package/dist/kit/data-scene.mjs +199 -0
- package/dist/kit/diagram.mjs +111 -50
- package/dist/kit/electronics.mjs +552 -60
- package/dist/kit/expr-analysis.d.mts +18 -6
- package/dist/kit/expr-analysis.mjs +82 -28
- package/dist/kit/frame.d.mts +3 -3
- package/dist/kit/frame.mjs +25 -6
- package/dist/kit/gameshow.mjs +2 -2
- package/dist/kit/index.d.mts +14 -2
- package/dist/kit/index.mjs +13 -1
- package/dist/kit/logic-gates.mjs +246 -47
- package/dist/kit/palette.mjs +26 -0
- package/dist/kit/pedagogy.d.mts +4 -4
- package/dist/kit/pedagogy.mjs +21 -17
- package/dist/kit/play.d.mts +1 -1
- package/dist/kit/play.mjs +3 -3
- package/dist/kit/predict.d.mts +55 -0
- package/dist/kit/predict.mjs +146 -0
- package/dist/kit/receipt.d.mts +29 -0
- package/dist/kit/receipt.mjs +94 -0
- package/dist/kit/rich.mjs +2 -2
- package/dist/kit/rule.d.mts +59 -0
- package/dist/kit/rule.mjs +215 -0
- package/dist/kit/scale.mjs +1 -1
- package/dist/kit/scene-library.d.mts +22 -0
- package/dist/kit/scene-library.mjs +311 -0
- package/dist/kit/scene-studio.d.mts +14 -0
- package/dist/kit/scene-studio.mjs +338 -0
- package/dist/kit/scenes.d.mts +31 -0
- package/dist/kit/scenes.mjs +569 -0
- package/dist/kit/slot-fill.d.mts +61 -0
- package/dist/kit/slot-fill.mjs +207 -0
- package/dist/kit/solve.d.mts +21 -0
- package/dist/kit/solve.mjs +75 -0
- package/dist/kit/space.mjs +5 -5
- package/dist/kit/steps.mjs +2 -2
- package/dist/kit/vessel.d.mts +69 -0
- package/dist/kit/vessel.mjs +191 -0
- package/dist/language/agreement/preset.mjs +2 -2
- package/dist/language/article-lens/preset.d.mts +1 -1
- package/dist/language/article-lens/preset.mjs +8 -8
- package/dist/language/deck.d.mts +3 -3
- package/dist/language/deck.mjs +1 -1
- package/dist/language/preposition-scene/preset.d.mts +2 -2
- package/dist/language/preposition-scene/preset.mjs +5 -5
- package/dist/language/sentence-builder/preset.mjs +5 -5
- package/dist/language/transform/preset.d.mts +2 -2
- package/dist/language/transform/preset.mjs +5 -5
- package/dist/language/ui.d.mts +3 -3
- package/dist/language/ui.mjs +4 -4
- package/dist/language/word-match/preset.mjs +3 -3
- package/dist/logic/LogicBuildLab.d.mts +22 -0
- package/dist/logic/LogicBuildLab.mjs +170 -0
- package/dist/logic/LogicEditScene.d.mts +31 -0
- package/dist/logic/LogicEditScene.mjs +276 -0
- package/dist/logic/LogicEditor.d.mts +14 -0
- package/dist/logic/LogicEditor.mjs +413 -0
- package/dist/logic/LogicScene.d.mts +32 -0
- package/dist/logic/LogicScene.mjs +277 -0
- package/dist/logic/contract.d.mts +72 -0
- package/dist/logic/display.d.mts +24 -0
- package/dist/logic/display.mjs +127 -0
- package/dist/logic/edit-ops.d.mts +44 -0
- package/dist/logic/edit-ops.mjs +177 -0
- package/dist/logic/evaluate.d.mts +11 -0
- package/dist/logic/evaluate.mjs +93 -0
- package/dist/logic/gates.d.mts +10 -0
- package/dist/logic/gates.mjs +73 -0
- package/dist/logic/index.d.mts +14 -0
- package/dist/logic/index.mjs +13 -0
- package/dist/logic/lab.d.mts +32 -0
- package/dist/logic/lab.mjs +160 -0
- package/dist/logic/presets.d.mts +12 -0
- package/dist/logic/presets.mjs +241 -0
- package/dist/logic/registry.d.mts +9 -0
- package/dist/logic/registry.mjs +15 -0
- package/dist/math/area-model/preset.mjs +70 -44
- package/dist/math/balance-algebra/preset.mjs +14 -5
- package/dist/math/broken-tree/index.d.mts +1 -0
- package/dist/math/broken-tree/preset.d.mts +26 -0
- package/dist/math/broken-tree/preset.mjs +435 -0
- package/dist/math/circle/index.d.mts +1 -0
- package/dist/math/circle/preset.d.mts +44 -0
- package/dist/math/circle/preset.mjs +198 -0
- package/dist/math/complex/core.d.mts +93 -0
- package/dist/math/complex/core.mjs +239 -0
- package/dist/math/complex/index.d.mts +3 -0
- package/dist/math/complex/preset.d.mts +31 -0
- package/dist/math/complex/preset.mjs +377 -0
- package/dist/math/complex/rules.d.mts +6 -0
- package/dist/math/complex/rules.mjs +121 -0
- package/dist/math/conic/index.d.mts +1 -0
- package/dist/math/conic/preset.d.mts +30 -0
- package/dist/math/conic/preset.mjs +334 -0
- package/dist/math/derivation.mjs +5 -5
- package/dist/math/derivative-explorer/preset.mjs +5 -5
- package/dist/math/domain-range/index.d.mts +1 -0
- package/dist/math/domain-range/preset.d.mts +33 -0
- package/dist/math/domain-range/preset.mjs +313 -0
- package/dist/math/fraction-bar/index.d.mts +1 -0
- package/dist/math/fraction-bar/preset.d.mts +27 -0
- package/dist/math/fraction-bar/preset.mjs +197 -0
- package/dist/math/function-machine/preset.mjs +2 -2
- package/dist/math/gradient-descent.mjs +6 -6
- package/dist/math/grapher/preset.d.mts +1 -1
- package/dist/math/grapher/preset.mjs +4 -4
- package/dist/math/harmonic-form/preset.mjs +6 -6
- package/dist/math/index.d.mts +27 -2
- package/dist/math/index.mjs +27 -2
- package/dist/math/integral-explorer/preset.mjs +2 -2
- package/dist/math/interactive/preset.mjs +3 -3
- package/dist/math/limit-explorer/preset.mjs +4 -4
- package/dist/math/linear-model/index.d.mts +1 -0
- package/dist/math/linear-model/preset.d.mts +53 -0
- package/dist/math/linear-model/preset.mjs +164 -0
- package/dist/math/linear-system/preset.mjs +4 -4
- package/dist/math/mystery-bucket/preset.mjs +6 -6
- package/dist/math/number-line/preset.mjs +3 -2
- package/dist/math/parabola/preset.mjs +4 -3
- package/dist/math/pattern/preset.mjs +7 -13
- package/dist/math/percent-bar/index.d.mts +1 -0
- package/dist/math/percent-bar/preset.d.mts +37 -0
- package/dist/math/percent-bar/preset.mjs +275 -0
- package/dist/math/poly/core.d.mts +50 -0
- package/dist/math/poly/core.mjs +268 -0
- package/dist/math/poly/index.d.mts +3 -0
- package/dist/math/poly/preset.d.mts +23 -0
- package/dist/math/poly/preset.mjs +141 -0
- package/dist/math/poly/steps.d.mts +10 -0
- package/dist/math/poly/steps.mjs +99 -0
- package/dist/math/rate-machine/index.d.mts +1 -0
- package/dist/math/rate-machine/preset.d.mts +35 -0
- package/dist/math/rate-machine/preset.mjs +281 -0
- package/dist/math/ratio-share/index.d.mts +1 -0
- package/dist/math/ratio-share/preset.d.mts +24 -0
- package/dist/math/ratio-share/preset.mjs +204 -0
- package/dist/math/receipt/index.d.mts +1 -0
- package/dist/math/receipt/preset.d.mts +22 -0
- package/dist/math/receipt/preset.mjs +137 -0
- package/dist/math/sequence-predict/index.d.mts +1 -0
- package/dist/math/sequence-predict/preset.d.mts +34 -0
- package/dist/math/sequence-predict/preset.mjs +130 -0
- package/dist/math/straight-line/index.d.mts +1 -0
- package/dist/math/straight-line/preset.d.mts +37 -0
- package/dist/math/straight-line/preset.mjs +374 -0
- package/dist/math/system-solve/index.d.mts +1 -0
- package/dist/math/system-solve/preset.d.mts +21 -0
- package/dist/math/system-solve/preset.mjs +227 -0
- package/dist/math/transform/index.d.mts +1 -0
- package/dist/math/transform/preset.d.mts +41 -0
- package/dist/math/transform/preset.mjs +343 -0
- package/dist/math/triangle-trig/preset.mjs +12 -9
- package/dist/math/trig/core.d.mts +37 -0
- package/dist/math/trig/core.mjs +150 -0
- package/dist/math/trig/diagrams.d.mts +1 -0
- package/dist/math/trig/diagrams.mjs +321 -0
- package/dist/math/trig/index.d.mts +3 -0
- package/dist/math/trig/preset.d.mts +25 -0
- package/dist/math/trig/preset.mjs +260 -0
- package/dist/math/trig/rules.d.mts +6 -0
- package/dist/math/trig/rules.mjs +159 -0
- package/dist/math/trig-explorer.mjs +4 -4
- package/dist/ml/boundary/preset.mjs +8 -3
- package/dist/ml/classifier/preset.mjs +31 -6
- package/dist/ml/kmeans/preset.mjs +4 -4
- package/dist/ml/knn/preset.mjs +47 -12
- package/dist/ml/regression/preset.mjs +36 -7
- package/dist/physics/atwood/preset.mjs +4 -4
- package/dist/physics/bullet-walls/preset.d.mts +1 -1
- package/dist/physics/bullet-walls/preset.mjs +7 -7
- package/dist/physics/carnot/preset.mjs +6 -6
- package/dist/physics/circular-motion/preset.mjs +36 -5
- package/dist/physics/collision-track/preset.mjs +35 -5
- package/dist/physics/efficiency/preset.d.mts +2 -2
- package/dist/physics/efficiency/preset.mjs +5 -5
- package/dist/physics/electric-field/preset.mjs +32 -23
- package/dist/physics/electric-flux/index.d.mts +1 -0
- package/dist/physics/electric-flux/preset.d.mts +29 -0
- package/dist/physics/electric-flux/preset.mjs +264 -0
- package/dist/physics/energy-skate/preset.mjs +5 -5
- package/dist/physics/entropy/preset.mjs +7 -7
- package/dist/physics/expansion/preset.mjs +13 -13
- package/dist/physics/exponential/asset.mjs +1 -1
- package/dist/physics/exponential/preset.mjs +4 -4
- package/dist/physics/gas-process/preset.mjs +3 -3
- package/dist/physics/gauss-law/index.d.mts +1 -0
- package/dist/physics/gauss-law/preset.d.mts +20 -0
- package/dist/physics/gauss-law/preset.mjs +286 -0
- package/dist/physics/gravitation/preset.mjs +7 -7
- package/dist/physics/gravity-drop.mjs +4 -4
- package/dist/physics/heat-transfer/preset.d.mts +1 -1
- package/dist/physics/heat-transfer/preset.mjs +10 -10
- package/dist/physics/impulse/preset.mjs +5 -5
- package/dist/physics/index.d.mts +4 -1
- package/dist/physics/index.mjs +4 -1
- package/dist/physics/kepler/preset.mjs +4 -4
- package/dist/physics/lever/preset.mjs +3 -3
- package/dist/physics/lorentz/preset.mjs +11 -11
- package/dist/physics/magnetism/preset.mjs +3 -3
- package/dist/physics/optics/preset.mjs +2 -2
- package/dist/physics/orbit-lab.mjs +5 -5
- package/dist/physics/projectile-lab.mjs +4 -4
- package/dist/physics/rain-relative/preset.mjs +5 -5
- package/dist/physics/ramp-forces/preset.mjs +5 -5
- package/dist/physics/river-boat.mjs +6 -6
- package/dist/physics/shm/preset.mjs +9 -9
- package/dist/physics/stopping-distance/preset.mjs +3 -3
- package/dist/physics/temperature-scales/preset.mjs +105 -116
- package/dist/physics/terminal-velocity/preset.mjs +5 -5
- package/dist/physics/thermal/preset.mjs +5 -5
- package/dist/physics/vector-board/preset.mjs +7 -6
- package/dist/physics/vector-scene.mjs +2 -2
- package/dist/physics/vector-types/preset.mjs +37 -3
- package/dist/physics/water-density/preset.mjs +12 -12
- package/dist/physics/waves/doppler.mjs +2 -2
- package/dist/physics/waves/preset.mjs +4 -4
- package/dist/physics/waves/ripple.mjs +6 -6
- package/dist/physics/waves/string.mjs +5 -5
- package/dist/physics/work-energy/preset.mjs +4 -4
- package/dist/physics/work-potential/index.d.mts +1 -0
- package/dist/physics/work-potential/preset.d.mts +20 -0
- package/dist/physics/work-potential/preset.mjs +276 -0
- package/dist/schemas/index.d.mts +6 -6
- package/dist/schemas/index.mjs +3 -3
- package/dist/statistics/center-spread/preset.mjs +3 -3
- package/dist/statistics/core/descriptive.d.mts +2 -2
- package/dist/statistics/core/descriptive.mjs +2 -2
- package/dist/statistics/core/normal.d.mts +3 -3
- package/dist/statistics/core/normal.mjs +3 -3
- package/dist/statistics/core/sequences.d.mts +1 -1
- package/dist/statistics/galton/preset.mjs +2 -2
- package/dist/statistics/histogram/preset.mjs +6 -6
- package/dist/statistics/normal/preset.mjs +2 -2
- package/dist/statistics/sampling/preset.mjs +4 -4
- package/dist/statistics/sequence/preset.mjs +58 -15
- package/dist/statistics/z-table/preset.mjs +17 -4
- package/package.json +11 -3
- package/styles.css +4 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Tex as Tex$1 } from "../../core/tex.mjs";
|
|
4
|
+
import { ControlBar, LabFrame } from "../../kit/frame.mjs";
|
|
5
|
+
import { toStr } from "../complex/core.mjs";
|
|
6
|
+
import { factorTex, fromAst, polyTex, solve } from "./core.mjs";
|
|
7
|
+
import { factorSteps, solveSteps } from "./steps.mjs";
|
|
8
|
+
import { WorkedSteps } from "../../kit/rule.mjs";
|
|
9
|
+
import { useMemo, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { compileExpr } from "@classytic/stage";
|
|
12
|
+
|
|
13
|
+
//#region src/math/poly/preset.tsx
|
|
14
|
+
/**
|
|
15
|
+
* PolynomialSolverLab, the dynamic "factor & solve" TOOL (the solver path, vs the
|
|
16
|
+
* curated lesson path). Type or author a polynomial; the engine factors it / solves
|
|
17
|
+
* it = 0 and SHOWS THE WORKING using the school method (split the middle term;
|
|
18
|
+
* factor theorem for higher degree). Runs entirely client-side on the canonical
|
|
19
|
+
* poly core — no heavy CAS dependency. "Show the steps" is a reveal so the learner
|
|
20
|
+
* can try first.
|
|
21
|
+
*/
|
|
22
|
+
function PolynomialSolverLab({ expr = "x^2 + 5x + 6", mode = "factor", editable = true, title = mode === "solve" ? "Solve the polynomial" : "Factor the polynomial", prompt = mode === "solve" ? "Type a polynomial; see it solved step by step." : "Type a polynomial; see it factored step by step." } = {}) {
|
|
23
|
+
const [src, setSrc] = useState(expr);
|
|
24
|
+
const [show, setShow] = useState(false);
|
|
25
|
+
const result = useMemo(() => {
|
|
26
|
+
const c = compileExpr(src);
|
|
27
|
+
if (c.error || !c.ast) return { error: "Could not read that expression." };
|
|
28
|
+
const p = fromAst(c.ast);
|
|
29
|
+
if (!p) return { error: "That is not a polynomial in x." };
|
|
30
|
+
if (p.length <= 1) return { error: "Enter a polynomial in x (degree ≥ 1)." };
|
|
31
|
+
const sol = solve(p);
|
|
32
|
+
return {
|
|
33
|
+
p,
|
|
34
|
+
sol,
|
|
35
|
+
worked: mode === "solve" ? solveSteps(p) : factorSteps(p),
|
|
36
|
+
answerTex: mode === "solve" ? sol.roots.map((r) => `x = ${toStr(r)}`).join(" \\quad\\text{or}\\quad ") : factorTex(p),
|
|
37
|
+
polyTex: polyTex(p)
|
|
38
|
+
};
|
|
39
|
+
}, [src, mode]);
|
|
40
|
+
const figure = "error" in result ? /* @__PURE__ */ jsxs("p", {
|
|
41
|
+
className: "lab-misconception",
|
|
42
|
+
role: "status",
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ jsx("span", {
|
|
45
|
+
"aria-hidden": true,
|
|
46
|
+
children: "⚠"
|
|
47
|
+
}),
|
|
48
|
+
" ",
|
|
49
|
+
result.error
|
|
50
|
+
]
|
|
51
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
52
|
+
style: {
|
|
53
|
+
display: "grid",
|
|
54
|
+
gap: 14
|
|
55
|
+
},
|
|
56
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
57
|
+
style: {
|
|
58
|
+
display: "flex",
|
|
59
|
+
justifyContent: "center",
|
|
60
|
+
alignItems: "baseline",
|
|
61
|
+
gap: 12,
|
|
62
|
+
flexWrap: "wrap",
|
|
63
|
+
fontSize: 19,
|
|
64
|
+
padding: "6px 4px"
|
|
65
|
+
},
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx(Tex$1, {
|
|
68
|
+
tex: `${result.polyTex}${mode === "solve" ? " = 0" : ""}`,
|
|
69
|
+
block: true
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsx("span", {
|
|
72
|
+
style: {
|
|
73
|
+
color: "var(--stage-muted)",
|
|
74
|
+
fontSize: 22
|
|
75
|
+
},
|
|
76
|
+
children: "→"
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ jsx(Tex$1, {
|
|
79
|
+
tex: result.answerTex,
|
|
80
|
+
block: true
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("button", {
|
|
84
|
+
type: "button",
|
|
85
|
+
className: "lab-chip",
|
|
86
|
+
onClick: () => setShow((s) => !s),
|
|
87
|
+
"aria-expanded": show,
|
|
88
|
+
children: show ? "▾ hide the steps" : "▸ show the steps"
|
|
89
|
+
}), show && /* @__PURE__ */ jsx("div", {
|
|
90
|
+
style: {
|
|
91
|
+
marginTop: 10,
|
|
92
|
+
border: "1px solid var(--stage-grid)",
|
|
93
|
+
borderRadius: 12,
|
|
94
|
+
padding: "12px 14px"
|
|
95
|
+
},
|
|
96
|
+
children: /* @__PURE__ */ jsx(WorkedSteps, { worked: result.worked })
|
|
97
|
+
})] })]
|
|
98
|
+
});
|
|
99
|
+
return /* @__PURE__ */ jsx(LabFrame, {
|
|
100
|
+
title,
|
|
101
|
+
prompt,
|
|
102
|
+
controls: editable ? /* @__PURE__ */ jsx(ControlBar, { children: /* @__PURE__ */ jsxs("label", {
|
|
103
|
+
style: {
|
|
104
|
+
display: "inline-flex",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
gap: 8,
|
|
107
|
+
flex: 1
|
|
108
|
+
},
|
|
109
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
110
|
+
style: {
|
|
111
|
+
color: "var(--stage-muted)",
|
|
112
|
+
fontSize: 13
|
|
113
|
+
},
|
|
114
|
+
children: mode === "solve" ? "solve" : "factor"
|
|
115
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
116
|
+
value: src,
|
|
117
|
+
onChange: (e) => {
|
|
118
|
+
setSrc(e.target.value);
|
|
119
|
+
setShow(false);
|
|
120
|
+
},
|
|
121
|
+
"aria-label": "polynomial in x",
|
|
122
|
+
spellCheck: false,
|
|
123
|
+
style: {
|
|
124
|
+
flex: 1,
|
|
125
|
+
minWidth: 180,
|
|
126
|
+
padding: "6px 10px",
|
|
127
|
+
borderRadius: 8,
|
|
128
|
+
border: "1px solid var(--stage-grid)",
|
|
129
|
+
background: "var(--stage-bg)",
|
|
130
|
+
color: "var(--stage-fg)",
|
|
131
|
+
fontFamily: "ui-monospace, monospace",
|
|
132
|
+
fontSize: 14
|
|
133
|
+
}
|
|
134
|
+
})]
|
|
135
|
+
}) }) : void 0,
|
|
136
|
+
children: figure
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { PolynomialSolverLab };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Worked } from "../../kit/calc.mjs";
|
|
2
|
+
import { Poly } from "./core.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/math/poly/steps.d.ts
|
|
5
|
+
/** Step-by-step FACTORISATION of a polynomial. */
|
|
6
|
+
declare function factorSteps(p0: Poly, x?: string): Worked;
|
|
7
|
+
/** Step-by-step SOLUTION of p = 0 (factor, then each factor = 0 → the roots). */
|
|
8
|
+
declare function solveSteps(p0: Poly, x?: string): Worked;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { factorSteps, solveSteps };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { toStr } from "../complex/core.mjs";
|
|
2
|
+
import { calc } from "../../kit/calc.mjs";
|
|
3
|
+
import { deflate, degree, evalPoly, factorTex, polyTex, solve, trim } from "./core.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/math/poly/steps.ts
|
|
6
|
+
/**
|
|
7
|
+
* Polynomial SOLVER steps, the engine side of a step-by-step solver. It emits a
|
|
8
|
+
* {@link Worked} trace (the same data a RuleCard / lesson renders) using the
|
|
9
|
+
* COMMON SCHOOL METHOD, not a raw CAS dump:
|
|
10
|
+
* • quadratics → split the middle term (find the factor pair of a·c that adds
|
|
11
|
+
* to b) and factor by grouping; fall back to the quadratic
|
|
12
|
+
* formula + discriminant when it doesn't factor over ℤ.
|
|
13
|
+
* • higher deg → the factor theorem: find a rational root, divide out (x − r)
|
|
14
|
+
* by synthetic division, repeat down to a quadratic.
|
|
15
|
+
*
|
|
16
|
+
* Pure: builds on the canonical poly core + complex kernel. A creator drops the
|
|
17
|
+
* solver lab; the learner sees the working. (For a curated LESSON, author the
|
|
18
|
+
* steps by hand instead — this is the TOOL path.)
|
|
19
|
+
*/
|
|
20
|
+
const n2 = (n) => {
|
|
21
|
+
const r = Math.round(n * 1e6) / 1e6;
|
|
22
|
+
return (Object.is(r, -0) ? 0 : r).toString();
|
|
23
|
+
};
|
|
24
|
+
const lin = (r, x) => r === 0 ? x : `(${x} ${r < 0 ? "+" : "-"} ${n2(Math.abs(r))})`;
|
|
25
|
+
/** coefficient × x-power, dropping a leading 1 (so "x^2", not "1x^2"). */
|
|
26
|
+
const cx = (c, xp) => Math.abs(c) === 1 && xp ? c < 0 ? `-${xp}` : xp : `${n2(c)}${xp}`;
|
|
27
|
+
/** Integer pair (u, v) with u·v = prod and u + v = sum, or null. */
|
|
28
|
+
function factorPair(prod, sum) {
|
|
29
|
+
if (!Number.isInteger(prod) || !Number.isInteger(sum)) return null;
|
|
30
|
+
const lim = Math.min(2e4, Math.abs(prod) + 1);
|
|
31
|
+
for (let u = -lim; u <= lim; u++) {
|
|
32
|
+
if (u === 0) {
|
|
33
|
+
if (prod === 0 && v0(sum) === 0) return [0, sum];
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (prod % u === 0) {
|
|
37
|
+
const v = prod / u;
|
|
38
|
+
if (u + v === sum) return [u, v];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const v0 = (s) => s;
|
|
44
|
+
function quadratic(p, x) {
|
|
45
|
+
const a = p[2], b = p[1], c = p[0];
|
|
46
|
+
const w = calc().step(`${polyTex(p, x)} \\;=\\; a${x}^2 + b${x} + c`, `compare to ax² + bx + c: a = ${n2(a)} (the x² coefficient), b = ${n2(b)} (the middle), c = ${n2(c)} (the constant)`);
|
|
47
|
+
const ac = a * c;
|
|
48
|
+
const pair = factorPair(ac, b);
|
|
49
|
+
if (pair && [
|
|
50
|
+
a,
|
|
51
|
+
b,
|
|
52
|
+
c
|
|
53
|
+
].every(Number.isInteger)) {
|
|
54
|
+
const [u, v] = pair;
|
|
55
|
+
w.step(`a \\times c = (${n2(a)})(${n2(c)}) = ${n2(ac)}`, "multiply the x² coefficient by the constant").step(`\\text{find } u, v:\\ \\ u \\cdot v = ${n2(ac)}\\ \\text{ and }\\ u + v = ${n2(b)} \\;\\Rightarrow\\; u = ${n2(u)},\\ v = ${n2(v)}`, `two numbers that multiply to a·c (${n2(ac)}) and add to b (${n2(b)})`).step(`${cx(a, `${x}^2`)} ${u < 0 ? "-" : "+"} ${n2(Math.abs(u))}${x} ${v < 0 ? "-" : "+"} ${n2(Math.abs(v))}${x} ${c < 0 ? "-" : "+"} ${n2(Math.abs(c))}`, `split the middle term ${n2(b)}${x} into ${n2(u)}${x} + ${n2(v)}${x}`).step(`= ${factorTex(p, x)}`, "group in pairs and take out the common factor");
|
|
56
|
+
return w.done(0);
|
|
57
|
+
}
|
|
58
|
+
const disc = b * b - 4 * a * c;
|
|
59
|
+
const sol = solve(p);
|
|
60
|
+
w.step(`\\Delta = b^2 - 4ac = (${n2(b)})^2 - 4(${n2(a)})(${n2(c)}) = ${n2(disc)}`, disc < 0 ? "the discriminant is negative, so the roots are complex" : "the discriminant b² − 4ac (no whole-number pair exists, so use the formula)").step(`x = \\dfrac{-b \\pm \\sqrt{\\Delta}}{2a} = \\dfrac{${n2(-b)} \\pm \\sqrt{${n2(disc)}}}{${n2(2 * a)}}`, "substitute a, b and Δ into the quadratic formula").step(sol.roots.length === 2 ? `x = ${toStr(sol.roots[0])} \\text{ or } ${toStr(sol.roots[1])}` : `x = ${toStr(sol.roots[0])}`, "the two roots").step(`= ${factorTex(p, x)}`, "factored form");
|
|
61
|
+
return w.done(0);
|
|
62
|
+
}
|
|
63
|
+
/** Step-by-step FACTORISATION of a polynomial. */
|
|
64
|
+
function factorSteps(p0, x = "x") {
|
|
65
|
+
const p = trim(p0);
|
|
66
|
+
const d = degree(p);
|
|
67
|
+
if (d <= 1) return calc().step(polyTex(p, x), d === 1 ? "already linear (a factor itself)" : "a constant").done(0);
|
|
68
|
+
if (d === 2) return quadratic(p, x);
|
|
69
|
+
const w = calc().step(polyTex(p, x), "the polynomial");
|
|
70
|
+
let cur = p;
|
|
71
|
+
for (const root of solve(p).roots) {
|
|
72
|
+
if (root.im !== 0) continue;
|
|
73
|
+
const r = root.re;
|
|
74
|
+
if (degree(cur) <= 2 || Math.abs(evalPoly(cur, r)) > 1e-6) continue;
|
|
75
|
+
w.step(`f(${n2(r)}) = 0 \\Rightarrow ${lin(r, x)} \\text{ is a factor}`, "factor theorem");
|
|
76
|
+
cur = deflate(cur, r);
|
|
77
|
+
w.step(`\\text{quotient } = ${polyTex(cur, x)}`, "divide it out (synthetic division)");
|
|
78
|
+
}
|
|
79
|
+
if (degree(cur) === 2) w.step(`${polyTex(cur, x)} \\Rightarrow \\text{factor the quadratic}`, "split the middle term / formula");
|
|
80
|
+
w.step(`= ${factorTex(p, x)}`, "fully factored");
|
|
81
|
+
return w.done(0);
|
|
82
|
+
}
|
|
83
|
+
/** Step-by-step SOLUTION of p = 0 (factor, then each factor = 0 → the roots). */
|
|
84
|
+
function solveSteps(p0, x = "x") {
|
|
85
|
+
const p = trim(p0);
|
|
86
|
+
const sol = solve(p);
|
|
87
|
+
if (!sol) return calc().step(polyTex(p, x), "no equation to solve").done(0);
|
|
88
|
+
const w = calc().step(`${polyTex(p, x)} = 0`, "set the polynomial to zero");
|
|
89
|
+
if (degree(p) === 2) {
|
|
90
|
+
const inner = quadratic(p, x);
|
|
91
|
+
for (const s of inner.steps.slice(1)) w.step(s.tex, s.note);
|
|
92
|
+
} else w.step(`${factorTex(p, x)} = 0`, "factor it (factor theorem)").step("\\text{each factor } = 0", "a product is 0 when a factor is 0");
|
|
93
|
+
const roots = sol.roots.map((r) => `${x} = ${toStr(r)}`).join(" \\text{ or } ");
|
|
94
|
+
w.step(roots || "\\text{no roots}", sol.realRoots.length < sol.roots.length ? "real and complex roots" : "the roots");
|
|
95
|
+
return w.done(sol.realRoots[0] ?? 0);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { factorSteps, solveSteps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { RateMachineLab, RateMachineProps } from "./preset.mjs";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/math/rate-machine/preset.d.ts
|
|
4
|
+
interface RateMachineProps {
|
|
5
|
+
/** Hidden rule: total = rate·count + base. */
|
|
6
|
+
rate?: number;
|
|
7
|
+
base?: number;
|
|
8
|
+
/** Largest count the learner can dial up to. */
|
|
9
|
+
maxCount?: number;
|
|
10
|
+
/** Where the count starts. */
|
|
11
|
+
startCount?: number;
|
|
12
|
+
yMax?: number;
|
|
13
|
+
yStep?: number;
|
|
14
|
+
xLabel?: string;
|
|
15
|
+
yLabel?: string;
|
|
16
|
+
unit?: string;
|
|
17
|
+
/** Word for one unit of the count (default: singular of xLabel). */
|
|
18
|
+
itemLabel?: string;
|
|
19
|
+
/** The concrete twin skin: 'vessel' (drops objects) or any registered level scene. */
|
|
20
|
+
scene?: string;
|
|
21
|
+
extraScenes?: string[];
|
|
22
|
+
/** Drop discrete objects (marbles) as the count = the input. Default true. */
|
|
23
|
+
showObjects?: boolean;
|
|
24
|
+
liquidColor?: string;
|
|
25
|
+
objectColor?: string;
|
|
26
|
+
/** Optional graded goal: "set it to N". Omit for a free explore. */
|
|
27
|
+
target?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
title?: string;
|
|
30
|
+
prompt?: string;
|
|
31
|
+
activity?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function RateMachineLab(props?: RateMachineProps): ReactNode;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { RateMachineLab, RateMachineProps };
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Stepper } from "../../kit/controls.mjs";
|
|
4
|
+
import { Callout, ControlBar, Field, LabFrame } from "../../kit/frame.mjs";
|
|
5
|
+
import { useCheckpoint } from "../../kit/pedagogy.mjs";
|
|
6
|
+
import { CoordPlane } from "../../kit/coords.mjs";
|
|
7
|
+
import { Vessel } from "../../kit/vessel.mjs";
|
|
8
|
+
import { getScene } from "../../kit/scenes.mjs";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Label, MovableDot, Point, Polyline, Segment } from "@classytic/stage";
|
|
12
|
+
|
|
13
|
+
//#region src/math/rate-machine/preset.tsx
|
|
14
|
+
/**
|
|
15
|
+
* RateMachineLab, the COUNT-driven member of the concrete → graph family (sibling of
|
|
16
|
+
* the reading-driven LinearModelLab). Here the learner drives the INPUT: drag the
|
|
17
|
+
* count up and down (or step it) and watch one quantity scale with it in three
|
|
18
|
+
* linked views at once:
|
|
19
|
+
* • discrete objects drop INTO / out of the vessel as the count changes;
|
|
20
|
+
* • the liquid level rises and falls by the same rate each step;
|
|
21
|
+
* • a point rides up the line on the graph, leaving a dot at every whole step so
|
|
22
|
+
* the equal-step pattern of a proportional/linear rule builds before your eyes.
|
|
23
|
+
*
|
|
24
|
+
* Proportionality becomes something you scrub, not a table you read. Built entirely
|
|
25
|
+
* on the shared primitives (Vessel + scene registry, CoordPlane + MovableDot, the
|
|
26
|
+
* kit Stepper / LabFrame / useCheckpoint), so it stays consistent with every other
|
|
27
|
+
* lab and an author skins it (battery, jar, savings, charge) by swapping props.
|
|
28
|
+
*/
|
|
29
|
+
const num = (n) => String(Math.round(n * 100) / 100);
|
|
30
|
+
const singular = (s) => s.replace(/s$/, "");
|
|
31
|
+
function RateMachineLab(props = {}) {
|
|
32
|
+
const { rate = 5, base = 0, maxCount = 6, startCount = 1, yMax = 40, yStep = 5, xLabel = "Items", yLabel = "Cost", unit = "$", itemLabel, scene = "vessel", extraScenes = [], showObjects = true, liquidColor = "var(--stage-accent)", objectColor = "#e85aa6", target, height = 340, title = `Build it up: ${rate} ${unit} per ${singular((itemLabel ?? xLabel).toLowerCase())}`, prompt, activity = "rate-machine" } = props;
|
|
33
|
+
const totalOf = (k) => rate * k + base;
|
|
34
|
+
const [count, setCount] = useState(() => Math.max(0, Math.min(maxCount, startCount)));
|
|
35
|
+
const total = totalOf(count);
|
|
36
|
+
const one = singular((itemLabel ?? xLabel).toLowerCase());
|
|
37
|
+
const solved = target != null && count === target;
|
|
38
|
+
const tone = solved ? "ok" : "idle";
|
|
39
|
+
useCheckpoint({
|
|
40
|
+
solved,
|
|
41
|
+
activity,
|
|
42
|
+
response: `${count} ${one} → ${num(total)} ${unit}`
|
|
43
|
+
});
|
|
44
|
+
const setK = (k) => setCount(Math.max(0, Math.min(maxCount, Math.round(k))));
|
|
45
|
+
const view = {
|
|
46
|
+
xMin: -maxCount * .04,
|
|
47
|
+
xMax: maxCount * 1.06,
|
|
48
|
+
yMin: -yMax * .06,
|
|
49
|
+
yMax: yMax * 1.06
|
|
50
|
+
};
|
|
51
|
+
const handle = {
|
|
52
|
+
x: count,
|
|
53
|
+
y: total
|
|
54
|
+
};
|
|
55
|
+
const accent = solved ? "var(--stage-good)" : "var(--stage-accent)";
|
|
56
|
+
const dots = [];
|
|
57
|
+
for (let k = 0; k <= count; k++) {
|
|
58
|
+
if (k === count) continue;
|
|
59
|
+
dots.push(/* @__PURE__ */ jsx(Point, {
|
|
60
|
+
x: k,
|
|
61
|
+
y: totalOf(k),
|
|
62
|
+
r: 5,
|
|
63
|
+
color: "var(--stage-fg)"
|
|
64
|
+
}, `d${k}`));
|
|
65
|
+
}
|
|
66
|
+
const figure = /* @__PURE__ */ jsxs(CoordPlane, {
|
|
67
|
+
view,
|
|
68
|
+
height,
|
|
69
|
+
preserveAspect: false,
|
|
70
|
+
stepX: 1,
|
|
71
|
+
stepY: yStep,
|
|
72
|
+
ariaLabel: `Graph of ${yLabel} against ${xLabel}; ${count} ${count === 1 ? one : (itemLabel ?? xLabel).toLowerCase()} so far`,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx(Label, {
|
|
75
|
+
x: 0,
|
|
76
|
+
y: view.yMax,
|
|
77
|
+
text: yLabel,
|
|
78
|
+
dx: 6,
|
|
79
|
+
dy: -2,
|
|
80
|
+
anchor: "start",
|
|
81
|
+
size: 12,
|
|
82
|
+
weight: 700
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ jsx(Label, {
|
|
85
|
+
x: view.xMax,
|
|
86
|
+
y: 0,
|
|
87
|
+
text: xLabel,
|
|
88
|
+
dx: -2,
|
|
89
|
+
dy: 16,
|
|
90
|
+
anchor: "end",
|
|
91
|
+
size: 12,
|
|
92
|
+
weight: 700
|
|
93
|
+
}),
|
|
94
|
+
count > 0 && /* @__PURE__ */ jsx(Polyline, {
|
|
95
|
+
points: [{
|
|
96
|
+
x: 0,
|
|
97
|
+
y: base
|
|
98
|
+
}, ...Array.from({ length: count }, (_, i) => ({
|
|
99
|
+
x: i + 1,
|
|
100
|
+
y: totalOf(i + 1)
|
|
101
|
+
}))],
|
|
102
|
+
color: accent,
|
|
103
|
+
weight: 2,
|
|
104
|
+
opacity: .55
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsx(Segment, {
|
|
107
|
+
from: {
|
|
108
|
+
x: count,
|
|
109
|
+
y: total
|
|
110
|
+
},
|
|
111
|
+
to: {
|
|
112
|
+
x: 0,
|
|
113
|
+
y: total
|
|
114
|
+
},
|
|
115
|
+
color: accent,
|
|
116
|
+
weight: 1.5,
|
|
117
|
+
dashed: true,
|
|
118
|
+
opacity: .8
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ jsx(Label, {
|
|
121
|
+
x: 0,
|
|
122
|
+
y: total,
|
|
123
|
+
text: num(total),
|
|
124
|
+
dx: -8,
|
|
125
|
+
anchor: "end",
|
|
126
|
+
size: 11,
|
|
127
|
+
weight: 700,
|
|
128
|
+
color: accent
|
|
129
|
+
}),
|
|
130
|
+
dots,
|
|
131
|
+
/* @__PURE__ */ jsx(MovableDot, {
|
|
132
|
+
value: handle,
|
|
133
|
+
onMove: (p) => setK(p.x),
|
|
134
|
+
constrain: "horizontal",
|
|
135
|
+
range: {
|
|
136
|
+
min: 0,
|
|
137
|
+
max: maxCount
|
|
138
|
+
},
|
|
139
|
+
step: 1,
|
|
140
|
+
color: accent,
|
|
141
|
+
r: 8,
|
|
142
|
+
ariaLabel: `drag right to add ${(itemLabel ?? xLabel).toLowerCase()}, left to remove; now ${count}`
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ jsx(Label, {
|
|
145
|
+
x: count,
|
|
146
|
+
y: total,
|
|
147
|
+
text: `${count} ${count === 1 ? one : (itemLabel ?? xLabel).toLowerCase()}`,
|
|
148
|
+
dx: 10,
|
|
149
|
+
dy: -8,
|
|
150
|
+
anchor: "start",
|
|
151
|
+
size: 11,
|
|
152
|
+
weight: 700,
|
|
153
|
+
color: accent
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
const fillFrac = total / yMax;
|
|
158
|
+
const levelColor = solved ? "var(--stage-good)" : liquidColor;
|
|
159
|
+
const sceneLabel = `${count} ${count === 1 ? one : (itemLabel ?? xLabel).toLowerCase()}`;
|
|
160
|
+
const names = scene === "none" ? [] : [scene, ...extraScenes];
|
|
161
|
+
const multi = names.length > 1;
|
|
162
|
+
const dim = multi ? Math.round((height - 8) / names.length) - 6 : height - 8;
|
|
163
|
+
const twins = names.map((name, i) => {
|
|
164
|
+
return /* @__PURE__ */ jsx("div", { children: name === "vessel" ? /* @__PURE__ */ jsx(Vessel, {
|
|
165
|
+
width: multi ? 110 : 132,
|
|
166
|
+
height: dim,
|
|
167
|
+
fillFrac,
|
|
168
|
+
guessTone: tone,
|
|
169
|
+
objects: showObjects ? count : 0,
|
|
170
|
+
liquidColor: levelColor,
|
|
171
|
+
objectColor,
|
|
172
|
+
label: multi ? void 0 : sceneLabel,
|
|
173
|
+
scaleMax: multi ? void 0 : yMax,
|
|
174
|
+
scaleStep: yStep * 2,
|
|
175
|
+
unit
|
|
176
|
+
}) : getScene(name)?.render({
|
|
177
|
+
frac: fillFrac,
|
|
178
|
+
guessTone: tone,
|
|
179
|
+
color: levelColor,
|
|
180
|
+
label: multi ? void 0 : sceneLabel,
|
|
181
|
+
width: multi ? 118 : 138,
|
|
182
|
+
height: dim
|
|
183
|
+
}) }, i);
|
|
184
|
+
}).filter((t) => t.props.children);
|
|
185
|
+
const readout = /* @__PURE__ */ jsx(Callout, {
|
|
186
|
+
tone: "result",
|
|
187
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
188
|
+
style: {
|
|
189
|
+
display: "grid",
|
|
190
|
+
gap: 6,
|
|
191
|
+
fontSize: 13,
|
|
192
|
+
fontVariantNumeric: "tabular-nums"
|
|
193
|
+
},
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsxs("span", {
|
|
196
|
+
style: { fontWeight: 700 },
|
|
197
|
+
children: [
|
|
198
|
+
count,
|
|
199
|
+
" × ",
|
|
200
|
+
num(rate),
|
|
201
|
+
base ? ` + ${num(base)}` : "",
|
|
202
|
+
" = ",
|
|
203
|
+
/* @__PURE__ */ jsxs("strong", {
|
|
204
|
+
style: { color: `var(--stage-${solved ? "good" : "fg"})` },
|
|
205
|
+
children: [
|
|
206
|
+
num(total),
|
|
207
|
+
" ",
|
|
208
|
+
unit
|
|
209
|
+
]
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
}),
|
|
213
|
+
/* @__PURE__ */ jsxs("span", {
|
|
214
|
+
style: { color: "var(--stage-muted)" },
|
|
215
|
+
children: [
|
|
216
|
+
"Each ",
|
|
217
|
+
one,
|
|
218
|
+
" adds ",
|
|
219
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
220
|
+
num(rate),
|
|
221
|
+
" ",
|
|
222
|
+
unit
|
|
223
|
+
] }),
|
|
224
|
+
": the same step every time."
|
|
225
|
+
]
|
|
226
|
+
}),
|
|
227
|
+
target != null && (solved ? /* @__PURE__ */ jsxs("span", {
|
|
228
|
+
style: {
|
|
229
|
+
color: "var(--stage-good)",
|
|
230
|
+
fontWeight: 700
|
|
231
|
+
},
|
|
232
|
+
children: [
|
|
233
|
+
"✓ ",
|
|
234
|
+
target,
|
|
235
|
+
" ",
|
|
236
|
+
target === 1 ? one : (itemLabel ?? xLabel).toLowerCase(),
|
|
237
|
+
"."
|
|
238
|
+
]
|
|
239
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
240
|
+
style: { color: "var(--stage-muted)" },
|
|
241
|
+
children: [
|
|
242
|
+
"Goal: set it to ",
|
|
243
|
+
target,
|
|
244
|
+
"."
|
|
245
|
+
]
|
|
246
|
+
}))
|
|
247
|
+
]
|
|
248
|
+
})
|
|
249
|
+
});
|
|
250
|
+
const aside = twins.length ? /* @__PURE__ */ jsxs("div", {
|
|
251
|
+
style: {
|
|
252
|
+
display: "grid",
|
|
253
|
+
gap: 10,
|
|
254
|
+
justifyItems: "center"
|
|
255
|
+
},
|
|
256
|
+
children: [twins, readout]
|
|
257
|
+
}) : readout;
|
|
258
|
+
const controls = /* @__PURE__ */ jsx(ControlBar, { children: /* @__PURE__ */ jsx(Field, {
|
|
259
|
+
label: xLabel,
|
|
260
|
+
name: "count",
|
|
261
|
+
value: `${count}`,
|
|
262
|
+
children: /* @__PURE__ */ jsx(Stepper, {
|
|
263
|
+
label: xLabel,
|
|
264
|
+
value: count,
|
|
265
|
+
min: 0,
|
|
266
|
+
max: maxCount,
|
|
267
|
+
step: 1,
|
|
268
|
+
onChange: setK
|
|
269
|
+
})
|
|
270
|
+
}) });
|
|
271
|
+
return /* @__PURE__ */ jsx(LabFrame, {
|
|
272
|
+
title,
|
|
273
|
+
prompt: prompt ?? `Drag the point right to add ${(itemLabel ?? xLabel).toLowerCase()}. Watch the ${unit === "$" ? yLabel.toLowerCase() : "level"} grow by ${num(rate)} ${unit} each time.`,
|
|
274
|
+
aside,
|
|
275
|
+
controls,
|
|
276
|
+
children: figure
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
//#endregion
|
|
281
|
+
export { RateMachineLab };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { RatioShareLab, RatioShareProps } from "./preset.mjs";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/math/ratio-share/preset.d.ts
|
|
4
|
+
interface RatioShareProps {
|
|
5
|
+
/** Ratio parts a : b. Defaults 2 : 3. */
|
|
6
|
+
a?: number;
|
|
7
|
+
b?: number;
|
|
8
|
+
/** The quantity being shared. Default 100. */
|
|
9
|
+
total?: number;
|
|
10
|
+
unit?: string;
|
|
11
|
+
labelA?: string;
|
|
12
|
+
labelB?: string;
|
|
13
|
+
/** Drag step for the divider, in units of the total. Default 1. */
|
|
14
|
+
step?: number;
|
|
15
|
+
/** Optional concrete twin (any level scene): share A as a pie / jar slice / etc. */
|
|
16
|
+
scene?: string;
|
|
17
|
+
height?: number;
|
|
18
|
+
title?: string;
|
|
19
|
+
prompt?: string;
|
|
20
|
+
activity?: string;
|
|
21
|
+
}
|
|
22
|
+
declare function RatioShareLab(props?: RatioShareProps): ReactNode;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RatioShareLab, RatioShareProps };
|