@khanacademy/perseus-editor 0.1.0 → 0.1.3
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/CHANGELOG.md +22 -0
- package/dist/es/index.css +1020 -0
- package/dist/es/index.js +2 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +1020 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/json-editor.jsx +4 -1
- package/src/components/link.jsx +4 -4
- package/src/diffs/string-array-diff.jsx +1 -0
- package/src/diffs/text-diff.jsx +1 -0
- package/src/multirenderer-editor.jsx +1 -0
- package/src/widgets/definition-editor.jsx +0 -1
- package/src/widgets/example-graphie-widget.jsx +1 -1
- package/src/widgets/expression-editor.jsx +2 -1
- package/src/widgets/interaction-editor.jsx +1 -0
- package/src/widgets/interactive-graph-editor.jsx +3 -1
- package/src/widgets/label-image-editor.jsx +1 -0
- package/src/widgets/number-line-editor.jsx +1 -1
- package/src/widgets/plotter-editor.jsx +1 -1
- package/src/widgets/radio/editor.jsx +0 -1
- package/src/widgets/reaction-diagram-editor.jsx +1 -0
- package/src/widgets/transformer-editor.jsx +7 -7
- package/src/widgets/unit-editor.jsx +1 -1
package/dist/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{constants as e,components as t,Widgets as n,Util as r,Log as a,PerseusError as s,Errors as i,Dependencies as o,PerseusMarkdown as l,preprocessTex as c,icons as p,WIDGET_PROP_BLACKLIST as h,ApiOptions as u,buildMapper as d,itemToTree as m,buildEmptyItemTreeForShape as g,shapes as f,itemDataVersion as v,ClassNames as y,MultiItems as b,traverse as E,Categorizer as w,Changeable as x,EditorJsonify as C,WidgetJsonifyDeprecated as k,Expression as S,interactiveSizes as N,KhanMath as T,GrapherWidget as _,GrapherUtil as O,SizingUtils as M,KhanColors as A,ColorPicker as P,DashPicker as D,ArrowPicker as I,ElementContainer as R,InteractiveGraphWidget as z,globalStyles as L,globalConstants as F,MatrixWidget as q,PlotterWidget as U,BaseRadio as W,TableWidget as V,TransformerWidget as j,displaySigFigs as B,widgets as $}from"@khanacademy/perseus";import*as H from"@khanacademy/perseus";export{H as Perseus};import*as G from"react";import Y,{Component as K}from"react";import X from"underscore";import J from"prop-types";import Z from"create-react-class";import Q from"jquery";import*as ee from"react-dom";import te from"react-dom";import{StyleSheet as ne,css as re}from"aphrodite";import ae from"classnames";import*as se from"@khanacademy/wonder-blocks-i18n";function ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function oe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ie(Object(n),!0).forEach((function(t){le(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ie(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function le(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(){return ce=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ce.apply(this,arguments)}function pe(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var he={phone:{width:320,height:480,framedWidth:320},tablet:{width:750,height:920,framedWidth:525},desktop:{width:688,height:600,framedWidth:688}};class ue extends G.Component{render(){var t=this.props.deviceType;if(this.props.nochrome)return G.createElement("div",null,G.createElement("div",{key:"screen",style:{width:he[t].framedWidth+2*e.perseusFrameBorderWidth+e.lintGutterWidth}},G.createElement("div",null,this.props.children)));var n=he[t].framedWidth/he[t].width,r={backgroundColor:"white",color:"black",textAlign:"left",width:he[t].width,height:he[t].height,border:"solid 1px #CCC",margin:8,zoom:n};return G.createElement("div",{key:"screen",className:"screen",style:r},this.props.children)}}le(ue,"propTypes",{children:J.element.isRequired,deviceType:J.oneOf([e.devices.PHONE,e.devices.TABLET,e.devices.DESKTOP]).isRequired,nochrome:J.bool});var de=Z({displayName:"JsonEditor",getInitialState:function(){return{currentValue:JSON.stringify(this.props.value,null,4),valid:!0}},UNSAFE_componentWillReceiveProps:function(e){(!this.state.valid||!X.isEqual(e.value,JSON.parse(this.state.currentValue)))&&this.setState(this.getInitialState())},render:function(){var e="perseus-json-editor "+(this.state.valid?"valid":"invalid");return G.createElement("textarea",{className:e,value:this.state.currentValue,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onBlur:this.handleBlur})},handleKeyDown:function(e){if("Tab"===e.key){var t=e.target.selectionStart,n=e.target.value,r=n.substring(0,t),a=n.substring(t,n.length);e.target.value=r+" "+a,e.target.selectionStart=r.length+4,e.target.selectionEnd=r.length+4,e.preventDefault(),this.handleChange(e)}},handleChange:function(e){var t=e.target.value;try{var n=JSON.parse(t);X.isString(n)&&(n=JSON.parse(n)),this.setState({currentValue:t,valid:!0},(function(){this.props.onChange(n)}))}catch(e){this.setState({currentValue:t,valid:!1})}},handleBlur:function(e){var t=e.target.value;try{var n=JSON.parse(t);X.isString(n)&&(n=JSON.parse(n)),this.setState({currentValue:JSON.stringify(n,null,4),valid:!0},(function(){this.props.onChange(n)}))}catch(e){this.setState({currentValue:JSON.stringify(this.props.value,null,4),valid:!0})}}}),me=Z({displayName:"DragTarget",propTypes:{onDrop:J.func.isRequired,component:J.any,shouldDragHighlight:J.func,style:J.any},getDefaultProps:function(){return{component:"div",shouldDragHighlight:()=>!0}},getInitialState:function(){return{dragHover:!1}},handleDrop:function(e){e.stopPropagation(),e.preventDefault(),this.setState({dragHover:!1}),this.props.onDrop(e)},handleDragEnd:function(){this.setState({dragHover:!1})},handleDragOver:function(e){e.preventDefault()},handleDragLeave:function(){this.setState({dragHover:!1})},handleDragEnter:function(e){this.setState({dragHover:this.props.shouldDragHighlight(e)})},render:function(){var e=this.state.dragHover?{opacity:.3}:{},t=this.props.component,n=Object.assign({},this.props);return delete n.component,delete n.shouldDragHighlight,G.createElement(t,ce({},n,{style:Object.assign({},this.props.style,e),onDrop:this.handleDrop,onDragEnd:this.handleDragEnd,onDragOver:this.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave}))}});class ge extends G.Component{constructor(){super(...arguments),le(this,"state",{showErrors:!1}),le(this,"handleToggleKatexErrors",(e=>{this.setState({showErrors:!this.state.showErrors})}))}render(){var{errorList:e}=this.props,{showErrors:t}=this.state,n=t?"icon-chevron-down":"icon-chevron-right";return G.createElement("div",{className:re(fe.errorContainer)},G.createElement("div",{className:re(fe.title),onClick:this.handleToggleKatexErrors},G.createElement("i",{className:n,style:{fontSize:14}})," KaTeX Errors (",e.length,")"),t&&G.createElement("div",{className:re(fe.errorExplanation)},"These errors will cause your LaTeX to load really slowly for the student. Please fix them if you can. If you can’t because KaTeX doesn’t support the feature you need, please message Cam."),t&&e.map(((e,t)=>G.createElement("div",{className:re(fe.error),key:t},G.createElement("div",{style:{color:"red"}},e.math),G.createElement("div",null,e.message)))))}}le(ge,"propTypes",{errorList:J.arrayOf(J.shape({math:J.string.isRequired,message:J.string.isRequired})).isRequired});var fe=ne.create({title:{backgroundColor:"#eee",fontSize:"1.25em",padding:"4px 10px"},errorContainer:{border:"1px solid #ddd",borderTop:"none"},errorExplanation:{padding:"4px 10px",backgroundColor:"pink"},error:{padding:"4px 10px"}});function ve(e,t){if(null==e)return{};var n,r,a={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}function ye(){return ye=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(this,arguments)}function be(e,t){return be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},be(e,t)}function Ee(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,be(e,t)}function we(e){return"/"===e.charAt(0)}function xe(e,t){for(var n=t,r=n+1,a=e.length;r<a;n+=1,r+=1)e[n]=e[r];e.pop()}var Ce="production"===process.env.NODE_ENV;function ke(e,t){if(!Ce){if(e)return;var n="Warning: "+t;"undefined"!=typeof console&&console.warn(n);try{throw Error(n)}catch(e){}}}var Se="production"===process.env.NODE_ENV,Ne="Invariant failed";function Te(e,t){if(!e){if(Se)throw new Error(Ne);var n="function"==typeof t?t():t;throw new Error(n?Ne+": "+n:Ne)}}function _e(e){return"/"===e.charAt(0)?e:"/"+e}function Oe(e){return"/"===e.charAt(0)?e.substr(1):e}function Me(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function Ae(e,t){return Me(e,t)?e.substr(t.length):e}function Pe(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function De(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function Ie(e,t,n,r){var a;"string"==typeof e?(a=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var s=t.indexOf("?");return-1!==s&&(n=t.substr(s),t=t.substr(0,s)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),a.state=t):(void 0===(a=ye({},e)).pathname&&(a.pathname=""),a.search?"?"!==a.search.charAt(0)&&(a.search="?"+a.search):a.search="",a.hash?"#"!==a.hash.charAt(0)&&(a.hash="#"+a.hash):a.hash="",void 0!==t&&void 0===a.state&&(a.state=t));try{a.pathname=decodeURI(a.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+a.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(a.key=n),r?a.pathname?"/"!==a.pathname.charAt(0)&&(a.pathname=function(e,t){void 0===t&&(t="");var n,r=e&&e.split("/")||[],a=t&&t.split("/")||[],s=e&&we(e),i=t&&we(t),o=s||i;if(e&&we(e)?a=r:r.length&&(a.pop(),a=a.concat(r)),!a.length)return"/";if(a.length){var l=a[a.length-1];n="."===l||".."===l||""===l}else n=!1;for(var c=0,p=a.length;p>=0;p--){var h=a[p];"."===h?xe(a,p):".."===h?(xe(a,p),c++):c&&(xe(a,p),c--)}if(!o)for(;c--;c)a.unshift("..");!o||""===a[0]||a[0]&&we(a[0])||a.unshift("");var u=a.join("/");return n&&"/"!==u.substr(-1)&&(u+="/"),u}(a.pathname,r.pathname)):a.pathname=r.pathname:a.pathname||(a.pathname="/"),a}function Re(){var e=null;var t=[];return{setPrompt:function(t){return"production"!==process.env.NODE_ENV&&ke(null==e,"A history supports only one prompt at a time"),e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var s="function"==typeof e?e(t,n):e;"string"==typeof s?"function"==typeof r?r(s,a):("production"!==process.env.NODE_ENV&&ke(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),a(!0)):a(!1!==s)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];t.forEach((function(e){return e.apply(void 0,n)}))}}}var ze=!("undefined"==typeof window||!window.document||!window.document.createElement);function Le(e,t){t(window.confirm(e))}function Fe(){try{return window.history.state||{}}catch(e){return{}}}function qe(e){void 0===e&&(e={}),ze||("production"!==process.env.NODE_ENV?Te(!1,"Browser history needs a DOM"):Te(!1));var t,n=window.history,r=(-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,a=!(-1===window.navigator.userAgent.indexOf("Trident")),s=e,i=s.forceRefresh,o=void 0!==i&&i,l=s.getUserConfirmation,c=void 0===l?Le:l,p=s.keyLength,h=void 0===p?6:p,u=e.basename?Pe(_e(e.basename)):"";function d(e){var t=e||{},n=t.key,r=t.state,a=window.location,s=a.pathname+a.search+a.hash;return"production"!==process.env.NODE_ENV&&ke(!u||Me(s,u),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+s+'" to begin with "'+u+'".'),u&&(s=Ae(s,u)),Ie(s,r,n)}function m(){return Math.random().toString(36).substr(2,h)}var g=Re();function f(e){ye(_,e),_.length=n.length,g.notifyListeners(_.location,_.action)}function v(e){(function(e){return void 0===e.state&&-1===navigator.userAgent.indexOf("CriOS")})(e)||E(d(e.state))}function y(){E(d(Fe()))}var b=!1;function E(e){if(b)b=!1,f();else{g.confirmTransitionTo(e,"POP",c,(function(t){t?f({action:"POP",location:e}):function(e){var t=_.location,n=x.indexOf(t.key);-1===n&&(n=0);var r=x.indexOf(e.key);-1===r&&(r=0);var a=n-r;a&&(b=!0,k(a))}(e)}))}}var w=d(Fe()),x=[w.key];function C(e){return u+De(e)}function k(e){n.go(e)}var S=0;function N(e){1===(S+=e)&&1===e?(window.addEventListener("popstate",v),a&&window.addEventListener("hashchange",y)):0===S&&(window.removeEventListener("popstate",v),a&&window.removeEventListener("hashchange",y))}var T=!1;var _={length:n.length,action:"POP",location:w,createHref:C,push:function(e,t){"production"!==process.env.NODE_ENV&&ke(!("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 a="PUSH",s=Ie(e,t,m(),_.location);g.confirmTransitionTo(s,a,c,(function(e){if(e){var t=C(s),i=s.key,l=s.state;if(r)if(n.pushState({key:i,state:l},null,t),o)window.location.href=t;else{var c=x.indexOf(_.location.key),p=x.slice(0,c+1);p.push(s.key),x=p,f({action:a,location:s})}else"production"!==process.env.NODE_ENV&&ke(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&&ke(!("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 a="REPLACE",s=Ie(e,t,m(),_.location);g.confirmTransitionTo(s,a,c,(function(e){if(e){var t=C(s),i=s.key,l=s.state;if(r)if(n.replaceState({key:i,state:l},null,t),o)window.location.replace(t);else{var c=x.indexOf(_.location.key);-1!==c&&(x[c]=s.key),f({action:a,location:s})}else"production"!==process.env.NODE_ENV&&ke(void 0===l,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(t)}}))},go:k,goBack:function(){k(-1)},goForward:function(){k(1)},block:function(e){void 0===e&&(e=!1);var t=g.setPrompt(e);return T||(N(1),T=!0),function(){return T&&(T=!1,N(-1)),t()}},listen:function(e){var t=g.appendListener(e);return N(1),function(){N(-1),t()}}};return _}var Ue={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+Oe(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:Oe,decodePath:_e},slash:{encodePath:_e,decodePath:_e}};function We(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function Ve(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function je(e){window.location.replace(We(window.location.href)+"#"+e)}function Be(e){void 0===e&&(e={}),ze||("production"!==process.env.NODE_ENV?Te(!1,"Hash history needs a DOM"):Te(!1));var t=window.history,n=-1===window.navigator.userAgent.indexOf("Firefox"),r=e,a=r.getUserConfirmation,s=void 0===a?Le:a,i=r.hashType,o=void 0===i?"slash":i,l=e.basename?Pe(_e(e.basename)):"",c=Ue[o],p=c.encodePath,h=c.decodePath;function u(){var e=h(Ve());return"production"!==process.env.NODE_ENV&&ke(!l||Me(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=Ae(e,l)),Ie(e)}var d=Re();function m(e){ye(N,e),N.length=t.length,d.notifyListeners(N.location,N.action)}var g=!1,f=null;function v(){var e,t,n=Ve(),r=p(n);if(n!==r)je(r);else{var a=u(),i=N.location;if(!g&&(t=a,(e=i).pathname===t.pathname&&e.search===t.search&&e.hash===t.hash))return;if(f===De(a))return;f=null,function(e){if(g)g=!1,m();else{var t="POP";d.confirmTransitionTo(e,t,s,(function(n){n?m({action:t,location:e}):function(e){var t=N.location,n=w.lastIndexOf(De(t));-1===n&&(n=0);var r=w.lastIndexOf(De(e));-1===r&&(r=0);var a=n-r;a&&(g=!0,x(a))}(e)}))}}(a)}}var y=Ve(),b=p(y);y!==b&&je(b);var E=u(),w=[De(E)];function x(e){"production"!==process.env.NODE_ENV&&ke(n,"Hash history go(n) causes a full page reload in this browser"),t.go(e)}var C=0;function k(e){1===(C+=e)&&1===e?window.addEventListener("hashchange",v):0===C&&window.removeEventListener("hashchange",v)}var S=!1;var N={length:t.length,action:"POP",location:E,createHref:function(e){var t=document.querySelector("base"),n="";return t&&t.getAttribute("href")&&(n=We(window.location.href)),n+"#"+p(l+De(e))},push:function(e,t){"production"!==process.env.NODE_ENV&&ke(void 0===t,"Hash history cannot push state; it is ignored");var n="PUSH",r=Ie(e,void 0,void 0,N.location);d.confirmTransitionTo(r,n,s,(function(e){if(e){var t=De(r),a=p(l+t);if(Ve()!==a){f=t,function(e){window.location.hash=e}(a);var s=w.lastIndexOf(De(N.location)),i=w.slice(0,s+1);i.push(t),w=i,m({action:n,location:r})}else"production"!==process.env.NODE_ENV&&ke(!1,"Hash history cannot PUSH the same path; a new entry will not be added to the history stack"),m()}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&ke(void 0===t,"Hash history cannot replace state; it is ignored");var n="REPLACE",r=Ie(e,void 0,void 0,N.location);d.confirmTransitionTo(r,n,s,(function(e){if(e){var t=De(r),a=p(l+t);Ve()!==a&&(f=t,je(a));var s=w.indexOf(De(N.location));-1!==s&&(w[s]=t),m({action:n,location:r})}}))},go:x,goBack:function(){x(-1)},goForward:function(){x(1)},block:function(e){void 0===e&&(e=!1);var t=d.setPrompt(e);return S||(k(1),S=!0),function(){return S&&(S=!1,k(-1)),t()}},listen:function(e){var t=d.appendListener(e);return k(1),function(){k(-1),t()}}};return N}function $e(e,t,n){return Math.min(Math.max(e,t),n)}function He(e){void 0===e&&(e={});var t=e,n=t.getUserConfirmation,r=t.initialEntries,a=void 0===r?["/"]:r,s=t.initialIndex,i=void 0===s?0:s,o=t.keyLength,l=void 0===o?6:o,c=Re();function p(e){ye(f,e),f.length=f.entries.length,c.notifyListeners(f.location,f.action)}function h(){return Math.random().toString(36).substr(2,l)}var u=$e(i,0,a.length-1),d=a.map((function(e){return Ie(e,void 0,"string"==typeof e?h():e.key||h())})),m=De;function g(e){var t=$e(f.index+e,0,f.entries.length-1),r=f.entries[t];c.confirmTransitionTo(r,"POP",n,(function(e){e?p({action:"POP",location:r,index:t}):p()}))}var f={length:d.length,action:"POP",location:d[u],index:u,entries:d,createHref:m,push:function(e,t){"production"!==process.env.NODE_ENV&&ke(!("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 r="PUSH",a=Ie(e,t,h(),f.location);c.confirmTransitionTo(a,r,n,(function(e){if(e){var t=f.index+1,n=f.entries.slice(0);n.length>t?n.splice(t,n.length-t,a):n.push(a),p({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&ke(!("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 r="REPLACE",a=Ie(e,t,h(),f.location);c.confirmTransitionTo(a,r,n,(function(e){e&&(f.entries[f.index]=a,p({action:r,location:a}))}))},go:g,goBack:function(){g(-1)},goForward:function(){g(1)},canGo:function(e){var t=f.index+e;return t>=0&&t<f.entries.length},block:function(e){return void 0===e&&(e=!1),c.setPrompt(e)},listen:function(e){return c.appendListener(e)}};return f}var Ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function Ye(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,r){e=n,t.forEach((function(t){return t(e,r)}))}}}var Ke=Y.createContext||function(e,t){var n,r,a="__create-react-context-"+function(){var e="__global_unique_id__";return Ge[e]=(Ge[e]||0)+1}()+"__",s=function(e){function n(){var t;return(t=e.apply(this,arguments)||this).emitter=Ye(t.props.value),t}Ee(n,e);var r=n.prototype;return r.getChildContext=function(){var e;return(e={})[a]=this.emitter,e},r.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var n,r=this.props.value,a=e.value;((s=r)===(i=a)?0!==s||1/s==1/i:s!=s&&i!=i)?n=0:(n="function"==typeof t?t(r,a):1073741823,"production"!==process.env.NODE_ENV&&ke((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 s,i},r.render=function(){return this.props.children},n}(K);s.childContextTypes=((n={})[a]=J.object.isRequired,n);var i=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}Ee(n,t);var r=n.prototype;return r.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?1073741823:t},r.componentDidMount=function(){this.context[a]&&this.context[a].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?1073741823:e},r.componentWillUnmount=function(){this.context[a]&&this.context[a].off(this.onUpdate)},r.getValue=function(){return this.context[a]?this.context[a].get():e},r.render=function(){return(e=this.props.children,Array.isArray(e)?e[0]:e)(this.state.value);var e},n}(K);return i.contextTypes=((r={})[a]=J.object,r),{Provider:s,Consumer:i}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Je={exports:{}},Ze=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)};Je.exports=lt,Je.exports.parse=et,Je.exports.compile=function(e,t){return nt(et(e,t),t)},Je.exports.tokensToFunction=nt,Je.exports.tokensToRegExp=ot;var Qe=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function et(e,t){for(var n,r=[],a=0,s=0,i="",o=t&&t.delimiter||"/";null!=(n=Qe.exec(e));){var l=n[0],c=n[1],p=n.index;if(i+=e.slice(s,p),s=p+l.length,c)i+=c[1];else{var h=e[s],u=n[2],d=n[3],m=n[4],g=n[5],f=n[6],v=n[7];i&&(r.push(i),i="");var y=null!=u&&null!=h&&h!==u,b="+"===f||"*"===f,E="?"===f||"*"===f,w=n[2]||o,x=m||g;r.push({name:d||a++,prefix:u||"",delimiter:w,optional:E,repeat:b,partial:y,asterisk:!!v,pattern:x?at(x):v?".*":"[^"+rt(w)+"]+?"})}}return s<e.length&&(i+=e.substr(s)),i&&r.push(i),r}function tt(e){return encodeURI(e).replace(/[\/?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}function nt(e,t){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$",it(t)));return function(t,r){for(var a="",s=t||{},i=(r||{}).pretty?tt:encodeURIComponent,o=0;o<e.length;o++){var l=e[o];if("string"!=typeof l){var c,p=s[l.name];if(null==p){if(l.optional){l.partial&&(a+=l.prefix);continue}throw new TypeError('Expected "'+l.name+'" to be defined')}if(Ze(p)){if(!l.repeat)throw new TypeError('Expected "'+l.name+'" to not repeat, but received `'+JSON.stringify(p)+"`");if(0===p.length){if(l.optional)continue;throw new TypeError('Expected "'+l.name+'" to not be empty')}for(var h=0;h<p.length;h++){if(c=i(p[h]),!n[o].test(c))throw new TypeError('Expected all "'+l.name+'" to match "'+l.pattern+'", but received `'+JSON.stringify(c)+"`");a+=(0===h?l.prefix:l.delimiter)+c}}else{if(c=l.asterisk?encodeURI(p).replace(/[?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})):i(p),!n[o].test(c))throw new TypeError('Expected "'+l.name+'" to match "'+l.pattern+'", but received "'+c+'"');a+=l.prefix+c}}else a+=l}return a}}function rt(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function at(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function st(e,t){return e.keys=t,e}function it(e){return e&&e.sensitive?"":"i"}function ot(e,t,n){Ze(t)||(n=t||n,t=[]);for(var r=(n=n||{}).strict,a=!1!==n.end,s="",i=0;i<e.length;i++){var o=e[i];if("string"==typeof o)s+=rt(o);else{var l=rt(o.prefix),c="(?:"+o.pattern+")";t.push(o),o.repeat&&(c+="(?:"+l+c+")*"),s+=c=o.optional?o.partial?l+"("+c+")?":"(?:"+l+"("+c+"))?":l+"("+c+")"}}var p=rt(n.delimiter||"/"),h=s.slice(-p.length)===p;return r||(s=(h?s.slice(0,-p.length):s)+"(?:"+p+"(?=$))?"),s+=a?"$":r&&h?"":"(?="+p+"|$)",st(new RegExp("^"+s,it(n)),t)}function lt(e,t,n){return Ze(t)||(n=t||n,t=[]),n=n||{},e instanceof RegExp?function(e,t){var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return st(e,t)}(e,t):Ze(e)?function(e,t,n){for(var r=[],a=0;a<e.length;a++)r.push(lt(e[a],t,n).source);return st(new RegExp("(?:"+r.join("|")+")",it(n)),t)}(e,t,n):function(e,t,n){return ot(et(e,n),t,n)}(e,t,n)}var ct,pt={exports:{}},ht={};var ut,dt,mt={};
|
|
1
|
+
import{constants as e,components as t,Widgets as n,Util as r,Log as a,PerseusError as s,Errors as i,Dependencies as o,PerseusMarkdown as l,preprocessTex as c,icons as p,WIDGET_PROP_BLACKLIST as h,ApiOptions as u,buildMapper as d,itemToTree as m,buildEmptyItemTreeForShape as g,shapes as f,itemDataVersion as v,ClassNames as y,MultiItems as b,traverse as E,Categorizer as w,Changeable as x,EditorJsonify as C,WidgetJsonifyDeprecated as k,Expression as S,interactiveSizes as N,KhanMath as T,GrapherWidget as _,GrapherUtil as O,SizingUtils as M,KhanColors as A,ColorPicker as P,DashPicker as D,ArrowPicker as I,ElementContainer as R,InteractiveGraphWidget as z,globalStyles as L,globalConstants as F,MatrixWidget as q,PlotterWidget as U,BaseRadio as W,TableWidget as V,TransformerWidget as j,displaySigFigs as B,widgets as $}from"@khanacademy/perseus";import*as H from"@khanacademy/perseus";export{H as Perseus};import*as G from"react";import Y,{Component as X}from"react";import K from"underscore";import J from"prop-types";import Z from"create-react-class";import Q from"jquery";import*as ee from"react-dom";import te from"react-dom";import{StyleSheet as ne,css as re}from"aphrodite";import ae from"classnames";import*as se from"@khanacademy/wonder-blocks-i18n";function ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function oe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ie(Object(n),!0).forEach((function(t){le(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ie(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function le(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(){return ce=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ce.apply(this,arguments)}function pe(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var he={phone:{width:320,height:480,framedWidth:320},tablet:{width:750,height:920,framedWidth:525},desktop:{width:688,height:600,framedWidth:688}};class ue extends G.Component{render(){var t=this.props.deviceType;if(this.props.nochrome)return G.createElement("div",null,G.createElement("div",{key:"screen",style:{width:he[t].framedWidth+2*e.perseusFrameBorderWidth+e.lintGutterWidth}},G.createElement("div",null,this.props.children)));var n=he[t].framedWidth/he[t].width,r={backgroundColor:"white",color:"black",textAlign:"left",width:he[t].width,height:he[t].height,border:"solid 1px #CCC",margin:8,zoom:n};return G.createElement("div",{key:"screen",className:"screen",style:r},this.props.children)}}le(ue,"propTypes",{children:J.element.isRequired,deviceType:J.oneOf([e.devices.PHONE,e.devices.TABLET,e.devices.DESKTOP]).isRequired,nochrome:J.bool});var de=Z({displayName:"JsonEditor",getInitialState:function(){return{currentValue:JSON.stringify(this.props.value,null,4),valid:!0}},UNSAFE_componentWillReceiveProps:function(e){(!this.state.valid||!K.isEqual(e.value,JSON.parse(this.state.currentValue)))&&this.setState(this.getInitialState())},render:function(){var e="perseus-json-editor "+(this.state.valid?"valid":"invalid");return G.createElement("textarea",{className:e,value:this.state.currentValue,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onBlur:this.handleBlur})},handleKeyDown:function(e){if("Tab"===e.key){var t=e.target.selectionStart,n=e.target.value,r=n.substring(0,t),a=n.substring(t,n.length);e.target.value=r+" "+a,e.target.selectionStart=r.length+4,e.target.selectionEnd=r.length+4,e.preventDefault(),this.handleChange(e)}},handleChange:function(e){var t=e.target.value;try{var n=JSON.parse(t);K.isString(n)&&(n=JSON.parse(n)),this.setState({currentValue:t,valid:!0},(function(){this.props.onChange(n)}))}catch(e){this.setState({currentValue:t,valid:!1})}},handleBlur:function(e){var t=e.target.value;try{var n=JSON.parse(t);K.isString(n)&&(n=JSON.parse(n)),this.setState({currentValue:JSON.stringify(n,null,4),valid:!0},(function(){this.props.onChange(n)}))}catch(e){this.setState({currentValue:JSON.stringify(this.props.value,null,4),valid:!0})}}}),me=Z({displayName:"DragTarget",propTypes:{onDrop:J.func.isRequired,component:J.any,shouldDragHighlight:J.func,style:J.any},getDefaultProps:function(){return{component:"div",shouldDragHighlight:()=>!0}},getInitialState:function(){return{dragHover:!1}},handleDrop:function(e){e.stopPropagation(),e.preventDefault(),this.setState({dragHover:!1}),this.props.onDrop(e)},handleDragEnd:function(){this.setState({dragHover:!1})},handleDragOver:function(e){e.preventDefault()},handleDragLeave:function(){this.setState({dragHover:!1})},handleDragEnter:function(e){this.setState({dragHover:this.props.shouldDragHighlight(e)})},render:function(){var e=this.state.dragHover?{opacity:.3}:{},t=this.props.component,n=Object.assign({},this.props);return delete n.component,delete n.shouldDragHighlight,G.createElement(t,ce({},n,{style:Object.assign({},this.props.style,e),onDrop:this.handleDrop,onDragEnd:this.handleDragEnd,onDragOver:this.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave}))}});class ge extends G.Component{constructor(){super(...arguments),le(this,"state",{showErrors:!1}),le(this,"handleToggleKatexErrors",(e=>{this.setState({showErrors:!this.state.showErrors})}))}render(){var{errorList:e}=this.props,{showErrors:t}=this.state,n=t?"icon-chevron-down":"icon-chevron-right";return G.createElement("div",{className:re(fe.errorContainer)},G.createElement("div",{className:re(fe.title),onClick:this.handleToggleKatexErrors},G.createElement("i",{className:n,style:{fontSize:14}})," KaTeX Errors (",e.length,")"),t&&G.createElement("div",{className:re(fe.errorExplanation)},"These errors will cause your LaTeX to load really slowly for the student. Please fix them if you can. If you can’t because KaTeX doesn’t support the feature you need, please message Cam."),t&&e.map(((e,t)=>G.createElement("div",{className:re(fe.error),key:t},G.createElement("div",{style:{color:"red"}},e.math),G.createElement("div",null,e.message)))))}}le(ge,"propTypes",{errorList:J.arrayOf(J.shape({math:J.string.isRequired,message:J.string.isRequired})).isRequired});var fe=ne.create({title:{backgroundColor:"#eee",fontSize:"1.25em",padding:"4px 10px"},errorContainer:{border:"1px solid #ddd",borderTop:"none"},errorExplanation:{padding:"4px 10px",backgroundColor:"pink"},error:{padding:"4px 10px"}});function ve(e,t){if(null==e)return{};var n,r,a={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}function ye(){return ye=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(this,arguments)}function be(e,t){return be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},be(e,t)}function Ee(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,be(e,t)}function we(e){return"/"===e.charAt(0)}function xe(e,t){for(var n=t,r=n+1,a=e.length;r<a;n+=1,r+=1)e[n]=e[r];e.pop()}var Ce="production"===process.env.NODE_ENV;function ke(e,t){if(!Ce){if(e)return;var n="Warning: "+t;"undefined"!=typeof console&&console.warn(n);try{throw Error(n)}catch(e){}}}var Se="production"===process.env.NODE_ENV,Ne="Invariant failed";function Te(e,t){if(!e){if(Se)throw new Error(Ne);var n="function"==typeof t?t():t;throw new Error(n?Ne+": "+n:Ne)}}function _e(e){return"/"===e.charAt(0)?e:"/"+e}function Oe(e){return"/"===e.charAt(0)?e.substr(1):e}function Me(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function Ae(e,t){return Me(e,t)?e.substr(t.length):e}function Pe(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function De(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function Ie(e,t,n,r){var a;"string"==typeof e?(a=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var s=t.indexOf("?");return-1!==s&&(n=t.substr(s),t=t.substr(0,s)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),a.state=t):(void 0===(a=ye({},e)).pathname&&(a.pathname=""),a.search?"?"!==a.search.charAt(0)&&(a.search="?"+a.search):a.search="",a.hash?"#"!==a.hash.charAt(0)&&(a.hash="#"+a.hash):a.hash="",void 0!==t&&void 0===a.state&&(a.state=t));try{a.pathname=decodeURI(a.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+a.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(a.key=n),r?a.pathname?"/"!==a.pathname.charAt(0)&&(a.pathname=function(e,t){void 0===t&&(t="");var n,r=e&&e.split("/")||[],a=t&&t.split("/")||[],s=e&&we(e),i=t&&we(t),o=s||i;if(e&&we(e)?a=r:r.length&&(a.pop(),a=a.concat(r)),!a.length)return"/";if(a.length){var l=a[a.length-1];n="."===l||".."===l||""===l}else n=!1;for(var c=0,p=a.length;p>=0;p--){var h=a[p];"."===h?xe(a,p):".."===h?(xe(a,p),c++):c&&(xe(a,p),c--)}if(!o)for(;c--;c)a.unshift("..");!o||""===a[0]||a[0]&&we(a[0])||a.unshift("");var u=a.join("/");return n&&"/"!==u.substr(-1)&&(u+="/"),u}(a.pathname,r.pathname)):a.pathname=r.pathname:a.pathname||(a.pathname="/"),a}function Re(){var e=null;var t=[];return{setPrompt:function(t){return"production"!==process.env.NODE_ENV&&ke(null==e,"A history supports only one prompt at a time"),e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var s="function"==typeof e?e(t,n):e;"string"==typeof s?"function"==typeof r?r(s,a):("production"!==process.env.NODE_ENV&&ke(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),a(!0)):a(!1!==s)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];t.forEach((function(e){return e.apply(void 0,n)}))}}}var ze=!("undefined"==typeof window||!window.document||!window.document.createElement);function Le(e,t){t(window.confirm(e))}function Fe(){try{return window.history.state||{}}catch(e){return{}}}function qe(e){void 0===e&&(e={}),ze||("production"!==process.env.NODE_ENV?Te(!1,"Browser history needs a DOM"):Te(!1));var t,n=window.history,r=(-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,a=!(-1===window.navigator.userAgent.indexOf("Trident")),s=e,i=s.forceRefresh,o=void 0!==i&&i,l=s.getUserConfirmation,c=void 0===l?Le:l,p=s.keyLength,h=void 0===p?6:p,u=e.basename?Pe(_e(e.basename)):"";function d(e){var t=e||{},n=t.key,r=t.state,a=window.location,s=a.pathname+a.search+a.hash;return"production"!==process.env.NODE_ENV&&ke(!u||Me(s,u),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+s+'" to begin with "'+u+'".'),u&&(s=Ae(s,u)),Ie(s,r,n)}function m(){return Math.random().toString(36).substr(2,h)}var g=Re();function f(e){ye(_,e),_.length=n.length,g.notifyListeners(_.location,_.action)}function v(e){(function(e){return void 0===e.state&&-1===navigator.userAgent.indexOf("CriOS")})(e)||E(d(e.state))}function y(){E(d(Fe()))}var b=!1;function E(e){if(b)b=!1,f();else{g.confirmTransitionTo(e,"POP",c,(function(t){t?f({action:"POP",location:e}):function(e){var t=_.location,n=x.indexOf(t.key);-1===n&&(n=0);var r=x.indexOf(e.key);-1===r&&(r=0);var a=n-r;a&&(b=!0,k(a))}(e)}))}}var w=d(Fe()),x=[w.key];function C(e){return u+De(e)}function k(e){n.go(e)}var S=0;function N(e){1===(S+=e)&&1===e?(window.addEventListener("popstate",v),a&&window.addEventListener("hashchange",y)):0===S&&(window.removeEventListener("popstate",v),a&&window.removeEventListener("hashchange",y))}var T=!1;var _={length:n.length,action:"POP",location:w,createHref:C,push:function(e,t){"production"!==process.env.NODE_ENV&&ke(!("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 a="PUSH",s=Ie(e,t,m(),_.location);g.confirmTransitionTo(s,a,c,(function(e){if(e){var t=C(s),i=s.key,l=s.state;if(r)if(n.pushState({key:i,state:l},null,t),o)window.location.href=t;else{var c=x.indexOf(_.location.key),p=x.slice(0,c+1);p.push(s.key),x=p,f({action:a,location:s})}else"production"!==process.env.NODE_ENV&&ke(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&&ke(!("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 a="REPLACE",s=Ie(e,t,m(),_.location);g.confirmTransitionTo(s,a,c,(function(e){if(e){var t=C(s),i=s.key,l=s.state;if(r)if(n.replaceState({key:i,state:l},null,t),o)window.location.replace(t);else{var c=x.indexOf(_.location.key);-1!==c&&(x[c]=s.key),f({action:a,location:s})}else"production"!==process.env.NODE_ENV&&ke(void 0===l,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(t)}}))},go:k,goBack:function(){k(-1)},goForward:function(){k(1)},block:function(e){void 0===e&&(e=!1);var t=g.setPrompt(e);return T||(N(1),T=!0),function(){return T&&(T=!1,N(-1)),t()}},listen:function(e){var t=g.appendListener(e);return N(1),function(){N(-1),t()}}};return _}var Ue={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+Oe(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:Oe,decodePath:_e},slash:{encodePath:_e,decodePath:_e}};function We(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function Ve(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function je(e){window.location.replace(We(window.location.href)+"#"+e)}function Be(e){void 0===e&&(e={}),ze||("production"!==process.env.NODE_ENV?Te(!1,"Hash history needs a DOM"):Te(!1));var t=window.history,n=-1===window.navigator.userAgent.indexOf("Firefox"),r=e,a=r.getUserConfirmation,s=void 0===a?Le:a,i=r.hashType,o=void 0===i?"slash":i,l=e.basename?Pe(_e(e.basename)):"",c=Ue[o],p=c.encodePath,h=c.decodePath;function u(){var e=h(Ve());return"production"!==process.env.NODE_ENV&&ke(!l||Me(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=Ae(e,l)),Ie(e)}var d=Re();function m(e){ye(N,e),N.length=t.length,d.notifyListeners(N.location,N.action)}var g=!1,f=null;function v(){var e=Ve(),t=p(e);if(e!==t)je(t);else{var n=u(),r=N.location;if(!g&&function(e,t){return e.pathname===t.pathname&&e.search===t.search&&e.hash===t.hash}(r,n))return;if(f===De(n))return;f=null,function(e){if(g)g=!1,m();else{var t="POP";d.confirmTransitionTo(e,t,s,(function(n){n?m({action:t,location:e}):function(e){var t=N.location,n=w.lastIndexOf(De(t));-1===n&&(n=0);var r=w.lastIndexOf(De(e));-1===r&&(r=0);var a=n-r;a&&(g=!0,x(a))}(e)}))}}(n)}}var y=Ve(),b=p(y);y!==b&&je(b);var E=u(),w=[De(E)];function x(e){"production"!==process.env.NODE_ENV&&ke(n,"Hash history go(n) causes a full page reload in this browser"),t.go(e)}var C=0;function k(e){1===(C+=e)&&1===e?window.addEventListener("hashchange",v):0===C&&window.removeEventListener("hashchange",v)}var S=!1;var N={length:t.length,action:"POP",location:E,createHref:function(e){var t=document.querySelector("base"),n="";return t&&t.getAttribute("href")&&(n=We(window.location.href)),n+"#"+p(l+De(e))},push:function(e,t){"production"!==process.env.NODE_ENV&&ke(void 0===t,"Hash history cannot push state; it is ignored");var n="PUSH",r=Ie(e,void 0,void 0,N.location);d.confirmTransitionTo(r,n,s,(function(e){if(e){var t=De(r),a=p(l+t);if(Ve()!==a){f=t,function(e){window.location.hash=e}(a);var s=w.lastIndexOf(De(N.location)),i=w.slice(0,s+1);i.push(t),w=i,m({action:n,location:r})}else"production"!==process.env.NODE_ENV&&ke(!1,"Hash history cannot PUSH the same path; a new entry will not be added to the history stack"),m()}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&ke(void 0===t,"Hash history cannot replace state; it is ignored");var n="REPLACE",r=Ie(e,void 0,void 0,N.location);d.confirmTransitionTo(r,n,s,(function(e){if(e){var t=De(r),a=p(l+t);Ve()!==a&&(f=t,je(a));var s=w.indexOf(De(N.location));-1!==s&&(w[s]=t),m({action:n,location:r})}}))},go:x,goBack:function(){x(-1)},goForward:function(){x(1)},block:function(e){void 0===e&&(e=!1);var t=d.setPrompt(e);return S||(k(1),S=!0),function(){return S&&(S=!1,k(-1)),t()}},listen:function(e){var t=d.appendListener(e);return k(1),function(){k(-1),t()}}};return N}function $e(e,t,n){return Math.min(Math.max(e,t),n)}function He(e){void 0===e&&(e={});var t=e,n=t.getUserConfirmation,r=t.initialEntries,a=void 0===r?["/"]:r,s=t.initialIndex,i=void 0===s?0:s,o=t.keyLength,l=void 0===o?6:o,c=Re();function p(e){ye(f,e),f.length=f.entries.length,c.notifyListeners(f.location,f.action)}function h(){return Math.random().toString(36).substr(2,l)}var u=$e(i,0,a.length-1),d=a.map((function(e){return Ie(e,void 0,"string"==typeof e?h():e.key||h())})),m=De;function g(e){var t=$e(f.index+e,0,f.entries.length-1),r=f.entries[t];c.confirmTransitionTo(r,"POP",n,(function(e){e?p({action:"POP",location:r,index:t}):p()}))}var f={length:d.length,action:"POP",location:d[u],index:u,entries:d,createHref:m,push:function(e,t){"production"!==process.env.NODE_ENV&&ke(!("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 r="PUSH",a=Ie(e,t,h(),f.location);c.confirmTransitionTo(a,r,n,(function(e){if(e){var t=f.index+1,n=f.entries.slice(0);n.length>t?n.splice(t,n.length-t,a):n.push(a),p({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&ke(!("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 r="REPLACE",a=Ie(e,t,h(),f.location);c.confirmTransitionTo(a,r,n,(function(e){e&&(f.entries[f.index]=a,p({action:r,location:a}))}))},go:g,goBack:function(){g(-1)},goForward:function(){g(1)},canGo:function(e){var t=f.index+e;return t>=0&&t<f.entries.length},block:function(e){return void 0===e&&(e=!1),c.setPrompt(e)},listen:function(e){return c.appendListener(e)}};return f}var Ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function Ye(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,r){e=n,t.forEach((function(t){return t(e,r)}))}}}var Xe=Y.createContext||function(e,t){var n,r,a="__create-react-context-"+function(){var e="__global_unique_id__";return Ge[e]=(Ge[e]||0)+1}()+"__",s=function(e){function n(){var t;return(t=e.apply(this,arguments)||this).emitter=Ye(t.props.value),t}Ee(n,e);var r=n.prototype;return r.getChildContext=function(){var e;return(e={})[a]=this.emitter,e},r.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var n,r=this.props.value,a=e.value;!function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(r,a)?(n="function"==typeof t?t(r,a):1073741823,"production"!==process.env.NODE_ENV&&ke((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)):n=0}},r.render=function(){return this.props.children},n}(X);s.childContextTypes=((n={})[a]=J.object.isRequired,n);var i=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}Ee(n,t);var r=n.prototype;return r.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?1073741823:t},r.componentDidMount=function(){this.context[a]&&this.context[a].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?1073741823:e},r.componentWillUnmount=function(){this.context[a]&&this.context[a].off(this.onUpdate)},r.getValue=function(){return this.context[a]?this.context[a].get():e},r.render=function(){return(e=this.props.children,Array.isArray(e)?e[0]:e)(this.state.value);var e},n}(X);return i.contextTypes=((r={})[a]=J.object,r),{Provider:s,Consumer:i}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Ke(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Je={exports:{}},Ze=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)};Je.exports=lt,Je.exports.parse=et,Je.exports.compile=function(e,t){return nt(et(e,t),t)},Je.exports.tokensToFunction=nt,Je.exports.tokensToRegExp=ot;var Qe=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function et(e,t){for(var n,r=[],a=0,s=0,i="",o=t&&t.delimiter||"/";null!=(n=Qe.exec(e));){var l=n[0],c=n[1],p=n.index;if(i+=e.slice(s,p),s=p+l.length,c)i+=c[1];else{var h=e[s],u=n[2],d=n[3],m=n[4],g=n[5],f=n[6],v=n[7];i&&(r.push(i),i="");var y=null!=u&&null!=h&&h!==u,b="+"===f||"*"===f,E="?"===f||"*"===f,w=n[2]||o,x=m||g;r.push({name:d||a++,prefix:u||"",delimiter:w,optional:E,repeat:b,partial:y,asterisk:!!v,pattern:x?at(x):v?".*":"[^"+rt(w)+"]+?"})}}return s<e.length&&(i+=e.substr(s)),i&&r.push(i),r}function tt(e){return encodeURI(e).replace(/[\/?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}function nt(e,t){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$",it(t)));return function(t,r){for(var a="",s=t||{},i=(r||{}).pretty?tt:encodeURIComponent,o=0;o<e.length;o++){var l=e[o];if("string"!=typeof l){var c,p=s[l.name];if(null==p){if(l.optional){l.partial&&(a+=l.prefix);continue}throw new TypeError('Expected "'+l.name+'" to be defined')}if(Ze(p)){if(!l.repeat)throw new TypeError('Expected "'+l.name+'" to not repeat, but received `'+JSON.stringify(p)+"`");if(0===p.length){if(l.optional)continue;throw new TypeError('Expected "'+l.name+'" to not be empty')}for(var h=0;h<p.length;h++){if(c=i(p[h]),!n[o].test(c))throw new TypeError('Expected all "'+l.name+'" to match "'+l.pattern+'", but received `'+JSON.stringify(c)+"`");a+=(0===h?l.prefix:l.delimiter)+c}}else{if(c=l.asterisk?encodeURI(p).replace(/[?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})):i(p),!n[o].test(c))throw new TypeError('Expected "'+l.name+'" to match "'+l.pattern+'", but received "'+c+'"');a+=l.prefix+c}}else a+=l}return a}}function rt(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function at(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function st(e,t){return e.keys=t,e}function it(e){return e&&e.sensitive?"":"i"}function ot(e,t,n){Ze(t)||(n=t||n,t=[]);for(var r=(n=n||{}).strict,a=!1!==n.end,s="",i=0;i<e.length;i++){var o=e[i];if("string"==typeof o)s+=rt(o);else{var l=rt(o.prefix),c="(?:"+o.pattern+")";t.push(o),o.repeat&&(c+="(?:"+l+c+")*"),s+=c=o.optional?o.partial?l+"("+c+")?":"(?:"+l+"("+c+"))?":l+"("+c+")"}}var p=rt(n.delimiter||"/"),h=s.slice(-p.length)===p;return r||(s=(h?s.slice(0,-p.length):s)+"(?:"+p+"(?=$))?"),s+=a?"$":r&&h?"":"(?="+p+"|$)",st(new RegExp("^"+s,it(n)),t)}function lt(e,t,n){return Ze(t)||(n=t||n,t=[]),n=n||{},e instanceof RegExp?function(e,t){var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return st(e,t)}(e,t):Ze(e)?function(e,t,n){for(var r=[],a=0;a<e.length;a++)r.push(lt(e[a],t,n).source);return st(new RegExp("(?:"+r.join("|")+")",it(n)),t)}(e,t,n):function(e,t,n){return ot(et(e,n),t,n)}(e,t,n)}var ct,pt={exports:{}},ht={};var ut,dt,mt={};
|
|
2
2
|
/** @license React v16.13.1
|
|
3
3
|
* react-is.development.js
|
|
4
4
|
*
|
|
@@ -6,6 +6,5 @@ import{constants as e,components as t,Widgets as n,Util as r,Log as a,PerseusErr
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/dt=pt,"production"===process.env.NODE_ENV?dt.exports=function(){if(ct)return ht;ct=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,s=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,o=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,f=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 r:case s:case a:case h:return e;default:switch(e=e&&e.$$typeof){case o:case p:case m:case d:case i:return e;default:return u}}case n:return u}}}function E(e){return b(e)===c}return ht.AsyncMode=l,ht.ConcurrentMode=c,ht.ContextConsumer=o,ht.ContextProvider=i,ht.Element=t,ht.ForwardRef=p,ht.Fragment=r,ht.Lazy=m,ht.Memo=d,ht.Portal=n,ht.Profiler=s,ht.StrictMode=a,ht.Suspense=h,ht.isAsyncMode=function(e){return E(e)||b(e)===l},ht.isConcurrentMode=E,ht.isContextConsumer=function(e){return b(e)===o},ht.isContextProvider=function(e){return b(e)===i},ht.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},ht.isForwardRef=function(e){return b(e)===p},ht.isFragment=function(e){return b(e)===r},ht.isLazy=function(e){return b(e)===m},ht.isMemo=function(e){return b(e)===d},ht.isPortal=function(e){return b(e)===n},ht.isProfiler=function(e){return b(e)===s},ht.isStrictMode=function(e){return b(e)===a},ht.isSuspense=function(e){return b(e)===h},ht.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===c||e===s||e===a||e===h||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===i||e.$$typeof===o||e.$$typeof===p||e.$$typeof===f||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},ht.typeOf=b,ht}():dt.exports=(ut||(ut=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,r=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,s=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,o=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,f=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 g=e.type;switch(g){case l:case c:case r:case s:case a:case h:return g;default:var f=g&&g.$$typeof;switch(f){case o:case p:case m:case d:case i:return f;default:return u}}case n:return u}}}var E=l,w=c,x=o,C=i,k=t,S=p,N=r,T=m,_=d,O=n,M=s,A=a,P=h,D=!1;function I(e){return b(e)===c}mt.AsyncMode=E,mt.ConcurrentMode=w,mt.ContextConsumer=x,mt.ContextProvider=C,mt.Element=k,mt.ForwardRef=S,mt.Fragment=N,mt.Lazy=T,mt.Memo=_,mt.Portal=O,mt.Profiler=M,mt.StrictMode=A,mt.Suspense=P,mt.isAsyncMode=function(e){return D||(D=!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.")),I(e)||b(e)===l},mt.isConcurrentMode=I,mt.isContextConsumer=function(e){return b(e)===o},mt.isContextProvider=function(e){return b(e)===i},mt.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},mt.isForwardRef=function(e){return b(e)===p},mt.isFragment=function(e){return b(e)===r},mt.isLazy=function(e){return b(e)===m},mt.isMemo=function(e){return b(e)===d},mt.isPortal=function(e){return b(e)===n},mt.isProfiler=function(e){return b(e)===s},mt.isStrictMode=function(e){return b(e)===a},mt.isSuspense=function(e){return b(e)===h},mt.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===c||e===s||e===a||e===h||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===i||e.$$typeof===o||e.$$typeof===p||e.$$typeof===f||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},mt.typeOf=b}()),mt);var gt=pt.exports,ft={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},vt={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},yt={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},bt={};function Et(e){return gt.isMemo(e)?yt:bt[e.$$typeof]||ft}bt[gt.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},bt[gt.Memo]=yt;var wt=Object.defineProperty,xt=Object.getOwnPropertyNames,Ct=Object.getOwnPropertySymbols,kt=Object.getOwnPropertyDescriptor,St=Object.getPrototypeOf,Nt=Object.prototype;var Tt=function e(t,n,r){if("string"!=typeof n){if(Nt){var a=St(n);a&&a!==Nt&&e(t,a,r)}var s=xt(n);Ct&&(s=s.concat(Ct(n)));for(var i=Et(t),o=Et(n),l=0;l<s.length;++l){var c=s[l];if(!(vt[c]||r&&r[c]||o&&o[c]||i&&i[c])){var p=kt(n,c);try{wt(t,c,p)}catch(e){}}}}return t},_t=function(e){var t=Ke();return t.displayName=e,t},Ot=_t("Router-History"),Mt=_t("Router"),At=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}Ee(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 Y.createElement(Mt.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},Y.createElement(Ot.Provider,{children:this.props.children||null,value:this.props.history}))},t}(Y.Component);"production"!==process.env.NODE_ENV&&(At.propTypes={children:J.node,history:J.object.isRequired,staticContext:J.object},At.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&ke(e.history===this.props.history,"You cannot change <Router history>")});var Pt=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).history=He(t.props),t}return Ee(t,e),t.prototype.render=function(){return Y.createElement(At,{history:this.history,children:this.props.children})},t}(Y.Component);if("production"!==process.env.NODE_ENV&&(Pt.propTypes={initialEntries:J.array,initialIndex:J.number,getUserConfirmation:J.func,keyLength:J.number,children:J.node},Pt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<MemoryRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { MemoryRouter as Router }`.")}),Y.Component,"production"!==process.env.NODE_ENV){var Dt=J.oneOfType([J.func,J.string]);J.bool,Dt.isRequired}"production"!==process.env.NODE_ENV&&(J.bool,J.string,J.oneOfType([J.string,J.object]).isRequired);var It={},Rt=0;function zt(e,t){void 0===t&&(t={}),("string"==typeof t||Array.isArray(t))&&(t={path:t});var n=t,r=n.path,a=n.exact,s=void 0!==a&&a,i=n.strict,o=void 0!==i&&i,l=n.sensitive,c=void 0!==l&&l;return[].concat(r).reduce((function(t,n){if(!n&&""!==n)return null;if(t)return t;var r=function(e,t){var n=""+t.end+t.strict+t.sensitive,r=It[n]||(It[n]={});if(r[e])return r[e];var a=[],s={regexp:Je.exports(e,a,t),keys:a};return Rt<1e4&&(r[e]=s,Rt++),s}(n,{end:s,strict:o,sensitive:c}),a=r.regexp,i=r.keys,l=a.exec(e);if(!l)return null;var p=l[0],h=l.slice(1),u=e===p;return s&&!u?null:{path:n,url:"/"===n&&""===p?"/":p,isExact:u,params:i.reduce((function(e,t,n){return e[t.name]=h[n],e}),{})}}),null)}function Lt(e){return 0===Y.Children.count(e)}function Ft(e,t,n){var r=e(t);return"production"!==process.env.NODE_ENV&&ke(void 0!==r,"You returned `undefined` from the `children` function of <Route"+(n?' path="'+n+'"':"")+">, but you should have returned a React element or `null`"),r||null}var qt=function(e){function t(){return e.apply(this,arguments)||this}return Ee(t,e),t.prototype.render=function(){var e=this;return Y.createElement(Mt.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <Route> outside a <Router>"):Te(!1));var n=e.props.location||t.location,r=ye({},t,{location:n,match:e.props.computedMatch?e.props.computedMatch:e.props.path?zt(n.pathname,e.props):t.match}),a=e.props,s=a.children,i=a.component,o=a.render;return Array.isArray(s)&&Lt(s)&&(s=null),Y.createElement(Mt.Provider,{value:r},r.match?s?"function"==typeof s?"production"!==process.env.NODE_ENV?Ft(s,r,e.props.path):s(r):s:i?Y.createElement(i,r):o?o(r):null:"function"==typeof s?"production"!==process.env.NODE_ENV?Ft(s,r,e.props.path):s(r):null)}))},t}(Y.Component);function Ut(e){return"/"===e.charAt(0)?e:"/"+e}function Wt(e,t){if(!e)return t;var n=Ut(e);return 0!==t.pathname.indexOf(n)?t:ye({},t,{pathname:t.pathname.substr(n.length)})}function Vt(e){return"string"==typeof e?e:De(e)}function jt(e){return function(){"production"!==process.env.NODE_ENV?Te(!1,"You cannot %s with <StaticRouter>"):Te(!1)}}function Bt(){}"production"!==process.env.NODE_ENV&&(qt.propTypes={children:J.oneOfType([J.func,J.node]),component:function(e,t){if(e[t]&&!pt.exports.isValidElementType(e[t]))return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component")},exact:J.bool,location:J.object,path:J.oneOfType([J.string,J.arrayOf(J.string)]),render:J.func,sensitive:J.bool,strict:J.bool},qt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!(this.props.children&&!Lt(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&&ke(!(this.props.children&&!Lt(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&&ke(!(this.props.component&&this.props.render),"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored")},qt.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&ke(!(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&&ke(!(!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 $t=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).handlePush=function(e){return t.navigateTo(e,"PUSH")},t.handleReplace=function(e){return t.navigateTo(e,"REPLACE")},t.handleListen=function(){return Bt},t.handleBlock=function(){return Bt},t}Ee(t,e);var n=t.prototype;return n.navigateTo=function(e,t){var n=this.props,r=n.basename,a=void 0===r?"":r,s=n.context,i=void 0===s?{}:s;i.action=t,i.location=function(e,t){return e?ye({},t,{pathname:Ut(e)+t.pathname}):t}(a,Ie(e)),i.url=Vt(i.location)},n.render=function(){var e=this.props,t=e.basename,n=void 0===t?"":t,r=e.context,a=void 0===r?{}:r,s=e.location,i=void 0===s?"/":s,o=ve(e,["basename","context","location"]),l={createHref:function(e){return Ut(n+Vt(e))},action:"POP",location:Wt(n,Ie(i)),push:this.handlePush,replace:this.handleReplace,go:jt(),goBack:jt(),goForward:jt(),listen:this.handleListen,block:this.handleBlock};return Y.createElement(At,ye({},o,{history:l,staticContext:a}))},t}(Y.Component);"production"!==process.env.NODE_ENV&&($t.propTypes={basename:J.string,context:J.object,location:J.oneOfType([J.string,J.object])},$t.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<StaticRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { StaticRouter as Router }`.")});var Ht=function(e){function t(){return e.apply(this,arguments)||this}return Ee(t,e),t.prototype.render=function(){var e=this;return Y.createElement(Mt.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <Switch> outside a <Router>"):Te(!1));var n,r,a=e.props.location||t.location;return Y.Children.forEach(e.props.children,(function(e){if(null==r&&Y.isValidElement(e)){n=e;var s=e.props.path||e.props.from;r=s?zt(a.pathname,ye({},e.props,{path:s})):t.match}})),r?Y.cloneElement(n,{location:a,computedMatch:r}):null}))},t}(Y.Component);if("production"!==process.env.NODE_ENV&&(Ht.propTypes={children:J.node,location:J.object},Ht.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&ke(!(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&&ke(!(!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.')}),Y.useContext,"production"!==process.env.NODE_ENV&&"undefined"!=typeof window){var Gt=window,Yt="__react_router_build__",Kt={cjs:"CommonJS",esm:"ES modules",umd:"UMD"};if(Gt[Yt]&&"esm"!==Gt[Yt]){var Xt=Kt[Gt[Yt]];throw new Error("You are loading the "+Kt.esm+" build of React Router on a page that is already running the "+Xt+" build, so things won't work right.")}Gt[Yt]="esm"}var Jt=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).history=qe(t.props),t}return Ee(t,e),t.prototype.render=function(){return Y.createElement(At,{history:this.history,children:this.props.children})},t}(Y.Component);"production"!==process.env.NODE_ENV&&(Jt.propTypes={basename:J.string,children:J.node,forceRefresh:J.bool,getUserConfirmation:J.func,keyLength:J.number},Jt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<BrowserRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { BrowserRouter as Router }`.")});var Zt=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).history=Be(t.props),t}return Ee(t,e),t.prototype.render=function(){return Y.createElement(At,{history:this.history,children:this.props.children})},t}(Y.Component);"production"!==process.env.NODE_ENV&&(Zt.propTypes={basename:J.string,children:J.node,getUserConfirmation:J.func,hashType:J.oneOf(["hashbang","noslash","slash"])},Zt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<HashRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { HashRouter as Router }`.")});var Qt=function(e,t){return"function"==typeof e?e(t):e},en=function(e,t){return"string"==typeof e?Ie(e,null,null,t):e},tn=function(e){return e},nn=Y.forwardRef;void 0===nn&&(nn=tn);var rn=nn((function(e,t){var n=e.innerRef,r=e.navigate,a=e.onClick,s=ve(e,["innerRef","navigate","onClick"]),i=s.target,o=ye({},s,{onClick:function(e){try{a&&a(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||i&&"_self"!==i||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),r())}});return o.ref=tn!==nn&&t||n,Y.createElement("a",o)}));"production"!==process.env.NODE_ENV&&(rn.displayName="LinkAnchor");var an=nn((function(e,t){var n=e.component,r=void 0===n?rn:n,a=e.replace,s=e.to,i=e.innerRef,o=ve(e,["component","replace","to","innerRef"]);return Y.createElement(Mt.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <Link> outside a <Router>"):Te(!1));var n=e.history,l=en(Qt(s,e.location),e.location),c=l?n.createHref(l):"",p=ye({},o,{href:c,navigate:function(){var t=Qt(s,e.location),r=De(e.location)===De(en(t));(a||r?n.replace:n.push)(t)}});return tn!==nn?p.ref=t||i:p.innerRef=i,Y.createElement(r,p)}))}));if("production"!==process.env.NODE_ENV){var sn=J.oneOfType([J.string,J.object,J.func]),on=J.oneOfType([J.string,J.func,J.shape({current:J.any})]);an.displayName="Link",an.propTypes={innerRef:on,onClick:J.func,replace:J.bool,target:J.string,to:sn.isRequired}}var ln=function(e){return e},cn=Y.forwardRef;void 0===cn&&(cn=ln);var pn=cn((function(e,t){var n=e["aria-current"],r=void 0===n?"page":n,a=e.activeClassName,s=void 0===a?"active":a,i=e.activeStyle,o=e.className,l=e.exact,c=e.isActive,p=e.location,h=e.sensitive,u=e.strict,d=e.style,m=e.to,g=e.innerRef,f=ve(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return Y.createElement(Mt.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <NavLink> outside a <Router>"):Te(!1));var n=p||e.location,a=en(Qt(m,n),n),v=a.pathname,y=v&&v.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),b=y?zt(n.pathname,{path:y,exact:l,sensitive:h,strict:u}):null,E=!!(c?c(b,n):b),w="function"==typeof o?o(E):o,x="function"==typeof d?d(E):d;E&&(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,s),x=ye({},x,i));var C=ye({"aria-current":E&&r||null,className:w,style:x,to:a},f);return ln!==cn?C.ref=t||g:C.innerRef=g,Y.createElement(an,C)}))}));if("production"!==process.env.NODE_ENV){pn.displayName="NavLink";var hn=J.oneOf(["page","step","location","date","time","true","false"]);pn.propTypes=ye({},an.propTypes,{"aria-current":hn,activeClassName:J.string,activeStyle:J.object,className:J.oneOfType([J.string,J.func]),exact:J.bool,isActive:J.func,location:J.object,sensitive:J.bool,strict:J.bool,style:J.oneOfType([J.object,J.func])})}function un(e){const t=[];if(!e)return t;if(Array.isArray(e))for(const n of e)t.push.apply(t,un(n));else t.push(e);return t}function dn(e){const t=[],n=[];if(!e)return{style:{},className:""};const r="undefined"!=typeof global&&global.SNAPSHOT_INLINE_APHRODITE;un(e).forEach((e=>{const a=e._definition;if(null!=a)if(r){const e={};for(const[t,n]of Object.entries(a))e[t.replace(/-[a-z]/g,(e=>e[1].toUpperCase()))]=n;n.push(e)}else t.push(e);else n.push(e)}));const a=Object.assign.apply(Object,[{}].concat(n));if(n.length>0&&!r){const e=ne.create({inlineStyles:a});t.push(e.inlineStyles)}return{style:r?a:{},className:re.apply(void 0,t)}}const mn=["children","style","tag","testId"],gn=/^h[1-6]$/,fn=ne.create({text:{WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"},header:{marginTop:0,marginBottom:0}});class vn extends G.Component{render(){const e=this.props,{children:t,style:n,tag:r,testId:a}=e,s=ve(e,mn),i=gn.test(r),o=dn([fn.text,i&&fn.header,n]);return G.createElement(r,ye({},s,{style:o.style,className:o.className,"data-test-id":a}),t)}}vn.defaultProps={tag:"span"};const yn=["className","style"];function bn(e,t){return function(n){const{className:r,style:a}=n,s=ve(n,yn),i="string"==typeof e?En[e]:null,{className:o,style:l}=dn([i,t,a]);return G.createElement(e,ye({},s,{className:[o,r].filter(Boolean).join(" "),style:l}))}}const En=ne.create({button:{margin:0,"::-moz-focus-inner":{border:0}}}),wn=["testId","tag"],xn=ne.create({default:{alignItems:"stretch",borderWidth:0,borderStyle:"solid",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:0,padding:0,position:"relative",zIndex:0,minHeight:0,minWidth:0}}),Cn=bn("div",xn.default),kn=bn("article",xn.default),Sn=bn("aside",xn.default),Nn=bn("nav",xn.default),Tn=bn("section",xn.default);class _n extends G.Component{render(){const e=this.props,{testId:t,tag:n}=e,r=ye({},ve(e,wn),{"data-test-id":t});switch(n){case"article":return G.createElement(kn,r);case"aside":return G.createElement(Sn,r);case"nav":return G.createElement(Nn,r);case"section":return G.createElement(Tn,r);case"div":return G.createElement(Cn,r);default:throw Error(`${n} is not an allowed value for the 'tag' prop`)}}}_n.defaultProps={tag:"div"};const On=require("flow-enums-runtime")({Root:"root",Initial:"initial",Standard:"standard"}),Mn=G.createContext(On.Root);class An extends G.Component{constructor(...e){super(...e),this.state={mounted:!1},this._isTheRootComponent=!1}componentDidMount(){this._isTheRootComponent&&this.setState({mounted:!0})}_renderAsRootComponent(){const{mounted:e}=this.state,{children:t,placeholder:n}=this.props;return this._isTheRootComponent=!0,e?G.createElement(Mn.Provider,{value:On.Standard},t()):n?G.createElement(Mn.Provider,{value:On.Initial},n()):null}_maybeRender(e){const{children:t,placeholder:n}=this.props;switch(e){case On.Root:return this._renderAsRootComponent();case On.Initial:return n?n():null;case On.Standard:return t()}return console.log(`We got a render state we don't understand: "${JSON.stringify(e)}"`),this._maybeRender(On.Root)}render(){return G.createElement(Mn.Consumer,null,(e=>this._maybeRender(e)))}}class Pn{constructor(e){this.get=e=>{const t=e.toLowerCase();if(!this._hasValidIdChars(e))throw new Error(`Invalid identifier key: ${e}`);return`${this._uniqueFactoryName}-${t}`};const t=(e="string"==typeof e?e:"").toLowerCase();if(!this._hasValidIdChars(t))throw new Error(`Invalid factory scope: ${e}`);this._uniqueFactoryName=`uid-${t}-${Pn._factoryUniquenessCounter++}`}_hasValidIdChars(e){if("string"!=typeof e)return!1;const t=e.replace(/[^\d\w-]/g,"-");return e===t}}Pn._factoryUniquenessCounter=0;class Dn{get(e){return e}}Dn.Default=new Dn;var In=Dn.Default;class Rn extends G.Component{_performRender(e){const{children:t,mockOnFirstRender:n,scope:r}=this.props;return e?n?t(In):null:(this._idFactory||(this._idFactory=new Pn(r)),t(this._idFactory))}render(){return G.createElement(An,{placeholder:()=>this._performRender(!0)},(()=>this._performRender(!1)))}}class zn extends G.Component{renderChildren(e){const{id:t,children:n}=this.props,r=e?e.get(zn.defaultId):t;if(!r)throw new Error("Did not get an identifier factory nor a id prop");return n(r)}render(){const{id:e,scope:t}=this.props;return e?this.renderChildren():G.createElement(Rn,{scope:t,mockOnFirstRender:!0},(e=>this.renderChildren(e)))}}zn.defaultId="wb-id";const Ln=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,Fn=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i,qn=/^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)$/i,Un=e=>{if("string"!=typeof e)throw new Error(`Failed to parse color: ${e}`);const t=e.match(Fn);if(t)return{r:parseInt(`${t[1]}${t[1]}`,16),g:parseInt(`${t[2]}${t[2]}`,16),b:parseInt(`${t[3]}${t[3]}`,16),a:1};const n=e.match(Ln);if(n)return{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16),a:1};const r=e.match(qn);if(r)return{r:parseFloat(r[1]),g:parseFloat(r[2]),b:parseFloat(r[3]),a:r[4]?parseFloat(r[4]):1};throw new Error(`Failed to parse color: ${e}`)},Wn=e=>{const t=Math.round(e.r),n=Math.round(e.g),r=Math.round(e.b);if(1===e.a){const e=e=>{const t=e.toString(16);return 1===t.length?t+t:t};return`#${e(t)}${e(n)}${e(r)}`}return`rgba(${t},${n},${r},${e.a.toFixed(2)})`},Vn=(e,t)=>{if(t<0||t>1)throw new Error("Percentage must be between 0 and 1");const n=Un(e);return Wn(ye({},n,{a:n.a*t}))},jn=(e,t)=>{const n=Un(e),r=Un(t);return Wn({r:n.r*n.a+r.r*(1-n.a),g:n.g*n.a+r.g*(1-n.a),b:n.b*n.a+r.b*(1-n.a),a:r.a})},Bn={blue:"#1865f2",purple:"#9059ff",green:"#00a60e",gold:"#ffb100",red:"#d92916",offBlack:"#21242c",offBlack64:Vn("#21242c",.64),offBlack50:Vn("#21242c",.5),offBlack32:Vn("#21242c",.32),offBlack16:Vn("#21242c",.16),offBlack8:Vn("#21242c",.08),offWhite:"#f7f8fa",white:"#ffffff",white64:Vn("#ffffff",.64),white50:Vn("#ffffff",.5),darkBlue:"#0a2a66",teal:"#14bf96",lightBlue:"#37c5fd",pink:"#fa50ae"},$n={controlDefault:Bn.blue,controlDestructive:Bn.red},Hn=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}}},Gn={onClick:()=>{},onMouseEnter:()=>{},onMouseLeave:()=>{},onMouseDown:()=>{},onMouseUp:()=>{},onDragStart:()=>{},onTouchStart:()=>{},onTouchEnd:()=>{},onTouchCancel:()=>{},onKeyDown:()=>{},onKeyUp:()=>{},tabIndex:0},Yn=13,Kn=32,Xn={hovered:!1,focused:!1,pressed:!1,waiting:!1};class Jn extends G.Component{static getDerivedStateFromProps(e,t){return e.disabled?ye({},Xn,{focused:t.focused}):null}constructor(e){super(e),this.handleClick=e=>{const{onClick:t,beforeNav:n,safeWithNav:r}=this.props;this.enterClick||((t||n||r)&&(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 r=e.which||e.keyCode,{triggerOnEnter:a,triggerOnSpace:s}=Hn(n);a&&r===Yn||s&&r===Kn?(e.preventDefault(),this.setState({pressed:!0})):a||r!==Yn||(this.enterClick=!0)},this.handleKeyUp=e=>{const{onKeyUp:t,role:n}=this.props;t&&t(e);const r=e.which||e.keyCode,{triggerOnEnter:a,triggerOnSpace:s}=Hn(n);a&&r===Yn||s&&r===Kn?(this.setState({pressed:!1,focused:!0}),this.runCallbackAndMaybeNavigate(e)):a||r!==Yn||(this.enterClick=!1)},this.handleFocus=e=>{this.setState({focused:!0})},this.handleBlur=e=>{this.setState({focused:!1,pressed:!1})},this.state=Xn,this.waitingForClick=!1,this.enterClick=!1,this.dragging=!1}navigateOrReset(e){if(e){const{history:e,href:t,skipClientNav:n,target:r}=this.props;t&&("_blank"===r?(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:r}=this.props;return r&&!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:r,href:a,type:s}=this.props;let i=!0,o=!0;if(t&&t(e),e.defaultPrevented&&(i=!1,o=!1),e.preventDefault(),!a&&"submit"===s&&o){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((()=>r?this.handleSafeWithNav(r,i):this.navigateOrReset(i))).catch((()=>{}));else{if(r)return this.handleSafeWithNav(r,i);this.navigateOrReset(i)}}render(){const e=this.props.disabled?ye({},Gn,{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)}}Jn.defaultProps={disabled:!1};const Zn=e=>"string"==typeof e&&(!/^(https?:)?\/\//i.test(e)&&!/^([^#]*#[\w-]*|[\w\-.]+:)/.test(e)),Qn=function(e){var t="withRouter("+(e.displayName||e.name)+")",n=function(n){var r=n.wrappedComponentRef,a=ve(n,["wrappedComponentRef"]);return Y.createElement(Mt.Consumer,null,(function(n){return n||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <"+t+" /> outside a <Router>"):Te(!1)),Y.createElement(e,ye({},a,n,{ref:r}))}))};return n.displayName=t,n.WrappedComponent=e,"production"!==process.env.NODE_ENV&&(n.propTypes={wrappedComponentRef:J.oneOfType([J.string,J.func,J.object])}),Tt(n,e)}(Jn);function er(e,t,n){return n&&!0!==t&&e&&Zn(e)?Qn:Jn}const tr=["href","onClick","skipClientNav","beforeNav","safeWithNav","style","target","testId","onKeyDown","onKeyUp","hideDefaultFocusRing","light","disabled"],nr=bn("a"),rr=bn("button"),ar=bn(an);class sr extends G.Component{constructor(...e){super(...e),this.getCorrectTag=(e,t,n)=>{const r=this.props.href&&!this.props.disabled,a=t&&!this.props.skipClientNav&&Zn(this.props.href||"");return r&&a&&this.props.href?G.createElement(ar,ye({},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)):r&&!a?G.createElement(nr,ye({},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)):G.createElement(rr,ye({},n,{type:"button","aria-disabled":this.props.disabled}),this.props.children(e))}}renderClickableBehavior(e){const t=this.props,{href:n,onClick:r,skipClientNav:a,beforeNav:s,safeWithNav:i,style:o,target:l,testId:c,onKeyDown:p,onKeyUp:h,hideDefaultFocusRing:u,light:d,disabled:m}=t,g=ve(t,tr),f=er(n,a,e),v=e=>[ir.reset,ir.link,!u&&e.focused&&(d?ir.focusedLight:ir.focused),o];return s?G.createElement(f,{href:n,onClick:r,beforeNav:s,safeWithNav:i,onKeyDown:p,onKeyUp:h,disabled:m},((t,n)=>this.getCorrectTag(t,e,ye({},g,{"data-test-id":c,style:v(t)},n)))):G.createElement(f,{href:n,onClick:r,safeWithNav:i,onKeyDown:p,onKeyUp:h,target:l,disabled:m},((t,n)=>this.getCorrectTag(t,e,ye({},g,{"data-test-id":c,style:v(t)},n))))}render(){return G.createElement(Mt.Consumer,null,(e=>this.renderClickableBehavior(e)))}}sr.defaultProps={light:!1,disabled:!1,"aria-label":""};const ir=ne.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 ${Bn.blue}`},focusedLight:{outline:`solid 2px ${Bn.white}`}});var{InlineIcon:or}=t;class lr extends G.Component{render(){var{icon:e,onClick:t,title:n}=this.props;return G.createElement(sr,{className:"section-control-button simple-button simple-button--small ",onClick:e=>{e.preventDefault(),t()},role:"button",hideDefaultFocusRing:!0,"aria-label":n,style:cr.button},(t=>G.createElement(or,e)))}}var cr=ne.create({button:{backgroundColor:Bn.gold,margin:2,paddingRight:10,paddingLeft:10,paddingBottom:2}}),{InlineIcon:pr,PropCheckBox:hr}=t,{iconChevronDown:ur,iconChevronRight:dr,iconTrash:mr}=p,gr=new RegExp("(\\[\\[☃ {id}\\]\\])".replace("{id}","[a-z-]+ [0-9]+"),"g"),fr=/^\[\[([a-z-]+)$/,vr=/(?:\n{2,}|^\n*)$/,yr=/(\n*)$/,br=/^(\n*)/,Er=e=>{var t=e.toString();return t.length>=5&&(t=t.replace(/(\d)(?=(\d{3})+$)/g,"$1{,}")),t};class wr extends G.Component{constructor(){super(...arguments),le(this,"handleChange",(e=>{var t=e.currentTarget.value;""!==t&&this.props.onChange&&this.props.onChange(t)}))}shouldComponentUpdate(){return!1}render(){var e=n.getPublicWidgets(),t=X.sortBy(X.keys(e),(t=>e[t].displayName));return G.createElement("select",{value:"",onChange:this.handleChange},G.createElement("option",{value:""},"Add a widget…"),G.createElement("option",{disabled:!0},"--"),X.map(t,(t=>G.createElement("option",{key:t,value:t},e[t].displayName))))}}var xr=e=>{var t=X.omit(e,h);return n.upgradeWidgetInfoToLatestVersion(t)};class Cr extends G.Component{constructor(e){super(e),le(this,"_toggleWidget",(e=>{e.preventDefault(),this.setState({showWidget:!this.state.showWidget})})),le(this,"_handleWidgetChange",((e,t,n)=>{var r=Object.assign({},this.state.widgetInfo);r.options=Object.assign(this.refs.widget.serialize(),e),this.props.onChange(r,t,n)})),le(this,"_toggleStatic",(e=>{e.preventDefault();var t=Object.assign({},this.state.widgetInfo,{static:!this.state.widgetInfo.static});this.props.onChange(t)})),le(this,"_handleAlignmentChange",(e=>{var t=e.currentTarget.value,n=Object.assign({},this.state.widgetInfo);n.alignment=t,this.props.onChange(n)})),le(this,"getSaveWarnings",(()=>{var e=this.refs.widget.getSaveWarnings;return e?e():[]})),le(this,"serialize",(()=>{var e=this.state.widgetInfo;return{type:e.type,alignment:e.alignment,static:e.static,graded:e.graded,options:this.refs.widget.serialize(),version:e.version}})),this.state={showWidget:!1,widgetInfo:xr(e)}}UNSAFE_componentWillReceiveProps(e){this.setState({widgetInfo:xr(e)})}render(){var e,t=this.state.widgetInfo,r=n.getEditor(t.type);e=this.props.apiOptions.showAlignmentOptions?n.getSupportedAlignments(t.type):["default"];var a=n.supportsStaticMode(t.type),s="transformer"===t.type,i=G.createElement(hr,{label:"Graded:",graded:t.graded,onChange:this.props.onChange});return G.createElement("div",{className:"perseus-widget-editor"},G.createElement("div",{className:"perseus-widget-editor-title "+(this.state.showWidget?"open":"closed")},G.createElement("a",{className:"perseus-widget-editor-title-id",href:"#",onClick:this._toggleWidget},this.props.id,this.state.showWidget?G.createElement(pr,ur):G.createElement(pr,dr)),a&&G.createElement("input",{type:"button",onClick:this._toggleStatic,className:"simple-button--small",value:t.static?"Unset as static":"Set as static"}),e.length>1&&G.createElement("select",{className:"alignment",value:t.alignment,onChange:this._handleAlignmentChange},e.map((e=>G.createElement("option",{key:e},e)))),G.createElement(lr,{icon:mr,onClick:()=>{this.props.onRemove()},title:"Remove image widget"})),G.createElement("div",{className:"perseus-widget-editor-content "+(this.state.showWidget?"enter":"leave")},s&&i,r&&G.createElement(r,ce({ref:"widget",onChange:this._handleWidgetChange,static:t.static,apiOptions:this.props.apiOptions},t.options))))}}var kr=/!\[[^\]]*\]\(([^\s)]+)[^)]*\)/g;class Sr extends G.Component{constructor(){super(...arguments),le(this,"lastUserValue",void 0),le(this,"deferredChange",void 0),le(this,"widgetIds",void 0),le(this,"state",{katex:void 0,showKatexErrors:!1,textAreaValue:this.props.content}),le(this,"getWidgetEditor",((e,t)=>{if(n.getEditor(t))return G.createElement(Cr,ce({key:e,ref:e,id:e,type:t,onChange:this._handleWidgetEditorChange.bind(this,e),onRemove:this._handleWidgetEditorRemove.bind(this,e),apiOptions:this.props.apiOptions},this.props.widgets[e]))})),le(this,"_handleWidgetEditorChange",((e,t,n,r)=>{var a=Object.assign({},this.props.widgets);a[e]=Object.assign({},a[e],t),this.props.onChange({widgets:a},n,r)})),le(this,"_handleWidgetEditorRemove",(e=>{var t=this.refs.textarea,n=new RegExp("(\\[\\[☃ {id}\\]\\])".replace("{id}",e),"gm");this.props.onChange({content:t.value.replace(n,"")})})),le(this,"_sizeImages",(e=>{var t,n=(t=e.content,X.map(function(e,t){for(var n=[];;){var r=e.exec(t);if(!r)break;n.push(r)}return n}(kr,t),(e=>e[1]))),a=X.pick(e.images,n),s=X.filter(n,(e=>!a[e]));X.each(s,(t=>{r.getImageSize(t,((n,r)=>{a[t]={width:n,height:r},e.onChange({images:X.clone(a)},null,!0)}))}))})),le(this,"handleDrop",(e=>{var{imageUploader:t}=this.props,n=this.state.textAreaValue||"",r=e.dataTransfer;if(r&&t){var a=r.files;if(0!==a.length){var s=this.state.textAreaValue;X(a).chain().map((function(e){if(!e.type.match("image.*"))return null;var t="☃ "+X.uniqueId("image_");return n+="\n\n",{file:e,sentinel:t}})).reject(X.isNull).tap((()=>{this.lastUserValue=s,this.props.onChange({content:n})})).each((e=>{t(e.file,(t=>{this.lastUserValue=s,this.props.onChange({content:this.state.textAreaValue.replace(e.sentinel,t)})}))}))}else{var i=r.getData("URL");if(i){var o=n+"\n\n";this.lastUserValue=this.props.content,this.props.onChange({content:o})}}}})),le(this,"handleChange",(e=>{clearTimeout(this.deferredChange),this.setState({textAreaValue:e.currentTarget.value}),this.deferredChange=setTimeout((()=>{this.state.textAreaValue!==this.props.content&&this.props.onChange({content:this.state.textAreaValue})}),this.props.apiOptions.editorChangeDelay)})),le(this,"_handleKeyDown",(e=>{if("Tab"===e.key){var t=ee.findDOMNode(this.refs.textarea),a=r.textarea.getWordBeforeCursor(t),s=a.string.toLowerCase().match(fr);if(null!=s){var i=s[1],o=n.getAllWidgetTypes(),l=X.filter(o,(e=>e.substring(0,i.length)===i));if(1===l.length){var c=l[0];this._addWidgetToContent(this.props.content,[a.pos.start,a.pos.end+1],c)}e.preventDefault()}}})),le(this,"_maybeCopyWidgets",(e=>{var t=e.currentTarget,n=t.value.substring(t.selectionStart,t.selectionEnd),s=X.map(n.match(gr),(e=>r.rWidgetParts.exec(e)[1])),i=X.pick(this.serialize().widgets,s);localStorage.perseusLastCopiedText=n,localStorage.perseusLastCopiedWidgets=JSON.stringify(i),a.log("Widgets copied: ".concat(localStorage.perseusLastCopiedWidgets))})),le(this,"_maybePasteWidgets",(e=>{var t=localStorage.perseusLastCopiedWidgets,n=localStorage.perseusLastCopiedText,a=e.originalEvent.clipboardData.getData("text");if(t&&n===a){e.preventDefault();var s=JSON.parse(t),i=this._safeWidgetNameMapping(s),o={};for(var[l,c]of Object.entries(s))o[i[l]]=c;var p=X.extend(o,this.props.widgets),h=n.replace(gr,(e=>{var t=r.rWidgetParts.exec(e),n=t[0],a=t[1];return n.replace(a,i[a])})),u=e.currentTarget,d=u.selectionStart,m=this.state.textAreaValue.substr(0,d)+h+this.state.textAreaValue.substr(u.selectionEnd);this.lastUserValue=this.state.textAreaValue,this.props.onChange({content:m,widgets:p},(()=>{var e=d+h.length;r.textarea.moveCursor(u,e)}))}})),le(this,"_safeWidgetNameMapping",(e=>{var t=X.keys(e).map((e=>e.split(" "))),n=X.uniq(t.map((e=>e[0]))),r=X.keys(this.props.widgets).map((e=>e.split(" "))),a={};X.each(n,(e=>{a[e]=X.chain(r).filter((t=>t[0]===e)).map((e=>+e[1]+1)).max().value(),a[e]=Math.max(a[e],1)}));var s={};return X.each(t,(e=>{var t=e.join(" "),n=e[0];s[t]="".concat(n," ").concat(a[n]),a[n]++})),s})),le(this,"_addWidgetToContent",((e,t,a)=>{var s,i=ee.findDOMNode(this.refs.textarea),o=X.map(e.match(gr),(e=>{var t=r.rWidgetParts.exec(e);return[t[2],+t[3]]})),l=X.reduce(o,((e,t)=>{var[n,r]=t;return n===a?Math.max(r+1,e):e}),1),c=a+" "+l,p="[[☃ {id}]]".replace("{id}",c),h="block"===n.getDefaultAlignment(a),u=e.slice(0,t[0]),d=e.slice(t[1]),m=(h?(e=>{if(!vr.test(e)){var t=yr.exec(e);if(t){var n=t[1];return e+"\n\n".slice(0,2-n.length)}}return e})(u):u)+p+(h?(e=>{var t=br.exec(e);if(!t)return e;var n=t[1];return"\n\n".slice(0,2-n.length)+e})(d):d),g=X.clone(this.props.widgets);g[c]={options:null===(s=n.getEditor(a))||void 0===s?void 0:s.defaultProps,type:a,version:n.getVersion(a)},this.lastUserValue=this.props.content,this.props.onChange({content:m,widgets:g},(function(){r.textarea.moveCursor(i,m.length-d.length)}))})),le(this,"_addWidget",(e=>{var t=this.refs.textarea;this._addWidgetToContent(this.props.content,[t.selectionStart,t.selectionEnd],e),t.focus()})),le(this,"addTemplate",(e=>{var t=e.currentTarget.value;if(""!==t){e.currentTarget.value="";var a,o=this.props.content;if(o=o.replace(/\n*$/,"\n\n"),"table"===t)a="header 1 | header 2 | header 3\n- | - | -\ndata 1 | data 2 | data 3\ndata 4 | data 5 | data 6\ndata 7 | data 8 | data 9";else if("titledTable"===t)a="|| **Table title** ||\nheader 1 | header 2 | header 3\n- | - | -\ndata 1 | data 2 | data 3\ndata 4 | data 5 | data 6\ndata 7 | data 8 | data 9";else if("alignment"===t)a="$\\begin{align} x+5 &= 30 \\\\\nx+5-5 &= 30-5 \\\\\nx &= 25 \\end{align}$";else if("piecewise"===t)a="$f(x) = \\begin{cases}\n7 & \\text{if }x=1 \\\\\nf(x-1)+5 & \\text{if }x > 1\n\\end{cases}$";else{if("allWidgets"!==t)throw new s("Invalid template type: "+t,i.InvalidInput,{metadata:{templateType:t}});a=n.getAllWidgetTypes().map((e=>"[[".concat(r.snowman," ").concat(e," 1]]"))).join("\n\n")}var l=o+a;this.lastUserValue=this.props.content,this.props.onChange({content:l},this.focusAndMoveToEnd)}})),le(this,"getSaveWarnings",(()=>{var e=X.intersection(this.widgetIds,X.keys(this.refs));return X(e).chain().map((e=>{var t=this.refs[e].getSaveWarnings,n=t?t():[];return X.map(n,(t=>e+": "+t))})).flatten(!0).value()})),le(this,"focus",(()=>{var e=ee.findDOMNode(this.refs.textarea);e&&e.focus()})),le(this,"focusAndMoveToEnd",(()=>{this.focus();var e=ee.findDOMNode(this.refs.textarea);e&&(e.selectionStart=e.value.length,e.selectionEnd=e.value.length)})),le(this,"serialize",(e=>{var t={},n=X.intersection(this.widgetIds,X.keys(this.refs));return X.each(n,(e=>{t[e]=this.refs[e].serialize()})),e&&e.keepDeletedWidgets&&X.chain(this.props.widgets).keys().reject((e=>X.contains(n,e))).each((e=>{t[e]=this.props.widgets[e]})),{replace:this.props.replace,content:this.props.content,images:this.props.images,widgets:t}}))}componentDidMount(){this.lastUserValue=null,this._sizeImages(this.props),Q(ee.findDOMNode(this.refs.textarea)).on("copy cut",this._maybeCopyWidgets).on("paste",this._maybePasteWidgets),o.getDependencies().getKaTeX().then((e=>{this.setState({katex:e})}))}UNSAFE_componentWillReceiveProps(e){this.props.content!==e.content&&this.setState({textAreaValue:e.content})}componentDidUpdate(e){var t=ee.findDOMNode(this.refs.textarea);null!==this.lastUserValue&&t&&(t.focus(),t.value=this.lastUserValue,t.selectionStart=0,t.select(0,e.content.length),!1===document.execCommand("insertText",!1,this.props.content)&&(t.value=this.props.content),this.lastUserValue=null),this.props.content!==e.content&&this._sizeImages(this.props)}componentWillUnmount(){clearTimeout(this.deferredChange)}render(){var e,t,n,a,s,i,o,p=[];if(this.props.showWordCount){var h=l.characterCount(this.props.content),u=Math.floor(h/6);o=G.createElement("span",{className:"perseus-editor-word-count",title:"~"+Er(u)+" words ("+Er(h)+" characters)"},Er(u))}var{katex:d}=this.state;if(this.props.widgetEnabled&&d){e=r.split(this.props.content,gr),t={},n=[];for(var m=0;m<e.length;m++)if(m%2==0){n.push(e[m]);var g=l.parse(e[m]);l.traverseContent(g,(e=>{if("math"===e.type||"blockMath"===e.type){var t=c(e.content);try{d.renderToString(t,{colorIsTextColor:!0})}catch(e){p.push({math:t,message:e.message})}}}))}else{var f=r.rWidgetParts.exec(e[m]);if(null!=f){var v=f[1],y=f[2],b=v in t;t[v]=this.getWidgetEditor(v,y);var E=b||!t[v]?"error ":"",w=b?m:v;n.push(G.createElement("b",{className:E,key:w},e[m]))}}this.widgetIds=X.keys(t),a=G.createElement(wr,{ref:"widgetSelect",onChange:this._addWidget});if(s=G.createElement("select",{onChange:this.addTemplate},G.createElement("option",{value:""},"Insert template…"),G.createElement("option",{disabled:!0},"--"),G.createElement("option",{value:"table"},"Table"),G.createElement("option",{value:"titledTable"},"Titled table"),G.createElement("option",{value:"alignment"},"Aligned equations"),G.createElement("option",{value:"piecewise"},"Piecewise function"),G.createElement("option",{disabled:!0},"--"),G.createElement("option",{value:"allWidgets"},"All widgets (for testing)")),!this.props.immutableWidgets){var x=Object.values(t);i=G.createElement("div",{className:"perseus-editor-widgets"},G.createElement("div",{className:"perseus-editor-widgets-selectors"},a,s,o),x),o=null}}else n=[this.props.content];n.push(G.createElement("br",{key:"end"}));var C,k=[G.createElement("div",{className:"perseus-textarea-underlay",ref:"underlay",key:"underlay"},n),G.createElement("textarea",{ref:"textarea",key:"textarea",onChange:this.handleChange,onKeyDown:this._handleKeyDown,placeholder:this.props.placeholder,disabled:this.props.disabled,value:this.state.textAreaValue})];C=this.props.imageUploader?G.createElement(me,{onDrop:this.handleDrop,className:"perseus-textarea-pair"},k):G.createElement("div",{className:"perseus-textarea-pair"},k);var S=0===this.props.content.replace(/\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/g,"").trim().length,N=!/\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/g.test(this.props.content),T={borderTop:"none",padding:4,backgroundColor:"pink"};return G.createElement("div",{className:"perseus-single-editor "+(this.props.className||"")},C,p.length>0&&G.createElement(ge,{errorList:p}),this.props.warnNoPrompt&&S&&G.createElement("div",{style:T},"Graded Groups should contain a prompt"),this.props.warnNoWidgets&&N&&G.createElement("div",{style:T},"Graded Groups should contain at least one widget"),o,i)}}le(Sr,"defaultProps",{content:"",placeholder:"",widgets:{},images:{},disabled:!1,widgetEnabled:!0,immutableWidgets:!1,showWordCount:!1,warnNoPrompt:!1,warnNoWidgets:!1});var Nr=0,Tr={},_r={};window.iframeDataStore={},window.addEventListener("message",(e=>{if("string"==typeof e.data){var t=Tr[e.data];t&&t()}else e.data.id&&(void 0!==e.data.height?_r[e.data.id](e.data.height):e.data.lintWarnings&&a.log("LINTER REPORT",{lintWarnings:JSON.stringify(e.data.lintWarnings)}))}));var Or=Z({displayName:"IframeContentRenderer",propTypes:{content:J.string.isRequired,datasetKey:J.any,datasetValue:J.any,seamless:J.bool},componentDidMount:function(){this._isMounted=!0,this.iframeID=Nr,Nr++,this._prepareFrame(),Tr[this.iframeID]=()=>{this.sendNewData(this._lastData)},_r[this.iframeID]=e=>{this._lastHeight=e,this._isMounted&&this.props.seamless&&(this.refs.container.style.height=e+"px")}},shouldComponentUpdate:function(e){return e.content!==this.props.content||e.datasetValue!==this.props.datasetValue||e.seamless!==this.props.seamless},componentDidUpdate:function(e){this.props.seamless?this.refs.container.style.height=this._lastHeight+"px":this.refs.container.style.height="100%",e.content===this.props.content&&e.datasetValue===this.props.datasetValue||this._prepareFrame()},componentWillUnmount:function(){Tr[this.iframeID]=null,_r[this.iframeID]=null,this._isMounted=!1},_prepareFrame:function(){this._frame&&this.refs.container.removeChild(this._frame),this._frame=document.createElement("iframe"),this._frame.style.width="100%",this._frame.style.height="100%",this.props.datasetKey&&(this._frame.dataset[this.props.datasetKey]=this.props.datasetValue),this._frame.dataset.id=this.iframeID,this.props.seamless&&(this._frame.dataset.lintGutter="true"),this._frame.onload=()=>{this._frame.onload=null,setTimeout((()=>{this._frame.contentWindow.document.open(),this._frame.contentWindow.document.write(this.props.content),this._frame.contentWindow.document.close()}))},this.refs.container.appendChild(this._frame)},sendNewData:function(e){this._isMounted&&e&&this._frame.contentWindow&&(this._lastData=e,window.iframeDataStore[this.iframeID]=e,this._frame.contentWindow.postMessage(this.iframeID,"*"))},render:function(){return G.createElement("div",{ref:"container",style:{width:"100%",height:"100%"}})}}),{HUD:Mr,InlineIcon:Ar}=t,{iconCircleArrowDown:Pr,iconCircleArrowUp:Dr,iconPlus:Ir,iconTrash:Rr}=p;class zr extends G.Component{constructor(){super(...arguments),le(this,"state",{highlightLint:!0}),le(this,"_handleJsonChange",(e=>{this.props.onChange({json:e})})),le(this,"_handleEditorChange",((e,t)=>{var n=X.clone(this._sections());n[e]=X.extend({},n[e],t),this.props.onChange({json:n})}))}componentDidMount(){this._updatePreviewFrames()}componentDidUpdate(){this._updatePreviewFrames()}_updatePreviewFrames(){"preview"===this.props.mode?this.refs["frame-all"].sendNewData({type:"article-all",data:this._sections().map(((e,t)=>this._apiOptionsForSection(e,t)))}):"edit"===this.props.mode&&this._sections().forEach(((e,t)=>{this.refs["frame-"+t].sendNewData({type:"article",data:this._apiOptionsForSection(e,t)})}))}_apiOptionsForSection(e,t){var n=this.refs["editor".concat(t)];return{apiOptions:oe(oe(oe({},u.defaults),this.props.apiOptions),{},{showAlignmentOptions:!0,isArticle:!0}),json:e,useNewStyles:this.props.useNewStyles,linterContext:{contentType:"article",highlightLint:this.state.highlightLint,paths:this.props.contentPaths},legacyPerseusLint:n?n.getSaveWarnings():[]}}_sections(){return Array.isArray(this.props.json)?this.props.json:[this.props.json]}_renderEditor(){var{imageUploader:e,sectionImageUploadGenerator:t}=this.props,n=oe(oe(oe({},u.defaults),this.props.apiOptions),{},{showAlignmentOptions:!0,isArticle:!0}),{KatexProvider:r}=o.getDependencies(),a=this._sections();return G.createElement("div",{className:"perseus-editor-table"},a.map(((s,i)=>[G.createElement("div",{className:"perseus-editor-row",key:i},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("div",{className:"pod-title"},"Section ",i+1,G.createElement("div",{style:{display:"inline-block",float:"right"}},t(i),G.createElement(lr,{icon:Ir,onClick:()=>{this._handleAddSectionAfter(i)},title:"Add a new section after this one"}),i+1<a.length&&G.createElement(lr,{icon:Pr,onClick:()=>{this._handleMoveSectionLater(i)},title:"Move this section down"}),i>0&&G.createElement(lr,{icon:Dr,onClick:()=>{this._handleMoveSectionEarlier(i)},title:"Move this section up"}),G.createElement(lr,{icon:Rr,onClick:()=>{confirm("Are you sure you want to delete section "+(i+1)+"?")&&this._handleRemoveSection(i)},title:"Delete this section"}))),G.createElement(r,null,G.createElement(Sr,ce({},s,{apiOptions:n,imageUploader:e,onChange:X.partial(this._handleEditorChange,i),placeholder:"Type your section text here...",ref:"editor"+i})))),G.createElement("div",{className:"editor-preview"},this._renderIframePreview(i,!0)))])),this._renderAddSection(),this._renderLinterHUD())}_renderAddSection(){return G.createElement("div",{className:"perseus-editor-row"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("a",{href:"#",className:"simple-button orange",onClick:()=>{this._handleAddSectionAfter(this._sections().length-1)}},G.createElement(Ar,Ir)," Add a section")))}_renderLinterHUD(){return G.createElement(Mr,{message:"Style warnings",enabled:this.state.highlightLint,onClick:()=>{this.setState({highlightLint:!this.state.highlightLint})}})}_renderIframePreview(e,t){var n="phone"===this.props.screen||"tablet"===this.props.screen;return G.createElement(ue,{deviceType:this.props.screen,nochrome:t},G.createElement(Or,{ref:"frame-"+e,key:this.props.screen,content:this.props.frameSource,datasetKey:"mobile",datasetValue:n,seamless:t}))}_renderPreviewMode(){return G.createElement("div",{className:"standalone-preview"},this._renderIframePreview("all",!1))}_handleMoveSectionEarlier(e){if(0!==e){var t=X.clone(this._sections()),n=t[e];t.splice(e,1),t.splice(e-1,0,n),this.props.onChange({json:t})}}_handleMoveSectionLater(e){var t=X.clone(this._sections());if(e+1!==t.length){var n=t[e];t.splice(e,1),t.splice(e+1,0,n),this.props.onChange({json:t})}}_handleAddSectionAfter(e){var t=X.clone(this.serialize()),n=e>=0?{widgets:t[e].widgets}:{};t.splice(e+1,0,n),this.props.onChange({json:t})}_handleRemoveSection(e){var t=X.clone(this._sections());t.splice(e,1),this.props.onChange({json:t})}serialize(){if("edit"===this.props.mode)return this._sections().map(((e,t)=>this.refs["editor"+t].serialize()));if("preview"===this.props.mode||"json"===this.props.mode)return this.props.json;throw new s("Could not serialize; mode "+this.props.mode+" not found",i.Internal)}getSaveWarnings(){if("edit"!==this.props.mode)throw new s("Can only get save warnings in edit mode.",i.NotAllowed);return this._sections().map(((e,t)=>this.refs["editor"+t].getSaveWarnings()))}render(){return G.createElement("div",{className:"framework-perseus perseus-article-editor"},"edit"===this.props.mode&&this._renderEditor(),"preview"===this.props.mode&&this._renderPreviewMode(),"json"===this.props.mode&&G.createElement("div",{className:"json-editor"},G.createElement("div",{className:"json-editor-warning"},G.createElement("span",null,"Warning: Editing in this mode can lead to broken articles!")),G.createElement(de,{multiLine:!0,onChange:this._handleJsonChange,value:this.props.json})))}}le(zr,"defaultProps",{contentPaths:[],json:[{}],mode:"edit",screen:"desktop",sectionImageUploadGenerator:()=>G.createElement("span",null),useNewStyles:!1});var{ButtonGroup:Lr,InlineIcon:Fr}=t,{devices:qr}=e,{iconDesktop:Ur,iconMobilePhone:Wr,iconTablet:Vr}=p;class jr extends G.Component{constructor(){super(...arguments),le(this,"handleChange",(e=>{this.props.onViewportSizeChanged(e)}))}render(){var e=G.createElement("span",null,G.createElement(Fr,Wr)," Phone"),t=G.createElement("span",null,G.createElement(Fr,Vr)," Tablet"),n=G.createElement("span",null,G.createElement(Fr,Ur)," Desktop");return G.createElement("span",{className:"viewport-resizer"},"Viewport:"," ",G.createElement(Lr,{value:this.props.deviceType,allowEmpty:!1,buttons:[{value:qr.PHONE,content:e},{value:qr.TABLET,content:t},{value:qr.DESKTOP,content:n}],onChange:this.handleChange}))}}le(jr,"propTypes",{deviceType:J.string.isRequired,onViewportSizeChanged:J.func.isRequired});var Br={exports:{}};!function(e){var t=function(){function e(e){return{newPos:e.newPos,components:e.components.slice(0)}}function t(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}var n=function(e){this.ignoreWhitespace=e};n.prototype={diff:function(t,n){if(n===t)return[{value:n}];if(!n)return[{value:t,removed:!0}];if(!t)return[{value:n,added:!0}];n=this.tokenize(n),t=this.tokenize(t);var r=n.length,a=t.length,s=r+a,i=[{newPos:-1,components:[]}],o=this.extractCommon(i[0],n,t,0);if(i[0].newPos+1>=r&&o+1>=a)return i[0].components;for(var l=1;l<=s;l++)for(var c=-1*l;c<=l;c+=2){var p,h=i[c-1],u=i[c+1];o=(u?u.newPos:0)-c,h&&(i[c-1]=void 0);var d=h&&h.newPos+1<r,m=u&&0<=o&&o<a;if(d||m){!d||m&&h.newPos<u.newPos?(p=e(u),this.pushComponent(p.components,t[o],void 0,!0)):((p=e(h)).newPos++,this.pushComponent(p.components,n[p.newPos],!0,void 0));o=this.extractCommon(p,n,t,c);if(p.newPos+1>=r&&o+1>=a)return p.components;i[c]=p}else i[c]=void 0}},pushComponent:function(e,t,n,r){var a=e[e.length-1];a&&a.added===n&&a.removed===r?e[e.length-1]={value:this.join(a.value,t),added:n,removed:r}:e.push({value:t,added:n,removed:r})},extractCommon:function(e,t,n,r){for(var a=t.length,s=n.length,i=e.newPos,o=i-r;i+1<a&&o+1<s&&this.equals(t[i+1],n[o+1]);)i++,o++,this.pushComponent(e.components,t[i],void 0,void 0);return e.newPos=i,o},equals:function(e,t){var n=/\S/;return!(!this.ignoreWhitespace||n.test(e)||n.test(t))||e===t},join:function(e,t){return e+t},tokenize:function(e){return e}};var r=new n,a=new n(!0),s=new n;a.tokenize=s.tokenize=function(e){return t(e.split(/(\s+|\b)/))};var i=new n(!0);i.tokenize=function(e){return t(e.split(/([{}:;,]|\s+)/))};var o=new n;return o.tokenize=function(e){for(var t=[],n=e.split(/^/m),r=0;r<n.length;r++){var a=n[r],s=n[r-1];"\n"==a&&s&&"\r"===s[s.length-1]?t[t.length-1]+="\n":a&&t.push(a)}return t},{Diff:n,diffChars:function(e,t){return r.diff(e,t)},diffWords:function(e,t){return a.diff(e,t)},diffWordsWithSpace:function(e,t){return s.diff(e,t)},diffLines:function(e,t){return o.diff(e,t)},diffCss:function(e,t){return i.diff(e,t)},createPatch:function(e,t,n,r,a){var s=[];s.push("Index: "+e),s.push("==================================================================="),s.push("--- "+e+(void 0===r?"":"\t"+r)),s.push("+++ "+e+(void 0===a?"":"\t"+a));var i=o.diff(t,n);function l(e){return e.map((function(e){return" "+e}))}function c(e,t,n){var r=i[i.length-2],a=t===i.length-2,s=t===i.length-3&&(n.added!==r.added||n.removed!==r.removed);/\n$/.test(n.value)||!a&&!s||e.push("\")}i[i.length-1].value||i.pop(),i.push({value:"",lines:[]});for(var p=0,h=0,u=[],d=1,m=1,g=0;g<i.length;g++){var f=i[g],v=f.lines||f.value.replace(/\n$/,"").split("\n");if(f.lines=v,f.added||f.removed){if(!p){var y=i[g-1];p=d,h=m,y&&(p-=(u=l(y.lines.slice(-4))).length,h-=u.length)}u.push.apply(u,v.map((function(e){return(f.added?"+":"-")+e}))),c(u,g,f),f.added?m+=v.length:d+=v.length}else{if(p)if(v.length<=8&&g<i.length-2)u.push.apply(u,l(v));else{var b=Math.min(v.length,4);s.push("@@ -"+p+","+(d-p+b)+" +"+h+","+(m-h+b)+" @@"),s.push.apply(s,u),s.push.apply(s,l(v.slice(0,b))),v.length<=4&&c(s,g,f),p=0,h=0,u=[]}d+=v.length,m+=v.length}}return s.join("\n")+"\n"},applyPatch:function(e,t){for(var n=t.split("\n"),r=[],a=!1,s=!1,i="I"===n[0][0]?4:0;i<n.length;i++)if("@"===n[i][0]){var o=n[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);r.unshift({start:o[3],oldlength:o[2],oldlines:[],newlength:o[4],newlines:[]})}else"+"===n[i][0]?r[0].newlines.push(n[i].substr(1)):"-"===n[i][0]?r[0].oldlines.push(n[i].substr(1)):" "===n[i][0]?(r[0].newlines.push(n[i].substr(1)),r[0].oldlines.push(n[i].substr(1))):"\\"===n[i][0]&&("+"===n[i-1][0]?a=!0:"-"===n[i-1][0]&&(s=!0));var l=e.split("\n");for(i=r.length-1;i>=0;i--){for(var c=r[i],p=0;p<c.oldlength;p++)if(l[c.start-1+p]!==c.oldlines[p])return!1;Array.prototype.splice.apply(l,[c.start-1,+c.oldlength].concat(c.newlines))}if(a)for(;!l[l.length-1];)l.pop();else s&&l.push("");return l.join("\n")},convertChangesToXML:function(e){for(var t,n=[],r=0;r<e.length;r++){var a=e[r];a.added?n.push("<ins>"):a.removed&&n.push("<del>"),n.push((t=a.value,void 0,t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""))),a.added?n.push("</ins>"):a.removed&&n.push("</del>")}return n.join("")},convertChangesToDMP:function(e){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push([t.added?1:t.removed?-1:0,t.value]);return n}}}();e.exports=t}(Br);var $r=Br.exports,Hr=function(e){return e.added?"added":e.removed?"removed":"unchanged"},Gr=e=>X.map(e.value,(t=>({value:t,status:Hr(e)}))),Yr=new $r.Diff;Yr.tokenize=e=>X.map(e,(e=>[e])),Yr.join=(e,t)=>e.concat(t),Yr.equals=X.isEqual;var Kr=e=>{return t=e,n=Gr,X.flatten(X.map(t,n),!0);var t,n},{SvgImage:Xr}=t,Jr=/http.*?\.png|web\+graphie[^)]*/g,Zr=function(e){return e.match(Jr)||[]},Qr=function(e,t,n){return e.added?t:e.removed?n:""};class ea extends G.Component{render(){return G.createElement("div",null,X.map(this.props.images,((e,t)=>{var n=ae({image:!0,"image-unchanged":"unchanged"===e.status,"image-added":"added"===e.status,"image-removed":"removed"===e.status});return G.createElement("div",{key:t},G.createElement("div",{className:n},G.createElement(Xr,{src:e.value,title:e.value})))})))}}le(ea,"propTypes",{images:J.arrayOf(J.shape({})).isRequired});class ta extends G.Component{constructor(){super(...arguments),le(this,"state",{collapsed:this.props.before===this.props.after}),le(this,"handleExpand",(()=>{this.setState({collapsed:!1})}))}UNSAFE_componentWillReceiveProps(e){this.setState({collapsed:e.before===e.after})}render(){var e,t,n,r,a=function(e){var t=[],n=[];return X.each(e,(e=>{var r=e.value.split("\n");X.each(r,((r,a)=>{a>0&&(t.push(n),n=[]);var s=X.extend({},e,{value:r});n.push(s)}))})),n.length&&t.push(n),t}($r.diffWords(this.props.before,this.props.after)),s=Zr(this.props.before),i=Zr(this.props.after),o=(e=s,t=i,n=Yr.diff(e,t),r=Kr(n),{before:X.filter(r,(e=>"added"!==e.status)),after:X.filter(r,(e=>"removed"!==e.status))}),l=X.map(a,(e=>{var t={};return t.before=X(e).map((function(e,t){return G.createElement("span",{key:t,className:Qr(e,"not-present","removed dark")},e.value)})),t.after=X(e).map((function(e,t){return G.createElement("span",{key:t,className:Qr(e,"added dark","not-present")},e.value)})),t})),c=ae({"diff-row":!0,collapsed:this.state.collapsed});return G.createElement("div",null,G.createElement("div",{className:"diff-header"},this.props.title),G.createElement("div",{className:"diff-header"},this.props.title),G.createElement("div",{className:"diff-body ui-helper-clearfix"},X.map(["before","after"],((e,t)=>G.createElement("div",{className:"diff-row "+e,key:t},!this.state.collapsed&&X.map(l,((t,n)=>{var r=t[e].length>1,a=ae({"diff-line":!0,added:"after"===e&&r,removed:"before"===e&&r});return G.createElement("div",{className:a,key:n},t[e])})),!this.state.collapsed&&G.createElement(ea,{images:o[e]}))))),X.map(["before","after"],((e,t)=>G.createElement("div",{className:c+" "+e,key:t,onClick:this.handleExpand},this.state.collapsed&&G.createElement("span",null,G.createElement("span",{className:"expand-button"}," ","[ show unmodified ]"," "))))))}}le(ta,"propTypes",{after:J.string,before:J.string,title:J.string.isRequired}),le(ta,"defaultProps",{after:"",before:""});var na=function(e,t,n){var r,a=X.isObject(e)?X(e).keys():[],s=X.isObject(t)?X(t).keys():[],i=X.union(a,s),o=X.map(i,(function(n){return ra((e||{})[n],(t||{})[n],n)}));if(void 0===e)r="added";else if(void 0===t)r="removed";else{r=X.any(o,(function(e){return"unchanged"!==e.status}))?"changed":"unchanged"}return{after:"",before:"",children:o,key:n,status:r}},ra=function(e,t,n){return"object"==typeof e||"object"==typeof t?na(e,t,n):function(e,t,n){var r;return r=e===t?"unchanged":void 0===e?"added":void 0===t?"removed":"changed",{after:JSON.stringify(t),before:JSON.stringify(e),children:[],key:n,status:r}}(e,t,n)},{SvgImage:aa}=t,sa=function(e){return 20*(e-1)};class ia extends G.Component{render(){var e=ae(this.props.className,{"diff-row":!0,before:"before"===this.props.side,after:"after"===this.props.side});return G.createElement("div",{className:e},G.createElement("div",{style:{paddingLeft:sa(this.props.depth)}},this.props.showKey&&this.props.propKey+": ",G.createElement("span",{className:"inner-value dark "+this.props.className},this.props.value)))}}le(ia,"propTypes",{className:J.string.isRequired,depth:J.number.isRequired,propKey:J.string.isRequired,showKey:J.bool.isRequired,side:J.oneOf(["before","after"]).isRequired,value:J.string});class oa extends G.Component{render(){var e=this;return G.createElement("div",{onClick:e.props.onClick,style:{clear:"both"}},X.map(["before","after"],(function(t){return G.createElement("div",{className:"diff-row collapsed "+t,key:t},G.createElement("div",{style:{paddingLeft:sa(e.props.depth)}},G.createElement("span",null," [ show unmodified ] ")))})))}}le(oa,"propTypes",{depth:J.number,onClick:J.func.isRequired}),le(oa,"defaultProps",{depth:0});class la extends G.Component{constructor(){super(...arguments),le(this,"state",{expanded:this.props.expanded}),le(this,"expand",(()=>{this.setState({expanded:!0})}))}render(){var e,t=this.props.entry,n="removed"===t.status,r="added"===t.status,a="changed"===t.status,s=t.children.length>0,i=ae({removed:n||a&&!s,dark:n,"blank-space":r}),o=ae({added:r||a&&!s,dark:r,"blank-space":n}),l=(e=this.state.expanded?t.children:X(t.children).select((function(e){return"unchanged"!==e.status}))).length<t.children.length;t.children.length===e.length+1&&(e=t.children,l=!1);var c=this;return G.createElement("div",null,t.key&&G.createElement("div",{style:{clear:"both"}},G.createElement(ia,{side:"before",className:i,depth:this.props.depth,propKey:t.key,showKey:!r,value:t.before}),G.createElement(ia,{side:"after",className:o,depth:this.props.depth,propKey:t.key,showKey:!n,value:t.after})),X.map(e,(function(e){return G.createElement(la,{key:e.key,depth:c.props.depth+1,entry:e,expanded:c.state.expanded})})),l&&G.createElement(oa,{depth:this.props.depth+1,onClick:this.expand}))}}le(la,"propTypes",{depth:J.number,entry:J.shape({after:J.string,before:J.string,children:J.arrayOf(J.any),key:J.string}),expanded:J.bool}),le(la,"defaultProps",{depth:0});class ca extends G.Component{render(){var{before:e,after:t}=this.props,n=e.options&&e.options.backgroundImage?e.options.backgroundImage.url:"",r=t.options&&t.options.backgroundImage?t.options.backgroundImage.url:"";return G.createElement("div",null,G.createElement("div",{className:"diff-row before"},n&&G.createElement("div",{className:ae({image:!0,"image-unchanged":n===r,"image-removed":n!==r})},G.createElement(aa,{src:n,title:n}))),G.createElement("div",{className:"diff-row after"},r&&G.createElement("div",{className:ae({image:!0,"image-unchanged":n===r,"image-added":n!==r})},G.createElement(aa,{src:r,title:r}))))}}le(ca,"propTypes",{after:J.shape({options:J.objectOf(J.any)}).isRequired,before:J.shape({options:J.objectOf(J.any)}).isRequired});class pa extends G.Component{render(){var{after:e,before:t,title:n,type:r}=this.props,a=ra(t,e);return G.createElement("div",null,G.createElement("div",{className:"diff-header"},n),G.createElement("div",{className:"diff-header"},n),G.createElement("div",{className:"diff-body ui-helper-clearfix"},"image"===r&&G.createElement(ca,{before:t,after:e}),G.createElement(la,{entry:a})))}}le(pa,"propTypes",{after:J.shape({options:J.objectOf(J.any)}),before:J.shape({options:J.objectOf(J.any)}),title:J.string.isRequired,type:J.string}),le(pa,"defaultProps",{after:{},before:{},type:""});var ha=function(e,t){var r,{alignment:a,graded:s,options:i,type:o}=e||{},l={options:i};(t&&n.getSupportedAlignments(o).length>1&&(l.alignment=a),"transformer"===o&&(l.graded=s),n.supportsStaticMode(o))&&(l.static=null!==(r=null==e?void 0:e.static)&&void 0!==r?r:void 0);return l};class ua extends G.Component{render(){var e,t,n,r,{after:a,before:s,showAlignmentOptions:i,showSeparator:o,title:l}=this.props;(s.content||a.content)&&(n=G.createElement(ta,{before:s.content,after:a.content,title:l}));var c=Object.keys(null!==(e=s.widgets)&&void 0!==e?e:{}).filter((e=>s.content.includes(e))),p=Object.keys(null!==(t=a.widgets)&&void 0!==t?t:{}).filter((e=>a.content.includes(e)));(c.length||p.length)&&(r=X.union(c,p).map((e=>{var t,n,r,o,l,c;return G.createElement(pa,{before:ha(null===(t=s.widgets)||void 0===t?void 0:t[e],i),after:ha(null===(n=a.widgets)||void 0===n?void 0:n[e],i),title:e,type:(null!==(r=null===(o=s.widgets)||void 0===o?void 0:o[e])&&void 0!==r?r:{}).type||(null!==(l=null===(c=a.widgets)||void 0===c?void 0:c[e])&&void 0!==l?l:{}).type,key:e})})));return G.createElement("div",null,n,r,o&&G.createElement("div",{className:"diff-separator"}))}}le(ua,"defaultProps",{after:{content:"",images:{},widgets:{}},before:{content:"",images:{},widgets:{}},showAlignmentOptions:!1,showSeparator:!1});var da=J.shape({content:J.string,images:J.objectOf(J.any),widgets:J.objectOf(J.any)});class ma extends G.Component{constructor(){super(...arguments),le(this,"state",ma._stateFromProps(this.props))}UNSAFE_componentWillReceiveProps(e){this.setState(ma._stateFromProps(e))}render(){var{before:e,after:t}=this.state,n=Math.max(e.length,t.length),r=X.times(n,(r=>G.createElement(ua,{before:r<e.length?e[r]:void 0,after:r<t.length?t[r]:void 0,title:"Section ".concat(r+1),showAlignmentOptions:!0,showSeparator:r<n-1,key:r})));return G.createElement("div",{className:"framework-perseus"},r)}}le(ma,"propTypes",{after:J.oneOfType([da,J.arrayOf(da)]).isRequired,before:J.oneOfType([da,J.arrayOf(da)]).isRequired}),le(ma,"_stateFromProps",(e=>{var{before:t,after:n}=e;return{before:Array.isArray(t)?t:[t],after:Array.isArray(n)?n:[n]}}));var ga=J.shape({question:J.shape({}).isRequired,answerArea:J.shape({}).isRequired,hints:J.arrayOf(J.any).isRequired});class fa extends G.Component{render(){var{before:e,after:t}=this.props,n=Math.max(e.hints.length,t.hints.length),r=G.createElement(ua,{before:e.question,after:t.question,title:"Question",showAlignmentOptions:!1,showSeparator:!0}),a=G.createElement(pa,{before:e.answerArea,after:t.answerArea,title:"Question extras"}),s=X.times(n,(function(r){return G.createElement(ua,{before:r<e.hints.length?e.hints[r]:void 0,after:r<t.hints.length?t.hints[r]:void 0,title:"Hint ".concat(r+1),showAlignmentOptions:!1,showSeparator:r<n-1,key:r})}));return G.createElement("div",{className:"framework-perseus"},r,a,s&&G.createElement("div",{className:"diff-separator"}),s)}}le(fa,"propTypes",{after:ga.isRequired,before:ga.isRequired});class va extends G.Component{render(){var{afterOnly:e,beforeOnly:t,intersection:n,showSeparator:r}=this.props,a=n.concat(t).join("\n")+"\n",s=n.concat(e).join("\n")+"\n";return G.createElement("div",null,G.createElement(ta,{before:a,after:s,title:this.props.title}),r&&G.createElement("div",{className:"diff-separator"}))}}function ya(e,t){for(var n=!0,r=0;r<t.length;r++){if(r>=e.length)return!1;t[r]!==e[r]&&(n=!1)}return n}function ba(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}le(va,"defaultProps",{afterOnly:[],beforeOnly:[],showSeparator:!1,title:"Question tags"});class Ea extends G.Component{static generateCompletePathsList(e,t,n,r,a){if("content"===r.type||"hint"===r.type||"tags"===r.type){var s=e.length>0&&ba(a,e[0][1]),i=t.length>0&&ba(a,t[0][1]);s&&i?(n.push(a),e.splice(0,1),t.splice(0,1)):s?(n.push(a),e.splice(0,1)):i&&(n.push(a),t.splice(0,1))}else if("array"===r.type)for(var o=0,l=a.concat(o);e.length>0&&ya(e[0][1],l)||t.length>0&&ya(t[0][1],l);)Ea.generateCompletePathsList(e,t,n,r.elementShape,l),o++,l=a.concat(o);else if("object"===r.type)for(var c=Object.keys(r.shape),p=0;p<c.length;p++){var h=a.concat([c[p]]);Ea.generateCompletePathsList(e,t,n,r.shape[c[p]],h)}}render(){var{before:e,after:t,shape:n,tags:r}=this.props,a=[],s=[];d().setContentMapper(((e,t,n)=>a.push([e,n]))).setHintMapper(((e,t,n)=>a.push([e,n]))).setTagsMapper(((e,t,n)=>a.push([e,n]))).mapTree(m(e),n),d().setContentMapper(((e,t,n)=>s.push([e,n]))).setHintMapper(((e,t,n)=>s.push([e,n]))).setTagsMapper(((e,t,n)=>s.push([e,n]))).mapTree(m(t),n);var i=a.slice(),o=s.slice(),l=[];Ea.generateCompletePathsList(i,o,l,n,[]);var c=l.length,p=l.map(((e,t)=>{var n="tags"===e[e.length-1],i=function(e){for(var t=[],n=0;n<e.length;n++)"number"==typeof e[n]?t.push((e[n]+1).toString()+":"):t.push(e[n]);return t.join(" ")}(e),o=a.find((t=>ba(t[1],e))),l=s.find((t=>ba(t[1],e)));if(n){o||(o=[[],e]),l||(l=[[],e]);var p=[];Array.isArray(o[0])&&o[0].forEach((e=>{"string"==typeof e&&p.push(r.idToName(e))}));var h=[];Array.isArray(l[0])&&l[0].forEach((e=>{"string"==typeof e&&h.push(r.idToName(e))}));var u=p.filter((e=>h.includes(e))),d=p.filter((e=>!h.includes(e))),m=h.filter((e=>!p.includes(e)));return G.createElement(va,{beforeOnly:d,afterOnly:m,intersection:u,title:i,showSeparator:t<c-1,key:t})}return o||(o=[g(f.content),e]),l||(l=[g(f.content),e]),G.createElement(ua,{before:o[0],after:l[0],title:i,showAlignmentOptions:!1,showSeparator:t<c-1,key:t})}));return G.createElement("div",{className:"framework-perseus"},p)}}var{InfoTip:wa,InlineIcon:xa}=t,{iconCircleArrowDown:Ca,iconCircleArrowUp:ka,iconPlus:Sa,iconTrash:Na}=p;class Ta extends G.Component{constructor(){super(...arguments),le(this,"handleChange",(e=>{this.props.onChange({replace:e.target.checked})})),le(this,"focus",(()=>{this.refs.editor.focus()})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(e=>this.refs.editor.serialize(e)))}render(){return G.createElement("div",{className:"perseus-hint-editor "+this.props.className},this.props.showTitle&&G.createElement("div",{className:"pod-title"},"Hint"),G.createElement(Sr,{ref:"editor",key:this.props.itemId,apiOptions:this.props.apiOptions,widgets:this.props.widgets||void 0,content:this.props.content||void 0,images:this.props.images,replace:this.props.replace,placeholder:"Type your hint here...",imageUploader:this.props.imageUploader,onChange:this.props.onChange}),G.createElement("div",{className:"hint-controls-container clearfix"},this.props.showMoveButtons&&G.createElement("span",{className:"reorder-hints"},G.createElement("button",{type:"button",className:this.props.isLast?"hidden":"",onClick:X.partial(this.props.onMove,1)},G.createElement(xa,Ca))," ",G.createElement("button",{type:"button",className:this.props.isFirst?"hidden":"",onClick:X.partial(this.props.onMove,-1)},G.createElement(xa,ka))," ",this.props.isLast&&G.createElement(wa,null,G.createElement("p",null,"The last hint is automatically bolded."))),G.createElement("input",{type:"checkbox",checked:this.props.replace,onChange:this.handleChange}),"Replace previous hint",this.props.showRemoveButton&&G.createElement("button",{type:"button",className:"remove-hint simple-button orange",onClick:this.props.onRemove},G.createElement(xa,Na),"Remove this hint"," ")))}}le(Ta,"defaultProps",{className:"",content:"",replace:!1,showMoveButtons:!0,showTitle:!0,showRemoveButton:!0});class _a extends G.Component{constructor(){super(...arguments),le(this,"updatePreview",(()=>{var e=this.props.isLast&&!/\*\*/.test(this.props.hint.content);this.refs.frame.sendNewData({type:"hint",data:{hint:this.props.hint,bold:e,pos:this.props.pos,apiOptions:this.props.apiOptions,linterContext:{contentType:"hint",highlightLint:this.props.highlightLint,paths:this.props.contentPaths}}})})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(e=>this.refs.editor.serialize(e))),le(this,"focus",(()=>{this.refs.editor.focus()}))}componentDidMount(){this.updatePreview()}componentDidUpdate(){this.updatePreview()}render(){var e="phone"===this.props.deviceType||"tablet"===this.props.deviceType;return G.createElement("div",{className:"perseus-combined-hint-editor perseus-editor-row"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement(Ta,{ref:"editor",itemId:this.props.itemId,isFirst:this.props.isFirst,isLast:this.props.isLast,widgets:this.props.hint.widgets,content:this.props.hint.content,images:this.props.hint.images,replace:this.props.hint.replace,imageUploader:this.props.imageUploader,onChange:this.props.onChange,onRemove:this.props.onRemove,onMove:this.props.onMove,apiOptions:this.props.apiOptions})),G.createElement("div",{className:"perseus-editor-right-cell"},G.createElement(ue,{deviceType:this.props.deviceType,nochrome:!0},G.createElement(Or,{ref:"frame",content:this.props.frameSource,datasetKey:"mobile",datasetValue:e,seamless:!0}))))}}le(_a,"defaultProps",{highlightLint:!1});class Oa extends G.Component{constructor(){super(...arguments),le(this,"handleHintChange",((e,t,n,r)=>{var a=X(this.props.hints).clone();a[e]=X.extend({},this.serializeHint(e,{keepDeletedWidgets:!0}),t),this.props.onChange({hints:a},n,r)})),le(this,"handleHintRemove",(e=>{var t=X(this.props.hints).clone();t.splice(e,1),this.props.onChange({hints:t})})),le(this,"handleHintMove",((e,t)=>{var n=X(this.props.hints).clone(),r=n.splice(e,1)[0];n.splice(e+t,0,r),this.props.onChange({hints:n},(()=>{this.refs["hintEditor"+(e+t)].focus()}))})),le(this,"addHint",(()=>{var e=X(this.props.hints).clone().concat([{content:""}]);this.props.onChange({hints:e},(()=>{var t=e.length-1;this.refs["hintEditor"+t].focus()}))})),le(this,"getSaveWarnings",(()=>X.chain(this.props.hints).map(((e,t)=>X.map(this.refs["hintEditor"+t].getSaveWarnings(),(e=>"Hint "+(t+1)+": "+e)))).flatten(!0).value())),le(this,"serialize",(e=>this.props.hints.map(((t,n)=>this.serializeHint(n,e))))),le(this,"serializeHint",((e,t)=>this.refs["hintEditor"+e].serialize(t)))}render(){var{itemId:e,hints:t}=this.props,n=X.map(t,(function(n,r){return G.createElement(_a,{ref:"hintEditor"+r,key:"hintEditor"+r,isFirst:0===r,isLast:r+1===t.length,itemId:e,hint:n,pos:r,imageUploader:this.props.imageUploader,onChange:this.handleHintChange.bind(this,r),onRemove:this.handleHintRemove.bind(this,r),onMove:this.handleHintMove.bind(this,r),deviceType:this.props.deviceType,apiOptions:this.props.apiOptions,frameSource:this.props.frameSource,highlightLint:this.props.highlightLint,contentPaths:[]})}),this);return G.createElement("div",{className:"perseus-hints-editor perseus-editor-table"},n,G.createElement("div",{className:"perseus-editor-row"},G.createElement("div",{className:"add-hint-container perseus-editor-left-cell"},G.createElement("button",{type:"button",className:"add-hint simple-button orange",onClick:this.addHint},G.createElement(xa,Sa)," Add a hint"))))}}le(Oa,"HintEditor",Ta),le(Oa,"defaultProps",{onChange:()=>{},hints:[],highlightLint:!1});var{InfoTip:Ma}=t;class Aa extends G.Component{constructor(){super(...arguments),le(this,"serialize",(()=>({calculator:this.props.calculator,chi2Table:this.props.chi2Table,periodicTable:this.props.periodicTable,tTable:this.props.tTable,zTable:this.props.zTable})))}render(){return G.createElement("div",{className:"perseus-answer-editor"},G.createElement("div",{className:"perseus-answer-options"},G.createElement("div",null,G.createElement("label",null,"Show calculator:"," ",G.createElement("input",{type:"checkbox",checked:this.props.calculator,onChange:e=>{this.props.onChange({calculator:e.target.checked})}})),G.createElement(Ma,null,"Use the calculator when completing difficult calculations is NOT the intent of the question. DON’T use the calculator when testing the student’s ability to complete different types of computations.")),G.createElement("div",null,G.createElement("label",null,"Show periodic table:"," ",G.createElement("input",{type:"checkbox",checked:this.props.periodicTable,onChange:e=>{this.props.onChange({periodicTable:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions.")),G.createElement("div",null,G.createElement("label",null,"Show z table (statistics):"," ",G.createElement("input",{type:"checkbox",checked:this.props.zTable,onChange:e=>{this.props.onChange({zTable:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a table of critical values for the z distribution, e.g. for answering statistics questions.")),G.createElement("div",null,G.createElement("label",null,"Show t table (statistics):"," ",G.createElement("input",{type:"checkbox",checked:this.props.tTable,onChange:e=>{this.props.onChange({tTable:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a table of critical values for the Student's t distribution, e.g. for answering statistics questions.")),G.createElement("div",null,G.createElement("label",null,"Show chi-squared table (statistics):"," ",G.createElement("input",{type:"checkbox",checked:this.props.chi2Table,onChange:e=>{this.props.onChange({chi2Table:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions."))))}}le(Aa,"propTypes",{calculator:J.bool,chi2Table:J.bool,onChange:J.func.isRequired,periodicTable:J.bool,tTable:J.bool,zTable:J.bool}),le(Aa,"defaultProps",{calculator:!1,chi2Table:!1,periodicTable:!1,tTable:!1,zTable:!1});var Pa=v;class Da extends G.Component{constructor(){super(...arguments),le(this,"updateProps",((e,t,n)=>{var r=X(this.props).pick("question","answerArea");this.props.onChange(X(r).extend(e),t,n)})),le(this,"triggerPreviewUpdate",(e=>{this.refs.frame.sendNewData(e)})),le(this,"handleEditorChange",((e,t,n)=>{var r=X.extend({},this.props.question,e);this.updateProps({question:r},t,n)})),le(this,"handleItemExtrasChange",((e,t,n)=>{var r=X.extend({},this.props.answerArea,e);this.updateProps({answerArea:r},t,n)})),le(this,"getSaveWarnings",(()=>this.refs.questionEditor.getSaveWarnings())),le(this,"serialize",(e=>({question:this.refs.questionEditor.serialize(e),answerArea:this.refs.itemExtrasEditor.serialize(e),itemDataVersion:Pa})))}render(){var e="phone"===this.props.deviceType||"tablet"===this.props.deviceType;return G.createElement("div",{className:"perseus-editor-table"},G.createElement("div",{className:"perseus-editor-row perseus-question-container"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("div",{className:"pod-title"},"Question"),G.createElement(Sr,ce({ref:"questionEditor",key:this.props.itemId,placeholder:"Type your question here...",className:"perseus-question-editor",imageUploader:this.props.imageUploader,onChange:this.handleEditorChange,apiOptions:this.props.apiOptions,showWordCount:!0},this.props.question))),G.createElement("div",{className:"perseus-editor-right-cell"},G.createElement("div",{id:"problemarea"},G.createElement(ue,{deviceType:this.props.deviceType,nochrome:!0},G.createElement(Or,{ref:"frame",key:this.props.deviceType,content:this.props.frameSource,datasetKey:"mobile",datasetValue:e,seamless:!0})),G.createElement("div",{id:"hintsarea",className:"hintsarea",style:{display:"none"}})))),G.createElement("div",{className:"perseus-editor-row perseus-answer-container"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("div",{className:"pod-title"},"Question extras"),G.createElement(Aa,ce({ref:"itemExtrasEditor",onChange:this.handleItemExtrasChange},this.props.answerArea))),G.createElement("div",{className:"perseus-editor-right-cell"},G.createElement("div",{id:"answer_area"}))))}}le(Da,"defaultProps",{onChange:()=>{},question:{},answerArea:{}});var{HUD:Ia}=t;class Ra extends G.Component{constructor(e){super(e),le(this,"_isMounted",void 0),le(this,"rendererMountNode",void 0),le(this,"renderer",void 0),le(this,"toggleJsonMode",(()=>{this.setState({json:this.serialize({keepDeletedWidgets:!0})},(()=>{this.props.onChange({jsonMode:!this.props.jsonMode})}))})),le(this,"handleChange",((e,t,n)=>{var r=X(this.props).pick("question","hints","answerArea");X(r).extend(e),this.props.onChange(r,t,n)})),le(this,"changeJSON",(e=>{this.setState({json:e}),this.props.onChange(e)})),this.state={json:X.pick(this.props,"question","answerArea","hints","itemDataVersion"),gradeMessage:"",wasAnswered:!1,highlightLint:!0},this._isMounted=!1}componentDidMount(){this._isMounted=!0,this.rendererMountNode=document.createElement("div"),this.updateRenderer()}componentDidUpdate(){setTimeout((()=>{this.updateRenderer()}))}componentWillUnmount(){this._isMounted=!1}updateRenderer(){var e=!this.props.developerMode||!this.props.jsonMode;if(this._isMounted&&e){var t="phone"===this.props.previewDevice||"tablet"===this.props.previewDevice,n=oe(oe({},this.getApiOptions()),{},{customKeypad:t,isMobile:t});this.refs.itemEditor.triggerPreviewUpdate({type:"question",data:X({item:this.serialize(),apiOptions:n,initialHintsVisible:0,device:this.props.previewDevice,linterContext:{contentType:"exercise",highlightLint:this.state.highlightLint,paths:this.props.contentPaths||[]},reviewMode:!0,legacyPerseusLint:this.refs.itemEditor.getSaveWarnings()}).extend(X(this.props).pick("workAreaSelector","solutionAreaSelector","hintsAreaSelector","problemNum"))})}}getApiOptions(){return oe(oe({},u.defaults),this.props.apiOptions)}getSaveWarnings(){var e=this.refs.itemEditor.getSaveWarnings(),t=this.refs.hintsEditor.getSaveWarnings();return e.concat(t)}serialize(e){return this.props.jsonMode?this.state.json:X.extend(this.refs.itemEditor.serialize(e),{hints:this.refs.hintsEditor.serialize(e)})}scorePreview(){return this.renderer?this.renderer.scoreInput():null}render(){var e="framework-perseus",t="phone"===this.props.previewDevice||"tablet"===this.props.previewDevice,n=oe(oe({},this.getApiOptions()),{},{customKeypad:t,isMobile:t});return n.isMobile&&(e+=" "+y.MOBILE),G.createElement("div",{id:"perseus",className:e},G.createElement("div",{style:{marginBottom:10}},this.props.developerMode&&G.createElement("span",null,G.createElement("label",null," ","Developer JSON Mode:"," ",G.createElement("input",{type:"checkbox",checked:this.props.jsonMode,onChange:this.toggleJsonMode}))," "),!this.props.jsonMode&&G.createElement(jr,{deviceType:this.props.previewDevice,onViewportSizeChanged:this.props.onPreviewDeviceChange}),!this.props.jsonMode&&G.createElement(Ia,{message:"Style warnings",enabled:this.state.highlightLint,onClick:()=>{this.setState({highlightLint:!this.state.highlightLint})}})),this.props.developerMode&&this.props.jsonMode&&G.createElement("div",null,G.createElement(de,{multiLine:!0,value:this.state.json,onChange:this.changeJSON})),(!this.props.developerMode||!this.props.jsonMode)&&G.createElement(Da,{ref:"itemEditor",itemId:this.props.itemId,question:this.props.question,answerArea:this.props.answerArea,imageUploader:this.props.imageUploader,onChange:this.handleChange,wasAnswered:this.state.wasAnswered,gradeMessage:this.state.gradeMessage,deviceType:this.props.previewDevice,apiOptions:n,frameSource:this.props.frameSource}),(!this.props.developerMode||!this.props.jsonMode)&&G.createElement(Oa,{ref:"hintsEditor",itemId:this.props.itemId,hints:this.props.hints,imageUploader:this.props.imageUploader,onChange:this.handleChange,deviceType:this.props.previewDevice,apiOptions:n,frameSource:this.props.frameSource,highlightLint:this.state.highlightLint}))}}le(Ra,"defaultProps",{developerMode:!1,jsonMode:!1,onChange:()=>{}});var{findContentNodesInItem:za,findHintNodesInItem:La,inferItemShape:Fa}=b;function qa(e,t){var n=l.parse(e);l.traverseContent(n,(function(e){"image"===e.type&&t.push(e.target)}))}function Ua(e,t){e&&e.backgroundImage&&e.backgroundImage.url&&t.push(e.backgroundImage.url)}function Wa(e){var t=[];return X.each(e,(e=>{E(e,(e=>{qa(e,t)}),(e=>function(e,t){e.options&&("categorizer"===e.type?(X.each(e.options.items,(function(e){qa(e,t)})),X.each(e.options.categories,(function(e){qa(e,t)}))):"image"===e.type?(qa(e.options.title,t),qa(e.options.caption,t)):"matcher"===e.type?(X.each(e.options.left,(function(e){qa(e,t)})),X.each(e.options.right,(function(e){qa(e,t)})),X.each(e.options.labels,(function(e){qa(e,t)}))):"matrix"===e.type?(qa(e.options.prefix,t),qa(e.options.suffix,t)):"orderer"===e.type?X.each(e.options.options,(function(e){qa(e.content,t)})):"passage"===e.type?qa(e.options.passageTitle,t):"radio"===e.type?X.each(e.options.choices,(function(e){qa(e.content,t)})):"sorter"===e.type?X.each(e.options.correct,(function(e){qa(e,t)})):"table"===e.type&&X.each(e.options.headers,(function(e){qa(e,t)})),"grapher"===e.type?Ua(e.options.graph,t):"image"===e.type||"interactive-graph"===e.type?Ua(e.options,t):"measurer"===e.type&&e.options.image?t.push(e.options.image.url):"plotter"===e.type?t.push(e.options.picUrl):"transformer"===e.type&&Ua(e.options.graph,t))}(e,t)))})),t}var Va,ja={findImagesInArticles:function(e){return Wa(e)},findImagesInItemData:function(e){var t=[];if(e._multi){var n=Fa(e);za(e,n,(e=>t.push(e))),La(e,n,(e=>t.push(e)))}else t=[e.question,...e.hints];return Wa(t)}},Ba={exports:{}};Va=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},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)},r=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var r in n)e[r]=n[r]}return e};e.exports={isObject:n,merge:r,clone:function(e){return n(e)?Array.isArray(e)?e.slice():r(e):e}}},function(e,t,n){var r=n(0),a=r.clone,s=r.isObject,i=r.merge,o=n(2),l=n(3),c=n(4),p=function(e){return Array.isArray(e)?o:s(e)?l:"string"==typeof e?c:void 0},h=function e(t){if(t instanceof e)return t;if(!(this instanceof e))return new e(t);var n=p(t);this._wrapped=n.thaw?n.thaw(t):t};h.prototype.freeze=function(){var e=this._wrapped,t=p(e);return t.freeze?t.freeze(e):e},h.prototype.zoom=function(e){return void 0===this._zoomStack&&(this._zoomStack=[]),this._zoomStack.push({zoom:e,wrapped:this._wrapped}),this._wrapped=h(this._wrapped).get(e),this},h.prototype.deZoom=function(){var e=this._zoomStack.pop();return this._wrapped=h(e.wrapped).set(e.zoom,this._wrapped).freeze(),this},h.prototype.get=function(e){for(var t=this._wrapped,n=0;n<e.length;n++)t=p(t).get(t,e[n]);return t},h.prototype.mod=function(e,t){var n=this._wrapped,r=a(n),s=p(n);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=s.mod(r,e[0],t);else{var i=e[0],o=e.slice(1);r[i]=h(n[i]).mod(o,t).freeze(),this._wrapped=r}return this},h.prototype.merge=function(e,t){return this._wrapped=h(this._wrapped).mod(e,(function(e){return i(e,t)})).freeze(),this},h.prototype.del=function(e){var t=this._wrapped,n=p(t);if(1===e.length)this._wrapped=n.del(t,e[0]);else{var r=e[0],s=e.slice(1),i=a(t);i[r]=h(t[r]).del(s).freeze(),this._wrapped=i}return this},h.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=h},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var r=e.splice();return r[t]=n,r},mod:function(e,t,n){var r=e.slice();return r[t]=n(e[t]),r},del:function(e,t){var n=e.slice();return n.splice(t,1),n}}},function(e,t,n){var r=n(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var a=r(e);return a[t]=n,a},mod:function(e,t,n){var a=r(e);return a[t]=n(e[t]),a},del:function(e,t){var n=r(e);return delete n[t],n}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var r=e.splice();return r[t]=n,r},mod:function(e,t,n){var r=e.splice();return r[t]=n(e[t]),r},del:function(e,t){var n=e.slice();return n.splice(t),n}}}])};var $a=Xe(Ba.exports=Va()),Ha=["children","color","onClick"];class Ga extends G.Component{render(){var e=this.props,{children:t,color:n,onClick:r}=e,a=pe(e,Ha);return G.createElement("div",ce({className:re(Ya.baseButton,"green"===n&&Ya.green,"orange"===n&&Ya.orange),onClick:r},a),t)}}le(Ga,"propTypes",{children:J.node,color:J.oneOf(["orange","green"]),onClick:J.func}),le(Ga,"defaultProps",{children:null,color:"green",onClick:()=>{}});var Ya=ne.create({baseButton:{top:"0",fontSize:"11px",padding:"3px 10px",backgroundRepeat:"repeat-x",borderColor:"\n rgba(0, 0, 0, 0.1)\n rgba(0, 0, 0, 0.1)\n rgba(0, 0, 0, 0.25)\n ",color:"#ffffff",borderRadius:"3px",lineHeight:"15px",cursor:"pointer",transition:"box-shadow ease-in-out 0.15s",appearance:"none",textDecoration:"none",textAlign:"center",":hover":{boxShadow:"0 1px 1px rgba(0, 0, 0, 0.35),\n inset 0 0 50px 5px rgba(255, 255, 255, 0.2)"}},green:{border:"1px solid #7fab07",backgroundColor:"#80ac07",backgroundImage:"linear-gradient(to bottom, #8aba08, #719807)",":hover":{borderBottomColor:"#547105",backgroundColor:"#719807"}},orange:{border:"1px solid #d45704",backgroundColor:"#d55704",backgroundImage:"linear-gradient(to bottom, #e35d04, #c04f03)",":hover":{borderBottomColor:"#983e03",backgroundColor:"#c04f03"}}}),Ka=["depth"],Xa=["shape","data","path","actions","name","controls"],Ja=["shape","data"],Za=["shape","data","path","actions"],Qa=["shape","data","path"],{InlineIcon:es}=t,{iconChevronDown:ts,iconTrash:ns}=p,{MultiRenderer:rs}=b;class as extends G.Component{constructor(){super(...arguments),le(this,"_handleSelectMode",(e=>{if(this.props.onChange){var t=e.target.value;this.props.onChange(t)}}))}render(){return G.createElement("label",null,"Mode:"," ",G.createElement("select",{value:this.props.currentMode,onChange:this._handleSelectMode},G.createElement("option",{value:"edit"},"Edit"),G.createElement("option",{value:"preview"},"Preview"),G.createElement("option",{value:"json"},"Dev-only JSON")))}}function ss(e){return e.replace(/[A-Z]/g,(e=>" "+e.toLowerCase()))}function is(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function os(e){return"s"===e.charAt(e.length-1)?e.slice(0,-1):e}function ls(e){return["_multi",...e]}var cs=e=>{var{depth:t}=e,n=pe(e,Ka),r=Math.min(t,5)+1,a="h".concat(r);return G.createElement(a,n)},ps=e=>{var{shape:t,data:n,path:r,actions:a,name:s,controls:i}=e,o=pe(e,Xa),l=s||ss(r[r.length-1]||""),c=G.createElement(ms,ce({},o,{shape:t,data:n,path:r,actions:a})),p=r.join(".");return"array"===t.type?G.createElement(us,{key:p,name:l,controls:i,path:r,shape:t,actions:a},c):"object"===t.type?G.createElement(ds,{key:p,name:l,controls:i,path:r},c):G.createElement(hs,{key:p,name:l,controls:i,path:r,shape:t},c)},hs=e=>{var{name:t,controls:n,children:r,path:a,shape:s}=e,i=("content"===s.type||"hint"===s.type)&&G.createElement("div",{className:re(xs.containerHeader)},G.createElement(cs,{depth:a.length,className:re(xs.containerTitle)},is(t)));return G.createElement("div",{className:re(xs.container)},G.createElement("span",{className:re(xs.row,xs.rowHeading)},G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:"pod-title "+re(xs.containerHeader)},G.createElement("div",{className:re(xs.containerTitle)},is(t)),n)),G.createElement("div",{className:re(xs.columnRight)},i)),r)},us=e=>{var{name:t,controls:n,children:r,path:a,shape:s,actions:i}=e;return G.createElement("div",{className:re(xs.container)},n&&G.createElement("div",{className:re(xs.columnLeft,xs.containerHeader)},n),G.createElement("div",null,r),G.createElement("div",{className:re(xs.columnLeft)},G.createElement("a",{href:"javascript:void 0",onClick:()=>i.addArrayElement(a,s.elementShape)},"Add a ",os(t))))},ds=e=>{var{name:t,controls:n,children:r,path:a}=e,s=G.createElement("div",{className:re(xs.containerHeader)},G.createElement(cs,{depth:a.length,className:re(xs.containerTitle)},is(t)),n),i=(t||n)&&G.createElement("div",{className:re(xs.containerHeader,xs.previewCollectionHeader)},G.createElement(cs,{depth:a.length,className:re(xs.containerTitle)},is(t))),o=s&&i;return G.createElement("div",{className:re(xs.container)},o&&G.createElement("span",{className:re(xs.row)},G.createElement("div",{className:re(xs.columnLeft)},s),G.createElement("div",{className:re(xs.columnRight)},i)),G.createElement("div",{className:re(a.length>0&&xs.contentIndent)},r))},ms=e=>{var{shape:t,data:n}=e,r=pe(e,Ja);return"content"===t.type?G.createElement(fs,ce({shape:t,data:n},r)):"hint"===t.type?G.createElement(vs,ce({shape:t,data:n},r)):"tags"===t.type?G.createElement(ys,ce({shape:t,data:n},r)):"array"===t.type?G.createElement(bs,ce({shape:t,data:n},r)):"object"===t.type?G.createElement(Es,ce({shape:t,data:n},r)):null},gs=e=>class extends G.Component{constructor(){super(...arguments),le(this,"stickynessTimer",void 0),le(this,"state",{sticky:!1}),le(this,"updateStickiness",(()=>{var e=te.findDOMNode(this).offsetHeight>window.innerHeight;e!==this.state.sticky&&this.setState({sticky:e})}))}componentDidMount(){this.stickynessTimer=setInterval(this.updateStickiness,1e3),this.updateStickiness()}componentWillUnmount(){clearInterval(this.stickynessTimer)}render(){return G.createElement(e,ce({},this.props,{sticky:this.state.sticky}))}},fs=gs((e=>{var{data:t,path:n,actions:r,apiOptions:a,renderers:s,sticky:i}=e,o=G.createElement("div",{className:"framework-perseus"},$a(s).get(n));return G.createElement("span",null,G.createElement("div",{className:re(xs.row)},G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:re(i&&xs.sticky)},G.createElement(Sr,ce({},t,{onChange:e=>r.mergeValueAtPath(n,e),apiOptions:a})))),G.createElement("div",{className:re(xs.columnRight)},G.createElement("div",{className:re(i&&xs.sticky)},o))))})),vs=gs((e=>{var{data:t,path:n,actions:r,apiOptions:a,renderers:s,sticky:i}=e,o=G.createElement("div",{className:"framework-perseus"},$a(s).get(n));return G.createElement("div",{className:re(xs.row)},G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:re(i&&xs.sticky)},G.createElement(Ta,ce({},t,{className:re(xs.hintEditor),onChange:e=>r.mergeValueAtPath(n,e),apiOptions:a,showTitle:!1,showRemoveButton:!1,showMoveButtons:!1,onRemove:()=>{},onMove:e=>{},isFirst:!0,isLast:!0})))),G.createElement("div",{className:re(xs.columnRight)},G.createElement("div",{className:re(i&&xs.sticky)},o)))})),ys=e=>{var{data:t,path:n,actions:r,apiOptions:a}=e,{GroupMetadataEditor:s}=a;return null==s?null:G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:re(xs.tagsEditor)},G.createElement(s,{value:t,onChange:e=>r.setValueAtPath(n,e),showTitle:!1})))},bs=e=>{var{shape:t,data:n,path:r,actions:a}=e,s=pe(e,Za),i=os(ss(r[r.length-1])),o=t.elementShape.type,l="content"===o||"hint"===o,c=n.map(((e,o)=>{var c=r.concat(o),p=[o>0&&G.createElement("div",{key:"moveArrayElementUp",className:re(xs.control)},G.createElement(Ga,{color:"orange",title:"Move up",onClick:()=>a.moveArrayElementUp(c)},G.createElement("div",{className:re(xs.verticalFlip)},G.createElement(es,ts)))),o<n.length-1&&G.createElement("div",{key:"moveArrayElementDown",className:re(xs.control)},G.createElement(Ga,{color:"orange",title:"Move down",onClick:()=>a.moveArrayElementDown(c)},G.createElement(es,ts))),G.createElement("div",{key:"removeArrayElement",className:re(xs.control)},G.createElement(Ga,{color:"orange",title:"Delete",onClick:()=>a.removeArrayElement(c)},G.createElement(es,ns)))];return G.createElement("div",{key:o,className:re(xs.arrayElement,!l&&xs.arrayElementAndNotLeaf)},G.createElement(ps,ce({},s,{key:o,shape:t.elementShape,data:e,path:c,actions:a,name:"".concat(i," ").concat(o+1),controls:p})))}));return G.createElement("div",null,c)},Es=e=>{var{shape:t,data:n,path:r}=e,a=pe(e,Qa),s=Object.keys(t.shape).map((e=>G.createElement("div",{key:e,className:re(xs.objectElement)},G.createElement(ps,ce({},a,{shape:t.shape[e],data:n[e],path:r.concat(e)})))));return G.createElement("div",null,s)};class ws extends G.Component{constructor(){super(...arguments),le(this,"layout",void 0),le(this,"_renderLayout",(()=>{var{Layout:e,apiOptions:t,item:n}=this.props;return G.createElement(e,{ref:e=>this.layout=e,item:n,apiOptions:t})})),le(this,"_renderJson",(()=>G.createElement("div",null,G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})}),G.createElement(de,{multiLine:!0,value:this.props.item,onChange:e=>this.props.onChange({item:e})})))),le(this,"_renderPreview",(()=>G.createElement("div",null,G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})}),this._renderLayout()))),le(this,"mergeValueAtPath",((e,t)=>{this.props.onChange({item:$a(this.props.item).merge(ls(e),t).freeze()})})),le(this,"setValueAtPath",((e,t)=>{this.props.onChange({item:$a(this.props.item).set(ls(e),t).freeze()})})),le(this,"addArrayElement",((e,t)=>{var n=$a(this.props.item).get(ls(e)).length,r=e.concat(n),a=g(t);this.props.onChange({item:$a(this.props.item).set(ls(r),a).freeze()})})),le(this,"removeArrayElement",(e=>{this.props.onChange({item:$a(this.props.item).del(ls(e)).freeze()})})),le(this,"moveArrayElementDown",(e=>{var t=e[e.length-1]+1,n=e.slice(0,-1).concat(t),r=$a(this.props.item).get(ls(e)),a=$a(this.props.item).get(ls(n));this.props.onChange({item:$a(this.props.item).set(ls(e),a).set(ls(n),r).freeze()})})),le(this,"moveArrayElementUp",(e=>{var t=e[e.length-1],n=e.slice(0,-1).concat(t-1);this.moveArrayElementDown(n)})),le(this,"_renderEdit",(()=>{var e=oe(oe({},u.defaults),this.props.apiOptions),{item:t}=this.props,n=this.props.Layout.shape;return G.createElement("div",{className:"perseus-multirenderer-editor"},G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})}),G.createElement(rs,{item:t,shape:n,apiOptions:e},(r=>{var{renderers:a}=r;return G.createElement(ps,{shape:n,data:m(t),path:[],actions:this,apiOptions:e,renderers:a})})))})),le(this,"score",(()=>{if(this.layout)return this.layout.score()})),le(this,"getSerializedState",(()=>{if(this.layout)return this.layout.getSerializedState()})),le(this,"restoreSerializedState",(e=>{this.layout&&this.layout.restoreSerializedState(e)})),le(this,"_renderContent",(()=>{switch(this.props.editorMode){case"json":return this._renderJson();case"preview":return this._renderPreview();case"edit":return this._renderEdit();default:return G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})})}}))}render(){return G.createElement("div",{id:"perseus"},this._renderContent())}}var xs=ne.create({container:{},editor:{width:"100%"},treePreview:{position:"relative"},verticalFlip:{transform:"scaleY(-1)"},control:{marginLeft:12},containerHeader:{alignItems:"flex-end",display:"flex",flexDirection:"row"},previewCollectionHeader:{marginBottom:16},containerTitle:{flexGrow:1,margin:0},contentIndent:{marginLeft:8},hintEditor:{paddingBottom:0},arrayElement:{marginBottom:16},arrayElementAndNotLeaf:{borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc",paddingTop:16}},objectElement:{marginBottom:16},tagsEditor:{border:"1px solid #ddd",padding:"5px 10px"},row:{display:"flex",position:"relative"},columnLeft:{width:360,marginRight:30,position:"relative"},columnRight:{flex:1,marginLeft:30,position:"relative"},sticky:{position:"sticky",top:33},rowHeading:{position:"sticky",backgroundColor:"white",width:"100%",zIndex:101,top:-1}}),Cs=Z({displayName:"StatefulArticleEditor",getInitialState:function(){return X({}).extend(this.props,{mode:"edit",onChange:this.handleChange,ref:"editor",screen:"phone"})},componentDidMount:function(){this._isMounted=!0},UNSAFE_componentWillReceiveProps:function(e){this.setState(X(e).omit("onChange","ref"))},componentWillUnmount:function(){this._isMounted=!1},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(){return this.refs.editor.serialize()},handleChange:function(e,t){this._isMounted&&this.setState(e,t)},scorePreview:function(){return this.refs.editor.scorePreview()},render:function(){var{mode:e,screen:t}=this.state;return G.createElement("div",null,G.createElement("div",{style:ks.controlBar},G.createElement("span",{style:ks.controls},"Mode:"," ",G.createElement("span",{onClick:()=>this.setState({mode:"edit"}),style:"edit"===e?ks.controlSelected:ks.control},"EDIT")," | ",G.createElement("span",{onClick:()=>this.setState({mode:"preview"}),style:"preview"===e?ks.controlSelected:ks.control},"PREVIEW")," | ",G.createElement("span",{onClick:()=>this.setState({mode:"json"}),style:"json"===e?ks.controlSelected:ks.control},"JSON")),G.createElement("span",{style:ks.controls},"Screen:"," ",G.createElement("span",{onClick:()=>this.setState({screen:"phone"}),style:"phone"===t?ks.controlSelected:ks.control},"PHONE")," | ",G.createElement("span",{onClick:()=>this.setState({screen:"tablet"}),style:"tablet"===t?ks.controlSelected:ks.control},"TABLET")," | ",G.createElement("span",{onClick:()=>this.setState({screen:"desktop"}),style:"desktop"===t?ks.controlSelected:ks.control},"DESKTOP"))),G.createElement("div",{style:ks.editor},G.createElement(zr,this.state)))}}),ks={controlBar:{marginBottom:25,marginTop:5},controls:{marginRight:10},controlSelected:{cursor:"default",fontWeight:700},control:{cursor:"pointer"},editor:{marginTop:-20}},Ss=Z({displayName:"StatefulEditorPage",propTypes:{componentClass:J.func},getDefaultProps:function(){return{componentClass:Ra}},render:function(){var e=this.props.componentClass;return G.createElement(e,this.state)},getInitialState:function(){return X({}).extend(X.omit(this.props,"componentClass"),{onChange:this.handleChange,ref:"editor"})},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},UNSAFE_componentWillReceiveProps:function(e){this.setState(X(e).pick("apiOptions","imageUploader","developerMode","problemNum","previewDevice","frameSource"))},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(){return this.refs.editor.serialize()},handleChange:function(e,t){this._isMounted&&this.setState(e,t)},scorePreview:function(){return this.refs.editor.scorePreview()}}),{PropCheckBox:Ns,TextListEditor:Ts}=t,_s=w.widget;class Os extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement(Ns,{label:"Randomize item order",labelAlignment:"right",randomizeItems:this.props.randomizeItems,onChange:this.props.onChange})),"Categories:",G.createElement(Ts,{options:this.props.categories,onChange:e=>{this.change("categories",e)},layout:"horizontal"}),"Items:",G.createElement(Ts,{options:this.props.items,onChange:e=>{this.change({items:e,values:X.first(this.props.values,e.length)})},layout:"vertical"}),G.createElement(_s,{apiOptions:this.props.apiOptions,items:this.props.items,categories:this.props.categories,values:this.props.values,onChange:e=>{this.props.onChange(e)},trackInteraction:function(){}}))}}le(Os,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,items:J.arrayOf(J.string),categories:J.arrayOf(J.string),values:J.arrayOf(J.number),randomizeItems:J.bool})),le(Os,"widgetName","categorizer"),le(Os,"defaultProps",{items:[],categories:[],values:[],randomizeItems:!1});class Ms extends G.Component{constructor(e){super(e),le(this,"handleChange",(e=>{this.setState({value:e.target.value})})),le(this,"handleBlur",(e=>{this.props.onChange(e.target.value)})),this.state={value:this.props.value}}UNSAFE_componentWillReceiveProps(e){this.setState({value:e.value})}render(){return G.createElement("input",{className:this.props.className,style:this.props.style,type:"text",value:this.state.value,onChange:this.handleChange,onBlur:this.handleBlur})}}var{InfoTip:As,PropCheckBox:Ps}=t;class Ds extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("fieldset",{className:"pair-editor"},G.createElement("label",null,"Name:"," ",G.createElement(Ms,{value:this.props.name,onChange:this.change("name")})),G.createElement("label",null," ","Value:"," ",G.createElement(Ms,{value:this.props.value,onChange:this.change("value")})))}}le(Ds,"propTypes",oe(oe({},x.propTypes),{},{name:J.string,value:J.string})),le(Ds,"defaultProps",{name:"",value:""});class Is extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handlePairChange",((e,t)=>{var n=this.props.pairs.slice();n[e]=t;var r=n[n.length-1];r.name&&r.value&&n.push({name:"",value:""}),this.change("pairs",n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=X.map(this.props.pairs,((e,t)=>G.createElement(Ds,{key:t,name:e.name,value:e.value,onChange:this.handlePairChange.bind(this,t)})));return G.createElement("div",null,e)}}le(Is,"propTypes",oe(oe({},x.propTypes),{},{pairs:J.arrayOf(J.shape({name:J.string,value:J.string})).isRequired}));var Rs=/khanacademy\.org\/computer-programming\/[^\/]+\/(\d+)/;class zs extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"_handleSettingsChange",(e=>{this.change({settings:e.pairs})})),le(this,"_handleProgramIDChange",(e=>{var t,n;t=e,(n=Rs.exec(t))&&(t=n[1]),e=t;var{isDevServer:r,InitialRequestUrl:s}=o.getDependencies(),l=r?s.origin:"https://www.khanacademy.org",c="".concat(l,"/api/internal/scratchpads/").concat(e);Q.getJSON(c).done((t=>{var n=t.userAuthoredContentType;this.change({width:t.width,height:t.height,programID:e,programType:n})})).fail(((t,n,r)=>{a.error("Error retrieving scratchpad info for program ID ",i.TransientService,{cause:r,loggedMetadata:{textStatus:n,programID:e}}),this.change({width:400,height:400,programID:e,programType:null})}))})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,"Url or Program ID:"," ",G.createElement(Ms,{value:this.props.programID,onChange:this._handleProgramIDChange})),G.createElement("br",null),G.createElement(Ps,{label:"Show Editor",showEditor:this.props.showEditor,onChange:this.props.onChange}),G.createElement(As,null,'If you show the editor, you should use the "full-width" alignment to make room for the width of the editor.'),G.createElement("br",null),G.createElement(Ps,{label:"Show Buttons",showButtons:this.props.showButtons,onChange:this.props.onChange}),G.createElement("br",null),G.createElement("label",null,"Settings:",G.createElement(Is,{name:"settings",pairs:this.props.settings,onChange:this._handleSettingsChange}),G.createElement(As,null,"Settings that you add here are available to the program as an object returned by ",G.createElement("code",null,"Program.settings()"))))}}le(zs,"propTypes",oe({},x.propTypes)),le(zs,"widgetName","cs-program"),le(zs,"defaultProps",{programID:"",programType:null,settings:[{name:"",value:""}],showEditor:!1,showButtons:!1,width:400,height:400});var{TextInput:Ls}=t;class Fs extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",{className:"perseus-widget-definition-editor"},G.createElement("a",{href:"https://docs.google.com/document/d/1udaPef4imOfTMhmLDlWq4SM0mxL0r3YHFZE-5J1uGfo",target:"_blank"},"Definition style guide"),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Word to be defined:"," ",G.createElement(Ls,{value:this.props.togglePrompt,onChange:this.change("togglePrompt"),placeholder:"define me"}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.definition,widgetEnabled:!1,placeholder:"definition goes here",onChange:e=>{var t={};X.has(e,"content")&&(t.definition=e.content),this.change(t)}})))}}le(Fs,"propTypes",oe(oe({},x.propTypes),{},{togglePrompt:J.string,definition:J.string,apiOptions:J.any})),le(Fs,"widgetName","definition"),le(Fs,"defaultProps",{togglePrompt:"",definition:""});var{InfoTip:qs,InlineIcon:Us}=t,{iconPlus:Ws,iconTrash:Vs}=p;class js extends G.Component{constructor(){super(...arguments),le(this,"onPlaceholderChange",(e=>{var t=e.target.value;this.props.onChange({placeholder:t})})),le(this,"onCorrectChange",(e=>{var t=X.map(this.props.choices,(function(t,n){return X.extend({},t,{correct:n===e})}));this.props.onChange({choices:t})})),le(this,"onContentChange",((e,t)=>{var n=this.props.choices.slice(),r=X.clone(n[e]);r.content=t.target.value,n[e]=r,this.props.onChange({choices:n})})),le(this,"addChoice",(e=>{e.preventDefault();var t=this.props.choices;this.props.onChange({choices:t.concat([{content:"",correct:!1}])},this.focus.bind(this,t.length))})),le(this,"removeChoice",((e,t)=>{t.preventDefault();var n=X(this.props.choices).clone();n.splice(e,1),this.props.onChange({choices:n})})),le(this,"focus",(e=>(te.findDOMNode(this.refs["editor"+e]).focus(),!0))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=X.uniqueId("perseus_dropdown_");return G.createElement("div",{className:"perseus-widget-dropdown"},G.createElement("div",{className:"dropdown-info"},"Dropdown",G.createElement(qs,null,G.createElement("p",null,"The drop down is useful for making inequalities in a custom format. We normally use the symbols ","<",","," ",">",', ≤, ≥ (in that order) which you can copy into the choices. When possible, use the "multiple choice" answer type instead.'))),G.createElement("div",{className:"dropdown-placeholder"},G.createElement("input",{type:"text",placeholder:"Placeholder value",value:this.props.placeholder,onChange:this.onPlaceholderChange}),G.createElement(qs,null,G.createElement("p",null,"This value will appear as the drop down default. It should give the user some indication of the values available in the drop down itself, e.g., Yes/No/Maybe."))),G.createElement("div",{className:"clearfix"}),G.createElement("ul",{className:"dropdown-choices"},this.props.choices.map((function(t,n){var r=t.correct?"correct":"incorrect";return G.createElement("li",{key:""+n},G.createElement("div",null,G.createElement("input",{ref:"radio"+n,type:"radio",name:e,checked:t.correct?"checked":"",onChange:this.onCorrectChange.bind(this,n),value:n}),G.createElement("input",{type:"text",ref:"editor"+n,onChange:this.onContentChange.bind(this,n),className:r,value:t.content}),G.createElement("a",{href:"#",className:"simple-button orange",onClick:this.removeChoice.bind(this,n)},G.createElement("span",{className:"remove-choice"},G.createElement(Us,Vs)))))}),this)),G.createElement("div",{className:"add-choice-container"},G.createElement("a",{href:"#",className:"simple-button orange",onClick:this.addChoice},G.createElement(Us,Ws)," Add a choice"," ")))}}le(js,"propTypes",{choices:J.arrayOf(J.shape({content:J.string,correct:J.bool})),placeholder:J.string}),le(js,"widgetName","dropdown"),le(js,"defaultProps",{placeholder:"",choices:[{content:"",correct:!1}]});var Bs=X,$s=Math.pow(2,-42),Hs={DEFAULT_TOLERANCE:1e-9,EPSILON:$s,is:function(e){return Bs.isNumber(e)&&!Bs.isNaN(e)},equal:function(e,t,n){return null==e||null==t?e===t:e===t||(null==n&&(n=1e-9),Math.abs(e-t)<n)},sign:function(e,t){return Hs.equal(e,0,t)?0:Math.abs(e)/e},isInteger:function(e,t){return Hs.equal(Math.round(e),e,t)},round:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n},roundTo:function(e,t){return Math.round(e/t)*t},floorTo:function(e,t){return Math.floor(e/t)*t},ceilTo:function(e,t){return Math.ceil(e/t)*t},toFraction:function(e,t,n){n=n||1e3,t=t||$s;for(var r=[1,0],a=[0,1],s=Math.floor(e),i=e-s;a[0]<=n;){if(Hs.equal(r[0]/a[0],e,t))return[r[0],a[0]];r=[s*r[0]+r[1],r[0]],a=[s*a[0]+a[1],a[0]],i=1/i-(s=Math.floor(1/i))}return[e,1]}},Gs=Hs,Ys=X,Ks=Gs;function Xs(e){return Ys.reduce(e,(function(e,t){return e+t}),0)}function Js(e){return Ys.reduce(e,(function(e,t){return e*t}),1)}var Zs={is:function(e,t){return!!Ys.isArray(e)&&((void 0===t||e.length===t)&&Ys.all(e,Ks.is))},normalize:function(e){return Zs.scale(e,1/Zs.length(e))},length:function(e){return Math.sqrt(Zs.dot(e,e))},dot:function(e,t){var n=Ys.toArray(arguments),r=Ys.zip.apply(Ys,n),a=Ys.map(r,Js);return Xs(a)},add:function(){var e=Ys.toArray(arguments),t=Ys.zip.apply(Ys,e);return Ys.map(t,Xs)},subtract:function(e,t){return Ys.map(Ys.zip(e,t),(function(e){return e[0]-e[1]}))},negate:function(e){return Ys.map(e,(function(e){return-e}))},scale:function(e,t){return Ys.map(e,(function(e){return e*t}))},equal:function(e,t,n){return Ys.all(Ys.zip(e,t),(function(e){return Ks.equal(e[0],e[1],n)}))},codirectional:function(e,t,n){return!(!Ks.equal(Zs.length(e),0,n)&&!Ks.equal(Zs.length(t),0,n))||(e=Zs.normalize(e),t=Zs.normalize(t),Zs.equal(e,t,n))},collinear:function(e,t,n){return Zs.codirectional(e,t,n)||Zs.codirectional(e,Zs.negate(t),n)},polarRadFromCart:function(e){var t=Zs.length(e),n=Math.atan2(e[1],e[0]);return n<0&&(n+=2*Math.PI),[t,n]},polarDegFromCart:function(e){var t=Zs.polarRadFromCart(e);return[t[0],180*t[1]/Math.PI]},cartFromPolarRad:function(e,t){return Ys.isUndefined(t)&&(t=e[1],e=e[0]),[e*Math.cos(t),e*Math.sin(t)]},cartFromPolarDeg:function(e,t){return Ys.isUndefined(t)&&(t=e[1],e=e[0]),Zs.cartFromPolarRad(e,t*Math.PI/180)},rotateRad:function(e,t){var n=Zs.polarRadFromCart(e),r=n[1]+t;return Zs.cartFromPolarRad(n[0],r)},rotateDeg:function(e,t){var n=Zs.polarDegFromCart(e),r=n[1]+t;return Zs.cartFromPolarDeg(n[0],r)},angleRad:function(e,t){return Math.acos(Zs.dot(e,t)/(Zs.length(e)*Zs.length(t)))},angleDeg:function(e,t){return 180*Zs.angleRad(e,t)/Math.PI},projection:function(e,t){var n=Zs.dot(e,t)/Zs.dot(t,t);return Zs.scale(t,n)},round:function(e,t){return Ys.map(e,(function(e,n){return Ks.round(e,t[n]||t)}))},roundTo:function(e,t){return Ys.map(e,(function(e,n){return Ks.roundTo(e,t[n]||t)}))},floorTo:function(e,t){return Ys.map(e,(function(e,n){return Ks.floorTo(e,t[n]||t)}))},ceilTo:function(e,t){return Ys.map(e,(function(e,n){return Ks.ceilTo(e,t[n]||t)}))}},Qs=Zs,ei=Qs,ti=Gs,ni={rotateRad:function(e,t,n){return void 0===n?ei.rotateRad(e,t):ei.add(n,ei.rotateRad(ei.subtract(e,n),t))},rotateDeg:function(e,t,n){return void 0===n?ei.rotateDeg(e,t):ei.add(n,ei.rotateDeg(ei.subtract(e,n),t))},distanceToPoint:function(e,t){return ei.length(ei.subtract(e,t))},distanceToLine:function(e,t){var n=ei.subtract(t[1],t[0]),r=ei.subtract(e,t[0]),a=ei.projection(r,n),s=ei.subtract(a,r);return ei.length(s)},reflectOverLine:function(e,t){var n=ei.subtract(t[1],t[0]),r=ei.subtract(e,t[0]),a=ei.projection(r,n),s=ei.subtract(ei.scale(a,2),r);return ei.add(t[0],s)},compare:function(e,t,n){if(e.length!==t.length)return e.length-t.length;for(var r=0;r<e.length;r++)if(!ti.equal(e[r],t[r],n))return e[r]-t[r];return 0}};X.extend(ni,{is:ei.is,addVector:ei.add,addVectors:ei.add,subtractVector:ei.subtract,equal:ei.equal,polarRadFromCart:ei.polarRadFromCart,polarDegFromCart:ei.polarDegFromCart,cartFromPolarRad:ei.cartFromPolarRad,cartFromPolarDeg:ei.cartFromPolarDeg,round:ei.round,roundTo:ei.roundTo,floorTo:ei.floorTo,ceilTo:ei.ceilTo});var ri=ni,ai=Qs,si={distanceToPoint:function(e,t){return ri.distanceToLine(t,e)},reflectPoint:function(e,t){return ri.reflectOverLine(t,e)},midpoint:function(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]},equal:function(e,t,n){var r=ai.subtract(e[1],e[0]),a=ai.subtract(t[1],t[0]);if(!ai.collinear(r,a,n))return!1;if(ri.equal(e[0],t[0]))return!0;var s=ai.subtract(t[0],e[0]);return ai.collinear(r,s,n)}},ii=Qs,oi=ni,li={number:Gs,vector:Qs,point:ni,line:si,ray:{equal:function(e,t,n){var r=ii.subtract(e[1],e[0]),a=ii.subtract(t[1],t[0]),s=oi.equal(e[0],t[0]),i=ii.codirectional(r,a,n);return s&&i}}},{Graphie:ci}=t,pi=ci.MovablePoint;class hi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"getUserInput",(()=>k.getUserInput.call(this))),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"movePoint",(e=>{this.change({coord:e})})),le(this,"_getGridConfig",(e=>X.map(e.step,(function(t,n){return r.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])})))),le(this,"setupGraphie",((e,t)=>{var n=this._getGridConfig(t);e.graphInit({range:t.range,scale:X.pluck(n,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,tickStep:X.pluck(n,"tickStep"),labelStep:1,unityLabels:X.pluck(n,"unityLabel")}),e.label([0,t.range[1][1]],t.labels[1],"above")})),le(this,"simpleValidate",(e=>hi.validate(this.getUserInput(),e)))}static validate(e,t){return null==e.coord?{type:"invalid",message:null}:li.point.equal(e.coord,t.correct)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}}render(){return G.createElement(ci,{ref:"graphie",box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},G.createElement(pi,{pointSize:5,coord:this.props.coord||[0,0],constraints:[pi.constraints.snap(),pi.constraints.bound()],onMove:this.movePoint}))}}le(hi,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,graph:J.object.isRequired,coord:J.arrayOf(J.number)})),le(hi,"defaultProps",{coord:null,graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],valid:!0,backgroundImage:null,markings:"grid",showProtractor:!1}});var ui={name:"example-graphie-widget",displayName:"Example Graphie Widget",hidden:!0,widget:hi},di=ui.widget;class mi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleChange",(e=>{e.coord&&this.change({correct:e.coord})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement(di,{graph:this.props.graph,coord:this.props.correct,onChange:this.handleChange,apiOptions:this.props.apiOptions}))}}le(mi,"propTypes",oe({},x.propTypes)),le(mi,"widgetName","example-graphie-widget"),le(mi,"defaultProps",{correct:[4,4],graph:{box:[340,340],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],valid:!0,backgroundImage:null,markings:"grid",showProtractor:!1}});class gi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"handleAnswerChange",(e=>{this.change({correct:e.target.value})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,"Correct answer:",G.createElement("input",{value:this.props.correct,onChange:this.handleAnswerChange,ref:"input"})))}}le(gi,"propTypes",oe({},x.propTypes)),le(gi,"widgetName","example-widget"),le(gi,"defaultProps",{correct:""});var{TextInput:fi}=t;class vi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"state",{}),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",{className:"perseus-widget-explanation-editor"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Prompt to show explanation:"," ",G.createElement(fi,{value:this.props.showPrompt,onChange:this.change("showPrompt")}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Prompt to hide explanation:"," ",G.createElement(fi,{value:this.props.hidePrompt,onChange:this.change("hidePrompt")}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,widgetEnabled:!0,immutableWidgets:!1,onChange:e=>{var t={};X.has(e,"content")&&(t.explanation=e.content),X.has(e,"widgets")&&(t.widgets=e.widgets),this.change(t)}})))}}le(vi,"propTypes",oe(oe({},x.propTypes),{},{showPrompt:J.string,hidePrompt:J.string,explanation:J.string,widgets:J.object,apiOptions:J.any})),le(vi,"widgetName","explanation"),le(vi,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{}});var yi={exports:{}};
|
|
10
|
-
/*! KAS | https://github.com/Khan/KAS */!function(e){var t,n={};e.exports?(t=X,e.exports=n):(t=window._,window.KAS=n),function(e){var t=function(){var e=function(e,t,n,r){for(n=n||{},r=e.length;r--;n[e[r]]=t);return n},t=[1,7],n=[1,17],r=[1,13],a=[1,14],s=[1,15],i=[1,32],o=[1,22],l=[1,23],c=[1,24],p=[1,25],h=[1,26],u=[1,33],d=[1,27],m=[1,28],g=[1,29],f=[1,30],v=[1,20],y=[1,36],b=[1,37],E=[5,6,8,10,33,35,41,43,45],w=[1,39],x=[1,40],C=[5,6,8,10,12,14,16,19,21,22,28,29,30,31,32,33,34,35,37,39,41,42,43,44,45,46],k=[10,16,19,21,22,28,29,30,31,32,34,37,39,42,43,44,46],S=[5,6,8,10,12,14,16,18,19,21,22,28,29,30,31,32,33,34,35,37,39,41,42,43,44,45,46],N={trace:function(){},yy:{},symbols_:{error:2,equation:3,expression:4,SIGN:5,EOF:6,additive:7,"+":8,multiplicative:9,"-":10,triglog:11,"*":12,negative:13,"/":14,trig:15,TRIG:16,trigfunc:17,"^":18,TRIGINV:19,logbase:20,ln:21,log:22,_:23,subscriptable:24,power:25,primitive:26,variable:27,VAR:28,CONST:29,INT:30,FLOAT:31,"{":32,"}":33,"(":34,")":35,function:36,FUNC:37,invocation:38,sqrt:39,"[":40,"]":41,abs:42,"|":43,"LEFT|":44,"RIGHT|":45,FRAC:46,$accept:0,$end:1},terminals_:{2:"error",5:"SIGN",6:"EOF",8:"+",10:"-",12:"*",14:"/",16:"TRIG",18:"^",19:"TRIGINV",21:"ln",22:"log",23:"_",28:"VAR",29:"CONST",30:"INT",31:"FLOAT",32:"{",33:"}",34:"(",35:")",37:"FUNC",39:"sqrt",40:"[",41:"]",42:"abs",43:"|",44:"LEFT|",45:"RIGHT|",46:"FRAC"},productions_:[0,[3,4],[3,2],[3,1],[4,1],[7,3],[7,3],[7,1],[9,2],[9,3],[9,3],[9,1],[13,2],[13,1],[15,1],[17,1],[17,3],[17,1],[20,1],[20,1],[20,3],[11,2],[11,2],[11,1],[25,3],[25,1],[27,1],[24,3],[24,1],[24,1],[24,1],[24,1],[24,3],[24,3],[36,1],[38,4],[38,4],[38,7],[38,4],[38,3],[38,3],[38,4],[26,1],[26,1],[26,7]],performAction:function(e,t,n,r,a,s,i){var o=s.length-1;switch(a){case 1:return new r.Eq(s[o-3],s[o-2],s[o-1]);case 2:return s[o-1];case 3:return new r.Add([]);case 4:case 7:case 11:case 13:case 15:case 20:case 23:case 25:case 42:case 43:this.$=s[o];break;case 5:this.$=r.Add.createOrAppend(s[o-2],s[o]);break;case 6:this.$=r.Add.createOrAppend(s[o-2],r.Mul.handleNegative(s[o],"subtract"));break;case 8:this.$=r.Mul.fold(r.Mul.createOrAppend(s[o-1],s[o]));break;case 9:this.$=r.Mul.fold(r.Mul.createOrAppend(s[o-2],s[o]));break;case 10:this.$=r.Mul.fold(r.Mul.handleDivide(s[o-2],s[o]));break;case 12:this.$=r.Mul.handleNegative(s[o]);break;case 14:case 17:this.$=[e];break;case 16:this.$=s[o-2].concat(s[o]);break;case 18:this.$=r.Log.natural();break;case 19:this.$=r.Log.common();break;case 21:this.$=r.Trig.create(s[o-1],s[o]);break;case 22:this.$=r.Log.create(s[o-1],s[o]);break;case 24:this.$=new r.Pow(s[o-2],s[o]);break;case 26:case 34:this.$=e;break;case 27:this.$=new r.Var(s[o-2],s[o]);break;case 28:this.$=new r.Var(s[o]);break;case 29:this.$=new r.Const(e.toLowerCase());break;case 30:this.$=r.Int.create(Number(e));break;case 31:this.$=r.Float.create(Number(e));break;case 32:this.$=s[o-1].completeParse();break;case 33:this.$=s[o-1].completeParse().addHint("parens");break;case 35:case 36:this.$=r.Pow.sqrt(s[o-1]);break;case 37:this.$=new r.Pow.nthroot(s[o-1],s[o-4]);break;case 38:case 39:case 40:this.$=new r.Abs(s[o-1]);break;case 41:this.$=new r.Func(s[o-3],s[o-1]);break;case 44:this.$=r.Mul.handleDivide(s[o-4],s[o-1])}},table:[{3:1,4:2,6:[1,3],7:4,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{1:[3]},{5:[1,34],6:[1,35]},{1:[2,3]},e([5,6],[2,4],{8:y,10:b}),e(E,[2,7],{17:9,20:10,25:11,15:12,26:16,24:18,38:19,27:21,36:31,11:38,12:w,14:x,16:n,19:r,21:a,22:s,28:i,29:o,30:l,31:c,32:p,34:h,37:u,39:d,42:m,44:f,46:v}),e(C,[2,11]),{10:t,11:8,13:41,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,13]),{10:t,11:8,13:42,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{10:t,11:8,13:43,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,23]),e(k,[2,15],{18:[1,44]}),e(k,[2,17]),e(k,[2,18]),e(k,[2,19],{23:[1,45]}),e(C,[2,25],{18:[1,46]}),e([10,16,18,19,21,22,28,29,30,31,32,34,37,39,42,43,44,46],[2,14]),e(S,[2,42]),e(S,[2,43]),{32:[1,47]},e(S,[2,28],{23:[1,48]}),e(S,[2,29]),e(S,[2,30]),e(S,[2,31]),{7:49,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:50,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{32:[1,52],34:[1,51],40:[1,53]},{34:[1,54]},{7:55,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:56,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{34:[1,57]},e([5,6,8,10,12,14,16,18,19,21,22,23,28,29,30,31,32,33,34,35,37,39,41,42,43,44,45,46],[2,26]),{34:[2,34]},{4:58,7:4,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{1:[2,2]},{9:59,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{9:60,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,8]),{10:t,11:8,13:61,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{10:t,11:8,13:62,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,12]),e(C,[2,21]),e(C,[2,22]),{10:t,11:8,13:63,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{24:64,27:21,28:i,29:o,30:l,31:c,32:p,34:h},{10:t,11:8,13:65,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:66,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{24:67,27:21,28:i,29:o,30:l,31:c,32:p,34:h},{8:y,10:b,33:[1,68]},{8:y,10:b,35:[1,69]},{7:70,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:71,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:72,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:73,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{8:y,10:b,43:[1,74]},{8:y,10:b,45:[1,75]},{7:76,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{6:[1,77]},e(E,[2,5],{17:9,20:10,25:11,15:12,26:16,24:18,38:19,27:21,36:31,11:38,12:w,14:x,16:n,19:r,21:a,22:s,28:i,29:o,30:l,31:c,32:p,34:h,37:u,39:d,42:m,44:f,46:v}),e(E,[2,6],{17:9,20:10,25:11,15:12,26:16,24:18,38:19,27:21,36:31,11:38,12:w,14:x,16:n,19:r,21:a,22:s,28:i,29:o,30:l,31:c,32:p,34:h,37:u,39:d,42:m,44:f,46:v}),e(C,[2,9]),e(C,[2,10]),e(k,[2,16]),e(k,[2,20]),e(C,[2,24]),{8:y,10:b,33:[1,78]},e(S,[2,27]),e(S,[2,32]),e(S,[2,33]),{8:y,10:b,35:[1,79]},{8:y,10:b,33:[1,80]},{8:y,10:b,41:[1,81]},{8:y,10:b,35:[1,82]},e(S,[2,39]),e(S,[2,40]),{8:y,10:b,35:[1,83]},{1:[2,1]},{32:[1,84]},e(S,[2,35]),e(S,[2,36]),{32:[1,85]},e(S,[2,38]),e(S,[2,41]),{7:86,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:87,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{8:y,10:b,33:[1,88]},{8:y,10:b,33:[1,89]},e(S,[2,44]),e(S,[2,37])],defaultActions:{3:[2,3],33:[2,34],35:[2,2],77:[2,1]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],a=[],s=this.table,i="",o=0,l=0,c=2,p=1,h=a.slice.call(arguments,1),u=Object.create(this.lexer),d={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(d.yy[m]=this.yy[m]);u.setInput(e,d.yy),d.yy.lexer=u,d.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var g=u.yylloc;a.push(g);var f=u.options&&u.options.ranges;function v(){var e;return"number"!=typeof(e=u.lex()||p)&&(e=t.symbols_[e]||e),e}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var y,b,E,w,x,C,k,S,N={};;){if(b=n[n.length-1],this.defaultActions[b]?E=this.defaultActions[b]:(null==y&&(y=v()),E=s[b]&&s[b][y]),void 0===E||!E.length||!E[0]){var T="";for(x in S=[],s[b])this.terminals_[x]&&x>c&&S.push("'"+this.terminals_[x]+"'");T=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(o+1)+": Unexpected "+(y==p?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:u.match,token:this.terminals_[y]||y,line:u.yylineno,loc:g,expected:S})}if(E[0]instanceof Array&&E.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+y);switch(E[0]){case 1:n.push(y),r.push(u.yytext),a.push(u.yylloc),n.push(E[1]),y=null,l=u.yyleng,i=u.yytext,o=u.yylineno,g=u.yylloc;break;case 2:if(C=this.productions_[E[1]][1],N.$=r[r.length-C],N._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},f&&(N._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(N,[i,l,o,d.yy,E[1],r,a].concat(h))))return w;C&&(n=n.slice(0,-1*C*2),r=r.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[E[1]][0]),r.push(N.$),a.push(N._$),k=s[n[n.length-2]][n[n.length-1]],n.push(k);break;case 3:return!0}}return!0}},T=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var s in a)this[s]=a[s];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),s=0;s<a.length;s++)if((n=this._input.match(this.rules[a[s]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,a[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,a[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0},performAction:function(e,t,n,r){switch(n){case 0:case 1:case 2:break;case 3:return"INT";case 4:return"FLOAT";case 5:case 15:return"^";case 6:case 7:case 8:case 9:return"*";case 10:case 11:return"/";case 12:case 13:return"-";case 14:return"+";case 16:case 18:return"(";case 17:case 19:return")";case 20:return"[";case 21:return"]";case 22:case 24:return"{";case 23:case 25:return"}";case 26:return"_";case 27:return"|";case 28:return"LEFT|";case 29:return"RIGHT|";case 30:return"!";case 31:return"SIGN";case 32:case 34:case 40:return t.yytext="<=","SIGN";case 33:case 35:case 41:return t.yytext=">=","SIGN";case 36:case 37:case 38:case 39:return t.yytext="<>","SIGN";case 42:case 43:return"FRAC";case 44:return"sqrt";case 45:return"abs";case 46:return"ln";case 47:return"log";case 48:case 49:case 50:case 51:return"TRIG";case 52:return t.yytext="sin","TRIG";case 53:return t.yytext="cos","TRIG";case 54:return t.yytext="tan","TRIG";case 55:return t.yytext="csc","TRIG";case 56:return t.yytext="sec","TRIG";case 57:return t.yytext="cot","TRIG";case 58:return t.yytext="arcsin","TRIG";case 59:return t.yytext="arccos","TRIG";case 60:return t.yytext="arctan","TRIG";case 61:return t.yytext="arccsc","TRIG";case 62:return t.yytext="arcsec","TRIG";case 63:return t.yytext="arccot","TRIG";case 64:case 65:return"TRIGINV";case 66:return t.yytext="sinh","TRIG";case 67:return t.yytext="cosh","TRIG";case 68:case 71:return t.yytext="tanh","TRIG";case 69:return t.yytext="csch","TRIG";case 70:return t.yytext="sech","TRIG";case 72:return"CONST";case 73:case 74:return t.yytext="pi","CONST";case 75:case 78:return"VAR";case 76:case 77:return t.yytext="theta","VAR";case 79:case 80:return t.yytext="phi","VAR";case 81:return e.symbolLexer(t.yytext);case 82:return"EOF";case 83:return"INVALID";case 84:console.log(t.yytext)}},rules:[/^(?:\s+)/,/^(?:\\space)/,/^(?:\\ )/,/^(?:[0-9]+\.?)/,/^(?:([0-9]+)?\.[0-9]+)/,/^(?:\*\*)/,/^(?:\*)/,/^(?:\\cdot|·)/,/^(?:\\times|×)/,/^(?:\\ast)/,/^(?:\/)/,/^(?:\\div|÷)/,/^(?:-)/,/^(?:−)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:\\left\()/,/^(?:\\right\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\\left\{)/,/^(?:\\right\})/,/^(?:_)/,/^(?:\|)/,/^(?:\\left\|)/,/^(?:\\right\|)/,/^(?:\!)/,/^(?:<=|>=|<>|<|>|=)/,/^(?:\\le)/,/^(?:\\ge)/,/^(?:\\leq)/,/^(?:\\geq)/,/^(?:=\/=)/,/^(?:\\ne)/,/^(?:\\neq)/,/^(?:≠)/,/^(?:≤)/,/^(?:≥)/,/^(?:\\frac)/,/^(?:\\dfrac)/,/^(?:sqrt|\\sqrt)/,/^(?:abs|\\abs)/,/^(?:ln|\\ln)/,/^(?:log|\\log)/,/^(?:sin|cos|tan)/,/^(?:csc|sec|cot)/,/^(?:sinh|cosh|tanh)/,/^(?:csch|sech|coth)/,/^(?:\\sin)/,/^(?:\\cos)/,/^(?:\\tan)/,/^(?:\\csc)/,/^(?:\\sec)/,/^(?:\\cot)/,/^(?:\\arcsin)/,/^(?:\\arccos)/,/^(?:\\arctan)/,/^(?:\\arccsc)/,/^(?:\\arcsec)/,/^(?:\\arccot)/,/^(?:arcsin|arccos|arctan)/,/^(?:arccsc|arcsec|arccot)/,/^(?:\\sinh)/,/^(?:\\cosh)/,/^(?:\\tanh)/,/^(?:\\csch)/,/^(?:\\sech)/,/^(?:\\coth)/,/^(?:pi)/,/^(?:π)/,/^(?:\\pi)/,/^(?:theta)/,/^(?:θ)/,/^(?:\\theta)/,/^(?:phi)/,/^(?:φ)/,/^(?:\\phi)/,/^(?:[a-zA-Z])/,/^(?:$)/,/^(?:.)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84],inclusive:!0}}};return e}();function _(){this.yy={}}return N.lexer=T,_.prototype=N,N.Parser=_,new _}();e.parser=t}(n),function(e){var t=function(){var e=function(e,t,n,r){for(n=n||{},r=e.length;r--;n[e[r]]=t);return n},t=[1,11],n=[1,9],r=[8,17],a=[6,11],s=[6,11,13,17],i={trace:function(){},yy:{},symbols_:{error:2,unitvalue:3,magnitude:4,unit:5,EOF:6,float:7,POW:8,int:9,multatoms:10,DIV:11,expatom:12,MUL:13,atom:14,"^":15,nat:16,ATOM:17,FLOAT:18,NAT:19,NEG:20,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",8:"POW",11:"DIV",13:"MUL",15:"^",17:"ATOM",18:"FLOAT",19:"NAT",20:"NEG"},productions_:[0,[3,3],[3,2],[4,3],[4,1],[5,3],[5,1],[10,3],[10,2],[10,1],[12,3],[12,1],[14,1],[7,1],[7,1],[16,1],[9,2],[9,1]],performAction:function(e,t,n,r,a,s,i){var o=s.length-1;switch(a){case 1:return{type:"unitMagnitude",magnitude:s[o-2],unit:s[o-1]};case 2:return{type:"unitStandalone",unit:s[o-1]};case 3:this.$=s[o-2]+"e"+s[o];break;case 4:case 13:case 14:case 15:case 17:this.$=s[o];break;case 5:this.$={num:s[o-2],denom:s[o]};break;case 6:this.$={num:s[o],denom:null};break;case 7:this.$=[s[o-2]].concat(s[o]);break;case 8:this.$=[s[o-1]].concat(s[o]);break;case 9:this.$=[s[o]];break;case 10:this.$={name:s[o-2],pow:s[o]};break;case 11:this.$={name:s[o],pow:1};break;case 12:this.$=e;break;case 16:this.$="-"+s[o]}},table:[{3:1,4:2,5:3,7:4,10:5,12:8,14:10,16:7,17:t,18:[1,6],19:n},{1:[3]},{5:12,10:5,12:8,14:10,17:t},{6:[1,13]},{8:[1,14],17:[2,4]},{6:[2,6],11:[1,15]},e(r,[2,13]),e(r,[2,14]),e(a,[2,9],{12:8,14:10,10:17,13:[1,16],17:t}),e([6,8,11,13,17],[2,15]),e(s,[2,11],{15:[1,18]}),e([6,11,13,15,17],[2,12]),{6:[1,19]},{1:[2,2]},{9:20,19:[1,22],20:[1,21]},{10:23,12:8,14:10,17:t},{10:24,12:8,14:10,17:t},e(a,[2,8]),{16:25,19:n},{1:[2,1]},{17:[2,3]},{19:[1,26]},{17:[2,17]},{6:[2,5]},e(a,[2,7]),e(s,[2,10]),{17:[2,16]}],defaultActions:{13:[2,2],19:[2,1],20:[2,3],22:[2,17],23:[2,5],26:[2,16]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],a=[],s=this.table,i="",o=0,l=0,c=2,p=1,h=a.slice.call(arguments,1),u=Object.create(this.lexer),d={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(d.yy[m]=this.yy[m]);u.setInput(e,d.yy),d.yy.lexer=u,d.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var g=u.yylloc;a.push(g);var f=u.options&&u.options.ranges;function v(){var e;return"number"!=typeof(e=u.lex()||p)&&(e=t.symbols_[e]||e),e}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var y,b,E,w,x,C,k,S,N={};;){if(b=n[n.length-1],this.defaultActions[b]?E=this.defaultActions[b]:(null==y&&(y=v()),E=s[b]&&s[b][y]),void 0===E||!E.length||!E[0]){var T="";for(x in S=[],s[b])this.terminals_[x]&&x>c&&S.push("'"+this.terminals_[x]+"'");T=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(o+1)+": Unexpected "+(y==p?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:u.match,token:this.terminals_[y]||y,line:u.yylineno,loc:g,expected:S})}if(E[0]instanceof Array&&E.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+y);switch(E[0]){case 1:n.push(y),r.push(u.yytext),a.push(u.yylloc),n.push(E[1]),y=null,l=u.yyleng,i=u.yytext,o=u.yylineno,g=u.yylloc;break;case 2:if(C=this.productions_[E[1]][1],N.$=r[r.length-C],N._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},f&&(N._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(N,[i,l,o,d.yy,E[1],r,a].concat(h))))return w;C&&(n=n.slice(0,-1*C*2),r=r.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[E[1]][0]),r.push(N.$),a.push(N._$),k=s[n[n.length-2]][n[n.length-1]],n.push(k);break;case 3:return!0}}return!0}},o=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var s in a)this[s]=a[s];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),s=0;s<a.length;s++)if((n=this._input.match(this.rules[a[s]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,a[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,a[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,n,r){switch(n){case 0:return 11;case 1:return"(";case 2:return")";case 3:return 8;case 4:return 15;case 5:return 13;case 6:return 18;case 7:return 19;case 8:return 20;case 9:case 10:case 11:return 17;case 12:break;case 13:return 6}},rules:[/^(?:\/)/,/^(?:\()/,/^(?:\))/,/^(?:(\*|x|\u00d7|\u2219|\u22c5|\u00b7)\s*10\s*\^)/,/^(?:\^)/,/^(?:\*)/,/^(?:[0-9]+\.[0-9]+)/,/^(?:[0-9]+)/,/^(?:-)/,/^(?:\u00b0( ?)[cCfF])/,/^(?:fl\.? oz\.?)/,/^(?:[\u00b5]?([A-Za-z-]+|[\u2103\u2109\u212b]))/,/^(?:\s+)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return e}();function l(){this.yy={}}return i.lexer=o,l.prototype=i,i.Parser=l,new l}();e.unitParser=t}(n),function(e){var n=function(){throw new Error("Abstract method - must override for expr: "+this.print())},r=function(e){throw new Error(e)},a=function(e){return e!=e};function s(){}function i(){}function o(){this.terms=1===arguments.length?arguments[0]:t.toArray(arguments)}function l(){this.terms=1===arguments.length?arguments[0]:t.toArray(arguments)}function c(e,t){this.base=e,this.exp=t}function p(e,t){this.base=e,this.power=t}function h(e,t){this.type=e,this.arg=t}function u(e){this.arg=e}function d(e,t,n){this.left=e,this.type=t,this.right=n}function m(){}function g(e,t){this.symbol=e,this.arg=t}function f(e,t){this.symbol=e,this.subscript=t}function v(e){this.symbol=e}function y(){}function b(e,t){var n=e,r=t;r<0&&(n=-n,r=-r),this.n=n,this.d=r}function E(e){this.n=e}function w(e){this.n=e}t.extend(s.prototype,{func:n,args:n,construct:function(e){var t=new this.func;return this.func.apply(t,e),t},recurse:function(e){var n=Array.prototype.slice.call(arguments,1),r=t.map(this.args(),(function(r){return t.isString(r)?r:r[e].apply(r,n)}));return this.construct(r)},eval:n,codegen:n,compile:function(){var e=this.codegen();try{return new Function("vars","return "+e+";")}catch(t){throw new Error("Function did not compile: "+e)}},print:n,tex:n,asTex:function(e){e=e||{},t.defaults(e,{display:!0,dynamic:!0,times:!1});var n=this.tex();return e.display&&(n="\\displaystyle "+n),e.dynamic&&(n=(n=n.replace(/\(/g,"\\left(")).replace(/\)/g,"\\right)")),e.times&&(n=n.replace(/\\cdot/g,"\\times")),n},name:function(){return this.func.name?this.func.name:this.func.toString().match(/^function\s*([^\s(]+)/)[1]},repr:function(){return this.name()+"("+t.map(this.args(),(function(e){return t.isString(e)?e:e.repr()})).join(",")+")"},strip:function(){return this.recurse("strip")},normalize:function(){return this.recurse("normalize")},expand:function(){return this.recurse("expand")},factor:function(e){return this.recurse("factor",e)},collect:function(e){return this.recurse("collect",e)},equals:function(e){return this.normalize().print()===e.normalize().print()},simplify:function(e){e=t.extend({once:!1},e);var n=this.factor(e),r=n.collect(e);n.equals(r)&&(r=this.collect(e));var a=r.expand(e),s=a.collect(e);a.equals(s)&&(s=r.collect(e));var i=s;return e.once||this.equals(i)?i:i.simplify(e)},isSimplified:function(){return this.equals(this.simplify())},exprArgs:function(){return t.filter(this.args(),(function(e){return e instanceof s}))},getVars:function(e){return t.uniq(t.flatten(t.invoke(this.exprArgs(),"getVars",e))).sort()},getConsts:function(){return t.uniq(t.flatten(t.invoke(this.exprArgs(),"getConsts"))).sort()},getUnits:function(){return t.flatten(t.invoke(this.exprArgs(),"getUnits"))},is:function(e){return this instanceof e},has:function(e){return this instanceof e||t.any(this.exprArgs(),(function(t){return t.has(e)}))},raiseToThe:function(e){return new c(this,e)},isSubtract:function(){return!1},isDivide:function(){return!1},isRoot:function(){return!1},needsExplicitMul:function(){return this.args()[0].needsExplicitMul()},sameVars:function(e){var n=this.getVars(),r=e.getVars(),a=function(e,n){return!t.difference(e,n).length},s=function(e){return t.uniq(t.invoke(e,"toLowerCase")).sort()};return{equal:a(n,r),equalIgnoringCase:a(s(n),s(r))}},compare:function(e){if(e instanceof d)return!1;var n=t.union(this.getVars(!0),e.getVars(!0)),r=function(e,t){var n=function(e,t){return Math.abs(e)<1||Math.abs(t)<1?Math.abs(e-t):Math.abs(1-e/t)}(e,t);return e===t||a(e)&&a(t)||n<Math.pow(10,-9)};if(!n.length&&!this.has(C)&&!e.has(C))return r(this.eval(),e.eval());var s=this.collect(),i=e.collect(),o=this.getUnits(),l=e.getUnits();if(!t.isEqual(o,l))return!1;for(var c=0;c<12;c++){var p,h={},u=Math.pow(10,1+Math.floor(3*c/12)),m=c%2==0;if(t.each(n,(function(e){var n,r;h[e]=m?(r=u-(n=-u),Math.random()*r+n):t.random(-u,u)})),s.has(g)||i.has(g)||s.has(C)||i.has(C)){var f=s.partialEval(h),v=i.partialEval(h);p=f.simplify().equals(v.simplify())}else{p=r(f=s.eval(h),v=i.eval(h))}if(!p)return!1}return!0},partialEval:function(e){return this instanceof C?this:this.has(g)?this instanceof g?new g(this.symbol,this.arg.partialEval(e)):this.recurse("partialEval",e):new w(this.eval(e).toFixed(9)).collect()},sameForm:function(e){return this.strip().equals(e.strip())},findGCD:function(e){return this.equals(e)?e:y.One},getDenominator:function(){return y.One},asMul:function(){return new l(y.One,this)},isPositive:n,isNegative:function(){return!1},asPositiveFactor:function(){return this.isPositive()?this:y.One},addHint:function(e){if(!e)return this;var n=this.construct(this.args());return n.hints=t.clone(this.hints),n.hints[e]=!0,n},hints:{parens:!1},asExpr:function(){return this},completeParse:function(){return this.recurse("completeParse")},abs:n,negate:function(){return new l(y.Neg,this)}}),i.prototype=new s,t.extend(i.prototype,{args:function(){return this.terms},normalize:function(){var e=t.sortBy(t.invoke(this.terms,"normalize"),(function(e){return e.print()}));return new this.func(e)},expand:function(){return this.recurse("expand").flatten()},partition:function(){var e=t.groupBy(this.terms,(function(e){return e instanceof y})),n=e[!0]||[],r=e[!1]||[];return[new this.func(n),new this.func(r)]},flatten:function(){var e=this,n=t.reject(this.terms,(function(t){return t.equals(e.identity)}));if(0===n.length)return e.identity;if(1===n.length)return n[0];var r=t.groupBy(n,(function(t){return t instanceof e.func})),a=r[!0]||[],s=(r[!1]||[]).concat(t.flatten(t.pluck(a,"terms"),!0));return new e.func(s)},identity:void 0,reduce:n,isPositive:function(){var e=t.invoke(this.terms,"collect");return t.all(t.invoke(e,"isPositive"))},replace:function(e,n){var r;r=e instanceof s?t.indexOf(this.terms,e):e;var a=[];t.isArray(n)?a=n:n&&(a=[n]);var i=this.terms.slice(0,r).concat(a).concat(this.terms.slice(r+1));return new this.func(i)},remove:function(e){return this.replace(e)},getDenominator:function(){return new l(t.invoke(this.terms,"getDenominator")).flatten()}}),o.prototype=new i,t.extend(o.prototype,{func:o,eval:function(e,n){return t.reduce(this.terms,(function(t,r){return t+r.eval(e,n)}),0)},codegen:function(){return t.map(this.terms,(function(e){return"("+e.codegen()+")"})).join(" + ")||"0"},print:function(){return t.invoke(this.terms,"print").join("+")},tex:function(){var e="";return t.each(this.terms,(function(t){!e||t.isSubtract()?e+=t.tex():e+="+"+t.tex()})),e},collect:function(e){var n=t.invoke(this.terms,"collect",e),r=[];t.each(n,(function(t){if(t instanceof l){var n=t.partition();r.push([n[1].flatten(),n[0].reduce(e)])}else t instanceof y?r.push([y.One,t]):r.push([t,y.One])}));var a=t.groupBy(r,(function(e){return e[0].normalize().print()})),s=t.compact(t.map(a,(function(n){var r=n[0][0];return new l(new o(t.zip.apply(t,n)[1]).reduce(e),r).collect(e)})));return new o(s).flatten()},factor:function(e){e=t.extend({keepNegative:!1},e);var n,r=t.invoke(this.terms,"collect");n=r[0]instanceof l?r[0].terms:[r[0]],t.each(t.rest(this.terms),(function(e){n=t.map(n,(function(t){return e.findGCD(t)}))})),!e.keepNegative&&this.isNegative()&&n.push(y.Neg),n=new l(n).flatten().collect();var a=t.map(r,(function(e){return l.handleDivide(e,n).simplify()}));return a=new o(a).flatten(),l.createOrAppend(n,a).flatten()},reduce:function(e){return t.reduce(this.terms,(function(t,n){return t.add(n,e)}),this.identity)},needsExplicitMul:function(){return!1},isNegative:function(){var e=t.invoke(this.terms,"collect");return t.all(t.invoke(e,"isNegative"))},negate:function(){return new o(t.invoke(this.terms,"negate"))}}),l.prototype=new i,t.extend(l.prototype,{func:l,eval:function(e,n){return t.reduce(this.terms,(function(t,r){return t*r.eval(e,n)}),1)},codegen:function(){return t.map(this.terms,(function(e){return"("+e.codegen()+")"})).join(" * ")||"0"},print:function(){return t.map(this.terms,(function(e){return e instanceof o?"("+e.print()+")":e.print()})).join("*")},getUnits:function(){var e=t(this.terms).chain().map((function(e){return e.getUnits()})).flatten().value();return e.sort((function(e,t){return e.unit<t.unit})),e},tex:function(){for(var e,n=" \\cdot ",r=t.groupBy(this.terms,(function(e){return e.isDivide()?"inverse":e instanceof y?"number":"other"})),a=r.inverse||[],s=r.number||[],i=r.other||[],p="",h=0;h<s.length;h++){if(s[h]instanceof b&&!(s[h]instanceof E)&&i.length>0&&a.length>0){var u=s.slice();u.splice(h,1);var d=u.concat(a).concat(i);return s[h].tex()+new l(d).tex()}}if(s=t.compact(t.map(s,(function(e){var n=e instanceof b&&!(e instanceof E),r=!e.hints.fraction||a.length>0;if(n&&r){a.push(new c(new E(e.d),y.Div));var s=new E(e.n);return s.hints=e.hints,t.any(e.hints)?s:null}return e}))),0===s.length&&1===i.length)e=i[0].tex();else{var m="";t.each(s,(function(e){e.hints.subtract&&e.hints.entered?(p+="-",m+=(m?n:"")+e.abs().tex()):e instanceof E&&-1===e.n&&(e.hints.negate||e.hints.subtract)?p+="-":m+=(m?n:"")+e.tex()})),t.each(i,(function(e){e.needsExplicitMul()?m+=(m?n:"")+e.tex():m+=e instanceof o?"("+e.tex()+")":e.tex()})),e=m||"1"}if(a.length){var g=new l(t.invoke(a,"asDivide")).flatten().tex();return p+"\\frac{"+e+"}{"+g+"}"}return p+e},strip:function(){return new l(t.map(this.terms,(function(e){return e instanceof y?e.abs():e.strip()}))).flatten()},expand:function(){var e=function(e){return e instanceof o},n=function(e){return e instanceof c&&e.exp.isNegative()},r=this.recurse("expand").flatten(),a=t.any(r.terms,e),s=t.any(r.terms,(function(t){return n(t)&&e(t.base)}));if(!a&&!s)return r;var i=t.groupBy(r.terms,n),p=i[!1]||[],h=i[!0]||[];if(a){var u=t.groupBy(p,e),d=u[!0]||[],m=u[!1]||[],g=t.reduce(d,(function(e,n){return t.reduce(e,(function(e,r){return e.concat(t.map(n.terms,(function(e){return r.concat(e)})))}),[])}),[[]]);p=[new o(t.map(g,(function(e){return new l(m.concat(e)).flatten()})))]}s&&(h=[new c(new l(t.invoke(h,"getDenominator")).flatten().expand(),y.Div)]);return new l(p.concat(h)).flatten()},factor:function(e){var n=this.recurse("factor",e).flatten();if(!(n instanceof l))return n;var r=t.groupBy(n.terms,(function(e){return e instanceof b})),a=t.reduce(r[!0],(function(e,t){return{n:e.n*t.n,d:e.d*t.d}}),{n:1,d:1});return a=1===a.d?new E(a.n):new b(a.n,a.d),new l((r[!1]||[]).concat(a)).flatten()},collect:function(e){var n=this.recurse("collect",e).partition(),r=n[0].reduce(e);if(0===r.eval())return y.Zero;var a=n[1].flatten();if(!(a instanceof l))return new l(r,a).flatten();a=a.terms;var s=[];t.each(a,(function(e){e instanceof c?s.push([e.base,e.exp]):s.push([e,y.One])}));var i=t.groupBy(s,(function(e){return e[0].normalize().print()})),u=t.compact(t.map(i,(function(n){var r=n[0][0],a=new o(t.zip.apply(t,n)[1]).collect(e);return a instanceof y&&0===a.eval()?null:[r,a]}))),d=(s=t.groupBy(u,(function(e){return e[0]instanceof h&&e[0].isBasic()?"trig":e[0]instanceof p?"log":"expr"}))).trig||[],m=s.log||[],g=s.expr||[];if(d.length>1){var f=t.groupBy(d,(function(e){return e[0].arg.normalize().print()}));d=[],t.each(f,(function(n){var r=n[0][0].arg,a={sin:y.Zero,cos:y.Zero};t.each(n,(function(e){a[e[0].type]=e[1]})),l.handleNegative(a.sin).collect(e).equals(a.cos)&&(a=a.cos.isNegative()?{tan:a.sin}:{cot:a.cos}),t.each(a,(function(e,t){d.push([new h(t,r),e])}))}))}if(m.length>1){var v=t.groupBy(m,(function(e){return e[0].base.normalize().print()}));m=[],t.each(v,(function(t){2===t.length&&l.handleNegative(t[0][1]).collect(e).equals(t[1][1])?t[0][1].isNegative()?m.push([new p(t[0][0].power,t[1][0].power),t[1][1]]):m.push([new p(t[1][0].power,t[0][0].power),t[0][1]]):m=m.concat(t)}))}s=d.concat(m).concat(g);var b=t.map(s,(function(t){return new c(t[0],t[1]).collect(e)}));return new l([r].concat(b)).flatten()},isSubtract:function(){return t.any(this.terms,(function(e){return e instanceof y&&e.hints.subtract}))},factorIn:function(e){var n=this.partition()[0].terms,r=n.length&&t.all(n,(function(e){return e.n>0}));if(r){var a=n[0].negate();return a.hints=n[0].hints,this.replace(n[0],a.addHint(e))}return new l([y.negativeOne(e)].concat(this.terms))},factorOut:function(){var e=!1,n=t.compact(t.map(this.terms,(function(t,n,r){return!e&&t instanceof y&&t.hints.divide?(e=!0,-1!==t.n?t.negate():null):t})));return 1===n.length?n[0]:new l(n)},reduce:function(e){return t.reduce(this.terms,(function(t,n){return t.mul(n,e)}),this.identity)},findGCD:function(e){return new l(t.invoke(this.terms,"findGCD",e)).flatten()},asMul:function(){return this},asPositiveFactor:function(){return this.isPositive()?this:new l(t.invoke(this.collect().terms,"asPositiveFactor")).flatten()},isNegative:function(){return t.any(t.invoke(this.collect().terms,"isNegative"))},fold:function(){return l.fold(this)},negate:function(){var e=function(e){return e instanceof y};if(t.any(this.terms,e)){var n=t.find(this.terms,e);return this.replace(n,n.negate())}return new l([y.Neg].concat(this.terms))}}),t.each([o,l],(function(e){t.extend(e,{createOrAppend:function(t,n){return t instanceof e?new e(t.terms.concat(n)):new e(t,n)}})})),t.extend(l,{handleNegative:function(e,t){if(e instanceof y&&e.n>0){var n=e.negate();return n.hints=e.hints,n.addHint(t)}return e instanceof l?e.factorIn(t):new l(y.negativeOne(t),e)},handleDivide:function(e,n){if(n instanceof l){var r=l.handleDivide(e,n.terms[0]),a=new l(t.rest(n.terms)).flatten();return l.handleDivide(r,a)}var s=function(e){return e instanceof E};if(s(n)&&e instanceof l&&t.any(e.terms,s)){var i=e.terms.slice().reverse(),o=t.find(i,(function(e){return e instanceof b}));if(!s(o))return new l(e.terms.concat([new b(1,n.n).addHint("fraction")]));var p=new b(o.n,n.n);return p.hints=o.hints,o===i[0]&&(p=p.addHint("fraction")),o.n<0&&n.n<0?(p.d=-p.d,e.replace(o,[y.Neg,p])):e.replace(o,p)}var u=function(e,t){if(t instanceof E){if(e instanceof E)return e.n<0&&t.n<0?[y.Neg,new b(e.n,-t.n).addHint("fraction")]:[new b(e.n,t.n).addHint("fraction")];var n=new b(1,t.eval());return t.eval()<0?[e,n.addHint("negate")]:[e,n]}var r;if(t instanceof h&&t.exp){var a=t.exp;t.exp=void 0,t=new c(t,a)}return r=t instanceof c?new c(t.base,l.handleNegative(t.exp,"divide")):new c(t,y.Div),e instanceof E&&1===e.n?[r]:[e,r]};if(e instanceof l){var d=u(t.last(e.terms),n);return new l(t.initial(e.terms).concat(d))}return new l(d=u(e,n)).flatten()},fold:function(e){if(e instanceof l){var n=t.find(t.initial(e.terms),(function(e){return(e instanceof h||e instanceof p)&&e.hints.open})),r=t.indexOf(e.terms,n);if(n){var a,s=t.last(e.terms);if(!(n.hints.parens||s.hints.parens||s.has(h)||s.has(p)))return a=n instanceof h?h.create([n.type,n.exp],l.createOrAppend(n.arg,s).fold()):p.create(n.base,l.createOrAppend(n.power,s).fold()),0===r?a:new l(e.terms.slice(0,r).concat(a)).fold();n.hints.open=!1}var i=e.partition()[0].terms,o=function(e){return e.n>0},c=function(e){return-1===e.n&&e.hints.negate};if(i.length>1&&t.some(i,c)&&t.some(i,o)&&t.every(i,(function(e){return o(e)||c(e)}))){var u=t.indexOf(e.terms,t.find(e.terms,c)),d=t.indexOf(e.terms,t.find(e.terms,o));if(u<d)return e.replace(d,e.terms[d].negate()).remove(u)}}return e}}),c.prototype=new s,t.extend(c.prototype,{func:c,args:function(){return[this.base,this.exp]},eval:function(e,t){var n=this.base.eval(e,t),r=this.exp.eval(e,t);if(n<0){var a=this.exp.simplify();if(a instanceof w){var s=a.n,i=(s-s.toFixed()).toString().length-2,o=Math.pow(10,i);a=new b(s*o,o).simplify()}if(a instanceof b)if(Math.abs(a.d)%2==1)return(Math.abs(a.n)%2==1?-1:1)*Math.pow(-1*n,r)}return Math.pow(n,r)},getUnits:function(){return this.base.getUnits().map(function(e){return{unit:e.unit,pow:e.pow*this.exp.n}}.bind(this))},codegen:function(){return"Math.pow("+this.base.codegen()+", "+this.exp.codegen()+")"},print:function(){var e=this.base.print();return(this.base instanceof i||this.base instanceof c)&&(e="("+e+")"),e+"^("+this.exp.print()+")"},tex:function(){if(this.isDivide())return"\\frac{1}{"+this.asDivide().tex()+"}";if(this.isRoot())return 1!==this.exp.n&&r("Node marked with hint 'root' does not have exponent of form 1/x."),2===this.exp.d?"\\sqrt{"+this.base.tex()+"}":"\\sqrt["+this.exp.d+"]{"+this.base.tex()+"}";if(this.base instanceof h&&!this.base.isInverse()&&this.exp instanceof y&&this.exp.isSimple()&&this.exp.eval()>=0){var e=this.base.tex({split:!0});return e[0]+"^{"+this.exp.tex()+"}"+e[1]}var t=this.base.tex();return this.base instanceof i||this.base instanceof c||this.base instanceof y&&!this.base.isSimple()?t="("+t+")":(this.base instanceof h||this.base instanceof p)&&(t="["+t+"]"),t+"^{"+this.exp.tex()+"}"},needsExplicitMul:function(){return!this.isRoot()&&this.base.needsExplicitMul()},expand:function(){var e=this.recurse("expand");if(e.base instanceof l)return new l(t.map(e.base.terms,(function(t){return new c(t,e.exp)}))).expand();if(e.base instanceof o&&e.exp instanceof E&&e.exp.abs().eval()>1){for(var n=e.exp.eval()>0,r=e.exp.abs().eval(),a=function(e){return n?e:new c(e,y.Div)},s={1:e.base},i=2;i<=r;i*=2){var p=new l(s[i/2],s[i/2]);s[i]=p.expand().collect()}if(t.has(s,r))return a(s[r]);var h=t.map(r.toString(2).split(""),(function(e,t,n){return Number(e)*Math.pow(2,n.length-t-1)}));return h=t.without(h,0),a(p=new l(t.pick(s,h)).expand().collect())}return e.exp instanceof o?new l(t.map(e.exp.terms,(function(t){return new c(e.base,t).expand()}))).expand():e},factor:function(){var e=this.recurse("factor");return e.base instanceof l?new l(t.map(e.base.terms,(function(t){return t instanceof E&&e.exp.equals(y.Div)?new b(1,t.n):new c(t,e.exp)}))):e},collect:function(e){if(this.base instanceof c)return new c(this.base.base,s=l.createOrAppend(this.base.exp,this.exp)).collect(e);var n=this.recurse("collect",e),r=function(e){return e instanceof p&&e.base.equals(n.base)};if(n.exp instanceof y&&0===n.exp.eval())return y.One;if(n.exp instanceof y&&1===n.exp.eval())return n.base;if(r(n.exp))return n.exp.power;if(n.exp instanceof l&&t.any(n.exp.terms,r)){var a=t.find(n.exp.terms,r);return new c(a.power,s=n.exp.remove(a).flatten()).collect(e)}if(n.base instanceof y&&n.exp instanceof y){if(e&&e.preciseFloats){var s=n.exp.asRational(),i=n.base.getDecimalPlaces();if(new c(n.base,new b(1,s.d)).collect().getDecimalPlaces()>i){var o=new c(n.base,new E(s.n)).collect();return new c(o,new b(1,s.d))}}return n.base.raiseToThe(n.exp,e)}return n},isDivide:function(){var e=function(e){return e instanceof y&&e.hints.divide};return e(this.exp)||this.exp instanceof l&&t.any(this.exp.terms,e)},asDivide:function(){if(this.exp instanceof y){if(-1===this.exp.eval())return this.base;var e=this.exp.negate();return e.hints=t.clone(this.exp.hints),e.hints.divide=!1,new c(this.base,e)}if(this.exp instanceof l)return new c(this.base,this.exp.factorOut());r("called asDivide() on an Expr that wasn't a Num or Mul")},isRoot:function(){return this.exp instanceof b&&this.exp.hints.root},isSquaredTrig:function(){return this.base instanceof h&&!this.base.isInverse()&&this.exp instanceof y&&2===this.exp.eval()},getDenominator:function(){if(this.exp instanceof y&&-1===this.exp.eval())return l.createOrAppend(this.base,this.base.getDenominator()).flatten();if(this.exp.isNegative()){var e=new c(this.base,l.handleNegative(this.exp).collect());return l.createOrAppend(e,e.collect().getDenominator()).flatten()}return this.base instanceof y?new c(this.base.getDenominator(),this.exp).collect():y.One},findGCD:function(e){var t,n;if(e instanceof c?(t=e.base,n=e.exp):(t=e,n=y.One),this.base.equals(t)){if(this.exp.equals(n))return this;if(this.exp instanceof y&&n instanceof y)return new c(this.base,y.min(this.exp,n)).collect();if(this.exp instanceof y||n instanceof y)return y.One;var r=this.exp.asMul().partition(),a=n.asMul().partition();if(r[1].equals(a[1]))return new c(t,new l(y.min(r[0].reduce(),a[0].reduce()),r[1].flatten()).flatten()).collect()}return y.One},isPositive:function(){if(this.base.isPositive())return!0;var e=this.exp.simplify();return e instanceof E&&e.eval()%2==0},asPositiveFactor:function(){if(this.isPositive())return this;var e=this.exp.simplify();if(e instanceof E){var t=e.eval();if(t>2)return new c(this.base,new E(t-1));if(t<-2)return new c(this.base,new E(t+1))}return y.One}}),t.extend(c,{sqrt:function(e){return new c(e,y.Sqrt)},nthroot:function(e,t){return new c(e,l.fold(l.handleDivide(new E(1),t)).addHint("root"))}}),p.prototype=new s,t.extend(p.prototype,{func:p,args:function(){return[this.base,this.power]},eval:function(e,t){return Math.log(this.power.eval(e,t))/Math.log(this.base.eval(e,t))},codegen:function(){return"(Math.log("+this.power.codegen()+") / Math.log("+this.base.codegen()+"))"},print:function(){var e="("+this.power.print()+")";return this.isNatural()?"ln"+e:"log_("+this.base.print()+") "+e},tex:function(){var e="("+this.power.tex()+")";return this.isNatural()?"\\ln"+e:"\\log_{"+this.base.tex()+"}"+e},collect:function(e){var t=this.recurse("collect",e);return t.power instanceof y&&1===t.power.eval()?y.Zero:t.base.equals(t.power)?y.One:t.power instanceof c&&t.power.base.equals(t.base)?t.power.exp:t},expand:function(){var e=this.recurse("expand");return e.power instanceof l?new o(t.map(e.power.terms,(function(t){return new p(e.base,t).expand()}))):e.power instanceof c?new l(e.power.exp,new p(e.base,e.power.base).expand()).flatten():e.isNatural()?e:l.handleDivide(new p(v.e,e.power),new p(v.e,e.base))},hints:t.extend(p.prototype.hints,{open:!1}),isPositive:function(){var e=this.collect();return e.base instanceof y&&e.power instanceof y&&this.eval()>0},needsExplicitMul:function(){return!1},isNatural:function(){return this.base.equals(v.e)}}),t.extend(p,{natural:function(){return v.e},common:function(){return y.Ten},create:function(e,t){var n=new p(e,t);return t.hints.parens||(n=n.addHint("open")),n}}),h.prototype=new s,t.extend(h.prototype,{func:h,args:function(){return[this.type,this.arg]},functions:{sin:{eval:Math.sin,codegen:"Math.sin((",tex:"\\sin",expand:function(){return this}},cos:{eval:Math.cos,codegen:"Math.cos((",tex:"\\cos",expand:function(){return this}},tan:{eval:Math.tan,codegen:"Math.tan((",tex:"\\tan",expand:function(){return l.handleDivide(h.sin(this.arg),h.cos(this.arg))}},csc:{eval:function(e){return 1/Math.sin(e)},codegen:"(1/Math.sin(",tex:"\\csc",expand:function(){return l.handleDivide(y.One,h.sin(this.arg))}},sec:{eval:function(e){return 1/Math.cos(e)},codegen:"(1/Math.cos(",tex:"\\sec",expand:function(){return l.handleDivide(y.One,h.cos(this.arg))}},cot:{eval:function(e){return 1/Math.tan(e)},codegen:"(1/Math.tan(",tex:"\\cot",expand:function(){return l.handleDivide(h.cos(this.arg),h.sin(this.arg))}},arcsin:{eval:Math.asin,codegen:"Math.asin((",tex:"\\arcsin"},arccos:{eval:Math.acos,codegen:"Math.acos((",tex:"\\arccos"},arctan:{eval:Math.atan,codegen:"Math.atan((",tex:"\\arctan"},arccsc:{eval:function(e){return Math.asin(1/e)},codegen:"Math.asin(1/(",tex:"\\operatorname{arccsc}"},arcsec:{eval:function(e){return Math.acos(1/e)},codegen:"Math.acos(1/(",tex:"\\operatorname{arcsec}"},arccot:{eval:function(e){return Math.atan(1/e)},codegen:"Math.atan(1/(",tex:"\\operatorname{arccot}"},sinh:{eval:function(e){return(Math.exp(e)-Math.exp(-e))/2},codegen:function(e){return"((Math.exp("+e+") - Math.exp(-("+e+"))) / 2)"},tex:"\\sinh",expand:function(){return this}},cosh:{eval:function(e){return(Math.exp(e)+Math.exp(-e))/2},codegen:function(e){return"((Math.exp("+e+") + Math.exp(-("+e+"))) / 2)"},tex:"\\cosh",expand:function(){return this}},tanh:{eval:function(e){return(Math.exp(e)-Math.exp(-e))/(Math.exp(e)+Math.exp(-e))},codegen:function(e){return"((Math.exp("+e+") - Math.exp(-("+e+"))) / (Math.exp("+e+") + Math.exp(-("+e+"))))"},tex:"\\tanh",expand:function(){return l.handleDivide(h.sinh(this.arg),h.cosh(this.arg))}},csch:{eval:function(e){return 2/(Math.exp(e)-Math.exp(-e))},codegen:function(e){return"(2 / (Math.exp("+e+") - Math.exp(-("+e+"))))"},tex:"\\csch",expand:function(){return l.handleDivide(y.One,h.sinh(this.arg))}},sech:{eval:function(e){return 2/(Math.exp(e)+Math.exp(-e))},codegen:function(e){return"(2 / (Math.exp("+e+") + Math.exp(-("+e+"))))"},tex:"\\sech",expand:function(){return l.handleDivide(y.One,h.cosh(this.arg))}},coth:{eval:function(e){return(Math.exp(e)+Math.exp(-e))/(Math.exp(e)-Math.exp(-e))},codegen:function(e){return"((Math.exp("+e+") + Math.exp(-("+e+"))) / (Math.exp("+e+") - Math.exp(-("+e+"))))"},tex:"\\coth",expand:function(){return l.handleDivide(h.cosh(this.arg),h.sinh(this.arg))}}},isEven:function(){return t.contains(["cos","sec"],this.type)},isInverse:function(){return 0===this.type.indexOf("arc")},isBasic:function(){return t.contains(["sin","cos"],this.type)},eval:function(e,t){return(0,this.functions[this.type].eval)(this.arg.eval(e,t))},codegen:function(){var e=this.functions[this.type].codegen;if("function"==typeof e)return e(this.arg.codegen());if("string"==typeof e)return e+this.arg.codegen()+"))";throw new Error("codegen not implemented for "+this.type)},print:function(){return this.type+"("+this.arg.print()+")"},tex:function(e){var t=this.functions[this.type].tex,n="("+this.arg.tex()+")";return e&&e.split?[t,n]:t+n},hints:t.extend(h.prototype.hints,{open:!1}),isPositive:function(){return this.collect().arg instanceof y&&this.eval()>0},completeParse:function(){if(this.exp){var e=new c(this,this.exp);return this.exp=void 0,e}return this},needsExplicitMul:function(){return!1},expand:function(){var e=this.recurse("expand");if(e.isInverse())return e;var n=e.functions[e.type].expand;return t.bind(n,e)()},collect:function(e){var t,n=this.recurse("collect",e);return!n.isInverse()&&n.arg.isNegative()?(t=n.arg instanceof y?n.arg.abs():l.handleDivide(n.arg,y.Neg).collect(e),n.isEven()?new h(n.type,t):new l(y.Neg,new h(n.type,t))):n}}),t.extend(h,{create:function(e,t){var n=e[0],r=e[1];r&&r.equals(y.Neg)&&(n="arc"+n,r=void 0);var a=new h(n,t);return t.hints.parens||(a=a.addHint("open")),r&&(a.exp=r),a},sin:function(e){return new h("sin",e)},cos:function(e){return new h("cos",e)},sinh:function(e){return new h("sinh",e)},cosh:function(e){return new h("cosh",e)}}),u.prototype=new s,t.extend(u.prototype,{func:u,args:function(){return[this.arg]},eval:function(e,t){return Math.abs(this.arg.eval(e,t))},codegen:function(){return"Math.abs("+this.arg.codegen()+")"},print:function(){return"abs("+this.arg.print()+")"},tex:function(){return"\\left|"+this.arg.tex()+"\\right|"},collect:function(e){var n=this.recurse("collect",e);if(n.arg.isPositive())return n.arg;if(n.arg instanceof y)return n.arg.abs();if(n.arg instanceof l){var r=t.groupBy(n.arg.terms,(function(e){return e.isPositive()?"positive":e instanceof y?"number":"other"})),a=r.positive.concat(t.invoke(r.number,"abs"));return r.other.length&&a.push(new u(new l(r.other).flatten())),new l(a).flatten()}return n},expand:function(){var e=this.recurse("expand");return e.arg instanceof l?new l(t.map(e.arg.terms,(function(e){return new u(e)}))):e},isPositive:function(){return!0}}),d.prototype=new s,t.extend(d.prototype,{func:d,args:function(){return[this.left,this.type,this.right]},needsExplicitMul:function(){return!1},print:function(){return this.left.print()+this.type+this.right.print()},signs:{"=":" = ","<":" < ",">":" > ","<>":" \\ne ","<=":" \\le ",">=":" \\ge "},tex:function(){return this.left.tex()+this.signs[this.type]+this.right.tex()},normalize:function(){var e=this.recurse("normalize");return t.contains([">",">="],e.type)?new d(e.right,e.type.replace(">","<"),e.left):e},asExpr:function(e){var n=function(e){return e instanceof y&&e.isSimple()&&0===e.eval()},r=[];this.left instanceof o?r=t.clone(this.left.terms):n(this.left)||(r=[this.left]),this.right instanceof o?r=r.concat(this.right.negate().terms):n(this.right)||r.push(this.right.negate());var a=!this.isEquality();r=t.invoke(r,"collect",{preciseFloats:!0});for(var s=0;s<r.length;s++){var i=r[s].getDenominator();a&&!i.isPositive()&&(i=i.asPositiveFactor()),i.equals(y.One)||(r=t.map(r,(function(e){return l.createOrAppend(e,i).simplify({once:!0,preciseFloats:!0})})))}var c=new o(r).flatten();return e?c:this.divideThrough(c)},divideThrough:function(e){var n=!this.isEquality(),r=e.simplify({once:!0}),a=r.factor({keepNegative:n});if(!(a instanceof l))return e;var s=a.terms,i=t.groupBy(s,(function(e){return e instanceof o})),p=i[!0]||[],h=i[!1]||[];if(p.length&&this.isEquality())return new l(p).flatten();var u=h;p.length||(u=t.reject(u,(function(e){return!!e.getVars().length}))),n&&(u=t.invoke(u,"asPositiveFactor")),u=t.reject(u,(function(e){return e.equals(y.One)})),u=t.map(u,(function(e){return new c(e,y.Div)}));var d=new l(s.concat(u)).collect();return d.equals(a)?r:d},isEquality:function(){return t.contains(["=","<>"],this.type)},compare:function(e){if(!(e instanceof d))return!1;var t=this.normalize(),n=e.normalize();if(t.type!==n.type)return!1;var r=t.divideThrough(t.asExpr(!0).collect()),a=n.divideThrough(n.asExpr(!0).collect());return t.isEquality()?r.compare(a)||r.compare(l.handleNegative(a)):r.compare(a)},sameForm:function(e){var t=this.normalize(),n=e.normalize(),r=t.left.sameForm(n.left)&&t.right.sameForm(n.right);return t.isEquality()?r||t.left.sameForm(n.right)&&t.right.sameForm(n.left):r},isSimplified:function(){var e=this.asExpr(!0),t=this.divideThrough(e).simplify();return e.equals(t)&&this.left.isSimplified()&&this.right.isSimplified()}}),t.extend(d.prototype,{solveLinearEquationForVariable:function(e){var n=this.asExpr();if(!n.is(o)||2!==n.terms.length)throw new Error("Can only handle linear equations of the form a + bx (= 0)");var r,a,s;return(s=n.terms[0]).has(f)&&t.contains(s.getVars(),e.symbol)?(r=l.handleNegative(n.terms[1]),a=l.handleDivide(n.terms[0],e)):(r=l.handleNegative(n.terms[0]),a=l.handleDivide(n.terms[1],e)),l.handleDivide(r,a).simplify()}}),m.prototype=new s,t.extend(m.prototype,{needsExplicitMul:function(){return!1},findGCD:function(e){return e instanceof m||e instanceof y?this.equals(e)?this:y.One:e.findGCD(this)}}),g.prototype=new m,t.extend(g.prototype,{func:g,args:function(){return[this.symbol,this.arg]},print:function(){return this.symbol+"("+this.arg.print()+")"},tex:function(){return this.symbol+"("+this.arg.tex()+")"},eval:function(n,r){var a=this.arg,s=n[this.symbol],i=t.extend(t.clone(n),{x:a.eval(n,r)}),o=e.parse(s,r);return o.parsed?o.expr.eval(i,r):o},codegen:function(){return'vars["'+this.symbol+'"]('+this.arg.codegen()+")"},getUnits:function(){return this.arg.getUnits()},getVars:function(e){return e?this.arg.getVars():t.union(this.arg.getVars(),[this.symbol]).sort()},getConsts:function(){return this.arg.getConsts()}}),f.prototype=new m,t.extend(f.prototype,{func:f,args:function(){return[this.symbol,this.subscript]},exprArgs:function(){return[]},recurse:function(){return this},print:function(){var e="";return this.subscript&&(e="_("+this.subscript.print()+")"),this.symbol+e},prettyPrint:function(){var e=this.subscript;return e&&(e instanceof y||e instanceof m)?this.symbol+"_"+e.print():this.print()},tex:function(){var e="";return this.subscript&&(e="_{"+this.subscript.tex()+"}"),(this.symbol.length>1?"\\":"")+this.symbol+e},repr:function(){return"Var("+this.print()+")"},eval:function(e,t){return e[this.prettyPrint()]},codegen:function(){return'vars["'+this.prettyPrint()+'"]'},getVars:function(){return[this.prettyPrint()]},isPositive:function(){return!1}}),v.prototype=new m,t.extend(v.prototype,{func:v,args:function(){return[this.symbol]},recurse:function(){return this},eval:function(e,t){return"pi"===this.symbol?Math.PI:"e"===this.symbol?Math.E:void 0},codegen:function(){return"pi"===this.symbol?"Math.PI":"e"===this.symbol?"Math.E":void 0},print:function(){return this.symbol},tex:function(){return"pi"===this.symbol?"\\pi ":"e"===this.symbol?"e":void 0},isPositive:function(){return this.eval()>0},abs:function(){return this.eval()>0?this:l.handleNegative(this)},getConsts:function(){return[this.print()]}}),v.e=new v("e"),v.pi=new v("pi"),y.prototype=new s,t.extend(y.prototype,{repr:function(){return this.print()},strip:function(){return this.abs()},recurse:function(){return this},codegen:function(){return this.print()},add:n,mul:n,negate:n,isSubtract:function(){return this.hints.subtract},abs:n,needsExplicitMul:function(){return!0},findGCD:n,isPositive:function(){return this.eval()>0},isNegative:function(){return this.eval()<0},asPositiveFactor:function(){return this.isPositive()?this:this.abs()},hints:t.extend(y.prototype.hints,{negate:!1,subtract:!1,divide:!1,root:!1,fraction:!1,entered:!1}),isSimple:n,getDecimalPlaces:function(){var e=(""+this.n).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return e?Math.max(0,(e[1]?e[1].length:0)-(e[2]?+e[2]:0)):0},asRational:n}),b.prototype=new y,t.extend(b.prototype,{func:b,args:function(){return[this.n,this.d]},eval:function(){return this.n/this.d},print:function(){return this.n.toString()+"/"+this.d.toString()},tex:function(){var e="\\frac{"+Math.abs(this.n).toString()+"}{"+this.d.toString()+"}";return this.n<0?"-"+e:e},add:function(e,t){return e instanceof b?new b(this.n*e.d+this.d*e.n,this.d*e.d).collect():e.add(this,t)},mul:function(e,t){return e instanceof b?new b(this.n*e.n,this.d*e.d).collect():e.mul(this,t)},collect:function(){var e=y.findGCD(this.n,this.d),t=this.n/e,n=this.d/e;return 1===n?new E(t):new b(t,n)},negate:function(){return new b(-this.n,this.d)},abs:function(){return new b(Math.abs(this.n),this.d)},findGCD:function(e){return e instanceof b?new b(y.findGCD(this.n*e.d,e.n*this.d),this.d*e.d).collect():e instanceof E?new b(y.findGCD(this.n,e.n),this.d):e.findGCD(this)},raiseToThe:function(e){if(e instanceof E){var t=e.eval()>0,n=e.abs().eval(),r=Math.pow(this.n,n),a=Math.pow(this.d,n);return t?new b(r,a).collect():new b(a,r).collect()}return new w(this.eval()).raiseToThe(e)},getDenominator:function(){return new E(this.d)},isSimple:function(){return!1},asRational:function(){return this}}),E.prototype=new b(0,1),t.extend(E.prototype,{func:E,args:function(){return[this.n]},print:function(){return this.n.toString()},tex:function(){return this.n.toString()},negate:function(){return new E(-this.n)},abs:function(){return new E(Math.abs(this.n))},isSimple:function(){return!0},findGCD:function(e){return e instanceof E?new E(y.findGCD(this.n,e.n)):e.findGCD(this)}}),t.extend(E,{create:function(e){return new E(e).addHint("entered")}}),w.prototype=new y,t.extend(w.prototype,{func:w,args:function(){return[this.n]},eval:function(){return this.n},print:function(){return this.n.toString()},tex:function(){return this.n.toString()},add:function(e,t){return t&&t.preciseFloats?w.toDecimalPlaces(this.n+e.eval(),Math.max(this.getDecimalPlaces(),e.getDecimalPlaces())):new w(this.n+e.eval()).collect()},mul:function(e,t){return t&&t.preciseFloats?w.toDecimalPlaces(this.n*e.eval(),this.getDecimalPlaces()+e.getDecimalPlaces()):new w(this.n*e.eval()).collect()},collect:function(){return this},negate:function(){return new w(-this.n)},abs:function(){return new w(Math.abs(this.n))},findGCD:function(e){return e instanceof y?new w(y.findGCD(this.eval(),e.eval())).collect():e.findGCD(this)},raiseToThe:function(e,t){return t&&t.preciseFloats&&e instanceof E&&e.n>1?w.toDecimalPlaces(new c(this,e).eval(),this.getDecimalPlaces()*e.n):new w(new c(this,e).eval()).collect()},asRational:function(){var e=this.n.toString().split(".");return 1===e.length?new b(this.n,1):new b(Number(e.join("")),Math.pow(10,e[1].length)).collect()},getDenominator:function(){return this.asRational().getDenominator()},isSimple:function(){return!0}}),t.extend(w,{create:function(e){return new w(e).addHint("entered")},toDecimalPlaces:function(e,t){return new w(+e.toFixed(Math.min(t,20))).collect()}}),t.extend(y,{negativeOne:function(e){return"subtract"===e?y.Sub:"divide"===e?y.Div:y.Neg},findGCD:function(e,t){var n;if(e=Math.abs(e),t=Math.abs(t),e!==Math.floor(e)||t!==Math.floor(t))return 1;for(;t;)n=e%t,e=t,t=n;return e},min:function(){return t.min(t.toArray(arguments),(function(e){return e.eval()}))},max:function(){return t.max(t.toArray(arguments),(function(e){return e.eval()}))}}),y.Neg=new E(-1).addHint("negate"),y.Sub=new E(-1).addHint("subtract"),y.Div=new E(-1).addHint("divide"),y.Sqrt=new b(1,2).addHint("root"),y.Zero=new E(0),y.One=new E(1),y.Ten=new E(10),o.prototype.identity=y.Zero,l.prototype.identity=y.One;var x=e.parser;function C(e){this.symbol=e}x.yy={Add:o,Mul:l,Pow:c,Log:p,Trig:h,Eq:d,Abs:u,Func:g,Const:v,Var:f,Int:E,Float:w,parseError:function(e,t){throw new Error(t.loc.first_column)},constants:["e"],symbolLexer:function(e){return t.contains(x.yy.constants,e)?"CONST":t.contains(x.yy.functions,e)?"FUNC":"VAR"}},e.parse=function(e,n){try{return n&&n.functions?x.yy.functions=t.without(n.functions,"i"):x.yy.functions=[],n&&n.decimal_separator&&(e=e.split(n.decimal_separator).join(".")),{parsed:!0,expr:x.parse(e).completeParse()}}catch(e){return{parsed:!1,error:e.message}}},C.prototype=new m;var k=function(e){if(t(S).has(e)||t(M).has(e))return new C(e);var n=t(t(N).keys()).find((function(t){return new RegExp("^"+t).test(e)}));if(n){var r=e.replace(new RegExp("^"+n),"");if(t(S).has(r)||M[r]&&M[r].prefixes===T)return new l(N[n],new C(r));throw new Error(r+" does not allow prefixes")}return new C(e)};e.unitParse=function(n){try{var r=e.unitParser.parse(n),a=[];t(r.unit.num).each((function(e){a.push(new c(k(e.name),new E(e.pow)))})),t(r.unit.denom).each((function(e){a.push(new c(k(e.name),new E(-1*e.pow)))}));var s=new l(a).flatten();return"unitMagnitude"===r.type?{parsed:!0,unit:s,expr:new l([new w(+r.magnitude)].concat(a)),coefficient:r.magnitude,type:r.type}:{parsed:!0,unit:s,type:r.type}}catch(e){return{parsed:!1,error:e.message}}},t.extend(C.prototype,{func:C,args:function(){return[this.symbol]},recurse:function(){return this},eval:function(e,t){return 1},getUnits:function(){return[{unit:this.symbol,pow:1}]},codegen:function(){return"1"},print:function(){return this.symbol},tex:function(){return this.symbol},collect:function(e){if(t(S).has(this.symbol))return this;if(t(M).has(this.symbol))return M[this.symbol].conversion;throw new Error("could not understand unit: "+this.symbol)}});var S={m:new C("m"),g:new C("g"),s:new C("s"),A:new C("A"),K:new C("K"),mol:new C("mol"),cd:new C("cd")},N={a:new c(new E(10),new E(-18)),f:new c(new E(10),new E(-15)),p:new c(new E(10),new E(-12)),n:new c(new E(10),new E(-9)),u:new c(new E(10),new E(-6)),m:new c(new E(10),new E(-3)),c:new c(new E(10),new E(-2)),d:new c(new E(10),new E(-1)),da:new E(10),h:new c(new E(10),new E(2)),k:new c(new E(10),new E(3)),M:new c(new E(10),new E(6)),G:new c(new E(10),new E(9)),T:new c(new E(10),new E(12)),P:new c(new E(10),new E(15)),E:new c(new E(10),new E(18)),hella:new c(new E(10),new E(27))},T={},_={},O=function(t,n){var r=t.split("|"),a=r[0].trim(),s=r[1].trim(),i=y.One;""!==a&&(i=e.parse(a).expr);var o=s.split("/"),p=[i];return o[0]&&o[0].split(" ").filter((function(e){return""!==e})).map((function(e){p.push(new C(e))})),o[1]&&o[1].split(" ").filter((function(e){return""!==e})).map((function(e){p.push(new c(new C(e),y.Div))})),{conversion:new l(p),prefixes:n}},M={Da:O("1.6605388628 x 10^-24 | g",T),u:O("| Da",_),meter:O("| m",_),meters:O("| m",_),in:O("254 / 10000 | m",_),ft:O("3048 / 10000 | m",_),yd:O("9144 / 10000 | m",_),mi:O("1609344 / 1000 | m",_),ly:O("9.4607 x 10^15 | m",_),nmi:O("1852 | m",_),"Å":O("10^-10 | m",_),pc:O("3.0857 x 10^16 | m",_),min:O("60 | s",_),hr:O("3600 | s",_),sec:O("| s",_),day:O("86400 | s",_),wk:O("604800 | s",_),fortnight:O("14 | day",_),shake:O("10^-8 | s",_),olympiad:O("126200000 | s",_),"°C":O("1 | K",_),"°F":O("5/9 | K",_),"°R":O("5/9 | K",_),e:O("1.6021765314 x 10^-19 | C",_),c:O("299792458 | m / s",_),kn:O("514/1000 | m / s",_),kt:O("| kn",_),knot:O("| kn",_),J:O("| N m",T),BTU:O("1060 | J",_),cal:O("4184 / 1000 | J",T),eV:O("1.602176514 x 10^-19 | J",T),erg:O("10^−7 | J",T),W:O("| J / s",T),"H-e":O("80 | W",_),N:O("1000 | g m / s s",T),lb:O("4448221615 / 1000000000 | N",_),dyn:O("10^-5 | N",_),Pa:O("1 | N / m m m",T),bar:O("10^5 | Pa",T),"㏔":O("1/1000 | bar",_),"㍴":O("| bar",_),atm:O("101325 | Pa",_),Torr:O("1/760 | atm",_),mmHg:O("| Torr",_),ha:O("10^4 | m m",_),b:O("10^−28 | m m",T),barn:O("| b",T),acre:O("4046.87 | m m",_),skilodge:O("10^-31 | m m",_),outhouse:O("10^-34 | m m",_),shed:O("10^-52 | m m",_),L:O("1/1000 | m m m",T),gal:O("3785/1000 | L",T),cup:O("1/16 | gal",_),qt:O("1/4 | gal",_),quart:O("| qt",_),p:O("1/8 | gal",_),pt:O("| p",_),pint:O("| p",_),"fl oz":O("1/8 | cup",_),"fl. oz.":O("1/8 | cup",_),tbsp:O("1/16 | cup",_),tsp:O("1/3 | tbsp",_),rev:O("2 pi | rad",_),deg:O("180 pi | rad",_),"°":O("| deg",_),arcminute:O("1/60 | deg",_),arcsec:O("1/3600 | deg",_),Hu:O("1000 | dB",T),dozen:O("12 |",_),mol:O("6.0221412927 x 10^23 |",T),"%":O("1/100 |",_),percent:O("| %",_),ppm:O("1/1000000 |",_),V:O("1000 | g m m / s s C",T),C:O("| A s",T),ampere:O("| A",_),"Ω":O("| V / A",T),ohm:O("| Ω",_),F:O("| C / V",T),H:O("| ohm s",T),T:O("1000 | g / C s",T),Wb:O("1000 | g m m / C s",T),lm:O("pi x 10^4 | cd / m m",_),lx:O("| lm / m m",_),nit:O("| cd / m m",_),sb:O("10^4 | cd / m m",_),stilb:O("1 | sb",_),apostilb:O("1 / pi x 10^(-4) | sb",_),blondel:O("| apostilb",_),asb:O("| apostilb",_),la:O("| lm",_),Lb:O("| lm",_),sk:O("10^-7 | lm",_),skot:O("| sk",_),bril:O("10^-11 | lm",_),Hz:O("| / s",T)};e.Add=o,e.Mul=l,e.Pow=c,e.Log=p,e.Eq=d,e.Trig=h,e.Abs=u,e.Func=g,e.Var=f,e.Const=v,e.Unit=C,e.Rational=b,e.Int=E,e.Float=w,e.Zero=y.Zero,e.One=y.One}(n),function(e){e.compare=function(e,n,r){var a={form:!1,simplify:!1};r=void 0!==r?t.extend(a,r):a;var s,i=e.sameVars(n);return i.equal?e.compare(n)?r.form&&!e.sameForm(n)?{equal:!1,message:"Your answer is not in the correct form."}:r.simplify&&!e.isSimplified()?{equal:!1,message:"Your answer is not fully expanded and simplified."}:{equal:!0,message:null}:{equal:!1,message:null}:(s=i.equalIgnoringCase?"Check your variables; one or more are using the wrong case (upper or lower).":"Check your variables; you may have used the wrong letter for one or more of them.",{equal:!1,wrongVariableCase:i.equalIgnoringCase,wrongVariableNames:!i.equalIgnoringCase,message:s})}}(n)}(yi);var bi=yi.exports,Ei=J,wi=Z({displayName:"SortableArea",propTypes:{className:Ei.string,components:Ei.arrayOf(Ei.node).isRequired,onReorder:Ei.func.isRequired,style:Ei.any,verify:Ei.func},getDefaultProps:function(){return{verify:()=>!0}},getInitialState:function(){return{dragging:null,components:this.props.components}},componentDidMount:function(){this._setDragEvents()},UNSAFE_componentWillReceiveProps:function(e){this.setState({components:e.components})},componentDidUpdate:function(){this._setDragEvents()},onDragStart:function(e){this.setState({dragging:e})},onDrop:function(){this.setState({dragging:null}),this.props.onReorder(this.state.components)},onDragEnter:function(e){if(this.state.dragging!==e){var t=this.state.components.slice(),n=t.splice(this.state.dragging,1);t.splice(e,0,n[0]);var r=this.props.verify(t);return r&&this.setState({dragging:e,components:t}),r}},_listenEvent:function(e){e.dataTransfer.setData("hackhackhack","because browsers!")},_cancelEvent:function(e){e.preventDefault()},_setDragEvents:function(){this._dragItems=this._dragItems||[];for(var e=te.findDOMNode(this).querySelectorAll("[draggable=true]"),t=[],n=[],r=0;r<this._dragItems.length;r++){var a=this._dragItems[r];e.indexOf(a)<0&&t.push(a)}for(var s=0;s<e.length;s++){var i=e[s];this._dragItems.indexOf(i)<0&&n.push(i)}for(var o=0;o<n.length;o++){var l=n[o];l.addEventListener("dragstart",this._listenEvent),l.addEventListener("drop",this._cancelEvent)}for(var c=0;c<t.length;c++){var p=t[c];p.removeEventListener("dragstart",this._listenEvent),p.removeEventListener("drop",this._cancelEvent)}},render:function(){var e=this.state.components.map(((e,t)=>G.createElement(xi,{index:t,component:e,area:this,key:e.key,draggable:e.props.draggable,dragging:t===this.state.dragging})));return G.createElement("ol",{className:this.props.className,style:this.props.style},e)}}),xi=Z({displayName:"SortableItem",propTypes:{area:Ei.shape({onDragEnter:Ei.func.isRequired,onDragStart:Ei.func.isRequired,onDrop:Ei.func.isRequired}),component:Ei.node.isRequired,dragging:Ei.bool.isRequired,draggable:Ei.bool.isRequired,index:Ei.number.isRequired},handleDragStart:function(e){e.nativeEvent.dataTransfer.effectAllowed="move",this.props.area.onDragStart(this.props.index)},handleDrop:function(){this.props.area.onDrop(this.props.index)},handleDragEnter:function(e){var t=this.props.area.onDragEnter(this.props.index);e.nativeEvent.dataTransfer.effectAllowed=t?"move":"none"},handleDragOver:function(e){e.preventDefault()},render:function(){var e="sortable-disabled";return this.props.dragging?e="sortable-dragging":this.props.draggable&&(e="sortable-enabled"),G.createElement("li",{draggable:this.props.draggable,className:e,onDragStart:this.handleDragStart,onDrop:this.handleDrop,onDragEnter:this.handleDragEnter,onDragOver:this.handleDragOver},this.props.component)}}),{InfoTip:Ci,PropCheckBox:ki,TexButtons:Si}=t,{getDependencies:Ni}=o,Ti=["correct","wrong","ungraded"],_i=J.shape({considered:J.oneOf(Ti).isRequired,value:J.string.isRequired,form:J.bool.isRequired,simplify:J.bool.isRequired}),Oi=e=>{var t=[];e.forEach((e=>{t[e.key]=!0}));for(var n=0;n<t.length;n++)if(!t[n])return n;return t.length};class Mi extends G.Component{constructor(e){var t,n;super(e),t=this,le(this,"change",(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return x.change.apply(t,n)})),le(this,"serialize",(()=>{var e=["value","form","simplify","considered","key"],t=["answerForms","buttonSets","functions","times"],n=this.props.answerForms.map((t=>X(t).pick(e)));return $a(this.props).set(["answerForms"],n).mod([],(e=>X(e).pick(t))).freeze()})),le(this,"getSaveWarnings",(()=>{var e=[];0===this.props.answerForms.length?e.push("No answers specified"):(!!X(this.props.answerForms).find((e=>"correct"===e.considered))||e.push("No correct answer specified"),X(this.props.answerForms).each(((t,n)=>{if(""===this.props.value)e.push("Answer ".concat(n+1," is empty"));else{var r=bi.parse(t.value,{functions:this.props.functions});r.parsed?t.simplify&&!r.expr.isSimplified()&&e.push("".concat(t.value,' isn\'t simplified, but is required" +\n " to be')):e.push("Couldn't parse ".concat(t.value))}})));return e})),le(this,"_newEmptyAnswerForm",(()=>({considered:"correct",form:!1,key:Oi(this.props.answerForms),simplify:!1,value:""}))),le(this,"newAnswer",(()=>{var e=this.props.answerForms.slice();e.push(this._newEmptyAnswerForm()),this.change({answerForms:e})})),le(this,"handleRemoveForm",(e=>{var t=this.props.answerForms.slice();t.splice(e,1),this.change({answerForms:t})})),le(this,"updateForm",((e,t)=>{var n=$a(this.props.answerForms).merge([e],t).freeze();this.change({answerForms:n})})),le(this,"handleReorder",(e=>{var t=X(e).map((e=>{var t=X(e.props).pick("considered","form","simplify","value");return t.key=e.key,t}));this.change({answerForms:t})})),le(this,"handleButtonSet",(e=>{var t=X(Si.buttonSets).keys(),n=X(t).filter((t=>X(this.props.buttonSets).contains(t)!==(t===e)));this.props.onChange({buttonSets:n})})),le(this,"handleToggleDiv",(()=>{var e,t;X(this.props.buttonSets).contains("basic+div")?(e="basic",t="basic+div"):(e="basic+div",t="basic");var n=X(this.props.buttonSets).reject((e=>e===t)).concat(e);this.change("buttonSets",n)})),le(this,"handleTexInsert",(e=>{this.refs.expression.insert(e)})),le(this,"handleFunctions",(e=>{var t={};t.functions=X.compact(e.target.value.split(/[ ,]+/)),this.props.onChange(t)})),n=0===e.answerForms.length||X(e.answerForms).any((e=>{var{value:t}=e;return-1!==X.indexOf(t,"\\")||-1!==X.indexOf(t,"{")})),this.state={isTex:n}}render(){var e=this.props.answerForms.map(((e,t)=>{var n={times:this.props.times,functions:this.props.functions,buttonSets:this.props.buttonSets,buttonsVisible:"focused",form:e.form,simplify:e.simplify,value:e.value,onChange:e=>this.updateForm(t,e),trackInteraction:()=>{},widgetId:this.props.widgetId+"-"+t};return $a(e).merge([],{draggable:!0,onChange:e=>this.updateForm(t,e),onDelete:()=>this.handleRemoveForm(t),expressionProps:n}).freeze()})).map(((e,t)=>G.createElement(Ai,ce({key:t},e)))),t=G.createElement(wi,{components:e,onReorder:this.handleReorder,className:"answer-options-list"}),n=X(Si.buttonSets).map(((e,t)=>{var n="basic"===t,r=X.contains(this.props.buttonSets,t)||n,a=n?"button-set-label-float":"button-set-label";return G.createElement("label",{className:a,key:t},G.createElement("input",{type:"checkbox",checked:r,disabled:n,onChange:()=>this.handleButtonSet(t)}),t)})),{TeX:r}=Ni();return n.splice(1,1,G.createElement("label",{key:"show-div"},G.createElement("input",{type:"checkbox",onChange:this.handleToggleDiv}),G.createElement("span",{className:"show-div-button"},"show ",G.createElement(r,null,"\\div")," button"))),G.createElement("div",{className:"perseus-widget-expression-editor"},G.createElement("h3",{className:"expression-editor-h3"},"Global Options"),G.createElement("div",null,G.createElement(ki,{times:this.props.times,onChange:this.props.onChange,labelAlignment:"right",label:"Use × for rendering multiplication instead of a center dot."}),G.createElement(Ci,null,G.createElement("p",null,"For pre-algebra problems this option displays multiplication as \\times instead of \\cdot in both the rendered output and the acceptable formats examples."))),G.createElement("div",null,G.createElement("label",null,"Function variables: ",G.createElement("input",{type:"text",defaultValue:this.props.functions.join(" "),onChange:this.handleFunctions})),G.createElement(Ci,null,G.createElement("p",null,'Single-letter variables listed here will be interpreted as functions. This let us know that f(x) means "f of x" and not "f times x".'))),G.createElement("div",null,G.createElement("div",null,"Button sets:"),n),this.state.isTex&&G.createElement(Si,{className:"math-input-buttons",sets:this.props.buttonSets,convertDotToTimes:this.props.times,onInsert:this.handleTexInsert}),G.createElement("h3",{className:"expression-editor-h3"},"Answers"),G.createElement("p",{style:{margin:"4px 0"}},"student responses area matched against these from top to bottom"),t,G.createElement("div",null,G.createElement("button",{className:"simple-button orange",style:{fontSize:13},onClick:this.newAnswer,type:"button"},"Add new answer")))}}le(Mi,"propTypes",oe(oe({},x.propTypes),{},{answerForms:J.arrayOf(_i),times:J.bool,buttonSets:Si.buttonSetsType,functions:J.arrayOf(J.string)})),le(Mi,"widgetName","expression"),le(Mi,"defaultProps",{answerForms:[],times:!1,buttonSets:["basic"],functions:["f","g","h"]});class Ai extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"state",{deleteFocused:!1}),le(this,"handleDeleteBlur",(()=>{this.setState({deleteFocused:!1})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleImSure",(()=>{this.props.onDelete()})),le(this,"handleDelete",(()=>{this.setState({deleteFocused:!0})})),le(this,"toggleConsidered",(()=>{var e,t,n,r=(e=Ti,t=this.props.considered,n=X(e).indexOf(t),e[n=(n+1)%e.length]);this.change({considered:r})}))}render(){var e=null;return e=this.state.deleteFocused?G.createElement("button",{type:"button",className:"simple-button orange",onClick:this.handleImSure,onBlur:this.handleDeleteBlur},"I'm sure!"):G.createElement("button",{type:"button",className:"simple-button orange",onClick:this.handleDelete},"Delete"),G.createElement("div",{className:"expression-answer-option"},G.createElement("div",{className:"answer-handle"}),G.createElement("div",{className:"answer-body"},G.createElement("div",{className:"answer-considered"},G.createElement("div",{onClick:this.toggleConsidered,className:"answer-status "+this.props.considered},this.props.considered),G.createElement("div",{className:"answer-expression"},G.createElement(S,this.props.expressionProps))),G.createElement("div",{className:"answer-option"},G.createElement(ki,{form:this.props.form,onChange:this.props.onChange,labelAlignment:"right",label:"Answer expression must have the same form."}),G.createElement(Ci,null,G.createElement("p",null,"The student's answer must be in the same form. Commutativity and excess negative signs are ignored."))),G.createElement("div",{className:"answer-option"},G.createElement(ki,{simplify:this.props.simplify,onChange:this.props.onChange,labelAlignment:"right",label:"Answer expression must be fully expanded and simplified."}),G.createElement(Ci,null,G.createElement("p",null,'The student\'s answer must be fully expanded and simplified. Answering this equation (x^2+2x+1) with this factored equation (x+1)^2 will render this response "Your answer is not fully expanded and simplified."'))),G.createElement("div",{className:"remove-container"},e)))}}le(Ai,"propTypes",oe(oe({},x.propTypes),{},{considered:J.oneOf(Ti).isRequired,expressionProps:J.object.isRequired,form:J.bool.isRequired,simplify:J.bool.isRequired,onChange:J.func.isRequired,onDelete:J.func.isRequired}));var{InlineIcon:Pi,TextInput:Di}=t,{iconPlus:Ii,iconTrash:Ri}=p;class zi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleAddHint",(()=>{this.props.onChange({hint:{content:""}},(()=>{this.refs["hint-editor"].focus()}))})),le(this,"handleRemoveHint",(e=>{this.props.onChange({hint:null})})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(()=>oe(oe({title:this.props.title},this.refs.editor.serialize()),{},{hint:this.refs["hint-editor"]&&this.refs["hint-editor"].serialize()})))}render(){return G.createElement("div",{className:"perseus-group-editor"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",{className:re(Li.title)},"Title:"," ",G.createElement(Di,{value:this.props.title,className:re(Li.input),onChange:this.change("title")}))),G.createElement(Sr,{ref:"editor",content:this.props.content,widgets:this.props.widgets,apiOptions:this.props.apiOptions,images:this.props.images,widgetEnabled:!0,immutableWidgets:!1,onChange:this.props.onChange,warnNoPrompt:!0,warnNoWidgets:!0}),!this.props.hint&&G.createElement("button",{type:"button",style:{marginTop:10},className:"add-hint simple-button orange",onClick:this.handleAddHint},G.createElement(Pi,Ii)," Add a hint"),this.props.hint&&G.createElement("div",{className:"perseus-hint-editor"},G.createElement("div",{className:re(Li.hintsTitle)},"Hint"),G.createElement(Sr,{ref:"hint-editor",content:this.props.hint?this.props.hint.content:"",widgets:this.props.hint?this.props.hint.widgets:{},apiOptions:this.props.apiOptions,images:this.props.hint&&this.props.hint.images,widgetEnabled:!0,immutableWidgets:!1,onChange:e=>{this.change("hint",Object.assign({},this.props.hint,e))}}),G.createElement("button",{type:"button",className:"remove-hint simple-button orange",onClick:this.handleRemoveHint},G.createElement(Pi,Ri)," Remove this hint")))}}le(zi,"propTypes",oe(oe({},x.propTypes),{},{title:J.string,content:J.string,widgets:J.object,images:J.object,apiOptions:u.propTypes})),le(zi,"widgetName","graded-group"),le(zi,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null});var Li=ne.create({title:{fontSize:18,fontWeight:"bold"},input:{fontSize:18},hintsTitle:{marginTop:10,fontSize:"110%",fontWeight:"bold"}});class Fi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_editors",void 0),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"getSaveWarnings",(()=>[].concat(...this._editors.map((e=>e?e.getSaveWarnings():[]))))),le(this,"serialize",(()=>({gradedGroups:this.props.gradedGroups}))),le(this,"renderGroups",(()=>this.props.gradedGroups?this.props.gradedGroups.map(((e,t)=>G.createElement(zi,ce({key:t,ref:e=>this._editors[t]=e},e,{apiOptions:this.props.apiOptions,widgetEnabled:!0,immutableWidgets:!1,onChange:e=>this.change("gradedGroups",qi(this.props.gradedGroups,t,oe(oe({},this.props.gradedGroups[t]),e)))})))):null)),le(this,"addGroup",(()=>{var e=this.props.gradedGroups||[];this.change("gradedGroups",e.concat([zi.defaultProps]))}))}UNSAFE_componentWillMount(){this._editors=[]}render(){return G.createElement("div",{className:"perseus-group-editor"},this.renderGroups(),G.createElement("button",{onClick:this.addGroup},"Add group"))}}le(Fi,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,gradedGroups:J.array,onChange:J.func.isRequired})),le(Fi,"widgetName","graded-group-set"),le(Fi,"defaultProps",{gradedGroups:[]});var qi=(e,t,n)=>[...e.slice(0,t),n,...e.slice(t+1)],{ButtonGroup:Ui,InfoTip:Wi,PropCheckBox:Vi,RangeInput:ji}=t,{getDependencies:Bi}=o,$i={url:null,width:0,height:0};var Hi=Z({displayName:"GraphSettings",propTypes:oe(oe({},x.propTypes),{},{editableSettings:J.arrayOf(J.oneOf(["canvas","graph","snap","image","measure"])),box:J.arrayOf(J.number),labels:J.arrayOf(J.string),range:J.arrayOf(J.arrayOf(J.number)),step:J.arrayOf(J.number),gridStep:J.arrayOf(J.number),snapStep:J.arrayOf(J.number),valid:J.oneOfType([J.bool,J.string]),backgroundImage:J.object,markings:J.oneOf(["graph","grid","none"]),showProtractor:J.bool,showRuler:J.bool,showTooltips:J.bool,rulerLabel:J.string,rulerTicks:J.number}),getDefaultProps:function(){return{editableSettings:["graph","snap","image","measure"],box:[N.defaultBoxSizeSmall,N.defaultBoxSizeSmall],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[1,1],valid:!0,backgroundImage:$i,markings:"graph",showProtractor:!1,showRuler:!1,showTooltips:!1,rulerLabel:"",rulerTicks:10}},getInitialState:function(){return this.stateFromProps(this.props)},componentDidMount:function(){this._isMounted=!0,this.changeGraph=X.debounce(this.changeGraph,300)},UNSAFE_componentWillReceiveProps:function(e){X.isEqual(this.props.labels,e.labels)&&X.isEqual(this.props.gridStep,e.gridStep)&&X.isEqual(this.props.snapStep,e.snapStep)&&X.isEqual(this.props.step,e.step)&&X.isEqual(this.props.range,e.range)&&X.isEqual(this.props.backgroundImage,e.backgroundImage)||this.setState(this.stateFromProps(e))},componentWillUnmount:function(){this._isMounted=!1},stateFromProps:function(e){return{labelsTextbox:e.labels,gridStepTextbox:e.gridStep,snapStepTextbox:e.snapStep,stepTextbox:e.step,rangeTextbox:e.range,backgroundImage:X.clone(e.backgroundImage)}},change(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.change.apply(this,t)},changeRulerLabel:function(e){this.change({rulerLabel:e.target.value})},changeRulerTicks:function(e){this.change({rulerTicks:+e.target.value})},changeBackgroundUrl:function(e){if("keypress"!==e.type||"Enter"===e.key){var t=(e,t,n)=>{var r=X.clone(this.props.backgroundImage);r.url=e,r.width=t,r.height=n,this.setState({backgroundImage:r},this.changeGraph)},n=te.findDOMNode(this.refs["bg-url"]).value;n?r.getImageSize(n,((e,r)=>{this._isMounted&&t(n,e,r)})):t(null,0,0)}},renderLabelChoices:function(e){return X.map(e,(function(e){return G.createElement("option",{value:e[1]},e[0])}))},validRange:function(e){return X.every(e,(function(e){return X.isFinite(e)}))?!(e[0]>=e[1])||"Range must have a higher number on the right":"Range must be a valid number"},validateStepValue:function(e){var{step:t,range:n,name:r,minTicks:a,maxTicks:s}=e;if(!X.isFinite(t))return r+" must be a valid number";var i=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,t);return i<a?r+" is too large, there must be at least "+a+" ticks.":!(i>s)||r+" is too small, there can be at most "+s+" ticks."},validSnapStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Snap step",minTicks:5,maxTicks:60})},validGridStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Grid step",minTicks:3,maxTicks:60})},validStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Step",minTicks:3,maxTicks:20})},validBackgroundImageSize:function(e){return!e.url||(!!(e.width<=450&&e.height<=450)||"Image must be smaller than 450px x 450px.")},validateGraphSettings:function(e,t,n,r,a){var s,i=this,o=X.every(e,(function(e){return!0===(s=i.validRange(e))}));if(!o)return s;var l=X.every(t,(function(t,n){return!0===(s=i.validStep(t,e[n]))}));if(!l)return s;var c=X.every(n,(function(t,n){return!0===(s=i.validGridStep(t,e[n]))}));if(!c)return s;var p=X.every(r,(function(t,n){return!0===(s=i.validSnapStep(t,e[n]))}));if(!p)return s;var h=this.validBackgroundImageSize(a);return!0===h||(s=h)},changeLabel:function(e,t){var n=t.target.value,r=this.state.labelsTextbox.slice();r[e]=n,this.setState({labelsTextbox:r},this.changeGraph)},changeRange:function(e,t){var n=this.state.rangeTextbox.slice();n[e]=t;var a=this.state.stepTextbox.slice(),s=this.state.gridStepTextbox.slice(),i=this.state.snapStepTextbox.slice(),o=r.scaleFromExtent(n[e],this.props.box[e]);!0===this.validRange(n[e])&&(a[e]=r.tickStepFromExtent(n[e],this.props.box[e]),s[e]=r.gridStepFromTickStep(a[e],o),i[e]=s[e]/2),this.setState({stepTextbox:a,gridStepTextbox:s,snapStepTextbox:i,rangeTextbox:n},this.changeGraph)},changeStep:function(e){this.setState({stepTextbox:e},this.changeGraph)},changeSnapStep:function(e){this.setState({snapStepTextbox:e},this.changeGraph)},changeGridStep:function(e){this.setState({gridStepTextbox:e,snapStepTextbox:X.map(e,(function(e){return e/2}))},this.changeGraph)},changeGraph:function(){var e=this.state.labelsTextbox,t=X.map(this.state.rangeTextbox,(function(e){return X.map(e,Number)})),n=X.map(this.state.stepTextbox,Number),r=this.state.gridStepTextbox,a=this.state.snapStepTextbox,s=this.state.backgroundImage,i=this.validateGraphSettings(t,n,r,a,s);!0===i?this.change({valid:!0,labels:e,range:t,step:n,gridStep:r,snapStep:a,backgroundImage:s}):this.change({valid:i})},render:function(){var e=[T.roundTo(2,r.scaleFromExtent(this.props.range[0],this.props.box[0])),T.roundTo(2,r.scaleFromExtent(this.props.range[1],this.props.box[1]))],{TeX:t}=Bi();return G.createElement("div",null,X.contains(this.props.editableSettings,"canvas")&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Canvas size (x,y pixels)",G.createElement(ji,{value:this.props.box,onChange:e=>{this.change({box:e})}})),G.createElement("div",{className:"perseus-widget-row"},"Scale (px per div):"," ",G.createElement(t,null,"("+e[0]+", "+e[1]+")"))),X.contains(this.props.editableSettings,"graph")&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"}," ","x Label",G.createElement("input",{type:"text",className:"graph-settings-axis-label",ref:"labels-0",onChange:e=>this.changeLabel(0,e),value:this.state.labelsTextbox[0]||""})),G.createElement("div",{className:"perseus-widget-right-col"},"y Label",G.createElement("input",{type:"text",className:"graph-settings-axis-label",ref:"labels-1",onChange:e=>this.changeLabel(1,e),value:this.state.labelsTextbox[1]||""}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"x Range",G.createElement(ji,{value:this.state.rangeTextbox[0],onChange:e=>this.changeRange(0,e)})),G.createElement("div",{className:"perseus-widget-right-col"},"y Range",G.createElement(ji,{value:this.state.rangeTextbox[1],onChange:e=>this.changeRange(1,e)}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Tick Step",G.createElement(ji,{value:this.state.stepTextbox,onChange:this.changeStep})),G.createElement("div",{className:"perseus-widget-right-col"},"Grid Step",G.createElement(ji,{value:this.state.gridStepTextbox,onChange:this.changeGridStep}))),X.contains(this.props.editableSettings,"snap")&&G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Snap Step",G.createElement(ji,{value:this.state.snapStepTextbox,onChange:this.changeSnapStep}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Markings: "),G.createElement(Ui,{value:this.props.markings,allowEmpty:!1,buttons:[{value:"graph",content:"Graph"},{value:"grid",content:"Grid"},{value:"none",content:"None"}],onChange:this.change("markings")})),G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(Vi,{label:"Show tooltips",showTooltips:this.props.showTooltips,onChange:this.change}))),X.contains(this.props.editableSettings,"image")&&G.createElement("div",{className:"image-settings"},G.createElement("div",null,"Background image:"),G.createElement("div",null,"Url:"," ",G.createElement("input",{type:"text",className:"graph-settings-background-url",ref:"bg-url",value:this.state.backgroundImage.url||"",onChange:e=>{var t=X.clone(this.props.backgroundImage);t.url=e.target.value,this.setState({backgroundImage:t})},onKeyPress:this.changeBackgroundUrl,onBlur:this.changeBackgroundUrl}),G.createElement(Wi,null,G.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.')))),X.contains(this.props.editableSettings,"measure")&&G.createElement("div",{className:"misc-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(Vi,{label:"Show ruler",showRuler:this.props.showRuler,onChange:this.change})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(Vi,{label:"Show protractor",showProtractor:this.props.showProtractor,onChange:this.change}))),this.props.showRuler&&G.createElement("div",null,G.createElement("div",null,G.createElement("label",null," ","Ruler label:"," ",G.createElement("select",{onChange:this.changeRulerLabel,value:this.props.rulerLabel},G.createElement("option",{value:""},"None"),G.createElement("optgroup",{label:"Metric"},this.renderLabelChoices([["milimeters","mm"],["centimeters","cm"],["meters","m"],["kilometers","km"]])),G.createElement("optgroup",{label:"Imperial"},this.renderLabelChoices([["inches","in"],["feet","ft"],["yards","yd"],["miles","mi"]]))))),G.createElement("div",null,G.createElement("label",null," ","Ruler ticks:"," ",G.createElement("select",{onChange:this.changeRulerTicks,value:this.props.rulerTicks},X.map([1,2,4,8,10,16],(function(e){return G.createElement("option",{value:e},e)}))))))))}}),{InfoTip:Gi,MultiButtonGroup:Yi}=t,{containerSizeClass:Ki,getInteractiveBoxFromSizeClass:Xi}=M,Ji=_.widget,{DEFAULT_GRAPHER_PROPS:Zi,allTypes:Qi,chooseType:eo,defaultPlotProps:to,getEquationString:no,typeToButton:ro}=O;class ao extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleAvailableTypesChange",(e=>{var t=this.props.correct;if(!X.contains(e,this.props.correct.type)){var n=this.props.graph,r=eo(e);t=to(r,n)}this.props.onChange({availableTypes:e,correct:t})})),le(this,"serialize",(()=>X.chain(this.props).pick("correct","availableTypes").extend({graph:X.omit(this.props.graph,"box")}).value()))}render(){var e,t,n=Ki.SMALL;if(!0===this.props.graph.valid){var r={graph:this.props.graph,plot:this.props.correct,availableTypes:this.props.availableTypes,onChange:(e,t)=>{var n,r=this.props.correct;r=r.type===(null===(n=e.plot)||void 0===n?void 0:n.type)?X.extend({},r,e.plot):e.plot,this.props.onChange({correct:r},t)},trackInteraction:function(){}};t=G.createElement(Ji,ce({},r,{apiOptions:this.props.apiOptions,containerSizeClass:n})),e=no(r)}else t=G.createElement("div",{className:"perseus-error"},this.props.graph.valid);return G.createElement("div",null,G.createElement("div",null,"Correct answer"," ",G.createElement(Gi,null,G.createElement("p",null,"Graph the correct answer in the graph below and ensure the equation or point coordinates displayed represent the correct answer."))," ",": ",e),G.createElement(Hi,{editableSettings:["graph","snap","image"],box:Xi(n),range:this.props.graph.range,labels:this.props.graph.labels,step:this.props.graph.step,gridStep:this.props.graph.gridStep,snapStep:this.props.graph.snapStep,valid:this.props.graph.valid,backgroundImage:this.props.graph.backgroundImage,markings:this.props.graph.markings,rulerLabel:this.props.graph.rulerLabel,rulerTicks:this.props.graph.rulerTicks,showTooltips:this.props.graph.showTooltips,onChange:this.change("graph")}),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Available functions: "),G.createElement(Yi,{allowEmpty:!1,values:this.props.availableTypes,buttons:X.map(Qi,ro),onChange:this.handleAvailableTypesChange})),t)}}le(ao,"propTypes",oe({},x.propTypes)),le(ao,"widgetName","grapher"),le(ao,"defaultProps",{correct:Zi.plot,graph:Zi.graph,availableTypes:Zi.availableTypes});class so extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_renderMetadataEditor",(()=>{var e=this.props.apiOptions.GroupMetadataEditor;return G.createElement(e,{value:this.props.metadata,onChange:this.change("metadata")})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(()=>X.extend({},this.refs.editor.serialize(),{metadata:this.props.metadata})))}render(){return G.createElement("div",{className:"perseus-group-editor"},G.createElement("div",null,this._renderMetadataEditor()),G.createElement(Sr,{ref:"editor",content:this.props.content,widgets:this.props.widgets,apiOptions:this.props.apiOptions,images:this.props.images,widgetEnabled:!0,immutableWidgets:!1,onChange:this.props.onChange}))}}le(so,"propTypes",oe(oe({},x.propTypes),{},{content:J.string,widgets:J.object,images:J.object,metadata:J.any,apiOptions:u.propTypes})),le(so,"widgetName","group"),le(so,"defaultProps",{content:"",widgets:{},images:{},metadata:void 0});var{PropCheckBox:io}=t;class oo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("fieldset",null,G.createElement("label",null,"Name:",G.createElement(Ms,{value:this.props.name,onChange:this.change("name")})),G.createElement("label",null,"Value:",G.createElement(Ms,{value:this.props.value,onChange:this.change("value")})))}}le(oo,"propTypes",oe(oe({},x.propTypes),{},{name:J.string,value:J.string})),le(oo,"defaultProps",{name:"",value:""});class lo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handlePairChange",((e,t)=>{var n=this.props.pairs.slice();n[e]=t;var r=n[n.length-1];r.name&&r.value&&n.push({name:"",value:""}),this.change("pairs",n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=X.map(this.props.pairs,((e,t)=>G.createElement(oo,{key:t,name:e.name,value:e.value,onChange:this.handlePairChange.bind(this,t)})));return G.createElement("div",null,e)}}le(lo,"propTypes",oe(oe({},x.propTypes),{},{pairs:J.arrayOf(J.shape({name:J.string,value:J.string})).isRequired}));class co extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleSettingsChange",(e=>{this.change({settings:e.pairs})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",{style:{fontWeight:"bold",textAlign:"center"}},"This widget is deprecated! ",G.createElement("br",null),"Try using the Video or CS Program widgets instead."),G.createElement("label",null,"Url or Program ID:",G.createElement(Ms,{value:this.props.url,onChange:this.change("url")})),G.createElement("br",null),G.createElement("label",null,"Settings:",G.createElement(lo,{name:"settings",pairs:this.props.settings,onChange:this.handleSettingsChange})),G.createElement("br",null),G.createElement("label",null,"Width:",G.createElement(Ms,{value:this.props.width,onChange:this.change("width")})),G.createElement("label",null,"Height:",G.createElement(Ms,{value:this.props.height,onChange:this.change("height")})),G.createElement(io,{label:"Allow full screen",allowFullScreen:this.props.allowFullScreen,onChange:this.props.onChange}),G.createElement("br",null),G.createElement(io,{label:"Allow iframe content to redirect the page",allowTopNavigation:this.props.allowTopNavigation,onChange:this.props.onChange}))}}le(co,"propTypes",oe({},x.propTypes)),le(co,"widgetName","iframe"),le(co,"defaultProps",{url:"",settings:[{name:"",value:""}],width:"400",height:"400",allowFullScreen:!1,allowTopNavigation:!1});var{InfoTip:po,InlineIcon:ho,RangeInput:uo}=t,mo=[0,10],go={url:null,width:0,height:0},fo=new RegExp("^(https?|web\\+graphie)://[^/]*(ka-.*.s3.amazonaws.com|(fastly|cdn).kastatic.org|khanacademy.org|kasandbox.org)"),vo=["center","above","above right","right","below right","below","below left","left","above left"],yo=Z({displayName:"ImageEditor",propTypes:oe({},x.propTypes),statics:{widgetName:"image"},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},getDefaultProps:function(){return{title:"",range:[mo,mo],box:[400,400],backgroundImage:go,labels:[],alt:"",caption:""}},getInitialState:function(){return{backgroundImageError:""}},render:function(){var e=this.props.backgroundImage,t=G.createElement("div",{className:"image-settings"},G.createElement("div",null,G.createElement("label",null,G.createElement("div",null,"Alt text:",G.createElement(po,null,"This is important for screenreaders. The content of this alt text will be formatted as markdown (tables, emphasis, etc. are supported).")),G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.alt,onChange:e=>{null!=e.content&&this.change("alt",e.content)},widgetEnabled:!1}))),G.createElement("div",null,G.createElement("label",null,G.createElement("div",null,"Caption:"),G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.caption,onChange:e=>{null!=e.content&&this.change("caption",e.content)},widgetEnabled:!1})))),n=G.createElement("div",{className:"renderer-widget-error"},this.state.backgroundImageError);return G.createElement("div",{className:"perseus-image-editor"},G.createElement("label",null,"Image url:",G.createElement(po,null,"Paste an image or graphie image URL."),this.state.backgroundImageError&&n,G.createElement(Ms,{value:e.url||"",style:{width:332},onChange:e=>this.onUrlChange(e,!1)})),e.url&&t)},_renderRowForLabel:function(e,t){return G.createElement("tr",{key:t},G.createElement("td",null,G.createElement(uo,{value:e.coordinates,onChange:this.onCoordinateChange.bind(this,t)})),G.createElement("td",{style:{verticalAlign:"bottom",width:"5px"}},G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:e.content,onChange:this.onContentChange.bind(this,t)})),G.createElement("td",null,G.createElement("select",{className:"perseus-widget-dropdown",value:e.alignment,onChange:this.onAlignmentChange.bind(this,t)},vo.map((function(e,t){return G.createElement("option",{key:""+t,value:e},e)}),this))),G.createElement("td",null,G.createElement("a",{href:"#",className:"simple-button orange delete-label",title:"Remove this label",onClick:this.removeLabel.bind(this,t)},G.createElement(ho,p.iconTrash))))},change(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.change.apply(this,t)},removeLabel:function(e,t){t.preventDefault();var n=X(this.props.labels).clone();n.splice(e,1),this.props.onChange({labels:n})},onCoordinateChange:function(e,t){var n=this.props.labels.slice();n[e]=X.extend({},n[e],{coordinates:t}),this.props.onChange({labels:n})},onContentChange:function(e,t){var n=t.target.value,r=this.props.labels.slice();r[e]=X.extend({},r[e],{content:n}),this.props.onChange({labels:r})},onAlignmentChange:function(e,t){var n=t.target.value,r=this.props.labels.slice();r[e]=X.extend({},r[e],{alignment:n}),this.props.onChange({labels:r})},setUrl:function(e,t,n,r){if(this._isMounted){var a=X.clone(this.props.backgroundImage);a.url=e,a.width=t,a.height=n;var s=[a.width,a.height];this.props.onChange({backgroundImage:a,box:s},null,r)}},onUrlChange:function(e,t){fo.test(e)?(this.setState({backgroundImageError:""}),this._leadingUrl=e,e?r.getImageSize(e,((t,n)=>{this._leadingUrl===e&&this.setUrl(e,t,n,!0)})):this.setUrl(e,0,0,t)):this.setState({backgroundImageError:"Images must be from sites hosted by Khan Academy. Please input a Khan Academy-owned address, or use the Add Image tool to rehost an existing image"})},onRangeChange:function(e,t){var n=this.props.range.slice();n[e]=t,this.props.onChange({range:n})},serialize(){return C.serialize.call(this)}}),{InfoTip:bo}=t,Eo={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"}};class wo extends G.Component{constructor(){super(...arguments),le(this,"handleAnswerChange",(e=>{var t=r.firstNumericalParse(e)||0;this.props.onChange({value:t})})),le(this,"focus",(()=>(te.findDOMNode(this.refs.input).focus(),!0))),le(this,"serialize",(()=>X.pick(this.props,"value","simplify","size","inexact","maxError","answerType","rightAlign")))}render(){var e=X.map(Eo,(function(e,t){return G.createElement("option",{value:t,key:t},e.name)}),this);return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"Correct answer:"," ",G.createElement(Ms,{value:""+this.props.value,onChange:this.handleAnswerChange,ref:"input"}))),G.createElement("div",null,G.createElement("label",null,"Unsimplified answers"," ",G.createElement("select",{value:this.props.simplify,onChange:e=>{this.props.onChange({simplify:e.target.value})}},G.createElement("option",{value:"required"},"will not be graded"),G.createElement("option",{value:"optional"},"will be accepted"),G.createElement("option",{value:"enforced"},"will be marked wrong"))),G.createElement(bo,null,G.createElement("p",null,'Normally select "will not be graded". This will give the user a message saying the answer is correct but not simplified. The user will then have to simplify it and re-enter, but will not be penalized. (5th grade and anything after)'),G.createElement("p",null,'Select "will be accepted" only if the user is not expected to know how to simplify fractions yet. (Anything prior to 5th grade)'),G.createElement("p",null,'Select "will be marked wrong" only if we are specifically assessing the ability to simplify.'))),G.createElement("div",null,G.createElement("label",null,G.createElement("input",{type:"checkbox",checked:this.props.inexact,onChange:e=>{this.props.onChange({inexact:e.target.checked})}})," ","Allow inexact answers"),G.createElement("label",null,G.createElement("input",{type:"checkbox",style:{visibility:"hidden"}}),"Max error:"," ",G.createElement("input",{type:"text",disabled:!this.props.inexact,defaultValue:this.props.maxError,onBlur:e=>{var t=""+(r.firstNumericalParse(e.target.value)||0);e.target.value=t,this.props.onChange({maxError:t})}}))),G.createElement("div",null,"Answer type:"," ",G.createElement("select",{value:this.props.answerType,onChange:e=>{this.props.onChange({answerType:e.target.value})}},e),G.createElement(bo,null,G.createElement("p",null,'Use the default "Numbers" unless the answer must be in a specific form (e.g., question is about converting decimals to fractions).'))),G.createElement("div",null,G.createElement("label",null,"Width"," ",G.createElement("select",{value:this.props.size,onChange:e=>{this.props.onChange({size:e.target.value})}},G.createElement("option",{value:"normal"},"Normal (80px)"),G.createElement("option",{value:"small"},"Small (40px)"))),G.createElement(bo,null,G.createElement("p",null,'Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.'))),G.createElement("div",null,G.createElement("label",null,G.createElement("input",{type:"checkbox",checked:this.props.rightAlign,onChange:e=>{this.props.onChange({rightAlign:e.target.checked})}})," ","Right alignment")))}}le(wo,"propTypes",{value:J.number,simplify:J.oneOf(["required","optional","enforced"]),size:J.oneOf(["normal","small"]),inexact:J.bool,maxError:J.number,answerType:J.string,rightAlign:J.bool}),le(wo,"widgetName","input-number"),le(wo,"defaultProps",{value:0,simplify:"required",size:"normal",inexact:!1,maxError:.1,answerType:"number",rightAlign:!1});var{ButtonGroup:xo,MathInput:Co,NumberInput:ko}=t;class So extends G.Component{constructor(){super(...arguments),le(this,"change",(e=>x.change.call(this,e)))}render(){var{TeX:e}=o.getDependencies();return G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},"Constraint:"," ",G.createElement(xo,{value:this.props.constraint,allowEmpty:!1,buttons:[{value:"none",content:"None"},{value:"snap",content:"Snap"},{value:"x",content:"x="},{value:"y",content:"y="}],onChange:this.change("constraint")})),"snap"===this.props.constraint&&G.createElement("div",{className:"perseus-widget-row"},"Snap:"," ",G.createElement(ko,{value:this.props.snap,placeholder:0,onChange:this.change("snap")})),"x"===this.props.constraint&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"x=")," ",G.createElement(Co,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintFn,onChange:this.change("constraintFn")}))),"y"===this.props.constraint&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"y=")," ",G.createElement(Co,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintFn,onChange:this.change("constraintFn")}))),"Ensure these are set so nothing can be dragged off the canvas:",G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"x \\in \\Large[")," ",G.createElement(Co,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintXMin,onChange:this.change("constraintXMin")}),G.createElement(e,null,", ")," ",G.createElement(Co,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintXMax,onChange:this.change("constraintXMax")})," ",G.createElement(e,null,"\\Large]"))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"y \\in \\Large[")," ",G.createElement(Co,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintYMin,onChange:this.change("constraintYMin")}),G.createElement(e,null,", ")," ",G.createElement(Co,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintYMax,onChange:this.change("constraintYMax")})," ",G.createElement(e,null,"\\Large]"))))}}le(So,"defaultProps",{constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"});var{MathInput:No,NumberInput:To,TextInput:_o}=t,{getDependencies:Oo}=o,{unescapeMathMode:Mo}=r;class Ao extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Coordinate: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})))}}le(Ao,"propTypes",oe(oe({},x.propTypes),{},{coordX:J.string,coordY:J.string,color:J.string})),le(Ao,"defaultProps",{coordX:"0",coordY:"0",color:A.BLACK});class Po extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Start: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"End: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.endX,onChange:this.change("endX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.endY,onChange:this.change("endY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(D,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})," ",G.createElement(I,{value:this.props.arrows,onChange:this.change("arrows")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Width:"," ",G.createElement(To,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}le(Po,"propTypes",oe(oe({},x.propTypes),{},{startX:J.string,startY:J.string,endX:J.string,endY:J.string,color:J.string,strokeDasharray:J.string,arrows:J.string,strokeWidth:J.number})),le(Po,"defaultProps",{startX:"-5",startY:"5",endX:"5",endY:"5",color:A.BLACK,strokeDasharray:"",arrows:"",strokeWidth:2});class Do extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Start: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"Update ",G.createElement(e,null,"(x_n, y_n)")," for ",G.createElement(e,null,"n =")," ",G.createElement(To,{value:this.props.varSubscript,placeholder:0,onChange:this.change("varSubscript")})),G.createElement(So,this.props))}}le(Do,"propTypes",oe(oe({},x.propTypes),{},{startX:J.string,startY:J.string,constraint:J.string,snap:J.number,constraintFn:J.string})),le(Do,"defaultProps",{startX:"0",startY:"0",constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"});class Io extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},"Initial position:",G.createElement("div",{className:"perseus-widget-row"},"Start: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"End: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.endX,onChange:this.change("endX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.endY,onChange:this.change("endY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"Start updates ",G.createElement(e,null,"(x_n, y_n)")," for ",G.createElement(e,null,"n ="),G.createElement(To,{value:this.props.startSubscript,placeholder:0,onChange:this.change("startSubscript")})),G.createElement("div",{className:"perseus-widget-row"},"End updates ",G.createElement(e,null,"(x_m, y_m)")," for ",G.createElement(e,null,"m ="),G.createElement(To,{value:this.props.endSubscript,placeholder:0,onChange:this.change("endSubscript")})),G.createElement("div",{className:"perseus-widget-row"},"All constraints are applied to the start point."),G.createElement(So,this.props))}}le(Io,"propTypes",oe(oe({},x.propTypes),{},{startX:J.string,startY:J.string,endX:J.string,endY:J.string,constraint:J.string,snap:J.number,constraintFn:J.string})),le(Io,"defaultProps",{startX:"-5",startY:"5",endX:"5",endY:"5",constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"});class Ro extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,this.props.funcName+"(x)=")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.value,onChange:this.change("value")})),G.createElement("div",{className:"perseus-widget-row"},"Range: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMin,onChange:this.change("rangeMin")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMax,onChange:this.change("rangeMax")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(D,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Width:"," ",G.createElement(To,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}le(Ro,"propTypes",oe(oe({},x.propTypes),{},{value:J.string,rangeMin:J.string,rangeMax:J.string,color:J.string,strokeDashArray:J.string,strokeWidth:J.number})),le(Ro,"defaultProps",{value:"x",rangeMin:"-10",rangeMax:"10",color:A.BLUE,strokeDasharray:"",strokeWidth:2});class zo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"X(t) =")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.x,onChange:this.change("x")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"Y(t) =")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.y,onChange:this.change("y")})),G.createElement("div",{className:"perseus-widget-row"},"Range: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMin,onChange:this.change("rangeMin")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMax,onChange:this.change("rangeMax")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(D,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Width:"," ",G.createElement(To,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}le(zo,"propTypes",oe(oe({},x.propTypes),{},{x:J.string,y:J.string,rangeMin:J.string,rangeMax:J.string,color:J.string,strokeDashArray:J.string,strokeWidth:J.number})),le(zo,"defaultProps",{x:"cos(t)",y:"sin(t)",rangeMin:"0",rangeMax:"2\\pi",color:A.BLUE,strokeDasharray:"",strokeWidth:2});class Lo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(_o,{value:this.props.label,onChange:this.change("label"),style:{width:"100%"}})),G.createElement("div",{className:"perseus-widget-row"},"Location: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})))}}le(Lo,"propTypes",oe(oe({},x.propTypes),{},{color:J.string,coordX:J.string,coordY:J.string,label:J.string})),le(Lo,"defaultProps",{coordX:"0",coordY:"0",color:A.BLACK,label:"\\phi"});class Fo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Bottom left: ",G.createElement(e,null,"\\Large("),G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),G.createElement(e,null,",")," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"Width:"," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.width,onChange:this.change("width")})),G.createElement("div",{className:"perseus-widget-row"},"Height:"," ",G.createElement(No,{buttonSets:[],buttonsVisible:"never",value:this.props.height,onChange:this.change("height")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,lightColors:!0,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},"You want a border? Sorry, draw your own."))}}le(Fo,"propTypes",oe(oe({},x.propTypes),{},{color:J.string,coordX:J.string,coordY:J.string,height:J.string,width:J.string})),le(Fo,"defaultProps",{coordX:"-5",coordY:"5",width:"2",height:"3",color:A.LIGHT_BLUE});class qo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"state",{usedVarSubscripts:this._getAllVarSubscripts(this.props.elements),usedFunctionNames:this._getAllFunctionNames(this.props.elements)}),le(this,"_updateGraphProps",(e=>{this.change({graph:X.extend(X.omit(e,"step"),{tickStep:e.step})})})),le(this,"_addNewElement",(e=>{var t=e.target.value;if(""!==t){e.target.value="";var n,r={type:t,key:t+"-"+(16777215*Math.random()<<0).toString(16),options:"point"===t?X.clone(Ao.defaultProps):"line"===t?X.clone(Po.defaultProps):"movable-point"===t?X.clone(Do.defaultProps):"movable-line"===t?X.clone(Io.defaultProps):"function"===t?X.clone(Ro.defaultProps):"parametric"===t?X.clone(zo.defaultProps):"label"===t?X.clone(Lo.defaultProps):"rectangle"===t?X.clone(Fo.defaultProps):{}};if("movable-point"===t)n=X.max([X.max(this.state.usedVarSubscripts),-1])+1,r.options.varSubscript=n;else if("movable-line"===t)n=X.max([X.max(this.state.usedVarSubscripts),-1])+1,r.options.startSubscript=n,r.options.endSubscript=n+1;else if("function"===t){var a=String.fromCharCode(X.max([X.max(X.map(this.state.usedFunctionNames,(function(e){return e.charCodeAt(0)}))),"e".charCodeAt(0)])+1);r.options.funcName=a}this.change({elements:this.props.elements.concat(r)})}})),le(this,"_deleteElement",(e=>{var t=this.props.elements[e];this.change({elements:X.without(this.props.elements,t)})})),le(this,"_moveElementUp",(e=>{var t=this.props.elements[e],n=X.without(this.props.elements,t);n.splice(e-1,0,t),this.change({elements:n})})),le(this,"_moveElementDown",(e=>{var t=this.props.elements[e],n=X.without(this.props.elements,t);n.splice(e+1,0,t),this.change({elements:n})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}UNSAFE_componentWillReceiveProps(e){this.setState({usedVarSubscripts:this._getAllVarSubscripts(e.elements),usedFunctionNames:this._getAllFunctionNames(e.elements)})}_getAllVarSubscripts(e){return X.map(X.where(e,{type:"movable-point"}),(e=>e.options.varSubscript)).concat(X.map(X.where(e,{type:"movable-line"}),(e=>e.options.startSubscript))).concat(X.map(X.where(e,{type:"movable-line"}),(e=>e.options.endSubscript)))}_getAllFunctionNames(e){return X.map(X.where(e,{type:"function"}),(e=>e.options.funcName))}render(){var{TeX:e}=Oo();return G.createElement("div",{className:"perseus-widget-interaction-editor"},G.createElement(R,{title:"Grid settings"},G.createElement(Hi,{editableSettings:["canvas","graph"],box:this.props.graph.box,labels:this.props.graph.labels,range:this.props.graph.range,step:this.props.graph.tickStep,gridStep:this.props.graph.gridStep,markings:this.props.graph.markings,onChange:this._updateGraphProps}),!0!==this.props.graph.valid&&G.createElement("div",null,this.props.graph.valid)),X.map(this.props.elements,(function(t,n){return"movable-point"===t.type?G.createElement(R,{title:G.createElement("span",null,"Movable point"," ",G.createElement(e,null,"(x_{"+t.options.varSubscript+"}, y_{"+t.options.varSubscript+"})")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Do,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"movable-line"===t.type?G.createElement(R,{title:G.createElement("span",null,"Movable line"," ",G.createElement(e,null,"(x_{"+t.options.startSubscript+"}, y_{"+t.options.startSubscript+"})")," ","to"," ",G.createElement(e,null,"(x_{"+t.options.endSubscript+"}, y_{"+t.options.endSubscript+"})")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Io,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"point"===t.type?G.createElement(R,{title:G.createElement("span",null,"Point"," ",G.createElement(e,null,"("+t.options.coordX+", "+t.options.coordY+")")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Ao,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"line"===t.type?G.createElement(R,{title:G.createElement("span",null,"Line"," ",G.createElement(e,null,"("+t.options.startX+", "+t.options.startY+")")," ","to"," ",G.createElement(e,null,"("+t.options.endX+", "+t.options.endY+")")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Po,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"function"===t.type?G.createElement(R,{title:G.createElement("span",null,"Function"," ",G.createElement(e,null,t.options.funcName+"(x) = "+t.options.value)),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(Ro,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"parametric"===t.type?G.createElement(R,{title:G.createElement("span",null,"Parametric"),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(zo,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"label"===t.type?G.createElement(R,{title:G.createElement("span",null,"Label"," ",G.createElement(e,null,Mo(t.options.label))," "),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(Lo,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):"rectangle"===t.type?G.createElement(R,{title:G.createElement("span",null,"Rectangle"," ",G.createElement(e,null,"("+t.options.coordX+", "+t.options.coordY+")")," — ",G.createElement(e,null,t.options.width+" \\times "+t.options.height)),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(Fo,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));X.extend(t[n].options,e),this.change({elements:t})}}))):void 0}),this),G.createElement("div",{className:"perseus-widget-interaction-editor-select-element"},G.createElement("select",{onChange:this._addNewElement},G.createElement("option",{value:""},"Add an element","…"),G.createElement("option",{disabled:!0},"--"),G.createElement("option",{value:"point"},"Point"),G.createElement("option",{value:"line"},"Line segment"),G.createElement("option",{value:"function"},"Function plot"),G.createElement("option",{value:"parametric"},"Parametric plot"),G.createElement("option",{value:"label"},"Label"),G.createElement("option",{value:"rectangle"},"Rectangle"),G.createElement("option",{value:"movable-point"},"★ Movable point"),G.createElement("option",{value:"movable-line"},"★ Movable line segment"))))}}le(qo,"propTypes",oe(oe({},x.propTypes),{},{elements:J.arrayOf(J.object),graph:J.objectOf(J.any)})),le(qo,"widgetName","interaction"),le(qo,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});var{InfoTip:Uo}=t,{containerSizeClass:Wo,getInteractiveBoxFromSizeClass:Vo}=M,jo=r.DeprecationMixin,Bo=z.widget,$o={url:null},Ho=Z({displayName:"InteractiveGraphEditor",className:"perseus-widget-interactive-graph",statics:{widgetName:"interactive-graph"},getDefaultProps:function(){return{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],valid:!0,backgroundImage:$o,markings:"graph",showProtractor:!1,showRuler:!1,showTooltips:!1,rulerLabel:"",rulerTicks:10,correct:{type:"linear",coords:null}}},deprecatedProps:{showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},UNSAFE_componentWillMount(){jo.UNSAFE_componentWillMount.call(this)},render:function(){var e,t,n=this.props.gridStep||r.getGridStep(this.props.range,this.props.step,N.defaultBoxSize),a=this.props.snapStep||r.snapStepFromGridStep(n),s=Wo.SMALL;if(!0===this.props.valid){var i={ref:"graph",box:this.props.box,range:this.props.range,labels:this.props.labels,step:this.props.step,gridStep:n,snapStep:a,graph:this.props.correct,backgroundImage:this.props.backgroundImage,markings:this.props.markings,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,trackInteraction:function(){},onChange:e=>{var t=this.props.correct;t=t.type===e.graph.type?X.extend({},t,e.graph):e.graph,this.props.onChange({correct:t})}};e=G.createElement(Bo,ce({},i,{containerSizeClass:s,apiOptions:oe(oe({},this.props.apiOptions),{},{isMobile:!1})})),t=Bo.getEquationString(i)}else e=G.createElement("div",{className:"perseus-error"},this.props.valid);return G.createElement("div",{className:"perseus-widget-interactive-graph"},G.createElement("div",null,"Correct answer"," ",G.createElement(Uo,null,G.createElement("p",null,"Graph the correct answer in the graph below and ensure the equation or point coordinates displayed represent the correct answer."))," ",": ",t),G.createElement(Hi,{box:Vo(s),range:this.props.range,labels:this.props.labels,step:this.props.step,gridStep:n,snapStep:a,valid:this.props.valid,backgroundImage:this.props.backgroundImage,markings:this.props.markings,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,showTooltips:this.props.showTooltips,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onChange:this.props.onChange}),"polygon"===this.props.correct.type&&G.createElement("div",{className:"type-settings"},G.createElement("label",null," ","Student answer must"," ",G.createElement("select",{value:this.props.correct.match,onChange:this.changeMatchType},G.createElement("option",{value:"exact"},"match exactly"),G.createElement("option",{value:"congruent"},"be congruent"),G.createElement("option",{value:"approx"},"be approximately congruent"),G.createElement("option",{value:"similar"},"be similar"))),G.createElement(Uo,null,G.createElement("ul",null,G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Match Exactly:")," Match exactly in size, orientation, and location on the grid even if it is not shown in the background.")),G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Be Congruent:")," Be congruent in size and shape, but can be located anywhere on the grid.")),G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Be Approximately Congruent:")," Be exactly similar, and congruent in size and shape to within 0.1 units, but can be located anywhere on the grid."," ",G.createElement("em",null,"Use this with snapping to angle measure."))),G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Be Similar:")," Be similar with matching interior angles, and side measures that are matching or a multiple of the correct side measures. The figure can be located anywhere on the grid."))))),"angle"===this.props.correct.type&&G.createElement("div",{className:"type-settings"},G.createElement("div",null,G.createElement("label",null," ","Student answer must"," ",G.createElement("select",{value:this.props.correct.match,onChange:this.changeMatchType},G.createElement("option",{value:"exact"},"match exactly"),G.createElement("option",{value:"congruent"},"be congruent"))),G.createElement(Uo,null,G.createElement("p",null,"Congruency requires only that the angle measures are the same. An exact match implies congruency, but also requires that the angles have the same orientation and that the vertices are in the same position.")))),e)},changeMatchType:function(e){var t=X.extend({},this.props.correct,{match:e.target.value});this.props.onChange({correct:t})},serialize:function(){var e=X.pick(this.props,"step","backgroundImage","markings","labels","showProtractor","showRuler","showTooltips","rulerLabel","rulerTicks","range","gridStep","snapStep"),t=this.refs.graph;if(t){var n=t&&t.getUserInput();X.extend(e,{graph:{type:n.type},correct:n}),X.each(["allowReflexAngles","angleOffsetDeg","numPoints","numSides","numSegments","showAngles","showSides","snapTo","snapDegrees"],(function(t){X.has(n,t)&&(e.graph[t]=n[t])}))}return e}}),Go=["forwardedRef","width","grow","shrink","icon","backgroundColor","focusBorderColor","borderColor","color","onSubmit","leftSideIcon","id","testId","type","labelMediumInputText"];class Yo extends G.Component{constructor(){super(...arguments),le(this,"state",{focused:!1}),le(this,"handleBlur",(e=>{var{onBlur:t}=this.props;t&&t(e),this.setState({focused:!1})})),le(this,"handleFocus",(e=>{var{onFocus:t}=this.props;t&&t(e),this.setState({focused:!0})})),le(this,"disableDefault",(e=>{e.preventDefault()}))}render(){var e=this.props,{forwardedRef:t,width:n,grow:r,shrink:a,icon:s,backgroundColor:i,focusBorderColor:o,borderColor:l,color:c,onSubmit:p,leftSideIcon:h,id:u,testId:d,type:m,labelMediumInputText:g}=e,f=pe(e,Go),{focused:v}=this.state,y={},b=[Ko.input,Ko.container];n&&(y.width=n),r&&(y.flexGrow=!0===r?1:r),(a||0===a)&&(y.flexShrink=!0===a?0:a),i?y.backgroundColor=i:b.push(Ko.defaultBackground),c&&(y.color=c);var E=v?o||Bn.blue:l||Bn.offBlack16;y.border="1px solid ".concat(E);var w=s&&G.createElement("span",{className:re(Ko.icon)},s),x=g?Ko.labelMediumInputBase:Ko.inputBase;return G.createElement("form",{className:re(b),style:y,onSubmit:p||this.disableDefault},h&&w,G.createElement("input",ce({},f,{onFocus:this.handleFocus,onBlur:this.handleBlur,type:m,className:re(x),ref:t,id:u,"data-test-id":d})),!h&&w)}}var Ko=ne.create({inputBase:oe(oe({background:"inherit",border:"none"},L.typography.bodyXsmall),{},{outline:"none","::placeholder":{color:L.colors.gray41},width:"100%",color:"inherit",marginBottom:0,paddingLeft:0,boxShadow:"none",padding:0,margin:0}),labelMediumInputBase:{background:"inherit",border:"none",outline:"none","::placeholder":{color:L.colors.gray41},width:"100%",fontWeight:"normal",fontFamily:"Lato, san-serif",fontSize:"16px",lineHeight:"20px"},input:{height:40,borderRadius:L.borderRadius,boxSizing:"border-box",padding:"8px 10px"},container:{display:"inline-flex",alignItems:"center",marginBottom:0},defaultBackground:{backgroundColor:L.colors.white},icon:{display:"flex",alignItems:"center",justifyContent:"center"}}),Xo=G.forwardRef(((e,t)=>G.createElement(Yo,ce({},e,{forwardedRef:t})))),Jo=["children","className","highlighted","href","inlineStyles","referrer","style","target","testId","element"];class Zo extends G.Component{render(){var e=this.props,{children:t,className:n,highlighted:r,href:a,inlineStyles:s,referrer:i,style:o,target:l,testId:c,element:p}=e,h=pe(e,Jo),[u,d]=a?a.split("#"):["javascript:void(0)"],m=u;i&&(m.indexOf("?")>-1?m+="&ref="+i:m+="?ref="+i),d&&(m+="#"+d);var g=[Qo.link,r&&Qo.highlighted];Array.isArray(o)?g.push(...o):g.push(o);var f=n?" "+n:"",v="a"===p?{href:m}:{to:m},y=h.rel;return"_blank"!==l||y||(y="noopener noreferrer"),G.createElement(p,oe(oe(oe({"data-test-id":c},h),v),{},{className:re(...g)+f,style:s,target:l,rel:y}),t)}}le(Zo,"defaultProps",{highlighted:!1,href:"javascript:void(0)",style:[],element:"a"});var Qo=ne.create({link:{backgroundColor:"transparent",color:"inherit",textDecoration:"none",":hover":{textDecoration:"underline"}},highlighted:{textDecoration:"underline"}}),{colors:el,typography:tl}=L,{Icon:nl}=t,rl={path:"M11 11V7a1 1 0 0 1 2 0v4h4a1 1 0 0 1 0 2h-4v4a1 1 0 0 1-2 0v-4H7a1 1 0 0 1 0-2h4zm1 13C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12zm0-2c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z",width:24,height:24},al={path:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12zm0-2c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10zm-5-9a1 1 0 0 1 0-2h10a1 1 0 0 1 0 2H7z",width:24,height:24},sl=()=>G.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},G.createElement("filter",{id:"draggable-grip-shadow",width:"112.5%",height:"116.7%",x:"-6.2%",y:"-8.3%",filterUnits:"objectBoundingBox"},G.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:".5",result:"shadowBlurInner"}),G.createElement("feOffset",{in:"shadowBlurInner",dy:"1",result:"shadowOffsetInner"}),G.createElement("feComposite",{in:"shadowOffsetInner",in2:"SourceAlpha",k2:"-1",k3:"1",operator:"arithmetic",result:"shadowInnerInner"}),G.createElement("feColorMatrix",{in:"shadowInnerInner",values:"0 0 0 0 0.129411765 0 0 0 0 0.141176471 0 0 0 0 0.17254902 0 0 0 0.2 0"})),G.createElement("path",{d:"M1 4a1 1 0 1 1 0-2h14a1 1 0 0 1 0 2H1zm0 10a1 1 0 0 1 0-2h14a1 1 0 0 1 0 2H1zm0-5a1 1 0 1 1 0-2h14a1 1 0 0 1 0 2H1z",fill:el.gray17,filter:"url(#draggable-grip-shadow)"})),il=e=>{var{onClick:t}=e;return G.createElement(Zo,{className:re(cl.addAnswer,pl.addAnswer),onClick:t},G.createElement(nl,{icon:rl,size:24}),G.createElement("div",{className:re(cl.spacer)}),"Add an answer choice")},ol=e=>{var{answer:t,onChange:n,onRemove:r}=e;return G.createElement("li",{className:re(cl.answer)},G.createElement(Zo,{onClick:r},G.createElement(nl,{icon:al,size:24,color:"#D92916"})),G.createElement("div",{className:re(cl.spacer)}),G.createElement(Xo,{grow:1,onChange:e=>n(e.target.value),value:t}),G.createElement("div",{className:re(cl.spacer)}),G.createElement(Zo,{style:[cl.disabled],title:"Answer reordering is not implemented."},G.createElement(sl,null)))},ll=e=>{var{choices:t,onChange:n}=e;return G.createElement("div",null,G.createElement("div",{className:re(cl.title)},"Answer Choices"),G.createElement("ul",{className:re(cl.answers)},t.map(((e,r)=>G.createElement(ol,{answer:e,key:r,onChange:e=>n([...t.slice(0,r),e,...t.slice(r+1)]),onRemove:()=>n([...t.slice(0,r),...t.slice(r+1)])})))),G.createElement(il,{onClick:()=>n([...t,""])}))},cl=ne.create({title:oe(oe({},tl.bodyXsmallBold),{},{marginBottom:6,color:el.gray17}),answers:{marginTop:12,marginBottom:12},answer:{display:"flex",flexDirection:"row",alignItems:"center",":not(:first-child)":{marginTop:12}},addAnswer:oe(oe({},tl.bodyXsmallBold),{},{display:"flex",flexDirection:"row",alignItems:"center",color:"#1865f2"}),spacer:{width:16},disabled:{cursor:"not-allowed"}}),pl=ne.create({addAnswer:{":link":{color:"#1865f2"}}});class hl extends G.Component{constructor(e){super(e),le(this,"focusFlag",void 0),le(this,"waitingForClick",void 0),le(this,"handleClick",(e=>{this.props.disabled||(this.props.shouldUpdate()&&(this.waitingForClick=!1),this.props.onClick&&!this.props.disabled&&this.props.onClick(e))})),le(this,"handleMouseEnter",(()=>{this.props.disabled||!this.props.shouldUpdate()||this.waitingForClick||this.setState({hovered:!0})})),le(this,"handleMouseLeave",(()=>{this.props.disabled||!this.props.shouldUpdate()||this.waitingForClick||this.setState({hovered:!1})})),le(this,"handleTouchStart",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&this.setState({hovered:!0})})),le(this,"handleTouchEnd",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&(this.setState({hovered:!1}),this.waitingForClick=!0)})),le(this,"handleMouseDown",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&(this.setState({focused:!1}),this.focusFlag=!0)})),le(this,"handleBlur",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&this.setState({focused:!1})})),le(this,"handleFocus",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&(this.focusFlag?this.focusFlag=!1:this.setState({focused:!0}))})),this.state={focused:!1,hovered:e.startHovered}}render(){var e={onBlur:this.handleBlur,onClick:this.handleClick,onFocus:this.handleFocus,onMouseDown:this.handleMouseDown,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd},{children:t}=this.props;return(null==t?void 0:t(this.state,e))||null}}le(hl,"defaultProps",{startHovered:!1,shouldUpdate:()=>!0});var{borderRadius:ul,colors:dl}=L;class ml extends G.Component{render(){var{checked:e,disabled:t,appearDisabled:n,onChange:r,tabIndex:a,style:s,dataTestId:i,id:o}=this.props,l=dl.gray41;return G.createElement(hl,null,((c,p)=>{var{focused:h}=c;return G.createElement("div",ce({},p,{className:re(bl.container,h&&bl.focused),style:s,"data-test-id":i,"data-checked":e}),G.createElement("svg",{className:re(bl.svg,(t||n)&&bl.disabled),width:yl,height:yl,viewBox:"-".concat(fl," -").concat(fl,"\n ").concat(yl," ").concat(yl)},G.createElement("g",{fill:"none",fillRule:"evenodd"},e&&G.createElement("g",null,G.createElement("rect",{fill:l,width:gl,height:gl,x:"0",y:"0",rx:ul}),G.createElement("path",{fill:dl.white,stroke:dl.white,d:"M4.98 7.41a0.58.58 0 1 0-0.81.81L6.47 10.53c0.23.23.59.23.81 0l4.55-4.55a0.58.58 0 0 0-0.81-0.81L6.88 9.31 4.98 7.41z"})),!e&&G.createElement("rect",{fill:dl.white,stroke:dl.gray68,width:gl-2*fl,height:gl-2*fl,x:fl,y:fl,rx:"4",strokeWidth:vl}))),G.createElement("input",{type:"checkbox",id:o,checked:e,className:re(bl.checkbox,t&&bl.defaultCursor),disabled:t,onChange:r,tabIndex:a}))}))}}le(ml,"defaultProps",{checked:!1,onChange:e=>{}});var gl=16,fl=.5,vl=1,yl=gl+2*fl,bl=ne.create({container:{position:"relative",display:"inline-block",verticalAlign:"middle",lineHeight:0,borderRadius:ul,width:yl,height:yl,flexShrink:0},focused:{"::before":{content:'""',position:"absolute",top:-2,right:-2,bottom:-2,left:-2,borderRadius:ul+2,backgroundColor:"lightblue"}},svg:{position:"absolute",left:0,top:0},checkbox:{appearance:"none",opacity:0,position:"absolute",top:fl,width:gl,height:gl,margin:0,outline:"none",cursor:"pointer"},disabled:{opacity:.5},defaultCursor:{cursor:"default"}}),{colors:El,typography:wl}=L,xl=e=>{var{multipleAnswers:t,hideChoicesFromInstructions:n,onChange:r}=e;return G.createElement("div",null,G.createElement("div",{className:re(Cl.title)},"Behavior"),G.createElement("ul",null,G.createElement("li",{className:re(Cl.option)},G.createElement(ml,{checked:t,onChange:()=>r({multipleAnswers:!t})}),G.createElement("span",{className:re(Cl.label)},"Allow multiple answers per marker")),G.createElement("li",{className:re(Cl.option)},G.createElement(ml,{checked:n,onChange:()=>r({hideChoicesFromInstructions:!n})}),G.createElement("span",{className:re(Cl.label)},"Do not display answer choices in instructions"))))},Cl=ne.create({title:oe(oe({},wl.bodyXsmallBold),{},{marginBottom:6,color:El.gray17}),option:{display:"flex",padding:"6px 0"},label:oe(oe({},wl.smallSubheadingMobile),{},{marginLeft:16,color:El.gray17})});var{Icon:kl}=t,{colors:Sl}=L;class Nl extends G.Component{constructor(){super(...arguments),le(this,"node",void 0)}handleKeyDown(e){var{onDropdownClose:t}=this.props,n=e.key,r=e.target;"ArrowDown"===n&&r.nextSibling&&(e.preventDefault(),r.nextSibling.focus()),"ArrowUp"===n&&r.previousSibling&&(e.preventDefault(),r.previousSibling.focus()),"ArrowUp"===n&&!r.previousSibling&&t&&(e.preventDefault(),t()),"Escape"!==n&&"Tab"!==n||!t||t()}render(){var{selected:e,value:t,onClick:n,children:r,optionRenderer:a,disabled:s,hideFocusState:i,testId:o,ariaLabel:l}=this.props;return G.createElement("button",{ref:e=>this.node=e,value:t,role:"menuitemradio","aria-checked":e,className:re(_l.notAButton,s&&_l.cursorDefault,i&&_l.noFocus),onClick:e=>{!s&&n&&n(e)},onKeyDown:e=>this.handleKeyDown(e),"aria-disabled":s,"aria-label":l,"data-test-id":o},a&&a(G.createElement(G.Fragment,null,r),t||"",e||!1,s),!a&&G.createElement("span",{className:re(_l.option,e&&_l.optionSelected,s&&_l.optionDisabled)},r,e&&G.createElement("span",{className:re(_l.check)},G.createElement(kl,{icon:"M10,3.8C10,4,9.9,4.2,9.8,4.3L5.1,8.9L4.3,9.8C4.2,9.9,4,10,3.8,10\n S3.5,9.9,3.4,9.8L2.5,8.9L0.2,6.6C0.1,6.5,0,6.3,0,6.2s0.1-0.3,0.2-0.4\n l0.9-0.9c0.1-0.1,0.3-0.2,0.4-0.2s0.3,0.1,0.4,0.2l1.9,1.9l4.2-4.2c0.1\n -0.1,0.3-0.2,0.4-0.2c0.2,0,0.3,0.1,0.4,0.2l0.9,0.9C9.9,3.5,10,3.7,\n 10,3.8z"}))))}}class Tl extends G.Component{constructor(){super(...arguments),le(this,"focusedElement",void 0)}componentDidMount(){var e,t;this.focusedElement&&(e=this.focusedElement,(t=te.findDOMNode(e)).focus&&t.focus({preventScroll:!0}))}render(){var{children:e,onSelected:t,selectedValues:n,optionRenderer:r,noMargin:a,onDropdownClose:s,hideFocusState:i}=this.props;return G.createElement("div",{style:{top:top},className:re(_l.optionGroup,a&&_l.optionGroupNoMargin)},G.Children.map(e,((e,a)=>{var o=n.includes(e.props.value),l=o||0===a?e=>this.focusedElement=e:null;return G.cloneElement(e,oe(oe({},e.props),{},{key:a,selected:o,onClick:()=>t(e.props.value),optionRenderer:r,ref:l,onDropdownClose:s,hideFocusState:i}))})))}}var _l=ne.create({optionGroup:{margin:"4px 0"},optionGroupNoMargin:{margin:0},option:{display:"flex",flexDirection:"row",alignItems:"center",paddingLeft:32,paddingRight:32,height:30,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:Sl.gray17,userSelect:"none",":hover":{backgroundColor:Sl.gray95}},optionSelected:{backgroundColor:Sl.gray95,color:"#11ACCD"},optionDisabled:{color:Sl.gray76,":hover":{backgroundColor:"transparent"}},check:{position:"absolute",left:11},notAButton:{backgroundColor:"transparent",border:"none",display:"block",padding:0,margin:0,width:"100%",font:"inherit"},noFocus:{outline:"none"},cursorDefault:{cursor:"default"}}),{colors:Ol,borderRadius:Ml}=L;class Al extends G.Component{constructor(e){super(e),le(this,"_marker",void 0),le(this,"handleClick",(e=>{var{showDropdown:t}=this.state;this._marker===e.target?this.setState({showDropdown:!t}):t&&this._marker&&!this._marker.contains(e.target)&&(e.stopPropagation(),this.setState({showDropdown:!1}))})),le(this,"handleLabelChange",(e=>{this.updateMarker({label:e.target.value})})),le(this,"handleSelectAnswer",(e=>{var{answers:t}=this.props;t=t.includes(e)?t.filter((t=>t!==e)):[...t,e],this.updateMarker({answers:t})})),this.state={showDropdown:!1}}componentDidMount(){document.addEventListener("click",this.handleClick,!0)}UNSAFE_componentWillReceiveProps(e){var{answers:t}=this.props,n=t.filter((t=>e.choices.includes(t)));JSON.stringify(t)!==JSON.stringify(n)&&setTimeout((()=>this.updateMarker({answers:n})))}componentWillUnmount(){document.removeEventListener("click",this.handleClick,!0)}openDropdown(){this.setState({showDropdown:!0})}updateMarker(e){var{answers:t,label:n,onChange:r,x:a,y:s}=this.props;r(oe({answers:t,label:n,x:a,y:s},e))}render(){var{answers:e,choices:t,label:n,onRemove:r,x:a,y:s}=this.props,{showDropdown:i}=this.state;return G.createElement("div",{className:re(Pl.marker,e.length>0&&Pl.markerWithAnswers,i&&Pl.markerSelected),ref:e=>this._marker=e,style:{left:"".concat(a,"%"),top:"".concat(s,"%")},title:"Click to select marker answers or to delete marker. Repositioning marker is not implemented."},i&&G.createElement("div",null,G.createElement("div",{className:re(Pl.dropdownBody,Pl.dropdownPositionWithArrow)},G.createElement(Nl,{value:"",onClick:()=>r()},"Delete marker"),G.createElement("hr",{className:re(Pl.dividerHorizontal)}),G.createElement(Tl,{onSelected:this.handleSelectAnswer,selectedValues:e},t.map((e=>G.createElement(Nl,{key:e,value:e},e)))),G.createElement("div",{className:re(Pl.labelContainer)},G.createElement(Xo,{placeholder:"ARIA label (for screen readers)",onChange:this.handleLabelChange,value:n,width:"100%"})))))}}var Pl=ne.create({marker:{position:"absolute",boxSizing:"content-box",width:16,height:16,marginLeft:-8,marginTop:-8,cursor:"pointer",background:"linear-gradient(to bottom, rgba(33, 36, 44, 0.2), rgba(33, 36, 44, 0.5))",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 10px 0 rgba(33, 36, 44, 0.1)"},markerSelected:{width:28,height:28,marginLeft:-12,marginTop:-12,border:"none",borderRadius:28,"::before":{content:"''",display:"block",width:20,height:20,marginLeft:2,marginTop:2,border:"solid 2px #ffffff",borderRadius:20}},markerWithAnswers:{background:"#1865f2"},dropdownPositionWithArrow:{left:46,bottom:-12,"::before":{content:"''",display:"block",position:"absolute",width:0,height:0,left:-16,bottom:8,borderRight:"solid 16px ".concat(Ol.gray98),borderTop:"solid 16px transparent",borderBottom:"solid 16px transparent"}},labelContainer:{padding:4},dividerHorizontal:{height:0,margin:0,border:"solid ".concat(Ol.gray85),borderWidth:"0 0 1px",boxShadow:"none"},dropdownBody:{position:"absolute",border:"solid 1px rgba(0, 0, 0, 0.1)",zIndex:F.zindexDropdown,color:Ol.gray17,backgroundColor:Ol.gray98,borderRadius:Ml,maxHeight:320,cursor:"pointer"}}),{colors:Dl,typography:Il}=L;class Rl extends G.Component{constructor(){super(...arguments),le(this,"_markers",[]),le(this,"handleImageDoubleClick",(e=>{e.preventDefault();var t=e.currentTarget.getBoundingClientRect(),n=Math.round((e.clientX-t.left)/t.width*1e3)/10,r=Math.round((e.clientY-t.top)/t.height*1e3)/10,{markers:a,onChange:s}=this.props;s([...a,{answers:[],label:"",x:n,y:r}])}))}openDropdownForMarkerIndices(e){e.forEach((e=>{this._markers[e]&&this._markers[e].openDropdown()}))}render(){var{choices:e,imageUrl:t,imageWidth:n,imageHeight:a,markers:s,onChange:i}=this.props,l=o.getDependencies().staticUrl;return G.createElement("div",null,G.createElement("div",{className:re(zl.title)},"Markers"),G.createElement("div",{className:re(zl.subtitle)},t?G.createElement("span",null,"Double-click on the image to add a marker.",G.createElement("br",null),G.createElement("br",null),"Markers are read by screen readers in the order that you add them here, so add in a logical order for the learner (e.g. sequentially, clockwise). You can test order by using keyboard tabbing."):"Upload an image to place markers."),t&&G.createElement("div",{className:re(zl.markersCanvas),style:{maxWidth:n,maxHeight:a}},G.createElement("img",{alt:"",className:re(zl.image),src:l(r.getRealImageUrl(t)),onDoubleClick:this.handleImageDoubleClick}),s.map(((t,n)=>G.createElement(Al,ce({},t,{choices:e,key:"".concat(t.x,".").concat(t.y),onChange:e=>i([...s.slice(0,n),e,...s.slice(n+1)]),onRemove:()=>i([...s.slice(0,n),...s.slice(n+1)]),ref:e=>this._markers[n]=e}))))))}}var zl=ne.create({title:oe(oe({},Il.bodyXsmallBold),{},{marginBottom:6,color:Dl.gray17}),subtitle:oe(oe({},Il.labelSmall),{},{marginBottom:12,color:Dl.gray68}),markersCanvas:{position:"relative",border:"solid 1px rgba(33, 36, 44, 0.16)"},image:{display:"block",maxWidth:"100%"}});const Ll="@media (max-width: 1023px)",Fl="@media (min-width: 1024px)",ql={display:"block"},Ul='Lato, "Noto Sans", sans-serif',Wl=ne.create({Title:ye({},ql,{fontFamily:Ul,fontWeight:900,[Fl]:{fontSize:36,lineHeight:"40px"},[Ll]:{fontSize:28,lineHeight:"32px"}}),Tagline:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:20,lineHeight:"24px"}),HeadingLarge:ye({},ql,{fontFamily:Ul,fontWeight:700,[Fl]:{fontSize:28,lineHeight:"32px"},[Ll]:{fontSize:24,lineHeight:"28px"}}),HeadingMedium:ye({},ql,{fontFamily:Ul,fontWeight:700,[Fl]:{fontSize:24,lineHeight:"28px"},[Ll]:{fontSize:22,lineHeight:"26px"}}),HeadingSmall:ye({},ql,{fontFamily:Ul,fontWeight:700,fontSize:20,lineHeight:"24px"}),HeadingXSmall:ye({},ql,{fontFamily:Ul,fontWeight:700,fontSize:12,lineHeight:"16px",letterSpacing:.6,textTransform:"uppercase"}),BodySerifBlock:ye({},ql,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:22,lineHeight:"28px"}),BodySerif:ye({},ql,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:18,lineHeight:"22px"}),BodyMonospace:ye({},ql,{fontFamily:"Inconsolata, monospace",fontWeight:400,fontSize:17,lineHeight:"22px"}),Body:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:16,lineHeight:"22px"}),LabelLarge:ye({},ql,{fontFamily:Ul,fontWeight:700,fontSize:16,lineHeight:"20px"}),LabelMedium:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:16,lineHeight:"20px"}),LabelSmall:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:14,lineHeight:"18px"}),LabelXSmall:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:12,lineHeight:"16px"}),Caption:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:14,lineHeight:"20px"}),Footnote:ye({},ql,{fontFamily:Ul,fontWeight:400,fontSize:12,lineHeight:"18px"})}),Vl=["style","children"];class jl extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Vl);return G.createElement(vn,ye({},r,{style:[Wl.Title,t]}),n)}}jl.defaultProps={tag:"h1"};const Bl=["style","children"];class $l extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Bl);return G.createElement(vn,ye({},r,{style:[Wl.HeadingLarge,t]}),n)}}$l.defaultProps={tag:"h2"};const Hl=["style","children"];class Gl extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Hl);return G.createElement(vn,ye({},r,{style:[Wl.HeadingMedium,t]}),n)}}Gl.defaultProps={tag:"h3"};const Yl=["style","children"];class Kl extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Yl);return G.createElement(vn,ye({},r,{style:[Wl.HeadingSmall,t]}),n)}}Kl.defaultProps={tag:"h4"};const Xl=["style","children"];class Jl extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Xl);return G.createElement(vn,ye({},r,{style:[Wl.HeadingXSmall,t]}),n)}}Jl.defaultProps={tag:"h4"};const Zl=["style","children"];class Ql extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Zl);return G.createElement(vn,ye({},r,{style:[Wl.BodySerifBlock,t]}),n)}}Ql.defaultProps={tag:"span"};const ec=["style","children"];class tc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,ec);return G.createElement(vn,ye({},r,{style:[Wl.BodySerif,t]}),n)}}tc.defaultProps={tag:"span"};const nc=["style","children"];class rc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,nc);return G.createElement(vn,ye({},r,{style:[Wl.BodyMonospace,t]}),n)}}rc.defaultProps={tag:"span"};const ac=["style","children"];class sc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,ac);return G.createElement(vn,ye({},r,{style:[Wl.Body,t]}),n)}}sc.defaultProps={tag:"span"};const ic=["style","children"];class oc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,ic);return G.createElement(vn,ye({},r,{style:[Wl.LabelLarge,t]}),n)}}oc.defaultProps={tag:"span"};const lc=["style","children"];class cc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,lc);return G.createElement(vn,ye({},r,{style:[Wl.LabelMedium,t]}),n)}}cc.defaultProps={tag:"span"};const pc=["style","children"];class hc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,pc);return G.createElement(vn,ye({},r,{style:[Wl.LabelSmall,t]}),n)}}hc.defaultProps={tag:"span"};const uc=["style","children"];class dc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,uc);return G.createElement(vn,ye({},r,{style:[Wl.LabelXSmall,t]}),n)}}dc.defaultProps={tag:"span"};const mc=["style","children"];class gc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,mc);return G.createElement(vn,ye({},r,{style:[Wl.Tagline,t]}),n)}}gc.defaultProps={tag:"span"};const fc=["style","children"];class vc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,fc);return G.createElement(vn,ye({},r,{style:[Wl.Caption,t]}),n)}}vc.defaultProps={tag:"span"};const yc=["style","children"];class bc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,yc);return G.createElement(vn,ye({},r,{style:[Wl.Footnote,t]}),n)}}bc.defaultProps={tag:"span"};const Ec={xsmall:16,small:24,medium:48,large:96},wc={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"},xc={light:Bn.white,dark:Bn.offBlack16},Cc=bn("path");class kc extends G.Component{render(){const{size:e,light:t,style:n}=this.props,r=Ec[e],a=wc[e],s=t?xc.light:xc.dark,i=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:`0 0 ${r} ${r}`},G.createElement(Cc,{style:[Sc.loadingSpinner,{fill:s}],fillRule:"nonzero",d:a}));return G.createElement(_n,{style:[Sc.spinnerContainer,n]},i)}}kc.defaultProps={size:"large",light:!1};const Sc=ne.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"}}),Nc=e=>({small:16,medium:24,large:48,xlarge:96}[e]),Tc=["color","icon","size","style"],_c=bn("svg");class Oc extends G.PureComponent{render(){const e=this.props,{color:t,icon:n,size:r,style:a}=e,s=ve(e,Tc),{assetSize:i,path:o}=((e,t)=>{if(e[t])return{assetSize:t,path:e[t]};{const n=Nc(t),r=Object.keys(e),a=e=>{const t=Nc(e)-n;return t>0?Number.POSITIVE_INFINITY:Math.abs(t)},s=r.sort(((e,t)=>a(e)-a(t)))[0];if(s&&e[s])return{assetSize:s,path:e[s]};throw new Error("Icon does not contain any valid asset sizes!")}})(n,r),l=Nc(r),c=Nc(i);return G.createElement(_c,ye({},s,{style:[Mc.svg,a],width:l,height:l,viewBox:`0 0 ${c} ${c}`}),G.createElement("path",{fill:t,d:o}))}}Oc.defaultProps={color:"currentColor",size:"small"};const Mc=ne.create({svg:{display:"inline-block",verticalAlign:"text-bottom",flexShrink:0,flexGrow:0}}),Ac=8,Pc=16,Dc=32,Ic=["children","skipClientNav","color","disabled","focused","hovered","href","kind","light","pressed","size","style","testId","type","spinner","icon","id","waiting"],Rc=bn("a"),zc=bn("button"),Lc=bn(an);class Fc extends G.Component{renderInner(e){const t=this.props,{children:n,skipClientNav:r,color:a,disabled:s,focused:i,hovered:o,href:l,kind:c,light:p,pressed:h,size:u,style:d,testId:m,type:g,spinner:f,icon:v,id:y}=t,b=ve(t,Ic),E=Wc("destructive"===a?$n.controlDestructive:$n.controlDefault,c,p,v?8+("small"===u?16:24):0,u),w=f||s,x=ye({"data-test-id":m,id:y,role:"button",style:[[qc.shared,w&&qc.disabled,v&&qc.withIcon,E.default,w&&E.disabled,"tertiary"!==c&&!w&&(h?E.active:(o||i)&&E.focus),"small"===u&&qc.small,"xlarge"===u&&qc.xlarge],d]},b),C="small"===u?hc:oc,k=G.createElement(C,{style:[qc.text,"xlarge"===u&&qc.xlargeText,v&&qc.textWithIcon,f&&qc.hiddenText,"tertiary"===c&&qc.textWithFocus,"tertiary"===c&&!w&&(h?E.active:(o||i)&&E.focus)]},v&&G.createElement(Oc,{size:u,color:"currentColor",icon:v,style:qc.icon}),n),S=G.createElement(G.Fragment,null,k,f&&G.createElement(kc,{style:qc.spinner,size:{medium:"small",small:"xsmall",xlarge:"medium"}[u],light:"primary"===c}));return l&&!w?e&&!r&&Zn(l)?G.createElement(Lc,ye({},x,{to:l}),S):G.createElement(Rc,ye({},x,{href:l}),S):G.createElement(zc,ye({type:g||"button"},x,{"aria-disabled":w}),S)}render(){return G.createElement(Mt.Consumer,null,(e=>this.renderInner(e)))}}const qc=ne.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:Ac}}),Uc={},Wc=(e,t,n,r,a)=>{const s=e+t+n.toString()+r.toString()+a;if(Uc[s])return Uc[s];const{white:i,white50:o,white64:l,offBlack32:c,offBlack50:p,darkBlue:h}=Bn,u=jn(Vn(e,.32),i),d=jn(c,e),m="xlarge"===a?Dc:Pc;let g={};if("primary"===t)g={default:{background:n?i:e,color:n?e:i,paddingLeft:m,paddingRight:m},focus:{boxShadow:`0 0 0 1px ${n?h:i}, 0 0 0 3px ${n?i:e}`},active:{boxShadow:`0 0 0 1px ${n?h:i}, 0 0 0 3px ${n?u:d}`,background:n?u:d,color:n?d:u},disabled:{background:n?u:c,color:n?e:l,cursor:"default",":focus":{boxShadow:`0 0 0 1px ${n?c:i}, 0 0 0 3px ${n?u:c}`}}};else if("secondary"===t)g={default:{background:"none",color:n?i:e,borderColor:n?o:p,borderStyle:"solid",borderWidth:1,paddingLeft:r?m-4:m,paddingRight:m},focus:{background:n?"transparent":i,borderColor:n?i:e,borderWidth:2,paddingLeft:r?m-5:m-1,paddingRight:m-1},active:{background:n?d:u,color:n?u:d,borderColor:n?u:d,borderWidth:2,paddingLeft:r?m-5:m-1,paddingRight:m-1},disabled:{color:n?o:c,borderColor:n?u:c,cursor:"default",":focus":{borderColor:n?o:c,borderWidth:2,paddingLeft:r?m-5:m-1,paddingRight:m-1}}};else{if("tertiary"!==t)throw new Error("Button kind not recognized");g={default:{background:"none",color:n?i:e,paddingLeft:0,paddingRight:0},focus:{":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${r}px)`,right:0,bottom:0,background:n?i:e,borderRadius:2}},active:{color:n?u:d,":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${r}px)`,right:0,bottom:"calc(50% - 11px)",background:n?u:d,borderRadius:2}},disabled:{color:n?u:c,cursor:"default"}}}return Uc[s]=ne.create(g),Uc[s]},Vc=["href","type","children","skipClientNav","spinner","disabled","onClick","beforeNav","safeWithNav","tabIndex","target","rel"],jc=["tabIndex"];class Bc extends G.Component{renderClickableBehavior(e){const t=this.props,{href:n,type:r,children:a,skipClientNav:s,spinner:i,disabled:o,onClick:l,beforeNav:c,safeWithNav:p,tabIndex:h,target:u,rel:d}=t,m=ve(t,Vc),g=er(n,s,e),f=(e,t)=>{let{tabIndex:l}=t,c=ve(t,jc);return G.createElement(Fc,ye({},m,e,c,{disabled:o,spinner:i||e.waiting,skipClientNav:s,href:n,target:u,type:r,tabIndex:h||l}),a)};return c?G.createElement(g,{disabled:i||o,href:n,role:"button",type:r,onClick:l,beforeNav:c,safeWithNav:p,rel:d},f):G.createElement(g,{disabled:i||o,href:n,role:"button",type:r,onClick:l,safeWithNav:p,target:u,rel:d},f)}render(){return G.createElement(Mt.Consumer,null,(e=>this.renderClickableBehavior(e)))}}Bc.defaultProps={color:"default",kind:"primary",light:!1,size:"medium",disabled:!1,spinner:!1};var{colors:$c,typography:Hc}=L,Gc=e=>{var{onChange:t,url:n}=e;return G.createElement("div",null,G.createElement("div",{className:re(Yc.title)},"Image"),G.createElement("div",{className:re(Yc.components)},G.createElement(Xo,{placeholder:"URL",grow:1,onChange:e=>t(e.target.value),value:n}),G.createElement("div",{className:re(Yc.spacer)}),G.createElement(Bc,{disabled:!n,"aria-label":n?"":"Not implemented. Use the 'Add Image' button in the editor to upload image, then copy the URL here.",onClick:()=>t(""),style:Yc.btn},n?"Remove":"Upload")))},Yc=ne.create({title:oe(oe({},Hc.bodyXsmallBold),{},{marginBottom:6,color:$c.gray17}),components:{display:"flex"},spacer:{width:16},btn:{minWidth:90}});class Kc extends G.Component{constructor(){super(...arguments),le(this,"_questionMarkers",void 0),le(this,"getSaveWarnings",(()=>{var{choices:e,imageAlt:t,imageUrl:n,markers:r}=this.props,a=[];if(e.length<2&&a.push("Question requires at least two answer choices"),n?t||a.push("Question image has no alt text"):a.push("Image is not specified for question"),r.length){var s=0,i=0;for(var o of r)o.answers.length||s++,o.label||i++;s&&a.push("Question has ".concat(s," markers with no ")+"answers selected"),i&&a.push("Question has ".concat(i," markers with no ")+"ARIA label")}else a.push("Question has no markers, to label answers on image");return a})),le(this,"handleImageChange",(e=>{this.props.onChange({imageUrl:e,imageWidth:0,imageHeight:0}),e&&r.getImageSize(e,((e,t)=>{this.props.onChange({imageWidth:e,imageHeight:t})}))})),le(this,"handleAltChange",(e=>{this.props.onChange({imageAlt:e})})),le(this,"handleChoicesChange",(e=>{this.props.onChange({choices:e})})),le(this,"handleMarkersChange",(e=>{this.props.onChange({markers:e})})),le(this,"handleBehaviorChange",(e=>{this.props.onChange(e)}))}componentDidUpdate(e){var t={};e.markers.forEach((e=>t["".concat(e.x,".").concat(e.y)]=e));var n=this.props.markers.map(((e,n)=>t.hasOwnProperty("".concat(e.x,".").concat(e.y))?-1:n)).filter((e=>-1!==e));n.length&&this._questionMarkers&&this._questionMarkers.openDropdownForMarkerIndices(n)}serialize(){return C.serialize.call(this)}render(){var{choices:e,imageAlt:t,imageUrl:n,imageWidth:r,imageHeight:a,markers:s,multipleAnswers:i,hideChoicesFromInstructions:o}=this.props,l=n&&r>0&&a>0;return G.createElement("div",null,G.createElement(Gc,{onChange:this.handleImageChange,url:n}),G.createElement("div",{className:re(Xc.smallSpacer)}),l&&G.createElement(Xo,{placeholder:"Alt text (for screen readers)",onChange:e=>this.handleAltChange(e.target.value),value:t,width:"100%"}),G.createElement("div",{className:re(Xc.largeSpacer)}),G.createElement(Rl,{choices:e,imageUrl:l?n:"",imageWidth:r,imageHeight:a,markers:s,onChange:this.handleMarkersChange,ref:e=>this._questionMarkers=e}),G.createElement("div",{className:re(Xc.largeSpacer)}),G.createElement(ll,{choices:e,onChange:this.handleChoicesChange}),G.createElement("div",{className:re(Xc.largeSpacer)}),G.createElement(xl,{multipleAnswers:i,hideChoicesFromInstructions:o,onChange:this.handleBehaviorChange}))}}le(Kc,"defaultProps",{choices:[],imageAlt:"",imageUrl:"",imageWidth:0,imageHeight:0,markers:[],multipleAnswers:!1,hideChoicesFromInstructions:!1}),le(Kc,"widgetName","label-image");var Xc=ne.create({largeSpacer:{height:32},smallSpacer:{height:16}}),{InfoTip:Jc,NumberInput:Zc,PropCheckBox:Qc}=t,ep={display:"table",tableLayout:"fixed"},tp={display:"table-row"},np={display:"table-cell",padding:5},rp={borderRadius:10,cursor:"pointer"},ap={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?ap.x():ap.plus()},sp=function(e,t,n){return e=Math.floor(e),e=Math.max(e,t),e=Math.min(e,n)};class ip extends G.Component{constructor(){super(...arguments),le(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){var e=this.props.value?"#55dd55":"#115511",t=X.extend({},rp,{width:this.props.size,height:this.props.size,backgroundColor:e});return G.createElement("div",{style:t,onClick:this._flip})}}le(ip,"propTypes",{value:J.bool.isRequired,size:J.number.isRequired});class op extends G.Component{render(){return G.createElement("div",{style:ep,className:"no-select"},X.map(this.props.cells,((e,t)=>G.createElement("div",{key:t,style:tp},X.map(e,((e,n)=>G.createElement("div",{key:n,style:np},G.createElement(ip,{value:e,size:this.props.size,onChange:X.partial(this.props.onChange,t,n)}))))))))}}le(op,"propTypes",{cells:J.arrayOf(J.arrayOf(J.bool)).isRequired,size:J.number.isRequired});class lp extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_height",(()=>this.props.startCells.length)),le(this,"_width",(()=>0!==this.props.startCells.length?this.props.startCells[0].length:0)),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"_handlePatternChange",(e=>{this.change("flipPattern",e.target.value)})),le(this,"_changeWidth",(e=>{e=sp(e,1,8),this._truncateCells(e,this._height())})),le(this,"_changeHeight",(e=>{e=sp(e,1,8),this._truncateCells(this._width(),e)})),le(this,"_truncateCells",((e,t)=>{var n=X.times(t,(t=>X.times(e,(e=>!(!this.props.startCells[t]||!this.props.startCells[t][e])))));this.change({startCells:n})})),le(this,"_switchTile",((e,t)=>{var n,r,a=(n=this.props.startCells,r=(n,r)=>n===e&&r===t,X.map(n,((e,t)=>X.map(e,((e,n)=>r(t,n)?!e:e)))));this.change({startCells:a})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,"Width:",G.createElement(Zc,{value:this._width(),placeholder:5,onChange:this._changeWidth}),", ","Height:",G.createElement(Zc,{value:this._height(),placeholder:5,onChange:this._changeHeight})),G.createElement("div",null,"Flip pattern:",G.createElement("select",{value:this.props.flipPattern,onChange:this._handlePatternChange},X.map(X.keys(ap),((e,t)=>G.createElement("option",{value:e,key:t},e))))),G.createElement("div",null,"Grade incomplete puzzles as wrong:"," ",G.createElement(Qc,{gradeIncompleteAsWrong:this.props.gradeIncompleteAsWrong,onChange:this.props.onChange}),G.createElement(Jc,null,"By default, incomplete puzzles are graded as empty.")),G.createElement("div",null,"Starting configuration:"),G.createElement("div",{style:{overflowX:"auto"}},G.createElement(op,{cells:this.props.startCells,size:50,onChange:this._switchTile})))}}le(lp,"propTypes",oe(oe({},x.propTypes),{},{startCells:J.arrayOf(J.arrayOf(J.bool)),flipPattern:J.string.isRequired,gradeIncompleteAsWrong:J.bool.isRequired})),le(lp,"widgetName","lights-puzzle"),le(lp,"defaultProps",{startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",gradeIncompleteAsWrong:!1});var{InfoTip:cp,PropCheckBox:pp,TextListEditor:hp}=t;class up extends G.Component{constructor(){super(...arguments),le(this,"onLabelChange",((e,t)=>{var n=X.clone(this.props.labels);n[e]=t.target.value,this.props.onChange({labels:n})})),le(this,"getSaveWarnings",(()=>this.props.left.length!==this.props.right.length?["The two halves of the matcher have different numbers of cards."]:[])),le(this,"serialize",(()=>X.pick(this.props,"left","right","labels","orderMatters","padding")))}render(){return G.createElement("div",{className:"perseus-matcher-editor"},G.createElement("div",null," ","Correct answer:"," ",G.createElement(cp,null,G.createElement("p",null,"Enter the correct answers here. The preview on the right will show the cards in a randomized order, which is how the student will see them."))),G.createElement("div",{className:"perseus-clearfix"},G.createElement(hp,{options:this.props.left,onChange:(e,t)=>{this.props.onChange({left:e},t)},layout:"vertical"}),G.createElement(hp,{options:this.props.right,onChange:(e,t)=>{this.props.onChange({right:e},t)},layout:"vertical"})),G.createElement("span",null," ","Labels:"," ",G.createElement(cp,null,G.createElement("p",null,"These are entirely optional."))),G.createElement("div",null,G.createElement("input",{type:"text",defaultValue:this.props.labels[0],onChange:this.onLabelChange.bind(this,0)}),G.createElement("input",{type:"text",defaultValue:this.props.labels[1],onChange:this.onLabelChange.bind(this,1)})),G.createElement("div",null,G.createElement(pp,{label:"Order of the matched pairs matters:",orderMatters:this.props.orderMatters,onChange:this.props.onChange}),G.createElement(cp,null,G.createElement("p",null,"With this option enabled, only the order provided above will be treated as correct. This is useful when ordering is significant, such as in the context of a proof."),G.createElement("p",null,"If disabled, pairwise matching is sufficient. To make this clear, the left column becomes fixed in the provided order and only the cards in the right column can be moved."))),G.createElement("div",null,G.createElement(pp,{label:"Padding:",padding:this.props.padding,onChange:this.props.onChange}),G.createElement(cp,null,G.createElement("p",null,"Padding is good for text, but not needed for images."))))}}le(up,"propTypes",{left:J.array,right:J.array,labels:J.array,orderMatters:J.bool,padding:J.bool}),le(up,"widgetName","matcher"),le(up,"defaultProps",{left:["$x$","$y$","$z$"],right:["$1$","$2$","$3$"],labels:["test","label"],orderMatters:!1,padding:!0});var{RangeInput:dp}=t,mp=q.widget;class gp extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"onMatrixBoardSizeChange",(e=>{var t=function(e){var t=[1,1];return X(e).each(((e,n)=>{var r=0;X(e).each(((e,t)=>{null!=e&&e.toString().length&&(r=t+1)})),t[1]=Math.max(t[1],r),r>0&&(t[0]=Math.max(t[0],n+1))})),t}(this.props.answers);if(null!==e[0]&&null!==e[1]){e=[Math.round(Math.min(Math.max(e[0],1),6)),Math.round(Math.min(Math.max(e[1],1),6))];var n=X(Math.min(e[0],t[0])).times((n=>X(Math.min(e[1],t[1])).times((e=>this.props.answers[n][e]))));this.props.onChange({matrixBoardSize:e,answers:n})}})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=X.extend({numericInput:!0,onBlur:()=>{},onFocus:()=>{},trackInteraction:()=>{}},this.props);return G.createElement("div",{className:"perseus-matrix-editor"},G.createElement("div",{className:"perseus-widget-row"}," ","Max matrix size:"," ",G.createElement(dp,{value:this.props.matrixBoardSize,onChange:this.onMatrixBoardSizeChange,format:this.props.labelStyle,useArrowKeys:!0})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(mp,e)),G.createElement("div",{className:"perseus-widget-row"}," ","Matrix prefix:"," ",G.createElement(Sr,{ref:"prefix",apiOptions:this.props.apiOptions,content:this.props.prefix,widgetEnabled:!1,onChange:e=>{this.change({prefix:e.content})}})),G.createElement("div",{className:"perseus-widget-row"}," ","Matrix suffix:"," ",G.createElement(Sr,{ref:"suffix",apiOptions:this.props.apiOptions,content:this.props.suffix,widgetEnabled:!1,onChange:e=>{this.change({suffix:e.content})}})))}}le(gp,"propTypes",oe(oe({},x.propTypes),{},{matrixBoardSize:J.arrayOf(J.number).isRequired,answers:J.arrayOf(J.arrayOf(J.number)),prefix:J.string,suffix:J.string,cursorPosition:J.arrayOf(J.number)})),le(gp,"widgetName","matrix"),le(gp,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]});var{InfoTip:fp,NumberInput:vp,PropCheckBox:yp,RangeInput:bp}=t,Ep={url:null,top:0,left:0};class wp extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"className","perseus-widget-measurer"),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"_changeUrl",(e=>{this._changeImage("url",e.target.value)})),le(this,"_changeTop",(e=>{this._changeImage("top",e)})),le(this,"_changeLeft",(e=>{this._changeImage("left",e)})),le(this,"_changeImage",((e,t)=>{var n=X.clone(this.props.image);n[e]=t,this.change("image",n)})),le(this,"renderLabelChoices",(e=>X.map(e,(function(e){var[t,n]=e;return G.createElement("option",{key:n,value:n},t)})))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=X.extend({},Ep,this.props.image);return G.createElement("div",{className:"perseus-widget-measurer"},G.createElement("div",null,"Image displayed under protractor and/or ruler:"),G.createElement("div",null,"URL:"," ",G.createElement("input",{type:"text",className:"perseus-widget-measurer-url",ref:"image-url",defaultValue:e.url,onChange:this._changeUrl}),G.createElement(fp,null,G.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.'))),e.url&&G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",{className:"perseus-widget-left-col"},"Pixels from top:"," ",G.createElement(vp,{placeholder:0,onChange:this._changeTop,value:e.top,useArrowKeys:!0})),G.createElement("label",{className:"perseus-widget-right-col"},"Pixels from left:"," ",G.createElement(vp,{placeholder:0,onChange:this._changeLeft,value:e.left,useArrowKeys:!0}))),G.createElement("div",null,"Containing area [width, height]:"," ",G.createElement(bp,{onChange:this.change("box"),value:this.props.box,useArrowKeys:!0})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(yp,{label:"Show ruler",showRuler:this.props.showRuler,onChange:this.props.onChange})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(yp,{label:"Show protractor",showProtractor:this.props.showProtractor,onChange:this.props.onChange}))),this.props.showRuler&&G.createElement("div",null,G.createElement("div",null,G.createElement("label",null," ","Ruler label:"," ",G.createElement("select",{onChange:e=>this.change("rulerLabel",e.target.value),value:this.props.rulerLabel},G.createElement("option",{value:""},"None"),G.createElement("optgroup",{label:"Metric"},this.renderLabelChoices([["milimeters","mm"],["centimeters","cm"],["meters","m"],["kilometers","km"]])),G.createElement("optgroup",{label:"Imperial"},this.renderLabelChoices([["inches","in"],["feet","ft"],["yards","yd"],["miles","mi"]]))))),G.createElement("div",null,G.createElement("label",null," ","Ruler ticks:"," ",G.createElement("select",{onChange:e=>this.change("rulerTicks",+e.target.value),value:this.props.rulerTicks},X.map([1,2,4,8,10,16],(function(e){return G.createElement("option",{key:e,value:e},e)}))))),G.createElement("div",null,G.createElement("label",null,"Ruler pixels per unit:"," ",G.createElement(vp,{placeholder:40,onChange:this.change("rulerPixels"),value:this.props.rulerPixels,useArrowKeys:!0}))),G.createElement("div",null,G.createElement("label",null,"Ruler length in units:"," ",G.createElement(vp,{placeholder:10,onChange:this.change("rulerLength"),value:this.props.rulerLength,useArrowKeys:!0})))))}}le(wp,"widgetName","measurer"),le(wp,"propTypes",oe(oe({},x.propTypes),{},{box:J.arrayOf(J.number),image:J.shape({url:J.string,top:J.number,left:J.number}),showProtractor:J.bool,showRuler:J.bool,rulerLabel:J.string,rulerTicks:J.number,rulerPixels:J.number,rulerLength:J.number})),le(wp,"defaultProps",{box:[480,480],image:{},showProtractor:!0,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10});var{NumberInput:xp,TextInput:Cp}=t;class kp extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"updateMolecule",(e=>{this.change({smiles:e})})),le(this,"updateRotation",(e=>{this.change({rotationAngle:e})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"SMILES: ",G.createElement(Cp,{onChange:this.updateMolecule,value:this.props.smiles}))),G.createElement("div",null,G.createElement("label",null,"Rotation (deg): ",G.createElement(xp,{onChange:this.updateRotation,value:this.props.rotationAngle}))))}}le(kp,"propTypes",oe(oe({},x.propTypes),{},{rotationAngle:J.number,smiles:J.string})),le(kp,"widgetName","molecule-renderer");var{ButtonGroup:Sp,InfoTip:Np,NumberInput:Tp,PropCheckBox:_p,RangeInput:Op}=t;class Mp extends G.Component{constructor(){super(...arguments),le(this,"onRangeChange",(e=>{this.props.onChange({range:e})})),le(this,"onLabelRangeChange",((e,t)=>{var n=this.props.labelRange.slice(),r=n[1-e];null==t||null==r?n[e]=t:n=[Math.min(t,r),Math.max(t,r)],this.props.onChange({labelRange:n})})),le(this,"onDivisionRangeChange",(e=>{var t,n,r,a=this.props.numDivisions;t=a,n=e[0],r=e[1],a=Math.min(Math.max(t,n),r),this.props.onChange({divisionRange:e,numDivisions:a})})),le(this,"onNumChange",((e,t)=>{var n={};n[e]=t,this.props.onChange(n)})),le(this,"onNumDivisionsChange",(e=>{var t=this.props.divisionRange.slice();(e=(e=X.isFinite(e)?Math.round(e):0)<0?-1*e:e)&&(e=Math.min(t[1],Math.max(t[0],e)),this.props.onChange({tickStep:null,divisionRange:t,numDivisions:e}))})),le(this,"onTickStepChange",(e=>{this.props.onChange({numDivisions:null,tickStep:e})})),le(this,"onChangeRelation",(e=>{var t=e.target.value;this.props.onChange({correctRel:t,isInequality:"eq"!==t})})),le(this,"onLabelStyleChange",(e=>{this.props.onChange({labelStyle:e})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=this.props.range,t=this.props.labelRange,n=this.props.divisionRange;e[0]=+e[0],e[1]=+e[1];var r,a=e[1]-e[0],s=this.props.numDivisions,i=this.props.snapDivisions,o=this.props.tickStep,l=this.props.isTickCtrl;r=l?null:o?o/i:a/s/i;return G.createElement("div",{className:"perseus-widget-number-line-editor"},G.createElement("div",{className:"perseus-widget-row"},"Correct x"," ",G.createElement("select",{value:this.props.correctRel,onChange:this.onChangeRelation},G.createElement("option",{value:"eq"}," = "),G.createElement("option",{value:"lt"}," < "),G.createElement("option",{value:"gt"}," > "),G.createElement("option",{value:"le"}," ≤ "),G.createElement("option",{value:"ge"}," ≥ "))," ",G.createElement(Tp,{value:this.props.correctX,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"correctX"),checkValidity:t=>t>=e[0]&&t<=e[1]&&(!r||li.number.isInteger((t-e[0])/r)),placeholder:"answer",size:"normal",useArrowKeys:!0}),G.createElement(Np,null,G.createElement("p",null,"This is the correct answer. The answer is validated (as right or wrong) by using only the end position of the point and the relation (=, <, >, ≤, ≥)."))),G.createElement("div",{className:"perseus-widget-row"},this.props.static?G.createElement("label",null,"Range:"):G.createElement("label",null,"Position:"," ",G.createElement(Tp,{value:this.props.initialX,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"initialX"),placeholder:e[0],checkValidity:t=>t>=e[0]&&t<=e[1],useArrowKeys:!0})," ∈ "),G.createElement(Op,{value:e,onChange:this.onRangeChange,format:this.props.labelStyle,useArrowKeys:!0}),G.createElement(Np,null,G.createElement("p",null,"This controls the initial position of the point along the number line and the",G.createElement("strong",null,"range"),", the position of the endpoints of the number line. Setting the range constrains the position of the answer and the labels."),G.createElement("p",null,"In static mode, the initial position of the point is determined by Correct x instead of position."))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Labels:"," ",G.createElement(Tp,{value:t[0],placeholder:e[0],format:this.props.labelStyle,checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onLabelRangeChange.bind(this,0),useArrowKeys:!0}),G.createElement("span",null," & "),G.createElement(Tp,{value:t[1],placeholder:e[1],format:this.props.labelStyle,checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onLabelRangeChange.bind(this,1),useArrowKeys:!0}),G.createElement(Np,null,G.createElement("p",null,"This controls the position of the left / right labels. By default, the labels are set by the range ",G.createElement("br",null),G.createElement("strong",null,"Note:")," Ensure that the labels line up with the tick marks, or it may be confusing for users.")))),G.createElement("div",{className:"perseus-widget-row"},"Style:"," ",G.createElement(Sp,{allowEmpty:!1,value:this.props.labelStyle,buttons:[{value:"decimal",content:"0.75",title:"Decimals"},{value:"improper",content:"⁷⁄₄",title:"Improper fractions"},{value:"mixed",content:"1¾",title:"Mixed numbers"},{value:"non-reduced",content:"⁸⁄₄",title:"Non-reduced"}],onChange:this.onLabelStyleChange}),G.createElement(Np,null,G.createElement("p",null,"This controls the styling of the labels for the two main labels as well as all the tick mark labels, if applicable. Your choices are decimal, improper fractions, mixed fractions, and non-reduced fractions."))),G.createElement("div",{className:"perseus-widget-row"},!this.props.static&&G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(_p,{label:"Show tick controller",isTickCtrl:this.props.isTickCtrl,onChange:this.props.onChange})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(_p,{label:"Show label ticks",labelTicks:this.props.labelTicks,onChange:this.props.onChange}))),G.createElement("div",{className:"perseus-widget-row"},!this.props.static&&G.createElement(_p,{label:"Show tooltips",showTooltips:this.props.showTooltips,onChange:this.props.onChange})),G.createElement("div",{className:"perseus-widget-row"},l&&G.createElement("span",null,G.createElement("label",null,"Start num divisions at"," ",G.createElement(Tp,{value:this.props.numDivisions||null,format:"decimal",onChange:this.onNumDivisionsChange,checkValidity:e=>e>=n[0]&&e<=n[1],placeholder:a/this.props.tickStep,useArrowKeys:!0})),G.createElement(Np,null,G.createElement("p",null,"This controls the number (and position) of the tick marks. The number of divisions is constrained to"," "+n[0]+"–"+n[1],".",G.createElement("br",null),G.createElement("strong",null,"Note:")," The user will be able to specify the number of divisions in a number input."))),!l&&G.createElement("span",null,G.createElement("label",null,"Num divisions:"," ",G.createElement(Tp,{value:this.props.numDivisions||null,format:"decimal",onChange:this.onNumDivisionsChange,checkValidity:e=>e>=n[0]&&e<=n[1],placeholder:a/this.props.tickStep,useArrowKeys:!0}))," ",G.createElement("label",null,"or tick step:"," ",G.createElement(Tp,{value:this.props.tickStep||null,format:this.props.labelStyle,onChange:this.onTickStepChange,checkValidity:e=>e>0&&e<=a,placeholder:a/this.props.numDivisions,useArrowKeys:!0})),G.createElement(Np,null,G.createElement("p",null,"This controls the number (and position) of the tick marks; you can either set the number of divisions (2 divisions would split the entire range in two halves), or the tick step (the distance between ticks) and the other value will be updated accordingly."," ",G.createElement("br",null),G.createElement("strong",null,"Note:")," There is no check to see if labels coordinate with the tick marks, which may be confusing for users if the blue labels and black ticks are off-step.")))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Snap increments per tick:"," ",G.createElement(Tp,{value:i,checkValidity:e=>e>0,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"snapDivisions"),useArrowKeys:!0})),G.createElement(Np,null,G.createElement("p",null,"This determines the number of different places the point will snap between two adjacent tick marks."," ",G.createElement("br",null),G.createElement("strong",null,"Note:"),"Ensure the required number of snap increments is provided to answer the question."))))}}le(Mp,"propTypes",{range:J.arrayOf(J.number).isRequired,labelRange:J.arrayOf(J.number).isRequired,labelStyle:J.string.isRequired,labelTicks:J.bool,divisionRange:J.arrayOf(J.number).isRequired,numDivisions:J.number.isRequired,snapDivisions:J.number,tickStep:J.number,correctRel:J.oneOf(["lt","gt","le","ge","eq"]),correctX:J.number,initialX:J.number,isTickCtrl:J.bool,onChange:J.func.isRequired,static:J.bool,showTooltips:J.bool}),le(Mp,"widgetName","number-line"),le(Mp,"defaultProps",{range:[0,10],labelRange:[null,null],labelStyle:"decimal",labelTicks:!0,divisionRange:[1,12],numDivisions:5,snapDivisions:2,tickStep:null,correctRel:"eq",correctX:null,initialX:null,showTooltips:!1});var{ButtonGroup:Ap,InfoTip:Pp,InlineIcon:Dp,MultiButtonGroup:Ip,NumberInput:Rp,PropCheckBox:zp,TextInput:Lp}=t,{iconGear:Fp,iconTrash:qp}=p,{firstNumericalParse:Up}=r,Wp=[{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:"π"}],Vp=e=>({value:null,status:e,message:"",simplify:"required",answerForms:[],strict:!1,maxError:null}),jp=Z({displayName:"NumericInputEditor",propTypes:oe({},x.propTypes),statics:{widgetName:"numeric-input"},getDefaultProps:function(){return{answers:[Vp("correct")],size:"normal",coefficient:!1,labelText:"",multipleNumberInput:!1,rightAlign:!1}},getInitialState:function(){return{lastStatus:"wrong",showOptions:X.map(this.props.answers,(()=>!1))}},render:function(){var e=this.props.answers,t=t=>G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Unsimplified answers are"),G.createElement(Ap,{value:e[t].simplify,allowEmpty:!1,buttons:[{value:"required",content:"ungraded"},{value:"optional",content:"accepted"},{value:"enforced",content:"wrong"}],onChange:this.updateAnswer(t,"simplify")}),G.createElement(Pp,null,G.createElement("p",null,'Normally select "ungraded". This will give the user a message saying the answer is correct but not simplified. The user will then have to simplify it and re-enter, but will not be penalized. (5th grade and after)'),G.createElement("p",null,'Select "accepted" only if the user is not expected to know how to simplify fractions yet. (Anything prior to 5th grade)'),G.createElement("p",null,'Select "wrong" ',G.createElement("em",null,"only")," if we are specifically assessing the ability to simplify."))),n=t=>G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Choose the suggested answer formats"),G.createElement(Ip,{buttons:Wp,values:e[t].answerForms,onChange:this.updateAnswer(t,"answerForms")}),G.createElement(Pp,null,G.createElement("p",null,'Formats will be autoselected for you based on the given answer; to show no suggested formats and accept all types, simply have a decimal/integer be the answer. Values with π will have format "pi", and values that are fractions will have some subset (mixed will be "mixed" and "proper"; improper/proper will both be "improper" and "proper"). If you would like to specify that it is only a proper fraction (or only a mixed/improper fraction), deselect the other format. Except for specific cases, you should not need to change the autoselected formats.'),G.createElement("p",null,"To restrict the answer to ",G.createElement("em",null,"only"),' an improper fraction (i.e. 7/4), select the improper fraction and toggle "strict" to true. This ',G.createElement("b",null,"will not")," ","accept 1.75 as an answer."," "),G.createElement("p",null,"Unless you are testing that specific skill, please do not restrict the answer format."))),G.createElement("div",{className:"perseus-widget-row"},G.createElement(zp,{label:"Strictly match only these formats",strict:e[t].strict,onChange:this.updateAnswer.bind(this,t)}))),r=t=>G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Max error"," ",G.createElement(Rp,{className:"max-error",value:e[t].maxError,onChange:this.updateAnswer(t,"maxError"),placeholder:"0"}))),a=G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Width: "),G.createElement(Ap,{value:this.props.size,allowEmpty:!1,buttons:[{value:"normal",content:"Normal (80px)"},{value:"small",content:"Small (40px)"}],onChange:this.change("size")}),G.createElement(Pp,null,G.createElement("p",null,'Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.'))),s=G.createElement("div",{className:"perseus-widget-row"},G.createElement(zp,{label:"Right alignment",rightAlign:this.props.rightAlign,onChange:this.props.onChange})),i=G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Label text:"," ",G.createElement(Lp,{value:this.props.labelText,onChange:this.change("labelText")})),G.createElement(Pp,null,G.createElement("p",null,"Text to describe this input. This will be shown to users using screenreaders."))),o=G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement(zp,{label:"Coefficient",coefficient:this.props.coefficient,onChange:this.props.onChange}),G.createElement(Pp,null,G.createElement("p",null,"A coefficient style number allows the student to use - for -1 and an empty string to mean 1.")))),l=G.createElement("div",null,G.createElement("a",{href:"javascript:void(0)",className:"simple-button orange",onClick:()=>this.addAnswer(),onKeyDown:e=>this.onSpace(e,this.addAnswer)},G.createElement("span",null,"Add new answer"))),c={wrong:"(address the mistake/misconception)",ungraded:"(explain in detail to avoid confusion)",correct:"(reinforce the user's understanding)"};return G.createElement("div",{className:"perseus-input-number-editor"},G.createElement("div",{ref:e=>this.multInputOption=e},G.createElement("select",{onChange:this.onMultipleInputChange},G.createElement("option",{value:"simple-numeric-input"},"Ask for one correct solution"),G.createElement("option",{value:"multiple-numeric-input"},"Ask for all correct solutions"))),G.createElement("div",{className:"ui-title"},"User input"),G.createElement("div",{className:"msg-title"},"Message shown to user on attempt"),(()=>e.map(((a,s)=>{var i=G.createElement(Sr,{apiOptions:this.props.apiOptions,content:a.message||"",placeholder:"Why is this answer "+a.status+"?\t"+c[a.status],widgetEnabled:!1,onChange:e=>{"content"in e&&this.updateAnswer(s,{message:e.content})}});return G.createElement("div",{className:"perseus-widget-row",key:s},G.createElement("div",{className:"input-answer-editor-value-container"+(a.maxError?" with-max-error":"")},G.createElement(Rp,{value:a.value,className:"numeric-input-value",placeholder:"answer",format:X.last(a.answerForms),onFormatChange:(e,t)=>{var n;"pi"===t?n=["pi"]:"mixed"===t?n=["proper","mixed"]:"proper"!==t&&"improper"!==t||(n=["proper","improper"]),this.updateAnswer(s,{value:Up(e),answerForms:n})},onChange:e=>{this.updateAnswer(s,{value:Up(e)})}}),a.strict&&G.createElement("div",{className:"is-strict-indicator",title:"strictly equivalent to"},"≡"),"required"!==a.simplify&&"correct"===a.status&&G.createElement("div",{className:"simplify-indicator "+a.simplify,title:"accepts unsimplified answers"},"‰"),a.maxError?G.createElement("div",{className:"max-error-container"},G.createElement("div",{className:"max-error-plusmn"},"±"),G.createElement(Rp,{placeholder:0,value:e[s].maxError,format:X.last(a.answerForms),onChange:this.updateAnswer(s,"maxError")})):null,G.createElement("div",{className:"value-divider"}),G.createElement("a",{href:"javascript:void(0)",className:"answer-status "+a.status,onClick:()=>this.onStatusChange(s),onKeyDown:e=>this.onSpace(e,this.onStatusChange,s)},a.status),G.createElement("a",{href:"javascript:void(0)",className:"answer-trash",onClick:()=>this.onTrashAnswer(s),onKeyDown:e=>this.onSpace(e,this.onTrashAnswer,s)},G.createElement(Dp,qp)),G.createElement("a",{href:"javascript:void(0)",className:"options-toggle",onClick:()=>this.onToggleOptions(s),onKeyDown:e=>this.onSpace(e,this.onToggleOptions,s)},G.createElement(Dp,Fp))),G.createElement("div",{className:"input-answer-editor-message"},i),this.state.showOptions[s]&&G.createElement("div",{className:"options-container"},r(s),"correct"===a.status&&t(s),n(s)))})))(),l,a,s,o,i)},change(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.change.apply(this,t)},onToggleOptions:function(e){var t=this.state.showOptions.slice();t[e]=!t[e],this.setState({showOptions:t})},onTrashAnswer:function(e){if(e>=0&&e<this.props.answers.length){var t=this.props.answers.slice(0);t.splice(e,1),this.props.onChange({answers:t})}},onSpace:function(e,t){if(" "===e.key){e.preventDefault();var n=X.toArray(arguments).slice(2);t.apply(this,n)}},onStatusChange:function(e){var t=["wrong","ungraded","correct"],n=this.props.answers,r=t[(X.indexOf(t,n[e].status)+1)%t.length];this.updateAnswer(e,{status:r,simplify:"correct"===r?"required":"accepted"})},onMultipleInputChange:function(e){"multiple-numeric-input"===e.target.value?this.props.onChange({multipleNumberInput:!0}):this.props.onChange({multipleNumberInput:!1})},updateAnswer:function(e,t){if(!X.isObject(t))return X.partial(((e,t,n)=>{var r={};r[t]=n,this.updateAnswer(e,r)}),e,t);var n=X.clone(this.props.answers);if(e===n.length){var r=Vp(this.state.lastStatus);n=n.concat(r)}n[e]=X.extend({},n[e],t),this.props.onChange({answers:n})},addAnswer:function(){var e=Vp(this.state.lastStatus),t=this.props.answers.concat(e);this.props.onChange({answers:t})},getSaveWarnings:function(){var e=[];return X.contains(X.pluck(this.props.answers,"value"),"")&&e.push("One or more answers is empty"),this.props.answers.forEach(((t,n)=>{t.strict&&(!t.answerForms||0===t.answerForms.length)&&e.push("Answer ".concat(n+1," is set to string format ")+"matching, but no format was selected")})),e},serialize(){return C.serialize.call(this)}}),{InfoTip:Bp,TextListEditor:$p}=t;class Hp extends G.Component{constructor(){super(...arguments),le(this,"onOptionsChange",((e,t,n)=>{var r={};r[e]=X.map(t,(function(e){return{content:e}})),this.props.onChange(r,n)})),le(this,"onLayoutChange",(e=>{this.props.onChange({layout:e.target.value})})),le(this,"onHeightChange",(e=>{this.props.onChange({height:e.target.value})})),le(this,"serialize",(()=>({options:X.chain(X.pluck(this.props.correctOptions,"content")).union(X.pluck(this.props.otherOptions,"content")).uniq().reject((function(e){return""===e})).sort().sortBy((function(e){return/\d/.test(e)?0:/^\$?[a-zA-Z]+\$?$/.test(e)?2:1})).map((function(e){return{content:e}})).value(),correctOptions:this.props.correctOptions,otherOptions:this.props.otherOptions,height:this.props.height,layout:this.props.layout})))}render(){return G.createElement("div",{className:"perseus-widget-orderer"},G.createElement("div",null," ","Correct answer:"," ",G.createElement(Bp,null,G.createElement("p",null,"Place the cards in the correct order. The same card can be used more than once in the answer but will only be displayed once at the top of a stack of identical cards."))),G.createElement($p,{options:X.pluck(this.props.correctOptions,"content"),onChange:this.onOptionsChange.bind(this,"correctOptions"),layout:this.props.layout}),G.createElement("div",null," ","Other cards:"," ",G.createElement(Bp,null,G.createElement("p",null,"Create cards that are not part of the answer."))),G.createElement($p,{options:X.pluck(this.props.otherOptions,"content"),onChange:this.onOptionsChange.bind(this,"otherOptions"),layout:this.props.layout}),G.createElement("div",null,G.createElement("label",null," ","Layout:"," ",G.createElement("select",{value:this.props.layout,onChange:this.onLayoutChange},G.createElement("option",{value:"horizontal"},"Horizontal"),G.createElement("option",{value:"vertical"},"Vertical"))),G.createElement(Bp,null,G.createElement("p",null,"Use the horizontal layout for short text and small images. The vertical layout is best for longer text (e.g. proofs)."))),G.createElement("div",null,G.createElement("label",null," ","Height:"," ",G.createElement("select",{value:this.props.height,onChange:this.onHeightChange},G.createElement("option",{value:"normal"},"Normal"),G.createElement("option",{value:"auto"},"Automatic"))),G.createElement(Bp,null,G.createElement("p",null,'Use "Normal" for text, "Automatic" for images.'))))}}le(Hp,"propTypes",{correctOptions:J.array,otherOptions:J.array,height:J.oneOf(["normal","auto"]),layout:J.oneOf(["horizontal","vertical"]),onChange:J.func.isRequired}),le(Hp,"widgetName","orderer"),le(Hp,"defaultProps",{correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:"normal",layout:"horizontal"});var{InfoTip:Gp,PropCheckBox:Yp}=t;class Kp extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=G.createElement(Sr,{ref:"passage-editor",apiOptions:this.props.apiOptions,content:this.props.passageText,widgetEnabled:!1,placeholder:"Type passage here...",onChange:e=>{this.change({passageText:e.content})},showWordCount:!0}),t=G.createElement(Sr,{ref:"passage-footnotes-editor",apiOptions:this.props.apiOptions,content:this.props.footnotes,widgetEnabled:!1,placeholder:"Type footnotes here...",onChange:e=>{this.change({footnotes:e.content})}});return G.createElement("div",{className:"perseus-widget-passage-editor"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(Yp,{label:"Show line numbers",labelAlignment:"right",showLineNumbers:this.props.showLineNumbers,onChange:this.props.onChange})),G.createElement("div",null,"Passage title:",G.createElement(Gp,null,G.createElement("p",null,"An optional title that will appear directly above the passage in the same font style. (E.g. Passage 1)")),G.createElement("div",null,G.createElement("input",{type:"text",defaultValue:this.props.passageTitle,onChange:e=>{this.change({passageTitle:e.target.value})}}))),G.createElement("div",null,"Passage Text:",e),G.createElement("div",null,"Footnotes:",G.createElement(Gp,null,G.createElement("p",null,"To add footnotes, add ^ characters where they belong in the passage. Then, add ^ in the footnotes area to reference the footnotes in the passage.")),t))}}le(Kp,"propTypes",oe(oe({},x.propTypes),{},{passageTitle:J.string,passageText:J.string,footnotes:J.string,showLineNumbers:J.bool})),le(Kp,"widgetName","passage"),le(Kp,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0});var{InfoTip:Xp,NumberInput:Jp,TextInput:Zp}=t;class Qp extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"Passage Number: ",G.createElement(Jp,{value:this.props.passageNumber,onChange:this.change("passageNumber")}))),G.createElement("div",null,G.createElement("label",null,"Reference Number: ",G.createElement(Jp,{value:this.props.referenceNumber,onChange:this.change("referenceNumber")}))),G.createElement("div",null,G.createElement("label",null,"Summary Text: ",G.createElement(Zp,{value:this.props.summaryText,onChange:this.change("summaryText")}),G.createElement(Xp,null,G.createElement("p",null,"Short summary of the referenced section. This will be included in parentheses and quotes automatically."),G.createElement("p",null,"Ex: The start ... the end")))))}}le(Qp,"propTypes",oe(oe({},x.propTypes),{},{passageNumber:J.number,referenceNumber:J.number,summaryText:J.string})),le(Qp,"widgetName","passage-ref"),le(Qp,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});class eh extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleContentChange",(e=>{this.change({content:e.target.value})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,"Content:",G.createElement("input",{type:"text",value:this.props.content,onChange:this.handleContentChange}))}}le(eh,"propTypes",oe(oe({},x.propTypes),{},{content:J.string})),le(eh,"widgetName","passage-ref-target"),le(eh,"defaultProps",{content:""});var{InfoTip:th,NumberInput:nh,RangeInput:rh,TextListEditor:ah}=t,sh=U.widget;function ih(e,t,n){var r=X.clone(e);r.length=t;for(var a=e.length;a<t;a++)r[a]=n;return r}var oh={scaleY:1,maxY:10,snapsPerLine:2},lh={type:J.oneOf(["bar","line","pic","histogram","dotplot"]),labels:J.arrayOf(J.string),categories:J.arrayOf(J.oneOfType([J.number,J.string])),scaleY:J.number,maxY:J.number,snapsPerLine:J.number,picSize:J.number,pixBoxHeight:J.number,picUrl:J.string,plotDimensions:J.arrayOf(J.number),labelInterval:J.number,starting:J.arrayOf(J.number),correct:J.arrayOf(J.number),static:J.bool,onChange:J.func},ch=e=>"$"+li.number.round(e,2)+"$";class ph extends G.Component{constructor(){super(...arguments),le(this,"state",{editing:this.props.static?"starting":"correct",pic:null,loadedUrl:null,minX:null,maxX:null,tickStep:null}),le(this,"fetchPic",(e=>{if(this.state.loadedUrl!==e){var t=new Image;t.src=e,t.onload=()=>{this.setState({pic:t,loadedUrl:e})}}})),le(this,"handleChangeTickStep",(e=>{this.setState({tickStep:e})})),le(this,"handleChangeRange",(e=>{this.setState({minX:e[0],maxX:e[1]})})),le(this,"changeLabelInterval",(e=>{this.props.onChange({labelInterval:e})})),le(this,"handlePlotterChange",(e=>{var t={};t[this.state.editing]=e.values,this.props.onChange(t)})),le(this,"changeType",(e=>{var t;("histogram"===e?(t=[ch(0)].concat(this.props.categories),this.props.onChange({type:e,categories:t})):"histogram"===this.props.type?(t=this.props.categories.slice(1),this.props.onChange({type:e,categories:t})):this.props.onChange({type:e}),t)&&(te.findDOMNode(this.refs.categories).value=t.join(", "))})),le(this,"changeLabel",((e,t)=>{var n=X.clone(this.props.labels);n[e]=t.target.value,this.props.onChange({labels:n})})),le(this,"changePicUrl",(e=>{var t=r.getRealImageUrl(e);this.props.onChange({picUrl:t})})),le(this,"changeCategories",(e=>{var t=e.length;"histogram"===this.props.type&&t--;var n=this.props.scaleY;this.props.onChange({categories:e,correct:ih(this.props.correct,t,n),starting:ih(this.props.starting,t,n)})})),le(this,"changeScale",(e=>{var t=this.props.scaleY,n=+e.target.value||oh.scaleY,r=function(e){return e*n/t},a=r(this.props.maxY);this.props.onChange({scaleY:n,maxY:a,correct:X.map(this.props.correct,r),starting:X.map(this.props.starting,r)}),te.findDOMNode(this.refs.maxY).value=a})),le(this,"changeMax",(e=>{this.props.onChange({maxY:+e.target.value||oh.maxY})})),le(this,"changeSnaps",(e=>{this.props.onChange({snapsPerLine:+e.target.value||oh.snapsPerLine})})),le(this,"changeEditing",(e=>{this.setState({editing:e})})),le(this,"setCategoriesFromScale",(()=>{var e,t=this.state.tickStep||1,n=this.state.minX||0,r=this.state.maxX||0,a=Math.floor((r-n)/t)*t;e="histogram"===this.props.type||"dotplot"===this.props.type?X.range(0,a+t,t):X.range(t,a+t,t),e=X.map(e,(e=>e+n)),e=X.map(e,ch),this.changeCategories(e),te.findDOMNode(this.refs.categories).value=e.join(", ")})),le(this,"serialize",(()=>{var e=X.pick(this.props,"correct","starting","type","labels","categories","scaleY","maxY","snapsPerLine","labelInterval");return"pic"===this.props.type&&(e.picUrl=this.props.picUrl),e}))}UNSAFE_componentWillMount(){this.fetchPic(this.props.picUrl)}UNSAFE_componentWillReceiveProps(e){this.fetchPic(e.picUrl),e.static&&this.setState({editing:"starting"})}render(){var e=X.contains(["line","histogram","dotplot"],this.props.type),t=!X.contains(["pic","dotplot"],this.props.type),n=oe({trackInteraction:()=>{}},this.props);return G.createElement("div",{className:"perseus-widget-plotter-editor"},G.createElement("div",null,"Chart type:"," ",X.map(["bar","line","pic","histogram","dotplot"],(function(e){return G.createElement("label",{key:e},G.createElement("input",{type:"radio",name:"chart-type",checked:this.props.type===e,onChange:X.partial(this.changeType,e)}),e)}),this)),G.createElement("div",null,"Labels:"," ",X.map(["x","y"],(function(e,t){return G.createElement("label",{key:e},e+":",G.createElement("input",{type:"text",onChange:X.partial(this.changeLabel,t),defaultValue:this.props.labels[t]}))}),this)),e&&G.createElement("div",{className:"set-from-scale-box"},G.createElement("span",{className:"categories-title"},"Set Categories From Scale"),G.createElement("div",null,G.createElement("label",null,"Tick Step:"," ",G.createElement(nh,{placeholder:1,useArrowKeys:!0,value:this.state.tickStep,onChange:this.handleChangeTickStep})),G.createElement(th,null,G.createElement("p",null,"The difference between adjacent ticks."))),G.createElement("div",null,G.createElement("label",null,"Range:"," ",G.createElement(rh,{placeholder:[0,10],useArrowKeys:!0,value:[this.state.minX,this.state.maxX],onChange:this.handleChangeRange}))),G.createElement("div",null,G.createElement("button",{onClick:this.setCategoriesFromScale},"Set Categories"," "))),G.createElement("div",null,G.createElement("label",null,"Label Interval:"," ",G.createElement(nh,{useArrowKeys:!0,value:this.props.labelInterval,onChange:this.changeLabelInterval})),G.createElement(th,null,G.createElement("p",null,'Which ticks to display the labels for. For instance, setting this to "4" will only show every 4th label (plus the last one)'))),"pic"===this.props.type&&G.createElement("div",null,G.createElement("label",null,"Picture:"," ",G.createElement(Ms,{className:"pic-url",value:this.props.picUrl,onChange:this.changePicUrl}),G.createElement(th,null,G.createElement("p",null,'Use the default picture of Earth, or insert the URL for a different picture using the "Add image" function.'))),this.state.pic&&this.state.pic.width!==this.state.pic.height&&G.createElement("p",{className:"warning"},G.createElement("b",null,"Warning"),": You are using a picture which is not square. This means the image will get distorted. You should probably crop it to be square.")),G.createElement("div",null,G.createElement("label",null,"Categories:"," ",G.createElement(ah,{ref:"categories",layout:"horizontal",options:this.props.categories,onChange:this.changeCategories}))),G.createElement("div",null,G.createElement("label",null,"Scale (y):"," ",G.createElement("input",{type:"text",onChange:this.changeScale,defaultValue:this.props.scaleY}))),G.createElement("div",null,G.createElement("label",null,"Max y:"," ",G.createElement("input",{type:"text",ref:"maxY",onChange:this.changeMax,defaultValue:this.props.maxY}))),t&&G.createElement("div",null,G.createElement("label",null,"Snaps per line:"," ",G.createElement("input",{type:"text",onChange:this.changeSnaps,defaultValue:this.props.snapsPerLine})),G.createElement(th,null,G.createElement("p",null,"Creates the specified number of divisions between the horizontal lines. Fewer snaps between lines makes the graph easier for the student to create correctly."))),G.createElement("div",null,"Editing values:"," ",["correct","starting"].map((e=>G.createElement("label",{key:e},G.createElement("input",{type:"radio",disabled:"correct"===e&&this.props.static,checked:this.props.static?"starting"===e:this.state.editing===e,onChange:t=>this.changeEditing(e)}),e))),G.createElement(th,null,G.createElement("p",null,"Use this toggle to switch between editing the correct answer (what the student will be graded on) and the starting values (what the student will see plotted when they start the problem). Note: These cannot be the same."),G.createElement("p",null,"In static mode, the starting values are rendered out to the displayed widget."))),G.createElement(sh,ce({},n,{starting:this.props[this.state.editing],onChange:this.handlePlotterChange})))}}le(ph,"propTypes",lh),le(ph,"widgetName","plotter"),le(ph,"defaultProps",oe(oe({},oh),{},{correct:[1],starting:[1],type:"bar",labels:["",""],categories:[""],picSize:30,picBoxHeight:36,plotDimensions:[275,200],labelInterval:1,get picUrl(){var e=o.getDependencies().staticUrl;return e?e("/images/badges/earth-small.png"):null}}));var{InlineIcon:hh,PropCheckBox:uh}=t,{iconPlus:dh,iconTrash:mh}=p;class gh extends G.Component{render(){var e=this.props.choice.correct?"correct":"incorrect",t="Type a choice here...";this.props.choice.isNoneOfTheAbove&&(t=this.props.choice.correct?"Type the answer to reveal to the user...":"None of the above");var n=G.createElement(Sr,{ref:"content-editor",apiOptions:this.props.apiOptions,content:this.props.choice.content||"",widgetEnabled:!1,placeholder:t,disabled:this.props.choice.isNoneOfTheAbove&&!this.props.choice.correct,onChange:this.props.onContentChange}),r=G.createElement(Sr,{ref:"clue-editor",apiOptions:this.props.apiOptions,content:this.props.choice.clue||"",widgetEnabled:!1,placeholder:se._("Why is this choice %(correctOrIncorrect)s?",{correctOrIncorrect:e}),onChange:this.props.onClueChange}),a=G.createElement("a",{className:"simple-button orange delete-choice",href:"#",onClick:this.props.onDelete,title:"Remove this choice"},G.createElement(hh,mh));return G.createElement("div",{className:"choice-clue-editors"},G.createElement("div",{className:"choice-editor ".concat(e)},n),G.createElement("div",{className:"clue-editor"},r),this.props.showDelete&&a)}}le(gh,"propTypes",{apiOptions:u.propTypes,choice:J.object,showDelete:J.bool,onClueChange:J.func,onContentChange:J.func,onDelete:J.func});class fh extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"onMultipleSelectChange",(e=>{e=e.multipleSelect;var t=X.reduce(this.props.choices,(function(e,t){return t.correct?e+1:e}),0);if(!e&&t>1){var n=X.map(this.props.choices,(function(e){return X.defaults({correct:!1},e)}));this.props.onChange({multipleSelect:e,choices:n})}else this.props.onChange({multipleSelect:e})})),le(this,"onCountChoicesChange",(e=>{e=e.countChoices,this.props.onChange({countChoices:e})})),le(this,"onChange",(e=>{var{checked:t}=e,n=X.map(this.props.choices,((e,n)=>X.extend({},e,{correct:t[n],content:e.isNoneOfTheAbove&&!t[n]?"":e.content})));this.props.onChange({choices:n})})),le(this,"onContentChange",((e,t)=>{var n=this.props.choices.slice();n[e]=X.extend({},n[e],{content:t}),this.props.onChange({choices:n})})),le(this,"onClueChange",((e,t)=>{var n=this.props.choices.slice();n[e]=X.extend({},n[e],{clue:t}),""===t&&delete n[e].clue,this.props.onChange({choices:n})})),le(this,"onDelete",((e,t)=>{t.preventDefault();var n=this.props.choices.slice(),r=n[e];n.splice(e,1),this.props.onChange({choices:n,hasNoneOfTheAbove:this.props.hasNoneOfTheAbove&&!r.isNoneOfTheAbove})})),le(this,"addChoice",((e,t)=>{t.preventDefault();var n=this.props.choices.slice(),r={isNoneOfTheAbove:e},a=n.length-(this.props.hasNoneOfTheAbove?1:0);n.splice(a,0,r),this.props.onChange({choices:n,hasNoneOfTheAbove:e||this.props.hasNoneOfTheAbove},(()=>{this.refs["choice-editor".concat(a)].refs["content-editor"].focus()}))})),le(this,"setDisplayCount",(e=>{this.props.onChange({displayCount:e})})),le(this,"focus",(()=>(this.refs["choice-editor0"].refs["content-editor"].focus(),!0))),le(this,"getSaveWarnings",(()=>X.some(X.pluck(this.props.choices,"correct"))?[]:["No choice is marked as correct."])),le(this,"serialize",(()=>X.pick(this.props,"choices","randomize","multipleSelect","countChoices","displayCount","hasNoneOfTheAbove","deselectEnabled")))}render(){var e=X.reduce(this.props.choices,(function(e,t){return t.correct?e+1:e}),0);return G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement("a",{href:"https://docs.google.com/document/d/1frZf7yrWVWb1n4tVjqlzqVUiv1pn4cZXbxgP62-JDBY/edit#heading=h.8ng1isya19nu",target:"_blank"},"Multiple choice style guide"),G.createElement("br",null),G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(uh,{label:"Multiple selections",labelAlignment:"right",multipleSelect:this.props.multipleSelect,onChange:this.onMultipleSelectChange})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(uh,{label:"Randomize order",labelAlignment:"right",randomize:this.props.randomize,onChange:this.props.onChange})),this.props.multipleSelect&&G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(uh,{label:"Specify number correct",labelAlignment:"right",countChoices:this.props.countChoices,onChange:this.onCountChoicesChange}))),G.createElement(W,{ref:"baseRadio",multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:e,editMode:!0,labelWrap:!1,apiOptions:this.props.apiOptions,choices:this.props.choices.map((function(e,t){return{content:G.createElement(gh,{ref:"choice-editor".concat(t),apiOptions:this.props.apiOptions,choice:e,onContentChange:e=>{"content"in e&&this.onContentChange(t,e.content)},onClueChange:e=>{"content"in e&&this.onClueChange(t,e.content)},onDelete:this.onDelete.bind(this,t),showDelete:this.props.choices.length>=2}),isNoneOfTheAbove:e.isNoneOfTheAbove,checked:e.correct}}),this),onChange:this.onChange}),G.createElement("div",{className:"add-choice-container"},G.createElement("a",{className:"simple-button orange",href:"#",onClick:this.addChoice.bind(this,!1)},G.createElement(hh,dh)," Add a choice"," "),!this.props.hasNoneOfTheAbove&&G.createElement("a",{className:"simple-button",href:"#",onClick:this.addChoice.bind(this,!0)},G.createElement(hh,dh)," None of the above"," ")))}}le(fh,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,choices:J.arrayOf(J.shape({content:J.string,clue:J.string,correct:J.bool})),displayCount:J.number,randomize:J.bool,hasNoneOfTheAbove:J.bool,multipleSelect:J.bool,countChoices:J.bool,deselectEnabled:J.bool,static:J.bool})),le(fh,"widgetName","radio"),le(fh,"defaultProps",{choices:[{},{}],displayCount:null,randomize:!1,hasNoneOfTheAbove:!1,multipleSelect:!1,countChoices:!1,deselectEnabled:!1});var{NumberInput:vh,TextInput:yh}=t;class bh extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"updateMolecule",(e=>function(t){var n=[...this.props.smiles];n[e]=t,this.change({smiles:n})}.bind(this))),le(this,"updateRotation",(e=>function(t){var n=[...this.props.rotationAngle];n[e]=t,this.change({rotationAngle:n})}.bind(this))),le(this,"updateSeparators",((e,t)=>n=>{var r=this.props.separators.map((e=>oe({},e)));r[e][t]=n,this.change({separators:r})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"LHS SMILES: ",G.createElement(yh,{onChange:this.updateMolecule(0),value:this.props.smiles[0]}))),G.createElement("div",null,G.createElement("label",null,"LHS Rotation (deg): ",G.createElement(vh,{onChange:this.updateRotation(0),value:this.props.rotationAngle[0]}))),G.createElement("div",null,G.createElement("label",null,"RHS SMILES: ",G.createElement(yh,{onChange:this.updateMolecule(1),value:this.props.smiles[1]}))),G.createElement("div",null,G.createElement("label",null,"RHS Rotation (deg): ",G.createElement(vh,{onChange:this.updateRotation(1),value:this.props.rotationAngle[1]}))),G.createElement("div",null,G.createElement("label",null,"Top of arrow text: ",G.createElement(yh,{onChange:this.updateSeparators(0,"topText"),value:this.props.separators[0].topText}))),G.createElement("div",null,G.createElement("label",null,"Bottom of arrow text: ",G.createElement(yh,{onChange:this.updateSeparators(0,"bottomText"),value:this.props.separators[0].bottomText}))))}}le(bh,"propTypes",oe(oe({},x.propTypes),{},{rotationAngle:J.arrayOf(J.number),separators:J.arrayOf(J.object),smiles:J.arrayOf(J.string)})),le(bh,"widgetName","reaction-diagram"),le(bh,"defaultProps",{smiles:["",""],rotationAngle:[0,0],separators:[{type:"right",topText:"",bottomText:""}]});var{InlineIcon:Eh}=t,{iconCircleArrowDown:wh,iconCircleArrowUp:xh,iconPlus:Ch,iconTrash:kh}=p;class Sh extends G.Component{render(){return G.createElement("a",{href:"#",className:"step-control-button simple-button simple-button--small orange",onClick:e=>{e.preventDefault(),this.props.onClick()}},G.createElement(Eh,this.props.icon))}}class Nh extends G.Component{constructor(){super(...arguments),le(this,"_handleEditorChange",((e,t)=>{var n=X.clone(this.props.json);n[e]=X.extend({},n[e],t),this.props.onChange({json:n})})),le(this,"serialize",(()=>({json:X.times(this.props.json.length,(e=>this.refs["editor"+e].serialize()))}))),le(this,"_handleMoveStepEarlier",(e=>{if(0!==e){var t=X.clone(this.props.json),n=t[e];t.splice(e,1),t.splice(e-1,0,n),this.props.onChange({json:t})}})),le(this,"_handleMoveStepLater",(e=>{var t=X.clone(this.props.json);if(e+1!==t.length){var n=t[e];t.splice(e,1),t.splice(e+1,0,n),this.props.onChange({json:t})}})),le(this,"_handleAddStepAfter",(e=>{var t=X.clone(this.props.json),n=e>=0?{widgets:t[e].widgets}:{};t.splice(e+1,0,n),this.props.onChange({json:t})})),le(this,"_handleRemoveStep",(e=>{var t=X.clone(this.props.json);t.splice(e,1),this.props.onChange({json:t})}))}render(){return G.createElement("div",{className:"perseus-sequence-editor"},X.map(this.props.json,((e,t)=>G.createElement("div",{key:t},"Step ",t+1,G.createElement("div",{style:{display:"inline-block",float:"right"}},t+1<this.props.json.length&&G.createElement(Sh,{icon:wh,onClick:()=>{this._handleMoveStepLater(t)}}),t>0&&G.createElement(Sh,{icon:xh,onClick:()=>{this._handleMoveStepEarlier(t)}}),G.createElement(Sh,{icon:kh,onClick:()=>{confirm("Are you sure you want to remove step "+(t+1)+"?")&&this._handleRemoveStep(t)}}),G.createElement(Sh,{icon:Ch,onClick:()=>{this._handleAddStepAfter(t)}})),G.createElement(Sr,{ref:"editor"+t,apiOptions:this.props.apiOptions,content:e.content,widgets:e.widgets,images:e.images,widgetEnabled:!0,immutableWidgets:!1,onChange:X.partial(this._handleEditorChange,t)})))))}}le(Nh,"propTypes",{json:J.arrayOf(J.shape({content:J.string,widgets:J.objectOf(J.any),images:J.objectOf(J.any)})),apiOptions:u.propTypes,onChange:J.func.isRequired}),le(Nh,"widgetName","sequence"),le(Nh,"defaultProps",{json:[{content:"",widgets:{},images:{}}]});class Th extends G.Component{constructor(){super(...arguments),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"changeValue",(e=>{this.props.onChange(e.target.value)}))}render(){return G.createElement("textarea",{ref:"input",value:this.props.value||"",onChange:this.changeValue})}}class _h extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,G.createElement("div",null,"Simple markdown contents:"),G.createElement("div",null,G.createElement(Th,{value:this.props.value,onChange:this.change("value"),ref:"input"}))))}}le(_h,"propTypes",oe({},x.propTypes)),le(_h,"widgetName","simple-markdown-tester"),le(_h,"defaultProps",{value:""});var{InfoTip:Oh,NumberInput:Mh}=t;class Ah extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleTargetValueChange",((e,t)=>{this.change(e,t.target.value)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",{className:"perseus-widget-simulator"},G.createElement("div",null,se._("X-Axis Label"),":",G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.xAxisLabel,onChange:X.partial(this.handleTargetValueChange,"xAxisLabel")})),G.createElement("div",null,se._("Y-Axis Label"),":",G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.yAxisLabel,onChange:X.partial(this.handleTargetValueChange,"yAxisLabel")})),G.createElement("div",null,se._('"True Proportion" Label'),":",G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.proportionLabel,onChange:X.partial(this.handleTargetValueChange,"proportionLabel")}),G.createElement(Oh,null,G.createElement("p",null,'This text will be displayed next to the box in which the user enters the sample proportion for their simulation. For example, if your question is about surveying for approval ratings, you might want this to say "Sample approval rating".'))),G.createElement("div",null,se._("Proportion or Percentage"),":",G.createElement("select",{className:"perseus-widget-dropdown",value:this.props.proportionOrPercentage,onChange:X.partial(this.handleTargetValueChange,"proportionOrPercentage")},G.createElement("option",{key:"proportion",value:"proportion"},"Proportion"),G.createElement("option",{key:"percentage",value:"percentage"},"Percentage")),G.createElement(Oh,null,G.createElement("p",null,"Do you want the user to describe their simulation in terms of a proportion or a percentage?"))),G.createElement("div",null,se._("Number of trials"),":",G.createElement(Mh,{value:this.props.numTrials,checkValidity:e=>e>=0&&e<=5e3,onChange:this.change("numTrials")}),G.createElement(Oh,null,G.createElement("p",null,"This controls the number of trials used in the simulation. For example, if you set this to 50, then the survey will be conducted 50 times. Warning: setting this too high (i.e., greater than 5000 or so) will freeze the page."))))}}le(Ah,"propTypes",oe(oe({},x.propTypes),{},{xAxisLabel:J.string,yAxisLabel:J.string,numTrials:J.number,proportionLabel:J.string,proportionOrPercentage:J.string})),le(Ah,"widgetName","simulator"),le(Ah,"defaultProps",{xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",numTrials:100,proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion"});var{InfoTip:Ph,PropCheckBox:Dh,TextListEditor:Ih}=t;class Rh extends G.Component{constructor(){super(...arguments),le(this,"onLayoutChange",(e=>{this.props.onChange({layout:e.target.value})})),le(this,"serialize",(()=>X.pick(this.props,"correct","layout","padding")))}render(){var e=this;return G.createElement("div",null,G.createElement("div",null," ","Correct answer:"," ",G.createElement(Ph,null,G.createElement("p",null,"Enter the correct answer (in the correct order) here. The preview on the right will have the cards in a randomized order, which is how the student will see them."))),G.createElement(Ih,{options:this.props.correct,onChange:function(t,n){e.props.onChange({correct:t},n)},layout:this.props.layout}),G.createElement("div",null,G.createElement("label",null," ","Layout:"," ",G.createElement("select",{value:this.props.layout,onChange:this.onLayoutChange},G.createElement("option",{value:"horizontal"},"Horizontal"),G.createElement("option",{value:"vertical"},"Vertical"))),G.createElement(Ph,null,G.createElement("p",null,"Use the horizontal layout for short text and small images. The vertical layout is best for longer text and larger images."))),G.createElement("div",null,G.createElement(Dh,{label:"Padding:",padding:this.props.padding,onChange:this.props.onChange}),G.createElement(Ph,null,G.createElement("p",null,"Padding is good for text, but not needed for images."))))}}le(Rh,"propTypes",{correct:J.array,layout:J.oneOf(["horizontal","vertical"]),padding:J.bool}),le(Rh,"widgetName","sorter"),le(Rh,"defaultProps",{correct:["$x$","$y$","$z$"],layout:"horizontal",padding:!0});var{InfoTip:zh,NumberInput:Lh}=t,Fh=V.widget;class qh extends G.Component{constructor(){super(...arguments),le(this,"focus",(()=>{te.findDOMNode(this.refs.numberOfColumns).focus()})),le(this,"onSizeInput",((e,t)=>{var n=+e||0,a=+t||0;n=Math.min(Math.max(1,n),30),a=Math.min(Math.max(1,a),6);var s=this.props.columns,i=this.props.rows,o=this.props.answers;function l(e){a<=s?e.length=a:X(a-s).times((function(){e.push("")}))}n<=i?o.length=n:X(n-i).times((function(){o.push(r.stringArrayOfSize(s))}));var c=this.props.headers;l(c),X.each(o,l),this.props.onChange({rows:n,columns:a,answers:o,headers:c})})),le(this,"serialize",(()=>{var e=X.pick(this.props,"headers","rows","columns");return X.extend({},e,{answers:X.map(this.props.answers,X.clone)})}))}render(){var e=X.pick(this.props,"headers","answers","onChange","apiOptions");return X.extend(e,{editableHeaders:!0,Editor:Sr,onFocus:()=>{},onBlur:()=>{},trackInteraction:()=>{}}),G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Number of columns:"," ",G.createElement(Lh,{ref:"numberOfColumns",value:this.props.columns,onChange:e=>{e&&this.onSizeInput(this.props.rows,e)},useArrowKeys:!0}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Number of rows:"," ",G.createElement(Lh,{ref:"numberOfRows",value:this.props.rows,onChange:e=>{e&&this.onSizeInput(e,this.props.columns)},useArrowKeys:!0}))),G.createElement("div",null," ","Table of answers:"," ",G.createElement(zh,null,G.createElement("p",null,"The student has to fill out all cells in the table. For partially filled tables create a table using the template, and insert text input boxes as desired."))),G.createElement("div",null,G.createElement(Fh,e)))}}le(qh,"propTypes",{rows:J.number,columns:J.number,headers:J.arrayOf(J.string),answers:J.arrayOf(J.arrayOf(J.string))}),le(qh,"widgetName","table"),le(qh,"defaultProps",{headers:[""],rows:4,columns:1,answers:X(4).times((function(){return r.stringArrayOfSize(1)}))});var{Graph:Uh,InfoTip:Wh,PropCheckBox:Vh}=t,jh=j.widget,{deepEq:Bh,getGridStep:$h}=r;var Hh={url:null};function Gh(e,t){return e=X.clone(e).sort(li.point.compare),t=X.clone(t).sort(li.point.compare),X.all(X.map(e,(function(e,n){var r=t[n];return li.point.equal(e,r)})))}var Yh={apiOptions:u.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:[]}};class Kh extends G.Component{constructor(){super(...arguments),le(this,"changeConstraints",(e=>{var t=X.extend({},this.props.constraints,e);this.props.onChange({constraints:t})}))}render(){return G.createElement("div",null,this.props.name,":"," ",G.createElement(Vh,{label:"enabled:",enabled:this.props.settings.enabled,onChange:this.props.onChange})," ",this.props.settings.enabled&&G.createElement(Vh,{label:"required:",required:this.props.settings.required,onChange:this.props.onChange}),this.props.settings.enabled&&G.createElement(Wh,null,"'Required' will only grade the answer as correct if the student has used at least one such transformation.")," ",this.props.allowFixed&&this.props.settings.enabled&&G.createElement(Vh,{label:"fixed:",fixed:this.props.settings.constraints.fixed,onChange:this.changeConstraints}),this.props.allowFixed&&this.props.settings.enabled&&G.createElement(Wh,null,"Enable 'fixed' to prevent the student from repositioning the tool. The tool will appear in the position at which it is placed in the editor below."))}}le(Kh,"defaultProps",{allowFixed:!0});class Xh extends G.Component{constructor(){super(...arguments),le(this,"getMode",(()=>this.props.graphMode+","+this.props.listMode)),le(this,"changeMode",(e=>{var t=e.target.value.split(",");this.props.onChange({graphMode:t[0],listMode:t[1]})})),le(this,"changeHandlerFor",(e=>t=>{var n=X.clone(this.props.tools);n[e]=X.extend({},this.props.tools[e],t),this.props.onChange({tools:n})}))}render(){return G.createElement("div",{className:"transformer-settings"},G.createElement("div",null," ","Mode:"," ",G.createElement("select",{value:this.getMode(),onChange:this.changeMode},G.createElement("option",{value:"interactive,dynamic"}," ","Exploration with text"," "),G.createElement("option",{value:"interactive,static"}," ","Exploration without text"," "),G.createElement("option",{value:"dynamic,interactive"}," ","Formal with movement"," "),G.createElement("option",{value:"static,interactive"}," ","Formal without movement"," ")),G.createElement(Wh,null,G.createElement("ul",null,G.createElement("li",null,G.createElement("b",null,"Exploration:")," Students create transformations with tools on the graph."," "),G.createElement("li",null,G.createElement("b",null,"Formal with movement:")," Students specify transformations mathematically in the transformation list. Graph shows the results of these transformations."," "),G.createElement("li",null,G.createElement("b",null,"Formal without movement:")," Students specify transformations mathematically in the transformation list. Graph does not update."," ")))),G.createElement(Kh,{name:"Translations",settings:this.props.tools.translation,allowFixed:!1,onChange:this.changeHandlerFor("translation")}),G.createElement(Kh,{name:"Rotations",settings:this.props.tools.rotation,onChange:this.changeHandlerFor("rotation")}),G.createElement(Kh,{name:"Reflections",settings:this.props.tools.reflection,onChange:this.changeHandlerFor("reflection")}),G.createElement(Kh,{name:"Dilations",settings:this.props.tools.dilation,onChange:this.changeHandlerFor("dilation")}),G.createElement(Vh,{label:"Draw Solution:",drawSolutionShape:this.props.drawSolutionShape,onChange:this.props.onChange}))}}var Jh={getPointCountForType:function(e){var 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 s("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously.",i.InvalidInput,{metadata:{options:t}});var n=X.map(t.shape.coords,(function(a){var s=!1,i=a,o=e.addMovablePoint({coord:a,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,a){s||(i=o.coord,s=!0);var l=li.vector.subtract([e,a],o.coord);t.onMove&&(l=t.onMove(l[0],l[1])),t.translatable&&X.each(n,(function(e){e!==o&&e.setCoord(li.vector.add(e.coord,l))}));var c=o.coord,p=li.vector.add(o.coord,l);return o.coord=p,r.update(),o.coord=c,p},onMoveEnd:function(){if(t.onMoveEnd&&s){s=!1;var e=li.vector.subtract(o.coord,i);t.onMoveEnd(e[0],e[1])}r.update()}});return o.bounded=!0,o})),r=Jh.addShape(e,t,n),a=r.remove;return r.remove=function(){a.apply(r),X.invoke(n,"remove")},r},addShape:function(e,t,n){n=n||t.shape.coords;var r=Jh._typesOf(t.shape),a=t.shape.options||Jh.defaultOptions(r),s=Jh._mapTypes(r,n,(function(n,r,s){var i=X.extend({},t,a[s]);return Jh._addType(e,n,r,i)})),i=X.filter(X.pluck(s,"update"),X.identity),o=X.filter(X.pluck(s,"remove"),X.identity),l=function(){return X.map(s,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:r,points:n,update:function(){X.invoke(i,"call")},remove:function(){X.invoke(o,"call")},toJSON:function(){var e=X.map(n,(function(e){return X.isArray(e)?e:e.coord}));return{type:r,coords:e,options:l()}},getOptions:l}},equal:function(e,t){var n=Jh._typesOf(e),r=Jh._typesOf(t);if(n.length!==r.length)return!1;var a=Jh._mapTypes(n,e.coords,Jh._combine),s=Jh._mapTypes(r,t.coords,Jh._combine);return X.all(X.map(a,(function(e,t){var n=s[t];return e.type===n.type&&Jh._forType(e.type).equal(e.coords,n.coords)})))},_typesOf:function(e){var t=e.type;return X.isArray(t)||(t=[t]),X.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return X.map(e,(function(e){var t=Jh._forType(e).defaultOptions;return X.extend({},t)}))},_forType:function(e){var t=e.split("-")[0];return Jh[t]},_mapTypes:function(e,t,n,r){return X.map(e,(function(e,a){var s=Jh.getPointCountForType(e),i=X.first(t,s);return t=X.rest(t,s),n.call(r,e,i,a)}))},_addType:function(e,t,n,r){var a=X.isArray(n[0])?{coordA:n[0],coordZ:n[1]}:{pointA:n[0],pointZ:n[1]};if("polygon"===(t=t.split("-")[0])){var o=e.addMovablePolygon(X.extend({},r,{fixed:!r.editable,snapX:r.snap&&r.snap[0]||0,snapY:r.snap&&r.snap[1]||0,points:n,constrainToGraph:!1}));return{update:o.transform.bind(o),remove:o.remove.bind(o)}}if("line"===t||"lineSegment"===t){var l=e.addMovableLineSegment(X.extend({},r,a,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:l.transform.bind(l,!0),remove:l.remove.bind(l)}}if("angle"===t){var c=!!r.editable&&null,p=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:n,normalStyle:r.normalStyle,reflex:r.reflex});return X.isArray(n[0])||r.editable||(n[0].remove(),n[2].remove()),{update:p.update.bind(p,c),remove:p.remove.bind(p),getOptions:function(){return{reflex:p.isReflex()}}}}if("circle"===t){var h={remove:X.identity},u=function(){var t=n[0].coord||n[0],a=n[1].coord||n[1],s=li.point.distanceToPoint(t,a);h.remove(),h=e.circle(t,s,X.extend({stroke:A.DYNAMIC,"stroke-width":2},r.normalStyle))};return u(),n[1].remove&&!r.editable&&n[1].remove(),{update:u,remove:function(){h.remove()}}}if("point"===t)return{update:null,remove:null};throw new s("Invalid shape type "+t,i.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:Gh},line:{equal:li.line.equal},lineSegment:{equal:Gh},angle:{equal:function(e,t){if(!li.point.equal(e[1],t[1]))return!1;var n=[e[1],e[0]],r=[e[1],e[2]],a=[t[1],t[0]],s=[t[1],t[2]],i=li.ray.equal(n,a)&&li.ray.equal(r,s),o=li.ray.equal(n,s)&&li.ray.equal(r,a);return i||o},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){var n=li.point.distanceToPoint(e[0],e[1]),r=li.point.distanceToPoint(t[0],t[1]);return li.point.equal(e[0],t[0])&&li.number.equal(n,r)}},point:{equal:li.point.equal}};class Zh extends G.Component{constructor(){super(...arguments),le(this,"getTypeString",(e=>X.isArray(e)?X.map(e,this.getTypeString).join(","):"polygon"===e?"polygon-"+this.props.shape.coords.length:e)),le(this,"changeType",(e=>{var t,n,r,a,s,i=String(e.target.value).split(","),o=(t=X.map(i,Jh.getPointCountForType),X.reduce(t,(function(e,t){return e+t}),0)),l=(n=4,r=this.refs.graph.props.range,a=r[0][1]-r[0][0],s=r[1][1]-r[1][0],n*Math.max(a,s)/20),c=180*(.5-1/o),p=X.times(o,(function(e){return li.point.rotateDeg([l,0],360*e/o+c)}));this.props.onChange({shape:{type:i,coords:p,options:Jh.defaultOptions(i)}})})),le(this,"updateCoords",(()=>{this.props.onChange({shape:this.shape.toJSON()})})),le(this,"setupGraphie",(e=>{this.shape=Jh.addMovableShape(e,{editable:!0,snap:e.snap,shape:this.props.shape,onMoveEnd:this.updateCoords})}))}render(){return G.createElement("div",null,G.createElement(Uh,{ref:"graph",box:this.props.graph.box,range:this.props.graph.range,labels:this.props.graph.labels,step:this.props.graph.step,gridStep:this.props.graph.gridStep,markings:this.props.graph.markings,backgroundImage:this.props.graph.backgroundImage,onGraphieUpdated:this.setupGraphie}),G.createElement("select",{key:"type-select",value:this.getTypeString(this.props.shape.type),onChange:this.changeType},G.createElement("option",{value:"polygon-3"},"Triangle"),G.createElement("option",{value:"polygon-4"},"Quadrilateral"),G.createElement("option",{value:"polygon-5"},"Pentagon"),G.createElement("option",{value:"polygon-6"},"Hexagon"),G.createElement("option",{value:"line"},"Line"),G.createElement("option",{value:"line,line"},"2 lines"),G.createElement("option",{value:"lineSegment"},"Line segment"),G.createElement("option",{value:"lineSegment,lineSegment"}," ","2 line segments"," "),G.createElement("option",{value:"angle"},"Angle"),G.createElement("option",{value:"circle"},"Circle")))}componentDidMount(){this.setupGraphie(this.refs.graph.graphie())}componentDidUpdate(e){Bh(e.shape,this.props.shape)||this.refs.graph.reset()}}class Qh extends G.Component{constructor(){super(...arguments),le(this,"changeGraph",((e,t)=>{var n=X.extend({},this.props.graph,e);this.props.onChange({graph:n},t)})),le(this,"changeStarting",(e=>{var t=X.extend({},this.props.starting,e);this.props.onChange({starting:t})})),le(this,"changeTransformer",((e,t)=>{e.transformations&&(e.correct=oe(oe({},this.props.correct),{},{transformations:e.transformations}),delete e.transformations),this.props.onChange(e,t)})),le(this,"serialize",(()=>{var e=this.refs.explorer.getEditorJSON();return e.correct=e.answer,delete e.answer,e}))}render(){var e,t,n,r,a,s=X.extend((e=this.props.graph,t=340,n=(e=e||{}).labels||["x","y"],r=e.range||[[-10,10],[-10,10]],a=e.step||[1,1],{box:[t,t],labels:n,range:r,step:a,gridStep:e.gridStep||$h(r,a,t),valid:!0,backgroundImage:Hh,markings:"grid",showProtractor:!1}),this.props.graph);return G.createElement("div",null,G.createElement("div",null,G.createElement(Vh,{label:"Grade empty answers as wrong:",gradeEmpty:this.props.gradeEmpty,onChange:this.props.onChange}),G.createElement(Wh,null,G.createElement("p",null,"We generally do not grade empty answers. This usually works well, but sometimes can result in giving away part of an answer in a multi-part question."),G.createElement("p",null,"If this is a multi-part question (there is another widget), you probably want to enable this option. Otherwise, you should leave it disabled."),G.createElement("p",null,"Confused? Talk to Elizabeth."))),G.createElement("div",null,"Graph settings:"),G.createElement(Hi,{box:s.box,labels:s.labels,range:s.range,step:s.step,gridStep:s.gridStep,valid:s.valid,backgroundImage:s.backgroundImage,markings:s.markings,showProtractor:s.showProtractor,onChange:this.changeGraph}),G.createElement("div",null,"Transformation settings:"),G.createElement(Xh,{ref:"transformationSettings",graphMode:this.props.graphMode,listMode:this.props.listMode,tools:this.props.tools,drawSolutionShape:this.props.drawSolutionShape,onChange:this.props.onChange}),G.createElement("div",null,"Starting location:"),G.createElement(Zh,{ref:"shapeEditor",graph:s,shape:this.props.starting.shape,onChange:this.changeStarting,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),G.createElement("div",null,"Solution transformations:"),G.createElement(jh,{ref:"explorer",graph:s,graphMode:this.props.graphMode,listMode:this.props.listMode,gradeEmpty:this.props.gradeEmpty,tools:this.props.tools,drawSolutionShape:this.props.drawSolutionShape,starting:this.props.starting,correct:this.props.starting,transformations:this.props.correct.transformations,onChange:this.changeTransformer,trackInteraction:()=>{}}))}}le(Qh,"defaultProps",Yh),le(Qh,"widgetName","transformer");var{InlineIcon:eu,NumberInput:tu}=t,{iconOk:nu,iconRemove:ru}=p,au=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()};class su extends G.Component{constructor(){super(...arguments),le(this,"_checkValidity",(e=>{var{name:t,original:n,sigfigs:r}=e,a=bi.unitParse(t),s="",i=!0;if(a.parsed&&n){var o=new bi.Var("x"),{unit:l}=a,c=new bi.Eq(n,"=",new bi.Mul(o,l));try{s=function(e,t){return B(e,t,-10,!1)}(c.solveLinearEquationForVariable(o).eval(),r),i=bi.compare(au(n),au(l)).equal}catch(e){i=!1}}else i=!1;this.setState({valid:i,solvedExample:s})}))}UNSAFE_componentWillMount(){this._checkValidity(this.props)}UNSAFE_componentWillReceiveProps(e){this._checkValidity(e)}render(){var e;return e=this.state.valid?G.createElement("span",null,G.createElement("span",{className:"unit-example-okay"},G.createElement(eu,nu)),this.state.solvedExample):G.createElement("span",{className:"unit-example-not-okay"},G.createElement(eu,ru)),G.createElement("div",null,e," ",this.props.name)}}class iu extends G.Component{constructor(e){var t;super(e),t=this,le(this,"parsed",void 0),le(this,"groupId",void 0),le(this,"original",void 0),le(this,"change",(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return x.change.apply(t,n)})),le(this,"handleAcceptingUnitsChange",(e=>{var t=e.target.value.split(",").map((e=>e.trim())).filter((e=>""!==e));this.change({acceptingUnits:t})})),le(this,"handleSigfigChange",(e=>{this.change({sigfigs:e})})),le(this,"_checkSigfigValidity",(e=>e>0&&e<=10)),le(this,"_setAccepting",(e=>{this.change({accepting:e})})),le(this,"_doOriginal",(e=>{var t=bi.unitParse(e.value);this.parsed=!1,t.parsed&&"unitMagnitude"===t.type&&(this.original=t.expr,this.parsed=!0)})),le(this,"onChange",(e=>{this.props.onChange({value:e.target.value})})),le(this,"getSaveWarnings",(()=>{var{value:e,accepting:t,acceptingUnits:n}=this.props,r=[];return bi.unitParse(e).parsed||r.push("Answer did not parse"),"some"===t&&0===n.length&&r.push("There are no accepted units"),r})),le(this,"serialize",(()=>C.serialize.call(this))),this.groupId=X.uniqueId("accepting"),this._doOriginal(e)}UNSAFE_componentWillReceiveProps(e){this._doOriginal(e)}render(){var{acceptingUnits:e=[],accepting:t}=this.props,n=null;if("some"===t){var r=e.map(((e,t)=>G.createElement(su,{name:e,original:this.original||null,sigfigs:this.props.sigfigs,key:t})));n=G.createElement("div",null,G.createElement("input",{type:"text",defaultValue:e.join(", "),onChange:this.handleAcceptingUnitsChange})," ","(comma-separated)",r)}return G.createElement("div",{className:"unit-editor"},G.createElement("div",null,G.createElement("input",{value:this.props.value,className:"unit-editor-canonical",onChange:this.onChange})," ",this.parsed?G.createElement("span",{className:"unit-example-okay"},G.createElement(eu,nu)):G.createElement("span",{className:"unit-example-not-okay"},G.createElement(eu,ru))),G.createElement("div",null,"Significant Figures:"," ",G.createElement(tu,{value:this.props.sigfigs,onChange:this.handleSigfigChange,checkValidity:this._checkSigfigValidity,useArrowKeys:!0})),G.createElement("div",null,G.createElement("label",null,G.createElement("input",{type:"radio",name:this.groupId,onChange:()=>this._setAccepting("all"),checked:"all"===this.props.accepting})," Any equivalent unit "),G.createElement("label",null,G.createElement("input",{type:"radio",name:this.groupId,onChange:()=>this._setAccepting("some"),checked:"some"===this.props.accepting})," Only these units ")),n)}}le(iu,"propTypes",oe(oe({},x.propTypes),{},{value:J.string,acceptingUnits:J.arrayOf(J.string),accepting:J.oneOf(["all","some"]),sigfigs:J.number})),le(iu,"widgetName","unit-input"),le(iu,"defaultProps",{value:"5x10^5 kg m / s^2",accepting:"all",sigfigs:3});var{InfoTip:ou}=t,lu=/khanacademy\.org\/.*\/v\/(.*)$/;function cu(e){var t=lu.exec(e);return t?t[1]:e}class pu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_handleUrlChange",(e=>{this.props.onChange({location:cu(e)})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,"KA Video Slug:"," ",G.createElement(Ms,{value:this.props.location,style:{width:290},onChange:this._handleUrlChange}),G.createElement(ou,null,"KA video URLs will be converted to just the slug.")))}}le(pu,"propTypes",oe(oe({},x.propTypes),{},{location:J.string,onChange:J.func})),le(pu,"widgetName","video"),le(pu,"defaultProps",{location:""});var hu=[Os,zs,Fs,js,mi,gi,vi,Mi,zi,Fi,ao,so,co,yo,wo,qo,Ho,Kc,lp,up,gp,wp,kp,Mp,jp,Hp,Kp,Qp,eh,ph,bh,Nh,_h,Ah,Rh,qh,Qh,iu,pu,fh];class uu extends G.Component{constructor(){super(...arguments),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"changeValue",(e=>{this.props.onChange(e.target.value)}))}render(){return G.createElement("input",{ref:"input",value:this.props.value||"",onChange:this.changeValue})}}class du extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"getUserInput",(()=>this.props.value)),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"simpleValidate",(e=>du.validate(this.getUserInput(),e)))}static validate(e,t){return""===e?{type:"invalid",message:"It looks like you haven't answered all of the question yet."}:e===t.correct?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}}render(){return G.createElement(uu,{ref:"input",value:this.props.value,onChange:this.change("value")})}}le(du,"propTypes",oe(oe({},x.propTypes),{},{value:J.string})),le(du,"defaultProps",{value:""});var mu={name:"example-widget",displayName:"Example Widget",defaultAlignment:"inline-block",hidden:!0,widget:du},gu=l.parse,fu=l.basicOutput;class vu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"toJSON",(()=>({}))),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"simpleValidate",(e=>vu.validate(this.toJSON(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e=gu(this.props.value),t=fu(e);return G.createElement("div",null,t)}}le(vu,"propTypes",oe(oe({},x.propTypes),{},{value:J.string})),le(vu,"defaultProps",{value:""});var yu=[...$,...[ui,mu,{name:"simple-markdown-tester",displayName:"Simple Markdown Tester",hidden:!0,widget:vu,transform:X.identity}]];n.registerEditors(hu),n.registerWidgets(yu);export{hu as AllEditors,yu as AllWidgets,ma as ArticleDiff,zr as ArticleEditor,ue as DeviceFramer,Sr as Editor,Ra as EditorPage,Or as IframeContentRenderer,fa as ItemDiff,ws as MultiRendererEditor,Cs as StatefulArticleEditor,Ss as StatefulEditorPage,Ea as StructuredItemDiff,jr as ViewportResizer,ja as i18n};
|
|
9
|
+
*/dt=pt,"production"===process.env.NODE_ENV?dt.exports=function(){if(ct)return ht;ct=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,s=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,o=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,f=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 r:case s:case a:case h:return e;default:switch(e=e&&e.$$typeof){case o:case p:case m:case d:case i:return e;default:return u}}case n:return u}}}function E(e){return b(e)===c}return ht.AsyncMode=l,ht.ConcurrentMode=c,ht.ContextConsumer=o,ht.ContextProvider=i,ht.Element=t,ht.ForwardRef=p,ht.Fragment=r,ht.Lazy=m,ht.Memo=d,ht.Portal=n,ht.Profiler=s,ht.StrictMode=a,ht.Suspense=h,ht.isAsyncMode=function(e){return E(e)||b(e)===l},ht.isConcurrentMode=E,ht.isContextConsumer=function(e){return b(e)===o},ht.isContextProvider=function(e){return b(e)===i},ht.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},ht.isForwardRef=function(e){return b(e)===p},ht.isFragment=function(e){return b(e)===r},ht.isLazy=function(e){return b(e)===m},ht.isMemo=function(e){return b(e)===d},ht.isPortal=function(e){return b(e)===n},ht.isProfiler=function(e){return b(e)===s},ht.isStrictMode=function(e){return b(e)===a},ht.isSuspense=function(e){return b(e)===h},ht.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===c||e===s||e===a||e===h||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===i||e.$$typeof===o||e.$$typeof===p||e.$$typeof===f||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},ht.typeOf=b,ht}():dt.exports=(ut||(ut=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,r=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,s=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,o=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,f=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 g=e.type;switch(g){case l:case c:case r:case s:case a:case h:return g;default:var f=g&&g.$$typeof;switch(f){case o:case p:case m:case d:case i:return f;default:return u}}case n:return u}}}var E=l,w=c,x=o,C=i,k=t,S=p,N=r,T=m,_=d,O=n,M=s,A=a,P=h,D=!1;function I(e){return b(e)===c}mt.AsyncMode=E,mt.ConcurrentMode=w,mt.ContextConsumer=x,mt.ContextProvider=C,mt.Element=k,mt.ForwardRef=S,mt.Fragment=N,mt.Lazy=T,mt.Memo=_,mt.Portal=O,mt.Profiler=M,mt.StrictMode=A,mt.Suspense=P,mt.isAsyncMode=function(e){return D||(D=!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.")),I(e)||b(e)===l},mt.isConcurrentMode=I,mt.isContextConsumer=function(e){return b(e)===o},mt.isContextProvider=function(e){return b(e)===i},mt.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},mt.isForwardRef=function(e){return b(e)===p},mt.isFragment=function(e){return b(e)===r},mt.isLazy=function(e){return b(e)===m},mt.isMemo=function(e){return b(e)===d},mt.isPortal=function(e){return b(e)===n},mt.isProfiler=function(e){return b(e)===s},mt.isStrictMode=function(e){return b(e)===a},mt.isSuspense=function(e){return b(e)===h},mt.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===c||e===s||e===a||e===h||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===i||e.$$typeof===o||e.$$typeof===p||e.$$typeof===f||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},mt.typeOf=b}()),mt);var gt=pt.exports,ft={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},vt={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},yt={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},bt={};function Et(e){return gt.isMemo(e)?yt:bt[e.$$typeof]||ft}bt[gt.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},bt[gt.Memo]=yt;var wt=Object.defineProperty,xt=Object.getOwnPropertyNames,Ct=Object.getOwnPropertySymbols,kt=Object.getOwnPropertyDescriptor,St=Object.getPrototypeOf,Nt=Object.prototype;var Tt=function e(t,n,r){if("string"!=typeof n){if(Nt){var a=St(n);a&&a!==Nt&&e(t,a,r)}var s=xt(n);Ct&&(s=s.concat(Ct(n)));for(var i=Et(t),o=Et(n),l=0;l<s.length;++l){var c=s[l];if(!(vt[c]||r&&r[c]||o&&o[c]||i&&i[c])){var p=kt(n,c);try{wt(t,c,p)}catch(e){}}}}return t},_t=function(e){var t=Xe();return t.displayName=e,t},Ot=_t("Router-History"),Mt=_t("Router"),At=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}Ee(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 Y.createElement(Mt.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},Y.createElement(Ot.Provider,{children:this.props.children||null,value:this.props.history}))},t}(Y.Component);"production"!==process.env.NODE_ENV&&(At.propTypes={children:J.node,history:J.object.isRequired,staticContext:J.object},At.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&ke(e.history===this.props.history,"You cannot change <Router history>")});var Pt=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).history=He(t.props),t}return Ee(t,e),t.prototype.render=function(){return Y.createElement(At,{history:this.history,children:this.props.children})},t}(Y.Component);if("production"!==process.env.NODE_ENV&&(Pt.propTypes={initialEntries:J.array,initialIndex:J.number,getUserConfirmation:J.func,keyLength:J.number,children:J.node},Pt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<MemoryRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { MemoryRouter as Router }`.")}),Y.Component,"production"!==process.env.NODE_ENV){var Dt=J.oneOfType([J.func,J.string]);J.bool,Dt.isRequired}"production"!==process.env.NODE_ENV&&(J.bool,J.string,J.oneOfType([J.string,J.object]).isRequired);var It={},Rt=0;function zt(e,t){void 0===t&&(t={}),("string"==typeof t||Array.isArray(t))&&(t={path:t});var n=t,r=n.path,a=n.exact,s=void 0!==a&&a,i=n.strict,o=void 0!==i&&i,l=n.sensitive,c=void 0!==l&&l;return[].concat(r).reduce((function(t,n){if(!n&&""!==n)return null;if(t)return t;var r=function(e,t){var n=""+t.end+t.strict+t.sensitive,r=It[n]||(It[n]={});if(r[e])return r[e];var a=[],s={regexp:Je.exports(e,a,t),keys:a};return Rt<1e4&&(r[e]=s,Rt++),s}(n,{end:s,strict:o,sensitive:c}),a=r.regexp,i=r.keys,l=a.exec(e);if(!l)return null;var p=l[0],h=l.slice(1),u=e===p;return s&&!u?null:{path:n,url:"/"===n&&""===p?"/":p,isExact:u,params:i.reduce((function(e,t,n){return e[t.name]=h[n],e}),{})}}),null)}function Lt(e){return 0===Y.Children.count(e)}function Ft(e,t,n){var r=e(t);return"production"!==process.env.NODE_ENV&&ke(void 0!==r,"You returned `undefined` from the `children` function of <Route"+(n?' path="'+n+'"':"")+">, but you should have returned a React element or `null`"),r||null}var qt=function(e){function t(){return e.apply(this,arguments)||this}return Ee(t,e),t.prototype.render=function(){var e=this;return Y.createElement(Mt.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <Route> outside a <Router>"):Te(!1));var n=e.props.location||t.location,r=ye({},t,{location:n,match:e.props.computedMatch?e.props.computedMatch:e.props.path?zt(n.pathname,e.props):t.match}),a=e.props,s=a.children,i=a.component,o=a.render;return Array.isArray(s)&&Lt(s)&&(s=null),Y.createElement(Mt.Provider,{value:r},r.match?s?"function"==typeof s?"production"!==process.env.NODE_ENV?Ft(s,r,e.props.path):s(r):s:i?Y.createElement(i,r):o?o(r):null:"function"==typeof s?"production"!==process.env.NODE_ENV?Ft(s,r,e.props.path):s(r):null)}))},t}(Y.Component);function Ut(e){return"/"===e.charAt(0)?e:"/"+e}function Wt(e,t){if(!e)return t;var n=Ut(e);return 0!==t.pathname.indexOf(n)?t:ye({},t,{pathname:t.pathname.substr(n.length)})}function Vt(e){return"string"==typeof e?e:De(e)}function jt(e){return function(){"production"!==process.env.NODE_ENV?Te(!1,"You cannot %s with <StaticRouter>"):Te(!1)}}function Bt(){}"production"!==process.env.NODE_ENV&&(qt.propTypes={children:J.oneOfType([J.func,J.node]),component:function(e,t){if(e[t]&&!pt.exports.isValidElementType(e[t]))return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component")},exact:J.bool,location:J.object,path:J.oneOfType([J.string,J.arrayOf(J.string)]),render:J.func,sensitive:J.bool,strict:J.bool},qt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!(this.props.children&&!Lt(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&&ke(!(this.props.children&&!Lt(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&&ke(!(this.props.component&&this.props.render),"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored")},qt.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&ke(!(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&&ke(!(!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 $t=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).handlePush=function(e){return t.navigateTo(e,"PUSH")},t.handleReplace=function(e){return t.navigateTo(e,"REPLACE")},t.handleListen=function(){return Bt},t.handleBlock=function(){return Bt},t}Ee(t,e);var n=t.prototype;return n.navigateTo=function(e,t){var n=this.props,r=n.basename,a=void 0===r?"":r,s=n.context,i=void 0===s?{}:s;i.action=t,i.location=function(e,t){return e?ye({},t,{pathname:Ut(e)+t.pathname}):t}(a,Ie(e)),i.url=Vt(i.location)},n.render=function(){var e=this.props,t=e.basename,n=void 0===t?"":t,r=e.context,a=void 0===r?{}:r,s=e.location,i=void 0===s?"/":s,o=ve(e,["basename","context","location"]),l={createHref:function(e){return Ut(n+Vt(e))},action:"POP",location:Wt(n,Ie(i)),push:this.handlePush,replace:this.handleReplace,go:jt(),goBack:jt(),goForward:jt(),listen:this.handleListen,block:this.handleBlock};return Y.createElement(At,ye({},o,{history:l,staticContext:a}))},t}(Y.Component);"production"!==process.env.NODE_ENV&&($t.propTypes={basename:J.string,context:J.object,location:J.oneOfType([J.string,J.object])},$t.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<StaticRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { StaticRouter as Router }`.")});var Ht=function(e){function t(){return e.apply(this,arguments)||this}return Ee(t,e),t.prototype.render=function(){var e=this;return Y.createElement(Mt.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <Switch> outside a <Router>"):Te(!1));var n,r,a=e.props.location||t.location;return Y.Children.forEach(e.props.children,(function(e){if(null==r&&Y.isValidElement(e)){n=e;var s=e.props.path||e.props.from;r=s?zt(a.pathname,ye({},e.props,{path:s})):t.match}})),r?Y.cloneElement(n,{location:a,computedMatch:r}):null}))},t}(Y.Component);if("production"!==process.env.NODE_ENV&&(Ht.propTypes={children:J.node,location:J.object},Ht.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&ke(!(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&&ke(!(!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.')}),Y.useContext,"production"!==process.env.NODE_ENV&&"undefined"!=typeof window){var Gt=window,Yt="__react_router_build__",Xt={cjs:"CommonJS",esm:"ES modules",umd:"UMD"};if(Gt[Yt]&&"esm"!==Gt[Yt]){var Kt=Xt[Gt[Yt]];throw new Error("You are loading the "+Xt.esm+" build of React Router on a page that is already running the "+Kt+" build, so things won't work right.")}Gt[Yt]="esm"}var Jt=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).history=qe(t.props),t}return Ee(t,e),t.prototype.render=function(){return Y.createElement(At,{history:this.history,children:this.props.children})},t}(Y.Component);"production"!==process.env.NODE_ENV&&(Jt.propTypes={basename:J.string,children:J.node,forceRefresh:J.bool,getUserConfirmation:J.func,keyLength:J.number},Jt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<BrowserRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { BrowserRouter as Router }`.")});var Zt=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return(t=e.call.apply(e,[this].concat(r))||this).history=Be(t.props),t}return Ee(t,e),t.prototype.render=function(){return Y.createElement(At,{history:this.history,children:this.props.children})},t}(Y.Component);"production"!==process.env.NODE_ENV&&(Zt.propTypes={basename:J.string,children:J.node,getUserConfirmation:J.func,hashType:J.oneOf(["hashbang","noslash","slash"])},Zt.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&ke(!this.props.history,"<HashRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { HashRouter as Router }`.")});var Qt=function(e,t){return"function"==typeof e?e(t):e},en=function(e,t){return"string"==typeof e?Ie(e,null,null,t):e},tn=function(e){return e},nn=Y.forwardRef;void 0===nn&&(nn=tn);var rn=nn((function(e,t){var n=e.innerRef,r=e.navigate,a=e.onClick,s=ve(e,["innerRef","navigate","onClick"]),i=s.target,o=ye({},s,{onClick:function(e){try{a&&a(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||i&&"_self"!==i||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),r())}});return o.ref=tn!==nn&&t||n,Y.createElement("a",o)}));"production"!==process.env.NODE_ENV&&(rn.displayName="LinkAnchor");var an=nn((function(e,t){var n=e.component,r=void 0===n?rn:n,a=e.replace,s=e.to,i=e.innerRef,o=ve(e,["component","replace","to","innerRef"]);return Y.createElement(Mt.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <Link> outside a <Router>"):Te(!1));var n=e.history,l=en(Qt(s,e.location),e.location),c=l?n.createHref(l):"",p=ye({},o,{href:c,navigate:function(){var t=Qt(s,e.location),r=De(e.location)===De(en(t));(a||r?n.replace:n.push)(t)}});return tn!==nn?p.ref=t||i:p.innerRef=i,Y.createElement(r,p)}))}));if("production"!==process.env.NODE_ENV){var sn=J.oneOfType([J.string,J.object,J.func]),on=J.oneOfType([J.string,J.func,J.shape({current:J.any})]);an.displayName="Link",an.propTypes={innerRef:on,onClick:J.func,replace:J.bool,target:J.string,to:sn.isRequired}}var ln=function(e){return e},cn=Y.forwardRef;void 0===cn&&(cn=ln);var pn=cn((function(e,t){var n=e["aria-current"],r=void 0===n?"page":n,a=e.activeClassName,s=void 0===a?"active":a,i=e.activeStyle,o=e.className,l=e.exact,c=e.isActive,p=e.location,h=e.sensitive,u=e.strict,d=e.style,m=e.to,g=e.innerRef,f=ve(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return Y.createElement(Mt.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <NavLink> outside a <Router>"):Te(!1));var n=p||e.location,a=en(Qt(m,n),n),v=a.pathname,y=v&&v.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),b=y?zt(n.pathname,{path:y,exact:l,sensitive:h,strict:u}):null,E=!!(c?c(b,n):b),w="function"==typeof o?o(E):o,x="function"==typeof d?d(E):d;E&&(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,s),x=ye({},x,i));var C=ye({"aria-current":E&&r||null,className:w,style:x,to:a},f);return ln!==cn?C.ref=t||g:C.innerRef=g,Y.createElement(an,C)}))}));if("production"!==process.env.NODE_ENV){pn.displayName="NavLink";var hn=J.oneOf(["page","step","location","date","time","true","false"]);pn.propTypes=ye({},an.propTypes,{"aria-current":hn,activeClassName:J.string,activeStyle:J.object,className:J.oneOfType([J.string,J.func]),exact:J.bool,isActive:J.func,location:J.object,sensitive:J.bool,strict:J.bool,style:J.oneOfType([J.object,J.func])})}function un(e){const t=[];if(!e)return t;if(Array.isArray(e))for(const n of e)t.push.apply(t,un(n));else t.push(e);return t}function dn(e){const t=[],n=[];if(!e)return{style:{},className:""};const r="undefined"!=typeof global&&global.SNAPSHOT_INLINE_APHRODITE;un(e).forEach((e=>{const a=e._definition;if(null!=a)if(r){const e={};for(const[t,n]of Object.entries(a))e[t.replace(/-[a-z]/g,(e=>e[1].toUpperCase()))]=n;n.push(e)}else t.push(e);else n.push(e)}));const a=Object.assign.apply(Object,[{}].concat(n));if(n.length>0&&!r){const e=ne.create({inlineStyles:a});t.push(e.inlineStyles)}return{style:r?a:{},className:re.apply(void 0,t)}}const mn=["children","style","tag","testId"],gn=/^h[1-6]$/,fn=ne.create({text:{WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"},header:{marginTop:0,marginBottom:0}});class vn extends G.Component{render(){const e=this.props,{children:t,style:n,tag:r,testId:a}=e,s=ve(e,mn),i=gn.test(r),o=dn([fn.text,i&&fn.header,n]);return G.createElement(r,ye({},s,{style:o.style,className:o.className,"data-test-id":a}),t)}}vn.defaultProps={tag:"span"};const yn=["className","style"];function bn(e,t){return function(n){const{className:r,style:a}=n,s=ve(n,yn),i="string"==typeof e?En[e]:null,{className:o,style:l}=dn([i,t,a]);return G.createElement(e,ye({},s,{className:[o,r].filter(Boolean).join(" "),style:l}))}}const En=ne.create({button:{margin:0,"::-moz-focus-inner":{border:0}}}),wn=["testId","tag"],xn=ne.create({default:{alignItems:"stretch",borderWidth:0,borderStyle:"solid",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:0,padding:0,position:"relative",zIndex:0,minHeight:0,minWidth:0}}),Cn=bn("div",xn.default),kn=bn("article",xn.default),Sn=bn("aside",xn.default),Nn=bn("nav",xn.default),Tn=bn("section",xn.default);class _n extends G.Component{render(){const e=this.props,{testId:t,tag:n}=e,r=ye({},ve(e,wn),{"data-test-id":t});switch(n){case"article":return G.createElement(kn,r);case"aside":return G.createElement(Sn,r);case"nav":return G.createElement(Nn,r);case"section":return G.createElement(Tn,r);case"div":return G.createElement(Cn,r);default:throw Error(`${n} is not an allowed value for the 'tag' prop`)}}}_n.defaultProps={tag:"div"};const On=require("flow-enums-runtime")({Root:"root",Initial:"initial",Standard:"standard"}),Mn=G.createContext(On.Root);class An extends G.Component{constructor(...e){super(...e),this.state={mounted:!1},this._isTheRootComponent=!1}componentDidMount(){this._isTheRootComponent&&this.setState({mounted:!0})}_renderAsRootComponent(){const{mounted:e}=this.state,{children:t,placeholder:n}=this.props;return this._isTheRootComponent=!0,e?G.createElement(Mn.Provider,{value:On.Standard},t()):n?G.createElement(Mn.Provider,{value:On.Initial},n()):null}_maybeRender(e){const{children:t,placeholder:n}=this.props;switch(e){case On.Root:return this._renderAsRootComponent();case On.Initial:return n?n():null;case On.Standard:return t()}return console.log(`We got a render state we don't understand: "${JSON.stringify(e)}"`),this._maybeRender(On.Root)}render(){return G.createElement(Mn.Consumer,null,(e=>this._maybeRender(e)))}}class Pn{constructor(e){this.get=e=>{const t=e.toLowerCase();if(!this._hasValidIdChars(e))throw new Error(`Invalid identifier key: ${e}`);return`${this._uniqueFactoryName}-${t}`};const t=(e="string"==typeof e?e:"").toLowerCase();if(!this._hasValidIdChars(t))throw new Error(`Invalid factory scope: ${e}`);this._uniqueFactoryName=`uid-${t}-${Pn._factoryUniquenessCounter++}`}_hasValidIdChars(e){if("string"!=typeof e)return!1;const t=e.replace(/[^\d\w-]/g,"-");return e===t}}Pn._factoryUniquenessCounter=0;class Dn{get(e){return e}}Dn.Default=new Dn;var In=Dn.Default;class Rn extends G.Component{_performRender(e){const{children:t,mockOnFirstRender:n,scope:r}=this.props;return e?n?t(In):null:(this._idFactory||(this._idFactory=new Pn(r)),t(this._idFactory))}render(){return G.createElement(An,{placeholder:()=>this._performRender(!0)},(()=>this._performRender(!1)))}}class zn extends G.Component{renderChildren(e){const{id:t,children:n}=this.props,r=e?e.get(zn.defaultId):t;if(!r)throw new Error("Did not get an identifier factory nor a id prop");return n(r)}render(){const{id:e,scope:t}=this.props;return e?this.renderChildren():G.createElement(Rn,{scope:t,mockOnFirstRender:!0},(e=>this.renderChildren(e)))}}zn.defaultId="wb-id";const Ln=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,Fn=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i,qn=/^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)$/i,Un=e=>{if("string"!=typeof e)throw new Error(`Failed to parse color: ${e}`);const t=e.match(Fn);if(t)return{r:parseInt(`${t[1]}${t[1]}`,16),g:parseInt(`${t[2]}${t[2]}`,16),b:parseInt(`${t[3]}${t[3]}`,16),a:1};const n=e.match(Ln);if(n)return{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16),a:1};const r=e.match(qn);if(r)return{r:parseFloat(r[1]),g:parseFloat(r[2]),b:parseFloat(r[3]),a:r[4]?parseFloat(r[4]):1};throw new Error(`Failed to parse color: ${e}`)},Wn=e=>{const t=Math.round(e.r),n=Math.round(e.g),r=Math.round(e.b);if(1===e.a){const e=e=>{const t=e.toString(16);return 1===t.length?t+t:t};return`#${e(t)}${e(n)}${e(r)}`}return`rgba(${t},${n},${r},${e.a.toFixed(2)})`},Vn=(e,t)=>{if(t<0||t>1)throw new Error("Percentage must be between 0 and 1");const n=Un(e);return Wn(ye({},n,{a:n.a*t}))},jn=(e,t)=>{const n=Un(e),r=Un(t);return Wn({r:n.r*n.a+r.r*(1-n.a),g:n.g*n.a+r.g*(1-n.a),b:n.b*n.a+r.b*(1-n.a),a:r.a})},Bn={blue:"#1865f2",purple:"#9059ff",green:"#00a60e",gold:"#ffb100",red:"#d92916",offBlack:"#21242c",offBlack64:Vn("#21242c",.64),offBlack50:Vn("#21242c",.5),offBlack32:Vn("#21242c",.32),offBlack16:Vn("#21242c",.16),offBlack8:Vn("#21242c",.08),offWhite:"#f7f8fa",white:"#ffffff",white64:Vn("#ffffff",.64),white50:Vn("#ffffff",.5),darkBlue:"#0a2a66",teal:"#14bf96",lightBlue:"#37c5fd",pink:"#fa50ae"},$n={controlDefault:Bn.blue,controlDestructive:Bn.red},Hn=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}}},Gn={onClick:()=>{},onMouseEnter:()=>{},onMouseLeave:()=>{},onMouseDown:()=>{},onMouseUp:()=>{},onDragStart:()=>{},onTouchStart:()=>{},onTouchEnd:()=>{},onTouchCancel:()=>{},onKeyDown:()=>{},onKeyUp:()=>{},tabIndex:0},Yn=13,Xn=32,Kn={hovered:!1,focused:!1,pressed:!1,waiting:!1};class Jn extends G.Component{static getDerivedStateFromProps(e,t){return e.disabled?ye({},Kn,{focused:t.focused}):null}constructor(e){super(e),this.handleClick=e=>{const{onClick:t,beforeNav:n,safeWithNav:r}=this.props;this.enterClick||((t||n||r)&&(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 r=e.which||e.keyCode,{triggerOnEnter:a,triggerOnSpace:s}=Hn(n);a&&r===Yn||s&&r===Xn?(e.preventDefault(),this.setState({pressed:!0})):a||r!==Yn||(this.enterClick=!0)},this.handleKeyUp=e=>{const{onKeyUp:t,role:n}=this.props;t&&t(e);const r=e.which||e.keyCode,{triggerOnEnter:a,triggerOnSpace:s}=Hn(n);a&&r===Yn||s&&r===Xn?(this.setState({pressed:!1,focused:!0}),this.runCallbackAndMaybeNavigate(e)):a||r!==Yn||(this.enterClick=!1)},this.handleFocus=e=>{this.setState({focused:!0})},this.handleBlur=e=>{this.setState({focused:!1,pressed:!1})},this.state=Kn,this.waitingForClick=!1,this.enterClick=!1,this.dragging=!1}navigateOrReset(e){if(e){const{history:e,href:t,skipClientNav:n,target:r}=this.props;t&&("_blank"===r?(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:r}=this.props;return r&&!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:r,href:a,type:s}=this.props;let i=!0,o=!0;if(t&&t(e),e.defaultPrevented&&(i=!1,o=!1),e.preventDefault(),!a&&"submit"===s&&o){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((()=>r?this.handleSafeWithNav(r,i):this.navigateOrReset(i))).catch((()=>{}));else{if(r)return this.handleSafeWithNav(r,i);this.navigateOrReset(i)}}render(){const e=this.props.disabled?ye({},Gn,{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)}}Jn.defaultProps={disabled:!1};const Zn=e=>"string"==typeof e&&(!/^(https?:)?\/\//i.test(e)&&!/^([^#]*#[\w-]*|[\w\-.]+:)/.test(e)),Qn=function(e){var t="withRouter("+(e.displayName||e.name)+")",n=function(n){var r=n.wrappedComponentRef,a=ve(n,["wrappedComponentRef"]);return Y.createElement(Mt.Consumer,null,(function(n){return n||("production"!==process.env.NODE_ENV?Te(!1,"You should not use <"+t+" /> outside a <Router>"):Te(!1)),Y.createElement(e,ye({},a,n,{ref:r}))}))};return n.displayName=t,n.WrappedComponent=e,"production"!==process.env.NODE_ENV&&(n.propTypes={wrappedComponentRef:J.oneOfType([J.string,J.func,J.object])}),Tt(n,e)}(Jn);function er(e,t,n){return n&&!0!==t&&e&&Zn(e)?Qn:Jn}const tr=["href","onClick","skipClientNav","beforeNav","safeWithNav","style","target","testId","onKeyDown","onKeyUp","hideDefaultFocusRing","light","disabled"],nr=bn("a"),rr=bn("button"),ar=bn(an);class sr extends G.Component{constructor(...e){super(...e),this.getCorrectTag=(e,t,n)=>{const r=this.props.href&&!this.props.disabled,a=t&&!this.props.skipClientNav&&Zn(this.props.href||"");return r&&a&&this.props.href?G.createElement(ar,ye({},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)):r&&!a?G.createElement(nr,ye({},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)):G.createElement(rr,ye({},n,{type:"button","aria-disabled":this.props.disabled}),this.props.children(e))}}renderClickableBehavior(e){const t=this.props,{href:n,onClick:r,skipClientNav:a,beforeNav:s,safeWithNav:i,style:o,target:l,testId:c,onKeyDown:p,onKeyUp:h,hideDefaultFocusRing:u,light:d,disabled:m}=t,g=ve(t,tr),f=er(n,a,e),v=e=>[ir.reset,ir.link,!u&&e.focused&&(d?ir.focusedLight:ir.focused),o];return s?G.createElement(f,{href:n,onClick:r,beforeNav:s,safeWithNav:i,onKeyDown:p,onKeyUp:h,disabled:m},((t,n)=>this.getCorrectTag(t,e,ye({},g,{"data-test-id":c,style:v(t)},n)))):G.createElement(f,{href:n,onClick:r,safeWithNav:i,onKeyDown:p,onKeyUp:h,target:l,disabled:m},((t,n)=>this.getCorrectTag(t,e,ye({},g,{"data-test-id":c,style:v(t)},n))))}render(){return G.createElement(Mt.Consumer,null,(e=>this.renderClickableBehavior(e)))}}sr.defaultProps={light:!1,disabled:!1,"aria-label":""};const ir=ne.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 ${Bn.blue}`},focusedLight:{outline:`solid 2px ${Bn.white}`}});var{InlineIcon:or}=t;class lr extends G.Component{render(){var{icon:e,onClick:t,title:n}=this.props;return G.createElement(sr,{className:"section-control-button simple-button simple-button--small ",onClick:e=>{e.preventDefault(),t()},role:"button",hideDefaultFocusRing:!0,"aria-label":n,style:cr.button},(t=>G.createElement(or,e)))}}var cr=ne.create({button:{backgroundColor:Bn.gold,margin:2,paddingRight:10,paddingLeft:10,paddingBottom:2}}),{InlineIcon:pr,PropCheckBox:hr}=t,{iconChevronDown:ur,iconChevronRight:dr,iconTrash:mr}=p,gr=new RegExp("(\\[\\[☃ {id}\\]\\])".replace("{id}","[a-z-]+ [0-9]+"),"g"),fr=/^\[\[([a-z-]+)$/,vr=/(?:\n{2,}|^\n*)$/,yr=/(\n*)$/,br=/^(\n*)/,Er=e=>{var t=e.toString();return t.length>=5&&(t=t.replace(/(\d)(?=(\d{3})+$)/g,"$1{,}")),t};class wr extends G.Component{constructor(){super(...arguments),le(this,"handleChange",(e=>{var t=e.currentTarget.value;""!==t&&this.props.onChange&&this.props.onChange(t)}))}shouldComponentUpdate(){return!1}render(){var e=n.getPublicWidgets(),t=K.sortBy(K.keys(e),(t=>e[t].displayName));return G.createElement("select",{value:"",onChange:this.handleChange},G.createElement("option",{value:""},"Add a widget…"),G.createElement("option",{disabled:!0},"--"),K.map(t,(t=>G.createElement("option",{key:t,value:t},e[t].displayName))))}}var xr=e=>{var t=K.omit(e,h);return n.upgradeWidgetInfoToLatestVersion(t)};class Cr extends G.Component{constructor(e){super(e),le(this,"_toggleWidget",(e=>{e.preventDefault(),this.setState({showWidget:!this.state.showWidget})})),le(this,"_handleWidgetChange",((e,t,n)=>{var r=Object.assign({},this.state.widgetInfo);r.options=Object.assign(this.refs.widget.serialize(),e),this.props.onChange(r,t,n)})),le(this,"_toggleStatic",(e=>{e.preventDefault();var t=Object.assign({},this.state.widgetInfo,{static:!this.state.widgetInfo.static});this.props.onChange(t)})),le(this,"_handleAlignmentChange",(e=>{var t=e.currentTarget.value,n=Object.assign({},this.state.widgetInfo);n.alignment=t,this.props.onChange(n)})),le(this,"getSaveWarnings",(()=>{var e=this.refs.widget.getSaveWarnings;return e?e():[]})),le(this,"serialize",(()=>{var e=this.state.widgetInfo;return{type:e.type,alignment:e.alignment,static:e.static,graded:e.graded,options:this.refs.widget.serialize(),version:e.version}})),this.state={showWidget:!1,widgetInfo:xr(e)}}UNSAFE_componentWillReceiveProps(e){this.setState({widgetInfo:xr(e)})}render(){var e,t=this.state.widgetInfo,r=n.getEditor(t.type);e=this.props.apiOptions.showAlignmentOptions?n.getSupportedAlignments(t.type):["default"];var a=n.supportsStaticMode(t.type),s="transformer"===t.type,i=G.createElement(hr,{label:"Graded:",graded:t.graded,onChange:this.props.onChange});return G.createElement("div",{className:"perseus-widget-editor"},G.createElement("div",{className:"perseus-widget-editor-title "+(this.state.showWidget?"open":"closed")},G.createElement("a",{className:"perseus-widget-editor-title-id",href:"#",onClick:this._toggleWidget},this.props.id,this.state.showWidget?G.createElement(pr,ur):G.createElement(pr,dr)),a&&G.createElement("input",{type:"button",onClick:this._toggleStatic,className:"simple-button--small",value:t.static?"Unset as static":"Set as static"}),e.length>1&&G.createElement("select",{className:"alignment",value:t.alignment,onChange:this._handleAlignmentChange},e.map((e=>G.createElement("option",{key:e},e)))),G.createElement(lr,{icon:mr,onClick:()=>{this.props.onRemove()},title:"Remove image widget"})),G.createElement("div",{className:"perseus-widget-editor-content "+(this.state.showWidget?"enter":"leave")},s&&i,r&&G.createElement(r,ce({ref:"widget",onChange:this._handleWidgetChange,static:t.static,apiOptions:this.props.apiOptions},t.options))))}}var kr=/!\[[^\]]*\]\(([^\s)]+)[^)]*\)/g;class Sr extends G.Component{constructor(){super(...arguments),le(this,"lastUserValue",void 0),le(this,"deferredChange",void 0),le(this,"widgetIds",void 0),le(this,"state",{katex:void 0,showKatexErrors:!1,textAreaValue:this.props.content}),le(this,"getWidgetEditor",((e,t)=>{if(n.getEditor(t))return G.createElement(Cr,ce({key:e,ref:e,id:e,type:t,onChange:this._handleWidgetEditorChange.bind(this,e),onRemove:this._handleWidgetEditorRemove.bind(this,e),apiOptions:this.props.apiOptions},this.props.widgets[e]))})),le(this,"_handleWidgetEditorChange",((e,t,n,r)=>{var a=Object.assign({},this.props.widgets);a[e]=Object.assign({},a[e],t),this.props.onChange({widgets:a},n,r)})),le(this,"_handleWidgetEditorRemove",(e=>{var t=this.refs.textarea,n=new RegExp("(\\[\\[☃ {id}\\]\\])".replace("{id}",e),"gm");this.props.onChange({content:t.value.replace(n,"")})})),le(this,"_sizeImages",(e=>{var t,n=(t=e.content,K.map(function(e,t){for(var n=[];;){var r=e.exec(t);if(!r)break;n.push(r)}return n}(kr,t),(e=>e[1]))),a=K.pick(e.images,n),s=K.filter(n,(e=>!a[e]));K.each(s,(t=>{r.getImageSize(t,((n,r)=>{a[t]={width:n,height:r},e.onChange({images:K.clone(a)},null,!0)}))}))})),le(this,"handleDrop",(e=>{var{imageUploader:t}=this.props,n=this.state.textAreaValue||"",r=e.dataTransfer;if(r&&t){var a=r.files;if(0!==a.length){var s=this.state.textAreaValue;K(a).chain().map((function(e){if(!e.type.match("image.*"))return null;var t="☃ "+K.uniqueId("image_");return n+="\n\n",{file:e,sentinel:t}})).reject(K.isNull).tap((()=>{this.lastUserValue=s,this.props.onChange({content:n})})).each((e=>{t(e.file,(t=>{this.lastUserValue=s,this.props.onChange({content:this.state.textAreaValue.replace(e.sentinel,t)})}))}))}else{var i=r.getData("URL");if(i){var o=n+"\n\n";this.lastUserValue=this.props.content,this.props.onChange({content:o})}}}})),le(this,"handleChange",(e=>{clearTimeout(this.deferredChange),this.setState({textAreaValue:e.currentTarget.value}),this.deferredChange=setTimeout((()=>{this.state.textAreaValue!==this.props.content&&this.props.onChange({content:this.state.textAreaValue})}),this.props.apiOptions.editorChangeDelay)})),le(this,"_handleKeyDown",(e=>{if("Tab"===e.key){var t=ee.findDOMNode(this.refs.textarea),a=r.textarea.getWordBeforeCursor(t),s=a.string.toLowerCase().match(fr);if(null!=s){var i=s[1],o=n.getAllWidgetTypes(),l=K.filter(o,(e=>e.substring(0,i.length)===i));if(1===l.length){var c=l[0];this._addWidgetToContent(this.props.content,[a.pos.start,a.pos.end+1],c)}e.preventDefault()}}})),le(this,"_maybeCopyWidgets",(e=>{var t=e.currentTarget,n=t.value.substring(t.selectionStart,t.selectionEnd),s=K.map(n.match(gr),(e=>r.rWidgetParts.exec(e)[1])),i=K.pick(this.serialize().widgets,s);localStorage.perseusLastCopiedText=n,localStorage.perseusLastCopiedWidgets=JSON.stringify(i),a.log("Widgets copied: ".concat(localStorage.perseusLastCopiedWidgets))})),le(this,"_maybePasteWidgets",(e=>{var t=localStorage.perseusLastCopiedWidgets,n=localStorage.perseusLastCopiedText,a=e.originalEvent.clipboardData.getData("text");if(t&&n===a){e.preventDefault();var s=JSON.parse(t),i=this._safeWidgetNameMapping(s),o={};for(var[l,c]of Object.entries(s))o[i[l]]=c;var p=K.extend(o,this.props.widgets),h=n.replace(gr,(e=>{var t=r.rWidgetParts.exec(e),n=t[0],a=t[1];return n.replace(a,i[a])})),u=e.currentTarget,d=u.selectionStart,m=this.state.textAreaValue.substr(0,d)+h+this.state.textAreaValue.substr(u.selectionEnd);this.lastUserValue=this.state.textAreaValue,this.props.onChange({content:m,widgets:p},(()=>{var e=d+h.length;r.textarea.moveCursor(u,e)}))}})),le(this,"_safeWidgetNameMapping",(e=>{var t=K.keys(e).map((e=>e.split(" "))),n=K.uniq(t.map((e=>e[0]))),r=K.keys(this.props.widgets).map((e=>e.split(" "))),a={};K.each(n,(e=>{a[e]=K.chain(r).filter((t=>t[0]===e)).map((e=>+e[1]+1)).max().value(),a[e]=Math.max(a[e],1)}));var s={};return K.each(t,(e=>{var t=e.join(" "),n=e[0];s[t]="".concat(n," ").concat(a[n]),a[n]++})),s})),le(this,"_addWidgetToContent",((e,t,a)=>{var s,i=ee.findDOMNode(this.refs.textarea),o=K.map(e.match(gr),(e=>{var t=r.rWidgetParts.exec(e);return[t[2],+t[3]]})),l=K.reduce(o,((e,t)=>{var[n,r]=t;return n===a?Math.max(r+1,e):e}),1),c=a+" "+l,p="[[☃ {id}]]".replace("{id}",c),h="block"===n.getDefaultAlignment(a),u=e.slice(0,t[0]),d=e.slice(t[1]),m=(h?(e=>{if(!vr.test(e)){var t=yr.exec(e);if(t){var n=t[1];return e+"\n\n".slice(0,2-n.length)}}return e})(u):u)+p+(h?(e=>{var t=br.exec(e);if(!t)return e;var n=t[1];return"\n\n".slice(0,2-n.length)+e})(d):d),g=K.clone(this.props.widgets);g[c]={options:null===(s=n.getEditor(a))||void 0===s?void 0:s.defaultProps,type:a,version:n.getVersion(a)},this.lastUserValue=this.props.content,this.props.onChange({content:m,widgets:g},(function(){r.textarea.moveCursor(i,m.length-d.length)}))})),le(this,"_addWidget",(e=>{var t=this.refs.textarea;this._addWidgetToContent(this.props.content,[t.selectionStart,t.selectionEnd],e),t.focus()})),le(this,"addTemplate",(e=>{var t=e.currentTarget.value;if(""!==t){e.currentTarget.value="";var a,o=this.props.content;if(o=o.replace(/\n*$/,"\n\n"),"table"===t)a="header 1 | header 2 | header 3\n- | - | -\ndata 1 | data 2 | data 3\ndata 4 | data 5 | data 6\ndata 7 | data 8 | data 9";else if("titledTable"===t)a="|| **Table title** ||\nheader 1 | header 2 | header 3\n- | - | -\ndata 1 | data 2 | data 3\ndata 4 | data 5 | data 6\ndata 7 | data 8 | data 9";else if("alignment"===t)a="$\\begin{align} x+5 &= 30 \\\\\nx+5-5 &= 30-5 \\\\\nx &= 25 \\end{align}$";else if("piecewise"===t)a="$f(x) = \\begin{cases}\n7 & \\text{if }x=1 \\\\\nf(x-1)+5 & \\text{if }x > 1\n\\end{cases}$";else{if("allWidgets"!==t)throw new s("Invalid template type: "+t,i.InvalidInput,{metadata:{templateType:t}});a=n.getAllWidgetTypes().map((e=>"[[".concat(r.snowman," ").concat(e," 1]]"))).join("\n\n")}var l=o+a;this.lastUserValue=this.props.content,this.props.onChange({content:l},this.focusAndMoveToEnd)}})),le(this,"getSaveWarnings",(()=>{var e=K.intersection(this.widgetIds,K.keys(this.refs));return K(e).chain().map((e=>{var t=this.refs[e].getSaveWarnings,n=t?t():[];return K.map(n,(t=>e+": "+t))})).flatten(!0).value()})),le(this,"focus",(()=>{var e=ee.findDOMNode(this.refs.textarea);e&&e.focus()})),le(this,"focusAndMoveToEnd",(()=>{this.focus();var e=ee.findDOMNode(this.refs.textarea);e&&(e.selectionStart=e.value.length,e.selectionEnd=e.value.length)})),le(this,"serialize",(e=>{var t={},n=K.intersection(this.widgetIds,K.keys(this.refs));return K.each(n,(e=>{t[e]=this.refs[e].serialize()})),e&&e.keepDeletedWidgets&&K.chain(this.props.widgets).keys().reject((e=>K.contains(n,e))).each((e=>{t[e]=this.props.widgets[e]})),{replace:this.props.replace,content:this.props.content,images:this.props.images,widgets:t}}))}componentDidMount(){this.lastUserValue=null,this._sizeImages(this.props),Q(ee.findDOMNode(this.refs.textarea)).on("copy cut",this._maybeCopyWidgets).on("paste",this._maybePasteWidgets),o.getDependencies().getKaTeX().then((e=>{this.setState({katex:e})}))}UNSAFE_componentWillReceiveProps(e){this.props.content!==e.content&&this.setState({textAreaValue:e.content})}componentDidUpdate(e){var t=ee.findDOMNode(this.refs.textarea);null!==this.lastUserValue&&t&&(t.focus(),t.value=this.lastUserValue,t.selectionStart=0,t.select(0,e.content.length),!1===document.execCommand("insertText",!1,this.props.content)&&(t.value=this.props.content),this.lastUserValue=null),this.props.content!==e.content&&this._sizeImages(this.props)}componentWillUnmount(){clearTimeout(this.deferredChange)}render(){var e,t,n,a,s,i,o,p=[];if(this.props.showWordCount){var h=l.characterCount(this.props.content),u=Math.floor(h/6);o=G.createElement("span",{className:"perseus-editor-word-count",title:"~"+Er(u)+" words ("+Er(h)+" characters)"},Er(u))}var{katex:d}=this.state;if(this.props.widgetEnabled&&d){e=r.split(this.props.content,gr),t={},n=[];for(var m=0;m<e.length;m++)if(m%2==0){n.push(e[m]);var g=l.parse(e[m]);l.traverseContent(g,(e=>{if("math"===e.type||"blockMath"===e.type){var t=c(e.content);try{d.renderToString(t,{colorIsTextColor:!0})}catch(e){p.push({math:t,message:e.message})}}}))}else{var f=r.rWidgetParts.exec(e[m]);if(null!=f){var v=f[1],y=f[2],b=v in t;t[v]=this.getWidgetEditor(v,y);var E=b||!t[v]?"error ":"",w=b?m:v;n.push(G.createElement("b",{className:E,key:w},e[m]))}}this.widgetIds=K.keys(t),a=G.createElement(wr,{ref:"widgetSelect",onChange:this._addWidget});if(s=G.createElement("select",{onChange:this.addTemplate},G.createElement("option",{value:""},"Insert template…"),G.createElement("option",{disabled:!0},"--"),G.createElement("option",{value:"table"},"Table"),G.createElement("option",{value:"titledTable"},"Titled table"),G.createElement("option",{value:"alignment"},"Aligned equations"),G.createElement("option",{value:"piecewise"},"Piecewise function"),G.createElement("option",{disabled:!0},"--"),G.createElement("option",{value:"allWidgets"},"All widgets (for testing)")),!this.props.immutableWidgets){var x=Object.values(t);i=G.createElement("div",{className:"perseus-editor-widgets"},G.createElement("div",{className:"perseus-editor-widgets-selectors"},a,s,o),x),o=null}}else n=[this.props.content];n.push(G.createElement("br",{key:"end"}));var C,k=[G.createElement("div",{className:"perseus-textarea-underlay",ref:"underlay",key:"underlay"},n),G.createElement("textarea",{ref:"textarea",key:"textarea",onChange:this.handleChange,onKeyDown:this._handleKeyDown,placeholder:this.props.placeholder,disabled:this.props.disabled,value:this.state.textAreaValue})];C=this.props.imageUploader?G.createElement(me,{onDrop:this.handleDrop,className:"perseus-textarea-pair"},k):G.createElement("div",{className:"perseus-textarea-pair"},k);var S=0===this.props.content.replace(/\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/g,"").trim().length,N=!/\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/g.test(this.props.content),T={borderTop:"none",padding:4,backgroundColor:"pink"};return G.createElement("div",{className:"perseus-single-editor "+(this.props.className||"")},C,p.length>0&&G.createElement(ge,{errorList:p}),this.props.warnNoPrompt&&S&&G.createElement("div",{style:T},"Graded Groups should contain a prompt"),this.props.warnNoWidgets&&N&&G.createElement("div",{style:T},"Graded Groups should contain at least one widget"),o,i)}}le(Sr,"defaultProps",{content:"",placeholder:"",widgets:{},images:{},disabled:!1,widgetEnabled:!0,immutableWidgets:!1,showWordCount:!1,warnNoPrompt:!1,warnNoWidgets:!1});var Nr=0,Tr={},_r={};window.iframeDataStore={},window.addEventListener("message",(e=>{if("string"==typeof e.data){var t=Tr[e.data];t&&t()}else e.data.id&&(void 0!==e.data.height?_r[e.data.id](e.data.height):e.data.lintWarnings&&a.log("LINTER REPORT",{lintWarnings:JSON.stringify(e.data.lintWarnings)}))}));var Or=Z({displayName:"IframeContentRenderer",propTypes:{content:J.string.isRequired,datasetKey:J.any,datasetValue:J.any,seamless:J.bool},componentDidMount:function(){this._isMounted=!0,this.iframeID=Nr,Nr++,this._prepareFrame(),Tr[this.iframeID]=()=>{this.sendNewData(this._lastData)},_r[this.iframeID]=e=>{this._lastHeight=e,this._isMounted&&this.props.seamless&&(this.refs.container.style.height=e+"px")}},shouldComponentUpdate:function(e){return e.content!==this.props.content||e.datasetValue!==this.props.datasetValue||e.seamless!==this.props.seamless},componentDidUpdate:function(e){this.props.seamless?this.refs.container.style.height=this._lastHeight+"px":this.refs.container.style.height="100%",e.content===this.props.content&&e.datasetValue===this.props.datasetValue||this._prepareFrame()},componentWillUnmount:function(){Tr[this.iframeID]=null,_r[this.iframeID]=null,this._isMounted=!1},_prepareFrame:function(){this._frame&&this.refs.container.removeChild(this._frame),this._frame=document.createElement("iframe"),this._frame.style.width="100%",this._frame.style.height="100%",this.props.datasetKey&&(this._frame.dataset[this.props.datasetKey]=this.props.datasetValue),this._frame.dataset.id=this.iframeID,this.props.seamless&&(this._frame.dataset.lintGutter="true"),this._frame.onload=()=>{this._frame.onload=null,setTimeout((()=>{this._frame.contentWindow.document.open(),this._frame.contentWindow.document.write(this.props.content),this._frame.contentWindow.document.close()}))},this.refs.container.appendChild(this._frame)},sendNewData:function(e){this._isMounted&&e&&this._frame.contentWindow&&(this._lastData=e,window.iframeDataStore[this.iframeID]=e,this._frame.contentWindow.postMessage(this.iframeID,"*"))},render:function(){return G.createElement("div",{ref:"container",style:{width:"100%",height:"100%"}})}}),{HUD:Mr,InlineIcon:Ar}=t,{iconCircleArrowDown:Pr,iconCircleArrowUp:Dr,iconPlus:Ir,iconTrash:Rr}=p;class zr extends G.Component{constructor(){super(...arguments),le(this,"state",{highlightLint:!0}),le(this,"_handleJsonChange",(e=>{this.props.onChange({json:e})})),le(this,"_handleEditorChange",((e,t)=>{var n=K.clone(this._sections());n[e]=K.extend({},n[e],t),this.props.onChange({json:n})}))}componentDidMount(){this._updatePreviewFrames()}componentDidUpdate(){this._updatePreviewFrames()}_updatePreviewFrames(){"preview"===this.props.mode?this.refs["frame-all"].sendNewData({type:"article-all",data:this._sections().map(((e,t)=>this._apiOptionsForSection(e,t)))}):"edit"===this.props.mode&&this._sections().forEach(((e,t)=>{this.refs["frame-"+t].sendNewData({type:"article",data:this._apiOptionsForSection(e,t)})}))}_apiOptionsForSection(e,t){var n=this.refs["editor".concat(t)];return{apiOptions:oe(oe(oe({},u.defaults),this.props.apiOptions),{},{showAlignmentOptions:!0,isArticle:!0}),json:e,useNewStyles:this.props.useNewStyles,linterContext:{contentType:"article",highlightLint:this.state.highlightLint,paths:this.props.contentPaths},legacyPerseusLint:n?n.getSaveWarnings():[]}}_sections(){return Array.isArray(this.props.json)?this.props.json:[this.props.json]}_renderEditor(){var{imageUploader:e,sectionImageUploadGenerator:t}=this.props,n=oe(oe(oe({},u.defaults),this.props.apiOptions),{},{showAlignmentOptions:!0,isArticle:!0}),{KatexProvider:r}=o.getDependencies(),a=this._sections();return G.createElement("div",{className:"perseus-editor-table"},a.map(((s,i)=>[G.createElement("div",{className:"perseus-editor-row",key:i},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("div",{className:"pod-title"},"Section ",i+1,G.createElement("div",{style:{display:"inline-block",float:"right"}},t(i),G.createElement(lr,{icon:Ir,onClick:()=>{this._handleAddSectionAfter(i)},title:"Add a new section after this one"}),i+1<a.length&&G.createElement(lr,{icon:Pr,onClick:()=>{this._handleMoveSectionLater(i)},title:"Move this section down"}),i>0&&G.createElement(lr,{icon:Dr,onClick:()=>{this._handleMoveSectionEarlier(i)},title:"Move this section up"}),G.createElement(lr,{icon:Rr,onClick:()=>{confirm("Are you sure you want to delete section "+(i+1)+"?")&&this._handleRemoveSection(i)},title:"Delete this section"}))),G.createElement(r,null,G.createElement(Sr,ce({},s,{apiOptions:n,imageUploader:e,onChange:K.partial(this._handleEditorChange,i),placeholder:"Type your section text here...",ref:"editor"+i})))),G.createElement("div",{className:"editor-preview"},this._renderIframePreview(i,!0)))])),this._renderAddSection(),this._renderLinterHUD())}_renderAddSection(){return G.createElement("div",{className:"perseus-editor-row"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("a",{href:"#",className:"simple-button orange",onClick:()=>{this._handleAddSectionAfter(this._sections().length-1)}},G.createElement(Ar,Ir)," Add a section")))}_renderLinterHUD(){return G.createElement(Mr,{message:"Style warnings",enabled:this.state.highlightLint,onClick:()=>{this.setState({highlightLint:!this.state.highlightLint})}})}_renderIframePreview(e,t){var n="phone"===this.props.screen||"tablet"===this.props.screen;return G.createElement(ue,{deviceType:this.props.screen,nochrome:t},G.createElement(Or,{ref:"frame-"+e,key:this.props.screen,content:this.props.frameSource,datasetKey:"mobile",datasetValue:n,seamless:t}))}_renderPreviewMode(){return G.createElement("div",{className:"standalone-preview"},this._renderIframePreview("all",!1))}_handleMoveSectionEarlier(e){if(0!==e){var t=K.clone(this._sections()),n=t[e];t.splice(e,1),t.splice(e-1,0,n),this.props.onChange({json:t})}}_handleMoveSectionLater(e){var t=K.clone(this._sections());if(e+1!==t.length){var n=t[e];t.splice(e,1),t.splice(e+1,0,n),this.props.onChange({json:t})}}_handleAddSectionAfter(e){var t=K.clone(this.serialize()),n=e>=0?{widgets:t[e].widgets}:{};t.splice(e+1,0,n),this.props.onChange({json:t})}_handleRemoveSection(e){var t=K.clone(this._sections());t.splice(e,1),this.props.onChange({json:t})}serialize(){if("edit"===this.props.mode)return this._sections().map(((e,t)=>this.refs["editor"+t].serialize()));if("preview"===this.props.mode||"json"===this.props.mode)return this.props.json;throw new s("Could not serialize; mode "+this.props.mode+" not found",i.Internal)}getSaveWarnings(){if("edit"!==this.props.mode)throw new s("Can only get save warnings in edit mode.",i.NotAllowed);return this._sections().map(((e,t)=>this.refs["editor"+t].getSaveWarnings()))}render(){return G.createElement("div",{className:"framework-perseus perseus-article-editor"},"edit"===this.props.mode&&this._renderEditor(),"preview"===this.props.mode&&this._renderPreviewMode(),"json"===this.props.mode&&G.createElement("div",{className:"json-editor"},G.createElement("div",{className:"json-editor-warning"},G.createElement("span",null,"Warning: Editing in this mode can lead to broken articles!")),G.createElement(de,{multiLine:!0,onChange:this._handleJsonChange,value:this.props.json})))}}le(zr,"defaultProps",{contentPaths:[],json:[{}],mode:"edit",screen:"desktop",sectionImageUploadGenerator:()=>G.createElement("span",null),useNewStyles:!1});var{ButtonGroup:Lr,InlineIcon:Fr}=t,{devices:qr}=e,{iconDesktop:Ur,iconMobilePhone:Wr,iconTablet:Vr}=p;class jr extends G.Component{constructor(){super(...arguments),le(this,"handleChange",(e=>{this.props.onViewportSizeChanged(e)}))}render(){var e=G.createElement("span",null,G.createElement(Fr,Wr)," Phone"),t=G.createElement("span",null,G.createElement(Fr,Vr)," Tablet"),n=G.createElement("span",null,G.createElement(Fr,Ur)," Desktop");return G.createElement("span",{className:"viewport-resizer"},"Viewport:"," ",G.createElement(Lr,{value:this.props.deviceType,allowEmpty:!1,buttons:[{value:qr.PHONE,content:e},{value:qr.TABLET,content:t},{value:qr.DESKTOP,content:n}],onChange:this.handleChange}))}}le(jr,"propTypes",{deviceType:J.string.isRequired,onViewportSizeChanged:J.func.isRequired});var Br={exports:{}};!function(e){var t=function(){function e(e){return{newPos:e.newPos,components:e.components.slice(0)}}function t(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}function n(e){var t=e;return t=(t=(t=(t=t.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/"/g,""")}var r=function(e){this.ignoreWhitespace=e};r.prototype={diff:function(t,n){if(n===t)return[{value:n}];if(!n)return[{value:t,removed:!0}];if(!t)return[{value:n,added:!0}];n=this.tokenize(n),t=this.tokenize(t);var r=n.length,a=t.length,s=r+a,i=[{newPos:-1,components:[]}],o=this.extractCommon(i[0],n,t,0);if(i[0].newPos+1>=r&&o+1>=a)return i[0].components;for(var l=1;l<=s;l++)for(var c=-1*l;c<=l;c+=2){var p,h=i[c-1],u=i[c+1];o=(u?u.newPos:0)-c,h&&(i[c-1]=void 0);var d=h&&h.newPos+1<r,m=u&&0<=o&&o<a;if(d||m){!d||m&&h.newPos<u.newPos?(p=e(u),this.pushComponent(p.components,t[o],void 0,!0)):((p=e(h)).newPos++,this.pushComponent(p.components,n[p.newPos],!0,void 0));o=this.extractCommon(p,n,t,c);if(p.newPos+1>=r&&o+1>=a)return p.components;i[c]=p}else i[c]=void 0}},pushComponent:function(e,t,n,r){var a=e[e.length-1];a&&a.added===n&&a.removed===r?e[e.length-1]={value:this.join(a.value,t),added:n,removed:r}:e.push({value:t,added:n,removed:r})},extractCommon:function(e,t,n,r){for(var a=t.length,s=n.length,i=e.newPos,o=i-r;i+1<a&&o+1<s&&this.equals(t[i+1],n[o+1]);)i++,o++,this.pushComponent(e.components,t[i],void 0,void 0);return e.newPos=i,o},equals:function(e,t){var n=/\S/;return!(!this.ignoreWhitespace||n.test(e)||n.test(t))||e===t},join:function(e,t){return e+t},tokenize:function(e){return e}};var a=new r,s=new r(!0),i=new r;s.tokenize=i.tokenize=function(e){return t(e.split(/(\s+|\b)/))};var o=new r(!0);o.tokenize=function(e){return t(e.split(/([{}:;,]|\s+)/))};var l=new r;return l.tokenize=function(e){for(var t=[],n=e.split(/^/m),r=0;r<n.length;r++){var a=n[r],s=n[r-1];"\n"==a&&s&&"\r"===s[s.length-1]?t[t.length-1]+="\n":a&&t.push(a)}return t},{Diff:r,diffChars:function(e,t){return a.diff(e,t)},diffWords:function(e,t){return s.diff(e,t)},diffWordsWithSpace:function(e,t){return i.diff(e,t)},diffLines:function(e,t){return l.diff(e,t)},diffCss:function(e,t){return o.diff(e,t)},createPatch:function(e,t,n,r,a){var s=[];s.push("Index: "+e),s.push("==================================================================="),s.push("--- "+e+(void 0===r?"":"\t"+r)),s.push("+++ "+e+(void 0===a?"":"\t"+a));var i=l.diff(t,n);function o(e){return e.map((function(e){return" "+e}))}function c(e,t,n){var r=i[i.length-2],a=t===i.length-2,s=t===i.length-3&&(n.added!==r.added||n.removed!==r.removed);/\n$/.test(n.value)||!a&&!s||e.push("\")}i[i.length-1].value||i.pop(),i.push({value:"",lines:[]});for(var p=0,h=0,u=[],d=1,m=1,g=0;g<i.length;g++){var f=i[g],v=f.lines||f.value.replace(/\n$/,"").split("\n");if(f.lines=v,f.added||f.removed){if(!p){var y=i[g-1];p=d,h=m,y&&(p-=(u=o(y.lines.slice(-4))).length,h-=u.length)}u.push.apply(u,v.map((function(e){return(f.added?"+":"-")+e}))),c(u,g,f),f.added?m+=v.length:d+=v.length}else{if(p)if(v.length<=8&&g<i.length-2)u.push.apply(u,o(v));else{var b=Math.min(v.length,4);s.push("@@ -"+p+","+(d-p+b)+" +"+h+","+(m-h+b)+" @@"),s.push.apply(s,u),s.push.apply(s,o(v.slice(0,b))),v.length<=4&&c(s,g,f),p=0,h=0,u=[]}d+=v.length,m+=v.length}}return s.join("\n")+"\n"},applyPatch:function(e,t){for(var n=t.split("\n"),r=[],a=!1,s=!1,i="I"===n[0][0]?4:0;i<n.length;i++)if("@"===n[i][0]){var o=n[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);r.unshift({start:o[3],oldlength:o[2],oldlines:[],newlength:o[4],newlines:[]})}else"+"===n[i][0]?r[0].newlines.push(n[i].substr(1)):"-"===n[i][0]?r[0].oldlines.push(n[i].substr(1)):" "===n[i][0]?(r[0].newlines.push(n[i].substr(1)),r[0].oldlines.push(n[i].substr(1))):"\\"===n[i][0]&&("+"===n[i-1][0]?a=!0:"-"===n[i-1][0]&&(s=!0));var l=e.split("\n");for(i=r.length-1;i>=0;i--){for(var c=r[i],p=0;p<c.oldlength;p++)if(l[c.start-1+p]!==c.oldlines[p])return!1;Array.prototype.splice.apply(l,[c.start-1,+c.oldlength].concat(c.newlines))}if(a)for(;!l[l.length-1];)l.pop();else s&&l.push("");return l.join("\n")},convertChangesToXML:function(e){for(var t=[],r=0;r<e.length;r++){var a=e[r];a.added?t.push("<ins>"):a.removed&&t.push("<del>"),t.push(n(a.value)),a.added?t.push("</ins>"):a.removed&&t.push("</del>")}return t.join("")},convertChangesToDMP:function(e){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push([t.added?1:t.removed?-1:0,t.value]);return n}}}();e.exports=t}(Br);var $r=Br.exports,Hr=function(e){return e.added?"added":e.removed?"removed":"unchanged"},Gr=e=>K.map(e.value,(t=>({value:t,status:Hr(e)}))),Yr=new $r.Diff;Yr.tokenize=e=>K.map(e,(e=>[e])),Yr.join=(e,t)=>e.concat(t),Yr.equals=K.isEqual;var Xr=e=>{return t=e,n=Gr,K.flatten(K.map(t,n),!0);var t,n},{SvgImage:Kr}=t,Jr=/http.*?\.png|web\+graphie[^)]*/g,Zr=function(e){return e.match(Jr)||[]},Qr=function(e,t,n){return e.added?t:e.removed?n:""};class ea extends G.Component{render(){return G.createElement("div",null,K.map(this.props.images,((e,t)=>{var n=ae({image:!0,"image-unchanged":"unchanged"===e.status,"image-added":"added"===e.status,"image-removed":"removed"===e.status});return G.createElement("div",{key:t},G.createElement("div",{className:n},G.createElement(Kr,{src:e.value,title:e.value})))})))}}le(ea,"propTypes",{images:J.arrayOf(J.shape({})).isRequired});class ta extends G.Component{constructor(){super(...arguments),le(this,"state",{collapsed:this.props.before===this.props.after}),le(this,"handleExpand",(()=>{this.setState({collapsed:!1})}))}UNSAFE_componentWillReceiveProps(e){this.setState({collapsed:e.before===e.after})}render(){var e=function(e){var t=[],n=[];return K.each(e,(e=>{var r=e.value.split("\n");K.each(r,((r,a)=>{a>0&&(t.push(n),n=[]);var s=K.extend({},e,{value:r});n.push(s)}))})),n.length&&t.push(n),t}($r.diffWords(this.props.before,this.props.after)),t=function(e,t){var n=Yr.diff(e,t),r=Xr(n);return{before:K.filter(r,(e=>"added"!==e.status)),after:K.filter(r,(e=>"removed"!==e.status))}}(Zr(this.props.before),Zr(this.props.after)),n=K.map(e,(e=>{var t={};return t.before=K(e).map((function(e,t){return G.createElement("span",{key:t,className:Qr(e,"not-present","removed dark")},e.value)})),t.after=K(e).map((function(e,t){return G.createElement("span",{key:t,className:Qr(e,"added dark","not-present")},e.value)})),t})),r=ae({"diff-row":!0,collapsed:this.state.collapsed});return G.createElement("div",null,G.createElement("div",{className:"diff-header"},this.props.title),G.createElement("div",{className:"diff-header"},this.props.title),G.createElement("div",{className:"diff-body ui-helper-clearfix"},K.map(["before","after"],((e,r)=>G.createElement("div",{className:"diff-row "+e,key:r},!this.state.collapsed&&K.map(n,((t,n)=>{var r=t[e].length>1,a=ae({"diff-line":!0,added:"after"===e&&r,removed:"before"===e&&r});return G.createElement("div",{className:a,key:n},t[e])})),!this.state.collapsed&&G.createElement(ea,{images:t[e]}))))),K.map(["before","after"],((e,t)=>G.createElement("div",{className:r+" "+e,key:t,onClick:this.handleExpand},this.state.collapsed&&G.createElement("span",null,G.createElement("span",{className:"expand-button"}," ","[ show unmodified ]"," "))))))}}le(ta,"propTypes",{after:J.string,before:J.string,title:J.string.isRequired}),le(ta,"defaultProps",{after:"",before:""});var na=function(e,t,n){var r,a=K.isObject(e)?K(e).keys():[],s=K.isObject(t)?K(t).keys():[],i=K.union(a,s),o=K.map(i,(function(n){return ra((e||{})[n],(t||{})[n],n)}));if(void 0===e)r="added";else if(void 0===t)r="removed";else{r=K.any(o,(function(e){return"unchanged"!==e.status}))?"changed":"unchanged"}return{after:"",before:"",children:o,key:n,status:r}},ra=function(e,t,n){return"object"==typeof e||"object"==typeof t?na(e,t,n):function(e,t,n){var r;return r=e===t?"unchanged":void 0===e?"added":void 0===t?"removed":"changed",{after:JSON.stringify(t),before:JSON.stringify(e),children:[],key:n,status:r}}(e,t,n)},{SvgImage:aa}=t,sa=function(e){return 20*(e-1)};class ia extends G.Component{render(){var e=ae(this.props.className,{"diff-row":!0,before:"before"===this.props.side,after:"after"===this.props.side});return G.createElement("div",{className:e},G.createElement("div",{style:{paddingLeft:sa(this.props.depth)}},this.props.showKey&&this.props.propKey+": ",G.createElement("span",{className:"inner-value dark "+this.props.className},this.props.value)))}}le(ia,"propTypes",{className:J.string.isRequired,depth:J.number.isRequired,propKey:J.string.isRequired,showKey:J.bool.isRequired,side:J.oneOf(["before","after"]).isRequired,value:J.string});class oa extends G.Component{render(){var e=this;return G.createElement("div",{onClick:e.props.onClick,style:{clear:"both"}},K.map(["before","after"],(function(t){return G.createElement("div",{className:"diff-row collapsed "+t,key:t},G.createElement("div",{style:{paddingLeft:sa(e.props.depth)}},G.createElement("span",null," [ show unmodified ] ")))})))}}le(oa,"propTypes",{depth:J.number,onClick:J.func.isRequired}),le(oa,"defaultProps",{depth:0});class la extends G.Component{constructor(){super(...arguments),le(this,"state",{expanded:this.props.expanded}),le(this,"expand",(()=>{this.setState({expanded:!0})}))}render(){var e,t=this.props.entry,n="removed"===t.status,r="added"===t.status,a="changed"===t.status,s=t.children.length>0,i=ae({removed:n||a&&!s,dark:n,"blank-space":r}),o=ae({added:r||a&&!s,dark:r,"blank-space":n}),l=(e=this.state.expanded?t.children:K(t.children).select((function(e){return"unchanged"!==e.status}))).length<t.children.length;t.children.length===e.length+1&&(e=t.children,l=!1);var c=this;return G.createElement("div",null,t.key&&G.createElement("div",{style:{clear:"both"}},G.createElement(ia,{side:"before",className:i,depth:this.props.depth,propKey:t.key,showKey:!r,value:t.before}),G.createElement(ia,{side:"after",className:o,depth:this.props.depth,propKey:t.key,showKey:!n,value:t.after})),K.map(e,(function(e){return G.createElement(la,{key:e.key,depth:c.props.depth+1,entry:e,expanded:c.state.expanded})})),l&&G.createElement(oa,{depth:this.props.depth+1,onClick:this.expand}))}}le(la,"propTypes",{depth:J.number,entry:J.shape({after:J.string,before:J.string,children:J.arrayOf(J.any),key:J.string}),expanded:J.bool}),le(la,"defaultProps",{depth:0});class ca extends G.Component{render(){var{before:e,after:t}=this.props,n=e.options&&e.options.backgroundImage?e.options.backgroundImage.url:"",r=t.options&&t.options.backgroundImage?t.options.backgroundImage.url:"";return G.createElement("div",null,G.createElement("div",{className:"diff-row before"},n&&G.createElement("div",{className:ae({image:!0,"image-unchanged":n===r,"image-removed":n!==r})},G.createElement(aa,{src:n,title:n}))),G.createElement("div",{className:"diff-row after"},r&&G.createElement("div",{className:ae({image:!0,"image-unchanged":n===r,"image-added":n!==r})},G.createElement(aa,{src:r,title:r}))))}}le(ca,"propTypes",{after:J.shape({options:J.objectOf(J.any)}).isRequired,before:J.shape({options:J.objectOf(J.any)}).isRequired});class pa extends G.Component{render(){var{after:e,before:t,title:n,type:r}=this.props,a=ra(t,e);return G.createElement("div",null,G.createElement("div",{className:"diff-header"},n),G.createElement("div",{className:"diff-header"},n),G.createElement("div",{className:"diff-body ui-helper-clearfix"},"image"===r&&G.createElement(ca,{before:t,after:e}),G.createElement(la,{entry:a})))}}le(pa,"propTypes",{after:J.shape({options:J.objectOf(J.any)}),before:J.shape({options:J.objectOf(J.any)}),title:J.string.isRequired,type:J.string}),le(pa,"defaultProps",{after:{},before:{},type:""});var ha=function(e,t){var r,{alignment:a,graded:s,options:i,type:o}=e||{},l={options:i};(t&&n.getSupportedAlignments(o).length>1&&(l.alignment=a),"transformer"===o&&(l.graded=s),n.supportsStaticMode(o))&&(l.static=null!==(r=null==e?void 0:e.static)&&void 0!==r?r:void 0);return l};class ua extends G.Component{render(){var e,t,n,r,{after:a,before:s,showAlignmentOptions:i,showSeparator:o,title:l}=this.props;(s.content||a.content)&&(n=G.createElement(ta,{before:s.content,after:a.content,title:l}));var c=Object.keys(null!==(e=s.widgets)&&void 0!==e?e:{}).filter((e=>s.content.includes(e))),p=Object.keys(null!==(t=a.widgets)&&void 0!==t?t:{}).filter((e=>a.content.includes(e)));(c.length||p.length)&&(r=K.union(c,p).map((e=>{var t,n,r,o,l,c;return G.createElement(pa,{before:ha(null===(t=s.widgets)||void 0===t?void 0:t[e],i),after:ha(null===(n=a.widgets)||void 0===n?void 0:n[e],i),title:e,type:(null!==(r=null===(o=s.widgets)||void 0===o?void 0:o[e])&&void 0!==r?r:{}).type||(null!==(l=null===(c=a.widgets)||void 0===c?void 0:c[e])&&void 0!==l?l:{}).type,key:e})})));return G.createElement("div",null,n,r,o&&G.createElement("div",{className:"diff-separator"}))}}le(ua,"defaultProps",{after:{content:"",images:{},widgets:{}},before:{content:"",images:{},widgets:{}},showAlignmentOptions:!1,showSeparator:!1});var da=J.shape({content:J.string,images:J.objectOf(J.any),widgets:J.objectOf(J.any)});class ma extends G.Component{constructor(){super(...arguments),le(this,"state",ma._stateFromProps(this.props))}UNSAFE_componentWillReceiveProps(e){this.setState(ma._stateFromProps(e))}render(){var{before:e,after:t}=this.state,n=Math.max(e.length,t.length),r=K.times(n,(r=>G.createElement(ua,{before:r<e.length?e[r]:void 0,after:r<t.length?t[r]:void 0,title:"Section ".concat(r+1),showAlignmentOptions:!0,showSeparator:r<n-1,key:r})));return G.createElement("div",{className:"framework-perseus"},r)}}le(ma,"propTypes",{after:J.oneOfType([da,J.arrayOf(da)]).isRequired,before:J.oneOfType([da,J.arrayOf(da)]).isRequired}),le(ma,"_stateFromProps",(e=>{var{before:t,after:n}=e;return{before:Array.isArray(t)?t:[t],after:Array.isArray(n)?n:[n]}}));var ga=J.shape({question:J.shape({}).isRequired,answerArea:J.shape({}).isRequired,hints:J.arrayOf(J.any).isRequired});class fa extends G.Component{render(){var{before:e,after:t}=this.props,n=Math.max(e.hints.length,t.hints.length),r=G.createElement(ua,{before:e.question,after:t.question,title:"Question",showAlignmentOptions:!1,showSeparator:!0}),a=G.createElement(pa,{before:e.answerArea,after:t.answerArea,title:"Question extras"}),s=K.times(n,(function(r){return G.createElement(ua,{before:r<e.hints.length?e.hints[r]:void 0,after:r<t.hints.length?t.hints[r]:void 0,title:"Hint ".concat(r+1),showAlignmentOptions:!1,showSeparator:r<n-1,key:r})}));return G.createElement("div",{className:"framework-perseus"},r,a,s&&G.createElement("div",{className:"diff-separator"}),s)}}le(fa,"propTypes",{after:ga.isRequired,before:ga.isRequired});class va extends G.Component{render(){var{afterOnly:e,beforeOnly:t,intersection:n,showSeparator:r}=this.props,a=n.concat(t).join("\n")+"\n",s=n.concat(e).join("\n")+"\n";return G.createElement("div",null,G.createElement(ta,{before:a,after:s,title:this.props.title}),r&&G.createElement("div",{className:"diff-separator"}))}}function ya(e,t){for(var n=!0,r=0;r<t.length;r++){if(r>=e.length)return!1;t[r]!==e[r]&&(n=!1)}return n}function ba(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}le(va,"defaultProps",{afterOnly:[],beforeOnly:[],showSeparator:!1,title:"Question tags"});class Ea extends G.Component{static generateCompletePathsList(e,t,n,r,a){if("content"===r.type||"hint"===r.type||"tags"===r.type){var s=e.length>0&&ba(a,e[0][1]),i=t.length>0&&ba(a,t[0][1]);s&&i?(n.push(a),e.splice(0,1),t.splice(0,1)):s?(n.push(a),e.splice(0,1)):i&&(n.push(a),t.splice(0,1))}else if("array"===r.type)for(var o=0,l=a.concat(o);e.length>0&&ya(e[0][1],l)||t.length>0&&ya(t[0][1],l);)Ea.generateCompletePathsList(e,t,n,r.elementShape,l),o++,l=a.concat(o);else if("object"===r.type)for(var c=Object.keys(r.shape),p=0;p<c.length;p++){var h=a.concat([c[p]]);Ea.generateCompletePathsList(e,t,n,r.shape[c[p]],h)}}render(){var{before:e,after:t,shape:n,tags:r}=this.props,a=[],s=[];d().setContentMapper(((e,t,n)=>a.push([e,n]))).setHintMapper(((e,t,n)=>a.push([e,n]))).setTagsMapper(((e,t,n)=>a.push([e,n]))).mapTree(m(e),n),d().setContentMapper(((e,t,n)=>s.push([e,n]))).setHintMapper(((e,t,n)=>s.push([e,n]))).setTagsMapper(((e,t,n)=>s.push([e,n]))).mapTree(m(t),n);var i=a.slice(),o=s.slice(),l=[];Ea.generateCompletePathsList(i,o,l,n,[]);var c=l.length,p=l.map(((e,t)=>{var n="tags"===e[e.length-1],i=function(e){for(var t=[],n=0;n<e.length;n++)"number"==typeof e[n]?t.push((e[n]+1).toString()+":"):t.push(e[n]);return t.join(" ")}(e),o=a.find((t=>ba(t[1],e))),l=s.find((t=>ba(t[1],e)));if(n){o||(o=[[],e]),l||(l=[[],e]);var p=[];Array.isArray(o[0])&&o[0].forEach((e=>{"string"==typeof e&&p.push(r.idToName(e))}));var h=[];Array.isArray(l[0])&&l[0].forEach((e=>{"string"==typeof e&&h.push(r.idToName(e))}));var u=p.filter((e=>h.includes(e))),d=p.filter((e=>!h.includes(e))),m=h.filter((e=>!p.includes(e)));return G.createElement(va,{beforeOnly:d,afterOnly:m,intersection:u,title:i,showSeparator:t<c-1,key:t})}return o||(o=[g(f.content),e]),l||(l=[g(f.content),e]),G.createElement(ua,{before:o[0],after:l[0],title:i,showAlignmentOptions:!1,showSeparator:t<c-1,key:t})}));return G.createElement("div",{className:"framework-perseus"},p)}}var{InfoTip:wa,InlineIcon:xa}=t,{iconCircleArrowDown:Ca,iconCircleArrowUp:ka,iconPlus:Sa,iconTrash:Na}=p;class Ta extends G.Component{constructor(){super(...arguments),le(this,"handleChange",(e=>{this.props.onChange({replace:e.target.checked})})),le(this,"focus",(()=>{this.refs.editor.focus()})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(e=>this.refs.editor.serialize(e)))}render(){return G.createElement("div",{className:"perseus-hint-editor "+this.props.className},this.props.showTitle&&G.createElement("div",{className:"pod-title"},"Hint"),G.createElement(Sr,{ref:"editor",key:this.props.itemId,apiOptions:this.props.apiOptions,widgets:this.props.widgets||void 0,content:this.props.content||void 0,images:this.props.images,replace:this.props.replace,placeholder:"Type your hint here...",imageUploader:this.props.imageUploader,onChange:this.props.onChange}),G.createElement("div",{className:"hint-controls-container clearfix"},this.props.showMoveButtons&&G.createElement("span",{className:"reorder-hints"},G.createElement("button",{type:"button",className:this.props.isLast?"hidden":"",onClick:K.partial(this.props.onMove,1)},G.createElement(xa,Ca))," ",G.createElement("button",{type:"button",className:this.props.isFirst?"hidden":"",onClick:K.partial(this.props.onMove,-1)},G.createElement(xa,ka))," ",this.props.isLast&&G.createElement(wa,null,G.createElement("p",null,"The last hint is automatically bolded."))),G.createElement("input",{type:"checkbox",checked:this.props.replace,onChange:this.handleChange}),"Replace previous hint",this.props.showRemoveButton&&G.createElement("button",{type:"button",className:"remove-hint simple-button orange",onClick:this.props.onRemove},G.createElement(xa,Na),"Remove this hint"," ")))}}le(Ta,"defaultProps",{className:"",content:"",replace:!1,showMoveButtons:!0,showTitle:!0,showRemoveButton:!0});class _a extends G.Component{constructor(){super(...arguments),le(this,"updatePreview",(()=>{var e=this.props.isLast&&!/\*\*/.test(this.props.hint.content);this.refs.frame.sendNewData({type:"hint",data:{hint:this.props.hint,bold:e,pos:this.props.pos,apiOptions:this.props.apiOptions,linterContext:{contentType:"hint",highlightLint:this.props.highlightLint,paths:this.props.contentPaths}}})})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(e=>this.refs.editor.serialize(e))),le(this,"focus",(()=>{this.refs.editor.focus()}))}componentDidMount(){this.updatePreview()}componentDidUpdate(){this.updatePreview()}render(){var e="phone"===this.props.deviceType||"tablet"===this.props.deviceType;return G.createElement("div",{className:"perseus-combined-hint-editor perseus-editor-row"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement(Ta,{ref:"editor",itemId:this.props.itemId,isFirst:this.props.isFirst,isLast:this.props.isLast,widgets:this.props.hint.widgets,content:this.props.hint.content,images:this.props.hint.images,replace:this.props.hint.replace,imageUploader:this.props.imageUploader,onChange:this.props.onChange,onRemove:this.props.onRemove,onMove:this.props.onMove,apiOptions:this.props.apiOptions})),G.createElement("div",{className:"perseus-editor-right-cell"},G.createElement(ue,{deviceType:this.props.deviceType,nochrome:!0},G.createElement(Or,{ref:"frame",content:this.props.frameSource,datasetKey:"mobile",datasetValue:e,seamless:!0}))))}}le(_a,"defaultProps",{highlightLint:!1});class Oa extends G.Component{constructor(){super(...arguments),le(this,"handleHintChange",((e,t,n,r)=>{var a=K(this.props.hints).clone();a[e]=K.extend({},this.serializeHint(e,{keepDeletedWidgets:!0}),t),this.props.onChange({hints:a},n,r)})),le(this,"handleHintRemove",(e=>{var t=K(this.props.hints).clone();t.splice(e,1),this.props.onChange({hints:t})})),le(this,"handleHintMove",((e,t)=>{var n=K(this.props.hints).clone(),r=n.splice(e,1)[0];n.splice(e+t,0,r),this.props.onChange({hints:n},(()=>{this.refs["hintEditor"+(e+t)].focus()}))})),le(this,"addHint",(()=>{var e=K(this.props.hints).clone().concat([{content:""}]);this.props.onChange({hints:e},(()=>{var t=e.length-1;this.refs["hintEditor"+t].focus()}))})),le(this,"getSaveWarnings",(()=>K.chain(this.props.hints).map(((e,t)=>K.map(this.refs["hintEditor"+t].getSaveWarnings(),(e=>"Hint "+(t+1)+": "+e)))).flatten(!0).value())),le(this,"serialize",(e=>this.props.hints.map(((t,n)=>this.serializeHint(n,e))))),le(this,"serializeHint",((e,t)=>this.refs["hintEditor"+e].serialize(t)))}render(){var{itemId:e,hints:t}=this.props,n=K.map(t,(function(n,r){return G.createElement(_a,{ref:"hintEditor"+r,key:"hintEditor"+r,isFirst:0===r,isLast:r+1===t.length,itemId:e,hint:n,pos:r,imageUploader:this.props.imageUploader,onChange:this.handleHintChange.bind(this,r),onRemove:this.handleHintRemove.bind(this,r),onMove:this.handleHintMove.bind(this,r),deviceType:this.props.deviceType,apiOptions:this.props.apiOptions,frameSource:this.props.frameSource,highlightLint:this.props.highlightLint,contentPaths:[]})}),this);return G.createElement("div",{className:"perseus-hints-editor perseus-editor-table"},n,G.createElement("div",{className:"perseus-editor-row"},G.createElement("div",{className:"add-hint-container perseus-editor-left-cell"},G.createElement("button",{type:"button",className:"add-hint simple-button orange",onClick:this.addHint},G.createElement(xa,Sa)," Add a hint"))))}}le(Oa,"HintEditor",Ta),le(Oa,"defaultProps",{onChange:()=>{},hints:[],highlightLint:!1});var{InfoTip:Ma}=t;class Aa extends G.Component{constructor(){super(...arguments),le(this,"serialize",(()=>({calculator:this.props.calculator,chi2Table:this.props.chi2Table,periodicTable:this.props.periodicTable,tTable:this.props.tTable,zTable:this.props.zTable})))}render(){return G.createElement("div",{className:"perseus-answer-editor"},G.createElement("div",{className:"perseus-answer-options"},G.createElement("div",null,G.createElement("label",null,"Show calculator:"," ",G.createElement("input",{type:"checkbox",checked:this.props.calculator,onChange:e=>{this.props.onChange({calculator:e.target.checked})}})),G.createElement(Ma,null,"Use the calculator when completing difficult calculations is NOT the intent of the question. DON’T use the calculator when testing the student’s ability to complete different types of computations.")),G.createElement("div",null,G.createElement("label",null,"Show periodic table:"," ",G.createElement("input",{type:"checkbox",checked:this.props.periodicTable,onChange:e=>{this.props.onChange({periodicTable:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions.")),G.createElement("div",null,G.createElement("label",null,"Show z table (statistics):"," ",G.createElement("input",{type:"checkbox",checked:this.props.zTable,onChange:e=>{this.props.onChange({zTable:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a table of critical values for the z distribution, e.g. for answering statistics questions.")),G.createElement("div",null,G.createElement("label",null,"Show t table (statistics):"," ",G.createElement("input",{type:"checkbox",checked:this.props.tTable,onChange:e=>{this.props.onChange({tTable:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a table of critical values for the Student's t distribution, e.g. for answering statistics questions.")),G.createElement("div",null,G.createElement("label",null,"Show chi-squared table (statistics):"," ",G.createElement("input",{type:"checkbox",checked:this.props.chi2Table,onChange:e=>{this.props.onChange({chi2Table:e.target.checked})}})),G.createElement(Ma,null,"This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions."))))}}le(Aa,"propTypes",{calculator:J.bool,chi2Table:J.bool,onChange:J.func.isRequired,periodicTable:J.bool,tTable:J.bool,zTable:J.bool}),le(Aa,"defaultProps",{calculator:!1,chi2Table:!1,periodicTable:!1,tTable:!1,zTable:!1});var Pa=v;class Da extends G.Component{constructor(){super(...arguments),le(this,"updateProps",((e,t,n)=>{var r=K(this.props).pick("question","answerArea");this.props.onChange(K(r).extend(e),t,n)})),le(this,"triggerPreviewUpdate",(e=>{this.refs.frame.sendNewData(e)})),le(this,"handleEditorChange",((e,t,n)=>{var r=K.extend({},this.props.question,e);this.updateProps({question:r},t,n)})),le(this,"handleItemExtrasChange",((e,t,n)=>{var r=K.extend({},this.props.answerArea,e);this.updateProps({answerArea:r},t,n)})),le(this,"getSaveWarnings",(()=>this.refs.questionEditor.getSaveWarnings())),le(this,"serialize",(e=>({question:this.refs.questionEditor.serialize(e),answerArea:this.refs.itemExtrasEditor.serialize(e),itemDataVersion:Pa})))}render(){var e="phone"===this.props.deviceType||"tablet"===this.props.deviceType;return G.createElement("div",{className:"perseus-editor-table"},G.createElement("div",{className:"perseus-editor-row perseus-question-container"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("div",{className:"pod-title"},"Question"),G.createElement(Sr,ce({ref:"questionEditor",key:this.props.itemId,placeholder:"Type your question here...",className:"perseus-question-editor",imageUploader:this.props.imageUploader,onChange:this.handleEditorChange,apiOptions:this.props.apiOptions,showWordCount:!0},this.props.question))),G.createElement("div",{className:"perseus-editor-right-cell"},G.createElement("div",{id:"problemarea"},G.createElement(ue,{deviceType:this.props.deviceType,nochrome:!0},G.createElement(Or,{ref:"frame",key:this.props.deviceType,content:this.props.frameSource,datasetKey:"mobile",datasetValue:e,seamless:!0})),G.createElement("div",{id:"hintsarea",className:"hintsarea",style:{display:"none"}})))),G.createElement("div",{className:"perseus-editor-row perseus-answer-container"},G.createElement("div",{className:"perseus-editor-left-cell"},G.createElement("div",{className:"pod-title"},"Question extras"),G.createElement(Aa,ce({ref:"itemExtrasEditor",onChange:this.handleItemExtrasChange},this.props.answerArea))),G.createElement("div",{className:"perseus-editor-right-cell"},G.createElement("div",{id:"answer_area"}))))}}le(Da,"defaultProps",{onChange:()=>{},question:{},answerArea:{}});var{HUD:Ia}=t;class Ra extends G.Component{constructor(e){super(e),le(this,"_isMounted",void 0),le(this,"rendererMountNode",void 0),le(this,"renderer",void 0),le(this,"toggleJsonMode",(()=>{this.setState({json:this.serialize({keepDeletedWidgets:!0})},(()=>{this.props.onChange({jsonMode:!this.props.jsonMode})}))})),le(this,"handleChange",((e,t,n)=>{var r=K(this.props).pick("question","hints","answerArea");K(r).extend(e),this.props.onChange(r,t,n)})),le(this,"changeJSON",(e=>{this.setState({json:e}),this.props.onChange(e)})),this.state={json:K.pick(this.props,"question","answerArea","hints","itemDataVersion"),gradeMessage:"",wasAnswered:!1,highlightLint:!0},this._isMounted=!1}componentDidMount(){this._isMounted=!0,this.rendererMountNode=document.createElement("div"),this.updateRenderer()}componentDidUpdate(){setTimeout((()=>{this.updateRenderer()}))}componentWillUnmount(){this._isMounted=!1}updateRenderer(){var e=!this.props.developerMode||!this.props.jsonMode;if(this._isMounted&&e){var t="phone"===this.props.previewDevice||"tablet"===this.props.previewDevice,n=oe(oe({},this.getApiOptions()),{},{customKeypad:t,isMobile:t});this.refs.itemEditor.triggerPreviewUpdate({type:"question",data:K({item:this.serialize(),apiOptions:n,initialHintsVisible:0,device:this.props.previewDevice,linterContext:{contentType:"exercise",highlightLint:this.state.highlightLint,paths:this.props.contentPaths||[]},reviewMode:!0,legacyPerseusLint:this.refs.itemEditor.getSaveWarnings()}).extend(K(this.props).pick("workAreaSelector","solutionAreaSelector","hintsAreaSelector","problemNum"))})}}getApiOptions(){return oe(oe({},u.defaults),this.props.apiOptions)}getSaveWarnings(){var e=this.refs.itemEditor.getSaveWarnings(),t=this.refs.hintsEditor.getSaveWarnings();return e.concat(t)}serialize(e){return this.props.jsonMode?this.state.json:K.extend(this.refs.itemEditor.serialize(e),{hints:this.refs.hintsEditor.serialize(e)})}scorePreview(){return this.renderer?this.renderer.scoreInput():null}render(){var e="framework-perseus",t="phone"===this.props.previewDevice||"tablet"===this.props.previewDevice,n=oe(oe({},this.getApiOptions()),{},{customKeypad:t,isMobile:t});return n.isMobile&&(e+=" "+y.MOBILE),G.createElement("div",{id:"perseus",className:e},G.createElement("div",{style:{marginBottom:10}},this.props.developerMode&&G.createElement("span",null,G.createElement("label",null," ","Developer JSON Mode:"," ",G.createElement("input",{type:"checkbox",checked:this.props.jsonMode,onChange:this.toggleJsonMode}))," "),!this.props.jsonMode&&G.createElement(jr,{deviceType:this.props.previewDevice,onViewportSizeChanged:this.props.onPreviewDeviceChange}),!this.props.jsonMode&&G.createElement(Ia,{message:"Style warnings",enabled:this.state.highlightLint,onClick:()=>{this.setState({highlightLint:!this.state.highlightLint})}})),this.props.developerMode&&this.props.jsonMode&&G.createElement("div",null,G.createElement(de,{multiLine:!0,value:this.state.json,onChange:this.changeJSON})),(!this.props.developerMode||!this.props.jsonMode)&&G.createElement(Da,{ref:"itemEditor",itemId:this.props.itemId,question:this.props.question,answerArea:this.props.answerArea,imageUploader:this.props.imageUploader,onChange:this.handleChange,wasAnswered:this.state.wasAnswered,gradeMessage:this.state.gradeMessage,deviceType:this.props.previewDevice,apiOptions:n,frameSource:this.props.frameSource}),(!this.props.developerMode||!this.props.jsonMode)&&G.createElement(Oa,{ref:"hintsEditor",itemId:this.props.itemId,hints:this.props.hints,imageUploader:this.props.imageUploader,onChange:this.handleChange,deviceType:this.props.previewDevice,apiOptions:n,frameSource:this.props.frameSource,highlightLint:this.state.highlightLint}))}}le(Ra,"defaultProps",{developerMode:!1,jsonMode:!1,onChange:()=>{}});var{findContentNodesInItem:za,findHintNodesInItem:La,inferItemShape:Fa}=b;function qa(e,t){var n=l.parse(e);l.traverseContent(n,(function(e){"image"===e.type&&t.push(e.target)}))}function Ua(e,t){e&&e.backgroundImage&&e.backgroundImage.url&&t.push(e.backgroundImage.url)}function Wa(e){var t=[];return K.each(e,(e=>{E(e,(e=>{qa(e,t)}),(e=>function(e,t){e.options&&("categorizer"===e.type?(K.each(e.options.items,(function(e){qa(e,t)})),K.each(e.options.categories,(function(e){qa(e,t)}))):"image"===e.type?(qa(e.options.title,t),qa(e.options.caption,t)):"matcher"===e.type?(K.each(e.options.left,(function(e){qa(e,t)})),K.each(e.options.right,(function(e){qa(e,t)})),K.each(e.options.labels,(function(e){qa(e,t)}))):"matrix"===e.type?(qa(e.options.prefix,t),qa(e.options.suffix,t)):"orderer"===e.type?K.each(e.options.options,(function(e){qa(e.content,t)})):"passage"===e.type?qa(e.options.passageTitle,t):"radio"===e.type?K.each(e.options.choices,(function(e){qa(e.content,t)})):"sorter"===e.type?K.each(e.options.correct,(function(e){qa(e,t)})):"table"===e.type&&K.each(e.options.headers,(function(e){qa(e,t)})),"grapher"===e.type?Ua(e.options.graph,t):"image"===e.type||"interactive-graph"===e.type?Ua(e.options,t):"measurer"===e.type&&e.options.image?t.push(e.options.image.url):"plotter"===e.type?t.push(e.options.picUrl):"transformer"===e.type&&Ua(e.options.graph,t))}(e,t)))})),t}var Va,ja={findImagesInArticles:function(e){return Wa(e)},findImagesInItemData:function(e){var t=[];if(e._multi){var n=Fa(e);za(e,n,(e=>t.push(e))),La(e,n,(e=>t.push(e)))}else t=[e.question,...e.hints];return Wa(t)}},Ba={exports:{}};Va=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},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)},r=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var r in n)e[r]=n[r]}return e};e.exports={isObject:n,merge:r,clone:function(e){return n(e)?Array.isArray(e)?e.slice():r(e):e}}},function(e,t,n){var r=n(0),a=r.clone,s=r.isObject,i=r.merge,o=n(2),l=n(3),c=n(4),p=function(e){return Array.isArray(e)?o:s(e)?l:"string"==typeof e?c:void 0},h=function e(t){if(t instanceof e)return t;if(!(this instanceof e))return new e(t);var n=p(t);this._wrapped=n.thaw?n.thaw(t):t};h.prototype.freeze=function(){var e=this._wrapped,t=p(e);return t.freeze?t.freeze(e):e},h.prototype.zoom=function(e){return void 0===this._zoomStack&&(this._zoomStack=[]),this._zoomStack.push({zoom:e,wrapped:this._wrapped}),this._wrapped=h(this._wrapped).get(e),this},h.prototype.deZoom=function(){var e=this._zoomStack.pop();return this._wrapped=h(e.wrapped).set(e.zoom,this._wrapped).freeze(),this},h.prototype.get=function(e){for(var t=this._wrapped,n=0;n<e.length;n++)t=p(t).get(t,e[n]);return t},h.prototype.mod=function(e,t){var n=this._wrapped,r=a(n),s=p(n);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=s.mod(r,e[0],t);else{var i=e[0],o=e.slice(1);r[i]=h(n[i]).mod(o,t).freeze(),this._wrapped=r}return this},h.prototype.merge=function(e,t){return this._wrapped=h(this._wrapped).mod(e,(function(e){return i(e,t)})).freeze(),this},h.prototype.del=function(e){var t=this._wrapped,n=p(t);if(1===e.length)this._wrapped=n.del(t,e[0]);else{var r=e[0],s=e.slice(1),i=a(t);i[r]=h(t[r]).del(s).freeze(),this._wrapped=i}return this},h.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=h},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var r=e.splice();return r[t]=n,r},mod:function(e,t,n){var r=e.slice();return r[t]=n(e[t]),r},del:function(e,t){var n=e.slice();return n.splice(t,1),n}}},function(e,t,n){var r=n(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var a=r(e);return a[t]=n,a},mod:function(e,t,n){var a=r(e);return a[t]=n(e[t]),a},del:function(e,t){var n=r(e);return delete n[t],n}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var r=e.splice();return r[t]=n,r},mod:function(e,t,n){var r=e.splice();return r[t]=n(e[t]),r},del:function(e,t){var n=e.slice();return n.splice(t),n}}}])};var $a=Ke(Ba.exports=Va()),Ha=["children","color","onClick"];class Ga extends G.Component{render(){var e=this.props,{children:t,color:n,onClick:r}=e,a=pe(e,Ha);return G.createElement("div",ce({className:re(Ya.baseButton,"green"===n&&Ya.green,"orange"===n&&Ya.orange),onClick:r},a),t)}}le(Ga,"propTypes",{children:J.node,color:J.oneOf(["orange","green"]),onClick:J.func}),le(Ga,"defaultProps",{children:null,color:"green",onClick:()=>{}});var Ya=ne.create({baseButton:{top:"0",fontSize:"11px",padding:"3px 10px",backgroundRepeat:"repeat-x",borderColor:"\n rgba(0, 0, 0, 0.1)\n rgba(0, 0, 0, 0.1)\n rgba(0, 0, 0, 0.25)\n ",color:"#ffffff",borderRadius:"3px",lineHeight:"15px",cursor:"pointer",transition:"box-shadow ease-in-out 0.15s",appearance:"none",textDecoration:"none",textAlign:"center",":hover":{boxShadow:"0 1px 1px rgba(0, 0, 0, 0.35),\n inset 0 0 50px 5px rgba(255, 255, 255, 0.2)"}},green:{border:"1px solid #7fab07",backgroundColor:"#80ac07",backgroundImage:"linear-gradient(to bottom, #8aba08, #719807)",":hover":{borderBottomColor:"#547105",backgroundColor:"#719807"}},orange:{border:"1px solid #d45704",backgroundColor:"#d55704",backgroundImage:"linear-gradient(to bottom, #e35d04, #c04f03)",":hover":{borderBottomColor:"#983e03",backgroundColor:"#c04f03"}}}),Xa=["depth"],Ka=["shape","data","path","actions","name","controls"],Ja=["shape","data"],Za=["shape","data","path","actions"],Qa=["shape","data","path"],{InlineIcon:es}=t,{iconChevronDown:ts,iconTrash:ns}=p,{MultiRenderer:rs}=b;class as extends G.Component{constructor(){super(...arguments),le(this,"_handleSelectMode",(e=>{if(this.props.onChange){var t=e.target.value;this.props.onChange(t)}}))}render(){return G.createElement("label",null,"Mode:"," ",G.createElement("select",{value:this.props.currentMode,onChange:this._handleSelectMode},G.createElement("option",{value:"edit"},"Edit"),G.createElement("option",{value:"preview"},"Preview"),G.createElement("option",{value:"json"},"Dev-only JSON")))}}function ss(e){return e.replace(/[A-Z]/g,(e=>" "+e.toLowerCase()))}function is(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function os(e){return"s"===e.charAt(e.length-1)?e.slice(0,-1):e}function ls(e){return["_multi",...e]}var cs=e=>{var{depth:t}=e,n=pe(e,Xa),r=Math.min(t,5)+1,a="h".concat(r);return G.createElement(a,n)},ps=e=>{var{shape:t,data:n,path:r,actions:a,name:s,controls:i}=e,o=pe(e,Ka),l=s||ss(r[r.length-1]||""),c=G.createElement(ms,ce({},o,{shape:t,data:n,path:r,actions:a})),p=r.join(".");return"array"===t.type?G.createElement(us,{key:p,name:l,controls:i,path:r,shape:t,actions:a},c):"object"===t.type?G.createElement(ds,{key:p,name:l,controls:i,path:r},c):G.createElement(hs,{key:p,name:l,controls:i,path:r,shape:t},c)},hs=e=>{var{name:t,controls:n,children:r,path:a,shape:s}=e,i=("content"===s.type||"hint"===s.type)&&G.createElement("div",{className:re(xs.containerHeader)},G.createElement(cs,{depth:a.length,className:re(xs.containerTitle)},is(t)));return G.createElement("div",{className:re(xs.container)},G.createElement("span",{className:re(xs.row,xs.rowHeading)},G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:"pod-title "+re(xs.containerHeader)},G.createElement("div",{className:re(xs.containerTitle)},is(t)),n)),G.createElement("div",{className:re(xs.columnRight)},i)),r)},us=e=>{var{name:t,controls:n,children:r,path:a,shape:s,actions:i}=e;return G.createElement("div",{className:re(xs.container)},n&&G.createElement("div",{className:re(xs.columnLeft,xs.containerHeader)},n),G.createElement("div",null,r),G.createElement("div",{className:re(xs.columnLeft)},G.createElement("a",{href:"javascript:void 0",onClick:()=>i.addArrayElement(a,s.elementShape)},"Add a ",os(t))))},ds=e=>{var{name:t,controls:n,children:r,path:a}=e,s=G.createElement("div",{className:re(xs.containerHeader)},G.createElement(cs,{depth:a.length,className:re(xs.containerTitle)},is(t)),n),i=(t||n)&&G.createElement("div",{className:re(xs.containerHeader,xs.previewCollectionHeader)},G.createElement(cs,{depth:a.length,className:re(xs.containerTitle)},is(t))),o=s&&i;return G.createElement("div",{className:re(xs.container)},o&&G.createElement("span",{className:re(xs.row)},G.createElement("div",{className:re(xs.columnLeft)},s),G.createElement("div",{className:re(xs.columnRight)},i)),G.createElement("div",{className:re(a.length>0&&xs.contentIndent)},r))},ms=e=>{var{shape:t,data:n}=e,r=pe(e,Ja);return"content"===t.type?G.createElement(fs,ce({shape:t,data:n},r)):"hint"===t.type?G.createElement(vs,ce({shape:t,data:n},r)):"tags"===t.type?G.createElement(ys,ce({shape:t,data:n},r)):"array"===t.type?G.createElement(bs,ce({shape:t,data:n},r)):"object"===t.type?G.createElement(Es,ce({shape:t,data:n},r)):null},gs=e=>class extends G.Component{constructor(){super(...arguments),le(this,"stickynessTimer",void 0),le(this,"state",{sticky:!1}),le(this,"updateStickiness",(()=>{var e=te.findDOMNode(this).offsetHeight>window.innerHeight;e!==this.state.sticky&&this.setState({sticky:e})}))}componentDidMount(){this.stickynessTimer=setInterval(this.updateStickiness,1e3),this.updateStickiness()}componentWillUnmount(){clearInterval(this.stickynessTimer)}render(){return G.createElement(e,ce({},this.props,{sticky:this.state.sticky}))}},fs=gs((e=>{var{data:t,path:n,actions:r,apiOptions:a,renderers:s,sticky:i}=e,o=G.createElement("div",{className:"framework-perseus"},$a(s).get(n));return G.createElement("span",null,G.createElement("div",{className:re(xs.row)},G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:re(i&&xs.sticky)},G.createElement(Sr,ce({},t,{onChange:e=>r.mergeValueAtPath(n,e),apiOptions:a})))),G.createElement("div",{className:re(xs.columnRight)},G.createElement("div",{className:re(i&&xs.sticky)},o))))})),vs=gs((e=>{var{data:t,path:n,actions:r,apiOptions:a,renderers:s,sticky:i}=e,o=G.createElement("div",{className:"framework-perseus"},$a(s).get(n));return G.createElement("div",{className:re(xs.row)},G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:re(i&&xs.sticky)},G.createElement(Ta,ce({},t,{className:re(xs.hintEditor),onChange:e=>r.mergeValueAtPath(n,e),apiOptions:a,showTitle:!1,showRemoveButton:!1,showMoveButtons:!1,onRemove:()=>{},onMove:e=>{},isFirst:!0,isLast:!0})))),G.createElement("div",{className:re(xs.columnRight)},G.createElement("div",{className:re(i&&xs.sticky)},o)))})),ys=e=>{var{data:t,path:n,actions:r,apiOptions:a}=e,{GroupMetadataEditor:s}=a;return null==s?null:G.createElement("div",{className:re(xs.columnLeft)},G.createElement("div",{className:re(xs.tagsEditor)},G.createElement(s,{value:t,onChange:e=>r.setValueAtPath(n,e),showTitle:!1})))},bs=e=>{var{shape:t,data:n,path:r,actions:a}=e,s=pe(e,Za),i=os(ss(r[r.length-1])),o=t.elementShape.type,l="content"===o||"hint"===o,c=n.map(((e,o)=>{var c=r.concat(o),p=[o>0&&G.createElement("div",{key:"moveArrayElementUp",className:re(xs.control)},G.createElement(Ga,{color:"orange",title:"Move up",onClick:()=>a.moveArrayElementUp(c)},G.createElement("div",{className:re(xs.verticalFlip)},G.createElement(es,ts)))),o<n.length-1&&G.createElement("div",{key:"moveArrayElementDown",className:re(xs.control)},G.createElement(Ga,{color:"orange",title:"Move down",onClick:()=>a.moveArrayElementDown(c)},G.createElement(es,ts))),G.createElement("div",{key:"removeArrayElement",className:re(xs.control)},G.createElement(Ga,{color:"orange",title:"Delete",onClick:()=>a.removeArrayElement(c)},G.createElement(es,ns)))];return G.createElement("div",{key:o,className:re(xs.arrayElement,!l&&xs.arrayElementAndNotLeaf)},G.createElement(ps,ce({},s,{key:o,shape:t.elementShape,data:e,path:c,actions:a,name:"".concat(i," ").concat(o+1),controls:p})))}));return G.createElement("div",null,c)},Es=e=>{var{shape:t,data:n,path:r}=e,a=pe(e,Qa),s=Object.keys(t.shape).map((e=>G.createElement("div",{key:e,className:re(xs.objectElement)},G.createElement(ps,ce({},a,{shape:t.shape[e],data:n[e],path:r.concat(e)})))));return G.createElement("div",null,s)};class ws extends G.Component{constructor(){super(...arguments),le(this,"layout",void 0),le(this,"_renderLayout",(()=>{var{Layout:e,apiOptions:t,item:n}=this.props;return G.createElement(e,{ref:e=>this.layout=e,item:n,apiOptions:t})})),le(this,"_renderJson",(()=>G.createElement("div",null,G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})}),G.createElement(de,{multiLine:!0,value:this.props.item,onChange:e=>this.props.onChange({item:e})})))),le(this,"_renderPreview",(()=>G.createElement("div",null,G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})}),this._renderLayout()))),le(this,"mergeValueAtPath",((e,t)=>{this.props.onChange({item:$a(this.props.item).merge(ls(e),t).freeze()})})),le(this,"setValueAtPath",((e,t)=>{this.props.onChange({item:$a(this.props.item).set(ls(e),t).freeze()})})),le(this,"addArrayElement",((e,t)=>{var n=$a(this.props.item).get(ls(e)).length,r=e.concat(n),a=g(t);this.props.onChange({item:$a(this.props.item).set(ls(r),a).freeze()})})),le(this,"removeArrayElement",(e=>{this.props.onChange({item:$a(this.props.item).del(ls(e)).freeze()})})),le(this,"moveArrayElementDown",(e=>{var t=e[e.length-1]+1,n=e.slice(0,-1).concat(t),r=$a(this.props.item).get(ls(e)),a=$a(this.props.item).get(ls(n));this.props.onChange({item:$a(this.props.item).set(ls(e),a).set(ls(n),r).freeze()})})),le(this,"moveArrayElementUp",(e=>{var t=e[e.length-1],n=e.slice(0,-1).concat(t-1);this.moveArrayElementDown(n)})),le(this,"_renderEdit",(()=>{var e=oe(oe({},u.defaults),this.props.apiOptions),{item:t}=this.props,n=this.props.Layout.shape;return G.createElement("div",{className:"perseus-multirenderer-editor"},G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})}),G.createElement(rs,{item:t,shape:n,apiOptions:e},(r=>{var{renderers:a}=r;return G.createElement(ps,{shape:n,data:m(t),path:[],actions:this,apiOptions:e,renderers:a})})))})),le(this,"score",(()=>{if(this.layout)return this.layout.score()})),le(this,"getSerializedState",(()=>{if(this.layout)return this.layout.getSerializedState()})),le(this,"restoreSerializedState",(e=>{this.layout&&this.layout.restoreSerializedState(e)})),le(this,"_renderContent",(()=>{switch(this.props.editorMode){case"json":return this._renderJson();case"preview":return this._renderPreview();case"edit":return this._renderEdit();default:return G.createElement(as,{currentMode:this.props.editorMode,onChange:e=>this.props.onChange({editorMode:e})})}}))}render(){return G.createElement("div",{id:"perseus"},this._renderContent())}}var xs=ne.create({container:{},editor:{width:"100%"},treePreview:{position:"relative"},verticalFlip:{transform:"scaleY(-1)"},control:{marginLeft:12},containerHeader:{alignItems:"flex-end",display:"flex",flexDirection:"row"},previewCollectionHeader:{marginBottom:16},containerTitle:{flexGrow:1,margin:0},contentIndent:{marginLeft:8},hintEditor:{paddingBottom:0},arrayElement:{marginBottom:16},arrayElementAndNotLeaf:{borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc",paddingTop:16}},objectElement:{marginBottom:16},tagsEditor:{border:"1px solid #ddd",padding:"5px 10px"},row:{display:"flex",position:"relative"},columnLeft:{width:360,marginRight:30,position:"relative"},columnRight:{flex:1,marginLeft:30,position:"relative"},sticky:{position:"sticky",top:33},rowHeading:{position:"sticky",backgroundColor:"white",width:"100%",zIndex:101,top:-1}}),Cs=Z({displayName:"StatefulArticleEditor",getInitialState:function(){return K({}).extend(this.props,{mode:"edit",onChange:this.handleChange,ref:"editor",screen:"phone"})},componentDidMount:function(){this._isMounted=!0},UNSAFE_componentWillReceiveProps:function(e){this.setState(K(e).omit("onChange","ref"))},componentWillUnmount:function(){this._isMounted=!1},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(){return this.refs.editor.serialize()},handleChange:function(e,t){this._isMounted&&this.setState(e,t)},scorePreview:function(){return this.refs.editor.scorePreview()},render:function(){var{mode:e,screen:t}=this.state;return G.createElement("div",null,G.createElement("div",{style:ks.controlBar},G.createElement("span",{style:ks.controls},"Mode:"," ",G.createElement("span",{onClick:()=>this.setState({mode:"edit"}),style:"edit"===e?ks.controlSelected:ks.control},"EDIT")," | ",G.createElement("span",{onClick:()=>this.setState({mode:"preview"}),style:"preview"===e?ks.controlSelected:ks.control},"PREVIEW")," | ",G.createElement("span",{onClick:()=>this.setState({mode:"json"}),style:"json"===e?ks.controlSelected:ks.control},"JSON")),G.createElement("span",{style:ks.controls},"Screen:"," ",G.createElement("span",{onClick:()=>this.setState({screen:"phone"}),style:"phone"===t?ks.controlSelected:ks.control},"PHONE")," | ",G.createElement("span",{onClick:()=>this.setState({screen:"tablet"}),style:"tablet"===t?ks.controlSelected:ks.control},"TABLET")," | ",G.createElement("span",{onClick:()=>this.setState({screen:"desktop"}),style:"desktop"===t?ks.controlSelected:ks.control},"DESKTOP"))),G.createElement("div",{style:ks.editor},G.createElement(zr,this.state)))}}),ks={controlBar:{marginBottom:25,marginTop:5},controls:{marginRight:10},controlSelected:{cursor:"default",fontWeight:700},control:{cursor:"pointer"},editor:{marginTop:-20}},Ss=Z({displayName:"StatefulEditorPage",propTypes:{componentClass:J.func},getDefaultProps:function(){return{componentClass:Ra}},render:function(){var e=this.props.componentClass;return G.createElement(e,this.state)},getInitialState:function(){return K({}).extend(K.omit(this.props,"componentClass"),{onChange:this.handleChange,ref:"editor"})},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},UNSAFE_componentWillReceiveProps:function(e){this.setState(K(e).pick("apiOptions","imageUploader","developerMode","problemNum","previewDevice","frameSource"))},getSaveWarnings:function(){return this.refs.editor.getSaveWarnings()},serialize:function(){return this.refs.editor.serialize()},handleChange:function(e,t){this._isMounted&&this.setState(e,t)},scorePreview:function(){return this.refs.editor.scorePreview()}}),{PropCheckBox:Ns,TextListEditor:Ts}=t,_s=w.widget;class Os extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement(Ns,{label:"Randomize item order",labelAlignment:"right",randomizeItems:this.props.randomizeItems,onChange:this.props.onChange})),"Categories:",G.createElement(Ts,{options:this.props.categories,onChange:e=>{this.change("categories",e)},layout:"horizontal"}),"Items:",G.createElement(Ts,{options:this.props.items,onChange:e=>{this.change({items:e,values:K.first(this.props.values,e.length)})},layout:"vertical"}),G.createElement(_s,{apiOptions:this.props.apiOptions,items:this.props.items,categories:this.props.categories,values:this.props.values,onChange:e=>{this.props.onChange(e)},trackInteraction:function(){}}))}}le(Os,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,items:J.arrayOf(J.string),categories:J.arrayOf(J.string),values:J.arrayOf(J.number),randomizeItems:J.bool})),le(Os,"widgetName","categorizer"),le(Os,"defaultProps",{items:[],categories:[],values:[],randomizeItems:!1});class Ms extends G.Component{constructor(e){super(e),le(this,"handleChange",(e=>{this.setState({value:e.target.value})})),le(this,"handleBlur",(e=>{this.props.onChange(e.target.value)})),this.state={value:this.props.value}}UNSAFE_componentWillReceiveProps(e){this.setState({value:e.value})}render(){return G.createElement("input",{className:this.props.className,style:this.props.style,type:"text",value:this.state.value,onChange:this.handleChange,onBlur:this.handleBlur})}}var{InfoTip:As,PropCheckBox:Ps}=t;class Ds extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("fieldset",{className:"pair-editor"},G.createElement("label",null,"Name:"," ",G.createElement(Ms,{value:this.props.name,onChange:this.change("name")})),G.createElement("label",null," ","Value:"," ",G.createElement(Ms,{value:this.props.value,onChange:this.change("value")})))}}le(Ds,"propTypes",oe(oe({},x.propTypes),{},{name:J.string,value:J.string})),le(Ds,"defaultProps",{name:"",value:""});class Is extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handlePairChange",((e,t)=>{var n=this.props.pairs.slice();n[e]=t;var r=n[n.length-1];r.name&&r.value&&n.push({name:"",value:""}),this.change("pairs",n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=K.map(this.props.pairs,((e,t)=>G.createElement(Ds,{key:t,name:e.name,value:e.value,onChange:this.handlePairChange.bind(this,t)})));return G.createElement("div",null,e)}}le(Is,"propTypes",oe(oe({},x.propTypes),{},{pairs:J.arrayOf(J.shape({name:J.string,value:J.string})).isRequired}));var Rs=/khanacademy\.org\/computer-programming\/[^\/]+\/(\d+)/;class zs extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"_handleSettingsChange",(e=>{this.change({settings:e.pairs})})),le(this,"_handleProgramIDChange",(e=>{var t,n;t=e,(n=Rs.exec(t))&&(t=n[1]),e=t;var{isDevServer:r,InitialRequestUrl:s}=o.getDependencies(),l=r?s.origin:"https://www.khanacademy.org",c="".concat(l,"/api/internal/scratchpads/").concat(e);Q.getJSON(c).done((t=>{var n=t.userAuthoredContentType;this.change({width:t.width,height:t.height,programID:e,programType:n})})).fail(((t,n,r)=>{a.error("Error retrieving scratchpad info for program ID ",i.TransientService,{cause:r,loggedMetadata:{textStatus:n,programID:e}}),this.change({width:400,height:400,programID:e,programType:null})}))})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,"Url or Program ID:"," ",G.createElement(Ms,{value:this.props.programID,onChange:this._handleProgramIDChange})),G.createElement("br",null),G.createElement(Ps,{label:"Show Editor",showEditor:this.props.showEditor,onChange:this.props.onChange}),G.createElement(As,null,'If you show the editor, you should use the "full-width" alignment to make room for the width of the editor.'),G.createElement("br",null),G.createElement(Ps,{label:"Show Buttons",showButtons:this.props.showButtons,onChange:this.props.onChange}),G.createElement("br",null),G.createElement("label",null,"Settings:",G.createElement(Is,{name:"settings",pairs:this.props.settings,onChange:this._handleSettingsChange}),G.createElement(As,null,"Settings that you add here are available to the program as an object returned by ",G.createElement("code",null,"Program.settings()"))))}}le(zs,"propTypes",oe({},x.propTypes)),le(zs,"widgetName","cs-program"),le(zs,"defaultProps",{programID:"",programType:null,settings:[{name:"",value:""}],showEditor:!1,showButtons:!1,width:400,height:400});var{TextInput:Ls}=t;class Fs extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",{className:"perseus-widget-definition-editor"},G.createElement("a",{href:"https://docs.google.com/document/d/1udaPef4imOfTMhmLDlWq4SM0mxL0r3YHFZE-5J1uGfo",target:"_blank"},"Definition style guide"),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Word to be defined:"," ",G.createElement(Ls,{value:this.props.togglePrompt,onChange:this.change("togglePrompt"),placeholder:"define me"}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.definition,widgetEnabled:!1,placeholder:"definition goes here",onChange:e=>{var t={};K.has(e,"content")&&(t.definition=e.content),this.change(t)}})))}}le(Fs,"propTypes",oe(oe({},x.propTypes),{},{togglePrompt:J.string,definition:J.string,apiOptions:J.any})),le(Fs,"widgetName","definition"),le(Fs,"defaultProps",{togglePrompt:"",definition:""});var{InfoTip:qs,InlineIcon:Us}=t,{iconPlus:Ws,iconTrash:Vs}=p;class js extends G.Component{constructor(){super(...arguments),le(this,"onPlaceholderChange",(e=>{var t=e.target.value;this.props.onChange({placeholder:t})})),le(this,"onCorrectChange",(e=>{var t=K.map(this.props.choices,(function(t,n){return K.extend({},t,{correct:n===e})}));this.props.onChange({choices:t})})),le(this,"onContentChange",((e,t)=>{var n=this.props.choices.slice(),r=K.clone(n[e]);r.content=t.target.value,n[e]=r,this.props.onChange({choices:n})})),le(this,"addChoice",(e=>{e.preventDefault();var t=this.props.choices;this.props.onChange({choices:t.concat([{content:"",correct:!1}])},this.focus.bind(this,t.length))})),le(this,"removeChoice",((e,t)=>{t.preventDefault();var n=K(this.props.choices).clone();n.splice(e,1),this.props.onChange({choices:n})})),le(this,"focus",(e=>(te.findDOMNode(this.refs["editor"+e]).focus(),!0))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=K.uniqueId("perseus_dropdown_");return G.createElement("div",{className:"perseus-widget-dropdown"},G.createElement("div",{className:"dropdown-info"},"Dropdown",G.createElement(qs,null,G.createElement("p",null,"The drop down is useful for making inequalities in a custom format. We normally use the symbols ","<",","," ",">",', ≤, ≥ (in that order) which you can copy into the choices. When possible, use the "multiple choice" answer type instead.'))),G.createElement("div",{className:"dropdown-placeholder"},G.createElement("input",{type:"text",placeholder:"Placeholder value",value:this.props.placeholder,onChange:this.onPlaceholderChange}),G.createElement(qs,null,G.createElement("p",null,"This value will appear as the drop down default. It should give the user some indication of the values available in the drop down itself, e.g., Yes/No/Maybe."))),G.createElement("div",{className:"clearfix"}),G.createElement("ul",{className:"dropdown-choices"},this.props.choices.map((function(t,n){var r=t.correct?"correct":"incorrect";return G.createElement("li",{key:""+n},G.createElement("div",null,G.createElement("input",{ref:"radio"+n,type:"radio",name:e,checked:t.correct?"checked":"",onChange:this.onCorrectChange.bind(this,n),value:n}),G.createElement("input",{type:"text",ref:"editor"+n,onChange:this.onContentChange.bind(this,n),className:r,value:t.content}),G.createElement("a",{href:"#",className:"simple-button orange",onClick:this.removeChoice.bind(this,n)},G.createElement("span",{className:"remove-choice"},G.createElement(Us,Vs)))))}),this)),G.createElement("div",{className:"add-choice-container"},G.createElement("a",{href:"#",className:"simple-button orange",onClick:this.addChoice},G.createElement(Us,Ws)," Add a choice"," ")))}}le(js,"propTypes",{choices:J.arrayOf(J.shape({content:J.string,correct:J.bool})),placeholder:J.string}),le(js,"widgetName","dropdown"),le(js,"defaultProps",{placeholder:"",choices:[{content:"",correct:!1}]});var Bs=Math.pow(2,-42);function $s(e){return K.isNumber(e)&&!K.isNaN(e)}function Hs(e,t,n){return null==e||null==t?e===t:e===t||(null==n&&(n=1e-9),Math.abs(e-t)<n)}function Gs(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}function Ys(e,t){return Math.round(e/t)*t}function Xs(e,t){return Math.floor(e/t)*t}function Ks(e,t){return Math.ceil(e/t)*t}var Js=Object.freeze({__proto__:null,DEFAULT_TOLERANCE:1e-9,EPSILON:Bs,is:$s,equal:Hs,sign:function(e,t){return Hs(e,0,t)?0:Math.abs(e)/e},isInteger:function(e,t){return Hs(Math.round(e),e,t)},round:Gs,roundTo:Ys,floorTo:Xs,ceilTo:Ks,toFraction:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Bs,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,r=[1,0],a=[0,1],s=Math.floor(e),i=e-s;a[0]<=n;){if(Hs(r[0]/a[0],e,t))return[r[0],a[0]];r=[s*r[0]+r[1],r[0]],a=[s*a[0]+a[1],a[0]],i=1/i-(s=Math.floor(1/i))}return[e,1]}});function Zs(e){return e.reduce(((e,t)=>e+t),0)}function Qs(e){return e.reduce(((e,t)=>e*t),1)}function ei(e,t){return!!K.isArray(e)&&(void 0===t||e.length===t)&&e.every($s)}function ti(e){return oi(e,1/ni(e))}function ni(e){return Math.sqrt(ri(e,e))}function ri(e,t){return Zs(K.zip(e,t).map(Qs))}function ai(){var e=K.zip(...arguments);return e.map(Zs)}function si(e,t){return K.zip(e,t).map((e=>e[0]-e[1]))}function ii(e){return e.map((e=>-e))}function oi(e,t){return e.map((e=>e*t))}function li(e,t,n){return K.zip(e,t).every((e=>Hs(e[0],e[1],n)))}function ci(e,t,n){return!(!Hs(ni(e),0,n)&&!Hs(ni(t),0,n))||li(e=ti(e),t=ti(t),n)}function pi(e,t,n){return ci(e,t,n)||ci(e,ii(t),n)}function hi(e){var t=ni(e),n=Math.atan2(e[1],e[0]);return n<0&&(n+=2*Math.PI),[t,n]}function ui(e){var t=hi(e);return[t[0],180*t[1]/Math.PI]}function di(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[e*Math.cos(t),e*Math.sin(t)]}function mi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return di(e,t*Math.PI/180)}function gi(e,t){var n=hi(e),r=n[1]+t;return di(n[0],r)}function fi(e,t){var n=ui(e),r=n[1]+t;return mi(n[0],r)}function vi(e,t){return Math.acos(ri(e,t)/(ni(e)*ni(t)))}function yi(e,t){return oi(t,ri(e,t)/ri(t,t))}function bi(e,t){return e.map(((e,n)=>Gs(e,t[n]||t)))}function Ei(e,t){return e.map(((e,n)=>Ys(e,t[n]||t)))}function wi(e,t){return e.map(((e,n)=>Xs(e,t[n]||t)))}function xi(e,t){return e.map(((e,n)=>Ks(e,t[n]||t)))}var Ci=Object.freeze({__proto__:null,is:ei,normalize:ti,length:ni,dot:ri,add:ai,subtract:si,negate:ii,scale:oi,equal:li,codirectional:ci,collinear:pi,polarRadFromCart:hi,polarDegFromCart:ui,cartFromPolarRad:di,cartFromPolarDeg:mi,rotateRad:gi,rotateDeg:fi,angleRad:vi,angleDeg:function(e,t){return 180*vi(e,t)/Math.PI},projection:yi,round:bi,roundTo:Ei,floorTo:wi,ceilTo:xi});function ki(e,t){var n=si(t[1],t[0]),r=si(e,t[0]);return ni(si(yi(r,n),r))}function Si(e,t){var n=si(t[1],t[0]),r=si(e,t[0]),a=si(oi(yi(r,n),2),r);return ai(t[0],a)}var Ni=ei,Ti=ai,_i=ai,Oi=si,Mi=li,Ai=hi,Pi=ui,Di=di,Ii=mi,Ri=bi,zi=Ei,Li=wi,Fi=xi,qi=Object.freeze({__proto__:null,rotateRad:function(e,t,n){return void 0===n?gi(e,t):ai(n,gi(si(e,n),t))},rotateDeg:function(e,t,n){return void 0===n?fi(e,t):ai(n,fi(si(e,n),t))},distanceToPoint:function(e,t){return ni(si(e,t))},distanceToLine:ki,reflectOverLine:Si,compare:function(e,t,n){if(e.length!==t.length)return e.length-t.length;for(var r=0;r<e.length;r++)if(!Hs(e[r],t[r],n))return e[r]-t[r];return 0},is:Ni,addVector:Ti,addVectors:_i,subtractVector:Oi,equal:Mi,polarRadFromCart:Ai,polarDegFromCart:Pi,cartFromPolarRad:Di,cartFromPolarDeg:Ii,round:Ri,roundTo:zi,floorTo:Li,ceilTo:Fi}),Ui=Object.freeze({__proto__:null,distanceToPoint:function(e,t){return ki(t,e)},reflectPoint:function(e,t){return Si(t,e)},midpoint:function(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]},equal:function(e,t,n){var r=si(e[1],e[0]);return!!pi(r,si(t[1],t[0]),n)&&(!!Mi(e[0],t[0])||pi(r,si(t[0],e[0]),n))}}),Wi=Object.freeze({__proto__:null,equal:function(e,t,n){var r=si(e[1],e[0]),a=si(t[1],t[0]),s=Mi(e[0],t[0]),i=ci(r,a,n);return s&&i}}),{Graphie:Vi}=t,ji=Vi.MovablePoint;class Bi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"getUserInput",(()=>k.getUserInput.call(this))),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"movePoint",(e=>{this.change({coord:e})})),le(this,"_getGridConfig",(e=>K.map(e.step,(function(t,n){return r.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])})))),le(this,"setupGraphie",((e,t)=>{var n=this._getGridConfig(t);e.graphInit({range:t.range,scale:K.pluck(n,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,tickStep:K.pluck(n,"tickStep"),labelStep:1,unityLabels:K.pluck(n,"unityLabel")}),e.label([0,t.range[1][1]],t.labels[1],"above")})),le(this,"simpleValidate",(e=>Bi.validate(this.getUserInput(),e)))}static validate(e,t){return null==e.coord?{type:"invalid",message:null}:qi.equal(e.coord,t.correct)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}}render(){return G.createElement(Vi,{ref:"graphie",box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},G.createElement(ji,{pointSize:5,coord:this.props.coord||[0,0],constraints:[ji.constraints.snap(),ji.constraints.bound()],onMove:this.movePoint}))}}le(Bi,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,graph:J.object.isRequired,coord:J.arrayOf(J.number)})),le(Bi,"defaultProps",{coord:null,graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],valid:!0,backgroundImage:null,markings:"grid",showProtractor:!1}});var $i={name:"example-graphie-widget",displayName:"Example Graphie Widget",hidden:!0,widget:Bi},Hi=$i.widget;class Gi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleChange",(e=>{e.coord&&this.change({correct:e.coord})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement(Hi,{graph:this.props.graph,coord:this.props.correct,onChange:this.handleChange,apiOptions:this.props.apiOptions}))}}le(Gi,"propTypes",oe({},x.propTypes)),le(Gi,"widgetName","example-graphie-widget"),le(Gi,"defaultProps",{correct:[4,4],graph:{box:[340,340],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],valid:!0,backgroundImage:null,markings:"grid",showProtractor:!1}});class Yi extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"handleAnswerChange",(e=>{this.change({correct:e.target.value})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,"Correct answer:",G.createElement("input",{value:this.props.correct,onChange:this.handleAnswerChange,ref:"input"})))}}le(Yi,"propTypes",oe({},x.propTypes)),le(Yi,"widgetName","example-widget"),le(Yi,"defaultProps",{correct:""});var{TextInput:Xi}=t;class Ki extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"state",{}),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",{className:"perseus-widget-explanation-editor"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Prompt to show explanation:"," ",G.createElement(Xi,{value:this.props.showPrompt,onChange:this.change("showPrompt")}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Prompt to hide explanation:"," ",G.createElement(Xi,{value:this.props.hidePrompt,onChange:this.change("hidePrompt")}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,widgetEnabled:!0,immutableWidgets:!1,onChange:e=>{var t={};K.has(e,"content")&&(t.explanation=e.content),K.has(e,"widgets")&&(t.widgets=e.widgets),this.change(t)}})))}}le(Ki,"propTypes",oe(oe({},x.propTypes),{},{showPrompt:J.string,hidePrompt:J.string,explanation:J.string,widgets:J.object,apiOptions:J.any})),le(Ki,"widgetName","explanation"),le(Ki,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{}});var Ji=function(){var e=function(e,t,n,r){for(n=n||{},r=e.length;r--;n[e[r]]=t);return n},t=[1,11],n=[1,9],r=[8,17],a=[6,11],s=[6,11,13,17],i={trace:function(){},yy:{},symbols_:{error:2,unitvalue:3,magnitude:4,unit:5,EOF:6,float:7,POW:8,int:9,multatoms:10,DIV:11,expatom:12,MUL:13,atom:14,"^":15,nat:16,ATOM:17,FLOAT:18,NAT:19,NEG:20,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",8:"POW",11:"DIV",13:"MUL",15:"^",17:"ATOM",18:"FLOAT",19:"NAT",20:"NEG"},productions_:[0,[3,3],[3,2],[4,3],[4,1],[5,3],[5,1],[10,3],[10,2],[10,1],[12,3],[12,1],[14,1],[7,1],[7,1],[16,1],[9,2],[9,1]],performAction:function(e,t,n,r,a,s,i){var o=s.length-1;switch(a){case 1:return{type:"unitMagnitude",magnitude:s[o-2],unit:s[o-1]};case 2:return{type:"unitStandalone",unit:s[o-1]};case 3:this.$=s[o-2]+"e"+s[o];break;case 4:case 13:case 14:case 15:case 17:this.$=s[o];break;case 5:this.$={num:s[o-2],denom:s[o]};break;case 6:this.$={num:s[o],denom:null};break;case 7:this.$=[s[o-2]].concat(s[o]);break;case 8:this.$=[s[o-1]].concat(s[o]);break;case 9:this.$=[s[o]];break;case 10:this.$={name:s[o-2],pow:s[o]};break;case 11:this.$={name:s[o],pow:1};break;case 12:this.$=e;break;case 16:this.$="-"+s[o]}},table:[{3:1,4:2,5:3,7:4,10:5,12:8,14:10,16:7,17:t,18:[1,6],19:n},{1:[3]},{5:12,10:5,12:8,14:10,17:t},{6:[1,13]},{8:[1,14],17:[2,4]},{6:[2,6],11:[1,15]},e(r,[2,13]),e(r,[2,14]),e(a,[2,9],{12:8,14:10,10:17,13:[1,16],17:t}),e([6,8,11,13,17],[2,15]),e(s,[2,11],{15:[1,18]}),e([6,11,13,15,17],[2,12]),{6:[1,19]},{1:[2,2]},{9:20,19:[1,22],20:[1,21]},{10:23,12:8,14:10,17:t},{10:24,12:8,14:10,17:t},e(a,[2,8]),{16:25,19:n},{1:[2,1]},{17:[2,3]},{19:[1,26]},{17:[2,17]},{6:[2,5]},e(a,[2,7]),e(s,[2,10]),{17:[2,16]}],defaultActions:{13:[2,2],19:[2,1],20:[2,3],22:[2,17],23:[2,5],26:[2,16]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],a=[],s=this.table,i="",o=0,l=0,c=2,p=1,h=a.slice.call(arguments,1),u=Object.create(this.lexer),d={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(d.yy[m]=this.yy[m]);u.setInput(e,d.yy),d.yy.lexer=u,d.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var g=u.yylloc;a.push(g);var f=u.options&&u.options.ranges;function v(){var e;return"number"!=typeof(e=u.lex()||p)&&(e=t.symbols_[e]||e),e}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var y,b,E,w,x,C,k,S,N={};;){if(b=n[n.length-1],this.defaultActions[b]?E=this.defaultActions[b]:(null==y&&(y=v()),E=s[b]&&s[b][y]),void 0===E||!E.length||!E[0]){var T="";for(x in S=[],s[b])this.terminals_[x]&&x>c&&S.push("'"+this.terminals_[x]+"'");T=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(o+1)+": Unexpected "+(y==p?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:u.match,token:this.terminals_[y]||y,line:u.yylineno,loc:g,expected:S})}if(E[0]instanceof Array&&E.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+y);switch(E[0]){case 1:n.push(y),r.push(u.yytext),a.push(u.yylloc),n.push(E[1]),y=null,l=u.yyleng,i=u.yytext,o=u.yylineno,g=u.yylloc;break;case 2:if(C=this.productions_[E[1]][1],N.$=r[r.length-C],N._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},f&&(N._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(N,[i,l,o,d.yy,E[1],r,a].concat(h))))return w;C&&(n=n.slice(0,-1*C*2),r=r.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[E[1]][0]),r.push(N.$),a.push(N._$),k=s[n[n.length-2]][n[n.length-1]],n.push(k);break;case 3:return!0}}return!0}},o={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var s in a)this[s]=a[s];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),s=0;s<a.length;s++)if((n=this._input.match(this.rules[a[s]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,a[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,a[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,n,r){switch(n){case 0:return 11;case 1:return"(";case 2:return")";case 3:return 8;case 4:return 15;case 5:return 13;case 6:return 18;case 7:return 19;case 8:return 20;case 9:case 10:case 11:return 17;case 12:break;case 13:return 6}},rules:[/^(?:\/)/,/^(?:\()/,/^(?:\))/,/^(?:(\*|x|\u00d7|\u2219|\u22c5|\u00b7)\s*10\s*\^)/,/^(?:\^)/,/^(?:\*)/,/^(?:[0-9]+\.[0-9]+)/,/^(?:[0-9]+)/,/^(?:-)/,/^(?:\u00b0( ?)[cCfF])/,/^(?:fl\.? oz\.?)/,/^(?:[\u00b5]?([A-Za-z-]+|[\u2103\u2109\u212b]))/,/^(?:\s+)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};function l(){this.yy={}}return i.lexer=o,l.prototype=i,i.Parser=l,new l}(),Zi=Ji,Qi=function(){var e=function(e,t,n,r){for(n=n||{},r=e.length;r--;n[e[r]]=t);return n},t=[1,7],n=[1,17],r=[1,13],a=[1,14],s=[1,15],i=[1,32],o=[1,22],l=[1,23],c=[1,24],p=[1,25],h=[1,26],u=[1,33],d=[1,27],m=[1,28],g=[1,29],f=[1,30],v=[1,20],y=[1,36],b=[1,37],E=[5,6,8,10,33,35,41,43,45],w=[1,39],x=[1,40],C=[5,6,8,10,12,14,16,19,21,22,28,29,30,31,32,33,34,35,37,39,41,42,43,44,45,46],k=[10,16,19,21,22,28,29,30,31,32,34,37,39,42,43,44,46],S=[5,6,8,10,12,14,16,18,19,21,22,28,29,30,31,32,33,34,35,37,39,41,42,43,44,45,46],N={trace:function(){},yy:{},symbols_:{error:2,equation:3,expression:4,SIGN:5,EOF:6,additive:7,"+":8,multiplicative:9,"-":10,triglog:11,"*":12,negative:13,"/":14,trig:15,TRIG:16,trigfunc:17,"^":18,TRIGINV:19,logbase:20,ln:21,log:22,_:23,subscriptable:24,power:25,primitive:26,variable:27,VAR:28,CONST:29,INT:30,FLOAT:31,"{":32,"}":33,"(":34,")":35,function:36,FUNC:37,invocation:38,sqrt:39,"[":40,"]":41,abs:42,"|":43,"LEFT|":44,"RIGHT|":45,FRAC:46,$accept:0,$end:1},terminals_:{2:"error",5:"SIGN",6:"EOF",8:"+",10:"-",12:"*",14:"/",16:"TRIG",18:"^",19:"TRIGINV",21:"ln",22:"log",23:"_",28:"VAR",29:"CONST",30:"INT",31:"FLOAT",32:"{",33:"}",34:"(",35:")",37:"FUNC",39:"sqrt",40:"[",41:"]",42:"abs",43:"|",44:"LEFT|",45:"RIGHT|",46:"FRAC"},productions_:[0,[3,4],[3,2],[3,1],[4,1],[7,3],[7,3],[7,1],[9,2],[9,3],[9,3],[9,1],[13,2],[13,1],[15,1],[17,1],[17,3],[17,1],[20,1],[20,1],[20,3],[11,2],[11,2],[11,1],[25,3],[25,1],[27,1],[24,3],[24,1],[24,1],[24,1],[24,1],[24,3],[24,3],[36,1],[38,4],[38,4],[38,7],[38,4],[38,3],[38,3],[38,4],[26,1],[26,1],[26,7]],performAction:function(e,t,n,r,a,s,i){var o=s.length-1;switch(a){case 1:return new r.Eq(s[o-3],s[o-2],s[o-1]);case 2:return s[o-1];case 3:return new r.Add([]);case 4:case 7:case 11:case 13:case 15:case 20:case 23:case 25:case 42:case 43:this.$=s[o];break;case 5:this.$=r.Add.createOrAppend(s[o-2],s[o]);break;case 6:this.$=r.Add.createOrAppend(s[o-2],r.Mul.handleNegative(s[o],"subtract"));break;case 8:this.$=r.Mul.fold(r.Mul.createOrAppend(s[o-1],s[o]));break;case 9:this.$=r.Mul.fold(r.Mul.createOrAppend(s[o-2],s[o]));break;case 10:this.$=r.Mul.fold(r.Mul.handleDivide(s[o-2],s[o]));break;case 12:this.$=r.Mul.handleNegative(s[o]);break;case 14:case 17:this.$=[e];break;case 16:this.$=s[o-2].concat(s[o]);break;case 18:this.$=r.Log.natural();break;case 19:this.$=r.Log.common();break;case 21:this.$=r.Trig.create(s[o-1],s[o]);break;case 22:this.$=r.Log.create(s[o-1],s[o]);break;case 24:this.$=new r.Pow(s[o-2],s[o]);break;case 26:case 34:this.$=e;break;case 27:this.$=new r.Var(s[o-2],s[o]);break;case 28:this.$=new r.Var(s[o]);break;case 29:this.$=new r.Const(e.toLowerCase());break;case 30:this.$=r.Int.create(Number(e));break;case 31:this.$=r.Float.create(Number(e));break;case 32:this.$=s[o-1].completeParse();break;case 33:this.$=s[o-1].completeParse().addHint("parens");break;case 35:case 36:this.$=r.Pow.sqrt(s[o-1]);break;case 37:this.$=new r.Pow.nthroot(s[o-1],s[o-4]);break;case 38:case 39:case 40:this.$=new r.Abs(s[o-1]);break;case 41:this.$=new r.Func(s[o-3],s[o-1]);break;case 44:this.$=r.Mul.handleDivide(s[o-4],s[o-1])}},table:[{3:1,4:2,6:[1,3],7:4,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{1:[3]},{5:[1,34],6:[1,35]},{1:[2,3]},e([5,6],[2,4],{8:y,10:b}),e(E,[2,7],{17:9,20:10,25:11,15:12,26:16,24:18,38:19,27:21,36:31,11:38,12:w,14:x,16:n,19:r,21:a,22:s,28:i,29:o,30:l,31:c,32:p,34:h,37:u,39:d,42:m,44:f,46:v}),e(C,[2,11]),{10:t,11:8,13:41,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,13]),{10:t,11:8,13:42,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{10:t,11:8,13:43,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,23]),e(k,[2,15],{18:[1,44]}),e(k,[2,17]),e(k,[2,18]),e(k,[2,19],{23:[1,45]}),e(C,[2,25],{18:[1,46]}),e([10,16,18,19,21,22,28,29,30,31,32,34,37,39,42,43,44,46],[2,14]),e(S,[2,42]),e(S,[2,43]),{32:[1,47]},e(S,[2,28],{23:[1,48]}),e(S,[2,29]),e(S,[2,30]),e(S,[2,31]),{7:49,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:50,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{32:[1,52],34:[1,51],40:[1,53]},{34:[1,54]},{7:55,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:56,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{34:[1,57]},e([5,6,8,10,12,14,16,18,19,21,22,23,28,29,30,31,32,33,34,35,37,39,41,42,43,44,45,46],[2,26]),{34:[2,34]},{4:58,7:4,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{1:[2,2]},{9:59,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{9:60,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,8]),{10:t,11:8,13:61,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{10:t,11:8,13:62,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},e(C,[2,12]),e(C,[2,21]),e(C,[2,22]),{10:t,11:8,13:63,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{24:64,27:21,28:i,29:o,30:l,31:c,32:p,34:h},{10:t,11:8,13:65,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:66,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{24:67,27:21,28:i,29:o,30:l,31:c,32:p,34:h},{8:y,10:b,33:[1,68]},{8:y,10:b,35:[1,69]},{7:70,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:71,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:72,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:73,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{8:y,10:b,43:[1,74]},{8:y,10:b,45:[1,75]},{7:76,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{6:[1,77]},e(E,[2,5],{17:9,20:10,25:11,15:12,26:16,24:18,38:19,27:21,36:31,11:38,12:w,14:x,16:n,19:r,21:a,22:s,28:i,29:o,30:l,31:c,32:p,34:h,37:u,39:d,42:m,44:f,46:v}),e(E,[2,6],{17:9,20:10,25:11,15:12,26:16,24:18,38:19,27:21,36:31,11:38,12:w,14:x,16:n,19:r,21:a,22:s,28:i,29:o,30:l,31:c,32:p,34:h,37:u,39:d,42:m,44:f,46:v}),e(C,[2,9]),e(C,[2,10]),e(k,[2,16]),e(k,[2,20]),e(C,[2,24]),{8:y,10:b,33:[1,78]},e(S,[2,27]),e(S,[2,32]),e(S,[2,33]),{8:y,10:b,35:[1,79]},{8:y,10:b,33:[1,80]},{8:y,10:b,41:[1,81]},{8:y,10:b,35:[1,82]},e(S,[2,39]),e(S,[2,40]),{8:y,10:b,35:[1,83]},{1:[2,1]},{32:[1,84]},e(S,[2,35]),e(S,[2,36]),{32:[1,85]},e(S,[2,38]),e(S,[2,41]),{7:86,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{7:87,9:5,10:t,11:8,13:6,15:12,16:n,17:9,19:r,20:10,21:a,22:s,24:18,25:11,26:16,27:21,28:i,29:o,30:l,31:c,32:p,34:h,36:31,37:u,38:19,39:d,42:m,43:g,44:f,46:v},{8:y,10:b,33:[1,88]},{8:y,10:b,33:[1,89]},e(S,[2,44]),e(S,[2,37])],defaultActions:{3:[2,3],33:[2,34],35:[2,2],77:[2,1]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],a=[],s=this.table,i="",o=0,l=0,c=2,p=1,h=a.slice.call(arguments,1),u=Object.create(this.lexer),d={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(d.yy[m]=this.yy[m]);u.setInput(e,d.yy),d.yy.lexer=u,d.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var g=u.yylloc;a.push(g);var f=u.options&&u.options.ranges;function v(){var e;return"number"!=typeof(e=u.lex()||p)&&(e=t.symbols_[e]||e),e}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var y,b,E,w,x,C,k,S,N={};;){if(b=n[n.length-1],this.defaultActions[b]?E=this.defaultActions[b]:(null==y&&(y=v()),E=s[b]&&s[b][y]),void 0===E||!E.length||!E[0]){var T="";for(x in S=[],s[b])this.terminals_[x]&&x>c&&S.push("'"+this.terminals_[x]+"'");T=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(o+1)+": Unexpected "+(y==p?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(T,{text:u.match,token:this.terminals_[y]||y,line:u.yylineno,loc:g,expected:S})}if(E[0]instanceof Array&&E.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+y);switch(E[0]){case 1:n.push(y),r.push(u.yytext),a.push(u.yylloc),n.push(E[1]),y=null,l=u.yyleng,i=u.yytext,o=u.yylineno,g=u.yylloc;break;case 2:if(C=this.productions_[E[1]][1],N.$=r[r.length-C],N._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},f&&(N._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(w=this.performAction.apply(N,[i,l,o,d.yy,E[1],r,a].concat(h))))return w;C&&(n=n.slice(0,-1*C*2),r=r.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[E[1]][0]),r.push(N.$),a.push(N._$),k=s[n[n.length-2]][n[n.length-1]],n.push(k);break;case 3:return!0}}return!0}},T={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var s in a)this[s]=a[s];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),s=0;s<a.length;s++)if((n=this._input.match(this.rules[a[s]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,a[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,a[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0},performAction:function(e,t,n,r){switch(n){case 0:case 1:case 2:break;case 3:return"INT";case 4:return"FLOAT";case 5:case 15:return"^";case 6:case 7:case 8:case 9:return"*";case 10:case 11:return"/";case 12:case 13:return"-";case 14:return"+";case 16:case 18:return"(";case 17:case 19:return")";case 20:return"[";case 21:return"]";case 22:case 24:return"{";case 23:case 25:return"}";case 26:return"_";case 27:return"|";case 28:return"LEFT|";case 29:return"RIGHT|";case 30:return"!";case 31:return"SIGN";case 32:case 34:case 40:return t.yytext="<=","SIGN";case 33:case 35:case 41:return t.yytext=">=","SIGN";case 36:case 37:case 38:case 39:return t.yytext="<>","SIGN";case 42:case 43:return"FRAC";case 44:return"sqrt";case 45:return"abs";case 46:return"ln";case 47:return"log";case 48:case 49:case 50:case 51:return"TRIG";case 52:return t.yytext="sin","TRIG";case 53:return t.yytext="cos","TRIG";case 54:return t.yytext="tan","TRIG";case 55:return t.yytext="csc","TRIG";case 56:return t.yytext="sec","TRIG";case 57:return t.yytext="cot","TRIG";case 58:return t.yytext="arcsin","TRIG";case 59:return t.yytext="arccos","TRIG";case 60:return t.yytext="arctan","TRIG";case 61:return t.yytext="arccsc","TRIG";case 62:return t.yytext="arcsec","TRIG";case 63:return t.yytext="arccot","TRIG";case 64:case 65:return"TRIGINV";case 66:return t.yytext="sinh","TRIG";case 67:return t.yytext="cosh","TRIG";case 68:case 71:return t.yytext="tanh","TRIG";case 69:return t.yytext="csch","TRIG";case 70:return t.yytext="sech","TRIG";case 72:return"CONST";case 73:case 74:return t.yytext="pi","CONST";case 75:case 78:return"VAR";case 76:case 77:return t.yytext="theta","VAR";case 79:case 80:return t.yytext="phi","VAR";case 81:return e.symbolLexer(t.yytext);case 82:return"EOF";case 83:return"INVALID";case 84:console.log(t.yytext)}},rules:[/^(?:\s+)/,/^(?:\\space)/,/^(?:\\ )/,/^(?:[0-9]+\.?)/,/^(?:([0-9]+)?\.[0-9]+)/,/^(?:\*\*)/,/^(?:\*)/,/^(?:\\cdot|·)/,/^(?:\\times|×)/,/^(?:\\ast)/,/^(?:\/)/,/^(?:\\div|÷)/,/^(?:-)/,/^(?:−)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:\\left\()/,/^(?:\\right\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\\left\{)/,/^(?:\\right\})/,/^(?:_)/,/^(?:\|)/,/^(?:\\left\|)/,/^(?:\\right\|)/,/^(?:\!)/,/^(?:<=|>=|<>|<|>|=)/,/^(?:\\le)/,/^(?:\\ge)/,/^(?:\\leq)/,/^(?:\\geq)/,/^(?:=\/=)/,/^(?:\\ne)/,/^(?:\\neq)/,/^(?:≠)/,/^(?:≤)/,/^(?:≥)/,/^(?:\\frac)/,/^(?:\\dfrac)/,/^(?:sqrt|\\sqrt)/,/^(?:abs|\\abs)/,/^(?:ln|\\ln)/,/^(?:log|\\log)/,/^(?:sin|cos|tan)/,/^(?:csc|sec|cot)/,/^(?:sinh|cosh|tanh)/,/^(?:csch|sech|coth)/,/^(?:\\sin)/,/^(?:\\cos)/,/^(?:\\tan)/,/^(?:\\csc)/,/^(?:\\sec)/,/^(?:\\cot)/,/^(?:\\arcsin)/,/^(?:\\arccos)/,/^(?:\\arctan)/,/^(?:\\arccsc)/,/^(?:\\arcsec)/,/^(?:\\arccot)/,/^(?:arcsin|arccos|arctan)/,/^(?:arccsc|arcsec|arccot)/,/^(?:\\sinh)/,/^(?:\\cosh)/,/^(?:\\tanh)/,/^(?:\\csch)/,/^(?:\\sech)/,/^(?:\\coth)/,/^(?:pi)/,/^(?:π)/,/^(?:\\pi)/,/^(?:theta)/,/^(?:θ)/,/^(?:\\theta)/,/^(?:phi)/,/^(?:φ)/,/^(?:\\phi)/,/^(?:[a-zA-Z])/,/^(?:$)/,/^(?:.)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84],inclusive:!0}}};function _(){this.yy={}}return N.lexer=T,_.prototype=N,N.Parser=_,new _}(),eo=function(){throw new Error("Abstract method - must override for expr: "+this.print())},to=function(e){throw new Error(e)},no=function(e){return e!=e};function ro(){}function ao(){}function so(){this.terms=1===arguments.length?arguments[0]:K.toArray(arguments)}function io(){this.terms=1===arguments.length?arguments[0]:K.toArray(arguments)}function oo(e,t){this.base=e,this.exp=t}function lo(e,t){this.base=e,this.power=t}function co(e,t){this.type=e,this.arg=t}function po(e){this.arg=e}function ho(e,t,n){this.left=e,this.type=t,this.right=n}function uo(){}function mo(e,t){this.symbol=e,this.arg=t}function go(e,t){this.symbol=e,this.subscript=t}function fo(e){this.symbol=e}function vo(){}function yo(e,t){var n=e,r=t;r<0&&(n=-n,r=-r),this.n=n,this.d=r}function bo(e){this.n=e}function Eo(e){this.n=e}K.extend(ro.prototype,{func:eo,args:eo,construct:function(e){var t=new this.func;return this.func.apply(t,e),t},recurse:function(e){var t=Array.prototype.slice.call(arguments,1),n=K.map(this.args(),(function(n){return K.isString(n)?n:n[e].apply(n,t)}));return this.construct(n)},eval:eo,codegen:eo,compile:function(){var e=this.codegen();try{return new Function("vars","return "+e+";")}catch(t){throw new Error("Function did not compile: "+e)}},print:eo,tex:eo,asTex:function(e){e=e||{},K.defaults(e,{display:!0,dynamic:!0,times:!1});var t=this.tex();return e.display&&(t="\\displaystyle "+t),e.dynamic&&(t=(t=t.replace(/\(/g,"\\left(")).replace(/\)/g,"\\right)")),e.times&&(t=t.replace(/\\cdot/g,"\\times")),t},name:function(){return this.func.name?this.func.name:this.func.toString().match(/^function\s*([^\s(]+)/)[1]},repr:function(){return this.name()+"("+K.map(this.args(),(function(e){return K.isString(e)?e:e.repr()})).join(",")+")"},strip:function(){return this.recurse("strip")},normalize:function(){return this.recurse("normalize")},expand:function(){return this.recurse("expand")},factor:function(e){return this.recurse("factor",e)},collect:function(e){return this.recurse("collect",e)},equals:function(e){return this.normalize().print()===e.normalize().print()},simplify:function(e){e=K.extend({once:!1},e);var t=this.factor(e),n=t.collect(e);t.equals(n)&&(n=this.collect(e));var r=n.expand(e),a=r.collect(e);r.equals(a)&&(a=n.collect(e));var s=a;return e.once||this.equals(s)?s:s.simplify(e)},isSimplified:function(){return this.equals(this.simplify())},exprArgs:function(){return K.filter(this.args(),(function(e){return e instanceof ro}))},getVars:function(e){return K.uniq(K.flatten(K.invoke(this.exprArgs(),"getVars",e))).sort()},getConsts:function(){return K.uniq(K.flatten(K.invoke(this.exprArgs(),"getConsts"))).sort()},getUnits:function(){return K.flatten(K.invoke(this.exprArgs(),"getUnits"))},is:function(e){return this instanceof e},has:function(e){return this instanceof e||K.any(this.exprArgs(),(function(t){return t.has(e)}))},raiseToThe:function(e){return new oo(this,e)},isSubtract:function(){return!1},isDivide:function(){return!1},isRoot:function(){return!1},needsExplicitMul:function(){return this.args()[0].needsExplicitMul()},sameVars:function(e){var t=this.getVars(),n=e.getVars(),r=function(e,t){return!K.difference(e,t).length},a=function(e){return K.uniq(K.invoke(e,"toLowerCase")).sort()};return{equal:r(t,n),equalIgnoringCase:r(a(t),a(n))}},compare:function(e){if(e instanceof ho)return!1;var t=K.union(this.getVars(!0),e.getVars(!0)),n=function(e,t){var n=function(e,t){return Math.abs(e)<1||Math.abs(t)<1?Math.abs(e-t):Math.abs(1-e/t)}(e,t);return e===t||no(e)&&no(t)||n<Math.pow(10,-9)};if(!t.length&&!this.has(xo)&&!e.has(xo))return n(this.eval(),e.eval());var r=this.collect(),a=e.collect(),s=this.getUnits(),i=e.getUnits();if(!K.isEqual(s,i))return!1;for(var o=0;o<12;o++){var l,c={},p=Math.pow(10,1+Math.floor(3*o/12)),h=o%2==0;if(K.each(t,(function(e){var t,n;c[e]=h?(n=p-(t=-p),Math.random()*n+t):K.random(-p,p)})),r.has(mo)||a.has(mo)||r.has(xo)||a.has(xo)){var u=r.partialEval(c),d=a.partialEval(c);l=u.simplify().equals(d.simplify())}else l=n(u=r.eval(c),d=a.eval(c));if(!l)return!1}return!0},partialEval:function(e){return this instanceof xo?this:this.has(mo)?this instanceof mo?new mo(this.symbol,this.arg.partialEval(e)):this.recurse("partialEval",e):new Eo(this.eval(e).toFixed(9)).collect()},sameForm:function(e){return this.strip().equals(e.strip())},findGCD:function(e){return this.equals(e)?e:vo.One},getDenominator:function(){return vo.One},asMul:function(){return new io(vo.One,this)},isPositive:eo,isNegative:function(){return!1},asPositiveFactor:function(){return this.isPositive()?this:vo.One},addHint:function(e){if(!e)return this;var t=this.construct(this.args());return t.hints=K.clone(this.hints),t.hints[e]=!0,t},hints:{parens:!1},asExpr:function(){return this},completeParse:function(){return this.recurse("completeParse")},abs:eo,negate:function(){return new io(vo.Neg,this)}}),ao.prototype=new ro,K.extend(ao.prototype,{args:function(){return this.terms},normalize:function(){var e=K.sortBy(K.invoke(this.terms,"normalize"),(function(e){return e.print()}));return new this.func(e)},expand:function(){return this.recurse("expand").flatten()},partition:function(){var e=K.groupBy(this.terms,(function(e){return e instanceof vo})),t=e[!0]||[],n=e[!1]||[];return[new this.func(t),new this.func(n)]},flatten:function(){var e=this,t=K.reject(this.terms,(function(t){return t.equals(e.identity)}));if(0===t.length)return e.identity;if(1===t.length)return t[0];var n=K.groupBy(t,(function(t){return t instanceof e.func})),r=n[!0]||[],a=(n[!1]||[]).concat(K.flatten(K.pluck(r,"terms"),!0));return new e.func(a)},identity:void 0,reduce:eo,isPositive:function(){var e=K.invoke(this.terms,"collect");return K.all(K.invoke(e,"isPositive"))},replace:function(e,t){var n;n=e instanceof ro?K.indexOf(this.terms,e):e;var r=[];K.isArray(t)?r=t:t&&(r=[t]);var a=this.terms.slice(0,n).concat(r).concat(this.terms.slice(n+1));return new this.func(a)},remove:function(e){return this.replace(e)},getDenominator:function(){return new io(K.invoke(this.terms,"getDenominator")).flatten()}}),so.prototype=new ao,K.extend(so.prototype,{func:so,eval:function(e,t){return K.reduce(this.terms,(function(n,r){return n+r.eval(e,t)}),0)},codegen:function(){return K.map(this.terms,(function(e){return"("+e.codegen()+")"})).join(" + ")||"0"},print:function(){return K.invoke(this.terms,"print").join("+")},tex:function(){var e="";return K.each(this.terms,(function(t){!e||t.isSubtract()?e+=t.tex():e+="+"+t.tex()})),e},collect:function(e){var t=K.invoke(this.terms,"collect",e),n=[];K.each(t,(function(t){if(t instanceof io){var r=t.partition();n.push([r[1].flatten(),r[0].reduce(e)])}else t instanceof vo?n.push([vo.One,t]):n.push([t,vo.One])}));var r=K.groupBy(n,(function(e){return e[0].normalize().print()})),a=K.compact(K.map(r,(function(t){var n=t[0][0];return new io(new so(K.zip.apply(K,t)[1]).reduce(e),n).collect(e)})));return new so(a).flatten()},factor:function(e){e=K.extend({keepNegative:!1},e);var t,n=K.invoke(this.terms,"collect");t=n[0]instanceof io?n[0].terms:[n[0]],K.each(K.rest(this.terms),(function(e){t=K.map(t,(function(t){return e.findGCD(t)}))})),!e.keepNegative&&this.isNegative()&&t.push(vo.Neg),t=new io(t).flatten().collect();var r=K.map(n,(function(e){return io.handleDivide(e,t).simplify()}));return r=new so(r).flatten(),io.createOrAppend(t,r).flatten()},reduce:function(e){return K.reduce(this.terms,(function(t,n){return t.add(n,e)}),this.identity)},needsExplicitMul:function(){return!1},isNegative:function(){var e=K.invoke(this.terms,"collect");return K.all(K.invoke(e,"isNegative"))},negate:function(){return new so(K.invoke(this.terms,"negate"))}}),io.prototype=new ao,K.extend(io.prototype,{func:io,eval:function(e,t){return K.reduce(this.terms,(function(n,r){return n*r.eval(e,t)}),1)},codegen:function(){return K.map(this.terms,(function(e){return"("+e.codegen()+")"})).join(" * ")||"0"},print:function(){return K.map(this.terms,(function(e){return e instanceof so?"("+e.print()+")":e.print()})).join("*")},getUnits:function(){var e=K(this.terms).chain().map((function(e){return e.getUnits()})).flatten().value();return e.sort(((e,t)=>e.unit.localeCompare(t.unit))),e},tex:function(){for(var e,t=" \\cdot ",n=K.groupBy(this.terms,(function(e){return e.isDivide()?"inverse":e instanceof vo?"number":"other"})),r=n.inverse||[],a=n.number||[],s=n.other||[],i="",o=0;o<a.length;o++)if(a[o]instanceof yo&&!(a[o]instanceof bo)&&s.length>0&&r.length>0){var l=a.slice();l.splice(o,1);var c=l.concat(r).concat(s);return a[o].tex()+new io(c).tex()}if(0===(a=K.compact(K.map(a,(function(e){var t=e instanceof yo&&!(e instanceof bo),n=!e.hints.fraction||r.length>0;if(t&&n){r.push(new oo(new bo(e.d),vo.Div));var a=new bo(e.n);return a.hints=e.hints,K.any(e.hints)?a:null}return e})))).length&&1===s.length)e=s[0].tex();else{var p="";K.each(a,(function(e){e.hints.subtract&&e.hints.entered?(i+="-",p+=(p?t:"")+e.abs().tex()):e instanceof bo&&-1===e.n&&(e.hints.negate||e.hints.subtract)?i+="-":p+=(p?t:"")+e.tex()})),K.each(s,(function(e){e.needsExplicitMul()?p+=(p?t:"")+e.tex():p+=e instanceof so?"("+e.tex()+")":e.tex()})),e=p||"1"}if(r.length){var h=new io(K.invoke(r,"asDivide")).flatten().tex();return i+"\\frac{"+e+"}{"+h+"}"}return i+e},strip:function(){return new io(K.map(this.terms,(function(e){return e instanceof vo?e.abs():e.strip()}))).flatten()},expand:function(){var e=function(e){return e instanceof so},t=function(e){return e instanceof oo&&e.exp.isNegative()},n=this.recurse("expand").flatten(),r=K.any(n.terms,e),a=K.any(n.terms,(function(n){return t(n)&&e(n.base)}));if(!r&&!a)return n;var s=K.groupBy(n.terms,t),i=s[!1]||[],o=s[!0]||[];if(r){var l=K.groupBy(i,e),c=l[!0]||[],p=l[!1]||[],h=K.reduce(c,(function(e,t){return K.reduce(e,(function(e,n){return e.concat(K.map(t.terms,(function(e){return n.concat(e)})))}),[])}),[[]]);i=[new so(K.map(h,(function(e){return new io(p.concat(e)).flatten()})))]}return a&&(o=[new oo(new io(K.invoke(o,"getDenominator")).flatten().expand(),vo.Div)]),new io(i.concat(o)).flatten()},factor:function(e){var t=this.recurse("factor",e).flatten();if(!(t instanceof io))return t;var n=K.groupBy(t.terms,(function(e){return e instanceof yo})),r=K.reduce(n[!0],(function(e,t){return{n:e.n*t.n,d:e.d*t.d}}),{n:1,d:1});return r=1===r.d?new bo(r.n):new yo(r.n,r.d),new io((n[!1]||[]).concat(r)).flatten()},collect:function(e){var t=this.recurse("collect",e).partition(),n=t[0].reduce(e);if(0===n.eval())return vo.Zero;var r=t[1].flatten();if(!(r instanceof io))return new io(n,r).flatten();r=r.terms;var a=[];K.each(r,(function(e){e instanceof oo?a.push([e.base,e.exp]):a.push([e,vo.One])}));var s=K.groupBy(a,(function(e){return e[0].normalize().print()})),i=K.compact(K.map(s,(function(t){var n=t[0][0],r=new so(K.zip.apply(K,t)[1]).collect(e);return r instanceof vo&&0===r.eval()?null:[n,r]}))),o=(a=K.groupBy(i,(function(e){return e[0]instanceof co&&e[0].isBasic()?"trig":e[0]instanceof lo?"log":"expr"}))).trig||[],l=a.log||[],c=a.expr||[];if(o.length>1){var p=K.groupBy(o,(function(e){return e[0].arg.normalize().print()}));o=[],K.each(p,(function(t){var n=t[0][0].arg,r={sin:vo.Zero,cos:vo.Zero};K.each(t,(function(e){r[e[0].type]=e[1]})),io.handleNegative(r.sin).collect(e).equals(r.cos)&&(r=r.cos.isNegative()?{tan:r.sin}:{cot:r.cos}),K.each(r,(function(e,t){o.push([new co(t,n),e])}))}))}if(l.length>1){var h=K.groupBy(l,(function(e){return e[0].base.normalize().print()}));l=[],K.each(h,(function(t){2===t.length&&io.handleNegative(t[0][1]).collect(e).equals(t[1][1])?t[0][1].isNegative()?l.push([new lo(t[0][0].power,t[1][0].power),t[1][1]]):l.push([new lo(t[1][0].power,t[0][0].power),t[0][1]]):l=l.concat(t)}))}a=o.concat(l).concat(c);var u=K.map(a,(function(t){return new oo(t[0],t[1]).collect(e)}));return new io([n].concat(u)).flatten()},isSubtract:function(){return K.any(this.terms,(function(e){return e instanceof vo&&e.hints.subtract}))},factorIn:function(e){var t=this.partition()[0].terms,n=t.length&&K.all(t,(function(e){return e.n>0}));if(n){var r=t[0].negate();return r.hints=t[0].hints,this.replace(t[0],r.addHint(e))}return new io([vo.negativeOne(e)].concat(this.terms))},factorOut:function(){var e=!1,t=K.compact(K.map(this.terms,(function(t,n,r){return!e&&t instanceof vo&&t.hints.divide?(e=!0,-1!==t.n?t.negate():null):t})));return 1===t.length?t[0]:new io(t)},reduce:function(e){return K.reduce(this.terms,(function(t,n){return t.mul(n,e)}),this.identity)},findGCD:function(e){return new io(K.invoke(this.terms,"findGCD",e)).flatten()},asMul:function(){return this},asPositiveFactor:function(){return this.isPositive()?this:new io(K.invoke(this.collect().terms,"asPositiveFactor")).flatten()},isNegative:function(){return K.any(K.invoke(this.collect().terms,"isNegative"))},fold:function(){return io.fold(this)},negate:function(){var e=function(e){return e instanceof vo};if(K.any(this.terms,e)){var t=K.find(this.terms,e);return this.replace(t,t.negate())}return new io([vo.Neg].concat(this.terms))}}),K.each([so,io],(function(e){K.extend(e,{createOrAppend:function(t,n){return t instanceof e?new e(t.terms.concat(n)):new e(t,n)}})})),K.extend(io,{handleNegative:function(e,t){if(e instanceof vo&&e.n>0){var n=e.negate();return n.hints=e.hints,n.addHint(t)}return e instanceof io?e.factorIn(t):new io(vo.negativeOne(t),e)},handleDivide:function(e,t){if(t instanceof io){var n=io.handleDivide(e,t.terms[0]),r=new io(K.rest(t.terms)).flatten();return io.handleDivide(n,r)}var a=function(e){return e instanceof bo};if(a(t)&&e instanceof io&&K.any(e.terms,a)){var s=e.terms.slice().reverse(),i=K.find(s,(function(e){return e instanceof yo}));if(!a(i))return new io(e.terms.concat([new yo(1,t.n).addHint("fraction")]));var o=new yo(i.n,t.n);return o.hints=i.hints,i===s[0]&&(o=o.addHint("fraction")),i.n<0&&t.n<0?(o.d=-o.d,e.replace(i,[vo.Neg,o])):e.replace(i,o)}var l=function(e,t){if(t instanceof bo){if(e instanceof bo)return e.n<0&&t.n<0?[vo.Neg,new yo(e.n,-t.n).addHint("fraction")]:[new yo(e.n,t.n).addHint("fraction")];var n=new yo(1,t.eval());return t.eval()<0?[e,n.addHint("negate")]:[e,n]}var r;if(t instanceof co&&t.exp){var a=t.exp;t.exp=void 0,t=new oo(t,a)}return r=t instanceof oo?new oo(t.base,io.handleNegative(t.exp,"divide")):new oo(t,vo.Div),e instanceof bo&&1===e.n?[r]:[e,r]};if(e instanceof io){var c=l(K.last(e.terms),t);return new io(K.initial(e.terms).concat(c))}return new io(c=l(e,t)).flatten()},fold:function(e){if(e instanceof io){var t=K.find(K.initial(e.terms),(function(e){return(e instanceof co||e instanceof lo)&&e.hints.open})),n=K.indexOf(e.terms,t);if(t){var r,a=K.last(e.terms);if(!(t.hints.parens||a.hints.parens||a.has(co)||a.has(lo)))return r=t instanceof co?co.create([t.type,t.exp],io.createOrAppend(t.arg,a).fold()):lo.create(t.base,io.createOrAppend(t.power,a).fold()),0===n?r:new io(e.terms.slice(0,n).concat(r)).fold();t.hints.open=!1}var s=e.partition()[0].terms,i=function(e){return e.n>0},o=function(e){return-1===e.n&&e.hints.negate};if(s.length>1&&K.some(s,o)&&K.some(s,i)&&K.every(s,(function(e){return i(e)||o(e)}))){var l=K.indexOf(e.terms,K.find(e.terms,o)),c=K.indexOf(e.terms,K.find(e.terms,i));if(l<c)return e.replace(c,e.terms[c].negate()).remove(l)}}return e}}),oo.prototype=new ro,K.extend(oo.prototype,{func:oo,args:function(){return[this.base,this.exp]},eval:function(e,t){var n=this.base.eval(e,t),r=this.exp.eval(e,t);if(n<0){var a=this.exp.simplify();if(a instanceof Eo){var s=a.n,i=(s-s.toFixed()).toString().length-2,o=Math.pow(10,i);a=new yo(s*o,o).simplify()}if(a instanceof yo&&Math.abs(a.d)%2==1)return(Math.abs(a.n)%2==1?-1:1)*Math.pow(-1*n,r)}return Math.pow(n,r)},getUnits:function(){return this.base.getUnits().map(function(e){return{unit:e.unit,pow:e.pow*this.exp.n}}.bind(this))},codegen:function(){return"Math.pow("+this.base.codegen()+", "+this.exp.codegen()+")"},print:function(){var e=this.base.print();return(this.base instanceof ao||this.base instanceof oo)&&(e="("+e+")"),e+"^("+this.exp.print()+")"},tex:function(){if(this.isDivide())return"\\frac{1}{"+this.asDivide().tex()+"}";if(this.isRoot())return 1!==this.exp.n&&to("Node marked with hint 'root' does not have exponent of form 1/x."),2===this.exp.d?"\\sqrt{"+this.base.tex()+"}":"\\sqrt["+this.exp.d+"]{"+this.base.tex()+"}";if(this.base instanceof co&&!this.base.isInverse()&&this.exp instanceof vo&&this.exp.isSimple()&&this.exp.eval()>=0){var e=this.base.tex({split:!0});return e[0]+"^{"+this.exp.tex()+"}"+e[1]}var t=this.base.tex();return this.base instanceof ao||this.base instanceof oo||this.base instanceof vo&&!this.base.isSimple()?t="("+t+")":(this.base instanceof co||this.base instanceof lo)&&(t="["+t+"]"),t+"^{"+this.exp.tex()+"}"},needsExplicitMul:function(){return!this.isRoot()&&this.base.needsExplicitMul()},expand:function(){var e=this.recurse("expand");if(e.base instanceof io)return new io(K.map(e.base.terms,(function(t){return new oo(t,e.exp)}))).expand();if(e.base instanceof so&&e.exp instanceof bo&&e.exp.abs().eval()>1){for(var t=e.exp.eval()>0,n=e.exp.abs().eval(),r=function(e){return t?e:new oo(e,vo.Div)},a={1:e.base},s=2;s<=n;s*=2){var i=new io(a[s/2],a[s/2]);a[s]=i.expand().collect()}if(K.has(a,n))return r(a[n]);var o=K.map(n.toString(2).split(""),(function(e,t,n){return Number(e)*Math.pow(2,n.length-t-1)}));return o=K.without(o,0),r(i=new io(K.pick(a,o)).expand().collect())}return e.exp instanceof so?new io(K.map(e.exp.terms,(function(t){return new oo(e.base,t).expand()}))).expand():e},factor:function(){var e=this.recurse("factor");return e.base instanceof io?new io(K.map(e.base.terms,(function(t){return t instanceof bo&&e.exp.equals(vo.Div)?new yo(1,t.n):new oo(t,e.exp)}))):e},collect:function(e){if(this.base instanceof oo)return new oo(this.base.base,a=io.createOrAppend(this.base.exp,this.exp)).collect(e);var t=this.recurse("collect",e),n=function(e){return e instanceof lo&&e.base.equals(t.base)};if(t.exp instanceof vo&&0===t.exp.eval())return vo.One;if(t.exp instanceof vo&&1===t.exp.eval())return t.base;if(n(t.exp))return t.exp.power;if(t.exp instanceof io&&K.any(t.exp.terms,n)){var r=K.find(t.exp.terms,n);return new oo(r.power,a=t.exp.remove(r).flatten()).collect(e)}if(t.base instanceof vo&&t.exp instanceof vo){if(e&&e.preciseFloats){var a=t.exp.asRational(),s=t.base.getDecimalPlaces();if(new oo(t.base,new yo(1,a.d)).collect().getDecimalPlaces()>s){var i=new oo(t.base,new bo(a.n)).collect();return new oo(i,new yo(1,a.d))}}return t.base.raiseToThe(t.exp,e)}return t},isDivide:function(){var e=function(e){return e instanceof vo&&e.hints.divide};return e(this.exp)||this.exp instanceof io&&K.any(this.exp.terms,e)},asDivide:function(){if(this.exp instanceof vo){if(-1===this.exp.eval())return this.base;var e=this.exp.negate();return e.hints=K.clone(this.exp.hints),e.hints.divide=!1,new oo(this.base,e)}if(this.exp instanceof io)return new oo(this.base,this.exp.factorOut());to("called asDivide() on an Expr that wasn't a Num or Mul")},isRoot:function(){return this.exp instanceof yo&&this.exp.hints.root},isSquaredTrig:function(){return this.base instanceof co&&!this.base.isInverse()&&this.exp instanceof vo&&2===this.exp.eval()},getDenominator:function(){if(this.exp instanceof vo&&-1===this.exp.eval())return io.createOrAppend(this.base,this.base.getDenominator()).flatten();if(this.exp.isNegative()){var e=new oo(this.base,io.handleNegative(this.exp).collect());return io.createOrAppend(e,e.collect().getDenominator()).flatten()}return this.base instanceof vo?new oo(this.base.getDenominator(),this.exp).collect():vo.One},findGCD:function(e){var t,n;if(e instanceof oo?(t=e.base,n=e.exp):(t=e,n=vo.One),this.base.equals(t)){if(this.exp.equals(n))return this;if(this.exp instanceof vo&&n instanceof vo)return new oo(this.base,vo.min(this.exp,n)).collect();if(this.exp instanceof vo||n instanceof vo)return vo.One;var r=this.exp.asMul().partition(),a=n.asMul().partition();if(r[1].equals(a[1]))return new oo(t,new io(vo.min(r[0].reduce(),a[0].reduce()),r[1].flatten()).flatten()).collect()}return vo.One},isPositive:function(){if(this.base.isPositive())return!0;var e=this.exp.simplify();return e instanceof bo&&e.eval()%2==0},asPositiveFactor:function(){if(this.isPositive())return this;var e=this.exp.simplify();if(e instanceof bo){var t=e.eval();if(t>2)return new oo(this.base,new bo(t-1));if(t<-2)return new oo(this.base,new bo(t+1))}return vo.One}}),K.extend(oo,{sqrt:function(e){return new oo(e,vo.Sqrt)},nthroot:function(e,t){return new oo(e,io.fold(io.handleDivide(new bo(1),t)).addHint("root"))}}),lo.prototype=new ro,K.extend(lo.prototype,{func:lo,args:function(){return[this.base,this.power]},eval:function(e,t){return Math.log(this.power.eval(e,t))/Math.log(this.base.eval(e,t))},codegen:function(){return"(Math.log("+this.power.codegen()+") / Math.log("+this.base.codegen()+"))"},print:function(){var e="("+this.power.print()+")";return this.isNatural()?"ln"+e:"log_("+this.base.print()+") "+e},tex:function(){var e="("+this.power.tex()+")";return this.isNatural()?"\\ln"+e:"\\log_{"+this.base.tex()+"}"+e},collect:function(e){var t=this.recurse("collect",e);return t.power instanceof vo&&1===t.power.eval()?vo.Zero:t.base.equals(t.power)?vo.One:t.power instanceof oo&&t.power.base.equals(t.base)?t.power.exp:t},expand:function(){var e=this.recurse("expand");return e.power instanceof io?new so(K.map(e.power.terms,(function(t){return new lo(e.base,t).expand()}))):e.power instanceof oo?new io(e.power.exp,new lo(e.base,e.power.base).expand()).flatten():e.isNatural()?e:io.handleDivide(new lo(fo.e,e.power),new lo(fo.e,e.base))},hints:K.extend(lo.prototype.hints,{open:!1}),isPositive:function(){var e=this.collect();return e.base instanceof vo&&e.power instanceof vo&&this.eval()>0},needsExplicitMul:function(){return!1},isNatural:function(){return this.base.equals(fo.e)}}),K.extend(lo,{natural:function(){return fo.e},common:function(){return vo.Ten},create:function(e,t){var n=new lo(e,t);return t.hints.parens||(n=n.addHint("open")),n}}),co.prototype=new ro,K.extend(co.prototype,{func:co,args:function(){return[this.type,this.arg]},functions:{sin:{eval:Math.sin,codegen:"Math.sin((",tex:"\\sin",expand:function(){return this}},cos:{eval:Math.cos,codegen:"Math.cos((",tex:"\\cos",expand:function(){return this}},tan:{eval:Math.tan,codegen:"Math.tan((",tex:"\\tan",expand:function(){return io.handleDivide(co.sin(this.arg),co.cos(this.arg))}},csc:{eval:function(e){return 1/Math.sin(e)},codegen:"(1/Math.sin(",tex:"\\csc",expand:function(){return io.handleDivide(vo.One,co.sin(this.arg))}},sec:{eval:function(e){return 1/Math.cos(e)},codegen:"(1/Math.cos(",tex:"\\sec",expand:function(){return io.handleDivide(vo.One,co.cos(this.arg))}},cot:{eval:function(e){return 1/Math.tan(e)},codegen:"(1/Math.tan(",tex:"\\cot",expand:function(){return io.handleDivide(co.cos(this.arg),co.sin(this.arg))}},arcsin:{eval:Math.asin,codegen:"Math.asin((",tex:"\\arcsin"},arccos:{eval:Math.acos,codegen:"Math.acos((",tex:"\\arccos"},arctan:{eval:Math.atan,codegen:"Math.atan((",tex:"\\arctan"},arccsc:{eval:function(e){return Math.asin(1/e)},codegen:"Math.asin(1/(",tex:"\\operatorname{arccsc}"},arcsec:{eval:function(e){return Math.acos(1/e)},codegen:"Math.acos(1/(",tex:"\\operatorname{arcsec}"},arccot:{eval:function(e){return Math.atan(1/e)},codegen:"Math.atan(1/(",tex:"\\operatorname{arccot}"},sinh:{eval:function(e){return(Math.exp(e)-Math.exp(-e))/2},codegen:function(e){return"((Math.exp("+e+") - Math.exp(-("+e+"))) / 2)"},tex:"\\sinh",expand:function(){return this}},cosh:{eval:function(e){return(Math.exp(e)+Math.exp(-e))/2},codegen:function(e){return"((Math.exp("+e+") + Math.exp(-("+e+"))) / 2)"},tex:"\\cosh",expand:function(){return this}},tanh:{eval:function(e){return(Math.exp(e)-Math.exp(-e))/(Math.exp(e)+Math.exp(-e))},codegen:function(e){return"((Math.exp("+e+") - Math.exp(-("+e+"))) / (Math.exp("+e+") + Math.exp(-("+e+"))))"},tex:"\\tanh",expand:function(){return io.handleDivide(co.sinh(this.arg),co.cosh(this.arg))}},csch:{eval:function(e){return 2/(Math.exp(e)-Math.exp(-e))},codegen:function(e){return"(2 / (Math.exp("+e+") - Math.exp(-("+e+"))))"},tex:"\\csch",expand:function(){return io.handleDivide(vo.One,co.sinh(this.arg))}},sech:{eval:function(e){return 2/(Math.exp(e)+Math.exp(-e))},codegen:function(e){return"(2 / (Math.exp("+e+") + Math.exp(-("+e+"))))"},tex:"\\sech",expand:function(){return io.handleDivide(vo.One,co.cosh(this.arg))}},coth:{eval:function(e){return(Math.exp(e)+Math.exp(-e))/(Math.exp(e)-Math.exp(-e))},codegen:function(e){return"((Math.exp("+e+") + Math.exp(-("+e+"))) / (Math.exp("+e+") - Math.exp(-("+e+"))))"},tex:"\\coth",expand:function(){return io.handleDivide(co.cosh(this.arg),co.sinh(this.arg))}}},isEven:function(){return K.contains(["cos","sec"],this.type)},isInverse:function(){return 0===this.type.indexOf("arc")},isBasic:function(){return K.contains(["sin","cos"],this.type)},eval:function(e,t){return(0,this.functions[this.type].eval)(this.arg.eval(e,t))},codegen:function(){var e=this.functions[this.type].codegen;if("function"==typeof e)return e(this.arg.codegen());if("string"==typeof e)return e+this.arg.codegen()+"))";throw new Error("codegen not implemented for "+this.type)},print:function(){return this.type+"("+this.arg.print()+")"},tex:function(e){var t=this.functions[this.type].tex,n="("+this.arg.tex()+")";return e&&e.split?[t,n]:t+n},hints:K.extend(co.prototype.hints,{open:!1}),isPositive:function(){return this.collect().arg instanceof vo&&this.eval()>0},completeParse:function(){if(this.exp){var e=new oo(this,this.exp);return this.exp=void 0,e}return this},needsExplicitMul:function(){return!1},expand:function(){var e=this.recurse("expand");if(e.isInverse())return e;var t=e.functions[e.type].expand;return K.bind(t,e)()},collect:function(e){var t,n=this.recurse("collect",e);return!n.isInverse()&&n.arg.isNegative()?(t=n.arg instanceof vo?n.arg.abs():io.handleDivide(n.arg,vo.Neg).collect(e),n.isEven()?new co(n.type,t):new io(vo.Neg,new co(n.type,t))):n}}),K.extend(co,{create:function(e,t){var n=e[0],r=e[1];r&&r.equals(vo.Neg)&&(n="arc"+n,r=void 0);var a=new co(n,t);return t.hints.parens||(a=a.addHint("open")),r&&(a.exp=r),a},sin:function(e){return new co("sin",e)},cos:function(e){return new co("cos",e)},sinh:function(e){return new co("sinh",e)},cosh:function(e){return new co("cosh",e)}}),po.prototype=new ro,K.extend(po.prototype,{func:po,args:function(){return[this.arg]},eval:function(e,t){return Math.abs(this.arg.eval(e,t))},codegen:function(){return"Math.abs("+this.arg.codegen()+")"},print:function(){return"abs("+this.arg.print()+")"},tex:function(){return"\\left|"+this.arg.tex()+"\\right|"},collect:function(e){var t=this.recurse("collect",e);if(t.arg.isPositive())return t.arg;if(t.arg instanceof vo)return t.arg.abs();if(t.arg instanceof io){var n=K.groupBy(t.arg.terms,(function(e){return e.isPositive()?"positive":e instanceof vo?"number":"other"})),r=n.positive.concat(K.invoke(n.number,"abs"));return n.other.length&&r.push(new po(new io(n.other).flatten())),new io(r).flatten()}return t},expand:function(){var e=this.recurse("expand");return e.arg instanceof io?new io(K.map(e.arg.terms,(function(e){return new po(e)}))):e},isPositive:function(){return!0}}),ho.prototype=new ro,K.extend(ho.prototype,{func:ho,args:function(){return[this.left,this.type,this.right]},needsExplicitMul:function(){return!1},print:function(){return this.left.print()+this.type+this.right.print()},signs:{"=":" = ","<":" < ",">":" > ","<>":" \\ne ","<=":" \\le ",">=":" \\ge "},tex:function(){return this.left.tex()+this.signs[this.type]+this.right.tex()},normalize:function(){var e=this.recurse("normalize");return K.contains([">",">="],e.type)?new ho(e.right,e.type.replace(">","<"),e.left):e},asExpr:function(e){var t=function(e){return e instanceof vo&&e.isSimple()&&0===e.eval()},n=[];this.left instanceof so?n=K.clone(this.left.terms):t(this.left)||(n=[this.left]),this.right instanceof so?n=n.concat(this.right.negate().terms):t(this.right)||n.push(this.right.negate());var r=!this.isEquality();n=K.invoke(n,"collect",{preciseFloats:!0});for(var a=0;a<n.length;a++){var s=n[a].getDenominator();r&&!s.isPositive()&&(s=s.asPositiveFactor()),s.equals(vo.One)||(n=K.map(n,(function(e){return io.createOrAppend(e,s).simplify({once:!0,preciseFloats:!0})})))}var i=new so(n).flatten();return e?i:this.divideThrough(i)},divideThrough:function(e){var t=!this.isEquality(),n=e.simplify({once:!0}),r=n.factor({keepNegative:t});if(!(r instanceof io))return e;var a=r.terms,s=K.groupBy(a,(function(e){return e instanceof so})),i=s[!0]||[],o=s[!1]||[];if(i.length&&this.isEquality())return new io(i).flatten();var l=o;i.length||(l=K.reject(l,(function(e){return!!e.getVars().length}))),t&&(l=K.invoke(l,"asPositiveFactor")),l=K.reject(l,(function(e){return e.equals(vo.One)})),l=K.map(l,(function(e){return new oo(e,vo.Div)}));var c=new io(a.concat(l)).collect();return c.equals(r)?n:c},isEquality:function(){return K.contains(["=","<>"],this.type)},compare:function(e){if(!(e instanceof ho))return!1;var t=this.normalize(),n=e.normalize();if(t.type!==n.type)return!1;var r=t.divideThrough(t.asExpr(!0).collect()),a=n.divideThrough(n.asExpr(!0).collect());return t.isEquality()?r.compare(a)||r.compare(io.handleNegative(a)):r.compare(a)},sameForm:function(e){var t=this.normalize(),n=e.normalize(),r=t.left.sameForm(n.left)&&t.right.sameForm(n.right);return t.isEquality()?r||t.left.sameForm(n.right)&&t.right.sameForm(n.left):r},isSimplified:function(){var e=this.asExpr(!0),t=this.divideThrough(e).simplify();return e.equals(t)&&this.left.isSimplified()&&this.right.isSimplified()}}),K.extend(ho.prototype,{solveLinearEquationForVariable:function(e){var t,n,r,a=this.asExpr();if(!a.is(so)||2!==a.terms.length)throw new Error("Can only handle linear equations of the form a + bx (= 0)");return(r=a.terms[0]).has(go)&&K.contains(r.getVars(),e.symbol)?(t=io.handleNegative(a.terms[1]),n=io.handleDivide(a.terms[0],e)):(t=io.handleNegative(a.terms[0]),n=io.handleDivide(a.terms[1],e)),io.handleDivide(t,n).simplify()}}),uo.prototype=new ro,K.extend(uo.prototype,{needsExplicitMul:function(){return!1},findGCD:function(e){return e instanceof uo||e instanceof vo?this.equals(e)?this:vo.One:e.findGCD(this)}}),mo.prototype=new uo,K.extend(mo.prototype,{func:mo,args:function(){return[this.symbol,this.arg]},print:function(){return this.symbol+"("+this.arg.print()+")"},tex:function(){return this.symbol+"("+this.arg.tex()+")"},eval:function(e,t){var n=this.arg,r=e[this.symbol],a=K.extend(K.clone(e),{x:n.eval(e,t)}),s=wo(r,t);return s.parsed?s.expr.eval(a,t):s},codegen:function(){return'vars["'+this.symbol+'"]('+this.arg.codegen()+")"},getUnits:function(){return this.arg.getUnits()},getVars:function(e){return e?this.arg.getVars():K.union(this.arg.getVars(),[this.symbol]).sort()},getConsts:function(){return this.arg.getConsts()}}),go.prototype=new uo,K.extend(go.prototype,{func:go,args:function(){return[this.symbol,this.subscript]},exprArgs:function(){return[]},recurse:function(){return this},print:function(){var e="";return this.subscript&&(e="_("+this.subscript.print()+")"),this.symbol+e},prettyPrint:function(){var e=this.subscript;return e&&(e instanceof vo||e instanceof uo)?this.symbol+"_"+e.print():this.print()},tex:function(){var e="";return this.subscript&&(e="_{"+this.subscript.tex()+"}"),(this.symbol.length>1?"\\":"")+this.symbol+e},repr:function(){return"Var("+this.print()+")"},eval:function(e,t){return e[this.prettyPrint()]},codegen:function(){return'vars["'+this.prettyPrint()+'"]'},getVars:function(){return[this.prettyPrint()]},isPositive:function(){return!1}}),fo.prototype=new uo,K.extend(fo.prototype,{func:fo,args:function(){return[this.symbol]},recurse:function(){return this},eval:function(e,t){return"pi"===this.symbol?Math.PI:"e"===this.symbol?Math.E:void 0},codegen:function(){return"pi"===this.symbol?"Math.PI":"e"===this.symbol?"Math.E":void 0},print:function(){return this.symbol},tex:function(){return"pi"===this.symbol?"\\pi ":"e"===this.symbol?"e":void 0},isPositive:function(){return this.eval()>0},abs:function(){return this.eval()>0?this:io.handleNegative(this)},getConsts:function(){return[this.print()]}}),fo.e=new fo("e"),fo.pi=new fo("pi"),vo.prototype=new ro,K.extend(vo.prototype,{repr:function(){return this.print()},strip:function(){return this.abs()},recurse:function(){return this},codegen:function(){return this.print()},add:eo,mul:eo,negate:eo,isSubtract:function(){return this.hints.subtract},abs:eo,needsExplicitMul:function(){return!0},findGCD:eo,isPositive:function(){return this.eval()>0},isNegative:function(){return this.eval()<0},asPositiveFactor:function(){return this.isPositive()?this:this.abs()},hints:K.extend(vo.prototype.hints,{negate:!1,subtract:!1,divide:!1,root:!1,fraction:!1,entered:!1}),isSimple:eo,getDecimalPlaces:function(){var e=(""+this.n).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return e?Math.max(0,(e[1]?e[1].length:0)-(e[2]?+e[2]:0)):0},asRational:eo}),yo.prototype=new vo,K.extend(yo.prototype,{func:yo,args:function(){return[this.n,this.d]},eval:function(){return this.n/this.d},print:function(){return this.n.toString()+"/"+this.d.toString()},tex:function(){var e="\\frac{"+Math.abs(this.n).toString()+"}{"+this.d.toString()+"}";return this.n<0?"-"+e:e},add:function(e,t){return e instanceof yo?new yo(this.n*e.d+this.d*e.n,this.d*e.d).collect():e.add(this,t)},mul:function(e,t){return e instanceof yo?new yo(this.n*e.n,this.d*e.d).collect():e.mul(this,t)},collect:function(){var e=vo.findGCD(this.n,this.d),t=this.n/e,n=this.d/e;return 1===n?new bo(t):new yo(t,n)},negate:function(){return new yo(-this.n,this.d)},abs:function(){return new yo(Math.abs(this.n),this.d)},findGCD:function(e){return e instanceof yo?new yo(vo.findGCD(this.n*e.d,e.n*this.d),this.d*e.d).collect():e instanceof bo?new yo(vo.findGCD(this.n,e.n),this.d):e.findGCD(this)},raiseToThe:function(e){if(e instanceof bo){var t=e.eval()>0,n=e.abs().eval(),r=Math.pow(this.n,n),a=Math.pow(this.d,n);return t?new yo(r,a).collect():new yo(a,r).collect()}return new Eo(this.eval()).raiseToThe(e)},getDenominator:function(){return new bo(this.d)},isSimple:function(){return!1},asRational:function(){return this}}),bo.prototype=new yo(0,1),K.extend(bo.prototype,{func:bo,args:function(){return[this.n]},print:function(){return this.n.toString()},tex:function(){return this.n.toString()},negate:function(){return new bo(-this.n)},abs:function(){return new bo(Math.abs(this.n))},isSimple:function(){return!0},findGCD:function(e){return e instanceof bo?new bo(vo.findGCD(this.n,e.n)):e.findGCD(this)}}),K.extend(bo,{create:function(e){return new bo(e).addHint("entered")}}),Eo.prototype=new vo,K.extend(Eo.prototype,{func:Eo,args:function(){return[this.n]},eval:function(){return this.n},print:function(){return this.n.toString()},tex:function(){return this.n.toString()},add:function(e,t){return t&&t.preciseFloats?Eo.toDecimalPlaces(this.n+e.eval(),Math.max(this.getDecimalPlaces(),e.getDecimalPlaces())):new Eo(this.n+e.eval()).collect()},mul:function(e,t){return t&&t.preciseFloats?Eo.toDecimalPlaces(this.n*e.eval(),this.getDecimalPlaces()+e.getDecimalPlaces()):new Eo(this.n*e.eval()).collect()},collect:function(){return this},negate:function(){return new Eo(-this.n)},abs:function(){return new Eo(Math.abs(this.n))},findGCD:function(e){return e instanceof vo?new Eo(vo.findGCD(this.eval(),e.eval())).collect():e.findGCD(this)},raiseToThe:function(e,t){return t&&t.preciseFloats&&e instanceof bo&&e.n>1?Eo.toDecimalPlaces(new oo(this,e).eval(),this.getDecimalPlaces()*e.n):new Eo(new oo(this,e).eval()).collect()},asRational:function(){var e=this.n.toString().split(".");return 1===e.length?new yo(this.n,1):new yo(Number(e.join("")),Math.pow(10,e[1].length)).collect()},getDenominator:function(){return this.asRational().getDenominator()},isSimple:function(){return!0}}),K.extend(Eo,{create:function(e){return new Eo(e).addHint("entered")},toDecimalPlaces:function(e,t){return new Eo(+e.toFixed(Math.min(t,20))).collect()}}),K.extend(vo,{negativeOne:function(e){return"subtract"===e?vo.Sub:"divide"===e?vo.Div:vo.Neg},findGCD:function(e,t){var n;if(e=Math.abs(e),t=Math.abs(t),e!==Math.floor(e)||t!==Math.floor(t))return 1;for(;t;)n=e%t,e=t,t=n;return e},min:function(){return K.min(K.toArray(arguments),(function(e){return e.eval()}))},max:function(){return K.max(K.toArray(arguments),(function(e){return e.eval()}))}}),vo.Neg=new bo(-1).addHint("negate"),vo.Sub=new bo(-1).addHint("subtract"),vo.Div=new bo(-1).addHint("divide"),vo.Sqrt=new yo(1,2).addHint("root"),vo.Zero=new bo(0),vo.One=new bo(1),vo.Ten=new bo(10),so.prototype.identity=vo.Zero,io.prototype.identity=vo.One,Qi.yy={Add:so,Mul:io,Pow:oo,Log:lo,Trig:co,Eq:ho,Abs:po,Func:mo,Const:fo,Var:go,Int:bo,Float:Eo,parseError:function(e,t){throw new Error(t.loc.first_column)},constants:["e"],symbolLexer:function(e){return K.contains(Qi.yy.constants,e)?"CONST":K.contains(Qi.yy.functions,e)?"FUNC":"VAR"}};var wo=function(e,t){try{return t&&t.functions?Qi.yy.functions=K.without(t.functions,"i"):Qi.yy.functions=[],t&&t.decimal_separator&&(e=e.split(t.decimal_separator).join(".")),{parsed:!0,expr:Qi.parse(e).completeParse()}}catch(e){return{parsed:!1,error:e.message}}};function xo(e){this.symbol=e}xo.prototype=new uo;var Co=function(e){if(K(So).has(e)||K(Mo).has(e))return new xo(e);var t=K(K(No).keys()).find((function(t){return new RegExp("^"+t).test(e)}));if(t){var n=e.replace(new RegExp("^"+t),"");if(K(So).has(n)||Mo[n]&&Mo[n].prefixes===To)return new io(No[t],new xo(n));throw new Error(n+" does not allow prefixes")}return new xo(e)},ko=function(e){try{var t=Zi.parse(e),n=[];K(t.unit.num).each((function(e){n.push(new oo(Co(e.name),new bo(e.pow)))})),K(t.unit.denom).each((function(e){n.push(new oo(Co(e.name),new bo(-1*e.pow)))}));var r=new io(n).flatten();return"unitMagnitude"===t.type?{parsed:!0,unit:r,expr:new io([new Eo(+t.magnitude)].concat(n)),coefficient:t.magnitude,type:t.type}:{parsed:!0,unit:r,type:t.type}}catch(e){return{parsed:!1,error:e.message}}};K.extend(xo.prototype,{func:xo,args:function(){return[this.symbol]},recurse:function(){return this},eval:function(e,t){return 1},getUnits:function(){return[{unit:this.symbol,pow:1}]},codegen:function(){return"1"},print:function(){return this.symbol},tex:function(){return this.symbol},collect:function(e){if(K(So).has(this.symbol))return this;if(K(Mo).has(this.symbol))return Mo[this.symbol].conversion;throw new Error("could not understand unit: "+this.symbol)}});var So={m:new xo("m"),g:new xo("g"),s:new xo("s"),A:new xo("A"),K:new xo("K"),mol:new xo("mol"),cd:new xo("cd")},No={a:new oo(new bo(10),new bo(-18)),f:new oo(new bo(10),new bo(-15)),p:new oo(new bo(10),new bo(-12)),n:new oo(new bo(10),new bo(-9)),u:new oo(new bo(10),new bo(-6)),m:new oo(new bo(10),new bo(-3)),c:new oo(new bo(10),new bo(-2)),d:new oo(new bo(10),new bo(-1)),da:new bo(10),h:new oo(new bo(10),new bo(2)),k:new oo(new bo(10),new bo(3)),M:new oo(new bo(10),new bo(6)),G:new oo(new bo(10),new bo(9)),T:new oo(new bo(10),new bo(12)),P:new oo(new bo(10),new bo(15)),E:new oo(new bo(10),new bo(18)),hella:new oo(new bo(10),new bo(27))},To={},_o={},Oo=function(e,t){var n=e.split("|"),r=n[0].trim(),a=n[1].trim(),s=vo.One;""!==r&&(s=wo(r).expr);var i=a.split("/"),o=[s];return i[0]&&i[0].split(" ").filter((function(e){return""!==e})).map((function(e){o.push(new xo(e))})),i[1]&&i[1].split(" ").filter((function(e){return""!==e})).map((function(e){o.push(new oo(new xo(e),vo.Div))})),{conversion:new io(o),prefixes:t}},Mo={Da:Oo("1.6605388628 x 10^-24 | g",To),u:Oo("| Da",_o),meter:Oo("| m",_o),meters:Oo("| m",_o),in:Oo("254 / 10000 | m",_o),ft:Oo("3048 / 10000 | m",_o),yd:Oo("9144 / 10000 | m",_o),mi:Oo("1609344 / 1000 | m",_o),ly:Oo("9.4607 x 10^15 | m",_o),nmi:Oo("1852 | m",_o),"Å":Oo("10^-10 | m",_o),pc:Oo("3.0857 x 10^16 | m",_o),min:Oo("60 | s",_o),hr:Oo("3600 | s",_o),sec:Oo("| s",_o),day:Oo("86400 | s",_o),wk:Oo("604800 | s",_o),fortnight:Oo("14 | day",_o),shake:Oo("10^-8 | s",_o),olympiad:Oo("126200000 | s",_o),"°C":Oo("1 | K",_o),"°F":Oo("5/9 | K",_o),"°R":Oo("5/9 | K",_o),e:Oo("1.6021765314 x 10^-19 | C",_o),c:Oo("299792458 | m / s",_o),kn:Oo("514/1000 | m / s",_o),kt:Oo("| kn",_o),knot:Oo("| kn",_o),J:Oo("| N m",To),BTU:Oo("1060 | J",_o),cal:Oo("4184 / 1000 | J",To),eV:Oo("1.602176514 x 10^-19 | J",To),erg:Oo("10^−7 | J",To),W:Oo("| J / s",To),"H-e":Oo("80 | W",_o),N:Oo("1000 | g m / s s",To),lb:Oo("4448221615 / 1000000000 | N",_o),dyn:Oo("10^-5 | N",_o),Pa:Oo("1 | N / m m m",To),bar:Oo("10^5 | Pa",To),"㏔":Oo("1/1000 | bar",_o),"㍴":Oo("| bar",_o),atm:Oo("101325 | Pa",_o),Torr:Oo("1/760 | atm",_o),mmHg:Oo("| Torr",_o),ha:Oo("10^4 | m m",_o),b:Oo("10^−28 | m m",To),barn:Oo("| b",To),acre:Oo("4046.87 | m m",_o),skilodge:Oo("10^-31 | m m",_o),outhouse:Oo("10^-34 | m m",_o),shed:Oo("10^-52 | m m",_o),L:Oo("1/1000 | m m m",To),gal:Oo("3785/1000 | L",To),cup:Oo("1/16 | gal",_o),qt:Oo("1/4 | gal",_o),quart:Oo("| qt",_o),p:Oo("1/8 | gal",_o),pt:Oo("| p",_o),pint:Oo("| p",_o),"fl oz":Oo("1/8 | cup",_o),"fl. oz.":Oo("1/8 | cup",_o),tbsp:Oo("1/16 | cup",_o),tsp:Oo("1/3 | tbsp",_o),rev:Oo("2 pi | rad",_o),deg:Oo("180 pi | rad",_o),"°":Oo("| deg",_o),arcminute:Oo("1/60 | deg",_o),arcsec:Oo("1/3600 | deg",_o),Hu:Oo("1000 | dB",To),dozen:Oo("12 |",_o),mol:Oo("6.0221412927 x 10^23 |",To),"%":Oo("1/100 |",_o),percent:Oo("| %",_o),ppm:Oo("1/1000000 |",_o),V:Oo("1000 | g m m / s s C",To),C:Oo("| A s",To),ampere:Oo("| A",_o),"Ω":Oo("| V / A",To),ohm:Oo("| Ω",_o),F:Oo("| C / V",To),H:Oo("| ohm s",To),T:Oo("1000 | g / C s",To),Wb:Oo("1000 | g m m / C s",To),lm:Oo("pi x 10^4 | cd / m m",_o),lx:Oo("| lm / m m",_o),nit:Oo("| cd / m m",_o),sb:Oo("10^4 | cd / m m",_o),stilb:Oo("1 | sb",_o),apostilb:Oo("1 / pi x 10^(-4) | sb",_o),blondel:Oo("| apostilb",_o),asb:Oo("| apostilb",_o),la:Oo("| lm",_o),Lb:Oo("| lm",_o),sk:Oo("10^-7 | lm",_o),skot:Oo("| sk",_o),bril:Oo("10^-11 | lm",_o),Hz:Oo("| / s",To)},Ao=J,Po=Z({displayName:"SortableArea",propTypes:{className:Ao.string,components:Ao.arrayOf(Ao.node).isRequired,onReorder:Ao.func.isRequired,style:Ao.any,verify:Ao.func},getDefaultProps:function(){return{verify:()=>!0}},getInitialState:function(){return{dragging:null,components:this.props.components}},componentDidMount:function(){this._setDragEvents()},UNSAFE_componentWillReceiveProps:function(e){this.setState({components:e.components})},componentDidUpdate:function(){this._setDragEvents()},onDragStart:function(e){this.setState({dragging:e})},onDrop:function(){this.setState({dragging:null}),this.props.onReorder(this.state.components)},onDragEnter:function(e){if(this.state.dragging!==e){var t=this.state.components.slice(),n=t.splice(this.state.dragging,1);t.splice(e,0,n[0]);var r=this.props.verify(t);return r&&this.setState({dragging:e,components:t}),r}},_listenEvent:function(e){e.dataTransfer.setData("hackhackhack","because browsers!")},_cancelEvent:function(e){e.preventDefault()},_setDragEvents:function(){this._dragItems=this._dragItems||[];for(var e=te.findDOMNode(this).querySelectorAll("[draggable=true]"),t=[],n=[],r=0;r<this._dragItems.length;r++){var a=this._dragItems[r];e.indexOf(a)<0&&t.push(a)}for(var s=0;s<e.length;s++){var i=e[s];this._dragItems.indexOf(i)<0&&n.push(i)}for(var o=0;o<n.length;o++){var l=n[o];l.addEventListener("dragstart",this._listenEvent),l.addEventListener("drop",this._cancelEvent)}for(var c=0;c<t.length;c++){var p=t[c];p.removeEventListener("dragstart",this._listenEvent),p.removeEventListener("drop",this._cancelEvent)}},render:function(){var e=this.state.components.map(((e,t)=>G.createElement(Do,{index:t,component:e,area:this,key:e.key,draggable:e.props.draggable,dragging:t===this.state.dragging})));return G.createElement("ol",{className:this.props.className,style:this.props.style},e)}}),Do=Z({displayName:"SortableItem",propTypes:{area:Ao.shape({onDragEnter:Ao.func.isRequired,onDragStart:Ao.func.isRequired,onDrop:Ao.func.isRequired}),component:Ao.node.isRequired,dragging:Ao.bool.isRequired,draggable:Ao.bool.isRequired,index:Ao.number.isRequired},handleDragStart:function(e){e.nativeEvent.dataTransfer.effectAllowed="move",this.props.area.onDragStart(this.props.index)},handleDrop:function(){this.props.area.onDrop(this.props.index)},handleDragEnter:function(e){var t=this.props.area.onDragEnter(this.props.index);e.nativeEvent.dataTransfer.effectAllowed=t?"move":"none"},handleDragOver:function(e){e.preventDefault()},render:function(){var e="sortable-disabled";return this.props.dragging?e="sortable-dragging":this.props.draggable&&(e="sortable-enabled"),G.createElement("li",{draggable:this.props.draggable,className:e,onDragStart:this.handleDragStart,onDrop:this.handleDrop,onDragEnter:this.handleDragEnter,onDragOver:this.handleDragOver},this.props.component)}}),{InfoTip:Io,PropCheckBox:Ro,TexButtons:zo}=t,{getDependencies:Lo}=o,Fo=["correct","wrong","ungraded"],qo=J.shape({considered:J.oneOf(Fo).isRequired,value:J.string.isRequired,form:J.bool.isRequired,simplify:J.bool.isRequired}),Uo=e=>{var t=[];e.forEach((e=>{t[e.key]=!0}));for(var n=0;n<t.length;n++)if(!t[n])return n;return t.length};class Wo extends G.Component{constructor(e){var t,n;super(e),t=this,le(this,"change",(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return x.change.apply(t,n)})),le(this,"serialize",(()=>{var e=["value","form","simplify","considered","key"],t=["answerForms","buttonSets","functions","times"],n=this.props.answerForms.map((t=>K(t).pick(e)));return $a(this.props).set(["answerForms"],n).mod([],(e=>K(e).pick(t))).freeze()})),le(this,"getSaveWarnings",(()=>{var e=[];0===this.props.answerForms.length?e.push("No answers specified"):(!!K(this.props.answerForms).find((e=>"correct"===e.considered))||e.push("No correct answer specified"),K(this.props.answerForms).each(((t,n)=>{if(""===this.props.value)e.push("Answer ".concat(n+1," is empty"));else{var r=wo(t.value,{functions:this.props.functions});r.parsed?t.simplify&&!r.expr.isSimplified()&&e.push("".concat(t.value,' isn\'t simplified, but is required" +\n " to be')):e.push("Couldn't parse ".concat(t.value))}})));return e})),le(this,"_newEmptyAnswerForm",(()=>({considered:"correct",form:!1,key:Uo(this.props.answerForms),simplify:!1,value:""}))),le(this,"newAnswer",(()=>{var e=this.props.answerForms.slice();e.push(this._newEmptyAnswerForm()),this.change({answerForms:e})})),le(this,"handleRemoveForm",(e=>{var t=this.props.answerForms.slice();t.splice(e,1),this.change({answerForms:t})})),le(this,"updateForm",((e,t)=>{var n=$a(this.props.answerForms).merge([e],t).freeze();this.change({answerForms:n})})),le(this,"handleReorder",(e=>{var t=K(e).map((e=>{var t=K(e.props).pick("considered","form","simplify","value");return t.key=e.key,t}));this.change({answerForms:t})})),le(this,"handleButtonSet",(e=>{var t=K(zo.buttonSets).keys(),n=K(t).filter((t=>K(this.props.buttonSets).contains(t)!==(t===e)));this.props.onChange({buttonSets:n})})),le(this,"handleToggleDiv",(()=>{var e,t;K(this.props.buttonSets).contains("basic+div")?(e="basic",t="basic+div"):(e="basic+div",t="basic");var n=K(this.props.buttonSets).reject((e=>e===t)).concat(e);this.change("buttonSets",n)})),le(this,"handleTexInsert",(e=>{this.refs.expression.insert(e)})),le(this,"handleFunctions",(e=>{var t={};t.functions=K.compact(e.target.value.split(/[ ,]+/)),this.props.onChange(t)})),n=0===e.answerForms.length||K(e.answerForms).any((e=>{var{value:t}=e;return-1!==K.indexOf(t,"\\")||-1!==K.indexOf(t,"{")})),this.state={isTex:n}}render(){var e=this.props.answerForms.map(((e,t)=>{var n={times:this.props.times,functions:this.props.functions,buttonSets:this.props.buttonSets,buttonsVisible:"focused",form:e.form,simplify:e.simplify,value:e.value,onChange:e=>this.updateForm(t,e),trackInteraction:()=>{},widgetId:this.props.widgetId+"-"+t};return $a(e).merge([],{draggable:!0,onChange:e=>this.updateForm(t,e),onDelete:()=>this.handleRemoveForm(t),expressionProps:n}).freeze()})).map(((e,t)=>G.createElement(Vo,ce({key:t},e)))),t=G.createElement(Po,{components:e,onReorder:this.handleReorder,className:"answer-options-list"}),n=K(zo.buttonSets).map(((e,t)=>{var n="basic"===t,r=K.contains(this.props.buttonSets,t)||n,a=n?"button-set-label-float":"button-set-label";return G.createElement("label",{className:a,key:t},G.createElement("input",{type:"checkbox",checked:r,disabled:n,onChange:()=>this.handleButtonSet(t)}),t)})),{TeX:r}=Lo();return n.splice(1,1,G.createElement("label",{key:"show-div"},G.createElement("input",{type:"checkbox",onChange:this.handleToggleDiv}),G.createElement("span",{className:"show-div-button"},"show ",G.createElement(r,null,"\\div")," button"))),G.createElement("div",{className:"perseus-widget-expression-editor"},G.createElement("h3",{className:"expression-editor-h3"},"Global Options"),G.createElement("div",null,G.createElement(Ro,{times:this.props.times,onChange:this.props.onChange,labelAlignment:"right",label:"Use × for rendering multiplication instead of a center dot."}),G.createElement(Io,null,G.createElement("p",null,"For pre-algebra problems this option displays multiplication as \\times instead of \\cdot in both the rendered output and the acceptable formats examples."))),G.createElement("div",null,G.createElement("label",null,"Function variables: ",G.createElement("input",{type:"text",defaultValue:this.props.functions.join(" "),onChange:this.handleFunctions})),G.createElement(Io,null,G.createElement("p",null,'Single-letter variables listed here will be interpreted as functions. This let us know that f(x) means "f of x" and not "f times x".'))),G.createElement("div",null,G.createElement("div",null,"Button sets:"),n),this.state.isTex&&G.createElement(zo,{className:"math-input-buttons",sets:this.props.buttonSets,convertDotToTimes:this.props.times,onInsert:this.handleTexInsert}),G.createElement("h3",{className:"expression-editor-h3"},"Answers"),G.createElement("p",{style:{margin:"4px 0"}},"student responses area matched against these from top to bottom"),t,G.createElement("div",null,G.createElement("button",{className:"simple-button orange",style:{fontSize:13},onClick:this.newAnswer,type:"button"},"Add new answer")))}}le(Wo,"propTypes",oe(oe({},x.propTypes),{},{answerForms:J.arrayOf(qo),times:J.bool,buttonSets:zo.buttonSetsType,functions:J.arrayOf(J.string)})),le(Wo,"widgetName","expression"),le(Wo,"defaultProps",{answerForms:[],times:!1,buttonSets:["basic"],functions:["f","g","h"]});class Vo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"state",{deleteFocused:!1}),le(this,"handleDeleteBlur",(()=>{this.setState({deleteFocused:!1})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleImSure",(()=>{this.props.onDelete()})),le(this,"handleDelete",(()=>{this.setState({deleteFocused:!0})})),le(this,"toggleConsidered",(()=>{var e,t,n,r=(e=Fo,t=this.props.considered,n=K(e).indexOf(t),e[n=(n+1)%e.length]);this.change({considered:r})}))}render(){var e=null;return e=this.state.deleteFocused?G.createElement("button",{type:"button",className:"simple-button orange",onClick:this.handleImSure,onBlur:this.handleDeleteBlur},"I'm sure!"):G.createElement("button",{type:"button",className:"simple-button orange",onClick:this.handleDelete},"Delete"),G.createElement("div",{className:"expression-answer-option"},G.createElement("div",{className:"answer-handle"}),G.createElement("div",{className:"answer-body"},G.createElement("div",{className:"answer-considered"},G.createElement("div",{onClick:this.toggleConsidered,className:"answer-status "+this.props.considered},this.props.considered),G.createElement("div",{className:"answer-expression"},G.createElement(S,this.props.expressionProps))),G.createElement("div",{className:"answer-option"},G.createElement(Ro,{form:this.props.form,onChange:this.props.onChange,labelAlignment:"right",label:"Answer expression must have the same form."}),G.createElement(Io,null,G.createElement("p",null,"The student's answer must be in the same form. Commutativity and excess negative signs are ignored."))),G.createElement("div",{className:"answer-option"},G.createElement(Ro,{simplify:this.props.simplify,onChange:this.props.onChange,labelAlignment:"right",label:"Answer expression must be fully expanded and simplified."}),G.createElement(Io,null,G.createElement("p",null,'The student\'s answer must be fully expanded and simplified. Answering this equation (x^2+2x+1) with this factored equation (x+1)^2 will render this response "Your answer is not fully expanded and simplified."'))),G.createElement("div",{className:"remove-container"},e)))}}le(Vo,"propTypes",oe(oe({},x.propTypes),{},{considered:J.oneOf(Fo).isRequired,expressionProps:J.object.isRequired,form:J.bool.isRequired,simplify:J.bool.isRequired,onChange:J.func.isRequired,onDelete:J.func.isRequired}));var{InlineIcon:jo,TextInput:Bo}=t,{iconPlus:$o,iconTrash:Ho}=p;class Go extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleAddHint",(()=>{this.props.onChange({hint:{content:""}},(()=>{this.refs["hint-editor"].focus()}))})),le(this,"handleRemoveHint",(e=>{this.props.onChange({hint:null})})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(()=>oe(oe({title:this.props.title},this.refs.editor.serialize()),{},{hint:this.refs["hint-editor"]&&this.refs["hint-editor"].serialize()})))}render(){return G.createElement("div",{className:"perseus-group-editor"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",{className:re(Yo.title)},"Title:"," ",G.createElement(Bo,{value:this.props.title,className:re(Yo.input),onChange:this.change("title")}))),G.createElement(Sr,{ref:"editor",content:this.props.content,widgets:this.props.widgets,apiOptions:this.props.apiOptions,images:this.props.images,widgetEnabled:!0,immutableWidgets:!1,onChange:this.props.onChange,warnNoPrompt:!0,warnNoWidgets:!0}),!this.props.hint&&G.createElement("button",{type:"button",style:{marginTop:10},className:"add-hint simple-button orange",onClick:this.handleAddHint},G.createElement(jo,$o)," Add a hint"),this.props.hint&&G.createElement("div",{className:"perseus-hint-editor"},G.createElement("div",{className:re(Yo.hintsTitle)},"Hint"),G.createElement(Sr,{ref:"hint-editor",content:this.props.hint?this.props.hint.content:"",widgets:this.props.hint?this.props.hint.widgets:{},apiOptions:this.props.apiOptions,images:this.props.hint&&this.props.hint.images,widgetEnabled:!0,immutableWidgets:!1,onChange:e=>{this.change("hint",Object.assign({},this.props.hint,e))}}),G.createElement("button",{type:"button",className:"remove-hint simple-button orange",onClick:this.handleRemoveHint},G.createElement(jo,Ho)," Remove this hint")))}}le(Go,"propTypes",oe(oe({},x.propTypes),{},{title:J.string,content:J.string,widgets:J.object,images:J.object,apiOptions:u.propTypes})),le(Go,"widgetName","graded-group"),le(Go,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null});var Yo=ne.create({title:{fontSize:18,fontWeight:"bold"},input:{fontSize:18},hintsTitle:{marginTop:10,fontSize:"110%",fontWeight:"bold"}});class Xo extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_editors",void 0),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"getSaveWarnings",(()=>[].concat(...this._editors.map((e=>e?e.getSaveWarnings():[]))))),le(this,"serialize",(()=>({gradedGroups:this.props.gradedGroups}))),le(this,"renderGroups",(()=>this.props.gradedGroups?this.props.gradedGroups.map(((e,t)=>G.createElement(Go,ce({key:t,ref:e=>this._editors[t]=e},e,{apiOptions:this.props.apiOptions,widgetEnabled:!0,immutableWidgets:!1,onChange:e=>this.change("gradedGroups",Ko(this.props.gradedGroups,t,oe(oe({},this.props.gradedGroups[t]),e)))})))):null)),le(this,"addGroup",(()=>{var e=this.props.gradedGroups||[];this.change("gradedGroups",e.concat([Go.defaultProps]))}))}UNSAFE_componentWillMount(){this._editors=[]}render(){return G.createElement("div",{className:"perseus-group-editor"},this.renderGroups(),G.createElement("button",{onClick:this.addGroup},"Add group"))}}le(Xo,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,gradedGroups:J.array,onChange:J.func.isRequired})),le(Xo,"widgetName","graded-group-set"),le(Xo,"defaultProps",{gradedGroups:[]});var Ko=(e,t,n)=>[...e.slice(0,t),n,...e.slice(t+1)],{ButtonGroup:Jo,InfoTip:Zo,PropCheckBox:Qo,RangeInput:el}=t,{getDependencies:tl}=o,nl={url:null,width:0,height:0};var rl=Z({displayName:"GraphSettings",propTypes:oe(oe({},x.propTypes),{},{editableSettings:J.arrayOf(J.oneOf(["canvas","graph","snap","image","measure"])),box:J.arrayOf(J.number),labels:J.arrayOf(J.string),range:J.arrayOf(J.arrayOf(J.number)),step:J.arrayOf(J.number),gridStep:J.arrayOf(J.number),snapStep:J.arrayOf(J.number),valid:J.oneOfType([J.bool,J.string]),backgroundImage:J.object,markings:J.oneOf(["graph","grid","none"]),showProtractor:J.bool,showRuler:J.bool,showTooltips:J.bool,rulerLabel:J.string,rulerTicks:J.number}),getDefaultProps:function(){return{editableSettings:["graph","snap","image","measure"],box:[N.defaultBoxSizeSmall,N.defaultBoxSizeSmall],labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[1,1],valid:!0,backgroundImage:nl,markings:"graph",showProtractor:!1,showRuler:!1,showTooltips:!1,rulerLabel:"",rulerTicks:10}},getInitialState:function(){return this.stateFromProps(this.props)},componentDidMount:function(){this._isMounted=!0,this.changeGraph=K.debounce(this.changeGraph,300)},UNSAFE_componentWillReceiveProps:function(e){K.isEqual(this.props.labels,e.labels)&&K.isEqual(this.props.gridStep,e.gridStep)&&K.isEqual(this.props.snapStep,e.snapStep)&&K.isEqual(this.props.step,e.step)&&K.isEqual(this.props.range,e.range)&&K.isEqual(this.props.backgroundImage,e.backgroundImage)||this.setState(this.stateFromProps(e))},componentWillUnmount:function(){this._isMounted=!1},stateFromProps:function(e){return{labelsTextbox:e.labels,gridStepTextbox:e.gridStep,snapStepTextbox:e.snapStep,stepTextbox:e.step,rangeTextbox:e.range,backgroundImage:K.clone(e.backgroundImage)}},change(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.change.apply(this,t)},changeRulerLabel:function(e){this.change({rulerLabel:e.target.value})},changeRulerTicks:function(e){this.change({rulerTicks:+e.target.value})},changeBackgroundUrl:function(e){if("keypress"!==e.type||"Enter"===e.key){var t=(e,t,n)=>{var r=K.clone(this.props.backgroundImage);r.url=e,r.width=t,r.height=n,this.setState({backgroundImage:r},this.changeGraph)},n=te.findDOMNode(this.refs["bg-url"]).value;n?r.getImageSize(n,((e,r)=>{this._isMounted&&t(n,e,r)})):t(null,0,0)}},renderLabelChoices:function(e){return K.map(e,(function(e){return G.createElement("option",{value:e[1]},e[0])}))},validRange:function(e){return K.every(e,(function(e){return K.isFinite(e)}))?!(e[0]>=e[1])||"Range must have a higher number on the right":"Range must be a valid number"},validateStepValue:function(e){var{step:t,range:n,name:r,minTicks:a,maxTicks:s}=e;if(!K.isFinite(t))return r+" must be a valid number";var i=function(e,t){return Math.floor((e[1]-e[0])/t)}(n,t);return i<a?r+" is too large, there must be at least "+a+" ticks.":!(i>s)||r+" is too small, there can be at most "+s+" ticks."},validSnapStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Snap step",minTicks:5,maxTicks:60})},validGridStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Grid step",minTicks:3,maxTicks:60})},validStep:function(e,t){return this.validateStepValue({step:e,range:t,name:"Step",minTicks:3,maxTicks:20})},validBackgroundImageSize:function(e){return!e.url||(!!(e.width<=450&&e.height<=450)||"Image must be smaller than 450px x 450px.")},validateGraphSettings:function(e,t,n,r,a){var s,i=this,o=K.every(e,(function(e){return!0===(s=i.validRange(e))}));if(!o)return s;var l=K.every(t,(function(t,n){return!0===(s=i.validStep(t,e[n]))}));if(!l)return s;var c=K.every(n,(function(t,n){return!0===(s=i.validGridStep(t,e[n]))}));if(!c)return s;var p=K.every(r,(function(t,n){return!0===(s=i.validSnapStep(t,e[n]))}));if(!p)return s;var h=this.validBackgroundImageSize(a);return!0===h||(s=h)},changeLabel:function(e,t){var n=t.target.value,r=this.state.labelsTextbox.slice();r[e]=n,this.setState({labelsTextbox:r},this.changeGraph)},changeRange:function(e,t){var n=this.state.rangeTextbox.slice();n[e]=t;var a=this.state.stepTextbox.slice(),s=this.state.gridStepTextbox.slice(),i=this.state.snapStepTextbox.slice(),o=r.scaleFromExtent(n[e],this.props.box[e]);!0===this.validRange(n[e])&&(a[e]=r.tickStepFromExtent(n[e],this.props.box[e]),s[e]=r.gridStepFromTickStep(a[e],o),i[e]=s[e]/2),this.setState({stepTextbox:a,gridStepTextbox:s,snapStepTextbox:i,rangeTextbox:n},this.changeGraph)},changeStep:function(e){this.setState({stepTextbox:e},this.changeGraph)},changeSnapStep:function(e){this.setState({snapStepTextbox:e},this.changeGraph)},changeGridStep:function(e){this.setState({gridStepTextbox:e,snapStepTextbox:K.map(e,(function(e){return e/2}))},this.changeGraph)},changeGraph:function(){var e=this.state.labelsTextbox,t=K.map(this.state.rangeTextbox,(function(e){return K.map(e,Number)})),n=K.map(this.state.stepTextbox,Number),r=this.state.gridStepTextbox,a=this.state.snapStepTextbox,s=this.state.backgroundImage,i=this.validateGraphSettings(t,n,r,a,s);!0===i?this.change({valid:!0,labels:e,range:t,step:n,gridStep:r,snapStep:a,backgroundImage:s}):this.change({valid:i})},render:function(){var e=[T.roundTo(2,r.scaleFromExtent(this.props.range[0],this.props.box[0])),T.roundTo(2,r.scaleFromExtent(this.props.range[1],this.props.box[1]))],{TeX:t}=tl();return G.createElement("div",null,K.contains(this.props.editableSettings,"canvas")&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Canvas size (x,y pixels)",G.createElement(el,{value:this.props.box,onChange:e=>{this.change({box:e})}})),G.createElement("div",{className:"perseus-widget-row"},"Scale (px per div):"," ",G.createElement(t,null,"("+e[0]+", "+e[1]+")"))),K.contains(this.props.editableSettings,"graph")&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"}," ","x Label",G.createElement("input",{type:"text",className:"graph-settings-axis-label",ref:"labels-0",onChange:e=>this.changeLabel(0,e),value:this.state.labelsTextbox[0]||""})),G.createElement("div",{className:"perseus-widget-right-col"},"y Label",G.createElement("input",{type:"text",className:"graph-settings-axis-label",ref:"labels-1",onChange:e=>this.changeLabel(1,e),value:this.state.labelsTextbox[1]||""}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"x Range",G.createElement(el,{value:this.state.rangeTextbox[0],onChange:e=>this.changeRange(0,e)})),G.createElement("div",{className:"perseus-widget-right-col"},"y Range",G.createElement(el,{value:this.state.rangeTextbox[1],onChange:e=>this.changeRange(1,e)}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Tick Step",G.createElement(el,{value:this.state.stepTextbox,onChange:this.changeStep})),G.createElement("div",{className:"perseus-widget-right-col"},"Grid Step",G.createElement(el,{value:this.state.gridStepTextbox,onChange:this.changeGridStep}))),K.contains(this.props.editableSettings,"snap")&&G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Snap Step",G.createElement(el,{value:this.state.snapStepTextbox,onChange:this.changeSnapStep}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Markings: "),G.createElement(Jo,{value:this.props.markings,allowEmpty:!1,buttons:[{value:"graph",content:"Graph"},{value:"grid",content:"Grid"},{value:"none",content:"None"}],onChange:this.change("markings")})),G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(Qo,{label:"Show tooltips",showTooltips:this.props.showTooltips,onChange:this.change}))),K.contains(this.props.editableSettings,"image")&&G.createElement("div",{className:"image-settings"},G.createElement("div",null,"Background image:"),G.createElement("div",null,"Url:"," ",G.createElement("input",{type:"text",className:"graph-settings-background-url",ref:"bg-url",value:this.state.backgroundImage.url||"",onChange:e=>{var t=K.clone(this.props.backgroundImage);t.url=e.target.value,this.setState({backgroundImage:t})},onKeyPress:this.changeBackgroundUrl,onBlur:this.changeBackgroundUrl}),G.createElement(Zo,null,G.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.')))),K.contains(this.props.editableSettings,"measure")&&G.createElement("div",{className:"misc-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(Qo,{label:"Show ruler",showRuler:this.props.showRuler,onChange:this.change})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(Qo,{label:"Show protractor",showProtractor:this.props.showProtractor,onChange:this.change}))),this.props.showRuler&&G.createElement("div",null,G.createElement("div",null,G.createElement("label",null," ","Ruler label:"," ",G.createElement("select",{onChange:this.changeRulerLabel,value:this.props.rulerLabel},G.createElement("option",{value:""},"None"),G.createElement("optgroup",{label:"Metric"},this.renderLabelChoices([["milimeters","mm"],["centimeters","cm"],["meters","m"],["kilometers","km"]])),G.createElement("optgroup",{label:"Imperial"},this.renderLabelChoices([["inches","in"],["feet","ft"],["yards","yd"],["miles","mi"]]))))),G.createElement("div",null,G.createElement("label",null," ","Ruler ticks:"," ",G.createElement("select",{onChange:this.changeRulerTicks,value:this.props.rulerTicks},K.map([1,2,4,8,10,16],(function(e){return G.createElement("option",{value:e},e)}))))))))}}),{InfoTip:al,MultiButtonGroup:sl}=t,{containerSizeClass:il,getInteractiveBoxFromSizeClass:ol}=M,ll=_.widget,{DEFAULT_GRAPHER_PROPS:cl,allTypes:pl,chooseType:hl,defaultPlotProps:ul,getEquationString:dl,typeToButton:ml}=O;class gl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleAvailableTypesChange",(e=>{var t=this.props.correct;if(!K.contains(e,this.props.correct.type)){var n=this.props.graph,r=hl(e);t=ul(r,n)}this.props.onChange({availableTypes:e,correct:t})})),le(this,"serialize",(()=>K.chain(this.props).pick("correct","availableTypes").extend({graph:K.omit(this.props.graph,"box")}).value()))}render(){var e,t,n=il.SMALL;if(!0===this.props.graph.valid){var r={graph:this.props.graph,plot:this.props.correct,availableTypes:this.props.availableTypes,onChange:(e,t)=>{var n,r=this.props.correct;r=r.type===(null===(n=e.plot)||void 0===n?void 0:n.type)?K.extend({},r,e.plot):e.plot,this.props.onChange({correct:r},t)},trackInteraction:function(){}};t=G.createElement(ll,ce({},r,{apiOptions:this.props.apiOptions,containerSizeClass:n})),e=dl(r)}else t=G.createElement("div",{className:"perseus-error"},this.props.graph.valid);return G.createElement("div",null,G.createElement("div",null,"Correct answer"," ",G.createElement(al,null,G.createElement("p",null,"Graph the correct answer in the graph below and ensure the equation or point coordinates displayed represent the correct answer."))," ",": ",e),G.createElement(rl,{editableSettings:["graph","snap","image"],box:ol(n),range:this.props.graph.range,labels:this.props.graph.labels,step:this.props.graph.step,gridStep:this.props.graph.gridStep,snapStep:this.props.graph.snapStep,valid:this.props.graph.valid,backgroundImage:this.props.graph.backgroundImage,markings:this.props.graph.markings,rulerLabel:this.props.graph.rulerLabel,rulerTicks:this.props.graph.rulerTicks,showTooltips:this.props.graph.showTooltips,onChange:this.change("graph")}),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Available functions: "),G.createElement(sl,{allowEmpty:!1,values:this.props.availableTypes,buttons:K.map(pl,ml),onChange:this.handleAvailableTypesChange})),t)}}le(gl,"propTypes",oe({},x.propTypes)),le(gl,"widgetName","grapher"),le(gl,"defaultProps",{correct:cl.plot,graph:cl.graph,availableTypes:cl.availableTypes});class fl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_renderMetadataEditor",(()=>{var e=this.props.apiOptions.GroupMetadataEditor;return G.createElement(e,{value:this.props.metadata,onChange:this.change("metadata")})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"getSaveWarnings",(()=>this.refs.editor.getSaveWarnings())),le(this,"serialize",(()=>K.extend({},this.refs.editor.serialize(),{metadata:this.props.metadata})))}render(){return G.createElement("div",{className:"perseus-group-editor"},G.createElement("div",null,this._renderMetadataEditor()),G.createElement(Sr,{ref:"editor",content:this.props.content,widgets:this.props.widgets,apiOptions:this.props.apiOptions,images:this.props.images,widgetEnabled:!0,immutableWidgets:!1,onChange:this.props.onChange}))}}le(fl,"propTypes",oe(oe({},x.propTypes),{},{content:J.string,widgets:J.object,images:J.object,metadata:J.any,apiOptions:u.propTypes})),le(fl,"widgetName","group"),le(fl,"defaultProps",{content:"",widgets:{},images:{},metadata:void 0});var{PropCheckBox:vl}=t;class yl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("fieldset",null,G.createElement("label",null,"Name:",G.createElement(Ms,{value:this.props.name,onChange:this.change("name")})),G.createElement("label",null,"Value:",G.createElement(Ms,{value:this.props.value,onChange:this.change("value")})))}}le(yl,"propTypes",oe(oe({},x.propTypes),{},{name:J.string,value:J.string})),le(yl,"defaultProps",{name:"",value:""});class bl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handlePairChange",((e,t)=>{var n=this.props.pairs.slice();n[e]=t;var r=n[n.length-1];r.name&&r.value&&n.push({name:"",value:""}),this.change("pairs",n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=K.map(this.props.pairs,((e,t)=>G.createElement(yl,{key:t,name:e.name,value:e.value,onChange:this.handlePairChange.bind(this,t)})));return G.createElement("div",null,e)}}le(bl,"propTypes",oe(oe({},x.propTypes),{},{pairs:J.arrayOf(J.shape({name:J.string,value:J.string})).isRequired}));class El extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleSettingsChange",(e=>{this.change({settings:e.pairs})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",{style:{fontWeight:"bold",textAlign:"center"}},"This widget is deprecated! ",G.createElement("br",null),"Try using the Video or CS Program widgets instead."),G.createElement("label",null,"Url or Program ID:",G.createElement(Ms,{value:this.props.url,onChange:this.change("url")})),G.createElement("br",null),G.createElement("label",null,"Settings:",G.createElement(bl,{name:"settings",pairs:this.props.settings,onChange:this.handleSettingsChange})),G.createElement("br",null),G.createElement("label",null,"Width:",G.createElement(Ms,{value:this.props.width,onChange:this.change("width")})),G.createElement("label",null,"Height:",G.createElement(Ms,{value:this.props.height,onChange:this.change("height")})),G.createElement(vl,{label:"Allow full screen",allowFullScreen:this.props.allowFullScreen,onChange:this.props.onChange}),G.createElement("br",null),G.createElement(vl,{label:"Allow iframe content to redirect the page",allowTopNavigation:this.props.allowTopNavigation,onChange:this.props.onChange}))}}le(El,"propTypes",oe({},x.propTypes)),le(El,"widgetName","iframe"),le(El,"defaultProps",{url:"",settings:[{name:"",value:""}],width:"400",height:"400",allowFullScreen:!1,allowTopNavigation:!1});var{InfoTip:wl,InlineIcon:xl,RangeInput:Cl}=t,kl=[0,10],Sl={url:null,width:0,height:0},Nl=new RegExp("^(https?|web\\+graphie)://[^/]*(ka-.*.s3.amazonaws.com|(fastly|cdn).kastatic.org|khanacademy.org|kasandbox.org)"),Tl=["center","above","above right","right","below right","below","below left","left","above left"],_l=Z({displayName:"ImageEditor",propTypes:oe({},x.propTypes),statics:{widgetName:"image"},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},getDefaultProps:function(){return{title:"",range:[kl,kl],box:[400,400],backgroundImage:Sl,labels:[],alt:"",caption:""}},getInitialState:function(){return{backgroundImageError:""}},render:function(){var e=this.props.backgroundImage,t=G.createElement("div",{className:"image-settings"},G.createElement("div",null,G.createElement("label",null,G.createElement("div",null,"Alt text:",G.createElement(wl,null,"This is important for screenreaders. The content of this alt text will be formatted as markdown (tables, emphasis, etc. are supported).")),G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.alt,onChange:e=>{null!=e.content&&this.change("alt",e.content)},widgetEnabled:!1}))),G.createElement("div",null,G.createElement("label",null,G.createElement("div",null,"Caption:"),G.createElement(Sr,{apiOptions:this.props.apiOptions,content:this.props.caption,onChange:e=>{null!=e.content&&this.change("caption",e.content)},widgetEnabled:!1})))),n=G.createElement("div",{className:"renderer-widget-error"},this.state.backgroundImageError);return G.createElement("div",{className:"perseus-image-editor"},G.createElement("label",null,"Image url:",G.createElement(wl,null,"Paste an image or graphie image URL."),this.state.backgroundImageError&&n,G.createElement(Ms,{value:e.url||"",style:{width:332},onChange:e=>this.onUrlChange(e,!1)})),e.url&&t)},_renderRowForLabel:function(e,t){return G.createElement("tr",{key:t},G.createElement("td",null,G.createElement(Cl,{value:e.coordinates,onChange:this.onCoordinateChange.bind(this,t)})),G.createElement("td",{style:{verticalAlign:"bottom",width:"5px"}},G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:e.content,onChange:this.onContentChange.bind(this,t)})),G.createElement("td",null,G.createElement("select",{className:"perseus-widget-dropdown",value:e.alignment,onChange:this.onAlignmentChange.bind(this,t)},Tl.map((function(e,t){return G.createElement("option",{key:""+t,value:e},e)}),this))),G.createElement("td",null,G.createElement("a",{href:"#",className:"simple-button orange delete-label",title:"Remove this label",onClick:this.removeLabel.bind(this,t)},G.createElement(xl,p.iconTrash))))},change(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.change.apply(this,t)},removeLabel:function(e,t){t.preventDefault();var n=K(this.props.labels).clone();n.splice(e,1),this.props.onChange({labels:n})},onCoordinateChange:function(e,t){var n=this.props.labels.slice();n[e]=K.extend({},n[e],{coordinates:t}),this.props.onChange({labels:n})},onContentChange:function(e,t){var n=t.target.value,r=this.props.labels.slice();r[e]=K.extend({},r[e],{content:n}),this.props.onChange({labels:r})},onAlignmentChange:function(e,t){var n=t.target.value,r=this.props.labels.slice();r[e]=K.extend({},r[e],{alignment:n}),this.props.onChange({labels:r})},setUrl:function(e,t,n,r){if(this._isMounted){var a=K.clone(this.props.backgroundImage);a.url=e,a.width=t,a.height=n;var s=[a.width,a.height];this.props.onChange({backgroundImage:a,box:s},null,r)}},onUrlChange:function(e,t){Nl.test(e)?(this.setState({backgroundImageError:""}),this._leadingUrl=e,e?r.getImageSize(e,((t,n)=>{this._leadingUrl===e&&this.setUrl(e,t,n,!0)})):this.setUrl(e,0,0,t)):this.setState({backgroundImageError:"Images must be from sites hosted by Khan Academy. Please input a Khan Academy-owned address, or use the Add Image tool to rehost an existing image"})},onRangeChange:function(e,t){var n=this.props.range.slice();n[e]=t,this.props.onChange({range:n})},serialize(){return C.serialize.call(this)}}),{InfoTip:Ol}=t,Ml={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"}};class Al extends G.Component{constructor(){super(...arguments),le(this,"handleAnswerChange",(e=>{var t=r.firstNumericalParse(e)||0;this.props.onChange({value:t})})),le(this,"focus",(()=>(te.findDOMNode(this.refs.input).focus(),!0))),le(this,"serialize",(()=>K.pick(this.props,"value","simplify","size","inexact","maxError","answerType","rightAlign")))}render(){var e=K.map(Ml,(function(e,t){return G.createElement("option",{value:t,key:t},e.name)}),this);return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"Correct answer:"," ",G.createElement(Ms,{value:""+this.props.value,onChange:this.handleAnswerChange,ref:"input"}))),G.createElement("div",null,G.createElement("label",null,"Unsimplified answers"," ",G.createElement("select",{value:this.props.simplify,onChange:e=>{this.props.onChange({simplify:e.target.value})}},G.createElement("option",{value:"required"},"will not be graded"),G.createElement("option",{value:"optional"},"will be accepted"),G.createElement("option",{value:"enforced"},"will be marked wrong"))),G.createElement(Ol,null,G.createElement("p",null,'Normally select "will not be graded". This will give the user a message saying the answer is correct but not simplified. The user will then have to simplify it and re-enter, but will not be penalized. (5th grade and anything after)'),G.createElement("p",null,'Select "will be accepted" only if the user is not expected to know how to simplify fractions yet. (Anything prior to 5th grade)'),G.createElement("p",null,'Select "will be marked wrong" only if we are specifically assessing the ability to simplify.'))),G.createElement("div",null,G.createElement("label",null,G.createElement("input",{type:"checkbox",checked:this.props.inexact,onChange:e=>{this.props.onChange({inexact:e.target.checked})}})," ","Allow inexact answers"),G.createElement("label",null,G.createElement("input",{type:"checkbox",style:{visibility:"hidden"}}),"Max error:"," ",G.createElement("input",{type:"text",disabled:!this.props.inexact,defaultValue:this.props.maxError,onBlur:e=>{var t=""+(r.firstNumericalParse(e.target.value)||0);e.target.value=t,this.props.onChange({maxError:t})}}))),G.createElement("div",null,"Answer type:"," ",G.createElement("select",{value:this.props.answerType,onChange:e=>{this.props.onChange({answerType:e.target.value})}},e),G.createElement(Ol,null,G.createElement("p",null,'Use the default "Numbers" unless the answer must be in a specific form (e.g., question is about converting decimals to fractions).'))),G.createElement("div",null,G.createElement("label",null,"Width"," ",G.createElement("select",{value:this.props.size,onChange:e=>{this.props.onChange({size:e.target.value})}},G.createElement("option",{value:"normal"},"Normal (80px)"),G.createElement("option",{value:"small"},"Small (40px)"))),G.createElement(Ol,null,G.createElement("p",null,'Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.'))),G.createElement("div",null,G.createElement("label",null,G.createElement("input",{type:"checkbox",checked:this.props.rightAlign,onChange:e=>{this.props.onChange({rightAlign:e.target.checked})}})," ","Right alignment")))}}le(Al,"propTypes",{value:J.number,simplify:J.oneOf(["required","optional","enforced"]),size:J.oneOf(["normal","small"]),inexact:J.bool,maxError:J.number,answerType:J.string,rightAlign:J.bool}),le(Al,"widgetName","input-number"),le(Al,"defaultProps",{value:0,simplify:"required",size:"normal",inexact:!1,maxError:.1,answerType:"number",rightAlign:!1});var{ButtonGroup:Pl,MathInput:Dl,NumberInput:Il}=t;class Rl extends G.Component{constructor(){super(...arguments),le(this,"change",(e=>x.change.call(this,e)))}render(){var{TeX:e}=o.getDependencies();return G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},"Constraint:"," ",G.createElement(Pl,{value:this.props.constraint,allowEmpty:!1,buttons:[{value:"none",content:"None"},{value:"snap",content:"Snap"},{value:"x",content:"x="},{value:"y",content:"y="}],onChange:this.change("constraint")})),"snap"===this.props.constraint&&G.createElement("div",{className:"perseus-widget-row"},"Snap:"," ",G.createElement(Il,{value:this.props.snap,placeholder:0,onChange:this.change("snap")})),"x"===this.props.constraint&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"x=")," ",G.createElement(Dl,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintFn,onChange:this.change("constraintFn")}))),"y"===this.props.constraint&&G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"y=")," ",G.createElement(Dl,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintFn,onChange:this.change("constraintFn")}))),"Ensure these are set so nothing can be dragged off the canvas:",G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"x \\in \\Large[")," ",G.createElement(Dl,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintXMin,onChange:this.change("constraintXMin")}),G.createElement(e,null,", ")," ",G.createElement(Dl,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintXMax,onChange:this.change("constraintXMax")})," ",G.createElement(e,null,"\\Large]"))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"y \\in \\Large[")," ",G.createElement(Dl,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintYMin,onChange:this.change("constraintYMin")}),G.createElement(e,null,", ")," ",G.createElement(Dl,{buttonSets:[],buttonsVisible:"never",value:this.props.constraintYMax,onChange:this.change("constraintYMax")})," ",G.createElement(e,null,"\\Large]"))))}}le(Rl,"defaultProps",{constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"});var{MathInput:zl,NumberInput:Ll,TextInput:Fl}=t,{getDependencies:ql}=o,{unescapeMathMode:Ul}=r;class Wl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Coordinate: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})))}}le(Wl,"propTypes",oe(oe({},x.propTypes),{},{coordX:J.string,coordY:J.string,color:J.string})),le(Wl,"defaultProps",{coordX:"0",coordY:"0",color:A.BLACK});class Vl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Start: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"End: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.endX,onChange:this.change("endX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.endY,onChange:this.change("endY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(D,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})," ",G.createElement(I,{value:this.props.arrows,onChange:this.change("arrows")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Width:"," ",G.createElement(Ll,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}le(Vl,"propTypes",oe(oe({},x.propTypes),{},{startX:J.string,startY:J.string,endX:J.string,endY:J.string,color:J.string,strokeDasharray:J.string,arrows:J.string,strokeWidth:J.number})),le(Vl,"defaultProps",{startX:"-5",startY:"5",endX:"5",endY:"5",color:A.BLACK,strokeDasharray:"",arrows:"",strokeWidth:2});class jl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Start: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"Update ",G.createElement(e,null,"(x_n, y_n)")," for ",G.createElement(e,null,"n =")," ",G.createElement(Ll,{value:this.props.varSubscript,placeholder:0,onChange:this.change("varSubscript")})),G.createElement(Rl,this.props))}}le(jl,"propTypes",oe(oe({},x.propTypes),{},{startX:J.string,startY:J.string,constraint:J.string,snap:J.number,constraintFn:J.string})),le(jl,"defaultProps",{startX:"0",startY:"0",constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"});class Bl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},"Initial position:",G.createElement("div",{className:"perseus-widget-row"},"Start: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.startX,onChange:this.change("startX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.startY,onChange:this.change("startY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"End: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.endX,onChange:this.change("endX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.endY,onChange:this.change("endY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"Start updates ",G.createElement(e,null,"(x_n, y_n)")," for ",G.createElement(e,null,"n ="),G.createElement(Ll,{value:this.props.startSubscript,placeholder:0,onChange:this.change("startSubscript")})),G.createElement("div",{className:"perseus-widget-row"},"End updates ",G.createElement(e,null,"(x_m, y_m)")," for ",G.createElement(e,null,"m ="),G.createElement(Ll,{value:this.props.endSubscript,placeholder:0,onChange:this.change("endSubscript")})),G.createElement("div",{className:"perseus-widget-row"},"All constraints are applied to the start point."),G.createElement(Rl,this.props))}}le(Bl,"propTypes",oe(oe({},x.propTypes),{},{startX:J.string,startY:J.string,endX:J.string,endY:J.string,constraint:J.string,snap:J.number,constraintFn:J.string})),le(Bl,"defaultProps",{startX:"-5",startY:"5",endX:"5",endY:"5",constraint:"none",snap:.5,constraintFn:"0",constraintXMin:"-10",constraintXMax:"10",constraintYMin:"-10",constraintYMax:"10"});class $l extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,this.props.funcName+"(x)=")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.value,onChange:this.change("value")})),G.createElement("div",{className:"perseus-widget-row"},"Range: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMin,onChange:this.change("rangeMin")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMax,onChange:this.change("rangeMax")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(D,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Width:"," ",G.createElement(Ll,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}le($l,"propTypes",oe(oe({},x.propTypes),{},{value:J.string,rangeMin:J.string,rangeMax:J.string,color:J.string,strokeDashArray:J.string,strokeWidth:J.number})),le($l,"defaultProps",{value:"x",rangeMin:"-10",rangeMax:"10",color:A.BLUE,strokeDasharray:"",strokeWidth:2});class Hl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"X(t) =")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.x,onChange:this.change("x")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(e,null,"Y(t) =")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.y,onChange:this.change("y")})),G.createElement("div",{className:"perseus-widget-row"},"Range: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMin,onChange:this.change("rangeMin")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.rangeMax,onChange:this.change("rangeMax")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(D,{value:this.props.strokeDasharray,onChange:this.change("strokeDasharray")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Width:"," ",G.createElement(Ll,{value:this.props.strokeWidth,placeholder:2,onChange:this.change("strokeWidth")}))))}}le(Hl,"propTypes",oe(oe({},x.propTypes),{},{x:J.string,y:J.string,rangeMin:J.string,rangeMax:J.string,color:J.string,strokeDashArray:J.string,strokeWidth:J.number})),le(Hl,"defaultProps",{x:"cos(t)",y:"sin(t)",rangeMin:"0",rangeMax:"2\\pi",color:A.BLUE,strokeDasharray:"",strokeWidth:2});class Gl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(Fl,{value:this.props.label,onChange:this.change("label"),style:{width:"100%"}})),G.createElement("div",{className:"perseus-widget-row"},"Location: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,onChange:this.change("color")})))}}le(Gl,"propTypes",oe(oe({},x.propTypes),{},{color:J.string,coordX:J.string,coordY:J.string,label:J.string})),le(Gl,"defaultProps",{coordX:"0",coordY:"0",color:A.BLACK,label:"\\phi"});class Yl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"graph-settings"},G.createElement("div",{className:"perseus-widget-row"},"Bottom left: ",G.createElement(e,null,"\\Large("),G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.coordX,onChange:this.change("coordX")}),G.createElement(e,null,",")," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.coordY,onChange:this.change("coordY")}),G.createElement(e,null,"\\Large)")),G.createElement("div",{className:"perseus-widget-row"},"Width:"," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.width,onChange:this.change("width")})),G.createElement("div",{className:"perseus-widget-row"},"Height:"," ",G.createElement(zl,{buttonSets:[],buttonsVisible:"never",value:this.props.height,onChange:this.change("height")})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(P,{value:this.props.color,lightColors:!0,onChange:this.change("color")})),G.createElement("div",{className:"perseus-widget-row"},"You want a border? Sorry, draw your own."))}}le(Yl,"propTypes",oe(oe({},x.propTypes),{},{color:J.string,coordX:J.string,coordY:J.string,height:J.string,width:J.string})),le(Yl,"defaultProps",{coordX:"-5",coordY:"5",width:"2",height:"3",color:A.LIGHT_BLUE});class Xl extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"state",{usedVarSubscripts:this._getAllVarSubscripts(this.props.elements),usedFunctionNames:this._getAllFunctionNames(this.props.elements)}),le(this,"_updateGraphProps",(e=>{this.change({graph:K.extend(K.omit(e,"step"),{tickStep:e.step})})})),le(this,"_addNewElement",(e=>{var t=e.target.value;if(""!==t){e.target.value="";var n,r={type:t,key:t+"-"+(16777215*Math.random()<<0).toString(16),options:"point"===t?K.clone(Wl.defaultProps):"line"===t?K.clone(Vl.defaultProps):"movable-point"===t?K.clone(jl.defaultProps):"movable-line"===t?K.clone(Bl.defaultProps):"function"===t?K.clone($l.defaultProps):"parametric"===t?K.clone(Hl.defaultProps):"label"===t?K.clone(Gl.defaultProps):"rectangle"===t?K.clone(Yl.defaultProps):{}};if("movable-point"===t)n=K.max([K.max(this.state.usedVarSubscripts),-1])+1,r.options.varSubscript=n;else if("movable-line"===t)n=K.max([K.max(this.state.usedVarSubscripts),-1])+1,r.options.startSubscript=n,r.options.endSubscript=n+1;else if("function"===t){var a=String.fromCharCode(K.max([K.max(K.map(this.state.usedFunctionNames,(function(e){return e.charCodeAt(0)}))),"e".charCodeAt(0)])+1);r.options.funcName=a}this.change({elements:this.props.elements.concat(r)})}})),le(this,"_deleteElement",(e=>{var t=this.props.elements[e];this.change({elements:K.without(this.props.elements,t)})})),le(this,"_moveElementUp",(e=>{var t=this.props.elements[e],n=K.without(this.props.elements,t);n.splice(e-1,0,t),this.change({elements:n})})),le(this,"_moveElementDown",(e=>{var t=this.props.elements[e],n=K.without(this.props.elements,t);n.splice(e+1,0,t),this.change({elements:n})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}UNSAFE_componentWillReceiveProps(e){this.setState({usedVarSubscripts:this._getAllVarSubscripts(e.elements),usedFunctionNames:this._getAllFunctionNames(e.elements)})}_getAllVarSubscripts(e){return K.map(K.where(e,{type:"movable-point"}),(e=>e.options.varSubscript)).concat(K.map(K.where(e,{type:"movable-line"}),(e=>e.options.startSubscript))).concat(K.map(K.where(e,{type:"movable-line"}),(e=>e.options.endSubscript)))}_getAllFunctionNames(e){return K.map(K.where(e,{type:"function"}),(e=>e.options.funcName))}render(){var{TeX:e}=ql();return G.createElement("div",{className:"perseus-widget-interaction-editor"},G.createElement(R,{title:"Grid settings"},G.createElement(rl,{editableSettings:["canvas","graph"],box:this.props.graph.box,labels:this.props.graph.labels,range:this.props.graph.range,step:this.props.graph.tickStep,gridStep:this.props.graph.gridStep,markings:this.props.graph.markings,onChange:this._updateGraphProps}),!0!==this.props.graph.valid&&G.createElement("div",null,this.props.graph.valid)),K.map(this.props.elements,(function(t,n){return"movable-point"===t.type?G.createElement(R,{title:G.createElement("span",null,"Movable point"," ",G.createElement(e,null,"(x_{"+t.options.varSubscript+"}, y_{"+t.options.varSubscript+"})")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(jl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"movable-line"===t.type?G.createElement(R,{title:G.createElement("span",null,"Movable line"," ",G.createElement(e,null,"(x_{"+t.options.startSubscript+"}, y_{"+t.options.startSubscript+"})")," ","to"," ",G.createElement(e,null,"(x_{"+t.options.endSubscript+"}, y_{"+t.options.endSubscript+"})")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Bl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"point"===t.type?G.createElement(R,{title:G.createElement("span",null,"Point"," ",G.createElement(e,null,"("+t.options.coordX+", "+t.options.coordY+")")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Wl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"line"===t.type?G.createElement(R,{title:G.createElement("span",null,"Line"," ",G.createElement(e,null,"("+t.options.startX+", "+t.options.startY+")")," ","to"," ",G.createElement(e,null,"("+t.options.endX+", "+t.options.endY+")")),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement.bind(this,n),key:t.key},G.createElement(Vl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"function"===t.type?G.createElement(R,{title:G.createElement("span",null,"Function"," ",G.createElement(e,null,t.options.funcName+"(x) = "+t.options.value)),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement($l,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"parametric"===t.type?G.createElement(R,{title:G.createElement("span",null,"Parametric"),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(Hl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"label"===t.type?G.createElement(R,{title:G.createElement("span",null,"Label"," ",G.createElement(e,null,Ul(t.options.label))," "),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(Gl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):"rectangle"===t.type?G.createElement(R,{title:G.createElement("span",null,"Rectangle"," ",G.createElement(e,null,"("+t.options.coordX+", "+t.options.coordY+")")," — ",G.createElement(e,null,t.options.width+" \\times "+t.options.height)),onUp:0===n?null:this._moveElementUp.bind(this,n),onDown:n===this.props.elements.length-1?null:this._moveElementDown.bind(this,n),onDelete:this._deleteElement,key:t.key},G.createElement(Yl,ce({},t.options,{onChange:e=>{var t=JSON.parse(JSON.stringify(this.props.elements));K.extend(t[n].options,e),this.change({elements:t})}}))):void 0}),this),G.createElement("div",{className:"perseus-widget-interaction-editor-select-element"},G.createElement("select",{onChange:this._addNewElement},G.createElement("option",{value:""},"Add an element","…"),G.createElement("option",{disabled:!0},"--"),G.createElement("option",{value:"point"},"Point"),G.createElement("option",{value:"line"},"Line segment"),G.createElement("option",{value:"function"},"Function plot"),G.createElement("option",{value:"parametric"},"Parametric plot"),G.createElement("option",{value:"label"},"Label"),G.createElement("option",{value:"rectangle"},"Rectangle"),G.createElement("option",{value:"movable-point"},"★ Movable point"),G.createElement("option",{value:"movable-line"},"★ Movable line segment"))))}}le(Xl,"propTypes",oe(oe({},x.propTypes),{},{elements:J.arrayOf(J.object),graph:J.objectOf(J.any)})),le(Xl,"widgetName","interaction"),le(Xl,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});var{InfoTip:Kl}=t,{containerSizeClass:Jl,getInteractiveBoxFromSizeClass:Zl}=M,Ql=r.DeprecationMixin,ec=z.widget,tc={url:null},nc=Z({displayName:"InteractiveGraphEditor",className:"perseus-widget-interactive-graph",statics:{widgetName:"interactive-graph"},getDefaultProps:function(){return{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],valid:!0,backgroundImage:tc,markings:"graph",showProtractor:!1,showRuler:!1,showTooltips:!1,rulerLabel:"",rulerTicks:10,correct:{type:"linear",coords:null}}},deprecatedProps:{showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},UNSAFE_componentWillMount(){Ql.UNSAFE_componentWillMount.call(this)},render:function(){var e,t,n=this.props.gridStep||r.getGridStep(this.props.range,this.props.step,N.defaultBoxSize),a=this.props.snapStep||r.snapStepFromGridStep(n),s=Jl.SMALL;if(!0===this.props.valid){var i={ref:"graph",box:this.props.box,range:this.props.range,labels:this.props.labels,step:this.props.step,gridStep:n,snapStep:a,graph:this.props.correct,backgroundImage:this.props.backgroundImage,markings:this.props.markings,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,trackInteraction:function(){},onChange:e=>{var t=this.props.correct;t=t.type===e.graph.type?K.extend({},t,e.graph):e.graph,this.props.onChange({correct:t})}};e=G.createElement(ec,ce({},i,{containerSizeClass:s,apiOptions:oe(oe({},this.props.apiOptions),{},{isMobile:!1})})),t=ec.getEquationString(i)}else e=G.createElement("div",{className:"perseus-error"},this.props.valid);return G.createElement("div",{className:"perseus-widget-interactive-graph"},G.createElement("div",null,"Correct answer"," ",G.createElement(Kl,null,G.createElement("p",null,"Graph the correct answer in the graph below and ensure the equation or point coordinates displayed represent the correct answer."))," ",": ",t),G.createElement(rl,{box:Zl(s),range:this.props.range,labels:this.props.labels,step:this.props.step,gridStep:n,snapStep:a,valid:this.props.valid,backgroundImage:this.props.backgroundImage,markings:this.props.markings,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,showTooltips:this.props.showTooltips,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onChange:this.props.onChange}),"polygon"===this.props.correct.type&&G.createElement("div",{className:"type-settings"},G.createElement("label",null," ","Student answer must"," ",G.createElement("select",{value:this.props.correct.match,onChange:this.changeMatchType},G.createElement("option",{value:"exact"},"match exactly"),G.createElement("option",{value:"congruent"},"be congruent"),G.createElement("option",{value:"approx"},"be approximately congruent"),G.createElement("option",{value:"similar"},"be similar"))),G.createElement(Kl,null,G.createElement("ul",null,G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Match Exactly:")," Match exactly in size, orientation, and location on the grid even if it is not shown in the background.")),G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Be Congruent:")," Be congruent in size and shape, but can be located anywhere on the grid.")),G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Be Approximately Congruent:")," Be exactly similar, and congruent in size and shape to within 0.1 units, but can be located anywhere on the grid."," ",G.createElement("em",null,"Use this with snapping to angle measure."))),G.createElement("li",null,G.createElement("p",null,G.createElement("b",null,"Be Similar:")," Be similar with matching interior angles, and side measures that are matching or a multiple of the correct side measures. The figure can be located anywhere on the grid."))))),"angle"===this.props.correct.type&&G.createElement("div",{className:"type-settings"},G.createElement("div",null,G.createElement("label",null," ","Student answer must"," ",G.createElement("select",{value:this.props.correct.match,onChange:this.changeMatchType},G.createElement("option",{value:"exact"},"match exactly"),G.createElement("option",{value:"congruent"},"be congruent"))),G.createElement(Kl,null,G.createElement("p",null,"Congruency requires only that the angle measures are the same. An exact match implies congruency, but also requires that the angles have the same orientation and that the vertices are in the same position.")))),e)},changeMatchType:function(e){var t=K.extend({},this.props.correct,{match:e.target.value});this.props.onChange({correct:t})},serialize:function(){var e=K.pick(this.props,"step","backgroundImage","markings","labels","showProtractor","showRuler","showTooltips","rulerLabel","rulerTicks","range","gridStep","snapStep"),t=this.refs.graph;if(t){var n=t&&t.getUserInput();K.extend(e,{graph:{type:n.type},correct:n}),K.each(["allowReflexAngles","angleOffsetDeg","numPoints","numSides","numSegments","showAngles","showSides","snapTo","snapDegrees"],(function(t){K.has(n,t)&&(e.graph[t]=n[t])}))}return e}}),rc=["forwardedRef","width","grow","shrink","icon","backgroundColor","focusBorderColor","borderColor","color","onSubmit","leftSideIcon","id","testId","type","labelMediumInputText"];class ac extends G.Component{constructor(){super(...arguments),le(this,"state",{focused:!1}),le(this,"handleBlur",(e=>{var{onBlur:t}=this.props;t&&t(e),this.setState({focused:!1})})),le(this,"handleFocus",(e=>{var{onFocus:t}=this.props;t&&t(e),this.setState({focused:!0})})),le(this,"disableDefault",(e=>{e.preventDefault()}))}render(){var e=this.props,{forwardedRef:t,width:n,grow:r,shrink:a,icon:s,backgroundColor:i,focusBorderColor:o,borderColor:l,color:c,onSubmit:p,leftSideIcon:h,id:u,testId:d,type:m,labelMediumInputText:g}=e,f=pe(e,rc),{focused:v}=this.state,y={},b=[sc.input,sc.container];n&&(y.width=n),r&&(y.flexGrow=!0===r?1:r),(a||0===a)&&(y.flexShrink=!0===a?0:a),i?y.backgroundColor=i:b.push(sc.defaultBackground),c&&(y.color=c);var E=v?o||Bn.blue:l||Bn.offBlack16;y.border="1px solid ".concat(E);var w=s&&G.createElement("span",{className:re(sc.icon)},s),x=g?sc.labelMediumInputBase:sc.inputBase;return G.createElement("form",{className:re(b),style:y,onSubmit:p||this.disableDefault},h&&w,G.createElement("input",ce({},f,{onFocus:this.handleFocus,onBlur:this.handleBlur,type:m,className:re(x),ref:t,id:u,"data-test-id":d})),!h&&w)}}var sc=ne.create({inputBase:oe(oe({background:"inherit",border:"none"},L.typography.bodyXsmall),{},{outline:"none","::placeholder":{color:L.colors.gray41},width:"100%",color:"inherit",marginBottom:0,paddingLeft:0,boxShadow:"none",padding:0,margin:0}),labelMediumInputBase:{background:"inherit",border:"none",outline:"none","::placeholder":{color:L.colors.gray41},width:"100%",fontWeight:"normal",fontFamily:"Lato, san-serif",fontSize:"16px",lineHeight:"20px"},input:{height:40,borderRadius:L.borderRadius,boxSizing:"border-box",padding:"8px 10px"},container:{display:"inline-flex",alignItems:"center",marginBottom:0},defaultBackground:{backgroundColor:L.colors.white},icon:{display:"flex",alignItems:"center",justifyContent:"center"}}),ic=G.forwardRef(((e,t)=>G.createElement(ac,ce({},e,{forwardedRef:t})))),oc=["children","className","highlighted","href","inlineStyles","referrer","style","target","testId","element"];class lc extends G.Component{render(){var e=this.props,{children:t,className:n,highlighted:r,href:a,inlineStyles:s,referrer:i,style:o,target:l,testId:c,element:p}=e,h=pe(e,oc),[u,d]=a?a.split("#"):["javascript:void(0)"],m=u;i&&(m.indexOf("?")>-1?m+="&ref="+i:m+="?ref="+i),d&&(m+="#"+d);var g=[cc.link,r&&cc.highlighted];Array.isArray(o)?g.push(...o):g.push(o);var f=n?" "+n:"",v="a"===p?{href:m}:{to:m},y=h.rel;return"_blank"!==l||y||(y="noopener noreferrer"),G.createElement(p,oe(oe(oe({"data-test-id":c},h),v),{},{className:re(...g)+f,style:s,target:l,rel:y}),t)}}le(lc,"defaultProps",{highlighted:!1,href:"javascript:void(0)",style:[],element:"a"});var cc=ne.create({link:{backgroundColor:"transparent",color:"inherit",textDecoration:"none",":hover":{textDecoration:"underline"}},highlighted:{textDecoration:"underline"}}),{colors:pc,typography:hc}=L,{Icon:uc}=t,dc={path:"M11 11V7a1 1 0 0 1 2 0v4h4a1 1 0 0 1 0 2h-4v4a1 1 0 0 1-2 0v-4H7a1 1 0 0 1 0-2h4zm1 13C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12zm0-2c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z",width:24,height:24},mc={path:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12zm0-2c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10zm-5-9a1 1 0 0 1 0-2h10a1 1 0 0 1 0 2H7z",width:24,height:24},gc=()=>G.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},G.createElement("filter",{id:"draggable-grip-shadow",width:"112.5%",height:"116.7%",x:"-6.2%",y:"-8.3%",filterUnits:"objectBoundingBox"},G.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:".5",result:"shadowBlurInner"}),G.createElement("feOffset",{in:"shadowBlurInner",dy:"1",result:"shadowOffsetInner"}),G.createElement("feComposite",{in:"shadowOffsetInner",in2:"SourceAlpha",k2:"-1",k3:"1",operator:"arithmetic",result:"shadowInnerInner"}),G.createElement("feColorMatrix",{in:"shadowInnerInner",values:"0 0 0 0 0.129411765 0 0 0 0 0.141176471 0 0 0 0 0.17254902 0 0 0 0.2 0"})),G.createElement("path",{d:"M1 4a1 1 0 1 1 0-2h14a1 1 0 0 1 0 2H1zm0 10a1 1 0 0 1 0-2h14a1 1 0 0 1 0 2H1zm0-5a1 1 0 1 1 0-2h14a1 1 0 0 1 0 2H1z",fill:pc.gray17,filter:"url(#draggable-grip-shadow)"})),fc=e=>{var{onClick:t}=e;return G.createElement(lc,{className:re(bc.addAnswer,Ec.addAnswer),onClick:t},G.createElement(uc,{icon:dc,size:24}),G.createElement("div",{className:re(bc.spacer)}),"Add an answer choice")},vc=e=>{var{answer:t,onChange:n,onRemove:r}=e;return G.createElement("li",{className:re(bc.answer)},G.createElement(lc,{onClick:r},G.createElement(uc,{icon:mc,size:24,color:"#D92916"})),G.createElement("div",{className:re(bc.spacer)}),G.createElement(ic,{grow:1,onChange:e=>n(e.target.value),value:t}),G.createElement("div",{className:re(bc.spacer)}),G.createElement(lc,{style:[bc.disabled],title:"Answer reordering is not implemented."},G.createElement(gc,null)))},yc=e=>{var{choices:t,onChange:n}=e;return G.createElement("div",null,G.createElement("div",{className:re(bc.title)},"Answer Choices"),G.createElement("ul",{className:re(bc.answers)},t.map(((e,r)=>G.createElement(vc,{answer:e,key:r,onChange:e=>n([...t.slice(0,r),e,...t.slice(r+1)]),onRemove:()=>n([...t.slice(0,r),...t.slice(r+1)])})))),G.createElement(fc,{onClick:()=>n([...t,""])}))},bc=ne.create({title:oe(oe({},hc.bodyXsmallBold),{},{marginBottom:6,color:pc.gray17}),answers:{marginTop:12,marginBottom:12},answer:{display:"flex",flexDirection:"row",alignItems:"center",":not(:first-child)":{marginTop:12}},addAnswer:oe(oe({},hc.bodyXsmallBold),{},{display:"flex",flexDirection:"row",alignItems:"center",color:"#1865f2"}),spacer:{width:16},disabled:{cursor:"not-allowed"}}),Ec=ne.create({addAnswer:{":link":{color:"#1865f2"}}});class wc extends G.Component{constructor(e){super(e),le(this,"focusFlag",void 0),le(this,"waitingForClick",void 0),le(this,"handleClick",(e=>{this.props.disabled||(this.props.shouldUpdate()&&(this.waitingForClick=!1),this.props.onClick&&!this.props.disabled&&this.props.onClick(e))})),le(this,"handleMouseEnter",(()=>{this.props.disabled||!this.props.shouldUpdate()||this.waitingForClick||this.setState({hovered:!0})})),le(this,"handleMouseLeave",(()=>{this.props.disabled||!this.props.shouldUpdate()||this.waitingForClick||this.setState({hovered:!1})})),le(this,"handleTouchStart",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&this.setState({hovered:!0})})),le(this,"handleTouchEnd",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&(this.setState({hovered:!1}),this.waitingForClick=!0)})),le(this,"handleMouseDown",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&(this.setState({focused:!1}),this.focusFlag=!0)})),le(this,"handleBlur",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&this.setState({focused:!1})})),le(this,"handleFocus",(()=>{!this.props.disabled&&this.props.shouldUpdate()&&(this.focusFlag?this.focusFlag=!1:this.setState({focused:!0}))})),this.state={focused:!1,hovered:e.startHovered}}render(){var e={onBlur:this.handleBlur,onClick:this.handleClick,onFocus:this.handleFocus,onMouseDown:this.handleMouseDown,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd},{children:t}=this.props;return(null==t?void 0:t(this.state,e))||null}}le(wc,"defaultProps",{startHovered:!1,shouldUpdate:()=>!0});var{borderRadius:xc,colors:Cc}=L;class kc extends G.Component{render(){var{checked:e,disabled:t,appearDisabled:n,onChange:r,tabIndex:a,style:s,dataTestId:i,id:o}=this.props,l=Cc.gray41;return G.createElement(wc,null,((c,p)=>{var{focused:h}=c;return G.createElement("div",ce({},p,{className:re(Oc.container,h&&Oc.focused),style:s,"data-test-id":i,"data-checked":e}),G.createElement("svg",{className:re(Oc.svg,(t||n)&&Oc.disabled),width:_c,height:_c,viewBox:"-".concat(Nc," -").concat(Nc,"\n ").concat(_c," ").concat(_c)},G.createElement("g",{fill:"none",fillRule:"evenodd"},e&&G.createElement("g",null,G.createElement("rect",{fill:l,width:Sc,height:Sc,x:"0",y:"0",rx:xc}),G.createElement("path",{fill:Cc.white,stroke:Cc.white,d:"M4.98 7.41a0.58.58 0 1 0-0.81.81L6.47 10.53c0.23.23.59.23.81 0l4.55-4.55a0.58.58 0 0 0-0.81-0.81L6.88 9.31 4.98 7.41z"})),!e&&G.createElement("rect",{fill:Cc.white,stroke:Cc.gray68,width:Sc-2*Nc,height:Sc-2*Nc,x:Nc,y:Nc,rx:"4",strokeWidth:Tc}))),G.createElement("input",{type:"checkbox",id:o,checked:e,className:re(Oc.checkbox,t&&Oc.defaultCursor),disabled:t,onChange:r,tabIndex:a}))}))}}le(kc,"defaultProps",{checked:!1,onChange:e=>{}});var Sc=16,Nc=.5,Tc=1,_c=Sc+2*Nc,Oc=ne.create({container:{position:"relative",display:"inline-block",verticalAlign:"middle",lineHeight:0,borderRadius:xc,width:_c,height:_c,flexShrink:0},focused:{"::before":{content:'""',position:"absolute",top:-2,right:-2,bottom:-2,left:-2,borderRadius:xc+2,backgroundColor:"lightblue"}},svg:{position:"absolute",left:0,top:0},checkbox:{appearance:"none",opacity:0,position:"absolute",top:Nc,width:Sc,height:Sc,margin:0,outline:"none",cursor:"pointer"},disabled:{opacity:.5},defaultCursor:{cursor:"default"}}),{colors:Mc,typography:Ac}=L,Pc=e=>{var{multipleAnswers:t,hideChoicesFromInstructions:n,onChange:r}=e;return G.createElement("div",null,G.createElement("div",{className:re(Dc.title)},"Behavior"),G.createElement("ul",null,G.createElement("li",{className:re(Dc.option)},G.createElement(kc,{checked:t,onChange:()=>r({multipleAnswers:!t})}),G.createElement("span",{className:re(Dc.label)},"Allow multiple answers per marker")),G.createElement("li",{className:re(Dc.option)},G.createElement(kc,{checked:n,onChange:()=>r({hideChoicesFromInstructions:!n})}),G.createElement("span",{className:re(Dc.label)},"Do not display answer choices in instructions"))))},Dc=ne.create({title:oe(oe({},Ac.bodyXsmallBold),{},{marginBottom:6,color:Mc.gray17}),option:{display:"flex",padding:"6px 0"},label:oe(oe({},Ac.smallSubheadingMobile),{},{marginLeft:16,color:Mc.gray17})});var{Icon:Ic}=t,{colors:Rc}=L;class zc extends G.Component{constructor(){super(...arguments),le(this,"node",void 0)}handleKeyDown(e){var{onDropdownClose:t}=this.props,n=e.key,r=e.target;"ArrowDown"===n&&r.nextSibling&&(e.preventDefault(),r.nextSibling.focus()),"ArrowUp"===n&&r.previousSibling&&(e.preventDefault(),r.previousSibling.focus()),"ArrowUp"===n&&!r.previousSibling&&t&&(e.preventDefault(),t()),"Escape"!==n&&"Tab"!==n||!t||t()}render(){var{selected:e,value:t,onClick:n,children:r,optionRenderer:a,disabled:s,hideFocusState:i,testId:o,ariaLabel:l}=this.props;return G.createElement("button",{ref:e=>this.node=e,value:t,role:"menuitemradio","aria-checked":e,className:re(Fc.notAButton,s&&Fc.cursorDefault,i&&Fc.noFocus),onClick:e=>{!s&&n&&n(e)},onKeyDown:e=>this.handleKeyDown(e),"aria-disabled":s,"aria-label":l,"data-test-id":o},a&&a(G.createElement(G.Fragment,null,r),t||"",e||!1,s),!a&&G.createElement("span",{className:re(Fc.option,e&&Fc.optionSelected,s&&Fc.optionDisabled)},r,e&&G.createElement("span",{className:re(Fc.check)},G.createElement(Ic,{icon:"M10,3.8C10,4,9.9,4.2,9.8,4.3L5.1,8.9L4.3,9.8C4.2,9.9,4,10,3.8,10\n S3.5,9.9,3.4,9.8L2.5,8.9L0.2,6.6C0.1,6.5,0,6.3,0,6.2s0.1-0.3,0.2-0.4\n l0.9-0.9c0.1-0.1,0.3-0.2,0.4-0.2s0.3,0.1,0.4,0.2l1.9,1.9l4.2-4.2c0.1\n -0.1,0.3-0.2,0.4-0.2c0.2,0,0.3,0.1,0.4,0.2l0.9,0.9C9.9,3.5,10,3.7,\n 10,3.8z"}))))}}class Lc extends G.Component{constructor(){super(...arguments),le(this,"focusedElement",void 0)}componentDidMount(){var e,t;this.focusedElement&&(e=this.focusedElement,(t=te.findDOMNode(e)).focus&&t.focus({preventScroll:!0}))}render(){var{children:e,onSelected:t,selectedValues:n,optionRenderer:r,noMargin:a,onDropdownClose:s,hideFocusState:i}=this.props;return G.createElement("div",{style:{top:top},className:re(Fc.optionGroup,a&&Fc.optionGroupNoMargin)},G.Children.map(e,((e,a)=>{var o=n.includes(e.props.value),l=o||0===a?e=>this.focusedElement=e:null;return G.cloneElement(e,oe(oe({},e.props),{},{key:a,selected:o,onClick:()=>t(e.props.value),optionRenderer:r,ref:l,onDropdownClose:s,hideFocusState:i}))})))}}var Fc=ne.create({optionGroup:{margin:"4px 0"},optionGroupNoMargin:{margin:0},option:{display:"flex",flexDirection:"row",alignItems:"center",paddingLeft:32,paddingRight:32,height:30,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:Rc.gray17,userSelect:"none",":hover":{backgroundColor:Rc.gray95}},optionSelected:{backgroundColor:Rc.gray95,color:"#11ACCD"},optionDisabled:{color:Rc.gray76,":hover":{backgroundColor:"transparent"}},check:{position:"absolute",left:11},notAButton:{backgroundColor:"transparent",border:"none",display:"block",padding:0,margin:0,width:"100%",font:"inherit"},noFocus:{outline:"none"},cursorDefault:{cursor:"default"}}),{colors:qc,borderRadius:Uc}=L;class Wc extends G.Component{constructor(e){super(e),le(this,"_marker",void 0),le(this,"handleClick",(e=>{var{showDropdown:t}=this.state;this._marker===e.target?this.setState({showDropdown:!t}):t&&this._marker&&!this._marker.contains(e.target)&&(e.stopPropagation(),this.setState({showDropdown:!1}))})),le(this,"handleLabelChange",(e=>{this.updateMarker({label:e.target.value})})),le(this,"handleSelectAnswer",(e=>{var{answers:t}=this.props;t=t.includes(e)?t.filter((t=>t!==e)):[...t,e],this.updateMarker({answers:t})})),this.state={showDropdown:!1}}componentDidMount(){document.addEventListener("click",this.handleClick,!0)}UNSAFE_componentWillReceiveProps(e){var{answers:t}=this.props,n=t.filter((t=>e.choices.includes(t)));JSON.stringify(t)!==JSON.stringify(n)&&setTimeout((()=>this.updateMarker({answers:n})))}componentWillUnmount(){document.removeEventListener("click",this.handleClick,!0)}openDropdown(){this.setState({showDropdown:!0})}updateMarker(e){var{answers:t,label:n,onChange:r,x:a,y:s}=this.props;r(oe({answers:t,label:n,x:a,y:s},e))}render(){var{answers:e,choices:t,label:n,onRemove:r,x:a,y:s}=this.props,{showDropdown:i}=this.state;return G.createElement("div",{className:re(Vc.marker,e.length>0&&Vc.markerWithAnswers,i&&Vc.markerSelected),ref:e=>this._marker=e,style:{left:"".concat(a,"%"),top:"".concat(s,"%")},title:"Click to select marker answers or to delete marker. Repositioning marker is not implemented."},i&&G.createElement("div",null,G.createElement("div",{className:re(Vc.dropdownBody,Vc.dropdownPositionWithArrow)},G.createElement(zc,{value:"",onClick:()=>r()},"Delete marker"),G.createElement("hr",{className:re(Vc.dividerHorizontal)}),G.createElement(Lc,{onSelected:this.handleSelectAnswer,selectedValues:e},t.map((e=>G.createElement(zc,{key:e,value:e},e)))),G.createElement("div",{className:re(Vc.labelContainer)},G.createElement(ic,{placeholder:"ARIA label (for screen readers)",onChange:this.handleLabelChange,value:n,width:"100%"})))))}}var Vc=ne.create({marker:{position:"absolute",boxSizing:"content-box",width:16,height:16,marginLeft:-8,marginTop:-8,cursor:"pointer",background:"linear-gradient(to bottom, rgba(33, 36, 44, 0.2), rgba(33, 36, 44, 0.5))",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 10px 0 rgba(33, 36, 44, 0.1)"},markerSelected:{width:28,height:28,marginLeft:-12,marginTop:-12,border:"none",borderRadius:28,"::before":{content:"''",display:"block",width:20,height:20,marginLeft:2,marginTop:2,border:"solid 2px #ffffff",borderRadius:20}},markerWithAnswers:{background:"#1865f2"},dropdownPositionWithArrow:{left:46,bottom:-12,"::before":{content:"''",display:"block",position:"absolute",width:0,height:0,left:-16,bottom:8,borderRight:"solid 16px ".concat(qc.gray98),borderTop:"solid 16px transparent",borderBottom:"solid 16px transparent"}},labelContainer:{padding:4},dividerHorizontal:{height:0,margin:0,border:"solid ".concat(qc.gray85),borderWidth:"0 0 1px",boxShadow:"none"},dropdownBody:{position:"absolute",border:"solid 1px rgba(0, 0, 0, 0.1)",zIndex:F.zindexDropdown,color:qc.gray17,backgroundColor:qc.gray98,borderRadius:Uc,maxHeight:320,cursor:"pointer"}}),{colors:jc,typography:Bc}=L;class $c extends G.Component{constructor(){super(...arguments),le(this,"_markers",[]),le(this,"handleImageDoubleClick",(e=>{e.preventDefault();var t=e.currentTarget.getBoundingClientRect(),n=Math.round((e.clientX-t.left)/t.width*1e3)/10,r=Math.round((e.clientY-t.top)/t.height*1e3)/10,{markers:a,onChange:s}=this.props;s([...a,{answers:[],label:"",x:n,y:r}])}))}openDropdownForMarkerIndices(e){e.forEach((e=>{this._markers[e]&&this._markers[e].openDropdown()}))}render(){var{choices:e,imageUrl:t,imageWidth:n,imageHeight:a,markers:s,onChange:i}=this.props,l=o.getDependencies().staticUrl;return G.createElement("div",null,G.createElement("div",{className:re(Hc.title)},"Markers"),G.createElement("div",{className:re(Hc.subtitle)},t?G.createElement("span",null,"Double-click on the image to add a marker.",G.createElement("br",null),G.createElement("br",null),"Markers are read by screen readers in the order that you add them here, so add in a logical order for the learner (e.g. sequentially, clockwise). You can test order by using keyboard tabbing."):"Upload an image to place markers."),t&&G.createElement("div",{className:re(Hc.markersCanvas),style:{maxWidth:n,maxHeight:a}},G.createElement("img",{alt:"",className:re(Hc.image),src:l(r.getRealImageUrl(t)),onDoubleClick:this.handleImageDoubleClick}),s.map(((t,n)=>G.createElement(Wc,ce({},t,{choices:e,key:"".concat(t.x,".").concat(t.y),onChange:e=>i([...s.slice(0,n),e,...s.slice(n+1)]),onRemove:()=>i([...s.slice(0,n),...s.slice(n+1)]),ref:e=>this._markers[n]=e}))))))}}var Hc=ne.create({title:oe(oe({},Bc.bodyXsmallBold),{},{marginBottom:6,color:jc.gray17}),subtitle:oe(oe({},Bc.labelSmall),{},{marginBottom:12,color:jc.gray68}),markersCanvas:{position:"relative",border:"solid 1px rgba(33, 36, 44, 0.16)"},image:{display:"block",maxWidth:"100%"}});const Gc="@media (max-width: 1023px)",Yc="@media (min-width: 1024px)",Xc={display:"block"},Kc='Lato, "Noto Sans", sans-serif',Jc=ne.create({Title:ye({},Xc,{fontFamily:Kc,fontWeight:900,[Yc]:{fontSize:36,lineHeight:"40px"},[Gc]:{fontSize:28,lineHeight:"32px"}}),Tagline:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:20,lineHeight:"24px"}),HeadingLarge:ye({},Xc,{fontFamily:Kc,fontWeight:700,[Yc]:{fontSize:28,lineHeight:"32px"},[Gc]:{fontSize:24,lineHeight:"28px"}}),HeadingMedium:ye({},Xc,{fontFamily:Kc,fontWeight:700,[Yc]:{fontSize:24,lineHeight:"28px"},[Gc]:{fontSize:22,lineHeight:"26px"}}),HeadingSmall:ye({},Xc,{fontFamily:Kc,fontWeight:700,fontSize:20,lineHeight:"24px"}),HeadingXSmall:ye({},Xc,{fontFamily:Kc,fontWeight:700,fontSize:12,lineHeight:"16px",letterSpacing:.6,textTransform:"uppercase"}),BodySerifBlock:ye({},Xc,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:22,lineHeight:"28px"}),BodySerif:ye({},Xc,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:18,lineHeight:"22px"}),BodyMonospace:ye({},Xc,{fontFamily:"Inconsolata, monospace",fontWeight:400,fontSize:17,lineHeight:"22px"}),Body:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:16,lineHeight:"22px"}),LabelLarge:ye({},Xc,{fontFamily:Kc,fontWeight:700,fontSize:16,lineHeight:"20px"}),LabelMedium:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:16,lineHeight:"20px"}),LabelSmall:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:14,lineHeight:"18px"}),LabelXSmall:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:12,lineHeight:"16px"}),Caption:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:14,lineHeight:"20px"}),Footnote:ye({},Xc,{fontFamily:Kc,fontWeight:400,fontSize:12,lineHeight:"18px"})}),Zc=["style","children"];class Qc extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Zc);return G.createElement(vn,ye({},r,{style:[Jc.Title,t]}),n)}}Qc.defaultProps={tag:"h1"};const ep=["style","children"];class tp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,ep);return G.createElement(vn,ye({},r,{style:[Jc.HeadingLarge,t]}),n)}}tp.defaultProps={tag:"h2"};const np=["style","children"];class rp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,np);return G.createElement(vn,ye({},r,{style:[Jc.HeadingMedium,t]}),n)}}rp.defaultProps={tag:"h3"};const ap=["style","children"];class sp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,ap);return G.createElement(vn,ye({},r,{style:[Jc.HeadingSmall,t]}),n)}}sp.defaultProps={tag:"h4"};const ip=["style","children"];class op extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,ip);return G.createElement(vn,ye({},r,{style:[Jc.HeadingXSmall,t]}),n)}}op.defaultProps={tag:"h4"};const lp=["style","children"];class cp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,lp);return G.createElement(vn,ye({},r,{style:[Jc.BodySerifBlock,t]}),n)}}cp.defaultProps={tag:"span"};const pp=["style","children"];class hp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,pp);return G.createElement(vn,ye({},r,{style:[Jc.BodySerif,t]}),n)}}hp.defaultProps={tag:"span"};const up=["style","children"];class dp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,up);return G.createElement(vn,ye({},r,{style:[Jc.BodyMonospace,t]}),n)}}dp.defaultProps={tag:"span"};const mp=["style","children"];class gp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,mp);return G.createElement(vn,ye({},r,{style:[Jc.Body,t]}),n)}}gp.defaultProps={tag:"span"};const fp=["style","children"];class vp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,fp);return G.createElement(vn,ye({},r,{style:[Jc.LabelLarge,t]}),n)}}vp.defaultProps={tag:"span"};const yp=["style","children"];class bp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,yp);return G.createElement(vn,ye({},r,{style:[Jc.LabelMedium,t]}),n)}}bp.defaultProps={tag:"span"};const Ep=["style","children"];class wp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Ep);return G.createElement(vn,ye({},r,{style:[Jc.LabelSmall,t]}),n)}}wp.defaultProps={tag:"span"};const xp=["style","children"];class Cp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,xp);return G.createElement(vn,ye({},r,{style:[Jc.LabelXSmall,t]}),n)}}Cp.defaultProps={tag:"span"};const kp=["style","children"];class Sp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,kp);return G.createElement(vn,ye({},r,{style:[Jc.Tagline,t]}),n)}}Sp.defaultProps={tag:"span"};const Np=["style","children"];class Tp extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,Np);return G.createElement(vn,ye({},r,{style:[Jc.Caption,t]}),n)}}Tp.defaultProps={tag:"span"};const _p=["style","children"];class Op extends G.Component{render(){const e=this.props,{style:t,children:n}=e,r=ve(e,_p);return G.createElement(vn,ye({},r,{style:[Jc.Footnote,t]}),n)}}Op.defaultProps={tag:"span"};const Mp={xsmall:16,small:24,medium:48,large:96},Ap={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"},Pp={light:Bn.white,dark:Bn.offBlack16},Dp=bn("path");class Ip extends G.Component{render(){const{size:e,light:t,style:n}=this.props,r=Mp[e],a=Ap[e],s=t?Pp.light:Pp.dark,i=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:`0 0 ${r} ${r}`},G.createElement(Dp,{style:[Rp.loadingSpinner,{fill:s}],fillRule:"nonzero",d:a}));return G.createElement(_n,{style:[Rp.spinnerContainer,n]},i)}}Ip.defaultProps={size:"large",light:!1};const Rp=ne.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"}}),zp=e=>({small:16,medium:24,large:48,xlarge:96}[e]),Lp=["color","icon","size","style"],Fp=bn("svg");class qp extends G.PureComponent{render(){const e=this.props,{color:t,icon:n,size:r,style:a}=e,s=ve(e,Lp),{assetSize:i,path:o}=((e,t)=>{if(e[t])return{assetSize:t,path:e[t]};{const n=zp(t),r=Object.keys(e),a=e=>{const t=zp(e)-n;return t>0?Number.POSITIVE_INFINITY:Math.abs(t)},s=r.sort(((e,t)=>a(e)-a(t))),i=s[0];if(i&&e[i])return{assetSize:i,path:e[i]};throw new Error("Icon does not contain any valid asset sizes!")}})(n,r),l=zp(r),c=zp(i);return G.createElement(Fp,ye({},s,{style:[Up.svg,a],width:l,height:l,viewBox:`0 0 ${c} ${c}`}),G.createElement("path",{fill:t,d:o}))}}qp.defaultProps={color:"currentColor",size:"small"};const Up=ne.create({svg:{display:"inline-block",verticalAlign:"text-bottom",flexShrink:0,flexGrow:0}}),Wp=8,Vp=16,jp=32,Bp=["children","skipClientNav","color","disabled","focused","hovered","href","kind","light","pressed","size","style","testId","type","spinner","icon","id","waiting"],$p=bn("a"),Hp=bn("button"),Gp=bn(an);class Yp extends G.Component{renderInner(e){const t=this.props,{children:n,skipClientNav:r,color:a,disabled:s,focused:i,hovered:o,href:l,kind:c,light:p,pressed:h,size:u,style:d,testId:m,type:g,spinner:f,icon:v,id:y}=t,b=ve(t,Bp),E=Jp("destructive"===a?$n.controlDestructive:$n.controlDefault,c,p,v?8+("small"===u?16:24):0,u),w=f||s,x=ye({"data-test-id":m,id:y,role:"button",style:[[Xp.shared,w&&Xp.disabled,v&&Xp.withIcon,E.default,w&&E.disabled,"tertiary"!==c&&!w&&(h?E.active:(o||i)&&E.focus),"small"===u&&Xp.small,"xlarge"===u&&Xp.xlarge],d]},b),C="small"===u?wp:vp,k=G.createElement(C,{style:[Xp.text,"xlarge"===u&&Xp.xlargeText,v&&Xp.textWithIcon,f&&Xp.hiddenText,"tertiary"===c&&Xp.textWithFocus,"tertiary"===c&&!w&&(h?E.active:(o||i)&&E.focus)]},v&&G.createElement(qp,{size:u,color:"currentColor",icon:v,style:Xp.icon}),n),S=G.createElement(G.Fragment,null,k,f&&G.createElement(Ip,{style:Xp.spinner,size:{medium:"small",small:"xsmall",xlarge:"medium"}[u],light:"primary"===c}));return l&&!w?e&&!r&&Zn(l)?G.createElement(Gp,ye({},x,{to:l}),S):G.createElement($p,ye({},x,{href:l}),S):G.createElement(Hp,ye({type:g||"button"},x,{"aria-disabled":w}),S)}render(){return G.createElement(Mt.Consumer,null,(e=>this.renderInner(e)))}}const Xp=ne.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:Wp}}),Kp={},Jp=(e,t,n,r,a)=>{const s=e+t+n.toString()+r.toString()+a;if(Kp[s])return Kp[s];const{white:i,white50:o,white64:l,offBlack32:c,offBlack50:p,darkBlue:h}=Bn,u=jn(Vn(e,.32),i),d=jn(c,e),m="xlarge"===a?jp:Vp;let g={};if("primary"===t)g={default:{background:n?i:e,color:n?e:i,paddingLeft:m,paddingRight:m},focus:{boxShadow:`0 0 0 1px ${n?h:i}, 0 0 0 3px ${n?i:e}`},active:{boxShadow:`0 0 0 1px ${n?h:i}, 0 0 0 3px ${n?u:d}`,background:n?u:d,color:n?d:u},disabled:{background:n?u:c,color:n?e:l,cursor:"default",":focus":{boxShadow:`0 0 0 1px ${n?c:i}, 0 0 0 3px ${n?u:c}`}}};else if("secondary"===t)g={default:{background:"none",color:n?i:e,borderColor:n?o:p,borderStyle:"solid",borderWidth:1,paddingLeft:r?m-4:m,paddingRight:m},focus:{background:n?"transparent":i,borderColor:n?i:e,borderWidth:2,paddingLeft:r?m-5:m-1,paddingRight:m-1},active:{background:n?d:u,color:n?u:d,borderColor:n?u:d,borderWidth:2,paddingLeft:r?m-5:m-1,paddingRight:m-1},disabled:{color:n?o:c,borderColor:n?u:c,cursor:"default",":focus":{borderColor:n?o:c,borderWidth:2,paddingLeft:r?m-5:m-1,paddingRight:m-1}}};else{if("tertiary"!==t)throw new Error("Button kind not recognized");g={default:{background:"none",color:n?i:e,paddingLeft:0,paddingRight:0},focus:{":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${r}px)`,right:0,bottom:0,background:n?i:e,borderRadius:2}},active:{color:n?u:d,":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${r}px)`,right:0,bottom:"calc(50% - 11px)",background:n?u:d,borderRadius:2}},disabled:{color:n?u:c,cursor:"default"}}}return Kp[s]=ne.create(g),Kp[s]},Zp=["href","type","children","skipClientNav","spinner","disabled","onClick","beforeNav","safeWithNav","tabIndex","target","rel"],Qp=["tabIndex"];class eh extends G.Component{renderClickableBehavior(e){const t=this.props,{href:n,type:r,children:a,skipClientNav:s,spinner:i,disabled:o,onClick:l,beforeNav:c,safeWithNav:p,tabIndex:h,target:u,rel:d}=t,m=ve(t,Zp),g=er(n,s,e),f=(e,t)=>{let{tabIndex:l}=t,c=ve(t,Qp);return G.createElement(Yp,ye({},m,e,c,{disabled:o,spinner:i||e.waiting,skipClientNav:s,href:n,target:u,type:r,tabIndex:h||l}),a)};return c?G.createElement(g,{disabled:i||o,href:n,role:"button",type:r,onClick:l,beforeNav:c,safeWithNav:p,rel:d},f):G.createElement(g,{disabled:i||o,href:n,role:"button",type:r,onClick:l,safeWithNav:p,target:u,rel:d},f)}render(){return G.createElement(Mt.Consumer,null,(e=>this.renderClickableBehavior(e)))}}eh.defaultProps={color:"default",kind:"primary",light:!1,size:"medium",disabled:!1,spinner:!1};var{colors:th,typography:nh}=L,rh=e=>{var{onChange:t,url:n}=e;return G.createElement("div",null,G.createElement("div",{className:re(ah.title)},"Image"),G.createElement("div",{className:re(ah.components)},G.createElement(ic,{placeholder:"URL",grow:1,onChange:e=>t(e.target.value),value:n}),G.createElement("div",{className:re(ah.spacer)}),G.createElement(eh,{disabled:!n,"aria-label":n?"":"Not implemented. Use the 'Add Image' button in the editor to upload image, then copy the URL here.",onClick:()=>t(""),style:ah.btn},n?"Remove":"Upload")))},ah=ne.create({title:oe(oe({},nh.bodyXsmallBold),{},{marginBottom:6,color:th.gray17}),components:{display:"flex"},spacer:{width:16},btn:{minWidth:90}});class sh extends G.Component{constructor(){super(...arguments),le(this,"_questionMarkers",void 0),le(this,"getSaveWarnings",(()=>{var{choices:e,imageAlt:t,imageUrl:n,markers:r}=this.props,a=[];if(e.length<2&&a.push("Question requires at least two answer choices"),n?t||a.push("Question image has no alt text"):a.push("Image is not specified for question"),r.length){var s=0,i=0;for(var o of r)o.answers.length||s++,o.label||i++;s&&a.push("Question has ".concat(s," markers with no ")+"answers selected"),i&&a.push("Question has ".concat(i," markers with no ")+"ARIA label")}else a.push("Question has no markers, to label answers on image");return a})),le(this,"handleImageChange",(e=>{this.props.onChange({imageUrl:e,imageWidth:0,imageHeight:0}),e&&r.getImageSize(e,((e,t)=>{this.props.onChange({imageWidth:e,imageHeight:t})}))})),le(this,"handleAltChange",(e=>{this.props.onChange({imageAlt:e})})),le(this,"handleChoicesChange",(e=>{this.props.onChange({choices:e})})),le(this,"handleMarkersChange",(e=>{this.props.onChange({markers:e})})),le(this,"handleBehaviorChange",(e=>{this.props.onChange(e)}))}componentDidUpdate(e){var t={};e.markers.forEach((e=>t["".concat(e.x,".").concat(e.y)]=e));var n=this.props.markers.map(((e,n)=>t.hasOwnProperty("".concat(e.x,".").concat(e.y))?-1:n)).filter((e=>-1!==e));n.length&&this._questionMarkers&&this._questionMarkers.openDropdownForMarkerIndices(n)}serialize(){return C.serialize.call(this)}render(){var{choices:e,imageAlt:t,imageUrl:n,imageWidth:r,imageHeight:a,markers:s,multipleAnswers:i,hideChoicesFromInstructions:o}=this.props,l=n&&r>0&&a>0;return G.createElement("div",null,G.createElement(rh,{onChange:this.handleImageChange,url:n}),G.createElement("div",{className:re(ih.smallSpacer)}),l&&G.createElement(ic,{placeholder:"Alt text (for screen readers)",onChange:e=>this.handleAltChange(e.target.value),value:t,width:"100%"}),G.createElement("div",{className:re(ih.largeSpacer)}),G.createElement($c,{choices:e,imageUrl:l?n:"",imageWidth:r,imageHeight:a,markers:s,onChange:this.handleMarkersChange,ref:e=>this._questionMarkers=e}),G.createElement("div",{className:re(ih.largeSpacer)}),G.createElement(yc,{choices:e,onChange:this.handleChoicesChange}),G.createElement("div",{className:re(ih.largeSpacer)}),G.createElement(Pc,{multipleAnswers:i,hideChoicesFromInstructions:o,onChange:this.handleBehaviorChange}))}}le(sh,"defaultProps",{choices:[],imageAlt:"",imageUrl:"",imageWidth:0,imageHeight:0,markers:[],multipleAnswers:!1,hideChoicesFromInstructions:!1}),le(sh,"widgetName","label-image");var ih=ne.create({largeSpacer:{height:32},smallSpacer:{height:16}}),{InfoTip:oh,NumberInput:lh,PropCheckBox:ch}=t,ph={display:"table",tableLayout:"fixed"},hh={display:"table-row"},uh={display:"table-cell",padding:5},dh={borderRadius:10,cursor:"pointer"},mh={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?mh.x():mh.plus()},gh=function(e,t,n){return e=Math.floor(e),e=Math.max(e,t),e=Math.min(e,n)};class fh extends G.Component{constructor(){super(...arguments),le(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){var e=this.props.value?"#55dd55":"#115511",t=K.extend({},dh,{width:this.props.size,height:this.props.size,backgroundColor:e});return G.createElement("div",{style:t,onClick:this._flip})}}le(fh,"propTypes",{value:J.bool.isRequired,size:J.number.isRequired});class vh extends G.Component{render(){return G.createElement("div",{style:ph,className:"no-select"},K.map(this.props.cells,((e,t)=>G.createElement("div",{key:t,style:hh},K.map(e,((e,n)=>G.createElement("div",{key:n,style:uh},G.createElement(fh,{value:e,size:this.props.size,onChange:K.partial(this.props.onChange,t,n)}))))))))}}le(vh,"propTypes",{cells:J.arrayOf(J.arrayOf(J.bool)).isRequired,size:J.number.isRequired});class yh extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_height",(()=>this.props.startCells.length)),le(this,"_width",(()=>0!==this.props.startCells.length?this.props.startCells[0].length:0)),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"_handlePatternChange",(e=>{this.change("flipPattern",e.target.value)})),le(this,"_changeWidth",(e=>{e=gh(e,1,8),this._truncateCells(e,this._height())})),le(this,"_changeHeight",(e=>{e=gh(e,1,8),this._truncateCells(this._width(),e)})),le(this,"_truncateCells",((e,t)=>{var n=K.times(t,(t=>K.times(e,(e=>!(!this.props.startCells[t]||!this.props.startCells[t][e])))));this.change({startCells:n})})),le(this,"_switchTile",((e,t)=>{var n,r,a=(n=this.props.startCells,r=(n,r)=>n===e&&r===t,K.map(n,((e,t)=>K.map(e,((e,n)=>r(t,n)?!e:e)))));this.change({startCells:a})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,"Width:",G.createElement(lh,{value:this._width(),placeholder:5,onChange:this._changeWidth}),", ","Height:",G.createElement(lh,{value:this._height(),placeholder:5,onChange:this._changeHeight})),G.createElement("div",null,"Flip pattern:",G.createElement("select",{value:this.props.flipPattern,onChange:this._handlePatternChange},K.map(K.keys(mh),((e,t)=>G.createElement("option",{value:e,key:t},e))))),G.createElement("div",null,"Grade incomplete puzzles as wrong:"," ",G.createElement(ch,{gradeIncompleteAsWrong:this.props.gradeIncompleteAsWrong,onChange:this.props.onChange}),G.createElement(oh,null,"By default, incomplete puzzles are graded as empty.")),G.createElement("div",null,"Starting configuration:"),G.createElement("div",{style:{overflowX:"auto"}},G.createElement(vh,{cells:this.props.startCells,size:50,onChange:this._switchTile})))}}le(yh,"propTypes",oe(oe({},x.propTypes),{},{startCells:J.arrayOf(J.arrayOf(J.bool)),flipPattern:J.string.isRequired,gradeIncompleteAsWrong:J.bool.isRequired})),le(yh,"widgetName","lights-puzzle"),le(yh,"defaultProps",{startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",gradeIncompleteAsWrong:!1});var{InfoTip:bh,PropCheckBox:Eh,TextListEditor:wh}=t;class xh extends G.Component{constructor(){super(...arguments),le(this,"onLabelChange",((e,t)=>{var n=K.clone(this.props.labels);n[e]=t.target.value,this.props.onChange({labels:n})})),le(this,"getSaveWarnings",(()=>this.props.left.length!==this.props.right.length?["The two halves of the matcher have different numbers of cards."]:[])),le(this,"serialize",(()=>K.pick(this.props,"left","right","labels","orderMatters","padding")))}render(){return G.createElement("div",{className:"perseus-matcher-editor"},G.createElement("div",null," ","Correct answer:"," ",G.createElement(bh,null,G.createElement("p",null,"Enter the correct answers here. The preview on the right will show the cards in a randomized order, which is how the student will see them."))),G.createElement("div",{className:"perseus-clearfix"},G.createElement(wh,{options:this.props.left,onChange:(e,t)=>{this.props.onChange({left:e},t)},layout:"vertical"}),G.createElement(wh,{options:this.props.right,onChange:(e,t)=>{this.props.onChange({right:e},t)},layout:"vertical"})),G.createElement("span",null," ","Labels:"," ",G.createElement(bh,null,G.createElement("p",null,"These are entirely optional."))),G.createElement("div",null,G.createElement("input",{type:"text",defaultValue:this.props.labels[0],onChange:this.onLabelChange.bind(this,0)}),G.createElement("input",{type:"text",defaultValue:this.props.labels[1],onChange:this.onLabelChange.bind(this,1)})),G.createElement("div",null,G.createElement(Eh,{label:"Order of the matched pairs matters:",orderMatters:this.props.orderMatters,onChange:this.props.onChange}),G.createElement(bh,null,G.createElement("p",null,"With this option enabled, only the order provided above will be treated as correct. This is useful when ordering is significant, such as in the context of a proof."),G.createElement("p",null,"If disabled, pairwise matching is sufficient. To make this clear, the left column becomes fixed in the provided order and only the cards in the right column can be moved."))),G.createElement("div",null,G.createElement(Eh,{label:"Padding:",padding:this.props.padding,onChange:this.props.onChange}),G.createElement(bh,null,G.createElement("p",null,"Padding is good for text, but not needed for images."))))}}le(xh,"propTypes",{left:J.array,right:J.array,labels:J.array,orderMatters:J.bool,padding:J.bool}),le(xh,"widgetName","matcher"),le(xh,"defaultProps",{left:["$x$","$y$","$z$"],right:["$1$","$2$","$3$"],labels:["test","label"],orderMatters:!1,padding:!0});var{RangeInput:Ch}=t,kh=q.widget;class Sh extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"onMatrixBoardSizeChange",(e=>{var t=function(e){var t=[1,1];return K(e).each(((e,n)=>{var r=0;K(e).each(((e,t)=>{null!=e&&e.toString().length&&(r=t+1)})),t[1]=Math.max(t[1],r),r>0&&(t[0]=Math.max(t[0],n+1))})),t}(this.props.answers);if(null!==e[0]&&null!==e[1]){e=[Math.round(Math.min(Math.max(e[0],1),6)),Math.round(Math.min(Math.max(e[1],1),6))];var n=K(Math.min(e[0],t[0])).times((n=>K(Math.min(e[1],t[1])).times((e=>this.props.answers[n][e]))));this.props.onChange({matrixBoardSize:e,answers:n})}})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=K.extend({numericInput:!0,onBlur:()=>{},onFocus:()=>{},trackInteraction:()=>{}},this.props);return G.createElement("div",{className:"perseus-matrix-editor"},G.createElement("div",{className:"perseus-widget-row"}," ","Max matrix size:"," ",G.createElement(Ch,{value:this.props.matrixBoardSize,onChange:this.onMatrixBoardSizeChange,format:this.props.labelStyle,useArrowKeys:!0})),G.createElement("div",{className:"perseus-widget-row"},G.createElement(kh,e)),G.createElement("div",{className:"perseus-widget-row"}," ","Matrix prefix:"," ",G.createElement(Sr,{ref:"prefix",apiOptions:this.props.apiOptions,content:this.props.prefix,widgetEnabled:!1,onChange:e=>{this.change({prefix:e.content})}})),G.createElement("div",{className:"perseus-widget-row"}," ","Matrix suffix:"," ",G.createElement(Sr,{ref:"suffix",apiOptions:this.props.apiOptions,content:this.props.suffix,widgetEnabled:!1,onChange:e=>{this.change({suffix:e.content})}})))}}le(Sh,"propTypes",oe(oe({},x.propTypes),{},{matrixBoardSize:J.arrayOf(J.number).isRequired,answers:J.arrayOf(J.arrayOf(J.number)),prefix:J.string,suffix:J.string,cursorPosition:J.arrayOf(J.number)})),le(Sh,"widgetName","matrix"),le(Sh,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]});var{InfoTip:Nh,NumberInput:Th,PropCheckBox:_h,RangeInput:Oh}=t,Mh={url:null,top:0,left:0};class Ah extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"className","perseus-widget-measurer"),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"_changeUrl",(e=>{this._changeImage("url",e.target.value)})),le(this,"_changeTop",(e=>{this._changeImage("top",e)})),le(this,"_changeLeft",(e=>{this._changeImage("left",e)})),le(this,"_changeImage",((e,t)=>{var n=K.clone(this.props.image);n[e]=t,this.change("image",n)})),le(this,"renderLabelChoices",(e=>K.map(e,(function(e){var[t,n]=e;return G.createElement("option",{key:n,value:n},t)})))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=K.extend({},Mh,this.props.image);return G.createElement("div",{className:"perseus-widget-measurer"},G.createElement("div",null,"Image displayed under protractor and/or ruler:"),G.createElement("div",null,"URL:"," ",G.createElement("input",{type:"text",className:"perseus-widget-measurer-url",ref:"image-url",defaultValue:e.url,onChange:this._changeUrl}),G.createElement(Nh,null,G.createElement("p",null,'Create an image in graphie, or use the "Add image" function to create a background.'))),e.url&&G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",{className:"perseus-widget-left-col"},"Pixels from top:"," ",G.createElement(Th,{placeholder:0,onChange:this._changeTop,value:e.top,useArrowKeys:!0})),G.createElement("label",{className:"perseus-widget-right-col"},"Pixels from left:"," ",G.createElement(Th,{placeholder:0,onChange:this._changeLeft,value:e.left,useArrowKeys:!0}))),G.createElement("div",null,"Containing area [width, height]:"," ",G.createElement(Oh,{onChange:this.change("box"),value:this.props.box,useArrowKeys:!0})),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(_h,{label:"Show ruler",showRuler:this.props.showRuler,onChange:this.props.onChange})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(_h,{label:"Show protractor",showProtractor:this.props.showProtractor,onChange:this.props.onChange}))),this.props.showRuler&&G.createElement("div",null,G.createElement("div",null,G.createElement("label",null," ","Ruler label:"," ",G.createElement("select",{onChange:e=>this.change("rulerLabel",e.target.value),value:this.props.rulerLabel},G.createElement("option",{value:""},"None"),G.createElement("optgroup",{label:"Metric"},this.renderLabelChoices([["milimeters","mm"],["centimeters","cm"],["meters","m"],["kilometers","km"]])),G.createElement("optgroup",{label:"Imperial"},this.renderLabelChoices([["inches","in"],["feet","ft"],["yards","yd"],["miles","mi"]]))))),G.createElement("div",null,G.createElement("label",null," ","Ruler ticks:"," ",G.createElement("select",{onChange:e=>this.change("rulerTicks",+e.target.value),value:this.props.rulerTicks},K.map([1,2,4,8,10,16],(function(e){return G.createElement("option",{key:e,value:e},e)}))))),G.createElement("div",null,G.createElement("label",null,"Ruler pixels per unit:"," ",G.createElement(Th,{placeholder:40,onChange:this.change("rulerPixels"),value:this.props.rulerPixels,useArrowKeys:!0}))),G.createElement("div",null,G.createElement("label",null,"Ruler length in units:"," ",G.createElement(Th,{placeholder:10,onChange:this.change("rulerLength"),value:this.props.rulerLength,useArrowKeys:!0})))))}}le(Ah,"widgetName","measurer"),le(Ah,"propTypes",oe(oe({},x.propTypes),{},{box:J.arrayOf(J.number),image:J.shape({url:J.string,top:J.number,left:J.number}),showProtractor:J.bool,showRuler:J.bool,rulerLabel:J.string,rulerTicks:J.number,rulerPixels:J.number,rulerLength:J.number})),le(Ah,"defaultProps",{box:[480,480],image:{},showProtractor:!0,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10});var{NumberInput:Ph,TextInput:Dh}=t;class Ih extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"updateMolecule",(e=>{this.change({smiles:e})})),le(this,"updateRotation",(e=>{this.change({rotationAngle:e})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"SMILES: ",G.createElement(Dh,{onChange:this.updateMolecule,value:this.props.smiles}))),G.createElement("div",null,G.createElement("label",null,"Rotation (deg): ",G.createElement(Ph,{onChange:this.updateRotation,value:this.props.rotationAngle}))))}}le(Ih,"propTypes",oe(oe({},x.propTypes),{},{rotationAngle:J.number,smiles:J.string})),le(Ih,"widgetName","molecule-renderer");var{ButtonGroup:Rh,InfoTip:zh,NumberInput:Lh,PropCheckBox:Fh,RangeInput:qh}=t;class Uh extends G.Component{constructor(){super(...arguments),le(this,"onRangeChange",(e=>{this.props.onChange({range:e})})),le(this,"onLabelRangeChange",((e,t)=>{var n=this.props.labelRange.slice(),r=n[1-e];null==t||null==r?n[e]=t:n=[Math.min(t,r),Math.max(t,r)],this.props.onChange({labelRange:n})})),le(this,"onDivisionRangeChange",(e=>{var t=this.props.numDivisions;t=((e,t,n)=>Math.min(Math.max(e,t),n))(t,e[0],e[1]),this.props.onChange({divisionRange:e,numDivisions:t})})),le(this,"onNumChange",((e,t)=>{var n={};n[e]=t,this.props.onChange(n)})),le(this,"onNumDivisionsChange",(e=>{var t=this.props.divisionRange.slice();(e=(e=K.isFinite(e)?Math.round(e):0)<0?-1*e:e)&&(e=Math.min(t[1],Math.max(t[0],e)),this.props.onChange({tickStep:null,divisionRange:t,numDivisions:e}))})),le(this,"onTickStepChange",(e=>{this.props.onChange({numDivisions:null,tickStep:e})})),le(this,"onChangeRelation",(e=>{var t=e.target.value;this.props.onChange({correctRel:t,isInequality:"eq"!==t})})),le(this,"onLabelStyleChange",(e=>{this.props.onChange({labelStyle:e})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=this.props.range,t=this.props.labelRange,n=this.props.divisionRange;e[0]=+e[0],e[1]=+e[1];var r,a=e[1]-e[0],s=this.props.numDivisions,i=this.props.snapDivisions,o=this.props.tickStep,l=this.props.isTickCtrl;r=l?null:o?o/i:a/s/i;return G.createElement("div",{className:"perseus-widget-number-line-editor"},G.createElement("div",{className:"perseus-widget-row"},"Correct x"," ",G.createElement("select",{value:this.props.correctRel,onChange:this.onChangeRelation},G.createElement("option",{value:"eq"}," = "),G.createElement("option",{value:"lt"}," < "),G.createElement("option",{value:"gt"}," > "),G.createElement("option",{value:"le"}," ≤ "),G.createElement("option",{value:"ge"}," ≥ "))," ",G.createElement(Lh,{value:this.props.correctX,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"correctX"),checkValidity:t=>t>=e[0]&&t<=e[1]&&(!r||Js.isInteger((t-e[0])/r)),placeholder:"answer",size:"normal",useArrowKeys:!0}),G.createElement(zh,null,G.createElement("p",null,"This is the correct answer. The answer is validated (as right or wrong) by using only the end position of the point and the relation (=, <, >, ≤, ≥)."))),G.createElement("div",{className:"perseus-widget-row"},this.props.static?G.createElement("label",null,"Range:"):G.createElement("label",null,"Position:"," ",G.createElement(Lh,{value:this.props.initialX,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"initialX"),placeholder:e[0],checkValidity:t=>t>=e[0]&&t<=e[1],useArrowKeys:!0})," ∈ "),G.createElement(qh,{value:e,onChange:this.onRangeChange,format:this.props.labelStyle,useArrowKeys:!0}),G.createElement(zh,null,G.createElement("p",null,"This controls the initial position of the point along the number line and the",G.createElement("strong",null,"range"),", the position of the endpoints of the number line. Setting the range constrains the position of the answer and the labels."),G.createElement("p",null,"In static mode, the initial position of the point is determined by Correct x instead of position."))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("div",{className:"perseus-widget-left-col"},"Labels:"," ",G.createElement(Lh,{value:t[0],placeholder:e[0],format:this.props.labelStyle,checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onLabelRangeChange.bind(this,0),useArrowKeys:!0}),G.createElement("span",null," & "),G.createElement(Lh,{value:t[1],placeholder:e[1],format:this.props.labelStyle,checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onLabelRangeChange.bind(this,1),useArrowKeys:!0}),G.createElement(zh,null,G.createElement("p",null,"This controls the position of the left / right labels. By default, the labels are set by the range ",G.createElement("br",null),G.createElement("strong",null,"Note:")," Ensure that the labels line up with the tick marks, or it may be confusing for users.")))),G.createElement("div",{className:"perseus-widget-row"},"Style:"," ",G.createElement(Rh,{allowEmpty:!1,value:this.props.labelStyle,buttons:[{value:"decimal",content:"0.75",title:"Decimals"},{value:"improper",content:"⁷⁄₄",title:"Improper fractions"},{value:"mixed",content:"1¾",title:"Mixed numbers"},{value:"non-reduced",content:"⁸⁄₄",title:"Non-reduced"}],onChange:this.onLabelStyleChange}),G.createElement(zh,null,G.createElement("p",null,"This controls the styling of the labels for the two main labels as well as all the tick mark labels, if applicable. Your choices are decimal, improper fractions, mixed fractions, and non-reduced fractions."))),G.createElement("div",{className:"perseus-widget-row"},!this.props.static&&G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(Fh,{label:"Show tick controller",isTickCtrl:this.props.isTickCtrl,onChange:this.props.onChange})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(Fh,{label:"Show label ticks",labelTicks:this.props.labelTicks,onChange:this.props.onChange}))),G.createElement("div",{className:"perseus-widget-row"},!this.props.static&&G.createElement(Fh,{label:"Show tooltips",showTooltips:this.props.showTooltips,onChange:this.props.onChange})),G.createElement("div",{className:"perseus-widget-row"},l&&G.createElement("span",null,G.createElement("label",null,"Start num divisions at"," ",G.createElement(Lh,{value:this.props.numDivisions||null,format:"decimal",onChange:this.onNumDivisionsChange,checkValidity:e=>e>=n[0]&&e<=n[1],placeholder:a/this.props.tickStep,useArrowKeys:!0})),G.createElement(zh,null,G.createElement("p",null,"This controls the number (and position) of the tick marks. The number of divisions is constrained to"," "+n[0]+"–"+n[1],".",G.createElement("br",null),G.createElement("strong",null,"Note:")," The user will be able to specify the number of divisions in a number input."))),!l&&G.createElement("span",null,G.createElement("label",null,"Num divisions:"," ",G.createElement(Lh,{value:this.props.numDivisions||null,format:"decimal",onChange:this.onNumDivisionsChange,checkValidity:e=>e>=n[0]&&e<=n[1],placeholder:a/this.props.tickStep,useArrowKeys:!0}))," ",G.createElement("label",null,"or tick step:"," ",G.createElement(Lh,{value:this.props.tickStep||null,format:this.props.labelStyle,onChange:this.onTickStepChange,checkValidity:e=>e>0&&e<=a,placeholder:a/this.props.numDivisions,useArrowKeys:!0})),G.createElement(zh,null,G.createElement("p",null,"This controls the number (and position) of the tick marks; you can either set the number of divisions (2 divisions would split the entire range in two halves), or the tick step (the distance between ticks) and the other value will be updated accordingly."," ",G.createElement("br",null),G.createElement("strong",null,"Note:")," There is no check to see if labels coordinate with the tick marks, which may be confusing for users if the blue labels and black ticks are off-step.")))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Snap increments per tick:"," ",G.createElement(Lh,{value:i,checkValidity:e=>e>0,format:this.props.labelStyle,onChange:this.onNumChange.bind(this,"snapDivisions"),useArrowKeys:!0})),G.createElement(zh,null,G.createElement("p",null,"This determines the number of different places the point will snap between two adjacent tick marks."," ",G.createElement("br",null),G.createElement("strong",null,"Note:"),"Ensure the required number of snap increments is provided to answer the question."))))}}le(Uh,"propTypes",{range:J.arrayOf(J.number).isRequired,labelRange:J.arrayOf(J.number).isRequired,labelStyle:J.string.isRequired,labelTicks:J.bool,divisionRange:J.arrayOf(J.number).isRequired,numDivisions:J.number.isRequired,snapDivisions:J.number,tickStep:J.number,correctRel:J.oneOf(["lt","gt","le","ge","eq"]),correctX:J.number,initialX:J.number,isTickCtrl:J.bool,onChange:J.func.isRequired,static:J.bool,showTooltips:J.bool}),le(Uh,"widgetName","number-line"),le(Uh,"defaultProps",{range:[0,10],labelRange:[null,null],labelStyle:"decimal",labelTicks:!0,divisionRange:[1,12],numDivisions:5,snapDivisions:2,tickStep:null,correctRel:"eq",correctX:null,initialX:null,showTooltips:!1});var{ButtonGroup:Wh,InfoTip:Vh,InlineIcon:jh,MultiButtonGroup:Bh,NumberInput:$h,PropCheckBox:Hh,TextInput:Gh}=t,{iconGear:Yh,iconTrash:Xh}=p,{firstNumericalParse:Kh}=r,Jh=[{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:"π"}],Zh=e=>({value:null,status:e,message:"",simplify:"required",answerForms:[],strict:!1,maxError:null}),Qh=Z({displayName:"NumericInputEditor",propTypes:oe({},x.propTypes),statics:{widgetName:"numeric-input"},getDefaultProps:function(){return{answers:[Zh("correct")],size:"normal",coefficient:!1,labelText:"",multipleNumberInput:!1,rightAlign:!1}},getInitialState:function(){return{lastStatus:"wrong",showOptions:K.map(this.props.answers,(()=>!1))}},render:function(){var e=this.props.answers,t=t=>G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Unsimplified answers are"),G.createElement(Wh,{value:e[t].simplify,allowEmpty:!1,buttons:[{value:"required",content:"ungraded"},{value:"optional",content:"accepted"},{value:"enforced",content:"wrong"}],onChange:this.updateAnswer(t,"simplify")}),G.createElement(Vh,null,G.createElement("p",null,'Normally select "ungraded". This will give the user a message saying the answer is correct but not simplified. The user will then have to simplify it and re-enter, but will not be penalized. (5th grade and after)'),G.createElement("p",null,'Select "accepted" only if the user is not expected to know how to simplify fractions yet. (Anything prior to 5th grade)'),G.createElement("p",null,'Select "wrong" ',G.createElement("em",null,"only")," if we are specifically assessing the ability to simplify."))),n=t=>G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Choose the suggested answer formats"),G.createElement(Bh,{buttons:Jh,values:e[t].answerForms,onChange:this.updateAnswer(t,"answerForms")}),G.createElement(Vh,null,G.createElement("p",null,'Formats will be autoselected for you based on the given answer; to show no suggested formats and accept all types, simply have a decimal/integer be the answer. Values with π will have format "pi", and values that are fractions will have some subset (mixed will be "mixed" and "proper"; improper/proper will both be "improper" and "proper"). If you would like to specify that it is only a proper fraction (or only a mixed/improper fraction), deselect the other format. Except for specific cases, you should not need to change the autoselected formats.'),G.createElement("p",null,"To restrict the answer to ",G.createElement("em",null,"only"),' an improper fraction (i.e. 7/4), select the improper fraction and toggle "strict" to true. This ',G.createElement("b",null,"will not")," ","accept 1.75 as an answer."," "),G.createElement("p",null,"Unless you are testing that specific skill, please do not restrict the answer format."))),G.createElement("div",{className:"perseus-widget-row"},G.createElement(Hh,{label:"Strictly match only these formats",strict:e[t].strict,onChange:this.updateAnswer.bind(this,t)}))),r=t=>G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Max error"," ",G.createElement($h,{className:"max-error",value:e[t].maxError,onChange:this.updateAnswer(t,"maxError"),placeholder:"0"}))),a=G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Width: "),G.createElement(Wh,{value:this.props.size,allowEmpty:!1,buttons:[{value:"normal",content:"Normal (80px)"},{value:"small",content:"Small (40px)"}],onChange:this.change("size")}),G.createElement(Vh,null,G.createElement("p",null,'Use size "Normal" for all text boxes, unless there are multiple text boxes in one line and the answer area is too narrow to fit them.'))),s=G.createElement("div",{className:"perseus-widget-row"},G.createElement(Hh,{label:"Right alignment",rightAlign:this.props.rightAlign,onChange:this.props.onChange})),i=G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Label text:"," ",G.createElement(Gh,{value:this.props.labelText,onChange:this.change("labelText")})),G.createElement(Vh,null,G.createElement("p",null,"Text to describe this input. This will be shown to users using screenreaders."))),o=G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement(Hh,{label:"Coefficient",coefficient:this.props.coefficient,onChange:this.props.onChange}),G.createElement(Vh,null,G.createElement("p",null,"A coefficient style number allows the student to use - for -1 and an empty string to mean 1.")))),l=G.createElement("div",null,G.createElement("a",{href:"javascript:void(0)",className:"simple-button orange",onClick:()=>this.addAnswer(),onKeyDown:e=>this.onSpace(e,this.addAnswer)},G.createElement("span",null,"Add new answer"))),c={wrong:"(address the mistake/misconception)",ungraded:"(explain in detail to avoid confusion)",correct:"(reinforce the user's understanding)"};return G.createElement("div",{className:"perseus-input-number-editor"},G.createElement("div",{ref:e=>this.multInputOption=e},G.createElement("select",{onChange:this.onMultipleInputChange},G.createElement("option",{value:"simple-numeric-input"},"Ask for one correct solution"),G.createElement("option",{value:"multiple-numeric-input"},"Ask for all correct solutions"))),G.createElement("div",{className:"ui-title"},"User input"),G.createElement("div",{className:"msg-title"},"Message shown to user on attempt"),(()=>e.map(((a,s)=>{var i=G.createElement(Sr,{apiOptions:this.props.apiOptions,content:a.message||"",placeholder:"Why is this answer "+a.status+"?\t"+c[a.status],widgetEnabled:!1,onChange:e=>{"content"in e&&this.updateAnswer(s,{message:e.content})}});return G.createElement("div",{className:"perseus-widget-row",key:s},G.createElement("div",{className:"input-answer-editor-value-container"+(a.maxError?" with-max-error":"")},G.createElement($h,{value:a.value,className:"numeric-input-value",placeholder:"answer",format:K.last(a.answerForms),onFormatChange:(e,t)=>{var n;"pi"===t?n=["pi"]:"mixed"===t?n=["proper","mixed"]:"proper"!==t&&"improper"!==t||(n=["proper","improper"]),this.updateAnswer(s,{value:Kh(e),answerForms:n})},onChange:e=>{this.updateAnswer(s,{value:Kh(e)})}}),a.strict&&G.createElement("div",{className:"is-strict-indicator",title:"strictly equivalent to"},"≡"),"required"!==a.simplify&&"correct"===a.status&&G.createElement("div",{className:"simplify-indicator "+a.simplify,title:"accepts unsimplified answers"},"‰"),a.maxError?G.createElement("div",{className:"max-error-container"},G.createElement("div",{className:"max-error-plusmn"},"±"),G.createElement($h,{placeholder:0,value:e[s].maxError,format:K.last(a.answerForms),onChange:this.updateAnswer(s,"maxError")})):null,G.createElement("div",{className:"value-divider"}),G.createElement("a",{href:"javascript:void(0)",className:"answer-status "+a.status,onClick:()=>this.onStatusChange(s),onKeyDown:e=>this.onSpace(e,this.onStatusChange,s)},a.status),G.createElement("a",{href:"javascript:void(0)",className:"answer-trash",onClick:()=>this.onTrashAnswer(s),onKeyDown:e=>this.onSpace(e,this.onTrashAnswer,s)},G.createElement(jh,Xh)),G.createElement("a",{href:"javascript:void(0)",className:"options-toggle",onClick:()=>this.onToggleOptions(s),onKeyDown:e=>this.onSpace(e,this.onToggleOptions,s)},G.createElement(jh,Yh))),G.createElement("div",{className:"input-answer-editor-message"},i),this.state.showOptions[s]&&G.createElement("div",{className:"options-container"},r(s),"correct"===a.status&&t(s),n(s)))})))(),l,a,s,o,i)},change(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.change.apply(this,t)},onToggleOptions:function(e){var t=this.state.showOptions.slice();t[e]=!t[e],this.setState({showOptions:t})},onTrashAnswer:function(e){if(e>=0&&e<this.props.answers.length){var t=this.props.answers.slice(0);t.splice(e,1),this.props.onChange({answers:t})}},onSpace:function(e,t){if(" "===e.key){e.preventDefault();var n=K.toArray(arguments).slice(2);t.apply(this,n)}},onStatusChange:function(e){var t=["wrong","ungraded","correct"],n=this.props.answers,r=t[(K.indexOf(t,n[e].status)+1)%t.length];this.updateAnswer(e,{status:r,simplify:"correct"===r?"required":"accepted"})},onMultipleInputChange:function(e){"multiple-numeric-input"===e.target.value?this.props.onChange({multipleNumberInput:!0}):this.props.onChange({multipleNumberInput:!1})},updateAnswer:function(e,t){if(!K.isObject(t))return K.partial(((e,t,n)=>{var r={};r[t]=n,this.updateAnswer(e,r)}),e,t);var n=K.clone(this.props.answers);if(e===n.length){var r=Zh(this.state.lastStatus);n=n.concat(r)}n[e]=K.extend({},n[e],t),this.props.onChange({answers:n})},addAnswer:function(){var e=Zh(this.state.lastStatus),t=this.props.answers.concat(e);this.props.onChange({answers:t})},getSaveWarnings:function(){var e=[];return K.contains(K.pluck(this.props.answers,"value"),"")&&e.push("One or more answers is empty"),this.props.answers.forEach(((t,n)=>{t.strict&&(!t.answerForms||0===t.answerForms.length)&&e.push("Answer ".concat(n+1," is set to string format ")+"matching, but no format was selected")})),e},serialize(){return C.serialize.call(this)}}),{InfoTip:eu,TextListEditor:tu}=t;class nu extends G.Component{constructor(){super(...arguments),le(this,"onOptionsChange",((e,t,n)=>{var r={};r[e]=K.map(t,(function(e){return{content:e}})),this.props.onChange(r,n)})),le(this,"onLayoutChange",(e=>{this.props.onChange({layout:e.target.value})})),le(this,"onHeightChange",(e=>{this.props.onChange({height:e.target.value})})),le(this,"serialize",(()=>({options:K.chain(K.pluck(this.props.correctOptions,"content")).union(K.pluck(this.props.otherOptions,"content")).uniq().reject((function(e){return""===e})).sort().sortBy((function(e){return/\d/.test(e)?0:/^\$?[a-zA-Z]+\$?$/.test(e)?2:1})).map((function(e){return{content:e}})).value(),correctOptions:this.props.correctOptions,otherOptions:this.props.otherOptions,height:this.props.height,layout:this.props.layout})))}render(){return G.createElement("div",{className:"perseus-widget-orderer"},G.createElement("div",null," ","Correct answer:"," ",G.createElement(eu,null,G.createElement("p",null,"Place the cards in the correct order. The same card can be used more than once in the answer but will only be displayed once at the top of a stack of identical cards."))),G.createElement(tu,{options:K.pluck(this.props.correctOptions,"content"),onChange:this.onOptionsChange.bind(this,"correctOptions"),layout:this.props.layout}),G.createElement("div",null," ","Other cards:"," ",G.createElement(eu,null,G.createElement("p",null,"Create cards that are not part of the answer."))),G.createElement(tu,{options:K.pluck(this.props.otherOptions,"content"),onChange:this.onOptionsChange.bind(this,"otherOptions"),layout:this.props.layout}),G.createElement("div",null,G.createElement("label",null," ","Layout:"," ",G.createElement("select",{value:this.props.layout,onChange:this.onLayoutChange},G.createElement("option",{value:"horizontal"},"Horizontal"),G.createElement("option",{value:"vertical"},"Vertical"))),G.createElement(eu,null,G.createElement("p",null,"Use the horizontal layout for short text and small images. The vertical layout is best for longer text (e.g. proofs)."))),G.createElement("div",null,G.createElement("label",null," ","Height:"," ",G.createElement("select",{value:this.props.height,onChange:this.onHeightChange},G.createElement("option",{value:"normal"},"Normal"),G.createElement("option",{value:"auto"},"Automatic"))),G.createElement(eu,null,G.createElement("p",null,'Use "Normal" for text, "Automatic" for images.'))))}}le(nu,"propTypes",{correctOptions:J.array,otherOptions:J.array,height:J.oneOf(["normal","auto"]),layout:J.oneOf(["horizontal","vertical"]),onChange:J.func.isRequired}),le(nu,"widgetName","orderer"),le(nu,"defaultProps",{correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:"normal",layout:"horizontal"});var{InfoTip:ru,PropCheckBox:au}=t;class su extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){var e=G.createElement(Sr,{ref:"passage-editor",apiOptions:this.props.apiOptions,content:this.props.passageText,widgetEnabled:!1,placeholder:"Type passage here...",onChange:e=>{this.change({passageText:e.content})},showWordCount:!0}),t=G.createElement(Sr,{ref:"passage-footnotes-editor",apiOptions:this.props.apiOptions,content:this.props.footnotes,widgetEnabled:!1,placeholder:"Type footnotes here...",onChange:e=>{this.change({footnotes:e.content})}});return G.createElement("div",{className:"perseus-widget-passage-editor"},G.createElement("div",{className:"perseus-widget-row"},G.createElement(au,{label:"Show line numbers",labelAlignment:"right",showLineNumbers:this.props.showLineNumbers,onChange:this.props.onChange})),G.createElement("div",null,"Passage title:",G.createElement(ru,null,G.createElement("p",null,"An optional title that will appear directly above the passage in the same font style. (E.g. Passage 1)")),G.createElement("div",null,G.createElement("input",{type:"text",defaultValue:this.props.passageTitle,onChange:e=>{this.change({passageTitle:e.target.value})}}))),G.createElement("div",null,"Passage Text:",e),G.createElement("div",null,"Footnotes:",G.createElement(ru,null,G.createElement("p",null,"To add footnotes, add ^ characters where they belong in the passage. Then, add ^ in the footnotes area to reference the footnotes in the passage.")),t))}}le(su,"propTypes",oe(oe({},x.propTypes),{},{passageTitle:J.string,passageText:J.string,footnotes:J.string,showLineNumbers:J.bool})),le(su,"widgetName","passage"),le(su,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0});var{InfoTip:iu,NumberInput:ou,TextInput:lu}=t;class cu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"Passage Number: ",G.createElement(ou,{value:this.props.passageNumber,onChange:this.change("passageNumber")}))),G.createElement("div",null,G.createElement("label",null,"Reference Number: ",G.createElement(ou,{value:this.props.referenceNumber,onChange:this.change("referenceNumber")}))),G.createElement("div",null,G.createElement("label",null,"Summary Text: ",G.createElement(lu,{value:this.props.summaryText,onChange:this.change("summaryText")}),G.createElement(iu,null,G.createElement("p",null,"Short summary of the referenced section. This will be included in parentheses and quotes automatically."),G.createElement("p",null,"Ex: The start ... the end")))))}}le(cu,"propTypes",oe(oe({},x.propTypes),{},{passageNumber:J.number,referenceNumber:J.number,summaryText:J.string})),le(cu,"widgetName","passage-ref"),le(cu,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});class pu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleContentChange",(e=>{this.change({content:e.target.value})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,"Content:",G.createElement("input",{type:"text",value:this.props.content,onChange:this.handleContentChange}))}}le(pu,"propTypes",oe(oe({},x.propTypes),{},{content:J.string})),le(pu,"widgetName","passage-ref-target"),le(pu,"defaultProps",{content:""});var{InfoTip:hu,NumberInput:uu,RangeInput:du,TextListEditor:mu}=t,gu=U.widget;function fu(e,t,n){var r=K.clone(e);r.length=t;for(var a=e.length;a<t;a++)r[a]=n;return r}var vu={scaleY:1,maxY:10,snapsPerLine:2},yu={type:J.oneOf(["bar","line","pic","histogram","dotplot"]),labels:J.arrayOf(J.string),categories:J.arrayOf(J.oneOfType([J.number,J.string])),scaleY:J.number,maxY:J.number,snapsPerLine:J.number,picSize:J.number,pixBoxHeight:J.number,picUrl:J.string,plotDimensions:J.arrayOf(J.number),labelInterval:J.number,starting:J.arrayOf(J.number),correct:J.arrayOf(J.number),static:J.bool,onChange:J.func},bu=e=>"$"+Js.round(e,2)+"$";class Eu extends G.Component{constructor(){super(...arguments),le(this,"state",{editing:this.props.static?"starting":"correct",pic:null,loadedUrl:null,minX:null,maxX:null,tickStep:null}),le(this,"fetchPic",(e=>{if(this.state.loadedUrl!==e){var t=new Image;t.src=e,t.onload=()=>{this.setState({pic:t,loadedUrl:e})}}})),le(this,"handleChangeTickStep",(e=>{this.setState({tickStep:e})})),le(this,"handleChangeRange",(e=>{this.setState({minX:e[0],maxX:e[1]})})),le(this,"changeLabelInterval",(e=>{this.props.onChange({labelInterval:e})})),le(this,"handlePlotterChange",(e=>{var t={};t[this.state.editing]=e.values,this.props.onChange(t)})),le(this,"changeType",(e=>{var t;("histogram"===e?(t=[bu(0)].concat(this.props.categories),this.props.onChange({type:e,categories:t})):"histogram"===this.props.type?(t=this.props.categories.slice(1),this.props.onChange({type:e,categories:t})):this.props.onChange({type:e}),t)&&(te.findDOMNode(this.refs.categories).value=t.join(", "))})),le(this,"changeLabel",((e,t)=>{var n=K.clone(this.props.labels);n[e]=t.target.value,this.props.onChange({labels:n})})),le(this,"changePicUrl",(e=>{var t=r.getRealImageUrl(e);this.props.onChange({picUrl:t})})),le(this,"changeCategories",(e=>{var t=e.length;"histogram"===this.props.type&&t--;var n=this.props.scaleY;this.props.onChange({categories:e,correct:fu(this.props.correct,t,n),starting:fu(this.props.starting,t,n)})})),le(this,"changeScale",(e=>{var t=this.props.scaleY,n=+e.target.value||vu.scaleY,r=function(e){return e*n/t},a=r(this.props.maxY);this.props.onChange({scaleY:n,maxY:a,correct:K.map(this.props.correct,r),starting:K.map(this.props.starting,r)}),te.findDOMNode(this.refs.maxY).value=a})),le(this,"changeMax",(e=>{this.props.onChange({maxY:+e.target.value||vu.maxY})})),le(this,"changeSnaps",(e=>{this.props.onChange({snapsPerLine:+e.target.value||vu.snapsPerLine})})),le(this,"changeEditing",(e=>{this.setState({editing:e})})),le(this,"setCategoriesFromScale",(()=>{var e,t=this.state.tickStep||1,n=this.state.minX||0,r=this.state.maxX||0,a=Math.floor((r-n)/t)*t;e="histogram"===this.props.type||"dotplot"===this.props.type?K.range(0,a+t,t):K.range(t,a+t,t),e=K.map(e,(e=>e+n)),e=K.map(e,bu),this.changeCategories(e),te.findDOMNode(this.refs.categories).value=e.join(", ")})),le(this,"serialize",(()=>{var e=K.pick(this.props,"correct","starting","type","labels","categories","scaleY","maxY","snapsPerLine","labelInterval");return"pic"===this.props.type&&(e.picUrl=this.props.picUrl),e}))}UNSAFE_componentWillMount(){this.fetchPic(this.props.picUrl)}UNSAFE_componentWillReceiveProps(e){this.fetchPic(e.picUrl),e.static&&this.setState({editing:"starting"})}render(){var e=K.contains(["line","histogram","dotplot"],this.props.type),t=!K.contains(["pic","dotplot"],this.props.type),n=oe({trackInteraction:()=>{}},this.props);return G.createElement("div",{className:"perseus-widget-plotter-editor"},G.createElement("div",null,"Chart type:"," ",K.map(["bar","line","pic","histogram","dotplot"],(function(e){return G.createElement("label",{key:e},G.createElement("input",{type:"radio",name:"chart-type",checked:this.props.type===e,onChange:K.partial(this.changeType,e)}),e)}),this)),G.createElement("div",null,"Labels:"," ",K.map(["x","y"],(function(e,t){return G.createElement("label",{key:e},e+":",G.createElement("input",{type:"text",onChange:K.partial(this.changeLabel,t),defaultValue:this.props.labels[t]}))}),this)),e&&G.createElement("div",{className:"set-from-scale-box"},G.createElement("span",{className:"categories-title"},"Set Categories From Scale"),G.createElement("div",null,G.createElement("label",null,"Tick Step:"," ",G.createElement(uu,{placeholder:1,useArrowKeys:!0,value:this.state.tickStep,onChange:this.handleChangeTickStep})),G.createElement(hu,null,G.createElement("p",null,"The difference between adjacent ticks."))),G.createElement("div",null,G.createElement("label",null,"Range:"," ",G.createElement(du,{placeholder:[0,10],useArrowKeys:!0,value:[this.state.minX,this.state.maxX],onChange:this.handleChangeRange}))),G.createElement("div",null,G.createElement("button",{onClick:this.setCategoriesFromScale},"Set Categories"," "))),G.createElement("div",null,G.createElement("label",null,"Label Interval:"," ",G.createElement(uu,{useArrowKeys:!0,value:this.props.labelInterval,onChange:this.changeLabelInterval})),G.createElement(hu,null,G.createElement("p",null,'Which ticks to display the labels for. For instance, setting this to "4" will only show every 4th label (plus the last one)'))),"pic"===this.props.type&&G.createElement("div",null,G.createElement("label",null,"Picture:"," ",G.createElement(Ms,{className:"pic-url",value:this.props.picUrl,onChange:this.changePicUrl}),G.createElement(hu,null,G.createElement("p",null,'Use the default picture of Earth, or insert the URL for a different picture using the "Add image" function.'))),this.state.pic&&this.state.pic.width!==this.state.pic.height&&G.createElement("p",{className:"warning"},G.createElement("b",null,"Warning"),": You are using a picture which is not square. This means the image will get distorted. You should probably crop it to be square.")),G.createElement("div",null,G.createElement("label",null,"Categories:"," ",G.createElement(mu,{ref:"categories",layout:"horizontal",options:this.props.categories,onChange:this.changeCategories}))),G.createElement("div",null,G.createElement("label",null,"Scale (y):"," ",G.createElement("input",{type:"text",onChange:this.changeScale,defaultValue:this.props.scaleY}))),G.createElement("div",null,G.createElement("label",null,"Max y:"," ",G.createElement("input",{type:"text",ref:"maxY",onChange:this.changeMax,defaultValue:this.props.maxY}))),t&&G.createElement("div",null,G.createElement("label",null,"Snaps per line:"," ",G.createElement("input",{type:"text",onChange:this.changeSnaps,defaultValue:this.props.snapsPerLine})),G.createElement(hu,null,G.createElement("p",null,"Creates the specified number of divisions between the horizontal lines. Fewer snaps between lines makes the graph easier for the student to create correctly."))),G.createElement("div",null,"Editing values:"," ",["correct","starting"].map((e=>G.createElement("label",{key:e},G.createElement("input",{type:"radio",disabled:"correct"===e&&this.props.static,checked:this.props.static?"starting"===e:this.state.editing===e,onChange:t=>this.changeEditing(e)}),e))),G.createElement(hu,null,G.createElement("p",null,"Use this toggle to switch between editing the correct answer (what the student will be graded on) and the starting values (what the student will see plotted when they start the problem). Note: These cannot be the same."),G.createElement("p",null,"In static mode, the starting values are rendered out to the displayed widget."))),G.createElement(gu,ce({},n,{starting:this.props[this.state.editing],onChange:this.handlePlotterChange})))}}le(Eu,"propTypes",yu),le(Eu,"widgetName","plotter"),le(Eu,"defaultProps",oe(oe({},vu),{},{correct:[1],starting:[1],type:"bar",labels:["",""],categories:[""],picSize:30,picBoxHeight:36,plotDimensions:[275,200],labelInterval:1,get picUrl(){var e=o.getDependencies().staticUrl;return e?e("/images/badges/earth-small.png"):null}}));var{InlineIcon:wu,PropCheckBox:xu}=t,{iconPlus:Cu,iconTrash:ku}=p;class Su extends G.Component{render(){var e=this.props.choice.correct?"correct":"incorrect",t="Type a choice here...";this.props.choice.isNoneOfTheAbove&&(t=this.props.choice.correct?"Type the answer to reveal to the user...":"None of the above");var n=G.createElement(Sr,{ref:"content-editor",apiOptions:this.props.apiOptions,content:this.props.choice.content||"",widgetEnabled:!1,placeholder:t,disabled:this.props.choice.isNoneOfTheAbove&&!this.props.choice.correct,onChange:this.props.onContentChange}),r=G.createElement(Sr,{ref:"clue-editor",apiOptions:this.props.apiOptions,content:this.props.choice.clue||"",widgetEnabled:!1,placeholder:se._("Why is this choice %(correctOrIncorrect)s?",{correctOrIncorrect:e}),onChange:this.props.onClueChange}),a=G.createElement("a",{className:"simple-button orange delete-choice",href:"#",onClick:this.props.onDelete,title:"Remove this choice"},G.createElement(wu,ku));return G.createElement("div",{className:"choice-clue-editors"},G.createElement("div",{className:"choice-editor ".concat(e)},n),G.createElement("div",{className:"clue-editor"},r),this.props.showDelete&&a)}}le(Su,"propTypes",{apiOptions:u.propTypes,choice:J.object,showDelete:J.bool,onClueChange:J.func,onContentChange:J.func,onDelete:J.func});class Nu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"onMultipleSelectChange",(e=>{e=e.multipleSelect;var t=K.reduce(this.props.choices,(function(e,t){return t.correct?e+1:e}),0);if(!e&&t>1){var n=K.map(this.props.choices,(function(e){return K.defaults({correct:!1},e)}));this.props.onChange({multipleSelect:e,choices:n})}else this.props.onChange({multipleSelect:e})})),le(this,"onCountChoicesChange",(e=>{e=e.countChoices,this.props.onChange({countChoices:e})})),le(this,"onChange",(e=>{var{checked:t}=e,n=K.map(this.props.choices,((e,n)=>K.extend({},e,{correct:t[n],content:e.isNoneOfTheAbove&&!t[n]?"":e.content})));this.props.onChange({choices:n})})),le(this,"onContentChange",((e,t)=>{var n=this.props.choices.slice();n[e]=K.extend({},n[e],{content:t}),this.props.onChange({choices:n})})),le(this,"onClueChange",((e,t)=>{var n=this.props.choices.slice();n[e]=K.extend({},n[e],{clue:t}),""===t&&delete n[e].clue,this.props.onChange({choices:n})})),le(this,"onDelete",((e,t)=>{t.preventDefault();var n=this.props.choices.slice(),r=n[e];n.splice(e,1),this.props.onChange({choices:n,hasNoneOfTheAbove:this.props.hasNoneOfTheAbove&&!r.isNoneOfTheAbove})})),le(this,"addChoice",((e,t)=>{t.preventDefault();var n=this.props.choices.slice(),r={isNoneOfTheAbove:e},a=n.length-(this.props.hasNoneOfTheAbove?1:0);n.splice(a,0,r),this.props.onChange({choices:n,hasNoneOfTheAbove:e||this.props.hasNoneOfTheAbove},(()=>{this.refs["choice-editor".concat(a)].refs["content-editor"].focus()}))})),le(this,"setDisplayCount",(e=>{this.props.onChange({displayCount:e})})),le(this,"focus",(()=>(this.refs["choice-editor0"].refs["content-editor"].focus(),!0))),le(this,"getSaveWarnings",(()=>K.some(K.pluck(this.props.choices,"correct"))?[]:["No choice is marked as correct."])),le(this,"serialize",(()=>K.pick(this.props,"choices","randomize","multipleSelect","countChoices","displayCount","hasNoneOfTheAbove","deselectEnabled")))}render(){var e=K.reduce(this.props.choices,(function(e,t){return t.correct?e+1:e}),0);return G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement("a",{href:"https://docs.google.com/document/d/1frZf7yrWVWb1n4tVjqlzqVUiv1pn4cZXbxgP62-JDBY/edit#heading=h.8ng1isya19nu",target:"_blank"},"Multiple choice style guide"),G.createElement("br",null),G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(xu,{label:"Multiple selections",labelAlignment:"right",multipleSelect:this.props.multipleSelect,onChange:this.onMultipleSelectChange})),G.createElement("div",{className:"perseus-widget-right-col"},G.createElement(xu,{label:"Randomize order",labelAlignment:"right",randomize:this.props.randomize,onChange:this.props.onChange})),this.props.multipleSelect&&G.createElement("div",{className:"perseus-widget-left-col"},G.createElement(xu,{label:"Specify number correct",labelAlignment:"right",countChoices:this.props.countChoices,onChange:this.onCountChoicesChange}))),G.createElement(W,{ref:"baseRadio",multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:e,editMode:!0,labelWrap:!1,apiOptions:this.props.apiOptions,choices:this.props.choices.map((function(e,t){return{content:G.createElement(Su,{ref:"choice-editor".concat(t),apiOptions:this.props.apiOptions,choice:e,onContentChange:e=>{"content"in e&&this.onContentChange(t,e.content)},onClueChange:e=>{"content"in e&&this.onClueChange(t,e.content)},onDelete:this.onDelete.bind(this,t),showDelete:this.props.choices.length>=2}),isNoneOfTheAbove:e.isNoneOfTheAbove,checked:e.correct}}),this),onChange:this.onChange}),G.createElement("div",{className:"add-choice-container"},G.createElement("a",{className:"simple-button orange",href:"#",onClick:this.addChoice.bind(this,!1)},G.createElement(wu,Cu)," Add a choice"," "),!this.props.hasNoneOfTheAbove&&G.createElement("a",{className:"simple-button",href:"#",onClick:this.addChoice.bind(this,!0)},G.createElement(wu,Cu)," None of the above"," ")))}}le(Nu,"propTypes",oe(oe({},x.propTypes),{},{apiOptions:u.propTypes,choices:J.arrayOf(J.shape({content:J.string,clue:J.string,correct:J.bool})),displayCount:J.number,randomize:J.bool,hasNoneOfTheAbove:J.bool,multipleSelect:J.bool,countChoices:J.bool,deselectEnabled:J.bool,static:J.bool})),le(Nu,"widgetName","radio"),le(Nu,"defaultProps",{choices:[{},{}],displayCount:null,randomize:!1,hasNoneOfTheAbove:!1,multipleSelect:!1,countChoices:!1,deselectEnabled:!1});var{NumberInput:Tu,TextInput:_u}=t;class Ou extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"updateMolecule",(e=>function(t){var n=[...this.props.smiles];n[e]=t,this.change({smiles:n})}.bind(this))),le(this,"updateRotation",(e=>function(t){var n=[...this.props.rotationAngle];n[e]=t,this.change({rotationAngle:n})}.bind(this))),le(this,"updateSeparators",((e,t)=>n=>{var r=this.props.separators.map((e=>oe({},e)));r[e][t]=n,this.change({separators:r})})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("div",null,G.createElement("label",null,"LHS SMILES: ",G.createElement(_u,{onChange:this.updateMolecule(0),value:this.props.smiles[0]}))),G.createElement("div",null,G.createElement("label",null,"LHS Rotation (deg): ",G.createElement(Tu,{onChange:this.updateRotation(0),value:this.props.rotationAngle[0]}))),G.createElement("div",null,G.createElement("label",null,"RHS SMILES: ",G.createElement(_u,{onChange:this.updateMolecule(1),value:this.props.smiles[1]}))),G.createElement("div",null,G.createElement("label",null,"RHS Rotation (deg): ",G.createElement(Tu,{onChange:this.updateRotation(1),value:this.props.rotationAngle[1]}))),G.createElement("div",null,G.createElement("label",null,"Top of arrow text: ",G.createElement(_u,{onChange:this.updateSeparators(0,"topText"),value:this.props.separators[0].topText}))),G.createElement("div",null,G.createElement("label",null,"Bottom of arrow text: ",G.createElement(_u,{onChange:this.updateSeparators(0,"bottomText"),value:this.props.separators[0].bottomText}))))}}le(Ou,"propTypes",oe(oe({},x.propTypes),{},{rotationAngle:J.arrayOf(J.number),separators:J.arrayOf(J.object),smiles:J.arrayOf(J.string)})),le(Ou,"widgetName","reaction-diagram"),le(Ou,"defaultProps",{smiles:["",""],rotationAngle:[0,0],separators:[{type:"right",topText:"",bottomText:""}]});var{InlineIcon:Mu}=t,{iconCircleArrowDown:Au,iconCircleArrowUp:Pu,iconPlus:Du,iconTrash:Iu}=p;class Ru extends G.Component{render(){return G.createElement("a",{href:"#",className:"step-control-button simple-button simple-button--small orange",onClick:e=>{e.preventDefault(),this.props.onClick()}},G.createElement(Mu,this.props.icon))}}class zu extends G.Component{constructor(){super(...arguments),le(this,"_handleEditorChange",((e,t)=>{var n=K.clone(this.props.json);n[e]=K.extend({},n[e],t),this.props.onChange({json:n})})),le(this,"serialize",(()=>({json:K.times(this.props.json.length,(e=>this.refs["editor"+e].serialize()))}))),le(this,"_handleMoveStepEarlier",(e=>{if(0!==e){var t=K.clone(this.props.json),n=t[e];t.splice(e,1),t.splice(e-1,0,n),this.props.onChange({json:t})}})),le(this,"_handleMoveStepLater",(e=>{var t=K.clone(this.props.json);if(e+1!==t.length){var n=t[e];t.splice(e,1),t.splice(e+1,0,n),this.props.onChange({json:t})}})),le(this,"_handleAddStepAfter",(e=>{var t=K.clone(this.props.json),n=e>=0?{widgets:t[e].widgets}:{};t.splice(e+1,0,n),this.props.onChange({json:t})})),le(this,"_handleRemoveStep",(e=>{var t=K.clone(this.props.json);t.splice(e,1),this.props.onChange({json:t})}))}render(){return G.createElement("div",{className:"perseus-sequence-editor"},K.map(this.props.json,((e,t)=>G.createElement("div",{key:t},"Step ",t+1,G.createElement("div",{style:{display:"inline-block",float:"right"}},t+1<this.props.json.length&&G.createElement(Ru,{icon:Au,onClick:()=>{this._handleMoveStepLater(t)}}),t>0&&G.createElement(Ru,{icon:Pu,onClick:()=>{this._handleMoveStepEarlier(t)}}),G.createElement(Ru,{icon:Iu,onClick:()=>{confirm("Are you sure you want to remove step "+(t+1)+"?")&&this._handleRemoveStep(t)}}),G.createElement(Ru,{icon:Du,onClick:()=>{this._handleAddStepAfter(t)}})),G.createElement(Sr,{ref:"editor"+t,apiOptions:this.props.apiOptions,content:e.content,widgets:e.widgets,images:e.images,widgetEnabled:!0,immutableWidgets:!1,onChange:K.partial(this._handleEditorChange,t)})))))}}le(zu,"propTypes",{json:J.arrayOf(J.shape({content:J.string,widgets:J.objectOf(J.any),images:J.objectOf(J.any)})),apiOptions:u.propTypes,onChange:J.func.isRequired}),le(zu,"widgetName","sequence"),le(zu,"defaultProps",{json:[{content:"",widgets:{},images:{}}]});class Lu extends G.Component{constructor(){super(...arguments),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"changeValue",(e=>{this.props.onChange(e.target.value)}))}render(){return G.createElement("textarea",{ref:"input",value:this.props.value||"",onChange:this.changeValue})}}class Fu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,G.createElement("div",null,"Simple markdown contents:"),G.createElement("div",null,G.createElement(Lu,{value:this.props.value,onChange:this.change("value"),ref:"input"}))))}}le(Fu,"propTypes",oe({},x.propTypes)),le(Fu,"widgetName","simple-markdown-tester"),le(Fu,"defaultProps",{value:""});var{InfoTip:qu,NumberInput:Uu}=t;class Wu extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"handleTargetValueChange",((e,t)=>{this.change(e,t.target.value)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",{className:"perseus-widget-simulator"},G.createElement("div",null,se._("X-Axis Label"),":",G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.xAxisLabel,onChange:K.partial(this.handleTargetValueChange,"xAxisLabel")})),G.createElement("div",null,se._("Y-Axis Label"),":",G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.yAxisLabel,onChange:K.partial(this.handleTargetValueChange,"yAxisLabel")})),G.createElement("div",null,se._('"True Proportion" Label'),":",G.createElement("input",{type:"text",className:"graph-settings-axis-label",value:this.props.proportionLabel,onChange:K.partial(this.handleTargetValueChange,"proportionLabel")}),G.createElement(qu,null,G.createElement("p",null,'This text will be displayed next to the box in which the user enters the sample proportion for their simulation. For example, if your question is about surveying for approval ratings, you might want this to say "Sample approval rating".'))),G.createElement("div",null,se._("Proportion or Percentage"),":",G.createElement("select",{className:"perseus-widget-dropdown",value:this.props.proportionOrPercentage,onChange:K.partial(this.handleTargetValueChange,"proportionOrPercentage")},G.createElement("option",{key:"proportion",value:"proportion"},"Proportion"),G.createElement("option",{key:"percentage",value:"percentage"},"Percentage")),G.createElement(qu,null,G.createElement("p",null,"Do you want the user to describe their simulation in terms of a proportion or a percentage?"))),G.createElement("div",null,se._("Number of trials"),":",G.createElement(Uu,{value:this.props.numTrials,checkValidity:e=>e>=0&&e<=5e3,onChange:this.change("numTrials")}),G.createElement(qu,null,G.createElement("p",null,"This controls the number of trials used in the simulation. For example, if you set this to 50, then the survey will be conducted 50 times. Warning: setting this too high (i.e., greater than 5000 or so) will freeze the page."))))}}le(Wu,"propTypes",oe(oe({},x.propTypes),{},{xAxisLabel:J.string,yAxisLabel:J.string,numTrials:J.number,proportionLabel:J.string,proportionOrPercentage:J.string})),le(Wu,"widgetName","simulator"),le(Wu,"defaultProps",{xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",numTrials:100,proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion"});var{InfoTip:Vu,PropCheckBox:ju,TextListEditor:Bu}=t;class $u extends G.Component{constructor(){super(...arguments),le(this,"onLayoutChange",(e=>{this.props.onChange({layout:e.target.value})})),le(this,"serialize",(()=>K.pick(this.props,"correct","layout","padding")))}render(){var e=this;return G.createElement("div",null,G.createElement("div",null," ","Correct answer:"," ",G.createElement(Vu,null,G.createElement("p",null,"Enter the correct answer (in the correct order) here. The preview on the right will have the cards in a randomized order, which is how the student will see them."))),G.createElement(Bu,{options:this.props.correct,onChange:function(t,n){e.props.onChange({correct:t},n)},layout:this.props.layout}),G.createElement("div",null,G.createElement("label",null," ","Layout:"," ",G.createElement("select",{value:this.props.layout,onChange:this.onLayoutChange},G.createElement("option",{value:"horizontal"},"Horizontal"),G.createElement("option",{value:"vertical"},"Vertical"))),G.createElement(Vu,null,G.createElement("p",null,"Use the horizontal layout for short text and small images. The vertical layout is best for longer text and larger images."))),G.createElement("div",null,G.createElement(ju,{label:"Padding:",padding:this.props.padding,onChange:this.props.onChange}),G.createElement(Vu,null,G.createElement("p",null,"Padding is good for text, but not needed for images."))))}}le($u,"propTypes",{correct:J.array,layout:J.oneOf(["horizontal","vertical"]),padding:J.bool}),le($u,"widgetName","sorter"),le($u,"defaultProps",{correct:["$x$","$y$","$z$"],layout:"horizontal",padding:!0});var{InfoTip:Hu,NumberInput:Gu}=t,Yu=V.widget;class Xu extends G.Component{constructor(){super(...arguments),le(this,"focus",(()=>{te.findDOMNode(this.refs.numberOfColumns).focus()})),le(this,"onSizeInput",((e,t)=>{var n=+e||0,a=+t||0;n=Math.min(Math.max(1,n),30),a=Math.min(Math.max(1,a),6);var s=this.props.columns,i=this.props.rows,o=this.props.answers;function l(e){a<=s?e.length=a:K(a-s).times((function(){e.push("")}))}n<=i?o.length=n:K(n-i).times((function(){o.push(r.stringArrayOfSize(s))}));var c=this.props.headers;l(c),K.each(o,l),this.props.onChange({rows:n,columns:a,answers:o,headers:c})})),le(this,"serialize",(()=>{var e=K.pick(this.props,"headers","rows","columns");return K.extend({},e,{answers:K.map(this.props.answers,K.clone)})}))}render(){var e=K.pick(this.props,"headers","answers","onChange","apiOptions");return K.extend(e,{editableHeaders:!0,Editor:Sr,onFocus:()=>{},onBlur:()=>{},trackInteraction:()=>{}}),G.createElement("div",null,G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Number of columns:"," ",G.createElement(Gu,{ref:"numberOfColumns",value:this.props.columns,onChange:e=>{e&&this.onSizeInput(this.props.rows,e)},useArrowKeys:!0}))),G.createElement("div",{className:"perseus-widget-row"},G.createElement("label",null,"Number of rows:"," ",G.createElement(Gu,{ref:"numberOfRows",value:this.props.rows,onChange:e=>{e&&this.onSizeInput(e,this.props.columns)},useArrowKeys:!0}))),G.createElement("div",null," ","Table of answers:"," ",G.createElement(Hu,null,G.createElement("p",null,"The student has to fill out all cells in the table. For partially filled tables create a table using the template, and insert text input boxes as desired."))),G.createElement("div",null,G.createElement(Yu,e)))}}le(Xu,"propTypes",{rows:J.number,columns:J.number,headers:J.arrayOf(J.string),answers:J.arrayOf(J.arrayOf(J.string))}),le(Xu,"widgetName","table"),le(Xu,"defaultProps",{headers:[""],rows:4,columns:1,answers:K(4).times((function(){return r.stringArrayOfSize(1)}))});var{Graph:Ku,InfoTip:Ju,PropCheckBox:Zu}=t,Qu=j.widget,{deepEq:ed,getGridStep:td}=r;var nd={url:null};function rd(e,t){return e=K.clone(e).sort(qi.compare),t=K.clone(t).sort(qi.compare),K.all(K.map(e,(function(e,n){var r=t[n];return qi.equal(e,r)})))}var ad={apiOptions:u.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:[]}};class sd extends G.Component{constructor(){super(...arguments),le(this,"changeConstraints",(e=>{var t=K.extend({},this.props.constraints,e);this.props.onChange({constraints:t})}))}render(){return G.createElement("div",null,this.props.name,":"," ",G.createElement(Zu,{label:"enabled:",enabled:this.props.settings.enabled,onChange:this.props.onChange})," ",this.props.settings.enabled&&G.createElement(Zu,{label:"required:",required:this.props.settings.required,onChange:this.props.onChange}),this.props.settings.enabled&&G.createElement(Ju,null,"'Required' will only grade the answer as correct if the student has used at least one such transformation.")," ",this.props.allowFixed&&this.props.settings.enabled&&G.createElement(Zu,{label:"fixed:",fixed:this.props.settings.constraints.fixed,onChange:this.changeConstraints}),this.props.allowFixed&&this.props.settings.enabled&&G.createElement(Ju,null,"Enable 'fixed' to prevent the student from repositioning the tool. The tool will appear in the position at which it is placed in the editor below."))}}le(sd,"defaultProps",{allowFixed:!0});class id extends G.Component{constructor(){super(...arguments),le(this,"getMode",(()=>this.props.graphMode+","+this.props.listMode)),le(this,"changeMode",(e=>{var t=e.target.value.split(",");this.props.onChange({graphMode:t[0],listMode:t[1]})})),le(this,"changeHandlerFor",(e=>t=>{var n=K.clone(this.props.tools);n[e]=K.extend({},this.props.tools[e],t),this.props.onChange({tools:n})}))}render(){return G.createElement("div",{className:"transformer-settings"},G.createElement("div",null," ","Mode:"," ",G.createElement("select",{value:this.getMode(),onChange:this.changeMode},G.createElement("option",{value:"interactive,dynamic"}," ","Exploration with text"," "),G.createElement("option",{value:"interactive,static"}," ","Exploration without text"," "),G.createElement("option",{value:"dynamic,interactive"}," ","Formal with movement"," "),G.createElement("option",{value:"static,interactive"}," ","Formal without movement"," ")),G.createElement(Ju,null,G.createElement("ul",null,G.createElement("li",null,G.createElement("b",null,"Exploration:")," Students create transformations with tools on the graph."," "),G.createElement("li",null,G.createElement("b",null,"Formal with movement:")," Students specify transformations mathematically in the transformation list. Graph shows the results of these transformations."," "),G.createElement("li",null,G.createElement("b",null,"Formal without movement:")," Students specify transformations mathematically in the transformation list. Graph does not update."," ")))),G.createElement(sd,{name:"Translations",settings:this.props.tools.translation,allowFixed:!1,onChange:this.changeHandlerFor("translation")}),G.createElement(sd,{name:"Rotations",settings:this.props.tools.rotation,onChange:this.changeHandlerFor("rotation")}),G.createElement(sd,{name:"Reflections",settings:this.props.tools.reflection,onChange:this.changeHandlerFor("reflection")}),G.createElement(sd,{name:"Dilations",settings:this.props.tools.dilation,onChange:this.changeHandlerFor("dilation")}),G.createElement(Zu,{label:"Draw Solution:",drawSolutionShape:this.props.drawSolutionShape,onChange:this.props.onChange}))}}var od={getPointCountForType:function(e){var 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 s("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously.",i.InvalidInput,{metadata:{options:t}});var n=K.map(t.shape.coords,(function(a){var s=!1,i=a,o=e.addMovablePoint({coord:a,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,a){s||(i=o.coord,s=!0);var l=Ci.subtract([e,a],o.coord);t.onMove&&(l=t.onMove(l[0],l[1])),t.translatable&&K.each(n,(function(e){e!==o&&e.setCoord(Ci.add(e.coord,l))}));var c=o.coord,p=Ci.add(o.coord,l);return o.coord=p,r.update(),o.coord=c,p},onMoveEnd:function(){if(t.onMoveEnd&&s){s=!1;var e=Ci.subtract(o.coord,i);t.onMoveEnd(e[0],e[1])}r.update()}});return o.bounded=!0,o})),r=od.addShape(e,t,n),a=r.remove;return r.remove=function(){a.apply(r),K.invoke(n,"remove")},r},addShape:function(e,t,n){n=n||t.shape.coords;var r=od._typesOf(t.shape),a=t.shape.options||od.defaultOptions(r),s=od._mapTypes(r,n,(function(n,r,s){var i=K.extend({},t,a[s]);return od._addType(e,n,r,i)})),i=K.filter(K.pluck(s,"update"),K.identity),o=K.filter(K.pluck(s,"remove"),K.identity),l=function(){return K.map(s,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:r,points:n,update:function(){K.invoke(i,"call")},remove:function(){K.invoke(o,"call")},toJSON:function(){var e=K.map(n,(function(e){return K.isArray(e)?e:e.coord}));return{type:r,coords:e,options:l()}},getOptions:l}},equal:function(e,t){var n=od._typesOf(e),r=od._typesOf(t);if(n.length!==r.length)return!1;var a=od._mapTypes(n,e.coords,od._combine),s=od._mapTypes(r,t.coords,od._combine);return K.all(K.map(a,(function(e,t){var n=s[t];return e.type===n.type&&od._forType(e.type).equal(e.coords,n.coords)})))},_typesOf:function(e){var t=e.type;return K.isArray(t)||(t=[t]),K.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return K.map(e,(function(e){var t=od._forType(e).defaultOptions;return K.extend({},t)}))},_forType:function(e){var t=e.split("-")[0];return od[t]},_mapTypes:function(e,t,n,r){return K.map(e,(function(e,a){var s=od.getPointCountForType(e),i=K.first(t,s);return t=K.rest(t,s),n.call(r,e,i,a)}))},_addType:function(e,t,n,r){var a=K.isArray(n[0])?{coordA:n[0],coordZ:n[1]}:{pointA:n[0],pointZ:n[1]};if("polygon"===(t=t.split("-")[0])){var o=e.addMovablePolygon(K.extend({},r,{fixed:!r.editable,snapX:r.snap&&r.snap[0]||0,snapY:r.snap&&r.snap[1]||0,points:n,constrainToGraph:!1}));return{update:o.transform.bind(o),remove:o.remove.bind(o)}}if("line"===t||"lineSegment"===t){var l=e.addMovableLineSegment(K.extend({},r,a,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:l.transform.bind(l,!0),remove:l.remove.bind(l)}}if("angle"===t){var c=!!r.editable&&null,p=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:n,normalStyle:r.normalStyle,reflex:r.reflex});return K.isArray(n[0])||r.editable||(n[0].remove(),n[2].remove()),{update:p.update.bind(p,c),remove:p.remove.bind(p),getOptions:function(){return{reflex:p.isReflex()}}}}if("circle"===t){var h={remove:K.identity},u=function(){var t=n[0].coord||n[0],a=n[1].coord||n[1],s=qi.distanceToPoint(t,a);h.remove(),h=e.circle(t,s,K.extend({stroke:A.DYNAMIC,"stroke-width":2},r.normalStyle))};return u(),n[1].remove&&!r.editable&&n[1].remove(),{update:u,remove:function(){h.remove()}}}if("point"===t)return{update:null,remove:null};throw new s("Invalid shape type "+t,i.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:rd},line:{equal:Ui.equal},lineSegment:{equal:rd},angle:{equal:function(e,t){if(!qi.equal(e[1],t[1]))return!1;var n=[e[1],e[0]],r=[e[1],e[2]],a=[t[1],t[0]],s=[t[1],t[2]],i=Wi.equal(n,a)&&Wi.equal(r,s),o=Wi.equal(n,s)&&Wi.equal(r,a);return i||o},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){var n=qi.distanceToPoint(e[0],e[1]),r=qi.distanceToPoint(t[0],t[1]);return qi.equal(e[0],t[0])&&Js.equal(n,r)}},point:{equal:qi.equal}};class ld extends G.Component{constructor(){super(...arguments),le(this,"getTypeString",(e=>K.isArray(e)?K.map(e,this.getTypeString).join(","):"polygon"===e?"polygon-"+this.props.shape.coords.length:e)),le(this,"changeType",(e=>{var t,n,r,a,s,i=String(e.target.value).split(","),o=(t=K.map(i,od.getPointCountForType),K.reduce(t,(function(e,t){return e+t}),0)),l=(n=4,r=this.refs.graph.props.range,a=r[0][1]-r[0][0],s=r[1][1]-r[1][0],n*Math.max(a,s)/20),c=180*(.5-1/o),p=K.times(o,(function(e){return qi.rotateDeg([l,0],360*e/o+c)}));this.props.onChange({shape:{type:i,coords:p,options:od.defaultOptions(i)}})})),le(this,"updateCoords",(()=>{this.props.onChange({shape:this.shape.toJSON()})})),le(this,"setupGraphie",(e=>{this.shape=od.addMovableShape(e,{editable:!0,snap:e.snap,shape:this.props.shape,onMoveEnd:this.updateCoords})}))}render(){return G.createElement("div",null,G.createElement(Ku,{ref:"graph",box:this.props.graph.box,range:this.props.graph.range,labels:this.props.graph.labels,step:this.props.graph.step,gridStep:this.props.graph.gridStep,markings:this.props.graph.markings,backgroundImage:this.props.graph.backgroundImage,onGraphieUpdated:this.setupGraphie}),G.createElement("select",{key:"type-select",value:this.getTypeString(this.props.shape.type),onChange:this.changeType},G.createElement("option",{value:"polygon-3"},"Triangle"),G.createElement("option",{value:"polygon-4"},"Quadrilateral"),G.createElement("option",{value:"polygon-5"},"Pentagon"),G.createElement("option",{value:"polygon-6"},"Hexagon"),G.createElement("option",{value:"line"},"Line"),G.createElement("option",{value:"line,line"},"2 lines"),G.createElement("option",{value:"lineSegment"},"Line segment"),G.createElement("option",{value:"lineSegment,lineSegment"}," ","2 line segments"," "),G.createElement("option",{value:"angle"},"Angle"),G.createElement("option",{value:"circle"},"Circle")))}componentDidMount(){this.setupGraphie(this.refs.graph.graphie())}componentDidUpdate(e){ed(e.shape,this.props.shape)||this.refs.graph.reset()}}class cd extends G.Component{constructor(){super(...arguments),le(this,"changeGraph",((e,t)=>{var n=K.extend({},this.props.graph,e);this.props.onChange({graph:n},t)})),le(this,"changeStarting",(e=>{var t=K.extend({},this.props.starting,e);this.props.onChange({starting:t})})),le(this,"changeTransformer",((e,t)=>{e.transformations&&(e.correct=oe(oe({},this.props.correct),{},{transformations:e.transformations}),delete e.transformations),this.props.onChange(e,t)})),le(this,"serialize",(()=>{var e=this.refs.explorer.getEditorJSON();return e.correct=e.answer,delete e.answer,e}))}render(){var e,t,n,r,a,s=K.extend((e=this.props.graph,t=340,n=(e=e||{}).labels||["x","y"],r=e.range||[[-10,10],[-10,10]],a=e.step||[1,1],{box:[t,t],labels:n,range:r,step:a,gridStep:e.gridStep||td(r,a,t),valid:!0,backgroundImage:nd,markings:"grid",showProtractor:!1}),this.props.graph);return G.createElement("div",null,G.createElement("div",null,G.createElement(Zu,{label:"Grade empty answers as wrong:",gradeEmpty:this.props.gradeEmpty,onChange:this.props.onChange}),G.createElement(Ju,null,G.createElement("p",null,"We generally do not grade empty answers. This usually works well, but sometimes can result in giving away part of an answer in a multi-part question."),G.createElement("p",null,"If this is a multi-part question (there is another widget), you probably want to enable this option. Otherwise, you should leave it disabled."),G.createElement("p",null,"Confused? Talk to Elizabeth."))),G.createElement("div",null,"Graph settings:"),G.createElement(rl,{box:s.box,labels:s.labels,range:s.range,step:s.step,gridStep:s.gridStep,valid:s.valid,backgroundImage:s.backgroundImage,markings:s.markings,showProtractor:s.showProtractor,onChange:this.changeGraph}),G.createElement("div",null,"Transformation settings:"),G.createElement(id,{ref:"transformationSettings",graphMode:this.props.graphMode,listMode:this.props.listMode,tools:this.props.tools,drawSolutionShape:this.props.drawSolutionShape,onChange:this.props.onChange}),G.createElement("div",null,"Starting location:"),G.createElement(ld,{ref:"shapeEditor",graph:s,shape:this.props.starting.shape,onChange:this.changeStarting,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),G.createElement("div",null,"Solution transformations:"),G.createElement(Qu,{ref:"explorer",graph:s,graphMode:this.props.graphMode,listMode:this.props.listMode,gradeEmpty:this.props.gradeEmpty,tools:this.props.tools,drawSolutionShape:this.props.drawSolutionShape,starting:this.props.starting,correct:this.props.starting,transformations:this.props.correct.transformations,onChange:this.changeTransformer,trackInteraction:()=>{}}))}}le(cd,"defaultProps",ad),le(cd,"widgetName","transformer");var{InlineIcon:pd,NumberInput:hd}=t,{iconOk:ud,iconRemove:dd}=p,md=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()};class gd extends G.Component{constructor(){super(...arguments),le(this,"_checkValidity",(e=>{var{name:t,original:n,sigfigs:r}=e,a=ko(t),s="",i=!0;if(a.parsed&&n){var o=new go("x"),{unit:l}=a,c=new ho(n,"=",new io(o,l));try{s=function(e,t){return B(e,t,-10,!1)}(c.solveLinearEquationForVariable(o).eval(),r),i=function(e,t,n){var r={form:!1,simplify:!1};n=void 0!==n?K.extend(r,n):r;var a,s=e.sameVars(t);return s.equal?e.compare(t)?n.form&&!e.sameForm(t)?{equal:!1,message:"Your answer is not in the correct form."}:n.simplify&&!e.isSimplified()?{equal:!1,message:"Your answer is not fully expanded and simplified."}:{equal:!0,message:null}:{equal:!1,message:null}:(a=s.equalIgnoringCase?"Check your variables; one or more are using the wrong case (upper or lower).":"Check your variables; you may have used the wrong letter for one or more of them.",{equal:!1,wrongVariableCase:s.equalIgnoringCase,wrongVariableNames:!s.equalIgnoringCase,message:a})}(md(n),md(l)).equal}catch(e){i=!1}}else i=!1;this.setState({valid:i,solvedExample:s})}))}UNSAFE_componentWillMount(){this._checkValidity(this.props)}UNSAFE_componentWillReceiveProps(e){this._checkValidity(e)}render(){var e;return e=this.state.valid?G.createElement("span",null,G.createElement("span",{className:"unit-example-okay"},G.createElement(pd,ud)),this.state.solvedExample):G.createElement("span",{className:"unit-example-not-okay"},G.createElement(pd,dd)),G.createElement("div",null,e," ",this.props.name)}}class fd extends G.Component{constructor(e){var t;super(e),t=this,le(this,"parsed",void 0),le(this,"groupId",void 0),le(this,"original",void 0),le(this,"change",(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return x.change.apply(t,n)})),le(this,"handleAcceptingUnitsChange",(e=>{var t=e.target.value.split(",").map((e=>e.trim())).filter((e=>""!==e));this.change({acceptingUnits:t})})),le(this,"handleSigfigChange",(e=>{this.change({sigfigs:e})})),le(this,"_checkSigfigValidity",(e=>e>0&&e<=10)),le(this,"_setAccepting",(e=>{this.change({accepting:e})})),le(this,"_doOriginal",(e=>{var t=ko(e.value);this.parsed=!1,t.parsed&&"unitMagnitude"===t.type&&(this.original=t.expr,this.parsed=!0)})),le(this,"onChange",(e=>{this.props.onChange({value:e.target.value})})),le(this,"getSaveWarnings",(()=>{var{value:e,accepting:t,acceptingUnits:n}=this.props,r=[];return ko(e).parsed||r.push("Answer did not parse"),"some"===t&&0===n.length&&r.push("There are no accepted units"),r})),le(this,"serialize",(()=>C.serialize.call(this))),this.groupId=K.uniqueId("accepting"),this._doOriginal(e)}UNSAFE_componentWillReceiveProps(e){this._doOriginal(e)}render(){var{acceptingUnits:e=[],accepting:t}=this.props,n=null;if("some"===t){var r=e.map(((e,t)=>G.createElement(gd,{name:e,original:this.original||null,sigfigs:this.props.sigfigs,key:t})));n=G.createElement("div",null,G.createElement("input",{type:"text",defaultValue:e.join(", "),onChange:this.handleAcceptingUnitsChange})," ","(comma-separated)",r)}return G.createElement("div",{className:"unit-editor"},G.createElement("div",null,G.createElement("input",{value:this.props.value,className:"unit-editor-canonical",onChange:this.onChange})," ",this.parsed?G.createElement("span",{className:"unit-example-okay"},G.createElement(pd,ud)):G.createElement("span",{className:"unit-example-not-okay"},G.createElement(pd,dd))),G.createElement("div",null,"Significant Figures:"," ",G.createElement(hd,{value:this.props.sigfigs,onChange:this.handleSigfigChange,checkValidity:this._checkSigfigValidity,useArrowKeys:!0})),G.createElement("div",null,G.createElement("label",null,G.createElement("input",{type:"radio",name:this.groupId,onChange:()=>this._setAccepting("all"),checked:"all"===this.props.accepting})," Any equivalent unit "),G.createElement("label",null,G.createElement("input",{type:"radio",name:this.groupId,onChange:()=>this._setAccepting("some"),checked:"some"===this.props.accepting})," Only these units ")),n)}}le(fd,"propTypes",oe(oe({},x.propTypes),{},{value:J.string,acceptingUnits:J.arrayOf(J.string),accepting:J.oneOf(["all","some"]),sigfigs:J.number})),le(fd,"widgetName","unit-input"),le(fd,"defaultProps",{value:"5x10^5 kg m / s^2",accepting:"all",sigfigs:3});var{InfoTip:vd}=t,yd=/khanacademy\.org\/.*\/v\/(.*)$/;function bd(e){var t=yd.exec(e);return t?t[1]:e}class Ed extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"_handleUrlChange",(e=>{this.props.onChange({location:bd(e)})})),le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"serialize",(()=>C.serialize.call(this)))}render(){return G.createElement("div",null,G.createElement("label",null,"KA Video Slug:"," ",G.createElement(Ms,{value:this.props.location,style:{width:290},onChange:this._handleUrlChange}),G.createElement(vd,null,"KA video URLs will be converted to just the slug.")))}}le(Ed,"propTypes",oe(oe({},x.propTypes),{},{location:J.string,onChange:J.func})),le(Ed,"widgetName","video"),le(Ed,"defaultProps",{location:""});var wd=[Os,zs,Fs,js,Gi,Yi,Ki,Wo,Go,Xo,gl,fl,El,_l,Al,Xl,nc,sh,yh,xh,Sh,Ah,Ih,Uh,Qh,nu,su,cu,pu,Eu,Ou,zu,Fu,Wu,$u,Xu,cd,fd,Ed,Nu];class xd extends G.Component{constructor(){super(...arguments),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"changeValue",(e=>{this.props.onChange(e.target.value)}))}render(){return G.createElement("input",{ref:"input",value:this.props.value||"",onChange:this.changeValue})}}class Cd extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"getUserInput",(()=>this.props.value)),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"simpleValidate",(e=>Cd.validate(this.getUserInput(),e)))}static validate(e,t){return""===e?{type:"invalid",message:"It looks like you haven't answered all of the question yet."}:e===t.correct?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}}render(){return G.createElement(xd,{ref:"input",value:this.props.value,onChange:this.change("value")})}}le(Cd,"propTypes",oe(oe({},x.propTypes),{},{value:J.string})),le(Cd,"defaultProps",{value:""});var kd={name:"example-widget",displayName:"Example Widget",defaultAlignment:"inline-block",hidden:!0,widget:Cd},Sd=l.parse,Nd=l.basicOutput;class Td extends G.Component{constructor(){var e;super(...arguments),e=this,le(this,"change",(function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return x.change.apply(e,n)})),le(this,"toJSON",(()=>({}))),le(this,"focus",(()=>(this.refs.input.focus(),!0))),le(this,"simpleValidate",(e=>Td.validate(this.toJSON(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){var e=Sd(this.props.value),t=Nd(e);return G.createElement("div",null,t)}}le(Td,"propTypes",oe(oe({},x.propTypes),{},{value:J.string})),le(Td,"defaultProps",{value:""});var _d=[...$,...[$i,kd,{name:"simple-markdown-tester",displayName:"Simple Markdown Tester",hidden:!0,widget:Td,transform:K.identity}]];n.registerEditors(wd),n.registerWidgets(_d);export{wd as AllEditors,_d as AllWidgets,ma as ArticleDiff,zr as ArticleEditor,ue as DeviceFramer,Sr as Editor,Ra as EditorPage,Or as IframeContentRenderer,fa as ItemDiff,ws as MultiRendererEditor,Cs as StatefulArticleEditor,Ss as StatefulEditorPage,Ea as StructuredItemDiff,jr as ViewportResizer,ja as i18n};
|
|
11
10
|
//# sourceMappingURL=index.js.map
|